UNPKG

@jsonurl/jsonurl

Version:

JSON->URL defines a text format for the JSON data model suitable for use within a URL/URI (as described by RFC3986).

7 lines (6 loc) 18.6 kB
/*! * jsonurl.js v1.1.8 * (c) 2024 David MacCormack * Released under the MIT License. */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).JsonURL=t()}(this,(function(){"use strict";const e="JSON->URL: expected literal value",t="JSON->URL: unexpected character",r="JSON->URL: unexpected end of text inside composite",s="JSON->URL: unexpected text after composite",i="JSON->URL: can not represent null with implied strings",n="JSON->URL: the empty string is not allowed",o="JSON->URL: invalid escape sequence",a="JSON->URL: invalid percent-encoded sequence",p="JSON->URL: expected object value";function u(e,t){return void 0===t?e:e+" at position "+t}const c=16,l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,6,6,48,10,20,20,6,6,20,6,6,6,6,6,6,6,6,6,6,6,6,6,20,6,0,48,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,0,6,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,6,0];function h(e){return e>127?0:l[e]}class d{constructor(e){this.setOrDefault(e,"allowEmptyUnquotedValues"),this.setOrDefault(e,"allowEmptyUnquotedKeys"),this.setOrDefault(e,"AQF"),this.setOrDefault(e,"coerceNullToEmptyString"),this.setOrDefault(e,"ignoreNullArrayMembers"),this.setOrDefault(e,"ignoreNullObjectMembers"),this.setOrDefault(e,"impliedArray"),this.setOrDefault(e,"impliedObject"),this.setOrDefault(e,"impliedStringLiterals"),this.setOrDefault(e,"noEmptyComposite"),this.setOrDefault(e,"wwwFormUrlEncoded")}setOrDefault(e,t,r){void 0!==e&&t in e?t in this||(this[t]=e[t]):void 0===r||t in this||(this[t]=r)}setOverride(e,t){void 0!==e&&t in e&&(this[t]=e[t])}setOrDefaultInt(e,t,r){this.setOrDefault(e,t,void 0===r?r:parseInt(r))}isPresentAndTrue(e){return e in this&&this[e]}}class f extends d{constructor(e,t){super(e),this.setOrDefault(e,"emptyValue"),this.setOrDefault(t,"emptyValue",{}),this.setOverride(e,"getMissingValue"),this.setOrDefaultInt(e,"maxParseChars"),this.setOrDefaultInt(t,"maxParseChars",32768),this.setOrDefaultInt(e,"maxParseDepth"),this.setOrDefaultInt(t,"maxParseDepth",32),this.setOrDefaultInt(e,"maxParseValues"),this.setOrDefaultInt(t,"maxParseValues",4096),this.setOrDefault(e,"nullValue"),this.setOrDefault(t,"nullValue",null)}getMissingValue(e,t){throw new SyntaxError(u(p,t))}}class m extends d{constructor(e){super(e);const t=!(void 0===e||!("impliedStringLiterals"in e)||!e.impliedStringLiterals)||void 0;this.setOrDefault(e,"allowEmptyUnquotedValues",t),this.setOrDefault(e,"allowEmptyUnquotedKeys",t),this.setOrDefault(e,"callFunctions"),this.setOrDefault(e,"isImplied"),this.setOrDefault(e,"ignoreNullArrayMembers",t),this.setOrDefault(e,"ignoreNullObjectMembers",t),this.setOrDefault(e,"ignoreUndefinedArrayMembers",t),this.setOrDefault(e,"ignoreUndefinedObjectMembers",t),this.isImplied=this.isImplied||this.impliedArray||this.impliedObject}}const w=/\+/g,y=/ /g,x=/(![\s\S]?)/g,A=/^[-A-Za-z0-9._~!$*;@?/ ][-A-Za-z0-9._~!$*;@?/' ]*$/,O=/^[-A-Za-z0-9._~!$*,;@?/(): ]+$/,E=/^-?\d+(?:\.\d+)?(?:[eE][-]?\d+)?$/,g=/^-?\d+(?:\.\d+)?[eE]\+\d+$/,b=/^-?\d+(?:\.\d+)?[eE] \d+$/,S=/[(),:]|%2[04]|%3B/gi,L={"%20":"+","%24":"$","(":"%28",")":"%29",",":"%2C",":":"%3A","%3B":";"},v=/[!(),:]|%2[01489BC]|%3[AB]/gi,U={"%20":"+","%21":"!!","!":"!!","%24":"$","%28":"!(","(":"!(","%29":"!)",")":"!)","+":"!+","%2B":"!+","%2C":"!,",",":"!,","%3A":"!:",":":"!:","%3B":";"},V=40,C=41,D=44,j=58,R=38,N=48,J=65,P=97,T=new Array(111);T[33]="!",T[40]="(",T[41]=")",T[43]="+",T[44]=",",T[45]=",",T[N]="0",T[N+1]="1",T[N+2]="2",T[N+3]="3",T[N+4]="4",T[N+5]="5",T[N+6]="6",T[N+7]="7",T[N+8]="8",T[N+9]="9",T[58]=":",T[116]="t",T[102]="f",T[110]="n";const F="",I="!e",k=" ";function M(e,t){const r=t?v:S,s=t?U:L;return encodeURIComponent(e).replace(r,(function(e){const t=s[e];return void 0===t?e:t}))}function _(e,t){switch(t){case N:return 0;case N+1:return 1;case N+2:return 2;case N+3:return 3;case N+4:return 4;case N+5:return 5;case N+6:return 6;case N+7:return 7;case N+8:return 8;case N+9:return 9;case J:case P:return 10;case J+1:case P+1:return 11;case J+2:case P+2:return 12;case J+3:case P+3:return 13;case J+4:case P+4:return 14;case J+5:case P+5:return 15;default:throw new SyntaxError(u(a,e))}}function q(e){if(e.coerceNullToEmptyString)return B(e,!1);if(e.impliedStringLiterals)throw new SyntaxError(i);return"null"}function B(e,t){if(t?e.allowEmptyUnquotedKeys:e.allowEmptyUnquotedValues)return F;if(e.AQF)return I;if(e.impliedStringLiterals)throw new SyntaxError(n);return"''"}!function(e){let{toJsonURLText_Array:t,toJsonURLText_Boolean:r,toJsonURLText_Number:s,toJsonURLText_Object:i,toJsonURLText_String:n}=e;Object.defineProperty(Array.prototype,"toJsonURLText",{value:t}),Object.defineProperty(Boolean.prototype,"toJsonURLText",{value:r}),Object.defineProperty(Number.prototype,"toJsonURLText",{value:s}),Object.defineProperty(Object.prototype,"toJsonURLText",{value:i}),Object.defineProperty(String.prototype,"toJsonURLText",{value:n})}({toJsonURLText_Array:function(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.forEach((function(s){if("function"==typeof s){if(!t.callFunctions)return;for(;"function"==typeof s;)s=s()}if(void 0===s){if(t.ignoreUndefinedArrayMembers)return;s=q(t)}else if(null===s){if(t.ignoreNullArrayMembers)return;s=q(t)}else s=s.toJsonURLText(t,r+1);void 0===e?e=s:!t.wwwFormUrlEncoded||r>0?e+=","+s:e+="&"+s})),!t.isImplied||r>0?void 0===e?"()":"("+e+")":void 0===e?F:e},toJsonURLText_Boolean:function(){return!0===this?"true":"false"},toJsonURLText_Number:function(e){const t=String(this);return e.impliedStringLiterals&&-1!==t.indexOf("+")?M(t,e):t},toJsonURLText_Object:function(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const s=Object.keys(this),i=this;return s.forEach((function(s){if(null==s)return;let n=i[s];if("function"==typeof n){if(!t.callFunctions)return;for(;"function"==typeof n;)n=n()}if(void 0===n){if(t.ignoreUndefinedObjectMembers)return;n=q(t)}else if(null===n){if(t.ignoreNullObjectMembers)return;n=q(t)}else n=n.toJsonURLText(t,r+1);const o=s.toJsonURLText(t,r,!0);void 0===e?e=!t.wwwFormUrlEncoded||r>0?o+":"+n:o+"="+n:!t.wwwFormUrlEncoded||r>0?e+=","+o+":"+n:e+="&"+o+"="+n})),!t.isImplied||r>0?(t.noEmptyComposite&&void 0===e&&(e=":"),void 0===e?"()":"("+e+")"):void 0===e?F:e},toJsonURLText_String:function(e,t,r){if(0===this.length)return B(e,r);if(e.impliedStringLiterals)return M(this,e.AQF);if("true"===(s=this)||"false"===s||"null"===s||E.test(s))return!0===r?this:e.AQF?"!"+this:"'"+this+"'";var s;if(g.test(this))return e.AQF?this.replace("+","!+"):this.replace("+","%2B");if(b.test(this))return e.AQF?"!"+this.replace(k,"+"):"'"+this.replace(k,"+")+"'";if(e.AQF)return M(this,!0);if(A.test(this))return-1==this.indexOf(k)?this:this.replace(y,"+");if(O.test(this))return-1==this.indexOf(k)?"'"+this+"'":"'"+this.replace(y,"+")+"'";let i=M(this);return 39==i.charCodeAt(0)?"%27"+i.substring(1):i}});class ${constructor(e,t,r,s){this.text=e,this.pos=this.markPos=t,this.end=r,this.options=s}skipAmps(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=this.text,r=this.end;let s=this.pos;if(e)for(;s<r&&t.charCodeAt(s)===R;)s++;else if(s<r&&t.charCodeAt(s)===R){for(s++;s<r&&t.charCodeAt(s)===R;s++);s!==r&&s--}this.pos=s}structChar(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.options.wwwFormUrlEncoded){const t=this.text.charCodeAt(this.pos);switch(t){case R:case 61:if(e)return;return this.pos++,t}}const t=this.pos,r=this.ordinal();switch(r){case D:case j:if(e)return void(this.pos=t);case V:case C:return r;default:return void(this.pos=t)}}ordinal(e){return void 0!==e?this.text.charCodeAt(e):this.text.charCodeAt(this.pos++)}accept(e){const t=this.pos;return this.ordinal()===e||(this.pos=t,!1)}acceptPlus(){return 43==this.text.charCodeAt(this.pos)&&(this.pos++,!0)}done(){return this.end<=this.pos}validateLiteral(e,r){const s=this.text,i=this.end;for(;e<i;e++){switch(h(s.charCodeAt(e))&r){case 0:throw new SyntaxError(u(t,e));case c:return e;case 8:return e+1;default:continue}}}findLiteralEnd(){const e=this.text,t=this.end;let r=this.pos;const s=39===e.charCodeAt(r);s&&r++;const i=s?28:18;if(r=this.validateLiteral(r,i),void 0!==r)return r;if(s)throw new SyntaxError(u("JSON->URL: quoted string still open",r));return t}isEmptyObject(){if(this.options.noEmptyComposite){const e=this.pos;if(!this.accept(j))return!1;const t=this.pos,r=this.accept(C);return this.pos=r?t:e,r}return!1}parseLiteral(e){const t=this.pos,r=this.options,s=this.findLiteralEnd();if(void 0===e&&(e=this.ordinal(s)==j),s<=t){return function(e,t){if(t)return F;throw new SyntaxError(u(n,e))}(t,e?this.options.allowEmptyUnquotedKeys:this.options.allowEmptyUnquotedValues)}if(!0===r.impliedStringLiterals)return this.parseStringLiteral(s,!0);const i=this.parseTrueFalseNull(s,e);if(void 0!==i)return i;const o=this.parseNumberLiteral(s,e);return void 0!==o?o:this.parseStringLiteral(s,!1)}parseDigits(e){let t,r=!1;for(;this.pos<e;)switch(this.ordinal()){case N:case N+1:case N+2:case N+3:case N+4:case N+5:case N+6:case N+7:case N+8:case N+9:t=this.pos,r=!0;continue;default:return this.pos=t,r}return this.pos=t,r}parseExponentValue(e){return!(e<=this.pos)&&(this.acceptPlus()||this.accept(45),this.parseDigits(e))}parseExponent(e){const t=this.pos;switch(this.ordinal()){case 69:case 101:if(this.parseExponentValue(e))return!0}return this.pos=t,!1}parseFraction(e){const t=this.pos;return!(e<=t)&&(!(!this.accept(46)||!this.parseDigits(e))||(this.pos=t,!1))}parseInteger(e){return!(e<=this.pos)&&(!!this.accept(N)||this.parseDigits(e))}parseNumberLiteral(e,t){const r=this.text,s=this.pos;if(this.accept(45),this.parseInteger(e)&&(this.parseFraction(e),this.parseExponent(e),this.pos===e)){const i=decodeURIComponent(r.substring(s,e));return t?i:Number(i)}this.pos=s}parseStringLiteral(e,t){const r=this.text,s=this.pos;let i=t||39!==r.charCodeAt(s)?r.substring(s,e):r.substring(s+1,e-1);return i=decodeURIComponent(i.replace(w,k)),this.pos=e,i}parseTrueFalseNull(e,t){const r=this.text,s=this.pos;let i,n,o,a,p;switch(e-s){case 4:if(i=r.charCodeAt(s),n=r.charCodeAt(s+1),o=r.charCodeAt(s+2),a=r.charCodeAt(s+3),116===i&&114===n&&117===o&&101===a)return this.pos=e,!t||"true";if(110===i&&117===n&&108===o&&108===a)return this.pos=e,t?"null":this.newNullValue();break;case 5:if(i=r.charCodeAt(s),n=r.charCodeAt(s+1),o=r.charCodeAt(s+2),a=r.charCodeAt(s+3),p=r.charCodeAt(s+4),102===i&&n===P&&108===o&&115===a&&101===p)return this.pos=e,!!t&&"false"}}newEmptyValue(){const e=this.options;if(e.noEmptyComposite)return[];const t=e.emptyValue;return"function"==typeof t?t():t}newNullValue(){const e=this.options;let t=e.nullValue;return"function"==typeof t&&(t=t()),null==t&&e.coerceNullToEmptyString&&(t=F),t}}class Q extends ${constructor(e,t,r,s){super(e,t,r,s)}ordinal(e){const t=e||this.pos,r=this.text.charCodeAt(t);let s,i;return 37===r?(s=function(e,t,r){if(r<=t+1)throw new SyntaxError(u(a,t));return _(t,e.charCodeAt(t))<<4|_(t,e.charCodeAt(t+1))}(this.text,t+1,this.end),i=3):(s=r,i=1),void 0===e&&(this.pos+=i),s}findLiteralEnd(){const e=this.end,r=this.pos,s=this.text;let i=r;for(;;){if(e<=this.pos)return this.pos=r,e;switch(50&h(s.charCodeAt(this.pos))){case 48:if(this.options.wwwFormUrlEncoded)return i=this.pos,this.pos=r,i;case 0:throw new SyntaxError(u(t,i))}switch(this.ordinal()){case V:case C:case j:case D:return this.pos=r,i;case 33:if(this.pos===e)throw new SyntaxError(u(o,i));this.ordinal(),i=this.pos;break;default:i=this.pos}}}parseStringLiteral(e){const t=this.text,r=this.pos,s=decodeURIComponent(t.substring(r,e).replace(w,(function(e,s){return 0!==s&&function(e,t){return 33===e.charCodeAt(t-1)||t>2&&37===e.charCodeAt(t-3)&&e.charCodeAt(t-2)===N+2&&e.charCodeAt(t-1)===N+1}(t,r+s)?"+":k})));return this.pos=e,"!e"===s?F:s.replace(x,(function(e,t,s){if(2===e.length){const t=e.charCodeAt(1),r=T[t];if(void 0!==r)return r}throw new SyntaxError(u(o,r+s))}))}}class K extends Array{constructor(e){super(),this.limits=e,this.parseDepth=0}replaceAndPush(e,t,r){if(this[this.parseDepth]=t,++this.parseDepth>=this.limits.maxParseDepth)throw new Error(u("JSON->URL: MaxParseDepth exceeded",e));this.push(r)}replace(e){this[this.parseDepth]=e}depth(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&(this.parseDepth--,this.pop()),this.parseDepth}}class z extends Array{constructor(e){super(),this.limits=e,this.numValues=0}popObjectValue(e){let t=this.pop(),r=this.pop(),s=this[this.length-1];return null===t&&e.isPresentAndTrue("ignoreNullObjectMembers")||(s[r]=t),s}popArrayValue(e){let t=this.pop(),r=this[this.length-1];return null===t&&e.isPresentAndTrue("ignoreNullArrayMembers")||r.push(t),r}checkValueLimit(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.numValues+=t,this.numValues>this.limits.maxParseValues+1)throw new Error(u("JSON->URL: MaxParseValues exceeded",e))}appendArrayValue(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this.checkValueLimit(e,r),this.push(t)}}function Z(e){for(;"function"==typeof e;)e=e();return e}function G(e,t,r,s){return"number"==typeof e?"number"!=typeof t&&(r=t):r=e,(r=Z(r))instanceof f||(r=new f(r,s)),r}function H(e,t,r,s){return s.AQF?new Q(e,t,r,s):new $(e,t,r,s)}function W(e,t){return"number"==typeof e?e:t}function X(i,n,o,a,c){if(void 0===i)return;a=G(n,o,a,c),i=String(i);const l=W(n,0),h=W(o,i.length);if(h<=l){if(void 0!==a.impliedArray)return a.impliedArray;if(void 0!==a.impliedObject)return a.impliedObject;throw new SyntaxError(u("JSON->URL: expected value",0))}if(h>a.maxParseChars)throw new Error("JSON->URL: MaxParseChars exceeded");const d=a.wwwFormUrlEncoded&&(a.impliedObject||a.impliedArray),f=new z(a),m=new K(a),w=H(i,l,h,a);if(void 0!==a.impliedObject)f.push(a.impliedObject),m.push(6);else if(void 0!==a.impliedArray)f.push(a.impliedArray),m.push(2);else{if(w.structChar(!0)!==V){const t=w.parseLiteral(!1);if(w.done())return t;throw new SyntaxError(u(e,0))}m.push(1)}for(d&&w.skipAmps(!0);;){if(w.done())throw new SyntaxError(u(r,w.pos));let i,n,o;switch(m[m.depth()]){case 1:switch(w.structChar(!0)){case V:f.appendArrayValue(w.pos,[]),m.replaceAndPush(w.pos,3,1);continue;case C:if(-1===m.depth(!0)){if(w.done())return w.newEmptyValue();throw new SyntaxError(u(s,w.pos))}if(f.appendArrayValue(w.pos,w.newEmptyValue()),0===m.depth()&&(d&&w.skipAmps(),w.done())){if(a.impliedArray)return f.popArrayValue(a);if(a.impliedObject)return f.popObjectValue(a);throw new SyntaxError(u(r,w.pos))}continue}switch(f.checkValueLimit(w.pos),n=w.isEmptyObject(),i=n?{}:w.parseLiteral(),o=w.pos,w.structChar()){case R:if(!a.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(u(t,o));case D:m.replace(2),f.appendArrayValue(o,[]),f.push(i),f.popArrayValue(a);continue;case C:switch(n?f.push({}):f.appendArrayValue(o,[i]),m.depth(!0)){case-1:if(w.pos===h)return f[0];throw new SyntaxError(u(s,o));case 0:if(d&&w.skipAmps(),w.done()){if(a.impliedArray)return f.popArrayValue(a);if(a.impliedObject)return f.popObjectValue(a);throw new SyntaxError(u(r,o))}}continue;case 61:if(!a.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(u(t,o));case j:m.replace(4),f.push({},i);continue;default:throw new SyntaxError(u(e,o))}case 2:if(w.accept(V)){m.replaceAndPush(w.pos,3,1);continue}if(f.checkValueLimit(w.pos),i=w.parseLiteral(!1),d&&w.skipAmps(),w.done()){if(0===m.depth()&&a.impliedArray)return f.push(i),f.popArrayValue(a);throw new SyntaxError(u(r,h))}m.replace(3),f.push(i);continue;case 3:switch(f.popArrayValue(a),w.structChar()){case R:if(!a.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(u(t,w.pos));case D:m.replace(2);continue;case C:switch(m.depth(!0)){case-1:if(w.done()&&!a.impliedArray)return f[0];throw new SyntaxError(u(s,w.pos));case 0:if(d&&w.skipAmps(),w.done()){if(a.impliedArray)return f.popArrayValue(a);if(a.impliedObject)return f.popObjectValue(a);throw new SyntaxError(u(r,w.pos))}}continue}throw new SyntaxError(u("JSON->URL: expected comma or close paren",w.pos));case 4:if(w.accept(V)){m.replaceAndPush(w.pos,5,1);continue}if(f.checkValueLimit(w.pos),i=w.parseLiteral(!1),d&&w.skipAmps(),w.done()){if(0===m.depth()&&a.impliedObject)return f.push(i),f.popObjectValue(a);throw new SyntaxError(u(r,h))}m.replace(5),f.push(i);continue;case 5:switch(f.popObjectValue(a),o=w.pos,w.structChar()){case R:if(!a.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(u(t,o));case D:m.replace(6);continue;case C:switch(m.depth(!0)){case-1:if(w.done()&&!a.impliedObject)return f[0];throw new SyntaxError(u(s,w.pos));case 0:if(d&&w.skipAmps(),w.done()){if(a.impliedArray)return f.popArrayValue(a);if(a.impliedObject)return f.popObjectValue(a);throw new SyntaxError(u(s,w.pos))}}continue}throw new SyntaxError(u("JSON->URL: expected comma, open paren, or close paren",w.pos));case 6:if(i=w.parseLiteral(!0),d&&w.skipAmps(),w.done()){if(a.impliedObject&&0==m.depth())return f.push(i,a.getMissingValue(i)),f.popObjectValue(a);throw new SyntaxError(u(r,h))}switch(w.structChar()){case 61:if(!a.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(u(t,w.pos));case j:break;case R:if(!a.wwwFormUrlEncoded||m.depth()>0)throw new SyntaxError(u(t,w.pos));case D:if(a.impliedObject&&0==m.depth()){f.push(i,a.getMissingValue(i)),f.popObjectValue(a);continue}default:throw new SyntaxError(u(p,w.pos))}m.replace(4),f.push(i);continue;default:throw new SyntaxError(u("JSON->URL: internal error",w.pos))}}}return class{constructor(e){for(;"function"==typeof e;)e=e();void 0===e&&(e={}),this.maxParseDepth="number"==typeof e.maxParseDepth?parseInt(e.maxParseDepth):32,this.maxParseValues="number"==typeof e.maxParseValues?parseInt(e.maxParseValues):4096,this.maxParseChars="number"==typeof e.maxParseChars?parseInt(e.maxParseChars):32768,this.emptyValue=void 0===e.emptyValue?{}:e.emptyValue,this.nullValue=void 0===e.nullValue?null:e.nullValue}parseLiteral(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4?arguments[4]:void 0;void 0!==e&&(e=String(e)),void 0===r&&(r=e.length);return H(e,t,r,G(i)).parseLiteral(s)}static parse(e,t,r,s){return X(e,t,r,s,void 0)}parse(e,t,r,s){return X(e,t,r,s,this)}static stringify(e,t){if(void 0!==e)return t=new m(Z(t)),null===e?q(t):e.toJsonURLText(t,0)}}}));