var r=/~/,t=/~[01]/g;function n(r){switch(r){case"~1":return"/";case"~0":return"~"}throw new Error("Invalid tilde escape: "+r)}function e(e){return r.test(e)?e.replace(t,n):e}function o(r){if("string"==typeof r){if(""===(r=r.split("/"))[0])return r;throw new Error("Invalid JSON pointer.")}if(Array.isArray(r))return r;throw new Error("Invalid JSON pointer.")}function i(r,t){if("object"!=typeof r)throw new Error("Invalid input object.");var n=(t=o(t)).length;if(1===n)return r;for(var i=1;i<n;){if(r=r[e(t[i++])],n===i)return r;if("object"!=typeof r)return}}function f(r,t,n){if("object"!=typeof r)throw new Error("Invalid input object.");if(0===(t=o(t)).length)throw new Error("Invalid JSON pointer for set.");return function(r,t,n){var o,i;if("constructor"===t[1]&&"prototype"===t[2])return r;if("__proto__"===t[1])return r;for(var f=1,u=t.length;f<u&&(o=e(t[f++]),i=u>f,void 0===r[o]&&(Array.isArray(r)&&"-"===o&&(o=r.length),i&&(r[o]=""!==t[f]&&t[f]<1/0||"-"===t[f]?[]:{})),i);)r=r[o];var c=r[o];return void 0===n?delete r[o]:r[o]=n,c}(r,t,n)}var u={get:i,set:f,compile:function(r){var t=o(r);return{get:function(r){return i(r,t)},set:function(r,n){return f(r,t,n)}}}};export{u as j}