Socket
Socket
Sign inDemoInstall

@stoplight/json

Package Overview
Dependencies
Maintainers
1
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stoplight/json - npm Package Compare versions

Comparing version 3.21.3 to 3.21.4

__tests__/bundle.spec.d.ts

2

index.cjs.js

@@ -1,1 +0,1 @@

"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var lodash=require("lodash"),path=require("@stoplight/path"),jsoncParser=require("jsonc-parser"),createOrderedObject=require("@stoplight/ordered-object-literal"),createOrderedObject__default=_interopDefault(createOrderedObject),types=require("@stoplight/types"),fastStringify=_interopDefault(require("safe-stable-stringify"));function isPlainObject(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype||"function"==typeof e.constructor&&Function.toString.call(Object)===Function.toString.call(e.constructor)}function assertResolvableInput(e,t,r){if(!isPlainObject(e)&&!Array.isArray(e)||!(t in e))throw new ReferenceError(`Could not resolve '${r}'`)}function assertObjectWithValidRef(e){if("string"!=typeof e.$ref)throw new TypeError("$ref should be a string")}const hasSomeRef=e=>isPlainObject(e)&&"$ref"in e,hasRef=e=>hasSomeRef(e)&&"string"==typeof e.$ref,isLocalRef=e=>e.length>0&&("#"===e||/^#\S*$/.test(e)),replaceInString=(e,t,r)=>{const n=e.toString();let o="",i=n,a=0,s=i.indexOf(t);for(;s>-1;)o+=n.substring(a,a+s)+r,i=i.substring(s+t.length,i.length),a+=s+t.length,s=i.indexOf(t);return i.length>0&&(o+=n.substring(n.length-i.length,n.length)),o},encodePointerFragment=e=>"number"==typeof e?e:replaceInString(replaceInString(e,"~","~0"),"/","~1"),ENCODABLE_CHAR=/[^a-zA–Z0–9_.!~*'()\/\-\u{D800}-\u{DFFF}]/gu;function encodeUriPointer(e){return e.replace(ENCODABLE_CHAR,encodeURIComponent)}const encodePointerUriFragment=e=>{const t=encodePointerFragment(e);return"number"==typeof t?t:encodeUriPointer(t)},pathToPointer=e=>encodeUriFragmentIdentifier(e),encodeUriFragmentIdentifier=e=>{if(e&&"object"!=typeof e)throw new TypeError("Invalid type: path must be an array of segments.");return 0===e.length?"#":`#/${e.map(encodePointerUriFragment).join("/")}`};function safeDecodeURIComponent(e){try{return decodeURIComponent(e)}catch(t){return e}}const PERCENT_ENCODING_OCTET=/%[0-9a-f]+/gi,decodePointer=e=>{let t;try{t=decodeURIComponent(e)}catch(r){t=e.replace(PERCENT_ENCODING_OCTET,safeDecodeURIComponent)}return replaceInString(replaceInString(t,"~1","/"),"~0","~")},pointerToPath=e=>decodeUriFragmentIdentifier(e),decodeFragmentSegments=e=>{const t=e.length,r=[];let n=-1;for(;++n<t;)r.push(decodePointer(e[n]));return r},decodeUriFragmentIdentifier=e=>{if("string"!=typeof e)throw new TypeError("Invalid type: JSON Pointers are represented as strings.");if(0===e.length||"#"!==e[0])throw new URIError("Invalid JSON Pointer syntax; URI fragment identifiers must begin with a hash.");if(1===e.length)return[];if("/"!==e[1])throw new URIError("Invalid JSON Pointer syntax.");return decodeFragmentSegments(e.substring(2).split("/"))},_traverse=(e,t,r)=>{const n={value:e,path:r};t.onEnter&&t.onEnter(n);const o=e;for(const n of Object.keys(o)){const i=o[n];t.onProperty&&t.onProperty({parent:e,parentPath:r,property:n,propertyValue:i}),"object"==typeof i&&null!==i&&_traverse(i,t,r.concat(n))}t.onLeave&&t.onLeave(n)},traverse=(e,t)=>{"object"==typeof e&&null!==e&&_traverse(e,"function"==typeof t?{onProperty:t}:t,[])};function remapRefs(e,t,r){traverse(e,{onProperty({property:e,propertyValue:n,parent:o}){"$ref"===e&&"string"==typeof n&&n.startsWith(t)&&(o.$ref=`${r}${n.slice(t.length)}`)}})}const isExternalRef=e=>e.length>0&&"#"!==e[0],extractSourceFromRef=e=>{if("string"!=typeof e||0===e.length||!isExternalRef(e))return null;const t=e.indexOf("#");return-1===t?e:e.slice(0,t)};function applyOverrides(e,t){return isPlainObject(t)&&isPlainObject(e)&&("summary"in e||"description"in e)?Object.assign(Object.assign(Object.assign({},t),"description"in e?{description:e.description}:null),"summary"in e?{summary:e.summary}:null):t}function resolveSource(e,t){const r=extractSourceFromRef(t);return null===r?e:path.isAbsolute(r)?r:path.join(path.dirname(e),r)}function*traverse$1(e,t,r){hasSomeRef(e.value)&&(assertObjectWithValidRef(e.value),yield[-1,e.value]);for(const[n,o]of t.entries())assertResolvableInput(e.value,o,r),e.value=e.value[o],hasSomeRef(e.value)&&(assertObjectWithValidRef(e.value),yield[n,e.value])}function _resolveInlineRefWithLocation(e,t,r,n){if(null!==extractSourceFromRef(t))throw new ReferenceError("Cannot resolve external references");const o=pointerToPath(t);let i=[...o];"#"===t&&hasSomeRef(e)&&(assertObjectWithValidRef(e),o.unshift(...pointerToPath(e.$ref)));const a={value:e};for(const[s,c]of traverse$1(a,o,t)){if(r.includes(c))return{source:null,location:null!=n?n:i,value:r[r.length-1]};r.push(c);const t=_resolveInlineRefWithLocation(e,c.$ref,r,i);a.value=t.value,(i=t.location).push(...o.slice(s+1))}return{source:null,location:i,value:r.length>0?applyOverrides(r[r.length-1],a.value):a.value}}function resolveInlineRef(e,t){return resolveInlineRefWithLocation(e,t).value}function resolveInlineRefWithLocation(e,t){return _resolveInlineRefWithLocation(e,t,[])}const BUNDLE_ROOT="#/__bundled__",ERRORS_ROOT="#/__errors__",bundleTarget=({document:e,path:t,bundleRoot:r=BUNDLE_ROOT,errorsRoot:n=ERRORS_ROOT,cloneDocument:o=!0,keyProvider:i},a)=>{if(t===r||t===n)throw new Error("Roots do not make any sense");const s=o?lodash.cloneDeep(e):e;return bundle(s,pointerToPath(r),pointerToPath(n),t,i)(t,{[t]:!0},a)},defaultKeyProvider=({document:e,path:t})=>{if(0===t.length)return"root";if(Array.isArray(lodash.get(e,t.slice(0,-1)))){return`${t[t.length-2]}_${t[t.length-1]}`}return String(t[t.length-1])},bundle=(e,t,r,n,o)=>{const i=new Set,a=(s,c,l,f={},u={},p={})=>{const h=pointerToPath(s),d=lodash.get(e,h);traverse(l||d,{onEnter:({value:r})=>{if(hasRef(r)&&isLocalRef(r.$ref)){const l=r.$ref;if(p[l])return;if(l===s&&(f[l]="#"),f[l])return void(r.$ref=f[l]);let h,d,g,y,P;try{let r;h=pointerToPath(l),o&&(r=o({document:e,path:h})),r||(r=defaultKeyProvider({document:e,path:h})),g=r;let n=1;for(;i.has(g);)if(g=`${r}_${++n}`,n>20)throw new Error(`Keys ${r}_2 through ${r}_20 already taken.`);i.add(g),d=[...t,g],y=pathToPointer(d)}catch(e){p[l]=e instanceof Error?e.message:String(e)}if(!h||!d||!y)return;if("object"==typeof e&&null!==e&&!(P=lodash.get(e,h)))try{P=resolveInlineRef(Object(e),l)}catch(e){}void 0!==P&&(f[l]=y,r.$ref=y,lodash.has(u,d)||(Array.isArray(P)?lodash.set(u,d,new Array(P.length).fill(null)):"object"==typeof P&&lodash.setWith(u,d,{},Object),lodash.set(u,d,P),"#"===l?bundleRootDocument(e,u,pointerToPath(n),d):c[l]||(c[l]=!0,a(s,c,P,f,u,p),c[l]=!1)))}}});const g=lodash.get(u,t);return g&&Object.keys(g).length&&lodash.set(d,t,g),(Object.keys(p).length||lodash.has(e,r))&&lodash.set(d,r,lodash.has(e,r)?lodash.get(e,r):p),d};return a};function bundleRootDocument(e,t,r,n){const o=r.map(e=>`[${JSON.stringify(e)}]`).join(""),i=JSON.parse(JSON.stringify(lodash.omit(Object(e),o))),a={};lodash.set(t,n,i),lodash.set(i,r,a),remapRefs(i,"#",pathToPointer(n)),a.$ref="#"}const decodePointerFragment=e=>replaceInString(replaceInString(e,"~1","/"),"~0","~");function decycle(e,t){const r=new WeakMap,n=[];const o=function e(o,i){if(t&&(o=t(o)),isPlainObject(o)||Array.isArray(o)){const t=r.get(o);if(t)return{$ref:t};if(r.set(o,pathToPointer(i)),Array.isArray(o))return o.map((t,r)=>e(t,[...i,r]));const a={};for(const t in o)Object.prototype.hasOwnProperty.call(o,t)&&(a[t]=e(o[t],[...i,t]));return n.push(o),a}return o}(e,[]);return n.forEach(e=>{r.delete(e)}),o}const encodePointer=e=>replaceInString(replaceInString(e,"~","~0"),"//","/~1"),extractPointerFromRef=e=>{if("string"!=typeof e||0===e.length)return null;const t=e.indexOf("#");return-1===t?null:e.slice(t)},getFirstPrimitiveProperty=e=>{const t=jsoncParser.createScanner(e,!0);if(t.scan(),1!==t.getToken())return;if(t.scan(),2===t.getToken())return;if(10!==t.getToken())throw new SyntaxError("Unexpected character");const r=t.getTokenValue();if(t.scan(),6!==t.getToken())throw new SyntaxError("Colon expected");switch(t.scan(),t.getToken()){case 10:return[r,t.getTokenValue()];case 11:return[r,Number(t.getTokenValue())];case 8:return[r,!0];case 9:return[r,!1];case 7:return[r,null];case 16:throw new SyntaxError("Unexpected character");case 17:throw new SyntaxError("Unexpected end of file");default:return}},getJsonPathForPosition=({lineMap:e,ast:t},r)=>{const n=e[r.line],o=e[r.line+1];if(void 0===n)return;const i=jsoncParser.findNodeAtOffset(t,void 0===o?n+r.character:Math.min(o,n+r.character),!0);if(void 0===i)return;const a=jsoncParser.getNodePath(i);return 0!==a.length?a:void 0};function getLastPathSegment(e){return decodePointerFragment(e.split("/").pop()||"")}const getLocationForJsonPath=({ast:e},t,r=!1)=>{const n=findNodeAtPath(e,t,r);if(void 0!==n&&void 0!==n.range)return{range:n.range}};function findNodeAtPath(e,t,r){e:for(const n of t){const t=Number.isInteger(Number(n))?Number(n):n;if("string"==typeof t||"number"==typeof t&&"array"!==e.type){if("object"!==e.type||!Array.isArray(e.children))return r?e:void 0;for(const r of e.children)if(Array.isArray(r.children)&&r.children[0].value===String(t)&&2===r.children.length){e=r.children[1];continue e}return r?e:void 0}if("array"!==e.type||t<0||!Array.isArray(e.children)||t>=e.children.length)return r?e:void 0;e=e.children[t]}return e}const parseWithPointers=(e,t={disallowComments:!0})=>{const r=[],{ast:n,data:o,lineMap:i}=parseTree(e,r,t);return{data:o,diagnostics:r,ast:n,lineMap:i}};function parseTree(e,t=[],r){const n=computeLineMap(e);let o={type:"array",offset:-1,length:-1,children:[],parent:void 0},i=null,a=[];const s=new WeakMap,c=[];function l(e){"property"===o.type&&(o.length=e-o.offset,o=o.parent)}function f(e,t,r){return{start:{line:e,character:t},end:{line:e,character:t+r}}}function u(e){return o.children.push(e),e}function p(e){Array.isArray(a)?a.push(e):null!==i&&(a[i]=e)}function h(e){p(e),c.push(a),a=e,i=null}function d(){a=c.pop()}const g={onObjectBegin:(e,t,n,i)=>{o=u({type:"object",offset:e,length:-1,parent:o,children:[],range:f(n,i,t)}),!1===r.ignoreDuplicateKeys&&s.set(o,[]),h(createObjectLiteral(!0===r.preserveKeyOrder))},onObjectProperty:(e,n,c,l,p)=>{if((o=u({type:"property",offset:n,length:-1,parent:o,children:[]})).children.push({type:"string",value:e,offset:n,length:c,parent:o}),!1===r.ignoreDuplicateKeys){const r=s.get(o.parent);r&&(0!==r.length&&r.includes(e)?t.push({range:f(l,p,c),message:"DuplicateKey",severity:types.DiagnosticSeverity.Error,path:getJsonPath(o),code:20}):r.push(e))}!0===r.preserveKeyOrder&&swapKey(a,e),i=e},onObjectEnd:(e,t,n,i)=>{!1===r.ignoreDuplicateKeys&&s.delete(o),o.length=e+t-o.offset,o.range&&(o.range.end.line=n,o.range.end.character=i+t),o=o.parent,l(e+t),d()},onArrayBegin:(e,t,r,n)=>{o=u({type:"array",offset:e,length:-1,parent:o,children:[],range:f(r,n,t)}),h([])},onArrayEnd:(e,t,r,n)=>{o.length=e+t-o.offset,o.range&&(o.range.end.line=r,o.range.end.character=n+t),o=o.parent,l(e+t),d()},onLiteralValue:(e,t,r,n,i)=>{u({type:getLiteralNodeType(e),offset:t,length:r,parent:o,value:e,range:f(n,i,r)}),l(t+r),p(e)},onSeparator:(e,t)=>{"property"===o.type&&(":"===e?o.colonOffset=t:","===e&&l(t))},onError:(e,r,n,o,i)=>{t.push({range:f(o,i,n),message:jsoncParser.printParseErrorCode(e),severity:types.DiagnosticSeverity.Error,code:e})}};jsoncParser.visit(e,g,r);const y=o.children[0];return y&&delete y.parent,{ast:y,data:a[0],lineMap:n}}function getLiteralNodeType(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";default:return"null"}}const computeLineMap=e=>{const t=[0];let r=0;for(;r<e.length;r++)"\n"===e[r]&&t.push(r+1);return t.push(r+1),t};function getJsonPath(e,t=[]){return"property"===e.type&&t.unshift(e.children[0].value),void 0!==e.parent?("array"===e.parent.type&&void 0!==e.parent.parent&&t.unshift(e.parent.children.indexOf(e)),getJsonPath(e.parent,t)):t}function createObjectLiteral(e){return e?createOrderedObject__default({}):{}}function swapKey(e,t){if(!(t in e))return;const r=createOrderedObject.getOrder(e),n=r.indexOf(t);-1!==n&&(r.splice(n,1),r.push(t))}const renameObjectKey=(e,t,r)=>{if(!e||!Object.hasOwnProperty.call(e,t)||t===r)return e;const n={};for(const[o,i]of Object.entries(e))o===t?n[r]=i:o in n||(n[o]=i);return n};function isObject(e){return isPlainObject(e)||Array.isArray(e)}function reparentBundleTarget(e,t,r){if(r.length<=1||t.length<=1)throw Error("Source/target path must not be empty and point at root");if(0===t.indexOf(r))throw Error("Target path cannot be contained within source");const n=pointerToPath(t);let o=e;for(const e of n){if(!isObject(o))return;o=o[e]}if(!isObject(o))return;const i=pointerToPath(r);let a=e;for(const[e,t]of i.entries()){if(!isObject(a)||t in a)return;const r=e===i.length-1?o:{};a[t]=r,a=r}delete e[n[0]],_reparentBundleTarget(e,t,r)}function _reparentBundleTarget(e,t,r){for(const[n,o]of Object.entries(e))if("$ref"!==n)isObject(o)&&_reparentBundleTarget(o,t,r);else{if("string"!=typeof o||!isLocalRef(o))continue;0===o.indexOf(t)&&(e[n]=o.replace(t,r))}}async function _resolveExternalRefWithLocation(e,t,r,n,o){let i=resolveSource(t,r);const a=extractPointerFromRef(r)||"#",s=await e[i],c=pointerToPath(a);let l=[...c];const f={value:s};for(const[r,s]of traverse$1(f,c,a)){if(n.includes(s))return{source:t,location:null!=o?o:l,value:n[n.length-1]};n.push(s);const a=await _resolveExternalRefWithLocation(e,i,s.$ref,n,l);({source:i,location:l}=a),f.value=a.value,l.push(...c.slice(r+1))}return{source:i,location:l,value:n.length>0?applyOverrides(n[n.length-1],f.value):f.value}}async function resolveExternalRef(e,t,r){return(await resolveExternalRefWithLocation(e,t,r)).value}function resolveExternalRefWithLocation(e,t,r){return _resolveExternalRefWithLocation(e,t,r,[])}const safeParse=(e,t)=>{if("string"!=typeof e)return e;try{const r=parseNumber(e);return"string"==typeof r?r:JSON.parse(e,t)}catch(e){return}},parseNumber=e=>{const t=Number(e);return Number.isFinite(t)?String(t)===e?t:e:NaN},safeStringify=(e,t,r)=>{if("string"==typeof e)return e;try{return JSON.stringify(e,t,r)}catch(n){return fastStringify(e,t,r)}},startsWith=(e,t)=>{if(e instanceof Array){if(t instanceof Array){if(t.length>e.length)return!1;for(const r in t){if(!t.hasOwnProperty(r))continue;const n=parseInt(e[r]),o=parseInt(t[r]);if(isNaN(n)&&isNaN(o)){if(e[r]!==t[r])return!1}else if(n!==o)return!1}}}else{if("string"!=typeof e)return!1;if("string"==typeof t)return e.startsWith(t)}return!0},stringify=(e,t,r)=>{const n=safeStringify(e,t,r);if(void 0===n)throw new Error("The value could not be stringified");return n};function toPropertyPath(e){return e.replace(/^(\/|#\/)/,"").split("/").map(decodePointerFragment).map(sanitize).join(".")}function sanitize(e){return e.includes(".")?`["${e.replace(/"/g,'\\"')}"]`:e}const KEYS=Symbol.for(createOrderedObject.ORDER_KEY_ID),trapAccess=e=>new Proxy(e,{ownKeys:e=>"object"==typeof e&&null!==e&&KEYS in e?e[KEYS]:Reflect.ownKeys(e)});function trimStart(e,t){if("string"==typeof e&&"string"==typeof t)return lodash.trimStart(e,t);if(!(e&&Array.isArray(e)&&e.length&&t&&Array.isArray(t)&&t.length))return e;let r=0;for(const n in e)if(e.hasOwnProperty(n)){if(e[n]!==t[n])break;r++}return e.slice(r)}exports.BUNDLE_ROOT=BUNDLE_ROOT,exports.ERRORS_ROOT=ERRORS_ROOT,exports.KEYS=KEYS,exports.bundleTarget=bundleTarget,exports.decodePointer=decodePointer,exports.decodePointerFragment=decodePointerFragment,exports.decodePointerUriFragment=decodePointer,exports.decycle=decycle,exports.encodePointer=encodePointer,exports.encodePointerFragment=encodePointerFragment,exports.encodePointerUriFragment=encodePointerUriFragment,exports.encodeUriPointer=encodeUriPointer,exports.extractPointerFromRef=extractPointerFromRef,exports.extractSourceFromRef=extractSourceFromRef,exports.getFirstPrimitiveProperty=getFirstPrimitiveProperty,exports.getJsonPathForPosition=getJsonPathForPosition,exports.getLastPathSegment=getLastPathSegment,exports.getLocationForJsonPath=getLocationForJsonPath,exports.hasRef=hasRef,exports.isExternalRef=isExternalRef,exports.isLocalRef=isLocalRef,exports.isPlainObject=isPlainObject,exports.parseTree=parseTree,exports.parseWithPointers=parseWithPointers,exports.pathToPointer=pathToPointer,exports.pointerToPath=pointerToPath,exports.remapRefs=remapRefs,exports.renameObjectKey=renameObjectKey,exports.reparentBundleTarget=reparentBundleTarget,exports.resolveExternalRef=resolveExternalRef,exports.resolveExternalRefWithLocation=resolveExternalRefWithLocation,exports.resolveInlineRef=resolveInlineRef,exports.resolveInlineRefWithLocation=resolveInlineRefWithLocation,exports.safeParse=safeParse,exports.safeStringify=safeStringify,exports.startsWith=startsWith,exports.stringify=stringify,exports.toPropertyPath=toPropertyPath,exports.trapAccess=trapAccess,exports.traverse=traverse,exports.trimStart=trimStart;
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var lodash=require("lodash"),path=require("@stoplight/path"),jsoncParser=require("jsonc-parser"),createOrderedObject=require("@stoplight/ordered-object-literal"),createOrderedObject__default=_interopDefault(createOrderedObject),types=require("@stoplight/types"),fastStringify=_interopDefault(require("safe-stable-stringify"));function isPlainObject(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype||"function"==typeof e.constructor&&Function.toString.call(Object)===Function.toString.call(e.constructor)}function assertResolvableInput(e,t,r){if(!isPlainObject(e)&&!Array.isArray(e)||!(t in e))throw new ReferenceError(`Could not resolve '${r}'`)}function assertObjectWithValidRef(e){if("string"!=typeof e.$ref)throw new TypeError("$ref should be a string")}const hasSomeRef=e=>isPlainObject(e)&&"$ref"in e,hasRef=e=>hasSomeRef(e)&&"string"==typeof e.$ref,isLocalRef=e=>e.length>0&&("#"===e||/^#\S*$/.test(e)),replaceInString=(e,t,r)=>{const n=e.toString();let o="",i=n,a=0,s=i.indexOf(t);for(;s>-1;)o+=n.substring(a,a+s)+r,i=i.substring(s+t.length,i.length),a+=s+t.length,s=i.indexOf(t);return i.length>0&&(o+=n.substring(n.length-i.length,n.length)),o},encodePointerFragment=e=>"number"==typeof e?e:replaceInString(replaceInString(e,"~","~0"),"/","~1"),ENCODABLE_CHAR=/[^a-zA–Z0–9_.!~*'()\/\-\u{D800}-\u{DFFF}]/gu;function encodeUriPointer(e){return e.replace(ENCODABLE_CHAR,encodeURIComponent)}const encodePointerUriFragment=e=>{const t=encodePointerFragment(e);return"number"==typeof t?t:encodeUriPointer(t)},pathToPointer=e=>encodeUriFragmentIdentifier(e),encodeUriFragmentIdentifier=e=>{if(e&&"object"!=typeof e)throw new TypeError("Invalid type: path must be an array of segments.");return 0===e.length?"#":`#/${e.map(encodePointerUriFragment).join("/")}`};function safeDecodeURIComponent(e){try{return decodeURIComponent(e)}catch(t){return e}}const PERCENT_ENCODING_OCTET=/%[0-9a-f]+/gi,decodePointer=e=>{let t;try{t=decodeURIComponent(e)}catch(r){t=e.replace(PERCENT_ENCODING_OCTET,safeDecodeURIComponent)}return replaceInString(replaceInString(t,"~1","/"),"~0","~")},pointerToPath=e=>decodeUriFragmentIdentifier(e),decodeFragmentSegments=e=>{const t=e.length,r=[];let n=-1;for(;++n<t;)r.push(decodePointer(e[n]));return r},decodeUriFragmentIdentifier=e=>{if("string"!=typeof e)throw new TypeError("Invalid type: JSON Pointers are represented as strings.");if(0===e.length||"#"!==e[0])throw new URIError("Invalid JSON Pointer syntax; URI fragment identifiers must begin with a hash.");if(1===e.length)return[];if("/"!==e[1])throw new URIError("Invalid JSON Pointer syntax.");return decodeFragmentSegments(e.substring(2).split("/"))},_traverse=(e,t,r)=>{const n={value:e,path:r};t.onEnter&&t.onEnter(n);for(const n of Object.keys(e)){const o=e[n];t.onProperty&&t.onProperty({parent:e,parentPath:r,property:n,propertyValue:o}),"object"==typeof o&&null!==o&&_traverse(o,t,r.concat(n))}t.onLeave&&t.onLeave(n)},traverse=(e,t)=>{"object"==typeof e&&null!==e&&_traverse(e,"function"==typeof t?{onProperty:t}:t,[])};function remapRefs(e,t,r){traverse(e,{onProperty({property:e,propertyValue:n,parent:o}){"$ref"===e&&"string"==typeof n&&n.startsWith(t)&&(o.$ref=`${r}${n.slice(t.length)}`)}})}const isExternalRef=e=>e.length>0&&"#"!==e[0],extractSourceFromRef=e=>{if("string"!=typeof e||0===e.length||!isExternalRef(e))return null;const t=e.indexOf("#");return-1===t?e:e.slice(0,t)};function applyOverrides(e,t){return isPlainObject(t)&&isPlainObject(e)&&("summary"in e||"description"in e)?Object.assign(Object.assign(Object.assign({},t),"description"in e?{description:e.description}:null),"summary"in e?{summary:e.summary}:null):t}function resolveSource(e,t){const r=extractSourceFromRef(t);return null===r?e:path.isAbsolute(r)?r:path.join(path.dirname(e),r)}function*traverse$1(e,t,r){hasSomeRef(e.value)&&(assertObjectWithValidRef(e.value),yield[-1,e.value]);for(const[n,o]of t.entries())assertResolvableInput(e.value,o,r),e.value=e.value[o],hasSomeRef(e.value)&&(assertObjectWithValidRef(e.value),yield[n,e.value])}function _resolveInlineRefWithLocation(e,t,r,n){if(null!==extractSourceFromRef(t))throw new ReferenceError("Cannot resolve external references");const o=pointerToPath(t);let i=[...o];"#"===t&&hasSomeRef(e)&&(assertObjectWithValidRef(e),o.unshift(...pointerToPath(e.$ref)));const a={value:e};for(const[s,c]of traverse$1(a,o,t)){if(r.includes(c))return{source:null,location:null!=n?n:i,value:r[r.length-1]};r.push(c);const t=_resolveInlineRefWithLocation(e,c.$ref,r,i);a.value=t.value,(i=t.location).push(...o.slice(s+1))}return{source:null,location:i,value:r.length>0?applyOverrides(r[r.length-1],a.value):a.value}}function resolveInlineRef(e,t){return resolveInlineRefWithLocation(e,t).value}function resolveInlineRefWithLocation(e,t){return _resolveInlineRefWithLocation(e,t,[])}const BUNDLE_ROOT="#/__bundled__",ERRORS_ROOT="#/__errors__",bundleTarget=({document:e,path:t,bundleRoot:r=BUNDLE_ROOT,errorsRoot:n=ERRORS_ROOT,cloneDocument:o=!0,keyProvider:i},a)=>{if(t===r||t===n)throw new Error("Roots do not make any sense");const s=o?lodash.cloneDeep(e):e;return bundle(s,pointerToPath(r),pointerToPath(n),t,i)(t,{[t]:!0},a)},defaultKeyProvider=({document:e,path:t})=>{if(0===t.length)return"root";if(Array.isArray(lodash.get(e,t.slice(0,-1)))){return`${t[t.length-2]}_${t[t.length-1]}`}return String(t[t.length-1])},bundle=(e,t,r,n,o)=>{const i=new Set,a=(s,c,l,f={},u={},p={})=>{const h=pointerToPath(s),d=lodash.get(e,h);traverse(l||d,{onEnter:({value:r})=>{if(hasRef(r)&&isLocalRef(r.$ref)){const l=r.$ref;if(p[l])return;if(l===s&&(f[l]="#"),f[l])return void(r.$ref=f[l]);let h,d,g,y,P;try{let r;h=pointerToPath(l),o&&(r=o({document:e,path:h})),r||(r=defaultKeyProvider({document:e,path:h})),g=r;let n=1;for(;i.has(g);)if(g=`${r}_${++n}`,n>20)throw new Error(`Keys ${r}_2 through ${r}_20 already taken.`);i.add(g),d=[...t,g],y=pathToPointer(d)}catch(e){p[l]=e instanceof Error?e.message:String(e)}if(!h||!d||!y)return;if("object"==typeof e&&null!==e&&!(P=lodash.get(e,h)))try{P=resolveInlineRef(Object(e),l)}catch(e){}void 0!==P&&(f[l]=y,r.$ref=y,lodash.has(u,d)||(Array.isArray(P)?lodash.set(u,d,new Array(P.length).fill(null)):"object"==typeof P&&lodash.setWith(u,d,{},Object),lodash.set(u,d,P),"#"===l?bundleRootDocument(e,u,pointerToPath(n),d):c[l]||(c[l]=!0,a(s,c,P,f,u,p),c[l]=!1)))}}});const g=lodash.get(u,t);return g&&Object.keys(g).length&&lodash.set(d,t,g),(Object.keys(p).length||lodash.has(e,r))&&lodash.set(d,r,lodash.has(e,r)?lodash.get(e,r):p),d};return a};function bundleRootDocument(e,t,r,n){const o=r.map(e=>`[${JSON.stringify(e)}]`).join(""),i=JSON.parse(JSON.stringify(lodash.omit(Object(e),o))),a={};lodash.set(t,n,i),lodash.set(i,r,a),remapRefs(i,"#",pathToPointer(n)),a.$ref="#"}const decodePointerFragment=e=>replaceInString(replaceInString(e,"~1","/"),"~0","~");function decycle(e,t){const r=new WeakMap;return function e(n,o){if(t&&(n=t(n)),isPlainObject(n)||Array.isArray(n)){const t=r.get(n);if(t)return{$ref:t};if(r.set(n,pathToPointer(o)),Array.isArray(n))return n.map((t,r)=>e(t,[...o,r]));const i={};for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(i[t]=e(n[t],[...o,t]));return r.delete(n),i}return n}(e,[])}const encodePointer=e=>replaceInString(replaceInString(e,"~","~0"),"//","/~1"),extractPointerFromRef=e=>{if("string"!=typeof e||0===e.length)return null;const t=e.indexOf("#");return-1===t?null:e.slice(t)},getFirstPrimitiveProperty=e=>{const t=jsoncParser.createScanner(e,!0);if(t.scan(),1!==t.getToken())return;if(t.scan(),2===t.getToken())return;if(10!==t.getToken())throw new SyntaxError("Unexpected character");const r=t.getTokenValue();if(t.scan(),6!==t.getToken())throw new SyntaxError("Colon expected");switch(t.scan(),t.getToken()){case 10:return[r,t.getTokenValue()];case 11:return[r,Number(t.getTokenValue())];case 8:return[r,!0];case 9:return[r,!1];case 7:return[r,null];case 16:throw new SyntaxError("Unexpected character");case 17:throw new SyntaxError("Unexpected end of file");default:return}},getJsonPathForPosition=({lineMap:e,ast:t},r)=>{const n=e[r.line],o=e[r.line+1];if(void 0===n)return;const i=jsoncParser.findNodeAtOffset(t,void 0===o?n+r.character:Math.min(o,n+r.character),!0);if(void 0===i)return;const a=jsoncParser.getNodePath(i);return 0!==a.length?a:void 0};function getLastPathSegment(e){return decodePointerFragment(e.split("/").pop()||"")}const getLocationForJsonPath=({ast:e},t,r=!1)=>{const n=findNodeAtPath(e,t,r);if(void 0!==n&&void 0!==n.range)return{range:n.range}};function findNodeAtPath(e,t,r){e:for(const n of t){const t=Number.isInteger(Number(n))?Number(n):n;if("string"==typeof t||"number"==typeof t&&"array"!==e.type){if("object"!==e.type||!Array.isArray(e.children))return r?e:void 0;for(const r of e.children)if(Array.isArray(r.children)&&r.children[0].value===String(t)&&2===r.children.length){e=r.children[1];continue e}return r?e:void 0}if("array"!==e.type||t<0||!Array.isArray(e.children)||t>=e.children.length)return r?e:void 0;e=e.children[t]}return e}const parseWithPointers=(e,t={disallowComments:!0})=>{const r=[],{ast:n,data:o,lineMap:i}=parseTree(e,r,t);return{data:o,diagnostics:r,ast:n,lineMap:i}};function parseTree(e,t=[],r){const n=computeLineMap(e);let o={type:"array",offset:-1,length:-1,children:[],parent:void 0},i=null,a=[];const s=new WeakMap,c=[];function l(e){"property"===o.type&&(o.length=e-o.offset,o=o.parent)}function f(e,t,r){return{start:{line:e,character:t},end:{line:e,character:t+r}}}function u(e){return o.children.push(e),e}function p(e){Array.isArray(a)?a.push(e):null!==i&&(a[i]=e)}function h(e){p(e),c.push(a),a=e,i=null}function d(){a=c.pop()}const g={onObjectBegin:(e,t,n,i)=>{o=u({type:"object",offset:e,length:-1,parent:o,children:[],range:f(n,i,t)}),!1===r.ignoreDuplicateKeys&&s.set(o,[]),h(createObjectLiteral(!0===r.preserveKeyOrder))},onObjectProperty:(e,n,c,l,p)=>{if((o=u({type:"property",offset:n,length:-1,parent:o,children:[]})).children.push({type:"string",value:e,offset:n,length:c,parent:o}),!1===r.ignoreDuplicateKeys){const r=s.get(o.parent);r&&(0!==r.length&&r.includes(e)?t.push({range:f(l,p,c),message:"DuplicateKey",severity:types.DiagnosticSeverity.Error,path:getJsonPath(o),code:20}):r.push(e))}!0===r.preserveKeyOrder&&swapKey(a,e),i=e},onObjectEnd:(e,t,n,i)=>{!1===r.ignoreDuplicateKeys&&s.delete(o),o.length=e+t-o.offset,o.range&&(o.range.end.line=n,o.range.end.character=i+t),o=o.parent,l(e+t),d()},onArrayBegin:(e,t,r,n)=>{o=u({type:"array",offset:e,length:-1,parent:o,children:[],range:f(r,n,t)}),h([])},onArrayEnd:(e,t,r,n)=>{o.length=e+t-o.offset,o.range&&(o.range.end.line=r,o.range.end.character=n+t),o=o.parent,l(e+t),d()},onLiteralValue:(e,t,r,n,i)=>{u({type:getLiteralNodeType(e),offset:t,length:r,parent:o,value:e,range:f(n,i,r)}),l(t+r),p(e)},onSeparator:(e,t)=>{"property"===o.type&&(":"===e?o.colonOffset=t:","===e&&l(t))},onError:(e,r,n,o,i)=>{t.push({range:f(o,i,n),message:jsoncParser.printParseErrorCode(e),severity:types.DiagnosticSeverity.Error,code:e})}};jsoncParser.visit(e,g,r);const y=o.children[0];return y&&delete y.parent,{ast:y,data:a[0],lineMap:n}}function getLiteralNodeType(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";default:return"null"}}const computeLineMap=e=>{const t=[0];let r=0;for(;r<e.length;r++)"\n"===e[r]&&t.push(r+1);return t.push(r+1),t};function getJsonPath(e,t=[]){return"property"===e.type&&t.unshift(e.children[0].value),void 0!==e.parent?("array"===e.parent.type&&void 0!==e.parent.parent&&t.unshift(e.parent.children.indexOf(e)),getJsonPath(e.parent,t)):t}function createObjectLiteral(e){return e?createOrderedObject__default({}):{}}function swapKey(e,t){if(!(t in e))return;const r=createOrderedObject.getOrder(e),n=r.indexOf(t);-1!==n&&(r.splice(n,1),r.push(t))}const renameObjectKey=(e,t,r)=>{if(!e||!Object.hasOwnProperty.call(e,t)||t===r)return e;const n={};for(const[o,i]of Object.entries(e))o===t?n[r]=i:o in n||(n[o]=i);return n};function isObject(e){return isPlainObject(e)||Array.isArray(e)}function reparentBundleTarget(e,t,r){if(r.length<=1||t.length<=1)throw Error("Source/target path must not be empty and point at root");if(0===t.indexOf(r))throw Error("Target path cannot be contained within source");const n=pointerToPath(t);let o=e;for(const e of n){if(!isObject(o))return;o=o[e]}if(!isObject(o))return;const i=pointerToPath(r);let a=e;for(const[e,t]of i.entries()){if(!isObject(a)||t in a)return;const r=e===i.length-1?o:{};a[t]=r,a=r}delete e[n[0]],_reparentBundleTarget(e,t,r)}function _reparentBundleTarget(e,t,r){for(const n of Object.keys(e)){const o=e[n];if("$ref"!==n)isObject(o)&&_reparentBundleTarget(o,t,r);else{if("string"!=typeof o||!isLocalRef(o))continue;0===o.indexOf(t)&&(e[n]=o.replace(t,r))}}}async function _resolveExternalRefWithLocation(e,t,r,n,o){let i=resolveSource(t,r);const a=extractPointerFromRef(r)||"#",s=await e[i],c=pointerToPath(a);let l=[...c];const f={value:s};for(const[r,s]of traverse$1(f,c,a)){if(n.includes(s))return{source:t,location:null!=o?o:l,value:n[n.length-1]};n.push(s);const a=await _resolveExternalRefWithLocation(e,i,s.$ref,n,l);({source:i,location:l}=a),f.value=a.value,l.push(...c.slice(r+1))}return{source:i,location:l,value:n.length>0?applyOverrides(n[n.length-1],f.value):f.value}}async function resolveExternalRef(e,t,r){return(await resolveExternalRefWithLocation(e,t,r)).value}function resolveExternalRefWithLocation(e,t,r){return _resolveExternalRefWithLocation(e,t,r,[])}const safeParse=(e,t)=>{if("string"!=typeof e)return e;try{const r=parseNumber(e);return"string"==typeof r?r:JSON.parse(e,t)}catch(e){return}},parseNumber=e=>{const t=Number(e);return Number.isFinite(t)?String(t)===e?t:e:NaN},safeStringify=(e,t,r)=>{if("string"==typeof e)return e;try{return JSON.stringify(e,t,r)}catch(n){return fastStringify(e,t,r)}},startsWith=(e,t)=>{if(e instanceof Array){if(t instanceof Array){if(t.length>e.length)return!1;for(const r in t){if(!t.hasOwnProperty(r))continue;const n=parseInt(e[r]),o=parseInt(t[r]);if(isNaN(n)&&isNaN(o)){if(e[r]!==t[r])return!1}else if(n!==o)return!1}}}else{if("string"!=typeof e)return!1;if("string"==typeof t)return e.startsWith(t)}return!0},stringify=(e,t,r)=>{const n=safeStringify(e,t,r);if(void 0===n)throw new Error("The value could not be stringified");return n};function toPropertyPath(e){return e.replace(/^(\/|#\/)/,"").split("/").map(decodePointerFragment).map(sanitize).join(".")}function sanitize(e){return e.includes(".")?`["${e.replace(/"/g,'\\"')}"]`:e}const KEYS=Symbol.for(createOrderedObject.ORDER_KEY_ID),traps={ownKeys:e=>KEYS in e?e[KEYS]:Reflect.ownKeys(e)},trapAccess=e=>new Proxy(e,traps);function trimStart(e,t){if("string"==typeof e&&"string"==typeof t)return lodash.trimStart(e,t);if(!(e&&Array.isArray(e)&&e.length&&t&&Array.isArray(t)&&t.length))return e;let r=0;for(const n in e)if(e.hasOwnProperty(n)){if(e[n]!==t[n])break;r++}return e.slice(r)}exports.BUNDLE_ROOT=BUNDLE_ROOT,exports.ERRORS_ROOT=ERRORS_ROOT,exports.KEYS=KEYS,exports.bundleTarget=bundleTarget,exports.decodePointer=decodePointer,exports.decodePointerFragment=decodePointerFragment,exports.decodePointerUriFragment=decodePointer,exports.decycle=decycle,exports.encodePointer=encodePointer,exports.encodePointerFragment=encodePointerFragment,exports.encodePointerUriFragment=encodePointerUriFragment,exports.encodeUriPointer=encodeUriPointer,exports.extractPointerFromRef=extractPointerFromRef,exports.extractSourceFromRef=extractSourceFromRef,exports.getFirstPrimitiveProperty=getFirstPrimitiveProperty,exports.getJsonPathForPosition=getJsonPathForPosition,exports.getLastPathSegment=getLastPathSegment,exports.getLocationForJsonPath=getLocationForJsonPath,exports.hasRef=hasRef,exports.isExternalRef=isExternalRef,exports.isLocalRef=isLocalRef,exports.isPlainObject=isPlainObject,exports.parseTree=parseTree,exports.parseWithPointers=parseWithPointers,exports.pathToPointer=pathToPointer,exports.pointerToPath=pointerToPath,exports.remapRefs=remapRefs,exports.renameObjectKey=renameObjectKey,exports.reparentBundleTarget=reparentBundleTarget,exports.resolveExternalRef=resolveExternalRef,exports.resolveExternalRefWithLocation=resolveExternalRefWithLocation,exports.resolveInlineRef=resolveInlineRef,exports.resolveInlineRefWithLocation=resolveInlineRefWithLocation,exports.safeParse=safeParse,exports.safeStringify=safeStringify,exports.startsWith=startsWith,exports.stringify=stringify,exports.toPropertyPath=toPropertyPath,exports.trapAccess=trapAccess,exports.traverse=traverse,exports.trimStart=trimStart;

@@ -1,1 +0,1 @@

import{cloneDeep as e,get as t,set as r,has as n,setWith as o,omit as i,trimStart as a}from"lodash";import{isAbsolute as s,join as c,dirname as u}from"@stoplight/path";import{createScanner as l,findNodeAtOffset as f,getNodePath as p,visit as h,printParseErrorCode as y}from"jsonc-parser";import g,{getOrder as d,ORDER_KEY_ID as m}from"@stoplight/ordered-object-literal";import{DiagnosticSeverity as v}from"@stoplight/types";import b from"safe-stable-stringify";function w(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype||"function"==typeof e.constructor&&Function.toString.call(Object)===Function.toString.call(e.constructor)}function O(e,t,r){if(!w(e)&&!Array.isArray(e)||!(t in e))throw new ReferenceError(`Could not resolve '${r}'`)}function j(e){if("string"!=typeof e.$ref)throw new TypeError("$ref should be a string")}const A=e=>w(e)&&"$ref"in e,$=e=>A(e)&&"string"==typeof e.$ref,E=e=>e.length>0&&("#"===e||/^#\S*$/.test(e)),S=(e,t,r)=>{const n=e.toString();let o="",i=n,a=0,s=i.indexOf(t);for(;s>-1;)o+=n.substring(a,a+s)+r,i=i.substring(s+t.length,i.length),a+=s+t.length,s=i.indexOf(t);return i.length>0&&(o+=n.substring(n.length-i.length,n.length)),o},x=e=>"number"==typeof e?e:S(S(e,"~","~0"),"/","~1"),_=/[^a-zA–Z0–9_.!~*'()\/\-\u{D800}-\u{DFFF}]/gu;function N(e){return e.replace(_,encodeURIComponent)}const k=e=>{const t=x(e);return"number"==typeof t?t:N(t)},P=e=>I(e),I=e=>{if(e&&"object"!=typeof e)throw new TypeError("Invalid type: path must be an array of segments.");return 0===e.length?"#":`#/${e.map(k).join("/")}`};function T(e){try{return decodeURIComponent(e)}catch(t){return e}}const R=/%[0-9a-f]+/gi,U=e=>{let t;try{t=decodeURIComponent(e)}catch(r){t=e.replace(R,T)}return S(S(t,"~1","/"),"~0","~")},K=e=>J(e),J=e=>{if("string"!=typeof e)throw new TypeError("Invalid type: JSON Pointers are represented as strings.");if(0===e.length||"#"!==e[0])throw new URIError("Invalid JSON Pointer syntax; URI fragment identifiers must begin with a hash.");if(1===e.length)return[];if("/"!==e[1])throw new URIError("Invalid JSON Pointer syntax.");return(e=>{const t=e.length,r=[];let n=-1;for(;++n<t;)r.push(U(e[n]));return r})(e.substring(2).split("/"))},C=(e,t,r)=>{const n={value:e,path:r};t.onEnter&&t.onEnter(n);const o=e;for(const n of Object.keys(o)){const i=o[n];t.onProperty&&t.onProperty({parent:e,parentPath:r,property:n,propertyValue:i}),"object"==typeof i&&null!==i&&C(i,t,r.concat(n))}t.onLeave&&t.onLeave(n)},D=(e,t)=>{"object"==typeof e&&null!==e&&C(e,"function"==typeof t?{onProperty:t}:t,[])};function F(e,t,r){D(e,{onProperty({property:e,propertyValue:n,parent:o}){"$ref"===e&&"string"==typeof n&&n.startsWith(t)&&(o.$ref=`${r}${n.slice(t.length)}`)}})}const M=e=>e.length>0&&"#"!==e[0],V=e=>{if("string"!=typeof e||0===e.length||!M(e))return null;const t=e.indexOf("#");return-1===t?e:e.slice(0,t)};function W(e,t){return w(t)&&w(e)&&("summary"in e||"description"in e)?Object.assign(Object.assign(Object.assign({},t),"description"in e?{description:e.description}:null),"summary"in e?{summary:e.summary}:null):t}function*L(e,t,r){A(e.value)&&(j(e.value),yield[-1,e.value]);for(const[n,o]of t.entries())O(e.value,o,r),e.value=e.value[o],A(e.value)&&(j(e.value),yield[n,e.value])}function B(e,t){return z(e,t).value}function z(e,t){return function e(t,r,n,o){if(null!==V(r))throw new ReferenceError("Cannot resolve external references");const i=K(r);let a=[...i];"#"===r&&A(t)&&(j(t),i.unshift(...K(t.$ref)));const s={value:t};for(const[c,u]of L(s,i,r)){if(n.includes(u))return{source:null,location:null!=o?o:a,value:n[n.length-1]};n.push(u);const r=e(t,u.$ref,n,a);s.value=r.value,(a=r.location).push(...i.slice(c+1))}return{source:null,location:a,value:n.length>0?W(n[n.length-1],s.value):s.value}}(e,t,[])}const Z="#/__bundled__",q="#/__errors__",G=({document:t,path:r,bundleRoot:n="#/__bundled__",errorsRoot:o="#/__errors__",cloneDocument:i=!0,keyProvider:a},s)=>{if(r===n||r===o)throw new Error("Roots do not make any sense");const c=i?e(t):t;return H(c,K(n),K(o),r,a)(r,{[r]:!0},s)},H=(e,a,s,c,u)=>{const l=new Set,f=(p,h,y,g={},d={},m={})=>{const v=K(p),b=t(e,v);D(y||b,{onEnter:({value:s})=>{if($(s)&&E(s.$ref)){const y=s.$ref;if(m[y])return;if(y===p&&(g[y]="#"),g[y])return void(s.$ref=g[y]);let v,b,w,O,j;try{let r;v=K(y),u&&(r=u({document:e,path:v})),r||(r=(({document:e,path:r})=>{if(0===r.length)return"root";if(Array.isArray(t(e,r.slice(0,-1))))return`${r[r.length-2]}_${r[r.length-1]}`;return String(r[r.length-1])})({document:e,path:v})),w=r;let n=1;for(;l.has(w);)if(w=`${r}_${++n}`,n>20)throw new Error(`Keys ${r}_2 through ${r}_20 already taken.`);l.add(w),b=[...a,w],O=P(b)}catch(e){m[y]=e instanceof Error?e.message:String(e)}if(!v||!b||!O)return;if("object"==typeof e&&null!==e&&!(j=t(e,v)))try{j=B(Object(e),y)}catch(e){}void 0!==j&&(g[y]=O,s.$ref=O,n(d,b)||(Array.isArray(j)?r(d,b,new Array(j.length).fill(null)):"object"==typeof j&&o(d,b,{},Object),r(d,b,j),"#"===y?function(e,t,n,o){const a=n.map(e=>`[${JSON.stringify(e)}]`).join(""),s=JSON.parse(JSON.stringify(i(Object(e),a))),c={};r(t,o,s),r(s,n,c),F(s,"#",P(o)),c.$ref="#"}(e,d,K(c),b):h[y]||(h[y]=!0,f(p,h,j,g,d,m),h[y]=!1)))}}});const w=t(d,a);return w&&Object.keys(w).length&&r(b,a,w),(Object.keys(m).length||n(e,s))&&r(b,s,n(e,s)?t(e,s):m),b};return f};const Q=e=>S(S(e,"~1","/"),"~0","~");function X(e,t){const r=new WeakMap,n=[];const o=function e(o,i){if(t&&(o=t(o)),w(o)||Array.isArray(o)){const t=r.get(o);if(t)return{$ref:t};if(r.set(o,P(i)),Array.isArray(o))return o.map((t,r)=>e(t,[...i,r]));const a={};for(const t in o)Object.prototype.hasOwnProperty.call(o,t)&&(a[t]=e(o[t],[...i,t]));return n.push(o),a}return o}(e,[]);return n.forEach(e=>{r.delete(e)}),o}const Y=e=>S(S(e,"~","~0"),"//","/~1"),ee=e=>{if("string"!=typeof e||0===e.length)return null;const t=e.indexOf("#");return-1===t?null:e.slice(t)},te=e=>{const t=l(e,!0);if(t.scan(),1!==t.getToken())return;if(t.scan(),2===t.getToken())return;if(10!==t.getToken())throw new SyntaxError("Unexpected character");const r=t.getTokenValue();if(t.scan(),6!==t.getToken())throw new SyntaxError("Colon expected");switch(t.scan(),t.getToken()){case 10:return[r,t.getTokenValue()];case 11:return[r,Number(t.getTokenValue())];case 8:return[r,!0];case 9:return[r,!1];case 7:return[r,null];case 16:throw new SyntaxError("Unexpected character");case 17:throw new SyntaxError("Unexpected end of file");default:return}},re=({lineMap:e,ast:t},r)=>{const n=e[r.line],o=e[r.line+1];if(void 0===n)return;const i=f(t,void 0===o?n+r.character:Math.min(o,n+r.character),!0);if(void 0===i)return;const a=p(i);return 0!==a.length?a:void 0};function ne(e){return Q(e.split("/").pop()||"")}const oe=({ast:e},t,r=!1)=>{const n=function(e,t,r){e:for(const n of t){const t=Number.isInteger(Number(n))?Number(n):n;if("string"==typeof t||"number"==typeof t&&"array"!==e.type){if("object"!==e.type||!Array.isArray(e.children))return r?e:void 0;for(const r of e.children)if(Array.isArray(r.children)&&r.children[0].value===String(t)&&2===r.children.length){e=r.children[1];continue e}return r?e:void 0}if("array"!==e.type||t<0||!Array.isArray(e.children)||t>=e.children.length)return r?e:void 0;e=e.children[t]}return e}(e,t,r);if(void 0!==n&&void 0!==n.range)return{range:n.range}};const ie=(e,t={disallowComments:!0})=>{const r=[],{ast:n,data:o,lineMap:i}=ae(e,r,t);return{data:o,diagnostics:r,ast:n,lineMap:i}};function ae(e,t=[],r){const n=ce(e);let o={type:"array",offset:-1,length:-1,children:[],parent:void 0},i=null,a=[];const s=new WeakMap,c=[];function u(e){"property"===o.type&&(o.length=e-o.offset,o=o.parent)}function l(e,t,r){return{start:{line:e,character:t},end:{line:e,character:t+r}}}function f(e){return o.children.push(e),e}function p(e){Array.isArray(a)?a.push(e):null!==i&&(a[i]=e)}function m(e){p(e),c.push(a),a=e,i=null}function b(){a=c.pop()}h(e,{onObjectBegin:(e,t,n,i)=>{o=f({type:"object",offset:e,length:-1,parent:o,children:[],range:l(n,i,t)}),!1===r.ignoreDuplicateKeys&&s.set(o,[]),m(function(e){return e?g({}):{}}(!0===r.preserveKeyOrder))},onObjectProperty:(e,n,c,u,p)=>{if((o=f({type:"property",offset:n,length:-1,parent:o,children:[]})).children.push({type:"string",value:e,offset:n,length:c,parent:o}),!1===r.ignoreDuplicateKeys){const r=s.get(o.parent);r&&(0!==r.length&&r.includes(e)?t.push({range:l(u,p,c),message:"DuplicateKey",severity:v.Error,path:ue(o),code:20}):r.push(e))}!0===r.preserveKeyOrder&&function(e,t){if(!(t in e))return;const r=d(e),n=r.indexOf(t);-1!==n&&(r.splice(n,1),r.push(t))}(a,e),i=e},onObjectEnd:(e,t,n,i)=>{!1===r.ignoreDuplicateKeys&&s.delete(o),o.length=e+t-o.offset,o.range&&(o.range.end.line=n,o.range.end.character=i+t),o=o.parent,u(e+t),b()},onArrayBegin:(e,t,r,n)=>{o=f({type:"array",offset:e,length:-1,parent:o,children:[],range:l(r,n,t)}),m([])},onArrayEnd:(e,t,r,n)=>{o.length=e+t-o.offset,o.range&&(o.range.end.line=r,o.range.end.character=n+t),o=o.parent,u(e+t),b()},onLiteralValue:(e,t,r,n,i)=>{f({type:se(e),offset:t,length:r,parent:o,value:e,range:l(n,i,r)}),u(t+r),p(e)},onSeparator:(e,t)=>{"property"===o.type&&(":"===e?o.colonOffset=t:","===e&&u(t))},onError:(e,r,n,o,i)=>{t.push({range:l(o,i,n),message:y(e),severity:v.Error,code:e})}},r);const w=o.children[0];return w&&delete w.parent,{ast:w,data:a[0],lineMap:n}}function se(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";default:return"null"}}const ce=e=>{const t=[0];let r=0;for(;r<e.length;r++)"\n"===e[r]&&t.push(r+1);return t.push(r+1),t};function ue(e,t=[]){return"property"===e.type&&t.unshift(e.children[0].value),void 0!==e.parent?("array"===e.parent.type&&void 0!==e.parent.parent&&t.unshift(e.parent.children.indexOf(e)),ue(e.parent,t)):t}const le=(e,t,r)=>{if(!e||!Object.hasOwnProperty.call(e,t)||t===r)return e;const n={};for(const[o,i]of Object.entries(e))o===t?n[r]=i:o in n||(n[o]=i);return n};function fe(e){return w(e)||Array.isArray(e)}function pe(e,t,r){if(r.length<=1||t.length<=1)throw Error("Source/target path must not be empty and point at root");if(0===t.indexOf(r))throw Error("Target path cannot be contained within source");const n=K(t);let o=e;for(const e of n){if(!fe(o))return;o=o[e]}if(!fe(o))return;const i=K(r);let a=e;for(const[e,t]of i.entries()){if(!fe(a)||t in a)return;const r=e===i.length-1?o:{};a[t]=r,a=r}delete e[n[0]],function e(t,r,n){for(const[o,i]of Object.entries(t))if("$ref"!==o)fe(i)&&e(i,r,n);else{if("string"!=typeof i||!E(i))continue;0===i.indexOf(r)&&(t[o]=i.replace(r,n))}}(e,t,r)}async function he(e,t,r,n,o){let i=function(e,t){const r=V(t);return null===r?e:s(r)?r:c(u(e),r)}(t,r);const a=ee(r)||"#",l=await e[i],f=K(a);let p=[...f];const h={value:l};for(const[r,s]of L(h,f,a)){if(n.includes(s))return{source:t,location:null!=o?o:p,value:n[n.length-1]};n.push(s);const a=await he(e,i,s.$ref,n,p);({source:i,location:p}=a),h.value=a.value,p.push(...f.slice(r+1))}return{source:i,location:p,value:n.length>0?W(n[n.length-1],h.value):h.value}}async function ye(e,t,r){return(await ge(e,t,r)).value}function ge(e,t,r){return he(e,t,r,[])}const de=(e,t)=>{if("string"!=typeof e)return e;try{const r=me(e);return"string"==typeof r?r:JSON.parse(e,t)}catch(e){return}},me=e=>{const t=Number(e);return Number.isFinite(t)?String(t)===e?t:e:NaN},ve=(e,t,r)=>{if("string"==typeof e)return e;try{return JSON.stringify(e,t,r)}catch(n){return b(e,t,r)}},be=(e,t)=>{if(e instanceof Array){if(t instanceof Array){if(t.length>e.length)return!1;for(const r in t){if(!t.hasOwnProperty(r))continue;const n=parseInt(e[r]),o=parseInt(t[r]);if(isNaN(n)&&isNaN(o)){if(e[r]!==t[r])return!1}else if(n!==o)return!1}}}else{if("string"!=typeof e)return!1;if("string"==typeof t)return e.startsWith(t)}return!0},we=(e,t,r)=>{const n=ve(e,t,r);if(void 0===n)throw new Error("The value could not be stringified");return n};function Oe(e){return e.replace(/^(\/|#\/)/,"").split("/").map(Q).map(je).join(".")}function je(e){return e.includes(".")?`["${e.replace(/"/g,'\\"')}"]`:e}const Ae=Symbol.for(m),$e=e=>new Proxy(e,{ownKeys:e=>"object"==typeof e&&null!==e&&Ae in e?e[Ae]:Reflect.ownKeys(e)});function Ee(e,t){if("string"==typeof e&&"string"==typeof t)return a(e,t);if(!(e&&Array.isArray(e)&&e.length&&t&&Array.isArray(t)&&t.length))return e;let r=0;for(const n in e)if(e.hasOwnProperty(n)){if(e[n]!==t[n])break;r++}return e.slice(r)}export{Z as BUNDLE_ROOT,q as ERRORS_ROOT,Ae as KEYS,G as bundleTarget,U as decodePointer,Q as decodePointerFragment,U as decodePointerUriFragment,X as decycle,Y as encodePointer,x as encodePointerFragment,k as encodePointerUriFragment,N as encodeUriPointer,ee as extractPointerFromRef,V as extractSourceFromRef,te as getFirstPrimitiveProperty,re as getJsonPathForPosition,ne as getLastPathSegment,oe as getLocationForJsonPath,$ as hasRef,M as isExternalRef,E as isLocalRef,w as isPlainObject,ae as parseTree,ie as parseWithPointers,P as pathToPointer,K as pointerToPath,F as remapRefs,le as renameObjectKey,pe as reparentBundleTarget,ye as resolveExternalRef,ge as resolveExternalRefWithLocation,B as resolveInlineRef,z as resolveInlineRefWithLocation,de as safeParse,ve as safeStringify,be as startsWith,we as stringify,Oe as toPropertyPath,$e as trapAccess,D as traverse,Ee as trimStart};
import{cloneDeep as e,get as t,set as r,has as n,setWith as o,omit as i,trimStart as a}from"lodash";import{isAbsolute as s,join as c,dirname as u}from"@stoplight/path";import{createScanner as l,findNodeAtOffset as f,getNodePath as p,visit as h,printParseErrorCode as y}from"jsonc-parser";import g,{getOrder as d,ORDER_KEY_ID as m}from"@stoplight/ordered-object-literal";import{DiagnosticSeverity as v}from"@stoplight/types";import b from"safe-stable-stringify";function w(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype||"function"==typeof e.constructor&&Function.toString.call(Object)===Function.toString.call(e.constructor)}function O(e,t,r){if(!w(e)&&!Array.isArray(e)||!(t in e))throw new ReferenceError(`Could not resolve '${r}'`)}function j(e){if("string"!=typeof e.$ref)throw new TypeError("$ref should be a string")}const A=e=>w(e)&&"$ref"in e,$=e=>A(e)&&"string"==typeof e.$ref,E=e=>e.length>0&&("#"===e||/^#\S*$/.test(e)),S=(e,t,r)=>{const n=e.toString();let o="",i=n,a=0,s=i.indexOf(t);for(;s>-1;)o+=n.substring(a,a+s)+r,i=i.substring(s+t.length,i.length),a+=s+t.length,s=i.indexOf(t);return i.length>0&&(o+=n.substring(n.length-i.length,n.length)),o},x=e=>"number"==typeof e?e:S(S(e,"~","~0"),"/","~1"),_=/[^a-zA–Z0–9_.!~*'()\/\-\u{D800}-\u{DFFF}]/gu;function N(e){return e.replace(_,encodeURIComponent)}const k=e=>{const t=x(e);return"number"==typeof t?t:N(t)},P=e=>I(e),I=e=>{if(e&&"object"!=typeof e)throw new TypeError("Invalid type: path must be an array of segments.");return 0===e.length?"#":`#/${e.map(k).join("/")}`};function T(e){try{return decodeURIComponent(e)}catch(t){return e}}const R=/%[0-9a-f]+/gi,U=e=>{let t;try{t=decodeURIComponent(e)}catch(r){t=e.replace(R,T)}return S(S(t,"~1","/"),"~0","~")},K=e=>J(e),J=e=>{if("string"!=typeof e)throw new TypeError("Invalid type: JSON Pointers are represented as strings.");if(0===e.length||"#"!==e[0])throw new URIError("Invalid JSON Pointer syntax; URI fragment identifiers must begin with a hash.");if(1===e.length)return[];if("/"!==e[1])throw new URIError("Invalid JSON Pointer syntax.");return(e=>{const t=e.length,r=[];let n=-1;for(;++n<t;)r.push(U(e[n]));return r})(e.substring(2).split("/"))},C=(e,t,r)=>{const n={value:e,path:r};t.onEnter&&t.onEnter(n);for(const n of Object.keys(e)){const o=e[n];t.onProperty&&t.onProperty({parent:e,parentPath:r,property:n,propertyValue:o}),"object"==typeof o&&null!==o&&C(o,t,r.concat(n))}t.onLeave&&t.onLeave(n)},D=(e,t)=>{"object"==typeof e&&null!==e&&C(e,"function"==typeof t?{onProperty:t}:t,[])};function F(e,t,r){D(e,{onProperty({property:e,propertyValue:n,parent:o}){"$ref"===e&&"string"==typeof n&&n.startsWith(t)&&(o.$ref=`${r}${n.slice(t.length)}`)}})}const M=e=>e.length>0&&"#"!==e[0],V=e=>{if("string"!=typeof e||0===e.length||!M(e))return null;const t=e.indexOf("#");return-1===t?e:e.slice(0,t)};function W(e,t){return w(t)&&w(e)&&("summary"in e||"description"in e)?Object.assign(Object.assign(Object.assign({},t),"description"in e?{description:e.description}:null),"summary"in e?{summary:e.summary}:null):t}function*L(e,t,r){A(e.value)&&(j(e.value),yield[-1,e.value]);for(const[n,o]of t.entries())O(e.value,o,r),e.value=e.value[o],A(e.value)&&(j(e.value),yield[n,e.value])}function B(e,t){return z(e,t).value}function z(e,t){return function e(t,r,n,o){if(null!==V(r))throw new ReferenceError("Cannot resolve external references");const i=K(r);let a=[...i];"#"===r&&A(t)&&(j(t),i.unshift(...K(t.$ref)));const s={value:t};for(const[c,u]of L(s,i,r)){if(n.includes(u))return{source:null,location:null!=o?o:a,value:n[n.length-1]};n.push(u);const r=e(t,u.$ref,n,a);s.value=r.value,(a=r.location).push(...i.slice(c+1))}return{source:null,location:a,value:n.length>0?W(n[n.length-1],s.value):s.value}}(e,t,[])}const Z="#/__bundled__",q="#/__errors__",G=({document:t,path:r,bundleRoot:n="#/__bundled__",errorsRoot:o="#/__errors__",cloneDocument:i=!0,keyProvider:a},s)=>{if(r===n||r===o)throw new Error("Roots do not make any sense");const c=i?e(t):t;return H(c,K(n),K(o),r,a)(r,{[r]:!0},s)},H=(e,a,s,c,u)=>{const l=new Set,f=(p,h,y,g={},d={},m={})=>{const v=K(p),b=t(e,v);D(y||b,{onEnter:({value:s})=>{if($(s)&&E(s.$ref)){const y=s.$ref;if(m[y])return;if(y===p&&(g[y]="#"),g[y])return void(s.$ref=g[y]);let v,b,w,O,j;try{let r;v=K(y),u&&(r=u({document:e,path:v})),r||(r=(({document:e,path:r})=>{if(0===r.length)return"root";if(Array.isArray(t(e,r.slice(0,-1))))return`${r[r.length-2]}_${r[r.length-1]}`;return String(r[r.length-1])})({document:e,path:v})),w=r;let n=1;for(;l.has(w);)if(w=`${r}_${++n}`,n>20)throw new Error(`Keys ${r}_2 through ${r}_20 already taken.`);l.add(w),b=[...a,w],O=P(b)}catch(e){m[y]=e instanceof Error?e.message:String(e)}if(!v||!b||!O)return;if("object"==typeof e&&null!==e&&!(j=t(e,v)))try{j=B(Object(e),y)}catch(e){}void 0!==j&&(g[y]=O,s.$ref=O,n(d,b)||(Array.isArray(j)?r(d,b,new Array(j.length).fill(null)):"object"==typeof j&&o(d,b,{},Object),r(d,b,j),"#"===y?function(e,t,n,o){const a=n.map(e=>`[${JSON.stringify(e)}]`).join(""),s=JSON.parse(JSON.stringify(i(Object(e),a))),c={};r(t,o,s),r(s,n,c),F(s,"#",P(o)),c.$ref="#"}(e,d,K(c),b):h[y]||(h[y]=!0,f(p,h,j,g,d,m),h[y]=!1)))}}});const w=t(d,a);return w&&Object.keys(w).length&&r(b,a,w),(Object.keys(m).length||n(e,s))&&r(b,s,n(e,s)?t(e,s):m),b};return f};const Q=e=>S(S(e,"~1","/"),"~0","~");function X(e,t){const r=new WeakMap;return function e(n,o){if(t&&(n=t(n)),w(n)||Array.isArray(n)){const t=r.get(n);if(t)return{$ref:t};if(r.set(n,P(o)),Array.isArray(n))return n.map((t,r)=>e(t,[...o,r]));const i={};for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(i[t]=e(n[t],[...o,t]));return r.delete(n),i}return n}(e,[])}const Y=e=>S(S(e,"~","~0"),"//","/~1"),ee=e=>{if("string"!=typeof e||0===e.length)return null;const t=e.indexOf("#");return-1===t?null:e.slice(t)},te=e=>{const t=l(e,!0);if(t.scan(),1!==t.getToken())return;if(t.scan(),2===t.getToken())return;if(10!==t.getToken())throw new SyntaxError("Unexpected character");const r=t.getTokenValue();if(t.scan(),6!==t.getToken())throw new SyntaxError("Colon expected");switch(t.scan(),t.getToken()){case 10:return[r,t.getTokenValue()];case 11:return[r,Number(t.getTokenValue())];case 8:return[r,!0];case 9:return[r,!1];case 7:return[r,null];case 16:throw new SyntaxError("Unexpected character");case 17:throw new SyntaxError("Unexpected end of file");default:return}},re=({lineMap:e,ast:t},r)=>{const n=e[r.line],o=e[r.line+1];if(void 0===n)return;const i=f(t,void 0===o?n+r.character:Math.min(o,n+r.character),!0);if(void 0===i)return;const a=p(i);return 0!==a.length?a:void 0};function ne(e){return Q(e.split("/").pop()||"")}const oe=({ast:e},t,r=!1)=>{const n=function(e,t,r){e:for(const n of t){const t=Number.isInteger(Number(n))?Number(n):n;if("string"==typeof t||"number"==typeof t&&"array"!==e.type){if("object"!==e.type||!Array.isArray(e.children))return r?e:void 0;for(const r of e.children)if(Array.isArray(r.children)&&r.children[0].value===String(t)&&2===r.children.length){e=r.children[1];continue e}return r?e:void 0}if("array"!==e.type||t<0||!Array.isArray(e.children)||t>=e.children.length)return r?e:void 0;e=e.children[t]}return e}(e,t,r);if(void 0!==n&&void 0!==n.range)return{range:n.range}};const ie=(e,t={disallowComments:!0})=>{const r=[],{ast:n,data:o,lineMap:i}=ae(e,r,t);return{data:o,diagnostics:r,ast:n,lineMap:i}};function ae(e,t=[],r){const n=ce(e);let o={type:"array",offset:-1,length:-1,children:[],parent:void 0},i=null,a=[];const s=new WeakMap,c=[];function u(e){"property"===o.type&&(o.length=e-o.offset,o=o.parent)}function l(e,t,r){return{start:{line:e,character:t},end:{line:e,character:t+r}}}function f(e){return o.children.push(e),e}function p(e){Array.isArray(a)?a.push(e):null!==i&&(a[i]=e)}function m(e){p(e),c.push(a),a=e,i=null}function b(){a=c.pop()}h(e,{onObjectBegin:(e,t,n,i)=>{o=f({type:"object",offset:e,length:-1,parent:o,children:[],range:l(n,i,t)}),!1===r.ignoreDuplicateKeys&&s.set(o,[]),m(function(e){return e?g({}):{}}(!0===r.preserveKeyOrder))},onObjectProperty:(e,n,c,u,p)=>{if((o=f({type:"property",offset:n,length:-1,parent:o,children:[]})).children.push({type:"string",value:e,offset:n,length:c,parent:o}),!1===r.ignoreDuplicateKeys){const r=s.get(o.parent);r&&(0!==r.length&&r.includes(e)?t.push({range:l(u,p,c),message:"DuplicateKey",severity:v.Error,path:ue(o),code:20}):r.push(e))}!0===r.preserveKeyOrder&&function(e,t){if(!(t in e))return;const r=d(e),n=r.indexOf(t);-1!==n&&(r.splice(n,1),r.push(t))}(a,e),i=e},onObjectEnd:(e,t,n,i)=>{!1===r.ignoreDuplicateKeys&&s.delete(o),o.length=e+t-o.offset,o.range&&(o.range.end.line=n,o.range.end.character=i+t),o=o.parent,u(e+t),b()},onArrayBegin:(e,t,r,n)=>{o=f({type:"array",offset:e,length:-1,parent:o,children:[],range:l(r,n,t)}),m([])},onArrayEnd:(e,t,r,n)=>{o.length=e+t-o.offset,o.range&&(o.range.end.line=r,o.range.end.character=n+t),o=o.parent,u(e+t),b()},onLiteralValue:(e,t,r,n,i)=>{f({type:se(e),offset:t,length:r,parent:o,value:e,range:l(n,i,r)}),u(t+r),p(e)},onSeparator:(e,t)=>{"property"===o.type&&(":"===e?o.colonOffset=t:","===e&&u(t))},onError:(e,r,n,o,i)=>{t.push({range:l(o,i,n),message:y(e),severity:v.Error,code:e})}},r);const w=o.children[0];return w&&delete w.parent,{ast:w,data:a[0],lineMap:n}}function se(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";default:return"null"}}const ce=e=>{const t=[0];let r=0;for(;r<e.length;r++)"\n"===e[r]&&t.push(r+1);return t.push(r+1),t};function ue(e,t=[]){return"property"===e.type&&t.unshift(e.children[0].value),void 0!==e.parent?("array"===e.parent.type&&void 0!==e.parent.parent&&t.unshift(e.parent.children.indexOf(e)),ue(e.parent,t)):t}const le=(e,t,r)=>{if(!e||!Object.hasOwnProperty.call(e,t)||t===r)return e;const n={};for(const[o,i]of Object.entries(e))o===t?n[r]=i:o in n||(n[o]=i);return n};function fe(e){return w(e)||Array.isArray(e)}function pe(e,t,r){if(r.length<=1||t.length<=1)throw Error("Source/target path must not be empty and point at root");if(0===t.indexOf(r))throw Error("Target path cannot be contained within source");const n=K(t);let o=e;for(const e of n){if(!fe(o))return;o=o[e]}if(!fe(o))return;const i=K(r);let a=e;for(const[e,t]of i.entries()){if(!fe(a)||t in a)return;const r=e===i.length-1?o:{};a[t]=r,a=r}delete e[n[0]],function e(t,r,n){for(const o of Object.keys(t)){const i=t[o];if("$ref"!==o)fe(i)&&e(i,r,n);else{if("string"!=typeof i||!E(i))continue;0===i.indexOf(r)&&(t[o]=i.replace(r,n))}}}(e,t,r)}async function he(e,t,r,n,o){let i=function(e,t){const r=V(t);return null===r?e:s(r)?r:c(u(e),r)}(t,r);const a=ee(r)||"#",l=await e[i],f=K(a);let p=[...f];const h={value:l};for(const[r,s]of L(h,f,a)){if(n.includes(s))return{source:t,location:null!=o?o:p,value:n[n.length-1]};n.push(s);const a=await he(e,i,s.$ref,n,p);({source:i,location:p}=a),h.value=a.value,p.push(...f.slice(r+1))}return{source:i,location:p,value:n.length>0?W(n[n.length-1],h.value):h.value}}async function ye(e,t,r){return(await ge(e,t,r)).value}function ge(e,t,r){return he(e,t,r,[])}const de=(e,t)=>{if("string"!=typeof e)return e;try{const r=me(e);return"string"==typeof r?r:JSON.parse(e,t)}catch(e){return}},me=e=>{const t=Number(e);return Number.isFinite(t)?String(t)===e?t:e:NaN},ve=(e,t,r)=>{if("string"==typeof e)return e;try{return JSON.stringify(e,t,r)}catch(n){return b(e,t,r)}},be=(e,t)=>{if(e instanceof Array){if(t instanceof Array){if(t.length>e.length)return!1;for(const r in t){if(!t.hasOwnProperty(r))continue;const n=parseInt(e[r]),o=parseInt(t[r]);if(isNaN(n)&&isNaN(o)){if(e[r]!==t[r])return!1}else if(n!==o)return!1}}}else{if("string"!=typeof e)return!1;if("string"==typeof t)return e.startsWith(t)}return!0},we=(e,t,r)=>{const n=ve(e,t,r);if(void 0===n)throw new Error("The value could not be stringified");return n};function Oe(e){return e.replace(/^(\/|#\/)/,"").split("/").map(Q).map(je).join(".")}function je(e){return e.includes(".")?`["${e.replace(/"/g,'\\"')}"]`:e}const Ae=Symbol.for(m),$e={ownKeys:e=>Ae in e?e[Ae]:Reflect.ownKeys(e)},Ee=e=>new Proxy(e,$e);function Se(e,t){if("string"==typeof e&&"string"==typeof t)return a(e,t);if(!(e&&Array.isArray(e)&&e.length&&t&&Array.isArray(t)&&t.length))return e;let r=0;for(const n in e)if(e.hasOwnProperty(n)){if(e[n]!==t[n])break;r++}return e.slice(r)}export{Z as BUNDLE_ROOT,q as ERRORS_ROOT,Ae as KEYS,G as bundleTarget,U as decodePointer,Q as decodePointerFragment,U as decodePointerUriFragment,X as decycle,Y as encodePointer,x as encodePointerFragment,k as encodePointerUriFragment,N as encodeUriPointer,ee as extractPointerFromRef,V as extractSourceFromRef,te as getFirstPrimitiveProperty,re as getJsonPathForPosition,ne as getLastPathSegment,oe as getLocationForJsonPath,$ as hasRef,M as isExternalRef,E as isLocalRef,w as isPlainObject,ae as parseTree,ie as parseWithPointers,P as pathToPointer,K as pointerToPath,F as remapRefs,le as renameObjectKey,pe as reparentBundleTarget,ye as resolveExternalRef,ge as resolveExternalRefWithLocation,B as resolveInlineRef,z as resolveInlineRefWithLocation,de as safeParse,ve as safeStringify,be as startsWith,we as stringify,Oe as toPropertyPath,Ee as trapAccess,D as traverse,Se as trimStart};
{
"name": "@stoplight/json",
"version": "3.21.3",
"version": "3.21.4",
"description": "Useful functions when working with JSON.",

@@ -29,3 +29,3 @@ "keywords": [

"@stoplight/types": "^13.6.0",
"jsonc-parser": "~3.2.1",
"jsonc-parser": "~2.2.1",
"lodash": "^4.17.21",

@@ -32,0 +32,0 @@ "safe-stable-stringify": "^1.1"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc