@speclynx/apidom-json-pointer 1.12.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/NOTICE +16 -7
- package/dist/apidom-json-pointer.browser.js +2383 -7784
- package/dist/apidom-json-pointer.browser.min.js +1 -1
- package/package.json +5 -4
- package/src/index.cjs +11 -57
- package/src/index.mjs +6 -54
- package/src/realm.cjs +55 -0
- package/src/realm.mjs +51 -0
- package/types/apidom-json-pointer.d.ts +6 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.apidomJsonPointer=t():e.apidomJsonPointer=t()}(self,()=>(()=>{var e={88:(e,t,r)=>{var n=r(4700);e.exports=function(e){return n(this,e).get(e)}},155:e=>{e.exports=function(e,t){return null==e?void 0:e[t]}},195:(e,t,r)=>{var n=r(4882),s=r(8121),a=Object.prototype.hasOwnProperty;e.exports=function(e){if(!n(e))return s(e);var t=[];for(var r in Object(e))a.call(e,r)&&"constructor"!=r&&t.push(r);return t}},353:(e,t,r)=>{var n=r(1340),s=r(3934),a=r(8861),i=r(1182),o=r(8486),c=r(3142),l=r(5853),u=r(8666),h="[object Arguments]",p="[object Array]",f="[object Object]",m=Object.prototype.hasOwnProperty;e.exports=function(e,t,r,d,y,g){var b=c(e),v=c(t),E=b?p:o(e),w=v?p:o(t),x=(E=E==h?f:E)==f,T=(w=w==h?f:w)==f,k=E==w;if(k&&l(e)){if(!l(t))return!1;b=!0,x=!1}if(k&&!x)return g||(g=new n),b||u(e)?s(e,t,r,d,y,g):a(e,t,E,r,d,y,g);if(!(1&r)){var O=x&&m.call(e,"__wrapped__"),j=T&&m.call(t,"__wrapped__");if(O||j){var A=O?e.value():e,_=j?t.value():t;return g||(g=new n),y(A,_,r,d,g)}}return!!k&&(g||(g=new n),i(e,t,r,d,y,g))}},358:(e,t,r)=>{var n=r(6137),s=r(3283),a=r(3142),i=r(5853),o=r(9632),c=r(8666),l=Object.prototype.hasOwnProperty;e.exports=function(e,t){var r=a(e),u=!r&&s(e),h=!r&&!u&&i(e),p=!r&&!u&&!h&&c(e),f=r||u||h||p,m=f?n(e.length,String):[],d=m.length;for(var y in e)!t&&!l.call(e,y)||f&&("length"==y||h&&("offset"==y||"parent"==y)||p&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||o(y,d))||m.push(y);return m}},393:(e,t,r)=>{var n=r(8244),s=r(7979),a=r(1211);e.exports=function(e){return n(e,a,s)}},394:e=>{e.exports=class{constructor(e){this.namespace=e||new this.Namespace}serialise(e){if(!(e instanceof this.namespace.elements.Element))throw new TypeError(`Given element \`${e}\` is not an Element instance`);const t={element:e.element};e._meta&&e._meta.length>0&&(t.meta=this.serialiseObject(e.meta)),e._attributes&&e._attributes.length>0&&(t.attributes=this.serialiseObject(e.attributes));const r=this.serialiseContent(e.content);return void 0!==r&&(t.content=r),t}deserialise(e){if(!e.element)throw new Error("Given value is not an object containing an element name");const t=new(this.namespace.getElementClass(e.element));t.element!==e.element&&(t.element=e.element),e.meta&&this.deserialiseObject(e.meta,t.meta),e.attributes&&this.deserialiseObject(e.attributes,t.attributes);const r=this.deserialiseContent(e.content);return void 0===r&&null!==t.content||(t.content=r),t}serialiseContent(e){if(e instanceof this.namespace.elements.Element)return this.serialise(e);if(e instanceof this.namespace.KeyValuePair){const t={key:this.serialise(e.key)};return e.value&&(t.value=this.serialise(e.value)),t}if(e&&e.map){if(0===e.length)return;return e.map(this.serialise,this)}return e}deserialiseContent(e){if(e){if(e.element)return this.deserialise(e);if(e.key){const t=new this.namespace.KeyValuePair(this.deserialise(e.key));return e.value&&(t.value=this.deserialise(e.value)),t}if(e.map)return e.map(this.deserialise,this)}return e}serialiseObject(e){const t={};if(e.forEach((e,r)=>{e&&(t[r.toValue()]=this.serialise(e))}),0!==Object.keys(t).length)return t}deserialiseObject(e,t){Object.keys(e).forEach(r=>{t.set(r,this.deserialise(e[r]))})}}},547:e=>{e.exports=function(e){return null!=e&&"object"==typeof e}},593:(e,t,r)=>{const n=r(8631);e.exports=class extends n{constructor(e,t,r){super(e||[],t,r),this.element="ref",this.path||(this.path="element")}get path(){return this.attributes.get("path")}set path(e){this.attributes.set("path",e)}}},674:(e,t,r)=>{var n=r(7379),s=r(5387),a=r(547),i={};i["[object Float32Array]"]=i["[object Float64Array]"]=i["[object Int8Array]"]=i["[object Int16Array]"]=i["[object Int32Array]"]=i["[object Uint8Array]"]=i["[object Uint8ClampedArray]"]=i["[object Uint16Array]"]=i["[object Uint32Array]"]=!0,i["[object Arguments]"]=i["[object Array]"]=i["[object ArrayBuffer]"]=i["[object Boolean]"]=i["[object DataView]"]=i["[object Date]"]=i["[object Error]"]=i["[object Function]"]=i["[object Map]"]=i["[object Number]"]=i["[object Object]"]=i["[object RegExp]"]=i["[object Set]"]=i["[object String]"]=i["[object WeakMap]"]=!1,e.exports=function(e){return a(e)&&s(e.length)&&!!i[n(e)]}},986:(e,t,r)=>{var n=r(7379),s=r(547);e.exports=function(e){return"number"==typeof e||s(e)&&"[object Number]"==n(e)}},1112:(e,t,r)=>{var n=r(4497),s=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(n){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return s.call(t,e)?t[e]:void 0}},1129:e=>{e.exports=function(e,t){for(var r=-1,n=t.length,s=e.length;++r<n;)e[s+r]=t[r];return e}},1182:(e,t,r)=>{var n=r(393),s=Object.prototype.hasOwnProperty;e.exports=function(e,t,r,a,i,o){var c=1&r,l=n(e),u=l.length;if(u!=n(t).length&&!c)return!1;for(var h=u;h--;){var p=l[h];if(!(c?p in t:s.call(t,p)))return!1}var f=o.get(e),m=o.get(t);if(f&&m)return f==t&&m==e;var d=!0;o.set(e,t),o.set(t,e);for(var y=c;++h<u;){var g=e[p=l[h]],b=t[p];if(a)var v=c?a(b,g,p,t,e,o):a(g,b,p,e,t,o);if(!(void 0===v?g===b||i(g,b,r,a,o):v)){d=!1;break}y||(y="constructor"==p)}if(d&&!y){var E=e.constructor,w=t.constructor;E==w||!("constructor"in e)||!("constructor"in t)||"function"==typeof E&&E instanceof E&&"function"==typeof w&&w instanceof w||(d=!1)}return o.delete(e),o.delete(t),d}},1211:(e,t,r)=>{var n=r(358),s=r(195),a=r(6529);e.exports=function(e){return a(e)?n(e):s(e)}},1340:(e,t,r)=>{var n=r(1386),s=r(4103),a=r(1779),i=r(4162),o=r(7462),c=r(6638);function l(e){var t=this.__data__=new n(e);this.size=t.size}l.prototype.clear=s,l.prototype.delete=a,l.prototype.get=i,l.prototype.has=o,l.prototype.set=c,e.exports=l},1386:(e,t,r)=>{var n=r(2393),s=r(2049),a=r(7144),i=r(7452),o=r(3964);function c(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}c.prototype.clear=n,c.prototype.delete=s,c.prototype.get=a,c.prototype.has=i,c.prototype.set=o,e.exports=c},1517:e=>{e.exports=function(e){if("function"!=typeof e)throw new TypeError("Expected a function");return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}},1580:e=>{e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},1623:(e,t,r)=>{var n=r(8942).Uint8Array;e.exports=n},1779:e=>{e.exports=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}},1877:e=>{e.exports=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this}},1950:(e,t,r)=>{var n=r(8942)["__core-js_shared__"];e.exports=n},2049:(e,t,r)=>{var n=r(7034),s=Array.prototype.splice;e.exports=function(e){var t=this.__data__,r=n(t,e);return!(r<0)&&(r==t.length-1?t.pop():s.call(t,r,1),--this.size,!0)}},2306:(e,t,r)=>{e=r.nmd(e);var n=r(4967),s=t&&!t.nodeType&&t,a=s&&e&&!e.nodeType&&e,i=a&&a.exports===s&&n.process,o=function(){try{var e=a&&a.require&&a.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=o},2322:e=>{class t{constructor(e,t){this.key=e,this.value=t}clone(){const e=new t;return this.key&&(e.key=this.key.clone()),this.value&&(e.value=this.value.clone()),e}}e.exports=t},2393:e=>{e.exports=function(){this.__data__=[],this.size=0}},2536:(e,t,r)=>{const n=r(8631);e.exports=class extends n{constructor(e,t,r){super(e,t,r),this.element="number"}primitive(){return"number"}}},2555:(e,t,r)=>{const n=r(8631);e.exports=class extends n{constructor(e,t,r){super(e,t,r),this.element="boolean"}primitive(){return"boolean"}}},2563:(e,t,r)=>{var n=r(7379),s=r(547);e.exports=function(e){return!0===e||!1===e||s(e)&&"[object Boolean]"==n(e)}},3004:(e,t,r)=>{const n=r(8631);e.exports=class extends n{constructor(e,t,r){super(e||null,t,r),this.element="null"}primitive(){return"null"}set(){return new Error("Cannot set the value of null")}}},3103:(e,t,r)=>{var n=r(4715)(r(8942),"DataView");e.exports=n},3142:e=>{var t=Array.isArray;e.exports=t},3148:(e,t,r)=>{const n=r(394);e.exports=class extends n{serialise(e){if(!(e instanceof this.namespace.elements.Element))throw new TypeError(`Given element \`${e}\` is not an Element instance`);let t;e._attributes&&e.attributes.get("variable")&&(t=e.attributes.get("variable"));const r={element:e.element};e._meta&&e._meta.length>0&&(r.meta=this.serialiseObject(e.meta));const n="enum"===e.element||-1!==e.attributes.keys().indexOf("enumerations");if(n){const t=this.enumSerialiseAttributes(e);t&&(r.attributes=t)}else if(e._attributes&&e._attributes.length>0){let{attributes:n}=e;n.get("metadata")&&(n=n.clone(),n.set("meta",n.get("metadata")),n.remove("metadata")),"member"===e.element&&t&&(n=n.clone(),n.remove("variable")),n.length>0&&(r.attributes=this.serialiseObject(n))}if(n)r.content=this.enumSerialiseContent(e,r);else if(this[`${e.element}SerialiseContent`])r.content=this[`${e.element}SerialiseContent`](e,r);else if(void 0!==e.content){let n;t&&e.content.key?(n=e.content.clone(),n.key.attributes.set("variable",t),n=this.serialiseContent(n)):n=this.serialiseContent(e.content),this.shouldSerialiseContent(e,n)&&(r.content=n)}else this.shouldSerialiseContent(e,e.content)&&e instanceof this.namespace.elements.Array&&(r.content=[]);return r}shouldSerialiseContent(e,t){return"parseResult"===e.element||"httpRequest"===e.element||"httpResponse"===e.element||"category"===e.element||"link"===e.element||void 0!==t&&(!Array.isArray(t)||0!==t.length)}refSerialiseContent(e,t){return delete t.attributes,{href:e.toValue(),path:e.path.toValue()}}sourceMapSerialiseContent(e){return e.toValue()}dataStructureSerialiseContent(e){return[this.serialiseContent(e.content)]}enumSerialiseAttributes(e){const t=e.attributes.clone(),r=t.remove("enumerations")||new this.namespace.elements.Array([]),n=t.get("default");let s=t.get("samples")||new this.namespace.elements.Array([]);if(n&&n.content&&(n.content.attributes&&n.content.attributes.remove("typeAttributes"),t.set("default",new this.namespace.elements.Array([n.content]))),s.forEach(e=>{e.content&&e.content.element&&e.content.attributes.remove("typeAttributes")}),e.content&&0!==r.length&&s.unshift(e.content),s=s.map(e=>e instanceof this.namespace.elements.Array?[e]:new this.namespace.elements.Array([e.content])),s.length&&t.set("samples",s),t.length>0)return this.serialiseObject(t)}enumSerialiseContent(e){if(e._attributes){const t=e.attributes.get("enumerations");if(t&&t.length>0)return t.content.map(e=>{const t=e.clone();return t.attributes.remove("typeAttributes"),this.serialise(t)})}if(e.content){const t=e.content.clone();return t.attributes.remove("typeAttributes"),[this.serialise(t)]}return[]}deserialise(e){if("string"==typeof e)return new this.namespace.elements.String(e);if("number"==typeof e)return new this.namespace.elements.Number(e);if("boolean"==typeof e)return new this.namespace.elements.Boolean(e);if(null===e)return new this.namespace.elements.Null;if(Array.isArray(e))return new this.namespace.elements.Array(e.map(this.deserialise,this));const t=this.namespace.getElementClass(e.element),r=new t;r.element!==e.element&&(r.element=e.element),e.meta&&this.deserialiseObject(e.meta,r.meta),e.attributes&&this.deserialiseObject(e.attributes,r.attributes);const n=this.deserialiseContent(e.content);if(void 0===n&&null!==r.content||(r.content=n),"enum"===r.element){r.content&&r.attributes.set("enumerations",r.content);let e=r.attributes.get("samples");if(r.attributes.remove("samples"),e){const n=e;e=new this.namespace.elements.Array,n.forEach(n=>{n.forEach(n=>{const s=new t(n);s.element=r.element,e.push(s)})});const s=e.shift();r.content=s?s.content:void 0,r.attributes.set("samples",e)}else r.content=void 0;let n=r.attributes.get("default");if(n&&n.length>0){n=n.get(0);const e=new t(n);e.element=r.element,r.attributes.set("default",e)}}else if("dataStructure"===r.element&&Array.isArray(r.content))[r.content]=r.content;else if("category"===r.element){const e=r.attributes.get("meta");e&&(r.attributes.set("metadata",e),r.attributes.remove("meta"))}else"member"===r.element&&r.key&&r.key._attributes&&r.key._attributes.getValue("variable")&&(r.attributes.set("variable",r.key.attributes.get("variable")),r.key.attributes.remove("variable"));return r}serialiseContent(e){if(e instanceof this.namespace.elements.Element)return this.serialise(e);if(e instanceof this.namespace.KeyValuePair){const t={key:this.serialise(e.key)};return e.value&&(t.value=this.serialise(e.value)),t}return e&&e.map?e.map(this.serialise,this):e}deserialiseContent(e){if(e){if(e.element)return this.deserialise(e);if(e.key){const t=new this.namespace.KeyValuePair(this.deserialise(e.key));return e.value&&(t.value=this.deserialise(e.value)),t}if(e.map)return e.map(this.deserialise,this)}return e}shouldRefract(e){return!!(e._attributes&&e.attributes.keys().length||e._meta&&e.meta.keys().length)||"enum"!==e.element&&(e.element!==e.primitive()||"member"===e.element)}convertKeyToRefract(e,t){return this.shouldRefract(t)?this.serialise(t):"enum"===t.element?this.serialiseEnum(t):"array"===t.element?t.map(t=>this.shouldRefract(t)||"default"===e?this.serialise(t):"array"===t.element||"object"===t.element||"enum"===t.element?t.children.map(e=>this.serialise(e)):t.toValue()):"object"===t.element?(t.content||[]).map(this.serialise,this):t.toValue()}serialiseEnum(e){return e.children.map(e=>this.serialise(e))}serialiseObject(e){const t={};return e.forEach((e,r)=>{if(e){const n=r.toValue();t[n]=this.convertKeyToRefract(n,e)}}),t}deserialiseObject(e,t){Object.keys(e).forEach(r=>{t.set(r,this.deserialise(e[r]))})}}},3212:(e,t,r)=>{var n=r(8250),s=r(1877),a=r(8006);function i(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new n;++t<r;)this.add(e[t])}i.prototype.add=i.prototype.push=s,i.prototype.has=a,e.exports=i},3283:(e,t,r)=>{var n=r(6027),s=r(547),a=Object.prototype,i=a.hasOwnProperty,o=a.propertyIsEnumerable,c=n(function(){return arguments}())?n:function(e){return s(e)&&i.call(e,"callee")&&!o.call(e,"callee")};e.exports=c},3305:(e,t,r)=>{var n=r(4497);e.exports=function(){this.__data__=n?n(null):{},this.size=0}},3311:(e,t,r)=>{const n=r(1517),s=r(4123);class a extends s{map(e,t){return this.elements.map(r=>e.bind(t)(r.value,r.key,r))}filter(e,t){return new a(this.elements.filter(r=>e.bind(t)(r.value,r.key,r)))}reject(e,t){return this.filter(n(e.bind(t)))}forEach(e,t){return this.elements.forEach((r,n)=>{e.bind(t)(r.value,r.key,r,n)})}keys(){return this.map((e,t)=>t.toValue())}values(){return this.map(e=>e.toValue())}}e.exports=a},3655:(e,t,r)=>{var n=r(7379),s=r(1580);e.exports=function(e){if(!s(e))return!1;var t=n(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},3766:e=>{e.exports=function(e,t){return function(r){return e(t(r))}}},3934:(e,t,r)=>{var n=r(3212),s=r(6465),a=r(5568);e.exports=function(e,t,r,i,o,c){var l=1&r,u=e.length,h=t.length;if(u!=h&&!(l&&h>u))return!1;var p=c.get(e),f=c.get(t);if(p&&f)return p==t&&f==e;var m=-1,d=!0,y=2&r?new n:void 0;for(c.set(e,t),c.set(t,e);++m<u;){var g=e[m],b=t[m];if(i)var v=l?i(b,g,m,t,e,c):i(g,b,m,e,t,c);if(void 0!==v){if(v)continue;d=!1;break}if(y){if(!s(t,function(e,t){if(!a(y,t)&&(g===e||o(g,e,r,i,c)))return y.push(t)})){d=!1;break}}else if(g!==b&&!o(g,b,r,i,c)){d=!1;break}}return c.delete(e),c.delete(t),d}},3964:(e,t,r)=>{var n=r(7034);e.exports=function(e,t){var r=this.__data__,s=n(r,e);return s<0?(++this.size,r.push([e,t])):r[s][1]=t,this}},4066:e=>{var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},4103:(e,t,r)=>{var n=r(1386);e.exports=function(){this.__data__=new n,this.size=0}},4123:(e,t,r)=>{const n=r(1517);function s(e){return"string"==typeof e?t=>t.element===e:e.constructor&&e.extend?t=>t instanceof e:e}class a{constructor(e){this.elements=e||[]}toValue(){return this.elements.map(e=>e.toValue())}map(e,t){return this.elements.map(e,t)}flatMap(e,t){return this.map(e,t).reduce((e,t)=>e.concat(t),[])}compactMap(e,t){const r=[];return this.forEach(n=>{const s=e.bind(t)(n);s&&r.push(s)}),r}filter(e,t){return e=s(e),new a(this.elements.filter(e,t))}reject(e,t){return e=s(e),new a(this.elements.filter(n(e),t))}find(e,t){return e=s(e),this.elements.find(e,t)}forEach(e,t){this.elements.forEach(e,t)}reduce(e,t){return this.elements.reduce(e,t)}includes(e){return this.elements.some(t=>t.equals(e))}shift(){return this.elements.shift()}unshift(e){this.elements.unshift(this.refract(e))}push(e){return this.elements.push(this.refract(e)),this}add(e){this.push(e)}get(e){return this.elements[e]}getValue(e){const t=this.elements[e];if(t)return t.toValue()}get length(){return this.elements.length}get isEmpty(){return 0===this.elements.length}get first(){return this.elements[0]}}"undefined"!=typeof Symbol&&(a.prototype[Symbol.iterator]=function(){return this.elements[Symbol.iterator]()}),e.exports=a},4162:e=>{e.exports=function(e){return this.__data__.get(e)}},4497:(e,t,r)=>{var n=r(4715)(Object,"create");e.exports=n},4512:(e,t,r)=>{var n=r(4715)(r(8942),"Set");e.exports=n},4687:(e,t,r)=>{var n=r(353),s=r(547);e.exports=function e(t,r,a,i,o){return t===r||(null==t||null==r||!s(t)&&!s(r)?t!=t&&r!=r:n(t,r,a,i,e,o))}},4700:(e,t,r)=>{var n=r(9067);e.exports=function(e,t){var r=e.__data__;return n(t)?r["string"==typeof t?"string":"hash"]:r.map}},4715:(e,t,r)=>{var n=r(9624),s=r(155);e.exports=function(e,t){var r=s(e,t);return n(r)?r:void 0}},4732:(e,t,r)=>{var n=r(4700);e.exports=function(e){return n(this,e).has(e)}},4759:(e,t,r)=>{var n,s=r(1950),a=(n=/[^.]+$/.exec(s&&s.keys&&s.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"";e.exports=function(e){return!!a&&a in e}},4772:e=>{e.exports=function(){return!1}},4882:e=>{var t=Object.prototype;e.exports=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}},4967:(e,t,r)=>{var n="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g;e.exports=n},5071:(e,t,r)=>{var n=r(4497);e.exports=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=n&&void 0===t?"__lodash_hash_undefined__":t,this}},5098:(e,t,r)=>{var n=r(3305),s=r(9361),a=r(1112),i=r(5276),o=r(5071);function c(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}c.prototype.clear=n,c.prototype.delete=s,c.prototype.get=a,c.prototype.has=i,c.prototype.set=o,e.exports=c},5276:(e,t,r)=>{var n=r(4497),s=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return n?void 0!==t[e]:s.call(t,e)}},5387:e=>{e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},5568:e=>{e.exports=function(e,t){return e.has(t)}},5642:(e,t,r)=>{const n=r(1517),s=r(1580),a=r(9796),i=r(7309),o=r(3311);e.exports=class extends a{constructor(e,t,r){super(e||[],t,r),this.element="object"}primitive(){return"object"}toValue(){return this.content.reduce((e,t)=>(e[t.key.toValue()]=t.value?t.value.toValue():void 0,e),{})}get(e){const t=this.getMember(e);if(t)return t.value}getMember(e){if(void 0!==e)return this.content.find(t=>t.key.toValue()===e)}remove(e){let t=null;return this.content=this.content.filter(r=>r.key.toValue()!==e||(t=r,!1)),t}getKey(e){const t=this.getMember(e);if(t)return t.key}set(e,t){if(s(e))return Object.keys(e).forEach(t=>{this.set(t,e[t])}),this;const r=e,n=this.getMember(r);return n?n.value=t:this.content.push(new i(r,t)),this}keys(){return this.content.map(e=>e.key.toValue())}values(){return this.content.map(e=>e.value.toValue())}hasKey(e){return this.content.some(t=>t.key.equals(e))}items(){return this.content.map(e=>[e.key.toValue(),e.value.toValue()])}map(e,t){return this.content.map(r=>e.bind(t)(r.value,r.key,r))}compactMap(e,t){const r=[];return this.forEach((n,s,a)=>{const i=e.bind(t)(n,s,a);i&&r.push(i)}),r}filter(e,t){return new o(this.content).filter(e,t)}reject(e,t){return this.filter(n(e),t)}forEach(e,t){return this.content.forEach(r=>e.bind(t)(r.value,r.key,r))}}},5650:(e,t,r)=>{var n=r(8942).Symbol;e.exports=n},5681:(e,t,r)=>{var n=r(4700);e.exports=function(e){var t=n(this,e).delete(e);return this.size-=t?1:0,t}},5735:(e,t,r)=>{const n=r(9310),s=r(8138),a=r(986),i=r(2563),o=r(1580),c=r(394),l=r(7547);class u{constructor(e){this.elementMap={},this.elementDetection=[],this.Element=l.Element,this.KeyValuePair=l.KeyValuePair,e&&e.noDefault||this.useDefault(),this._attributeElementKeys=[],this._attributeElementArrayKeys=[]}use(e){return e.namespace&&e.namespace({base:this}),e.load&&e.load({base:this}),this}useDefault(){return this.register("null",l.NullElement).register("string",l.StringElement).register("number",l.NumberElement).register("boolean",l.BooleanElement).register("array",l.ArrayElement).register("object",l.ObjectElement).register("member",l.MemberElement).register("ref",l.RefElement).register("link",l.LinkElement),this.detect(n,l.NullElement,!1).detect(s,l.StringElement,!1).detect(a,l.NumberElement,!1).detect(i,l.BooleanElement,!1).detect(Array.isArray,l.ArrayElement,!1).detect(o,l.ObjectElement,!1),this}register(e,t){return this._elements=void 0,this.elementMap[e]=t,this}unregister(e){return this._elements=void 0,delete this.elementMap[e],this}detect(e,t,r){return void 0===r||r?this.elementDetection.unshift([e,t]):this.elementDetection.push([e,t]),this}toElement(e){if(e instanceof this.Element)return e;let t;for(let r=0;r<this.elementDetection.length;r+=1){const n=this.elementDetection[r][0],s=this.elementDetection[r][1];if(n(e)){t=new s(e);break}}return t}getElementClass(e){const t=this.elementMap[e];return void 0===t?this.Element:t}fromRefract(e){return this.serialiser.deserialise(e)}toRefract(e){return this.serialiser.serialise(e)}get elements(){return void 0===this._elements&&(this._elements={Element:this.Element},Object.keys(this.elementMap).forEach(e=>{const t=e[0].toUpperCase()+e.substr(1);this._elements[t]=this.elementMap[e]})),this._elements}get serialiser(){return new c(this)}}c.prototype.Namespace=u,e.exports=u},5853:(e,t,r)=>{e=r.nmd(e);var n=r(8942),s=r(4772),a=t&&!t.nodeType&&t,i=a&&e&&!e.nodeType&&e,o=i&&i.exports===a?n.Buffer:void 0,c=(o?o.isBuffer:void 0)||s;e.exports=c},5894:e=>{e.exports=function(e){var t=-1,r=Array(e.size);return e.forEach(function(e,n){r[++t]=[n,e]}),r}},6027:(e,t,r)=>{var n=r(7379),s=r(547);e.exports=function(e){return s(e)&&"[object Arguments]"==n(e)}},6137:e=>{e.exports=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}},6285:e=>{e.exports=function(e,t){return e===t||e!=e&&t!=t}},6343:(e,t,r)=>{var n=r(4687);e.exports=function(e,t){return n(e,t)}},6465:e=>{e.exports=function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}},6529:(e,t,r)=>{var n=r(3655),s=r(5387);e.exports=function(e){return null!=e&&s(e.length)&&!n(e)}},6638:(e,t,r)=>{var n=r(1386),s=r(9770),a=r(8250);e.exports=function(e,t){var r=this.__data__;if(r instanceof n){var i=r.__data__;if(!s||i.length<199)return i.push([e,t]),this.size=++r.size,this;r=this.__data__=new a(i)}return r.set(e,t),this.size=r.size,this}},7034:(e,t,r)=>{var n=r(6285);e.exports=function(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}},7144:(e,t,r)=>{var n=r(7034);e.exports=function(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]}},7309:(e,t,r)=>{const n=r(2322),s=r(8631);e.exports=class extends s{constructor(e,t,r,s){super(new n,r,s),this.element="member",this.key=e,this.value=t}get key(){return this.content.key}set key(e){this.content.key=this.refract(e)}get value(){return this.content.value}set value(e){this.content.value=this.refract(e)}}},7379:(e,t,r)=>{var n=r(5650),s=r(8870),a=r(9005),i=n?n.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":i&&i in Object(e)?s(e):a(e)}},7452:(e,t,r)=>{var n=r(7034);e.exports=function(e){return n(this.__data__,e)>-1}},7462:e=>{e.exports=function(e){return this.__data__.has(e)}},7547:(e,t,r)=>{const n=r(8631),s=r(3004),a=r(8712),i=r(2536),o=r(2555),c=r(9796),l=r(7309),u=r(5642),h=r(9620),p=r(593),f=r(4123),m=r(3311),d=r(2322);function y(e){if(e instanceof n)return e;if("string"==typeof e)return new a(e);if("number"==typeof e)return new i(e);if("boolean"==typeof e)return new o(e);if(null===e)return new s;if(Array.isArray(e))return new c(e.map(y));if("object"==typeof e){return new u(e)}return e}n.prototype.ObjectElement=u,n.prototype.RefElement=p,n.prototype.MemberElement=l,n.prototype.refract=y,f.prototype.refract=y,e.exports={Element:n,NullElement:s,StringElement:a,NumberElement:i,BooleanElement:o,ArrayElement:c,MemberElement:l,ObjectElement:u,LinkElement:h,RefElement:p,refract:y,ArraySlice:f,ObjectSlice:m,KeyValuePair:d}},7979:(e,t,r)=>{var n=r(9847),s=r(9306),a=Object.prototype.propertyIsEnumerable,i=Object.getOwnPropertySymbols,o=i?function(e){return null==e?[]:(e=Object(e),n(i(e),function(t){return a.call(e,t)}))}:s;e.exports=o},8006:e=>{e.exports=function(e){return this.__data__.has(e)}},8121:(e,t,r)=>{var n=r(3766)(Object.keys,Object);e.exports=n},8138:(e,t,r)=>{var n=r(7379),s=r(3142),a=r(547);e.exports=function(e){return"string"==typeof e||!s(e)&&a(e)&&"[object String]"==n(e)}},8244:(e,t,r)=>{var n=r(1129),s=r(3142);e.exports=function(e,t,r){var a=t(e);return s(e)?a:n(a,r(e))}},8250:(e,t,r)=>{var n=r(9753),s=r(5681),a=r(88),i=r(4732),o=r(9068);function c(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}c.prototype.clear=n,c.prototype.delete=s,c.prototype.get=a,c.prototype.has=i,c.prototype.set=o,e.exports=c},8326:(e,t,r)=>{const n=r(5735),s=r(7547);r(2322),s.ArraySlice,s.ObjectSlice,t.Hg=s.Element,t.Om=s.StringElement,t.kT=s.NumberElement,t.bd=s.BooleanElement,t.Os=s.NullElement,t.wE=s.ArrayElement,t.Sh=s.ObjectElement,t.Pr=s.MemberElement,t.sI=s.RefElement,t.Ft=s.LinkElement,s.refract,r(394),r(3148)},8486:(e,t,r)=>{var n=r(3103),s=r(9770),a=r(9413),i=r(4512),o=r(9270),c=r(7379),l=r(4066),u="[object Map]",h="[object Promise]",p="[object Set]",f="[object WeakMap]",m="[object DataView]",d=l(n),y=l(s),g=l(a),b=l(i),v=l(o),E=c;(n&&E(new n(new ArrayBuffer(1)))!=m||s&&E(new s)!=u||a&&E(a.resolve())!=h||i&&E(new i)!=p||o&&E(new o)!=f)&&(E=function(e){var t=c(e),r="[object Object]"==t?e.constructor:void 0,n=r?l(r):"";if(n)switch(n){case d:return m;case y:return u;case g:return h;case b:return p;case v:return f}return t}),e.exports=E},8631:(e,t,r)=>{const n=r(6343),s=r(2322),a=r(4123);class i{constructor(e,t,r){t&&(this.meta=t),r&&(this.attributes=r),this.content=e}freeze(){Object.isFrozen(this)||(this._meta&&(this.meta.parent=this,this.meta.freeze()),this._attributes&&(this.attributes.parent=this,this.attributes.freeze()),this.children.forEach(e=>{e.parent=this,e.freeze()},this),this.content&&Array.isArray(this.content)&&Object.freeze(this.content),Object.freeze(this))}primitive(){}clone(){const e=new this.constructor;return e.element=this.element,this.meta.length&&(e._meta=this.meta.clone()),this.attributes.length&&(e._attributes=this.attributes.clone()),this.content?this.content.clone?e.content=this.content.clone():Array.isArray(this.content)?e.content=this.content.map(e=>e.clone()):e.content=this.content:e.content=this.content,e}toValue(){return this.content instanceof i?this.content.toValue():this.content instanceof s?{key:this.content.key.toValue(),value:this.content.value?this.content.value.toValue():void 0}:this.content&&this.content.map?this.content.map(e=>e.toValue(),this):this.content}toRef(e){if(""===this.id.toValue())throw Error("Cannot create reference to an element that does not contain an ID");const t=new this.RefElement(this.id.toValue());return e&&(t.path=e),t}findRecursive(...e){if(arguments.length>1&&!this.isFrozen)throw new Error("Cannot find recursive with multiple element names without first freezing the element. Call `element.freeze()`");const t=e.pop();let r=new a;const n=(e,t)=>(e.push(t),e),i=(e,r)=>{r.element===t&&e.push(r);const a=r.findRecursive(t);return a&&a.reduce(n,e),r.content instanceof s&&(r.content.key&&i(e,r.content.key),r.content.value&&i(e,r.content.value)),e};return this.content&&(this.content.element&&i(r,this.content),Array.isArray(this.content)&&this.content.reduce(i,r)),e.isEmpty||(r=r.filter(t=>{let r=t.parents.map(e=>e.element);for(const t in e){const n=e[t],s=r.indexOf(n);if(-1===s)return!1;r=r.splice(0,s)}return!0})),r}set(e){return this.content=e,this}equals(e){return n(this.toValue(),e)}getMetaProperty(e,t){if(!this.meta.hasKey(e)){if(this.isFrozen){const e=this.refract(t);return e.freeze(),e}this.meta.set(e,t)}return this.meta.get(e)}setMetaProperty(e,t){this.meta.set(e,t)}get element(){return this._storedElement||"element"}set element(e){this._storedElement=e}get content(){return this._content}set content(e){if(e instanceof i)this._content=e;else if(e instanceof a)this.content=e.elements;else if("string"==typeof e||"number"==typeof e||"boolean"==typeof e||"null"===e||null==e)this._content=e;else if(e instanceof s)this._content=e;else if(Array.isArray(e))this._content=e.map(this.refract);else{if("object"!=typeof e)throw new Error("Cannot set content to given value");this._content=Object.keys(e).map(t=>new this.MemberElement(t,e[t]))}}get meta(){if(!this._meta){if(this.isFrozen){const e=new this.ObjectElement;return e.freeze(),e}this._meta=new this.ObjectElement}return this._meta}set meta(e){e instanceof this.ObjectElement?this._meta=e:this.meta.set(e||{})}get attributes(){if(!this._attributes){if(this.isFrozen){const e=new this.ObjectElement;return e.freeze(),e}this._attributes=new this.ObjectElement}return this._attributes}set attributes(e){e instanceof this.ObjectElement?this._attributes=e:this.attributes.set(e||{})}get id(){return this.getMetaProperty("id","")}set id(e){this.setMetaProperty("id",e)}get classes(){return this.getMetaProperty("classes",[])}set classes(e){this.setMetaProperty("classes",e)}get title(){return this.getMetaProperty("title","")}set title(e){this.setMetaProperty("title",e)}get description(){return this.getMetaProperty("description","")}set description(e){this.setMetaProperty("description",e)}get links(){return this.getMetaProperty("links",[])}set links(e){this.setMetaProperty("links",e)}get isFrozen(){return Object.isFrozen(this)}get parents(){let{parent:e}=this;const t=new a;for(;e;)t.push(e),e=e.parent;return t}get children(){if(Array.isArray(this.content))return new a(this.content);if(this.content instanceof s){const e=new a([this.content.key]);return this.content.value&&e.push(this.content.value),e}return this.content instanceof i?new a([this.content]):new a}get recursiveChildren(){const e=new a;return this.children.forEach(t=>{e.push(t),t.recursiveChildren.forEach(t=>{e.push(t)})}),e}}e.exports=i},8666:(e,t,r)=>{var n=r(674),s=r(9460),a=r(2306),i=a&&a.isTypedArray,o=i?s(i):n;e.exports=o},8712:(e,t,r)=>{const n=r(8631);e.exports=class extends n{constructor(e,t,r){super(e,t,r),this.element="string"}primitive(){return"string"}get length(){return this.content.length}}},8861:(e,t,r)=>{var n=r(5650),s=r(1623),a=r(6285),i=r(3934),o=r(5894),c=r(9828),l=n?n.prototype:void 0,u=l?l.valueOf:void 0;e.exports=function(e,t,r,n,l,h,p){switch(r){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!h(new s(e),new s(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return a(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var f=o;case"[object Set]":var m=1&n;if(f||(f=c),e.size!=t.size&&!m)return!1;var d=p.get(e);if(d)return d==t;n|=2,p.set(e,t);var y=i(f(e),f(t),n,l,h,p);return p.delete(e),y;case"[object Symbol]":if(u)return u.call(e)==u.call(t)}return!1}},8870:(e,t,r)=>{var n=r(5650),s=Object.prototype,a=s.hasOwnProperty,i=s.toString,o=n?n.toStringTag:void 0;e.exports=function(e){var t=a.call(e,o),r=e[o];try{e[o]=void 0;var n=!0}catch(e){}var s=i.call(e);return n&&(t?e[o]=r:delete e[o]),s}},8942:(e,t,r)=>{var n=r(4967),s="object"==typeof self&&self&&self.Object===Object&&self,a=n||s||Function("return this")();e.exports=a},9005:e=>{var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},9067:e=>{e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},9068:(e,t,r)=>{var n=r(4700);e.exports=function(e,t){var r=n(this,e),s=r.size;return r.set(e,t),this.size+=r.size==s?0:1,this}},9270:(e,t,r)=>{var n=r(4715)(r(8942),"WeakMap");e.exports=n},9306:e=>{e.exports=function(){return[]}},9310:e=>{e.exports=function(e){return null===e}},9361:e=>{e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},9413:(e,t,r)=>{var n=r(4715)(r(8942),"Promise");e.exports=n},9460:e=>{e.exports=function(e){return function(t){return e(t)}}},9620:(e,t,r)=>{const n=r(8631);e.exports=class extends n{constructor(e,t,r){super(e||[],t,r),this.element="link"}get relation(){return this.attributes.get("relation")}set relation(e){this.attributes.set("relation",e)}get href(){return this.attributes.get("href")}set href(e){this.attributes.set("href",e)}}},9624:(e,t,r)=>{var n=r(3655),s=r(4759),a=r(1580),i=r(4066),o=/^\[object .+?Constructor\]$/,c=Function.prototype,l=Object.prototype,u=c.toString,h=l.hasOwnProperty,p=RegExp("^"+u.call(h).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!a(e)||s(e))&&(n(e)?p:o).test(i(e))}},9632:e=>{var t=/^(?:0|[1-9]\d*)$/;e.exports=function(e,r){var n=typeof e;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&t.test(e))&&e>-1&&e%1==0&&e<r}},9753:(e,t,r)=>{var n=r(5098),s=r(1386),a=r(9770);e.exports=function(){this.size=0,this.__data__={hash:new n,map:new(a||s),string:new n}}},9770:(e,t,r)=>{var n=r(4715)(r(8942),"Map");e.exports=n},9796:(e,t,r)=>{const n=r(1517),s=r(8631),a=r(4123);class i extends s{constructor(e,t,r){super(e||[],t,r),this.element="array"}primitive(){return"array"}get(e){return this.content[e]}getValue(e){const t=this.get(e);if(t)return t.toValue()}getIndex(e){return this.content[e]}set(e,t){return this.content[e]=this.refract(t),this}remove(e){const t=this.content.splice(e,1);return t.length?t[0]:null}map(e,t){return this.content.map(e,t)}flatMap(e,t){return this.map(e,t).reduce((e,t)=>e.concat(t),[])}compactMap(e,t){const r=[];return this.forEach(n=>{const s=e.bind(t)(n);s&&r.push(s)}),r}filter(e,t){return new a(this.content.filter(e,t))}reject(e,t){return this.filter(n(e),t)}reduce(e,t){let r,n;void 0!==t?(r=0,n=this.refract(t)):(r=1,n="object"===this.primitive()?this.first.value:this.first);for(let t=r;t<this.length;t+=1){const r=this.content[t];n="object"===this.primitive()?this.refract(e(n,r.value,r.key,r,this)):this.refract(e(n,r,t,this))}return n}forEach(e,t){this.content.forEach((r,n)=>{e.bind(t)(r,this.refract(n))})}shift(){return this.content.shift()}unshift(e){this.content.unshift(this.refract(e))}push(e){return this.content.push(this.refract(e)),this}add(e){this.push(e)}findElements(e,t){const r=t||{},n=!!r.recursive,s=void 0===r.results?[]:r.results;return this.forEach((t,r,a)=>{n&&void 0!==t.findElements&&t.findElements(e,{results:s,recursive:n}),e(t,r,a)&&s.push(t)}),s}find(e){return new a(this.findElements(e,{recursive:!0}))}findByElement(e){return this.find(t=>t.element===e)}findByClass(e){return this.find(t=>t.classes.includes(e))}getById(e){return this.find(t=>t.id.toValue()===e).first}includes(e){return this.content.some(t=>t.equals(e))}contains(e){return this.includes(e)}empty(){return new this.constructor([])}"fantasy-land/empty"(){return this.empty()}concat(e){return new this.constructor(this.content.concat(e.content))}"fantasy-land/concat"(e){return this.concat(e)}"fantasy-land/map"(e){return new this.constructor(this.map(e))}"fantasy-land/chain"(e){return this.map(t=>e(t),this).reduce((e,t)=>e.concat(t),this.empty())}"fantasy-land/filter"(e){return new this.constructor(this.content.filter(e))}"fantasy-land/reduce"(e,t){return this.content.reduce(e,t)}get length(){return this.content.length}get isEmpty(){return 0===this.content.length}get first(){return this.getIndex(0)}get second(){return this.getIndex(1)}get last(){return this.getIndex(this.length-1)}}i.empty=function(){return new this},i["fantasy-land/empty"]=i.empty,"undefined"!=typeof Symbol&&(i.prototype[Symbol.iterator]=function(){return this.content[Symbol.iterator]()}),e.exports=i},9828:e=>{e.exports=function(e){var t=-1,r=Array(e.size);return e.forEach(function(e){r[++t]=e}),r}},9847:e=>{e.exports=function(e,t){for(var r=-1,n=null==e?0:e.length,s=0,a=[];++r<n;){var i=e[r];t(i,r,e)&&(a[s++]=i)}return a}}},t={};function r(n){var s=t[n];if(void 0!==s)return s.exports;var a=t[n]={id:n,loaded:!1,exports:{}};return e[n](a,a.exports,r),a.loaded=!0,a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var n={};return(()=>{"use strict";r.r(n),r.d(n,{ASTTranslator:()=>x,CSTTranslator:()=>E,Grammar:()=>l,JSONPointerCompileError:()=>U,JSONPointerError:()=>g,JSONPointerEvaluateError:()=>Y,JSONPointerIndexError:()=>J,JSONPointerKeyError:()=>W,JSONPointerParseError:()=>b,JSONPointerTypeError:()=>G,JSONString:()=>e,URIFragmentIdentifier:()=>t,XMLTranslator:()=>A,compile:()=>H,escape:()=>B,evaluate:()=>Ce,parse:()=>j,testArrayDash:()=>z,testArrayIndex:()=>I,testArrayLocation:()=>C,testJSONPointer:()=>_,testReferenceToken:()=>M,unescape:()=>w});var e={};r.r(e),r.d(e,{from:()=>a,to:()=>s});var t={};r.r(t),r.d(t,{from:()=>o,fromURIReference:()=>c,to:()=>i});const s=e=>JSON.stringify(e),a=e=>{try{return String(JSON.parse(e))}catch{return e}},i=e=>`#${[...e].map(e=>/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/.test(e)?e:encodeURIComponent(e)).join("")}`,o=e=>{try{const t=e.startsWith("#")?e.slice(1):e;return decodeURIComponent(t)}catch{return e}},c=e=>{const t=e.indexOf("#"),r=-1===t?"#":e.substring(t);return o(r)};function l(){this.grammarObject="grammarObject",this.rules=[],this.rules[0]={name:"json-pointer",lower:"json-pointer",index:0,isBkr:!1},this.rules[1]={name:"reference-token",lower:"reference-token",index:1,isBkr:!1},this.rules[2]={name:"unescaped",lower:"unescaped",index:2,isBkr:!1},this.rules[3]={name:"escaped",lower:"escaped",index:3,isBkr:!1},this.rules[4]={name:"array-location",lower:"array-location",index:4,isBkr:!1},this.rules[5]={name:"array-index",lower:"array-index",index:5,isBkr:!1},this.rules[6]={name:"array-dash",lower:"array-dash",index:6,isBkr:!1},this.rules[7]={name:"slash",lower:"slash",index:7,isBkr:!1},this.udts=[],this.rules[0].opcodes=[],this.rules[0].opcodes[0]={type:3,min:0,max:1/0},this.rules[0].opcodes[1]={type:2,children:[2,3]},this.rules[0].opcodes[2]={type:4,index:7},this.rules[0].opcodes[3]={type:4,index:1},this.rules[1].opcodes=[],this.rules[1].opcodes[0]={type:3,min:0,max:1/0},this.rules[1].opcodes[1]={type:1,children:[2,3]},this.rules[1].opcodes[2]={type:4,index:2},this.rules[1].opcodes[3]={type:4,index:3},this.rules[2].opcodes=[],this.rules[2].opcodes[0]={type:1,children:[1,2,3]},this.rules[2].opcodes[1]={type:5,min:0,max:46},this.rules[2].opcodes[2]={type:5,min:48,max:125},this.rules[2].opcodes[3]={type:5,min:127,max:1114111},this.rules[3].opcodes=[],this.rules[3].opcodes[0]={type:2,children:[1,2]},this.rules[3].opcodes[1]={type:7,string:[126]},this.rules[3].opcodes[2]={type:1,children:[3,4]},this.rules[3].opcodes[3]={type:7,string:[48]},this.rules[3].opcodes[4]={type:7,string:[49]},this.rules[4].opcodes=[],this.rules[4].opcodes[0]={type:1,children:[1,2]},this.rules[4].opcodes[1]={type:4,index:5},this.rules[4].opcodes[2]={type:4,index:6},this.rules[5].opcodes=[],this.rules[5].opcodes[0]={type:1,children:[1,2]},this.rules[5].opcodes[1]={type:6,string:[48]},this.rules[5].opcodes[2]={type:2,children:[3,4]},this.rules[5].opcodes[3]={type:5,min:49,max:57},this.rules[5].opcodes[4]={type:3,min:0,max:1/0},this.rules[5].opcodes[5]={type:5,min:48,max:57},this.rules[6].opcodes=[],this.rules[6].opcodes[0]={type:7,string:[45]},this.rules[7].opcodes=[],this.rules[7].opcodes[0]={type:7,string:[47]},this.toString=function(){let e="";return e+="; JavaScript Object Notation (JSON) Pointer ABNF syntax\n",e+="; https://datatracker.ietf.org/doc/html/rfc6901\n",e+="json-pointer = *( slash reference-token ) ; MODIFICATION: surrogate text rule used\n",e+="reference-token = *( unescaped / escaped )\n",e+="unescaped = %x00-2E / %x30-7D / %x7F-10FFFF\n",e+=" ; %x2F ('/') and %x7E ('~') are excluded from 'unescaped'\n",e+='escaped = "~" ( "0" / "1" )\n',e+=" ; representing '~' and '/', respectively\n",e+="\n",e+="; https://datatracker.ietf.org/doc/html/rfc6901#section-4\n",e+="array-location = array-index / array-dash\n",e+="array-index = %x30 / ( %x31-39 *(%x30-39) )\n",e+=' ; "0", or digits without a leading "0"\n',e+='array-dash = "-"\n',e+="\n",e+="; Surrogate named rules\n",e+='slash = "/"\n','; JavaScript Object Notation (JSON) Pointer ABNF syntax\n; https://datatracker.ietf.org/doc/html/rfc6901\njson-pointer = *( slash reference-token ) ; MODIFICATION: surrogate text rule used\nreference-token = *( unescaped / escaped )\nunescaped = %x00-2E / %x30-7D / %x7F-10FFFF\n ; %x2F (\'/\') and %x7E (\'~\') are excluded from \'unescaped\'\nescaped = "~" ( "0" / "1" )\n ; representing \'~\' and \'/\', respectively\n\n; https://datatracker.ietf.org/doc/html/rfc6901#section-4\narray-location = array-index / array-dash\narray-index = %x30 / ( %x31-39 *(%x30-39) )\n ; "0", or digits without a leading "0"\narray-dash = "-"\n\n; Surrogate named rules\nslash = "/"\n'}}const u=function(){const e=d,t=m,r=this,n="parser.js: Parser(): ";r.ast=void 0,r.stats=void 0,r.trace=void 0,r.callbacks=[];let s,a,i,o,c,l,u,h=0,p=0,f=0,y=0,g=0,b=new function(){this.state=e.ACTIVE,this.phraseLength=0,this.refresh=()=>{this.state=e.ACTIVE,this.phraseLength=0}};r.parse=(m,d,v,E)=>{const x=`${n}parse(): `;h=0,p=0,f=0,y=0,g=0,s=void 0,a=void 0,i=void 0,o=void 0,b.refresh(),c=void 0,l=void 0,u=void 0,o=t.stringToChars(v),s=m.rules,a=m.udts;const T=d.toLowerCase();let k;for(const e in s)if(s.hasOwnProperty(e)&&T===s[e].lower){k=s[e].index;break}if(void 0===k)throw new Error(`${x}start rule name '${startRule}' not recognized`);(()=>{const e=`${n}initializeCallbacks(): `;let t,i;for(c=[],l=[],t=0;t<s.length;t+=1)c[t]=void 0;for(t=0;t<a.length;t+=1)l[t]=void 0;const o=[];for(t=0;t<s.length;t+=1)o.push(s[t].lower);for(t=0;t<a.length;t+=1)o.push(a[t].lower);for(const n in r.callbacks)if(r.callbacks.hasOwnProperty(n)){if(t=o.indexOf(n.toLowerCase()),t<0)throw new Error(`${e}syntax callback '${n}' not a rule or udt name`);if(i=r.callbacks[n]?r.callbacks[n]:void 0,"function"!=typeof i&&void 0!==i)throw new Error(`${e}syntax callback[${n}] must be function reference or falsy)`);t<s.length?c[t]=i:l[t-s.length]=i}})(),r.trace&&r.trace.init(s,a,o),r.stats&&r.stats.init(s,a),r.ast&&r.ast.init(s,a,o),u=E,i=[{type:e.RNM,index:k}],w(0,0),i=void 0;let O=!1;switch(b.state){case e.ACTIVE:throw new Error(`${x}final state should never be 'ACTIVE'`);case e.NOMATCH:O=!1;break;case e.EMPTY:case e.MATCH:O=b.phraseLength===o.length;break;default:throw new Error("unrecognized state")}return{success:O,state:b.state,stateName:e.idName(b.state),length:o.length,matched:b.phraseLength,maxMatched:g,maxTreeDepth:f,nodeHits:y}};const v=(t,r,s,a)=>{if(r.phraseLength>s){let e=`${n}opRNM(${t.name}): callback function error: `;throw e+=`sysData.phraseLength: ${r.phraseLength}`,e+=` must be <= remaining chars: ${s}`,new Error(e)}switch(r.state){case e.ACTIVE:if(!a)throw new Error(`${n}opRNM(${t.name}): callback function return error. ACTIVE state not allowed.`);break;case e.EMPTY:r.phraseLength=0;break;case e.MATCH:0===r.phraseLength&&(r.state=e.EMPTY);break;case e.NOMATCH:r.phraseLength=0;break;default:throw new Error(`${n}opRNM(${t.name}): callback function return error. Unrecognized return state: ${r.state}`)}},E=(t,c)=>{let p,f,m;const d=i[t],y=a[d.index];b.UdtIndex=y.index,h||(m=r.ast&&r.ast.udtDefined(d.index),m&&(f=s.length+d.index,p=r.ast.getLength(),r.ast.down(f,y.name)));const g=o.length-c;l[d.index](b,o,c,u),((t,r,s)=>{if(r.phraseLength>s){let e=`${n}opUDT(${t.name}): callback function error: `;throw e+=`sysData.phraseLength: ${r.phraseLength}`,e+=` must be <= remaining chars: ${s}`,new Error(e)}switch(r.state){case e.ACTIVE:throw new Error(`${n}opUDT(${t.name}) ACTIVE state return not allowed.`);case e.EMPTY:if(!t.empty)throw new Error(`${n}opUDT(${t.name}) may not return EMPTY.`);r.phraseLength=0;break;case e.MATCH:if(0===r.phraseLength){if(!t.empty)throw new Error(`${n}opUDT(${t.name}) may not return EMPTY.`);r.state=e.EMPTY}break;case e.NOMATCH:r.phraseLength=0;break;default:throw new Error(`${n}opUDT(${t.name}): callback function return error. Unrecognized return state: ${r.state}`)}})(y,b,g),h||m&&(b.state===e.NOMATCH?r.ast.setLength(p):r.ast.up(f,y.name,c,b.phraseLength))},w=(t,a)=>{const l=`${n}opExecute(): `,m=i[t];switch(y+=1,p>f&&(f=p),p+=1,b.refresh(),r.trace&&r.trace.down(m,a),m.type){case e.ALT:((t,r)=>{const n=i[t];for(let t=0;t<n.children.length&&(w(n.children[t],r),b.state===e.NOMATCH);t+=1);})(t,a);break;case e.CAT:((t,n)=>{let s,a,o,c;const l=i[t];r.ast&&(a=r.ast.getLength()),s=!0,o=n,c=0;for(let t=0;t<l.children.length;t+=1){if(w(l.children[t],o),b.state===e.NOMATCH){s=!1;break}o+=b.phraseLength,c+=b.phraseLength}s?(b.state=0===c?e.EMPTY:e.MATCH,b.phraseLength=c):(b.state=e.NOMATCH,b.phraseLength=0,r.ast&&r.ast.setLength(a))})(t,a);break;case e.REP:((t,n)=>{let s,a,c,l;const u=i[t];if(0===u.max)return b.state=e.EMPTY,void(b.phraseLength=0);for(a=n,c=0,l=0,r.ast&&(s=r.ast.getLength());!(a>=o.length)&&(w(t+1,a),b.state!==e.NOMATCH)&&b.state!==e.EMPTY&&(l+=1,c+=b.phraseLength,a+=b.phraseLength,l!==u.max););b.state===e.EMPTY||l>=u.min?(b.state=0===c?e.EMPTY:e.MATCH,b.phraseLength=c):(b.state=e.NOMATCH,b.phraseLength=0,r.ast&&r.ast.setLength(s))})(t,a);break;case e.RNM:((t,n)=>{let a,l,p;const f=i[t],m=s[f.index],d=c[m.index];if(h||(l=r.ast&&r.ast.ruleDefined(f.index),l&&(a=r.ast.getLength(),r.ast.down(f.index,s[f.index].name))),d){const t=o.length-n;d(b,o,n,u),v(m,b,t,!0),b.state===e.ACTIVE&&(p=i,i=m.opcodes,w(0,n),i=p,d(b,o,n,u),v(m,b,t,!1))}else p=i,i=m.opcodes,w(0,n,b),i=p;h||l&&(b.state===e.NOMATCH?r.ast.setLength(a):r.ast.up(f.index,m.name,n,b.phraseLength))})(t,a);break;case e.TRG:((t,r)=>{const n=i[t];b.state=e.NOMATCH,r<o.length&&n.min<=o[r]&&o[r]<=n.max&&(b.state=e.MATCH,b.phraseLength=1)})(t,a);break;case e.TBS:((t,r)=>{const n=i[t],s=n.string.length;if(b.state=e.NOMATCH,r+s<=o.length){for(let e=0;e<s;e+=1)if(o[r+e]!==n.string[e])return;b.state=e.MATCH,b.phraseLength=s}})(t,a);break;case e.TLS:((t,r)=>{let n;const s=i[t];b.state=e.NOMATCH;const a=s.string.length;if(0!==a){if(r+a<=o.length){for(let e=0;e<a;e+=1)if(n=o[r+e],n>=65&&n<=90&&(n+=32),n!==s.string[e])return;b.state=e.MATCH,b.phraseLength=a}}else b.state=e.EMPTY})(t,a);break;case e.UDT:E(t,a);break;case e.AND:((t,r)=>{switch(h+=1,w(t+1,r),h-=1,b.phraseLength=0,b.state){case e.EMPTY:case e.MATCH:b.state=e.EMPTY;break;case e.NOMATCH:b.state=e.NOMATCH;break;default:throw new Error(`opAND: invalid state ${b.state}`)}})(t,a);break;case e.NOT:((t,r)=>{switch(h+=1,w(t+1,r),h-=1,b.phraseLength=0,b.state){case e.EMPTY:case e.MATCH:b.state=e.NOMATCH;break;case e.NOMATCH:b.state=e.EMPTY;break;default:throw new Error(`opNOT: invalid state ${b.state}`)}})(t,a);break;default:throw new Error(`${l}unrecognized operator`)}h||a+b.phraseLength>g&&(g=a+b.phraseLength),r.stats&&r.stats.collect(m,b),r.trace&&r.trace.up(m,b.state,a,b.phraseLength),p-=1}},h=function(){const e=d,t=m,r=this;let n,s,a,i=0;const o=[],c=[],l=[];function u(e){let t="";for(;e-- >0;)t+=" ";return t}r.callbacks=[],r.init=(e,t,u)=>{let h;c.length=0,l.length=0,i=0,n=e,s=t,a=u;const p=[];for(h=0;h<n.length;h+=1)p.push(n[h].lower);for(h=0;h<s.length;h+=1)p.push(s[h].lower);for(i=n.length+s.length,h=0;h<i;h+=1)o[h]=void 0;for(const e in r.callbacks)if(r.callbacks.hasOwnProperty(e)){const t=e.toLowerCase();if(h=p.indexOf(t),h<0)throw new Error(`parser.js: Ast()): init: node '${e}' not a rule or udt name`);o[h]=r.callbacks[e]}},r.ruleDefined=e=>!!o[e],r.udtDefined=e=>!!o[n.length+e],r.down=(t,r)=>{const n=l.length;return c.push(n),l.push({name:r,thisIndex:n,thatIndex:void 0,state:e.SEM_PRE,callbackIndex:t,phraseIndex:void 0,phraseLength:void 0,stack:c.length}),n},r.up=(t,r,n,s)=>{const a=l.length,i=c.pop();return l.push({name:r,thisIndex:a,thatIndex:i,state:e.SEM_POST,callbackIndex:t,phraseIndex:n,phraseLength:s,stack:c.length}),l[i].thatIndex=a,l[i].phraseIndex=n,l[i].phraseLength=s,a},r.translate=t=>{let r,n;for(let s=0;s<l.length;s+=1)n=l[s],r=o[n.callbackIndex],r&&(n.state===e.SEM_PRE?r(e.SEM_PRE,a,n.phraseIndex,n.phraseLength,t):r&&r(e.SEM_POST,a,n.phraseIndex,n.phraseLength,t))},r.setLength=e=>{l.length=e,c.length=e>0?l[e-1].stack:0},r.getLength=()=>l.length,r.toXml=()=>{let r="",n=0;return r+='<?xml version="1.0" encoding="utf-8"?>\n',r+=`<root nodes="${l.length/2}" characters="${a.length}">\n`,r+="\x3c!-- input string --\x3e\n",r+=u(n+2),r+=t.charsToString(a),r+="\n",l.forEach(s=>{s.state===e.SEM_PRE?(n+=1,r+=u(n),r+=`<node name="${s.name}" index="${s.phraseIndex}" length="${s.phraseLength}">\n`,r+=u(n+2),r+=t.charsToString(a,s.phraseIndex,s.phraseLength),r+="\n"):(r+=u(n),r+=`</node>\x3c!-- name="${s.name}" --\x3e\n`,n-=1)}),r+="</root>\n",r}},p=function(){const e=d,t=m,r="parser.js: Trace(): ";let n,s,a,i="",o=0;const c=this,l=e=>{let t="",r=0;if(e>=0)for(;e--;)r+=1,5===r?(t+="|",r=0):t+=".";return t};c.init=(e,t,r)=>{s=e,a=t,n=r};const u=n=>{let i;switch(n.type){case e.ALT:i="ALT";break;case e.CAT:i="CAT";break;case e.REP:i=n.max===1/0?`REP(${n.min},inf)`:`REP(${n.min},${n.max})`;break;case e.RNM:i=`RNM(${s[n.index].name})`;break;case e.TRG:i=`TRG(${n.min},${n.max})`;break;case e.TBS:i=n.string.length>6?`TBS(${t.charsToString(n.string,0,3)}...)`:`TBS(${t.charsToString(n.string,0,6)})`;break;case e.TLS:i=n.string.length>6?`TLS(${t.charsToString(n.string,0,3)}...)`:`TLS(${t.charsToString(n.string,0,6)})`;break;case e.UDT:i=`UDT(${a[n.index].name})`;break;case e.AND:i="AND";break;case e.NOT:i="NOT";break;default:throw new Error(`${r}Trace: opName: unrecognized opcode`)}return i};c.down=(e,r)=>{const s=l(o),a=Math.min(100,n.length-r);let c=t.charsToString(n,r,a);a<n.length-r&&(c+="..."),c=`${s}|-|[${u(e)}]${c}\n`,i+=c,o+=1},c.up=(s,a,c,h)=>{const p=`${r}trace.up: `;o-=1;const f=l(o);let m,d,y;switch(a){case e.EMPTY:y="|E|",d="''";break;case e.MATCH:y="|M|",m=Math.min(100,h),d=m<h?`'${t.charsToString(n,c,m)}...'`:`'${t.charsToString(n,c,m)}'`;break;case e.NOMATCH:y="|N|",d="";break;default:throw new Error(`${p} unrecognized state`)}d=`${f}${y}[${u(s)}]${d}\n`,i+=d},c.displayTrace=()=>i},f=function(){const e=d;let t,r,n;const s=[],a=[],i=[];this.init=(e,n)=>{t=e,r=n,p()},this.collect=(t,r)=>{f(n,r.state,r.phraseLength),f(s[t.type],r.state,r.phraseLength),t.type===e.RNM&&f(a[t.index],r.state,r.phraseLength),t.type===e.UDT&&f(i[t.index],r.state,r.phraseLength)},this.displayStats=()=>{let t="";const r={match:0,empty:0,nomatch:0,total:0},n=(e,t,n,s,a)=>{r.match+=t,r.empty+=n,r.nomatch+=s,r.total+=a;return`${e} | ${o(t)} | ${o(n)} | ${o(s)} | ${o(a)} |\n`};return t+=" OPERATOR STATS\n",t+=" | MATCH | EMPTY | NOMATCH | TOTAL |\n",t+=n(" ALT",s[e.ALT].match,s[e.ALT].empty,s[e.ALT].nomatch,s[e.ALT].total),t+=n(" CAT",s[e.CAT].match,s[e.CAT].empty,s[e.CAT].nomatch,s[e.CAT].total),t+=n(" REP",s[e.REP].match,s[e.REP].empty,s[e.REP].nomatch,s[e.REP].total),t+=n(" RNM",s[e.RNM].match,s[e.RNM].empty,s[e.RNM].nomatch,s[e.RNM].total),t+=n(" TRG",s[e.TRG].match,s[e.TRG].empty,s[e.TRG].nomatch,s[e.TRG].total),t+=n(" TBS",s[e.TBS].match,s[e.TBS].empty,s[e.TBS].nomatch,s[e.TBS].total),t+=n(" TLS",s[e.TLS].match,s[e.TLS].empty,s[e.TLS].nomatch,s[e.TLS].total),t+=n(" UDT",s[e.UDT].match,s[e.UDT].empty,s[e.UDT].nomatch,s[e.UDT].total),t+=n(" AND",s[e.AND].match,s[e.AND].empty,s[e.AND].nomatch,s[e.AND].total),t+=n(" NOT",s[e.NOT].match,s[e.NOT].empty,s[e.NOT].nomatch,s[e.NOT].total),t+=n("TOTAL",r.match,r.empty,r.nomatch,r.total),t},this.displayHits=e=>{let t="";const r=(e,t,r,s,a)=>{n.match+=e,n.empty+=t,n.nomatch+=r,n.total+=s;return`| ${o(e)} | ${o(t)} | ${o(r)} | ${o(s)} | ${a}\n`};"string"==typeof e&&"a"===e.toLowerCase()[0]?(a.sort(c),i.sort(c),t+=" RULES/UDTS ALPHABETICALLY\n"):"string"==typeof e&&"i"===e.toLowerCase()[0]?(a.sort(u),i.sort(u),t+=" RULES/UDTS BY INDEX\n"):(a.sort(l),i.sort(l),t+=" RULES/UDTS BY HIT COUNT\n"),t+="| MATCH | EMPTY | NOMATCH | TOTAL | NAME\n";for(let e=0;e<a.length;e+=1){let n=a[e];n.total&&(t+=r(n.match,n.empty,n.nomatch,n.total,n.name))}for(let e=0;e<i.length;e+=1){let n=i[e];n.total&&(t+=r(n.match,n.empty,n.nomatch,n.total,n.name))}return t};const o=e=>e<10?` ${e}`:e<100?` ${e}`:e<1e3?` ${e}`:e<1e4?` ${e}`:e<1e5?` ${e}`:e<1e6?` ${e}`:`${e}`,c=(e,t)=>e.lower<t.lower?-1:e.lower>t.lower?1:0,l=(e,t)=>e.total<t.total?1:e.total>t.total?-1:c(e,t),u=(e,t)=>e.index<t.index?-1:e.index>t.index?1:0,h=function(){this.empty=0,this.match=0,this.nomatch=0,this.total=0},p=()=>{s.length=0,n=new h,s[e.ALT]=new h,s[e.CAT]=new h,s[e.REP]=new h,s[e.RNM]=new h,s[e.TRG]=new h,s[e.TBS]=new h,s[e.TLS]=new h,s[e.UDT]=new h,s[e.AND]=new h,s[e.NOT]=new h,a.length=0;for(let e=0;e<t.length;e+=1)a.push({empty:0,match:0,nomatch:0,total:0,name:t[e].name,lower:t[e].lower,index:t[e].index});if(r.length>0){i.length=0;for(let e=0;e<r.length;e+=1)i.push({empty:0,match:0,nomatch:0,total:0,name:r[e].name,lower:r[e].lower,index:r[e].index})}},f=(t,r)=>{switch(t.total+=1,r){case e.EMPTY:t.empty+=1;break;case e.MATCH:t.match+=1;break;case e.NOMATCH:t.nomatch+=1;break;default:throw new Error(`parser.js: Stats(): collect(): incStat(): unrecognized state: ${r}`)}}},m={stringToChars:e=>[...e].map(e=>e.codePointAt(0)),charsToString:(e,t,r)=>{let n=e;for(;!(void 0===t||t<0);){if(void 0===r){n=e.slice(t);break}if(r<=0)return"";n=e.slice(t,t+r);break}return String.fromCodePoint(...n)}},d={ALT:1,CAT:2,REP:3,RNM:4,TRG:5,TBS:6,TLS:7,UDT:11,AND:12,NOT:13,ACTIVE:100,MATCH:101,EMPTY:102,NOMATCH:103,SEM_PRE:200,SEM_POST:201,SEM_OK:300,idName:e=>{switch(e){case d.ALT:return"ALT";case d.CAT:return"CAT";case d.REP:return"REP";case d.RNM:return"RNM";case d.TRG:return"TRG";case d.TBS:return"TBS";case d.TLS:return"TLS";case d.UDT:return"UDT";case d.AND:return"AND";case d.NOT:return"NOT";case d.ACTIVE:return"ACTIVE";case d.EMPTY:return"EMPTY";case d.MATCH:return"MATCH";case d.NOMATCH:return"NOMATCH";case d.SEM_PRE:return"SEM_PRE";case d.SEM_POST:return"SEM_POST";case d.SEM_OK:return"SEM_OK";default:return"UNRECOGNIZED STATE"}}};class y extends Error{constructor(e,t=void 0){if(super(e,t),this.name=this.constructor.name,"string"==typeof e&&(this.message=e),"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error(e).stack,null!=t&&"object"==typeof t&&Object.prototype.hasOwnProperty.call(t,"cause")&&!("cause"in this)){const{cause:e}=t;this.cause=e,e instanceof Error&&"stack"in e&&(this.stack=`${this.stack}\nCAUSE: ${e.stack}`)}if(null!=t&&"object"==typeof t){const{cause:e,...r}=t;Object.assign(this,r)}}}const g=y;const b=class extends g{},v=e=>(t,r,n,s,a)=>{if("object"!=typeof a||null===a||Array.isArray(a))throw new b("parser's user data must be an object");if(t===d.SEM_PRE){const t={type:e,text:m.charsToString(r,n,s),start:n,length:s,children:[]};if(a.stack.length>0){a.stack[a.stack.length-1].children.push(t)}else a.root=t;a.stack.push(t)}t===d.SEM_POST&&a.stack.pop()};const E=class extends h{constructor(){super(),this.callbacks["json-pointer"]=v("json-pointer"),this.callbacks["reference-token"]=v("reference-token"),this.callbacks.slash=v("text")}getTree(){const e={stack:[],root:null};return this.translate(e),delete e.stack,e}},w=e=>{if("string"!=typeof e)throw new TypeError("Reference token must be a string");return e.replace(/~1/g,"/").replace(/~0/g,"~")};const x=class extends E{getTree(){const{root:e}=super.getTree();return e.children.filter(({type:e})=>"reference-token"===e).map(({text:e})=>w(e))}};const T=class extends Array{toString(){return this.map(e=>`"${String(e)}"`).join(", ")}};const k=class extends p{inferExpectations(){const e=this.displayTrace().split("\n"),t=new Set;let r=-1;for(let n=0;n<e.length;n++){const s=e[n];if(s.includes("M|")){const e=s.match(/]'(.*)'$/);e&&e[1]&&(r=n)}if(n>r){const e=s.match(/N\|\[TLS\(([^)]+)\)]/);e&&t.add(e[1])}}return new T(...t)}},O=new l,j=(e,{translator:t=new x,stats:r=!1,trace:n=!1}={})=>{if("string"!=typeof e)throw new TypeError("JSON Pointer must be a string");try{const s=new u;t&&(s.ast=t),r&&(s.stats=new f),n&&(s.trace=new k);const a=s.parse(O,"json-pointer",e);return{result:a,tree:a.success&&t?s.ast.getTree():void 0,stats:s.stats,trace:s.trace}}catch(t){throw new b("Unexpected error during JSON Pointer parsing",{cause:t,jsonPointer:e})}};const A=class extends E{getTree(){return this.toXml()}},_=e=>{try{return j(e,{translator:null}).result.success}catch{return!1}},S=new l,P=new u,M=e=>{if("string"!=typeof e)return!1;try{return P.parse(S,"reference-token",e).success}catch{return!1}},N=new l,$=new u,C=e=>{if("string"!=typeof e)return!1;try{return $.parse(N,"array-location",e).success}catch{return!1}},L=new l,R=new u,I=e=>{if("string"!=typeof e)return!1;try{return R.parse(L,"array-index",e).success}catch{return!1}},V=new l,D=new u,z=e=>{if("string"!=typeof e)return!1;try{return D.parse(V,"array-dash",e).success}catch{return!1}},B=e=>{if("string"!=typeof e&&"number"!=typeof e)throw new TypeError("Reference token must be a string or number");return String(e).replace(/~/g,"~0").replace(/\//g,"~1")};const U=class extends g{},H=e=>{if(!Array.isArray(e))throw new TypeError("Reference tokens must be a list of strings or numbers");try{return 0===e.length?"":`/${e.map(e=>{if("string"!=typeof e&&"number"!=typeof e)throw new TypeError("Reference token must be a string or number");return B(String(e))}).join("/")}`}catch(t){throw new U("Unexpected error during JSON Pointer compilation",{cause:t,referenceTokens:e})}};const F=class{#e;#t;#r;constructor(e,t={}){this.#e=e,this.#e.steps=[],this.#e.failed=!1,this.#e.failedAt=-1,this.#e.message=`JSON Pointer "${t.jsonPointer}" was successfully evaluated against the provided value`,this.#e.context={...t,realm:t.realm.name},this.#t=[],this.#r=t.realm}step({referenceToken:e,input:t,output:r,success:n=!0,reason:s}){const a=this.#t.length;this.#t.push(e);const i={referenceToken:e,referenceTokenPosition:a,input:t,inputType:this.#r.isObject(t)?"object":this.#r.isArray(t)?"array":"unrecognized",output:r,success:n};s&&(i.reason=s),this.#e.steps.push(i),n||(this.#e.failed=!0,this.#e.failedAt=a,this.#e.message=s)}};const q=class{name="";isArray(e){throw new g("Realm.isArray(node) must be implemented in a subclass")}isObject(e){throw new g("Realm.isObject(node) must be implemented in a subclass")}sizeOf(e){throw new g("Realm.sizeOf(node) must be implemented in a subclass")}has(e,t){throw new g("Realm.has(node) must be implemented in a subclass")}evaluate(e,t){throw new g("Realm.evaluate(node) must be implemented in a subclass")}};const Y=class extends g{};const J=class extends Y{};const K=class extends q{name="json";isArray(e){return Array.isArray(e)}isObject(e){return"object"==typeof e&&null!==e&&!this.isArray(e)}sizeOf(e){return this.isArray(e)?e.length:this.isObject(e)?Object.keys(e).length:0}has(e,t){if(this.isArray(e)){const r=Number(t),n=r>>>0;if(r!==n)throw new J(`Invalid array index "${t}": index must be an unsinged 32-bit integer`,{referenceToken:t,currentValue:e,realm:this.name});return n<this.sizeOf(e)&&Object.prototype.hasOwnProperty.call(e,r)}return!!this.isObject(e)&&Object.prototype.hasOwnProperty.call(e,t)}evaluate(e,t){return this.isArray(e)?e[Number(t)]:e[t]}};const G=class extends Y{};const W=class extends Y{},X=(e,t,{strictArrays:r=!0,strictObjects:n=!0,realm:s=new K,trace:a=!0}={})=>{const{result:i,tree:o,trace:c}=j(t,{trace:!!a}),l="object"==typeof a&&null!==a?new F(a,{jsonPointer:t,referenceTokens:o,strictArrays:r,strictObjects:n,realm:s,value:e}):null;try{let a;if(!i.success){let r=`Invalid JSON Pointer: "${t}". Syntax error at position ${i.maxMatched}`;throw r+=c?`, expected ${c.inferExpectations()}`:"",new Y(r,{jsonPointer:t,currentValue:e,realm:s.name})}return o.reduce((e,i,c)=>{if(s.isArray(e)){if(z(i)){if(r)throw new J(`Invalid array index "-" at position ${c} in "${t}". The "-" token always refers to a nonexistent element during evaluation`,{jsonPointer:t,referenceTokens:o,referenceToken:i,referenceTokenPosition:c,currentValue:e,realm:s.name});return a=s.evaluate(e,String(s.sizeOf(e))),null==l||l.step({referenceToken:i,input:e,output:a}),a}if(!I(i))throw new J(`Invalid array index "${i}" at position ${c} in "${t}": index MUST be "0", or digits without a leading "0"`,{jsonPointer:t,referenceTokens:o,referenceToken:i,referenceTokenPosition:c,currentValue:e,realm:s.name});const n=Number(i);if(!Number.isSafeInteger(n))throw new J(`Invalid array index "${i}" at position ${c} in "${t}": index must be a safe integer`,{jsonPointer:t,referenceTokens:o,referenceToken:i,referenceTokenPosition:c,currentValue:e,realm:s.name});if(!s.has(e,i)&&r)throw new J(`Invalid array index "${i}" at position ${c} in "${t}": index not found in array`,{jsonPointer:t,referenceTokens:o,referenceToken:i,referenceTokenPosition:c,currentValue:e,realm:s.name});return a=s.evaluate(e,i),null==l||l.step({referenceToken:i,input:e,output:a}),a}if(s.isObject(e)){if(!s.has(e,i)&&n)throw new W(`Invalid object key "${i}" at position ${c} in "${t}": key not found in object`,{jsonPointer:t,referenceTokens:o,referenceToken:i,referenceTokenPosition:c,currentValue:e,realm:s.name});return a=s.evaluate(e,i),null==l||l.step({referenceToken:i,input:e,output:a}),a}throw new G(`Invalid reference token "${i}" at position ${c} in "${t}": cannot be applied to a non-object/non-array value`,{jsonPointer:t,referenceTokens:o,referenceToken:i,referenceTokenPosition:c,currentValue:e,realm:s.name})},e)}catch(e){if(null==l||l.step({referenceToken:e.referenceToken,input:e.currentValue,success:!1,reason:e.message}),e instanceof Y)throw e;throw new Y("Unexpected error during JSON Pointer evaluation",{cause:e,jsonPointer:t,referenceTokens:o})}};var Z=r(8326);class Q extends Z.Om{constructor(e,t,r){super(e,t,r),this.element="annotation"}get code(){return this.attributes.get("code")}set code(e){this.attributes.set("code",e)}}const ee=Q;class te extends Z.Om{constructor(e,t,r){super(e,t,r),this.element="comment"}}const re=te;function ne(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}function se(e){return function t(r){return 0===arguments.length||ne(r)?t:e.apply(this,arguments)}}function ae(e){return function t(r,n){switch(arguments.length){case 0:return t;case 1:return ne(r)?t:se(function(t){return e(r,t)});default:return ne(r)&&ne(n)?t:ne(r)?se(function(t){return e(t,n)}):ne(n)?se(function(t){return e(r,t)}):e(r,n)}}}function ie(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}function oe(e,t,r){for(var n=0,s=r.length;n<s;){if(e(t,r[n]))return!0;n+=1}return!1}function ce(e,t){return Object.prototype.hasOwnProperty.call(t,e)}const le="function"==typeof Object.is?Object.is:function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t};var ue=Object.prototype.toString;const he=function(){return"[object Arguments]"===ue.call(arguments)?function(e){return"[object Arguments]"===ue.call(e)}:function(e){return ce("callee",e)}}();var pe=!{toString:null}.propertyIsEnumerable("toString"),fe=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],me=function(){return arguments.propertyIsEnumerable("length")}(),de=function(e,t){for(var r=0;r<e.length;){if(e[r]===t)return!0;r+=1}return!1};const ye="function"!=typeof Object.keys||me?se(function(e){if(Object(e)!==e)return[];var t,r,n=[],s=me&&he(e);for(t in e)!ce(t,e)||s&&"length"===t||(n[n.length]=t);if(pe)for(r=fe.length-1;r>=0;)ce(t=fe[r],e)&&!de(n,t)&&(n[n.length]=t),r-=1;return n}):se(function(e){return Object(e)!==e?[]:Object.keys(e)});const ge=se(function(e){return null===e?"Null":void 0===e?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});function be(e,t,r,n){var s=ie(e);function a(e,t){return ve(e,t,r.slice(),n.slice())}return!oe(function(e,t){return!oe(a,t,e)},ie(t),s)}function ve(e,t,r,n){if(le(e,t))return!0;var s,a,i=ge(e);if(i!==ge(t))return!1;if("function"==typeof e["fantasy-land/equals"]||"function"==typeof t["fantasy-land/equals"])return"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t)&&"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e);if("function"==typeof e.equals||"function"==typeof t.equals)return"function"==typeof e.equals&&e.equals(t)&&"function"==typeof t.equals&&t.equals(e);switch(i){case"Arguments":case"Array":case"Object":if("function"==typeof e.constructor&&"Promise"===(s=e.constructor,null==(a=String(s).match(/^function (\w*)/))?"":a[1]))return e===t;break;case"Boolean":case"Number":case"String":if(typeof e!=typeof t||!le(e.valueOf(),t.valueOf()))return!1;break;case"Date":if(!le(e.valueOf(),t.valueOf()))return!1;break;case"Error":return e.name===t.name&&e.message===t.message;case"RegExp":if(e.source!==t.source||e.global!==t.global||e.ignoreCase!==t.ignoreCase||e.multiline!==t.multiline||e.sticky!==t.sticky||e.unicode!==t.unicode)return!1}for(var o=r.length-1;o>=0;){if(r[o]===e)return n[o]===t;o-=1}switch(i){case"Map":return e.size===t.size&&be(e.entries(),t.entries(),r.concat([e]),n.concat([t]));case"Set":return e.size===t.size&&be(e.values(),t.values(),r.concat([e]),n.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var c=ye(e);if(c.length!==ye(t).length)return!1;var l=r.concat([e]),u=n.concat([t]);for(o=c.length-1;o>=0;){var h=c[o];if(!ce(h,t)||!ve(t[h],e[h],l,u))return!1;o-=1}return!0}const Ee=ae(function(e,t){return ve(e,t,[],[])})(se(function(e){return function(){return e}})(void 0)());class we extends Z.wE{constructor(e,t,r){super(e,t,r),this.element="parseResult"}get api(){return this.children.filter(e=>e.classes.contains("api")).first}get results(){return this.children.filter(e=>e.classes.contains("result"))}get result(){return this.results.first}get annotations(){return this.children.filter(e=>"annotation"===e.element)}get warnings(){return this.children.filter(e=>"annotation"===e.element&&e.classes.contains("warning"))}get errors(){return this.children.filter(e=>"annotation"===e.element&&e.classes.contains("error"))}get isEmpty(){return this.children.reject(e=>"annotation"===e.element).isEmpty}replaceResult(e){const{result:t}=this;if(Ee(t))return!1;const r=this.content.findIndex(e=>e===t);return-1!==r&&(this.content[r]=e,!0)}}const xe=we;class Te extends Z.wE{constructor(e,t,r){super(e,t,r),this.element="sourceMap"}get positionStart(){return this.children.filter(e=>e.classes.contains("position")).get(0)}get positionEnd(){return this.children.filter(e=>e.classes.contains("position")).get(1)}set position(e){if(void 0===e)return;const t=new Z.wE([e.start.row,e.start.column,e.start.char]),r=new Z.wE([e.end.row,e.end.column,e.end.char]);t.classes.push("position"),r.classes.push("position"),this.push(t).push(r)}}const ke=Te,Oe=(e,t)=>"object"==typeof t&&null!==t&&e in t&&"function"==typeof t[e],je=e=>"object"==typeof e&&null!=e&&"_storedElement"in e&&"string"==typeof e._storedElement&&"_content"in e,Ae=(e,t)=>"object"==typeof t&&null!==t&&"primitive"in t&&("function"==typeof t.primitive&&t.primitive()===e),_e=(e,t)=>"object"==typeof t&&null!==t&&"classes"in t&&(Array.isArray(t.classes)||t.classes instanceof Z.wE)&&t.classes.includes(e),Se=(e,t)=>"object"==typeof t&&null!==t&&"element"in t&&t.element===e,Pe=e=>e({hasMethod:Oe,hasBasicElementProps:je,primitiveEq:Ae,isElementType:Se,hasClass:_e}),Me=(Pe(({hasBasicElementProps:e,primitiveEq:t})=>r=>r instanceof Z.Hg||e(r)&&t(void 0,r)),Pe(({hasBasicElementProps:e,primitiveEq:t})=>r=>r instanceof Z.Om||e(r)&&t("string",r)),Pe(({hasBasicElementProps:e,primitiveEq:t})=>r=>r instanceof Z.kT||e(r)&&t("number",r)),Pe(({hasBasicElementProps:e,primitiveEq:t})=>r=>r instanceof Z.Os||e(r)&&t("null",r)),Pe(({hasBasicElementProps:e,primitiveEq:t})=>r=>r instanceof Z.bd||e(r)&&t("boolean",r)),Pe(({hasBasicElementProps:e,primitiveEq:t,hasMethod:r})=>n=>n instanceof Z.Sh||e(n)&&t("object",n)&&r("keys",n)&&r("values",n)&&r("items",n))),Ne=Pe(({hasBasicElementProps:e,primitiveEq:t,hasMethod:r})=>n=>n instanceof Z.wE&&!(n instanceof Z.Sh)||e(n)&&t("array",n)&&r("push",n)&&r("unshift",n)&&r("map",n)&&r("reduce",n));Pe(({hasBasicElementProps:e,isElementType:t,primitiveEq:r})=>n=>n instanceof Z.Pr||e(n)&&t("member",n)&&r(void 0,n)),Pe(({hasBasicElementProps:e,isElementType:t,primitiveEq:r})=>n=>n instanceof Z.Ft||e(n)&&t("link",n)&&r(void 0,n)),Pe(({hasBasicElementProps:e,isElementType:t,primitiveEq:r})=>n=>n instanceof Z.sI||e(n)&&t("ref",n)&&r(void 0,n)),Pe(({hasBasicElementProps:e,isElementType:t,primitiveEq:r})=>n=>n instanceof ee||e(n)&&t("annotation",n)&&r("array",n)),Pe(({hasBasicElementProps:e,isElementType:t,primitiveEq:r})=>n=>n instanceof re||e(n)&&t("comment",n)&&r("string",n)),Pe(({hasBasicElementProps:e,isElementType:t,primitiveEq:r})=>n=>n instanceof xe||e(n)&&t("parseResult",n)&&r("array",n)),Pe(({hasBasicElementProps:e,isElementType:t,primitiveEq:r})=>n=>n instanceof ke||e(n)&&t("sourceMap",n)&&r("array",n));class $e extends q{name="apidom";isArray(e){return Ne(e)}isObject(e){return Me(e)}sizeOf(e){return this.isArray(e)||this.isObject(e)?e.length:0}has(e,t){if(this.isArray(e)){const r=Number(t),n=r>>>0;if(r!==n)throw new J(`Invalid array index "${t}": index must be an unsinged 32-bit integer`,{referenceToken:t,currentValue:e,realm:this.name});return n<this.sizeOf(e)}if(this.isObject(e)){const r=e.keys(),n=new Set(r);if(r.length!==n.size)throw new W(`Object key "${t}" is not unique — JSON Pointer requires unique member names`,{referenceToken:t,currentValue:e,realm:this.name});return e.hasKey(t)}return!1}evaluate(e,t){return this.isArray(e)?e.get(Number(t)):this.isObject(e)?e.get(t):void 0}}const Ce=(e,t,r={})=>X(e,t,{...r,realm:new $e})})(),n})());
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.apidomJsonPointer=t():e.apidomJsonPointer=t()}(self,()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ASTTranslator:()=>E,CSTTranslator:()=>w,Grammar:()=>l,JSONPointerCompileError:()=>z,JSONPointerError:()=>g,JSONPointerEvaluateError:()=>J,JSONPointerIndexError:()=>q,JSONPointerKeyError:()=>X,JSONPointerParseError:()=>T,JSONPointerTypeError:()=>K,JSONString:()=>r,URIFragmentIdentifier:()=>n,XMLTranslator:()=>S,compile:()=>B,escape:()=>U,evaluate:()=>Pe,parse:()=>O,testArrayDash:()=>H,testArrayIndex:()=>I,testArrayLocation:()=>_,testJSONPointer:()=>M,testReferenceToken:()=>N,unescape:()=>k});var r={};e.r(r),e.d(r,{from:()=>a,to:()=>s});var n={};e.r(n),e.d(n,{from:()=>i,fromURIReference:()=>c,to:()=>o});const s=e=>JSON.stringify(e),a=e=>{try{return String(JSON.parse(e))}catch{return e}},o=e=>`#${[...e].map(e=>/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/.test(e)?e:encodeURIComponent(e)).join("")}`,i=e=>{try{const t=e.startsWith("#")?e.slice(1):e;return decodeURIComponent(t)}catch{return e}},c=e=>{const t=e.indexOf("#"),r=-1===t?"#":e.substring(t);return i(r)};function l(){this.grammarObject="grammarObject",this.rules=[],this.rules[0]={name:"json-pointer",lower:"json-pointer",index:0,isBkr:!1},this.rules[1]={name:"reference-token",lower:"reference-token",index:1,isBkr:!1},this.rules[2]={name:"unescaped",lower:"unescaped",index:2,isBkr:!1},this.rules[3]={name:"escaped",lower:"escaped",index:3,isBkr:!1},this.rules[4]={name:"array-location",lower:"array-location",index:4,isBkr:!1},this.rules[5]={name:"array-index",lower:"array-index",index:5,isBkr:!1},this.rules[6]={name:"array-dash",lower:"array-dash",index:6,isBkr:!1},this.rules[7]={name:"slash",lower:"slash",index:7,isBkr:!1},this.udts=[],this.rules[0].opcodes=[],this.rules[0].opcodes[0]={type:3,min:0,max:1/0},this.rules[0].opcodes[1]={type:2,children:[2,3]},this.rules[0].opcodes[2]={type:4,index:7},this.rules[0].opcodes[3]={type:4,index:1},this.rules[1].opcodes=[],this.rules[1].opcodes[0]={type:3,min:0,max:1/0},this.rules[1].opcodes[1]={type:1,children:[2,3]},this.rules[1].opcodes[2]={type:4,index:2},this.rules[1].opcodes[3]={type:4,index:3},this.rules[2].opcodes=[],this.rules[2].opcodes[0]={type:1,children:[1,2,3]},this.rules[2].opcodes[1]={type:5,min:0,max:46},this.rules[2].opcodes[2]={type:5,min:48,max:125},this.rules[2].opcodes[3]={type:5,min:127,max:1114111},this.rules[3].opcodes=[],this.rules[3].opcodes[0]={type:2,children:[1,2]},this.rules[3].opcodes[1]={type:7,string:[126]},this.rules[3].opcodes[2]={type:1,children:[3,4]},this.rules[3].opcodes[3]={type:7,string:[48]},this.rules[3].opcodes[4]={type:7,string:[49]},this.rules[4].opcodes=[],this.rules[4].opcodes[0]={type:1,children:[1,2]},this.rules[4].opcodes[1]={type:4,index:5},this.rules[4].opcodes[2]={type:4,index:6},this.rules[5].opcodes=[],this.rules[5].opcodes[0]={type:1,children:[1,2]},this.rules[5].opcodes[1]={type:6,string:[48]},this.rules[5].opcodes[2]={type:2,children:[3,4]},this.rules[5].opcodes[3]={type:5,min:49,max:57},this.rules[5].opcodes[4]={type:3,min:0,max:1/0},this.rules[5].opcodes[5]={type:5,min:48,max:57},this.rules[6].opcodes=[],this.rules[6].opcodes[0]={type:7,string:[45]},this.rules[7].opcodes=[],this.rules[7].opcodes[0]={type:7,string:[47]},this.toString=function(){let e="";return e+="; JavaScript Object Notation (JSON) Pointer ABNF syntax\n",e+="; https://datatracker.ietf.org/doc/html/rfc6901\n",e+="json-pointer = *( slash reference-token ) ; MODIFICATION: surrogate text rule used\n",e+="reference-token = *( unescaped / escaped )\n",e+="unescaped = %x00-2E / %x30-7D / %x7F-10FFFF\n",e+=" ; %x2F ('/') and %x7E ('~') are excluded from 'unescaped'\n",e+='escaped = "~" ( "0" / "1" )\n',e+=" ; representing '~' and '/', respectively\n",e+="\n",e+="; https://datatracker.ietf.org/doc/html/rfc6901#section-4\n",e+="array-location = array-index / array-dash\n",e+="array-index = %x30 / ( %x31-39 *(%x30-39) )\n",e+=' ; "0", or digits without a leading "0"\n',e+='array-dash = "-"\n',e+="\n",e+="; Surrogate named rules\n",e+='slash = "/"\n','; JavaScript Object Notation (JSON) Pointer ABNF syntax\n; https://datatracker.ietf.org/doc/html/rfc6901\njson-pointer = *( slash reference-token ) ; MODIFICATION: surrogate text rule used\nreference-token = *( unescaped / escaped )\nunescaped = %x00-2E / %x30-7D / %x7F-10FFFF\n ; %x2F (\'/\') and %x7E (\'~\') are excluded from \'unescaped\'\nescaped = "~" ( "0" / "1" )\n ; representing \'~\' and \'/\', respectively\n\n; https://datatracker.ietf.org/doc/html/rfc6901#section-4\narray-location = array-index / array-dash\narray-index = %x30 / ( %x31-39 *(%x30-39) )\n ; "0", or digits without a leading "0"\narray-dash = "-"\n\n; Surrogate named rules\nslash = "/"\n'}}const h=function(){const e=m,t=d,r=this,n="parser.js: Parser(): ";r.ast=void 0,r.stats=void 0,r.trace=void 0,r.callbacks=[];let s,a,o,i,c,l,h,u=0,p=0,f=0,y=0,g=0,T=new function(){this.state=e.ACTIVE,this.phraseLength=0,this.refresh=()=>{this.state=e.ACTIVE,this.phraseLength=0}};r.parse=(d,m,b,w)=>{const E=`${n}parse(): `;u=0,p=0,f=0,y=0,g=0,s=void 0,a=void 0,o=void 0,i=void 0,T.refresh(),c=void 0,l=void 0,h=void 0,i=t.stringToChars(b),s=d.rules,a=d.udts;const A=m.toLowerCase();let x;for(const e in s)if(s.hasOwnProperty(e)&&A===s[e].lower){x=s[e].index;break}if(void 0===x)throw new Error(`${E}start rule name '${startRule}' not recognized`);(()=>{const e=`${n}initializeCallbacks(): `;let t,o;for(c=[],l=[],t=0;t<s.length;t+=1)c[t]=void 0;for(t=0;t<a.length;t+=1)l[t]=void 0;const i=[];for(t=0;t<s.length;t+=1)i.push(s[t].lower);for(t=0;t<a.length;t+=1)i.push(a[t].lower);for(const n in r.callbacks)if(r.callbacks.hasOwnProperty(n)){if(t=i.indexOf(n.toLowerCase()),t<0)throw new Error(`${e}syntax callback '${n}' not a rule or udt name`);if(o=r.callbacks[n]?r.callbacks[n]:void 0,"function"!=typeof o&&void 0!==o)throw new Error(`${e}syntax callback[${n}] must be function reference or falsy)`);t<s.length?c[t]=o:l[t-s.length]=o}})(),r.trace&&r.trace.init(s,a,i),r.stats&&r.stats.init(s,a),r.ast&&r.ast.init(s,a,i),h=w,o=[{type:e.RNM,index:x}],k(0,0),o=void 0;let v=!1;switch(T.state){case e.ACTIVE:throw new Error(`${E}final state should never be 'ACTIVE'`);case e.NOMATCH:v=!1;break;case e.EMPTY:case e.MATCH:v=T.phraseLength===i.length;break;default:throw new Error("unrecognized state")}return{success:v,state:T.state,stateName:e.idName(T.state),length:i.length,matched:T.phraseLength,maxMatched:g,maxTreeDepth:f,nodeHits:y}};const b=(t,r,s,a)=>{if(r.phraseLength>s){let e=`${n}opRNM(${t.name}): callback function error: `;throw e+=`sysData.phraseLength: ${r.phraseLength}`,e+=` must be <= remaining chars: ${s}`,new Error(e)}switch(r.state){case e.ACTIVE:if(!a)throw new Error(`${n}opRNM(${t.name}): callback function return error. ACTIVE state not allowed.`);break;case e.EMPTY:r.phraseLength=0;break;case e.MATCH:0===r.phraseLength&&(r.state=e.EMPTY);break;case e.NOMATCH:r.phraseLength=0;break;default:throw new Error(`${n}opRNM(${t.name}): callback function return error. Unrecognized return state: ${r.state}`)}},w=(t,c)=>{let p,f,d;const m=o[t],y=a[m.index];T.UdtIndex=y.index,u||(d=r.ast&&r.ast.udtDefined(m.index),d&&(f=s.length+m.index,p=r.ast.getLength(),r.ast.down(f,y.name)));const g=i.length-c;l[m.index](T,i,c,h),((t,r,s)=>{if(r.phraseLength>s){let e=`${n}opUDT(${t.name}): callback function error: `;throw e+=`sysData.phraseLength: ${r.phraseLength}`,e+=` must be <= remaining chars: ${s}`,new Error(e)}switch(r.state){case e.ACTIVE:throw new Error(`${n}opUDT(${t.name}) ACTIVE state return not allowed.`);case e.EMPTY:if(!t.empty)throw new Error(`${n}opUDT(${t.name}) may not return EMPTY.`);r.phraseLength=0;break;case e.MATCH:if(0===r.phraseLength){if(!t.empty)throw new Error(`${n}opUDT(${t.name}) may not return EMPTY.`);r.state=e.EMPTY}break;case e.NOMATCH:r.phraseLength=0;break;default:throw new Error(`${n}opUDT(${t.name}): callback function return error. Unrecognized return state: ${r.state}`)}})(y,T,g),u||d&&(T.state===e.NOMATCH?r.ast.setLength(p):r.ast.up(f,y.name,c,T.phraseLength))},k=(t,a)=>{const l=`${n}opExecute(): `,d=o[t];switch(y+=1,p>f&&(f=p),p+=1,T.refresh(),r.trace&&r.trace.down(d,a),d.type){case e.ALT:((t,r)=>{const n=o[t];for(let t=0;t<n.children.length&&(k(n.children[t],r),T.state===e.NOMATCH);t+=1);})(t,a);break;case e.CAT:((t,n)=>{let s,a,i,c;const l=o[t];r.ast&&(a=r.ast.getLength()),s=!0,i=n,c=0;for(let t=0;t<l.children.length;t+=1){if(k(l.children[t],i),T.state===e.NOMATCH){s=!1;break}i+=T.phraseLength,c+=T.phraseLength}s?(T.state=0===c?e.EMPTY:e.MATCH,T.phraseLength=c):(T.state=e.NOMATCH,T.phraseLength=0,r.ast&&r.ast.setLength(a))})(t,a);break;case e.REP:((t,n)=>{let s,a,c,l;const h=o[t];if(0===h.max)return T.state=e.EMPTY,void(T.phraseLength=0);for(a=n,c=0,l=0,r.ast&&(s=r.ast.getLength());!(a>=i.length)&&(k(t+1,a),T.state!==e.NOMATCH)&&T.state!==e.EMPTY&&(l+=1,c+=T.phraseLength,a+=T.phraseLength,l!==h.max););T.state===e.EMPTY||l>=h.min?(T.state=0===c?e.EMPTY:e.MATCH,T.phraseLength=c):(T.state=e.NOMATCH,T.phraseLength=0,r.ast&&r.ast.setLength(s))})(t,a);break;case e.RNM:((t,n)=>{let a,l,p;const f=o[t],d=s[f.index],m=c[d.index];if(u||(l=r.ast&&r.ast.ruleDefined(f.index),l&&(a=r.ast.getLength(),r.ast.down(f.index,s[f.index].name))),m){const t=i.length-n;m(T,i,n,h),b(d,T,t,!0),T.state===e.ACTIVE&&(p=o,o=d.opcodes,k(0,n),o=p,m(T,i,n,h),b(d,T,t,!1))}else p=o,o=d.opcodes,k(0,n,T),o=p;u||l&&(T.state===e.NOMATCH?r.ast.setLength(a):r.ast.up(f.index,d.name,n,T.phraseLength))})(t,a);break;case e.TRG:((t,r)=>{const n=o[t];T.state=e.NOMATCH,r<i.length&&n.min<=i[r]&&i[r]<=n.max&&(T.state=e.MATCH,T.phraseLength=1)})(t,a);break;case e.TBS:((t,r)=>{const n=o[t],s=n.string.length;if(T.state=e.NOMATCH,r+s<=i.length){for(let e=0;e<s;e+=1)if(i[r+e]!==n.string[e])return;T.state=e.MATCH,T.phraseLength=s}})(t,a);break;case e.TLS:((t,r)=>{let n;const s=o[t];T.state=e.NOMATCH;const a=s.string.length;if(0!==a){if(r+a<=i.length){for(let e=0;e<a;e+=1)if(n=i[r+e],n>=65&&n<=90&&(n+=32),n!==s.string[e])return;T.state=e.MATCH,T.phraseLength=a}}else T.state=e.EMPTY})(t,a);break;case e.UDT:w(t,a);break;case e.AND:((t,r)=>{switch(u+=1,k(t+1,r),u-=1,T.phraseLength=0,T.state){case e.EMPTY:case e.MATCH:T.state=e.EMPTY;break;case e.NOMATCH:T.state=e.NOMATCH;break;default:throw new Error(`opAND: invalid state ${T.state}`)}})(t,a);break;case e.NOT:((t,r)=>{switch(u+=1,k(t+1,r),u-=1,T.phraseLength=0,T.state){case e.EMPTY:case e.MATCH:T.state=e.NOMATCH;break;case e.NOMATCH:T.state=e.EMPTY;break;default:throw new Error(`opNOT: invalid state ${T.state}`)}})(t,a);break;default:throw new Error(`${l}unrecognized operator`)}u||a+T.phraseLength>g&&(g=a+T.phraseLength),r.stats&&r.stats.collect(d,T),r.trace&&r.trace.up(d,T.state,a,T.phraseLength),p-=1}},u=function(){const e=m,t=d,r=this;let n,s,a,o=0;const i=[],c=[],l=[];function h(e){let t="";for(;e-- >0;)t+=" ";return t}r.callbacks=[],r.init=(e,t,h)=>{let u;c.length=0,l.length=0,o=0,n=e,s=t,a=h;const p=[];for(u=0;u<n.length;u+=1)p.push(n[u].lower);for(u=0;u<s.length;u+=1)p.push(s[u].lower);for(o=n.length+s.length,u=0;u<o;u+=1)i[u]=void 0;for(const e in r.callbacks)if(r.callbacks.hasOwnProperty(e)){const t=e.toLowerCase();if(u=p.indexOf(t),u<0)throw new Error(`parser.js: Ast()): init: node '${e}' not a rule or udt name`);i[u]=r.callbacks[e]}},r.ruleDefined=e=>!!i[e],r.udtDefined=e=>!!i[n.length+e],r.down=(t,r)=>{const n=l.length;return c.push(n),l.push({name:r,thisIndex:n,thatIndex:void 0,state:e.SEM_PRE,callbackIndex:t,phraseIndex:void 0,phraseLength:void 0,stack:c.length}),n},r.up=(t,r,n,s)=>{const a=l.length,o=c.pop();return l.push({name:r,thisIndex:a,thatIndex:o,state:e.SEM_POST,callbackIndex:t,phraseIndex:n,phraseLength:s,stack:c.length}),l[o].thatIndex=a,l[o].phraseIndex=n,l[o].phraseLength=s,a},r.translate=t=>{let r,n;for(let s=0;s<l.length;s+=1)n=l[s],r=i[n.callbackIndex],r&&(n.state===e.SEM_PRE?r(e.SEM_PRE,a,n.phraseIndex,n.phraseLength,t):r&&r(e.SEM_POST,a,n.phraseIndex,n.phraseLength,t))},r.setLength=e=>{l.length=e,c.length=e>0?l[e-1].stack:0},r.getLength=()=>l.length,r.toXml=()=>{let r="",n=0;return r+='<?xml version="1.0" encoding="utf-8"?>\n',r+=`<root nodes="${l.length/2}" characters="${a.length}">\n`,r+="\x3c!-- input string --\x3e\n",r+=h(n+2),r+=t.charsToString(a),r+="\n",l.forEach(s=>{s.state===e.SEM_PRE?(n+=1,r+=h(n),r+=`<node name="${s.name}" index="${s.phraseIndex}" length="${s.phraseLength}">\n`,r+=h(n+2),r+=t.charsToString(a,s.phraseIndex,s.phraseLength),r+="\n"):(r+=h(n),r+=`</node>\x3c!-- name="${s.name}" --\x3e\n`,n-=1)}),r+="</root>\n",r}},p=function(){const e=m,t=d,r="parser.js: Trace(): ";let n,s,a,o="",i=0;const c=this,l=e=>{let t="",r=0;if(e>=0)for(;e--;)r+=1,5===r?(t+="|",r=0):t+=".";return t};c.init=(e,t,r)=>{s=e,a=t,n=r};const h=n=>{let o;switch(n.type){case e.ALT:o="ALT";break;case e.CAT:o="CAT";break;case e.REP:o=n.max===1/0?`REP(${n.min},inf)`:`REP(${n.min},${n.max})`;break;case e.RNM:o=`RNM(${s[n.index].name})`;break;case e.TRG:o=`TRG(${n.min},${n.max})`;break;case e.TBS:o=n.string.length>6?`TBS(${t.charsToString(n.string,0,3)}...)`:`TBS(${t.charsToString(n.string,0,6)})`;break;case e.TLS:o=n.string.length>6?`TLS(${t.charsToString(n.string,0,3)}...)`:`TLS(${t.charsToString(n.string,0,6)})`;break;case e.UDT:o=`UDT(${a[n.index].name})`;break;case e.AND:o="AND";break;case e.NOT:o="NOT";break;default:throw new Error(`${r}Trace: opName: unrecognized opcode`)}return o};c.down=(e,r)=>{const s=l(i),a=Math.min(100,n.length-r);let c=t.charsToString(n,r,a);a<n.length-r&&(c+="..."),c=`${s}|-|[${h(e)}]${c}\n`,o+=c,i+=1},c.up=(s,a,c,u)=>{const p=`${r}trace.up: `;i-=1;const f=l(i);let d,m,y;switch(a){case e.EMPTY:y="|E|",m="''";break;case e.MATCH:y="|M|",d=Math.min(100,u),m=d<u?`'${t.charsToString(n,c,d)}...'`:`'${t.charsToString(n,c,d)}'`;break;case e.NOMATCH:y="|N|",m="";break;default:throw new Error(`${p} unrecognized state`)}m=`${f}${y}[${h(s)}]${m}\n`,o+=m},c.displayTrace=()=>o},f=function(){const e=m;let t,r,n;const s=[],a=[],o=[];this.init=(e,n)=>{t=e,r=n,p()},this.collect=(t,r)=>{f(n,r.state,r.phraseLength),f(s[t.type],r.state,r.phraseLength),t.type===e.RNM&&f(a[t.index],r.state,r.phraseLength),t.type===e.UDT&&f(o[t.index],r.state,r.phraseLength)},this.displayStats=()=>{let t="";const r={match:0,empty:0,nomatch:0,total:0},n=(e,t,n,s,a)=>{r.match+=t,r.empty+=n,r.nomatch+=s,r.total+=a;return`${e} | ${i(t)} | ${i(n)} | ${i(s)} | ${i(a)} |\n`};return t+=" OPERATOR STATS\n",t+=" | MATCH | EMPTY | NOMATCH | TOTAL |\n",t+=n(" ALT",s[e.ALT].match,s[e.ALT].empty,s[e.ALT].nomatch,s[e.ALT].total),t+=n(" CAT",s[e.CAT].match,s[e.CAT].empty,s[e.CAT].nomatch,s[e.CAT].total),t+=n(" REP",s[e.REP].match,s[e.REP].empty,s[e.REP].nomatch,s[e.REP].total),t+=n(" RNM",s[e.RNM].match,s[e.RNM].empty,s[e.RNM].nomatch,s[e.RNM].total),t+=n(" TRG",s[e.TRG].match,s[e.TRG].empty,s[e.TRG].nomatch,s[e.TRG].total),t+=n(" TBS",s[e.TBS].match,s[e.TBS].empty,s[e.TBS].nomatch,s[e.TBS].total),t+=n(" TLS",s[e.TLS].match,s[e.TLS].empty,s[e.TLS].nomatch,s[e.TLS].total),t+=n(" UDT",s[e.UDT].match,s[e.UDT].empty,s[e.UDT].nomatch,s[e.UDT].total),t+=n(" AND",s[e.AND].match,s[e.AND].empty,s[e.AND].nomatch,s[e.AND].total),t+=n(" NOT",s[e.NOT].match,s[e.NOT].empty,s[e.NOT].nomatch,s[e.NOT].total),t+=n("TOTAL",r.match,r.empty,r.nomatch,r.total),t},this.displayHits=e=>{let t="";const r=(e,t,r,s,a)=>{n.match+=e,n.empty+=t,n.nomatch+=r,n.total+=s;return`| ${i(e)} | ${i(t)} | ${i(r)} | ${i(s)} | ${a}\n`};"string"==typeof e&&"a"===e.toLowerCase()[0]?(a.sort(c),o.sort(c),t+=" RULES/UDTS ALPHABETICALLY\n"):"string"==typeof e&&"i"===e.toLowerCase()[0]?(a.sort(h),o.sort(h),t+=" RULES/UDTS BY INDEX\n"):(a.sort(l),o.sort(l),t+=" RULES/UDTS BY HIT COUNT\n"),t+="| MATCH | EMPTY | NOMATCH | TOTAL | NAME\n";for(let e=0;e<a.length;e+=1){let n=a[e];n.total&&(t+=r(n.match,n.empty,n.nomatch,n.total,n.name))}for(let e=0;e<o.length;e+=1){let n=o[e];n.total&&(t+=r(n.match,n.empty,n.nomatch,n.total,n.name))}return t};const i=e=>e<10?` ${e}`:e<100?` ${e}`:e<1e3?` ${e}`:e<1e4?` ${e}`:e<1e5?` ${e}`:e<1e6?` ${e}`:`${e}`,c=(e,t)=>e.lower<t.lower?-1:e.lower>t.lower?1:0,l=(e,t)=>e.total<t.total?1:e.total>t.total?-1:c(e,t),h=(e,t)=>e.index<t.index?-1:e.index>t.index?1:0,u=function(){this.empty=0,this.match=0,this.nomatch=0,this.total=0},p=()=>{s.length=0,n=new u,s[e.ALT]=new u,s[e.CAT]=new u,s[e.REP]=new u,s[e.RNM]=new u,s[e.TRG]=new u,s[e.TBS]=new u,s[e.TLS]=new u,s[e.UDT]=new u,s[e.AND]=new u,s[e.NOT]=new u,a.length=0;for(let e=0;e<t.length;e+=1)a.push({empty:0,match:0,nomatch:0,total:0,name:t[e].name,lower:t[e].lower,index:t[e].index});if(r.length>0){o.length=0;for(let e=0;e<r.length;e+=1)o.push({empty:0,match:0,nomatch:0,total:0,name:r[e].name,lower:r[e].lower,index:r[e].index})}},f=(t,r)=>{switch(t.total+=1,r){case e.EMPTY:t.empty+=1;break;case e.MATCH:t.match+=1;break;case e.NOMATCH:t.nomatch+=1;break;default:throw new Error(`parser.js: Stats(): collect(): incStat(): unrecognized state: ${r}`)}}},d={stringToChars:e=>[...e].map(e=>e.codePointAt(0)),charsToString:(e,t,r)=>{let n=e;for(;!(void 0===t||t<0);){if(void 0===r){n=e.slice(t);break}if(r<=0)return"";n=e.slice(t,t+r);break}return String.fromCodePoint(...n)}},m={ALT:1,CAT:2,REP:3,RNM:4,TRG:5,TBS:6,TLS:7,UDT:11,AND:12,NOT:13,ACTIVE:100,MATCH:101,EMPTY:102,NOMATCH:103,SEM_PRE:200,SEM_POST:201,SEM_OK:300,idName:e=>{switch(e){case m.ALT:return"ALT";case m.CAT:return"CAT";case m.REP:return"REP";case m.RNM:return"RNM";case m.TRG:return"TRG";case m.TBS:return"TBS";case m.TLS:return"TLS";case m.UDT:return"UDT";case m.AND:return"AND";case m.NOT:return"NOT";case m.ACTIVE:return"ACTIVE";case m.EMPTY:return"EMPTY";case m.MATCH:return"MATCH";case m.NOMATCH:return"NOMATCH";case m.SEM_PRE:return"SEM_PRE";case m.SEM_POST:return"SEM_POST";case m.SEM_OK:return"SEM_OK";default:return"UNRECOGNIZED STATE"}}};class y extends Error{constructor(e,t=void 0){if(super(e,t),this.name=this.constructor.name,"string"==typeof e&&(this.message=e),"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error(e).stack,null!=t&&"object"==typeof t&&Object.prototype.hasOwnProperty.call(t,"cause")&&!("cause"in this)){const{cause:e}=t;this.cause=e,e instanceof Error&&"stack"in e&&(this.stack=`${this.stack}\nCAUSE: ${e.stack}`)}if(null!=t&&"object"==typeof t){const{cause:e,...r}=t;Object.assign(this,r)}}}const g=y;const T=class extends g{},b=e=>(t,r,n,s,a)=>{if("object"!=typeof a||null===a||Array.isArray(a))throw new T("parser's user data must be an object");if(t===m.SEM_PRE){const t={type:e,text:d.charsToString(r,n,s),start:n,length:s,children:[]};if(a.stack.length>0){a.stack[a.stack.length-1].children.push(t)}else a.root=t;a.stack.push(t)}t===m.SEM_POST&&a.stack.pop()};const w=class extends u{constructor(){super(),this.callbacks["json-pointer"]=b("json-pointer"),this.callbacks["reference-token"]=b("reference-token"),this.callbacks.slash=b("text")}getTree(){const e={stack:[],root:null};return this.translate(e),delete e.stack,e}},k=e=>{if("string"!=typeof e)throw new TypeError("Reference token must be a string");return e.replace(/~1/g,"/").replace(/~0/g,"~")};const E=class extends w{getTree(){const{root:e}=super.getTree();return e.children.filter(({type:e})=>"reference-token"===e).map(({text:e})=>k(e))}};const A=class extends Array{toString(){return this.map(e=>`"${String(e)}"`).join(", ")}};const x=class extends p{inferExpectations(){const e=this.displayTrace().split("\n"),t=new Set;let r=-1;for(let n=0;n<e.length;n++){const s=e[n];if(s.includes("M|")){const e=s.match(/]'(.*)'$/);e&&e[1]&&(r=n)}if(n>r){const e=s.match(/N\|\[TLS\(([^)]+)\)]/);e&&t.add(e[1])}}return new A(...t)}},v=new l,O=(e,{translator:t=new E,stats:r=!1,trace:n=!1}={})=>{if("string"!=typeof e)throw new TypeError("JSON Pointer must be a string");try{const s=new h;t&&(s.ast=t),r&&(s.stats=new f),n&&(s.trace=new x);const a=s.parse(v,"json-pointer",e);return{result:a,tree:a.success&&t?s.ast.getTree():void 0,stats:s.stats,trace:s.trace}}catch(t){throw new T("Unexpected error during JSON Pointer parsing",{cause:t,jsonPointer:e})}};const S=class extends w{getTree(){return this.toXml()}},M=e=>{try{return O(e,{translator:null}).result.success}catch{return!1}},P=new l,$=new h,N=e=>{if("string"!=typeof e)return!1;try{return $.parse(P,"reference-token",e).success}catch{return!1}},L=new l,j=new h,_=e=>{if("string"!=typeof e)return!1;try{return j.parse(L,"array-location",e).success}catch{return!1}},C=new l,R=new h,I=e=>{if("string"!=typeof e)return!1;try{return R.parse(C,"array-index",e).success}catch{return!1}},D=new l,V=new h,H=e=>{if("string"!=typeof e)return!1;try{return V.parse(D,"array-dash",e).success}catch{return!1}},U=e=>{if("string"!=typeof e&&"number"!=typeof e)throw new TypeError("Reference token must be a string or number");return String(e).replace(/~/g,"~0").replace(/\//g,"~1")};const z=class extends g{},B=e=>{if(!Array.isArray(e))throw new TypeError("Reference tokens must be a list of strings or numbers");try{return 0===e.length?"":`/${e.map(e=>{if("string"!=typeof e&&"number"!=typeof e)throw new TypeError("Reference token must be a string or number");return U(String(e))}).join("/")}`}catch(t){throw new z("Unexpected error during JSON Pointer compilation",{cause:t,referenceTokens:e})}};const Y=class{#e;#t;#r;constructor(e,t={}){this.#e=e,this.#e.steps=[],this.#e.failed=!1,this.#e.failedAt=-1,this.#e.message=`JSON Pointer "${t.jsonPointer}" was successfully evaluated against the provided value`,this.#e.context={...t,realm:t.realm.name},this.#t=[],this.#r=t.realm}step({referenceToken:e,input:t,output:r,success:n=!0,reason:s}){const a=this.#t.length;this.#t.push(e);const o={referenceToken:e,referenceTokenPosition:a,input:t,inputType:this.#r.isObject(t)?"object":this.#r.isArray(t)?"array":"unrecognized",output:r,success:n};s&&(o.reason=s),this.#e.steps.push(o),n||(this.#e.failed=!0,this.#e.failedAt=a,this.#e.message=s)}};const F=class{name="";isArray(e){throw new g("Realm.isArray(node) must be implemented in a subclass")}isObject(e){throw new g("Realm.isObject(node) must be implemented in a subclass")}sizeOf(e){throw new g("Realm.sizeOf(node) must be implemented in a subclass")}has(e,t){throw new g("Realm.has(node) must be implemented in a subclass")}evaluate(e,t){throw new g("Realm.evaluate(node) must be implemented in a subclass")}};const J=class extends g{};const q=class extends J{};const G=class extends F{name="json";isArray(e){return Array.isArray(e)}isObject(e){return"object"==typeof e&&null!==e&&!this.isArray(e)}sizeOf(e){return this.isArray(e)?e.length:this.isObject(e)?Object.keys(e).length:0}has(e,t){if(this.isArray(e)){const r=Number(t),n=r>>>0;if(r!==n)throw new q(`Invalid array index "${t}": index must be an unsinged 32-bit integer`,{referenceToken:t,currentValue:e,realm:this.name});return n<this.sizeOf(e)&&Object.prototype.hasOwnProperty.call(e,r)}return!!this.isObject(e)&&Object.prototype.hasOwnProperty.call(e,t)}evaluate(e,t){return this.isArray(e)?e[Number(t)]:e[t]}};const K=class extends J{};const X=class extends J{},Z=(e,t,{strictArrays:r=!0,strictObjects:n=!0,realm:s=new G,trace:a=!0}={})=>{const{result:o,tree:i,trace:c}=O(t,{trace:!!a}),l="object"==typeof a&&null!==a?new Y(a,{jsonPointer:t,referenceTokens:i,strictArrays:r,strictObjects:n,realm:s,value:e}):null;try{let a;if(!o.success){let r=`Invalid JSON Pointer: "${t}". Syntax error at position ${o.maxMatched}`;throw r+=c?`, expected ${c.inferExpectations()}`:"",new J(r,{jsonPointer:t,currentValue:e,realm:s.name})}return i.reduce((e,o,c)=>{if(s.isArray(e)){if(H(o)){if(r)throw new q(`Invalid array index "-" at position ${c} in "${t}". The "-" token always refers to a nonexistent element during evaluation`,{jsonPointer:t,referenceTokens:i,referenceToken:o,referenceTokenPosition:c,currentValue:e,realm:s.name});return a=s.evaluate(e,String(s.sizeOf(e))),null==l||l.step({referenceToken:o,input:e,output:a}),a}if(!I(o))throw new q(`Invalid array index "${o}" at position ${c} in "${t}": index MUST be "0", or digits without a leading "0"`,{jsonPointer:t,referenceTokens:i,referenceToken:o,referenceTokenPosition:c,currentValue:e,realm:s.name});const n=Number(o);if(!Number.isSafeInteger(n))throw new q(`Invalid array index "${o}" at position ${c} in "${t}": index must be a safe integer`,{jsonPointer:t,referenceTokens:i,referenceToken:o,referenceTokenPosition:c,currentValue:e,realm:s.name});if(!s.has(e,o)&&r)throw new q(`Invalid array index "${o}" at position ${c} in "${t}": index not found in array`,{jsonPointer:t,referenceTokens:i,referenceToken:o,referenceTokenPosition:c,currentValue:e,realm:s.name});return a=s.evaluate(e,o),null==l||l.step({referenceToken:o,input:e,output:a}),a}if(s.isObject(e)){if(!s.has(e,o)&&n)throw new X(`Invalid object key "${o}" at position ${c} in "${t}": key not found in object`,{jsonPointer:t,referenceTokens:i,referenceToken:o,referenceTokenPosition:c,currentValue:e,realm:s.name});return a=s.evaluate(e,o),null==l||l.step({referenceToken:o,input:e,output:a}),a}throw new K(`Invalid reference token "${o}" at position ${c} in "${t}": cannot be applied to a non-object/non-array value`,{jsonPointer:t,referenceTokens:i,referenceToken:o,referenceTokenPosition:c,currentValue:e,realm:s.name})},e)}catch(e){if(null==l||l.step({referenceToken:e.referenceToken,input:e.currentValue,success:!1,reason:e.message}),e instanceof J)throw e;throw new J("Unexpected error during JSON Pointer evaluation",{cause:e,jsonPointer:t,referenceTokens:i})}};function W(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}function Q(e){return function t(r){return 0===arguments.length||W(r)?t:e.apply(this,arguments)}}function ee(e){return function t(r,n){switch(arguments.length){case 0:return t;case 1:return W(r)?t:Q(function(t){return e(r,t)});default:return W(r)&&W(n)?t:W(r)?Q(function(t){return e(t,n)}):W(n)?Q(function(t){return e(r,t)}):e(r,n)}}}function te(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}function re(e,t,r){for(var n=0,s=r.length;n<s;){if(e(t,r[n]))return!0;n+=1}return!1}function ne(e,t){return Object.prototype.hasOwnProperty.call(t,e)}const se="function"==typeof Object.is?Object.is:function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t};var ae=Object.prototype.toString;const oe=function(){return"[object Arguments]"===ae.call(arguments)?function(e){return"[object Arguments]"===ae.call(e)}:function(e){return ne("callee",e)}}();var ie=!{toString:null}.propertyIsEnumerable("toString"),ce=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],le=function(){return arguments.propertyIsEnumerable("length")}(),he=function(e,t){for(var r=0;r<e.length;){if(e[r]===t)return!0;r+=1}return!1};const ue="function"!=typeof Object.keys||le?Q(function(e){if(Object(e)!==e)return[];var t,r,n=[],s=le&&oe(e);for(t in e)!ne(t,e)||s&&"length"===t||(n[n.length]=t);if(ie)for(r=ce.length-1;r>=0;)ne(t=ce[r],e)&&!he(n,t)&&(n[n.length]=t),r-=1;return n}):Q(function(e){return Object(e)!==e?[]:Object.keys(e)});const pe=Q(function(e){return null===e?"Null":void 0===e?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});function fe(e,t,r,n){var s=te(e);function a(e,t){return de(e,t,r.slice(),n.slice())}return!re(function(e,t){return!re(a,t,e)},te(t),s)}function de(e,t,r,n){if(se(e,t))return!0;var s,a,o=pe(e);if(o!==pe(t))return!1;if("function"==typeof e["fantasy-land/equals"]||"function"==typeof t["fantasy-land/equals"])return"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t)&&"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e);if("function"==typeof e.equals||"function"==typeof t.equals)return"function"==typeof e.equals&&e.equals(t)&&"function"==typeof t.equals&&t.equals(e);switch(o){case"Arguments":case"Array":case"Object":if("function"==typeof e.constructor&&"Promise"===(s=e.constructor,null==(a=String(s).match(/^function (\w*)/))?"":a[1]))return e===t;break;case"Boolean":case"Number":case"String":if(typeof e!=typeof t||!se(e.valueOf(),t.valueOf()))return!1;break;case"Date":if(!se(e.valueOf(),t.valueOf()))return!1;break;case"Error":return e.name===t.name&&e.message===t.message;case"RegExp":if(e.source!==t.source||e.global!==t.global||e.ignoreCase!==t.ignoreCase||e.multiline!==t.multiline||e.sticky!==t.sticky||e.unicode!==t.unicode)return!1}for(var i=r.length-1;i>=0;){if(r[i]===e)return n[i]===t;i-=1}switch(o){case"Map":return e.size===t.size&&fe(e.entries(),t.entries(),r.concat([e]),n.concat([t]));case"Set":return e.size===t.size&&fe(e.values(),t.values(),r.concat([e]),n.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var c=ue(e);if(c.length!==ue(t).length)return!1;var l=r.concat([e]),h=n.concat([t]);for(i=c.length-1;i>=0;){var u=c[i];if(!ne(u,t)||!de(t[u],e[u],l,h))return!1;i-=1}return!0}const me=ee(function(e,t){return de(e,t,[],[])});const ye=class{key;value;constructor(e,t){this.key=e,this.value=t}toValue(){return{key:this.key?.toValue(),value:this.value?.toValue()}}};class ge{elements;constructor(e){this.elements=e??[]}toValue(){return this.elements.map(e=>({key:e.key?.toValue(),value:e.value?.toValue()}))}map(e,t){return this.elements.map(r=>{const n=r.value,s=r.key;if(void 0===n||void 0===s)throw new Error("MemberElement must have both key and value");return void 0!==t?e.call(t,n,s,r):e(n,s,r)})}filter(e,t){const r=this.elements.filter(r=>{const n=r.value,s=r.key;return void 0!==n&&void 0!==s&&(void 0!==t?e.call(t,n,s,r):e(n,s,r))});return new ge(r)}reject(e,t){const r=[];for(const n of this.elements){const s=n.value,a=n.key;void 0!==s&&void 0!==a&&(e.call(t,s,a,n)||r.push(n))}return new ge(r)}forEach(e,t){this.elements.forEach((r,n)=>{const s=r.value,a=r.key;void 0!==s&&void 0!==a&&(void 0!==t?e.call(t,s,a,r,n):e(s,a,r,n))})}find(e,t){return this.elements.find(r=>{const n=r.value,s=r.key;return void 0!==n&&void 0!==s&&(void 0!==t?e.call(t,n,s,r):e(n,s,r))})}keys(){return this.elements.map(e=>e.key?.toValue()).filter(e=>void 0!==e)}values(){return this.elements.map(e=>e.value?.toValue()).filter(e=>void 0!==e)}get length(){return this.elements.length}get isEmpty(){return 0===this.length}get first(){return this.elements[0]}get(e){return this.elements[e]}push(e){return this.elements.push(e),this}includesKey(e){return this.elements.some(t=>t.key?.equals(e))}[Symbol.iterator](){return this.elements[Symbol.iterator]()}}const Te=ge;class be{parent;startLine;startCharacter;startOffset;endLine;endCharacter;endOffset;_storedElement="element";_content;_meta;_attributes;constructor(e,t,r){void 0!==t&&(this.meta=t),void 0!==r&&(this.attributes=r),void 0!==e&&(this.content=e)}get element(){return this._storedElement}set element(e){this._storedElement=e}get content(){return this._content}set content(e){if(e instanceof be)this._content=e;else if(null!=e&&"string"!=typeof e&&"number"!=typeof e&&"boolean"!=typeof e&&"bigint"!=typeof e&&"symbol"!=typeof e)if(e instanceof ye)this._content=e;else if(e instanceof Te)this._content=e.elements;else if(Array.isArray(e))this._content=e.map(e=>this.refract(e));else{if("object"!=typeof e)throw new Error("Cannot set content to value of type "+typeof e);this._content=Object.entries(e).map(([e,t])=>new this.MemberElement(e,t))}else this._content=e}get meta(){if(!this._meta){if(this.isFrozen){const e=new this.ObjectElement;return e.freeze(),e}this._meta=new this.ObjectElement}return this._meta}set meta(e){e instanceof be?this._meta=e:this.meta.set(e??{})}get attributes(){if(!this._attributes){if(this.isFrozen){const e=new this.ObjectElement;return e.freeze(),e}this._attributes=new this.ObjectElement}return this._attributes}set attributes(e){e instanceof be?this._attributes=e:this.attributes.set(e??{})}get id(){return this.getMetaProperty("id","")}set id(e){this.setMetaProperty("id",e)}get classes(){return this.getMetaProperty("classes",[])}set classes(e){this.setMetaProperty("classes",e)}get links(){return this.getMetaProperty("links",[])}set links(e){this.setMetaProperty("links",e)}get children(){const{_content:e}=this;if(Array.isArray(e))return e;if(e instanceof ye){const t=[];return e.key&&t.push(e.key),e.value&&t.push(e.value),t}return e instanceof be?[e]:[]}get isFrozen(){return Object.isFrozen(this)}freeze(){if(!this.isFrozen){this._meta&&(this._meta.parent=this,this._meta.freeze()),this._attributes&&(this._attributes.parent=this,this._attributes.freeze());for(const e of this.children)e.parent=this,e.freeze();Array.isArray(this._content)&&Object.freeze(this._content),Object.freeze(this)}}toValue(){const{_content:e}=this;return e instanceof be||e instanceof ye?e.toValue():Array.isArray(e)?e.map(e=>e.toValue()):e}equals(e){return me(this.toValue(),e)}primitive(){}set(e){return this.content=e,this}toRef(e){const t=this.id.toValue();if(""===t)throw new Error("Cannot create reference to an element without an ID");const r=new this.RefElement(t);return"string"==typeof e&&(r.path=this.refract(e)),r}getMetaProperty(e,t){if(!this.meta.hasKey(e)){if(this.isFrozen){const e=this.refract(t);return e.freeze(),e}this.meta.set(e,t)}return this.meta.get(e)}setMetaProperty(e,t){this.meta.set(e,t)}hasMetaProperty(e){return!this.isMetaEmpty&&this.meta.hasKey(e)}get isMetaEmpty(){return void 0===this._meta||this.meta.isEmpty}getAttributesProperty(e,t){if(!this.hasAttributesProperty(e)){if(this.isFrozen){const e=this.refract(t);return e.freeze(),e}this.attributes.set(e,t)}return this.attributes.get(e)}setAttributesProperty(e,t){this.attributes.set(e,t)}hasAttributesProperty(e){return!this.isAttributesEmpty&&this.attributes.hasKey(e)}get isAttributesEmpty(){return void 0===this._attributes||this.attributes.isEmpty}}const we=be;class ke extends we{constructor(e,t,r){super(e||[],t,r)}get length(){return this._content.length}get isEmpty(){return 0===this.length}get first(){return this._content[0]}get second(){return this._content[1]}get last(){return this._content.at(-1)}push(...e){for(const t of e)this._content.push(this.refract(t));return this}shift(){return this._content.shift()}unshift(e){this._content.unshift(this.refract(e))}includes(e){return this._content.some(t=>t.equals(e))}findElements(e,t){const r=t||{},n=!!r.recursive,s=void 0===r.results?[]:r.results;for(let t=0;t<this._content.length;t+=1){const r=this._content[t],a=r;n&&"function"==typeof a.findElements&&a.findElements(e,{results:s,recursive:n}),e(r,t,void 0)&&s.push(r)}return s}find(e){const t=this.findElements(e,{recursive:!0});return new this.ArrayElement(t)}findByElement(e){return this.find(t=>t.element===e)}findByClass(e){return this.find(t=>{const r=t.classes;return"function"==typeof r.includes&&r.includes(e)})}getById(e){return this.find(t=>t.id.toValue()===e).first}concat(e){return new(0,this.constructor)(this._content.concat(e._content))}[Symbol.iterator](){return this._content[Symbol.iterator]()}}const Ee=ke;const Ae=class extends Ee{constructor(e,t,r){super(e||[],t,r),this.element="array"}primitive(){return"array"}get(e){return this._content[e]}getValue(e){const t=this.get(e);if(t)return t.toValue()}set(e,t){return"number"==typeof e&&void 0!==t?this._content[e]=this.refract(t):this.content=e,this}remove(e){return this._content.splice(e,1)[0]??null}map(e,t){return this._content.map(e,t)}flatMap(e,t){return this._content.flatMap(e,t)}compactMap(e,t){const r=[];for(const n of this._content){const s=e.call(t,n);s&&r.push(s)}return r}filter(e,t){const r=this._content.filter(e,t);return new this.constructor(r)}reject(e,t){const r=[];for(const n of this._content)e.call(t,n)||r.push(n);return new this.constructor(r)}reduce(e,t){let r,n;void 0!==t?(r=0,n=this.refract(t)):(r=1,n=this.first);for(let t=r;t<this.length;t+=1){const r=e(n,this._content[t],t,this);n=void 0===r?r:this.refract(r)}return n}forEach(e,t){this._content.forEach((r,n)=>{e.call(t,r,n)})}empty(){return new this.constructor([])}};const xe=class extends we{constructor(e,t,r,n){super(new ye,r,n),this.element="member",void 0!==e&&(this.key=e),arguments.length>=2&&(this.value=t)}primitive(){return"member"}get key(){return this._content.key}set key(e){this._content.key=this.refract(e)}get value(){return this._content.value}set value(e){this._content.value=void 0===e?void 0:this.refract(e)}};const ve=class extends Ee{constructor(e,t,r){super(e||[],t,r),this.element="object"}primitive(){return"object"}toValue(){return this._content.reduce((e,t)=>(e[t.key.toValue()]=t.value?t.value.toValue():void 0,e),{})}get(e){const t=this.getMember(e);if(t)return t.value}getValue(e){const t=this.get(e);if(t)return t.toValue()}getMember(e){if(void 0!==e)return this._content.find(t=>t.key.toValue()===e)}remove(e){let t=null;return this.content=this._content.filter(r=>r.key.toValue()!==e||(t=r,!1)),t}getKey(e){const t=this.getMember(e);if(t)return t.key}set(e,t){if("string"==typeof e){const r=this.getMember(e);r?r.value=t:this._content.push(new xe(e,t))}else if("object"==typeof e&&!Array.isArray(e))for(const t of Object.keys(e))this.set(t,e[t]);return this}keys(){return this._content.map(e=>e.key.toValue())}values(){return this._content.map(e=>e.value.toValue())}hasKey(e){return this._content.some(t=>t.key.equals(e))}items(){return this._content.map(e=>[e.key.toValue(),e.value.toValue()])}map(e,t){return this._content.map(r=>e.call(t,r.value,r.key,r))}compactMap(e,t){const r=[];return this.forEach((n,s,a)=>{const o=e.call(t,n,s,a);o&&r.push(o)}),r}filter(e,t){return new Te(this._content).filter(e,t)}reject(e,t){const r=[];for(const n of this._content)e.call(t,n.value,n.key,n)||r.push(n);return new Te(r)}forEach(e,t){this._content.forEach(r=>e.call(t,r.value,r.key,r))}reduce(e,t){let r,n;void 0!==t?(r=0,n=this.refract(t)):(r=1,n=this._content[0]?.value);for(let t=r;t<this._content.length;t+=1){const r=this._content[t],s=e(n,r.value,r.key,r,this);n=void 0===s?s:this.refract(s)}return n}empty(){return new this.constructor([])}},Oe=e=>e instanceof Ae,Se=e=>e instanceof ve;const Me=class extends F{name="apidom";isArray(e){return Oe(e)}isObject(e){return Se(e)}sizeOf(e){return this.isArray(e)||this.isObject(e)?e.length:0}has(e,t){if(this.isArray(e)){const r=Number(t),n=r>>>0;if(r!==n)throw new q(`Invalid array index "${t}": index must be an unsinged 32-bit integer`,{referenceToken:t,currentValue:e,realm:this.name});return n<this.sizeOf(e)}if(this.isObject(e)){const r=e.keys(),n=new Set(r);if(r.length!==n.size)throw new X(`Object key "${t}" is not unique — JSON Pointer requires unique member names`,{referenceToken:t,currentValue:e,realm:this.name});return e.hasKey(t)}return!1}evaluate(e,t){return this.isArray(e)?e.get(Number(t)):e.get(t)}},Pe=(e,t,r={})=>Z(e,t,{...r,realm:new Me});return t})());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speclynx/apidom-json-pointer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Evaluate JSON Pointer expressions against ApiDOM.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -41,8 +41,9 @@
|
|
|
41
41
|
"license": "Apache-2.0",
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@babel/runtime-corejs3": "^7.28.4",
|
|
44
|
-
"@speclynx/apidom-core": "^
|
|
45
|
-
"@speclynx/apidom-
|
|
44
|
+
"@speclynx/apidom-core": "^2.0.1",
|
|
45
|
+
"@speclynx/apidom-datamodel": "^2.0.1",
|
|
46
|
+
"@speclynx/apidom-error": "^2.0.1",
|
|
46
47
|
"@swaggerexpert/json-pointer": "^2.10.2"
|
|
47
48
|
},
|
|
48
49
|
"files": [
|
|
@@ -55,5 +56,5 @@
|
|
|
55
56
|
"README.md",
|
|
56
57
|
"CHANGELOG.md"
|
|
57
58
|
],
|
|
58
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "6a9caf87f445f76ffd69afa760990ffa784bc82d"
|
|
59
60
|
}
|
package/src/index.cjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
3
4
|
exports.__esModule = true;
|
|
4
|
-
exports.unescape = exports.testReferenceToken = exports.testJSONPointer = exports.testArrayLocation = exports.testArrayIndex = exports.testArrayDash = exports.parse = exports.evaluate = exports.escape = exports.compile = exports.XMLTranslator = exports.URIFragmentIdentifier = exports.JSONString = exports.JSONPointerTypeError = exports.JSONPointerParseError = exports.JSONPointerEvaluateError = exports.JSONPointerError = exports.JSONPointerCompileError = exports.Grammar = exports.CSTTranslator = exports.ASTTranslator = void 0;
|
|
5
|
+
exports.unescape = exports.testReferenceToken = exports.testJSONPointer = exports.testArrayLocation = exports.testArrayIndex = exports.testArrayDash = exports.parse = exports.evaluate = exports.escape = exports.compile = exports.XMLTranslator = exports.URIFragmentIdentifier = exports.JSONString = exports.JSONPointerTypeError = exports.JSONPointerParseError = exports.JSONPointerKeyError = exports.JSONPointerIndexError = exports.JSONPointerEvaluateError = exports.JSONPointerError = exports.JSONPointerCompileError = exports.Grammar = exports.CSTTranslator = exports.ASTTranslator = void 0;
|
|
5
6
|
var _jsonPointer = require("@swaggerexpert/json-pointer");
|
|
6
|
-
exports.JSONPointerIndexError = _jsonPointer.JSONPointerIndexError;
|
|
7
|
-
exports.JSONPointerKeyError = _jsonPointer.JSONPointerKeyError;
|
|
8
7
|
exports.JSONString = _jsonPointer.JSONString;
|
|
9
8
|
exports.URIFragmentIdentifier = _jsonPointer.URIFragmentIdentifier;
|
|
10
9
|
exports.parse = _jsonPointer.parse;
|
|
@@ -25,65 +24,20 @@ exports.JSONPointerParseError = _jsonPointer.JSONPointerParseError;
|
|
|
25
24
|
exports.JSONPointerCompileError = _jsonPointer.JSONPointerCompileError;
|
|
26
25
|
exports.JSONPointerEvaluateError = _jsonPointer.JSONPointerEvaluateError;
|
|
27
26
|
exports.JSONPointerTypeError = _jsonPointer.JSONPointerTypeError;
|
|
28
|
-
|
|
27
|
+
exports.JSONPointerKeyError = _jsonPointer.JSONPointerKeyError;
|
|
28
|
+
exports.JSONPointerIndexError = _jsonPointer.JSONPointerIndexError;
|
|
29
|
+
var _realm = _interopRequireDefault(require("./realm.cjs"));
|
|
30
|
+
/**
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
|
|
29
34
|
/**
|
|
30
|
-
*
|
|
35
|
+
* @public
|
|
31
36
|
*/
|
|
32
|
-
class ApiDOMEvaluationRealm extends _jsonPointer.EvaluationRealm {
|
|
33
|
-
name = 'apidom';
|
|
34
|
-
isArray(node) {
|
|
35
|
-
return (0, _apidomCore.isArrayElement)(node);
|
|
36
|
-
}
|
|
37
|
-
isObject(node) {
|
|
38
|
-
return (0, _apidomCore.isObjectElement)(node);
|
|
39
|
-
}
|
|
40
|
-
sizeOf(node) {
|
|
41
|
-
if (this.isArray(node) || this.isObject(node)) {
|
|
42
|
-
return node.length;
|
|
43
|
-
}
|
|
44
|
-
return 0;
|
|
45
|
-
}
|
|
46
|
-
has(node, referenceToken) {
|
|
47
|
-
if (this.isArray(node)) {
|
|
48
|
-
const index = Number(referenceToken);
|
|
49
|
-
const indexUint32 = index >>> 0;
|
|
50
|
-
if (index !== indexUint32) {
|
|
51
|
-
throw new _jsonPointer.JSONPointerIndexError(`Invalid array index "${referenceToken}": index must be an unsinged 32-bit integer`, {
|
|
52
|
-
referenceToken,
|
|
53
|
-
currentValue: node,
|
|
54
|
-
realm: this.name
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return indexUint32 < this.sizeOf(node);
|
|
58
|
-
}
|
|
59
|
-
if (this.isObject(node)) {
|
|
60
|
-
const keys = node.keys();
|
|
61
|
-
const uniqueKeys = new Set(keys);
|
|
62
|
-
if (keys.length !== uniqueKeys.size) {
|
|
63
|
-
throw new _jsonPointer.JSONPointerKeyError(`Object key "${referenceToken}" is not unique — JSON Pointer requires unique member names`, {
|
|
64
|
-
referenceToken,
|
|
65
|
-
currentValue: node,
|
|
66
|
-
realm: this.name
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return node.hasKey(referenceToken);
|
|
70
|
-
}
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
evaluate(node, referenceToken) {
|
|
74
|
-
if (this.isArray(node)) {
|
|
75
|
-
return node.get(Number(referenceToken));
|
|
76
|
-
}
|
|
77
|
-
if (this.isObject(node)) {
|
|
78
|
-
return node.get(referenceToken);
|
|
79
|
-
}
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
37
|
const evaluate = (value, jsonPointer, options = {}) => {
|
|
84
38
|
return (0, _jsonPointer.evaluate)(value, jsonPointer, {
|
|
85
39
|
...options,
|
|
86
|
-
realm: new
|
|
40
|
+
realm: new _realm.default()
|
|
87
41
|
});
|
|
88
42
|
};
|
|
89
43
|
|
package/src/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { evaluate as baseEvaluate
|
|
2
|
-
import { isArrayElement, isObjectElement } from '@speclynx/apidom-core';
|
|
1
|
+
import { evaluate as baseEvaluate } from '@swaggerexpert/json-pointer';
|
|
3
2
|
export {
|
|
4
3
|
/**
|
|
5
4
|
* Representation
|
|
@@ -29,60 +28,13 @@ Grammar,
|
|
|
29
28
|
* Errors
|
|
30
29
|
*/
|
|
31
30
|
JSONPointerError, JSONPointerParseError, JSONPointerCompileError, JSONPointerEvaluateError, JSONPointerTypeError, JSONPointerKeyError, JSONPointerIndexError } from '@swaggerexpert/json-pointer';
|
|
31
|
+
import ApiDOMEvaluationRealm from "./realm.mjs";
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* @public
|
|
34
37
|
*/
|
|
35
|
-
class ApiDOMEvaluationRealm extends EvaluationRealm {
|
|
36
|
-
name = 'apidom';
|
|
37
|
-
isArray(node) {
|
|
38
|
-
return isArrayElement(node);
|
|
39
|
-
}
|
|
40
|
-
isObject(node) {
|
|
41
|
-
return isObjectElement(node);
|
|
42
|
-
}
|
|
43
|
-
sizeOf(node) {
|
|
44
|
-
if (this.isArray(node) || this.isObject(node)) {
|
|
45
|
-
return node.length;
|
|
46
|
-
}
|
|
47
|
-
return 0;
|
|
48
|
-
}
|
|
49
|
-
has(node, referenceToken) {
|
|
50
|
-
if (this.isArray(node)) {
|
|
51
|
-
const index = Number(referenceToken);
|
|
52
|
-
const indexUint32 = index >>> 0;
|
|
53
|
-
if (index !== indexUint32) {
|
|
54
|
-
throw new JSONPointerIndexError(`Invalid array index "${referenceToken}": index must be an unsinged 32-bit integer`, {
|
|
55
|
-
referenceToken,
|
|
56
|
-
currentValue: node,
|
|
57
|
-
realm: this.name
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return indexUint32 < this.sizeOf(node);
|
|
61
|
-
}
|
|
62
|
-
if (this.isObject(node)) {
|
|
63
|
-
const keys = node.keys();
|
|
64
|
-
const uniqueKeys = new Set(keys);
|
|
65
|
-
if (keys.length !== uniqueKeys.size) {
|
|
66
|
-
throw new JSONPointerKeyError(`Object key "${referenceToken}" is not unique — JSON Pointer requires unique member names`, {
|
|
67
|
-
referenceToken,
|
|
68
|
-
currentValue: node,
|
|
69
|
-
realm: this.name
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
return node.hasKey(referenceToken);
|
|
73
|
-
}
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
evaluate(node, referenceToken) {
|
|
77
|
-
if (this.isArray(node)) {
|
|
78
|
-
return node.get(Number(referenceToken));
|
|
79
|
-
}
|
|
80
|
-
if (this.isObject(node)) {
|
|
81
|
-
return node.get(referenceToken);
|
|
82
|
-
}
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
38
|
export const evaluate = (value, jsonPointer, options = {}) => {
|
|
87
39
|
return baseEvaluate(value, jsonPointer, {
|
|
88
40
|
...options,
|
package/src/realm.cjs
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomDatamodel = require("@speclynx/apidom-datamodel");
|
|
6
|
+
var _jsonPointer = require("@swaggerexpert/json-pointer");
|
|
7
|
+
class ApiDOMEvaluationRealm extends _jsonPointer.EvaluationRealm {
|
|
8
|
+
name = 'apidom';
|
|
9
|
+
isArray(node) {
|
|
10
|
+
return (0, _apidomDatamodel.isArrayElement)(node);
|
|
11
|
+
}
|
|
12
|
+
isObject(node) {
|
|
13
|
+
return (0, _apidomDatamodel.isObjectElement)(node);
|
|
14
|
+
}
|
|
15
|
+
sizeOf(node) {
|
|
16
|
+
if (this.isArray(node) || this.isObject(node)) {
|
|
17
|
+
return node.length;
|
|
18
|
+
}
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
has(node, referenceToken) {
|
|
22
|
+
if (this.isArray(node)) {
|
|
23
|
+
const index = Number(referenceToken);
|
|
24
|
+
const indexUint32 = index >>> 0;
|
|
25
|
+
if (index !== indexUint32) {
|
|
26
|
+
throw new _jsonPointer.JSONPointerIndexError(`Invalid array index "${referenceToken}": index must be an unsinged 32-bit integer`, {
|
|
27
|
+
referenceToken,
|
|
28
|
+
currentValue: node,
|
|
29
|
+
realm: this.name
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return indexUint32 < this.sizeOf(node);
|
|
33
|
+
}
|
|
34
|
+
if (this.isObject(node)) {
|
|
35
|
+
const keys = node.keys();
|
|
36
|
+
const uniqueKeys = new Set(keys);
|
|
37
|
+
if (keys.length !== uniqueKeys.size) {
|
|
38
|
+
throw new _jsonPointer.JSONPointerKeyError(`Object key "${referenceToken}" is not unique — JSON Pointer requires unique member names`, {
|
|
39
|
+
referenceToken,
|
|
40
|
+
currentValue: node,
|
|
41
|
+
realm: this.name
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return node.hasKey(referenceToken);
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
evaluate(node, referenceToken) {
|
|
49
|
+
if (this.isArray(node)) {
|
|
50
|
+
return node.get(Number(referenceToken));
|
|
51
|
+
}
|
|
52
|
+
return node.get(referenceToken);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
var _default = exports.default = ApiDOMEvaluationRealm;
|
package/src/realm.mjs
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { isObjectElement, isArrayElement } from '@speclynx/apidom-datamodel';
|
|
2
|
+
import { EvaluationRealm, JSONPointerIndexError, JSONPointerKeyError } from '@swaggerexpert/json-pointer';
|
|
3
|
+
class ApiDOMEvaluationRealm extends EvaluationRealm {
|
|
4
|
+
name = 'apidom';
|
|
5
|
+
isArray(node) {
|
|
6
|
+
return isArrayElement(node);
|
|
7
|
+
}
|
|
8
|
+
isObject(node) {
|
|
9
|
+
return isObjectElement(node);
|
|
10
|
+
}
|
|
11
|
+
sizeOf(node) {
|
|
12
|
+
if (this.isArray(node) || this.isObject(node)) {
|
|
13
|
+
return node.length;
|
|
14
|
+
}
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
has(node, referenceToken) {
|
|
18
|
+
if (this.isArray(node)) {
|
|
19
|
+
const index = Number(referenceToken);
|
|
20
|
+
const indexUint32 = index >>> 0;
|
|
21
|
+
if (index !== indexUint32) {
|
|
22
|
+
throw new JSONPointerIndexError(`Invalid array index "${referenceToken}": index must be an unsinged 32-bit integer`, {
|
|
23
|
+
referenceToken,
|
|
24
|
+
currentValue: node,
|
|
25
|
+
realm: this.name
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return indexUint32 < this.sizeOf(node);
|
|
29
|
+
}
|
|
30
|
+
if (this.isObject(node)) {
|
|
31
|
+
const keys = node.keys();
|
|
32
|
+
const uniqueKeys = new Set(keys);
|
|
33
|
+
if (keys.length !== uniqueKeys.size) {
|
|
34
|
+
throw new JSONPointerKeyError(`Object key "${referenceToken}" is not unique — JSON Pointer requires unique member names`, {
|
|
35
|
+
referenceToken,
|
|
36
|
+
currentValue: node,
|
|
37
|
+
realm: this.name
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return node.hasKey(referenceToken);
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
evaluate(node, referenceToken) {
|
|
45
|
+
if (this.isArray(node)) {
|
|
46
|
+
return node.get(Number(referenceToken));
|
|
47
|
+
}
|
|
48
|
+
return node.get(referenceToken);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export default ApiDOMEvaluationRealm;
|
|
@@ -23,6 +23,9 @@ import { unescape as unescape_2 } from '@swaggerexpert/json-pointer';
|
|
|
23
23
|
import { URIFragmentIdentifier } from '@swaggerexpert/json-pointer';
|
|
24
24
|
import { XMLTranslator } from '@swaggerexpert/json-pointer';
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
26
29
|
export declare type ApiDOMRealmEvaluationOptions = Omit<EvaluationOptions, 'realm'>;
|
|
27
30
|
|
|
28
31
|
export { ASTTranslator }
|
|
@@ -33,6 +36,9 @@ export { CSTTranslator }
|
|
|
33
36
|
|
|
34
37
|
export { escape_2 as escape }
|
|
35
38
|
|
|
39
|
+
/**
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
36
42
|
export declare const evaluate: <T = unknown>(value: unknown, jsonPointer: JSONPointer, options?: ApiDOMRealmEvaluationOptions) => T;
|
|
37
43
|
|
|
38
44
|
export { Grammar }
|