!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function r(e,r,t){return e(t={path:r,exports:{},require:function(e,r){return function(){throw Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}()}},t.exports),t.exports}var t,n=r((function(e){e.exports=function(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e},e.exports.__esModule=!0,e.exports.default=e.exports})),o=e(n),i=r((function(e){function r(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}e.exports=function(e){for(var t=1;arguments.length>t;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?r(Object(o),!0).forEach((function(r){n(e,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))}))}return e},e.exports.__esModule=!0,e.exports.default=e.exports})),a=e(i),u=r((function(e){e.exports=function(e,r){if(null==e)return{};var t,n,o={},i=Object.keys(e);for(n=0;i.length>n;n++)0>r.indexOf(t=i[n])&&(o[t]=e[t]);return o},e.exports.__esModule=!0,e.exports.default=e.exports})),c=r((function(e){e.exports=function(e,r){if(null==e)return{};var t,n,o=u(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;i.length>n;n++)0>r.indexOf(t=i[n])&&Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o},e.exports.__esModule=!0,e.exports.default=e.exports})),s=e(c),l=e(r((function(e){e.exports=function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports}))),f=r((function(e){function r(e,r){for(var t=0;r.length>t;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports})),d=e(f),p=new Uint8Array(16);function m(){if(!t&&!(t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(p)}var y=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function g(e){return"string"==typeof e&&y.test(e)}for(var v=[],_=0;256>_;++_)v.push((_+256).toString(16).substr(1));function x(e,r,t){var n=(e=e||{}).random||(e.rng||m)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,r){t=t||0;for(var o=0;16>o;++o)r[t+o]=n[o];return r}return function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=(v[e[r+0]]+v[e[r+1]]+v[e[r+2]]+v[e[r+3]]+"-"+v[e[r+4]]+v[e[r+5]]+"-"+v[e[r+6]]+v[e[r+7]]+"-"+v[e[r+8]]+v[e[r+9]]+"-"+v[e[r+10]]+v[e[r+11]]+v[e[r+12]]+v[e[r+13]]+v[e[r+14]]+v[e[r+15]]).toLowerCase();if(!g(t))throw TypeError("Stringified UUID is invalid");return t}(n)}var h=r((function(e,r){e.exports=function(){function e(e){for(var r=1;arguments.length>r;r++){var t=arguments[r];for(var n in t)e[n]=t[n]}return e}function r(t,n){function o(r,o,i){if("undefined"!=typeof document){"number"==typeof(i=e({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var u in i)i[u]&&(a+="; "+u,!0!==i[u]&&(a+="="+i[u].split(";")[0]));return document.cookie=r+"="+t.write(o,r)+a}}function i(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var r=document.cookie?document.cookie.split("; "):[],n={},o=0;r.length>o;o++){var i=r[o].split("="),a=i.slice(1).join("=");try{var u=decodeURIComponent(i[0]);if(n[u]=t.read(a,u),e===u)break}catch(e){}}return e?n[e]:n}}return Object.create({set:o,get:i,remove:function(r,t){o(r,"",e({},t,{expires:-1}))},withAttributes:function(t){return r(this.converter,e({},this.attributes,t))},withConverter:function(t){return r(e({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}return r({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}()})),b=r((function(e){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports})),w=r((function(e){e.exports=function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,i=[],a=!0,u=!1;try{for(t=t.call(e);!(a=(n=t.next()).done)&&(i.push(n.value),!r||i.length!==r);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==t.return||t.return()}finally{if(u)throw o}}return i}},e.exports.__esModule=!0,e.exports.default=e.exports})),O=r((function(e){e.exports=function(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);r>t;t++)n[t]=e[t];return n},e.exports.__esModule=!0,e.exports.default=e.exports})),E=r((function(e){e.exports=function(e,r){if(e){if("string"==typeof e)return O(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?O(e,r):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports})),S=r((function(e){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports})),A=r((function(e){e.exports=function(e,r){return b(e)||w(e,r)||E(e,r)||S()},e.exports.__esModule=!0,e.exports.default=e.exports})),I=e(A),C=r((function(e){e.exports=function(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=E(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==t.return||t.return()}finally{if(u)throw i}}}},e.exports.__esModule=!0,e.exports.default=e.exports})),k=e(C),j=r((function(e){function r(t){return e.exports=r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})),P=e(j),R=r((function(e){e.exports=function(e){if(Array.isArray(e))return O(e)},e.exports.__esModule=!0,e.exports.default=e.exports})),N=r((function(e){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports})),T=r((function(e){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports})),D=e(r((function(e){e.exports=function(e){return R(e)||N(e)||E(e)||T()},e.exports.__esModule=!0,e.exports.default=e.exports}))),F="%[a-f0-9]{2}",M=RegExp(F,"gi"),U=RegExp("("+F+")+","gi");function L(e,r){try{return decodeURIComponent(e.join(""))}catch(e){}if(1===e.length)return e;var t=e.slice(0,r=r||1),n=e.slice(r);return Array.prototype.concat.call([],L(t),L(n))}function K(e){try{return decodeURIComponent(e)}catch(n){for(var r=e.match(M),t=1;r.length>t;t++)r=(e=L(r,t).join("")).match(M);return e}}var G=function(e){if("string"!=typeof e)throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return e=e.replace(/\+/g," "),decodeURIComponent(e)}catch(r){return function(e){for(var r={"%FE%FF":"��","%FF%FE":"��"},t=U.exec(e);t;){try{r[t[0]]=decodeURIComponent(t[0])}catch(e){var n=K(t[0]);n!==t[0]&&(r[t[0]]=n)}t=U.exec(e)}r["%C2"]="�";for(var o=Object.keys(r),i=0;o.length>i;i++){var a=o[i];e=e.replace(RegExp(a,"g"),r[a])}return e}(e)}},H=function(e,r){if("string"!=typeof e||"string"!=typeof r)throw new TypeError("Expected the arguments to be of type `string`");if(""===r)return[e];var t=e.indexOf(r);return-1===t?[e]:[e.slice(0,t),e.slice(t+r.length)]},$=function(e,r){for(var t={},n=Object.keys(e),o=Array.isArray(r),i=0;n.length>i;i++){var a=n[i],u=e[a];(o?-1!==r.indexOf(a):r(a,u,e))&&(t[a]=u)}return t},Y=r((function(e,r){var t=Symbol("encodeFragmentIdentifier");function n(e){if("string"!=typeof e||1!==e.length)throw new TypeError("arrayFormatSeparator must be single character string")}function i(e,r){return r.encode?r.strict?encodeURIComponent(e).replace(/[!'()*]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())})):encodeURIComponent(e):e}function a(e,r){return r.decode?G(e):e}function u(e){return Array.isArray(e)?e.sort():"object"===P(e)?u(Object.keys(e)).sort((function(e,r){return Number(e)-Number(r)})).map((function(r){return e[r]})):e}function c(e){var r=e.indexOf("#");return-1!==r&&(e=e.slice(0,r)),e}function s(e){var r=(e=c(e)).indexOf("?");return-1===r?"":e.slice(r+1)}function l(e,r){return r.parseNumbers&&!Number.isNaN(Number(e))&&"string"==typeof e&&""!==e.trim()?e=Number(e):!r.parseBooleans||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(e="true"===e.toLowerCase()),e}function f(e,r){n((r=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},r)).arrayFormatSeparator);var t=function(e){var r;switch(e.arrayFormat){case"index":return function(e,t,n){r=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),r?(void 0===n[e]&&(n[e]={}),n[e][r[1]]=t):n[e]=t};case"bracket":return function(e,t,n){r=/(\[\])$/.exec(e),n[e=e.replace(/\[\]$/,"")]=r?void 0!==n[e]?[].concat(n[e],t):[t]:t};case"colon-list-separator":return function(e,t,n){r=/(:list)$/.exec(e),n[e=e.replace(/:list$/,"")]=r?void 0!==n[e]?[].concat(n[e],t):[t]:t};case"comma":case"separator":return function(r,t,n){var o="string"==typeof t&&t.includes(e.arrayFormatSeparator),i="string"==typeof t&&!o&&a(t,e).includes(e.arrayFormatSeparator);t=i?a(t,e):t;var u=o||i?t.split(e.arrayFormatSeparator).map((function(r){return a(r,e)})):null===t?t:a(t,e);n[r]=u};case"bracket-separator":return function(r,t,n){var o=/(\[\])$/.test(r);if(r=r.replace(/\[\]$/,""),o){var i=null===t?[]:t.split(e.arrayFormatSeparator).map((function(r){return a(r,e)}));n[r]=void 0!==n[r]?[].concat(n[r],i):i}else n[r]=t?a(t,e):t};default:return function(e,r,t){t[e]=void 0!==t[e]?[].concat(t[e],r):r}}}(r),o=Object.create(null);if("string"!=typeof e)return o;if(!(e=e.trim().replace(/^[?#&]/,"")))return o;var i,c=k(e.split("&"));try{for(c.s();!(i=c.n()).done;){var s=i.value;if(""!==s){var f=H(r.decode?s.replace(/\+/g," "):s,"="),d=I(f,2),p=d[0],m=d[1];m=void 0===m?null:["comma","separator","bracket-separator"].includes(r.arrayFormat)?m:a(m,r),t(a(p,r),m,o)}}}catch(e){c.e(e)}finally{c.f()}for(var y=0,g=Object.keys(o);g.length>y;y++){var v=g[y],_=o[v];if("object"===P(_)&&null!==_)for(var x=0,h=Object.keys(_);h.length>x;x++){var b=h[x];_[b]=l(_[b],r)}else o[v]=l(_,r)}return!1===r.sort?o:(!0===r.sort?Object.keys(o).sort():Object.keys(o).sort(r.sort)).reduce((function(e,r){var t=o[r];return e[r]=t&&"object"===P(t)&&!Array.isArray(t)?u(t):t,e}),Object.create(null))}r.extract=s,r.parse=f,r.stringify=function(e,r){if(!e)return"";n((r=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},r)).arrayFormatSeparator);for(var t=function(t){return r.skipNull&&null==e[t]||r.skipEmptyString&&""===e[t]},o=function(e){switch(e.arrayFormat){case"index":return function(r){return function(t,n){var o=t.length;return void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?t:[].concat(D(t),null===n?[i(r,e)+"["+o+"]"]:[i(r,e)+"["+i(o,e)+"]="+i(n,e)])}};case"bracket":return function(r){return function(t,n){return void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?t:[].concat(D(t),null===n?[i(r,e)+"[]"]:[i(r,e)+"[]="+i(n,e)])}};case"colon-list-separator":return function(r){return function(t,n){return void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?t:[].concat(D(t),null===n?[i(r,e)+":list="]:[i(r,e)+":list="+i(n,e)])}};case"comma":case"separator":case"bracket-separator":var r="bracket-separator"===e.arrayFormat?"[]=":"=";return function(t){return function(n,o){return void 0===o||e.skipNull&&null===o||e.skipEmptyString&&""===o?n:(o=null===o?"":o,0===n.length?[""+i(t,e)+r+i(o,e)]:[[n,i(o,e)].join(e.arrayFormatSeparator)])}};default:return function(r){return function(t,n){return void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?t:[].concat(D(t),null===n?[i(r,e)]:[i(r,e)+"="+i(n,e)])}}}}(r),a={},u=0,c=Object.keys(e);c.length>u;u++){var s=c[u];t(s)||(a[s]=e[s])}var l=Object.keys(a);return!1!==r.sort&&l.sort(r.sort),l.map((function(t){var n=e[t];return void 0===n?"":null===n?i(t,r):Array.isArray(n)?0===n.length&&"bracket-separator"===r.arrayFormat?i(t,r)+"[]":n.reduce(o(t),[]).join("&"):i(t,r)+"="+i(n,r)})).filter((function(e){return e.length>0})).join("&")},r.parseUrl=function(e,r){r=Object.assign({decode:!0},r);var t=H(e,"#"),n=I(t,2),o=n[1];return Object.assign({url:n[0].split("?")[0]||"",query:f(s(e),r)},r&&r.parseFragmentIdentifier&&o?{fragmentIdentifier:a(o,r)}:{})},r.stringifyUrl=function(e,n){n=Object.assign(o({encode:!0,strict:!0},t,!0),n);var a=c(e.url).split("?")[0]||"",u=r.extract(e.url),s=r.parse(u,{sort:!1}),l=Object.assign(s,e.query),f=r.stringify(l,n);f&&(f="?".concat(f));var d=function(e){var r="",t=e.indexOf("#");return-1!==t&&(r=e.slice(t)),r}(e.url);return e.fragmentIdentifier&&(d="#".concat(n[t]?i(e.fragmentIdentifier,n):e.fragmentIdentifier)),"".concat(a).concat(f).concat(d)},r.pick=function(e,n,i){i=Object.assign(o({parseFragmentIdentifier:!0},t,!1),i);var a=r.parseUrl(e,i),u=a.fragmentIdentifier;return r.stringifyUrl({url:a.url,query:$(a.query,n),fragmentIdentifier:u},i)},r.exclude=function(e,t,n){return r.pick(e,Array.isArray(t)?function(e){return!t.includes(e)}:function(e,r){return!t(e,r)},n)}}));function q(e,r){void 0===r&&(r={});for(var t=function(e){for(var r=[],t=0;e.length>t;){var n=e[t];if("*"!==n&&"+"!==n&&"?"!==n)if("\\"!==n)if("{"!==n)if("}"!==n)if(":"!==n)if("("!==n)r.push({type:"CHAR",index:t,value:e[t++]});else{var o=1,i="";if("?"===e[u=t+1])throw new TypeError('Pattern cannot start with "?" at '.concat(u));for(;e.length>u;)if("\\"!==e[u]){if(")"===e[u]){if(0==--o){u++;break}}else if("("===e[u]&&(o++,"?"!==e[u+1]))throw new TypeError("Capturing groups are not allowed at ".concat(u));i+=e[u++]}else i+=e[u++]+e[u++];if(o)throw new TypeError("Unbalanced pattern at ".concat(t));if(!i)throw new TypeError("Missing pattern at ".concat(t));r.push({type:"PATTERN",index:t,value:i}),t=u}else{for(var a="",u=t+1;e.length>u;){var c=e.charCodeAt(u);if((48>c||c>57)&&(65>c||c>90)&&(97>c||c>122)&&95!==c)break;a+=e[u++]}if(!a)throw new TypeError("Missing parameter name at ".concat(t));r.push({type:"NAME",index:t,value:a}),t=u}else r.push({type:"CLOSE",index:t,value:e[t++]});else r.push({type:"OPEN",index:t,value:e[t++]});else r.push({type:"ESCAPED_CHAR",index:t++,value:e[t++]});else r.push({type:"MODIFIER",index:t,value:e[t++]})}return r.push({type:"END",index:t,value:""}),r}(e),n=r.prefixes,o=void 0===n?"./":n,i="[^".concat(J(r.delimiter||"/#?"),"]+?"),a=[],u=0,c=0,s="",l=function(e){if(t.length>c&&t[c].type===e)return t[c++].value},f=function(e){var r=l(e);if(void 0!==r)return r;var n=t[c],o=n.index;throw new TypeError("Unexpected ".concat(n.type," at ").concat(o,", expected ").concat(e))},d=function(){for(var e,r="";e=l("CHAR")||l("ESCAPED_CHAR");)r+=e;return r};t.length>c;){var p=l("CHAR"),m=l("NAME"),y=l("PATTERN");if(m||y){-1===o.indexOf(v=p||"")&&(s+=v,v=""),s&&(a.push(s),s=""),a.push({name:m||u++,prefix:v,suffix:"",pattern:y||i,modifier:l("MODIFIER")||""})}else{var g=p||l("ESCAPED_CHAR");if(g)s+=g;else if(s&&(a.push(s),s=""),l("OPEN")){var v=d(),_=l("NAME")||"",x=l("PATTERN")||"",h=d();f("CLOSE"),a.push({name:_||(x?u++:""),pattern:_&&!x?i:x,prefix:v,suffix:h,modifier:l("MODIFIER")||""})}else f("END")}}return a}function B(e,r){var t=[];return function(e,r,t){void 0===t&&(t={});var n=t.decode,o=void 0===n?function(e){return e}:n;return function(t){var n=e.exec(t);if(!n)return!1;for(var i=n[0],a=n.index,u=Object.create(null),c=function(e){if(void 0===n[e])return"continue";var t=r[e-1];u[t.name]="*"===t.modifier||"+"===t.modifier?n[e].split(t.prefix+t.suffix).map((function(e){return o(e,t)})):o(n[e],t)},s=1;n.length>s;s++)c(s);return{path:i,index:a,params:u}}}(z(e,t,r),t,r)}function J(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function V(e){return e&&e.sensitive?"":"i"}function Q(e,r,t){return function(e,r,t){void 0===t&&(t={});for(var n=t.strict,o=void 0!==n&&n,i=t.start,a=void 0===i||i,u=t.end,c=void 0===u||u,s=t.encode,l=void 0===s?function(e){return e}:s,f=t.delimiter,d=void 0===f?"/#?":f,p=t.endsWith,m="[".concat(J(void 0===p?"":p),"]|$"),y="[".concat(J(d),"]"),g=a?"^":"",v=0,_=e;_.length>v;v++){var x=_[v];if("string"==typeof x)g+=J(l(x));else{var h=J(l(x.prefix)),b=J(l(x.suffix));if(x.pattern)if(r&&r.push(x),h||b)if("+"===x.modifier||"*"===x.modifier){var w="*"===x.modifier?"?":"";g+="(?:".concat(h,"((?:").concat(x.pattern,")(?:").concat(b).concat(h,"(?:").concat(x.pattern,"))*)").concat(b,")").concat(w)}else g+="(?:".concat(h,"(").concat(x.pattern,")").concat(b,")").concat(x.modifier);else g+="+"===x.modifier||"*"===x.modifier?"((?:".concat(x.pattern,")").concat(x.modifier,")"):"(".concat(x.pattern,")").concat(x.modifier);else g+="(?:".concat(h).concat(b,")").concat(x.modifier)}}if(c)o||(g+="".concat(y,"?")),g+=t.endsWith?"(?=".concat(m,")"):"$";else{var O=e[e.length-1],E="string"==typeof O?y.indexOf(O[O.length-1])>-1:void 0===O;o||(g+="(?:".concat(y,"(?=").concat(m,"))?")),E||(g+="(?=".concat(y,"|").concat(m,")"))}return RegExp(g,V(t))}(q(e,t),r,t)}function z(e,r,t){return e instanceof RegExp?function(e,r){if(!r)return e;for(var t=/\((?:\?<(.*?)>)?(?!\?)/g,n=0,o=t.exec(e.source);o;)r.push({name:o[1]||n++,prefix:"",suffix:"",modifier:"",pattern:""}),o=t.exec(e.source);return e}(e,r):Array.isArray(e)?function(e,r,t){var n=e.map((function(e){return z(e,r,t).source}));return RegExp("(?:".concat(n.join("|"),")"),V(t))}(e,r,t):Q(e,r,t)}var W=["occurredAt"],X=["/trade/checkout/:id","/trade/processing","/trade/thank_you","/trade/repay","/:storeId/checkouts/:token","/:storeId/checkouts/:token/processing","/:storeId/checkouts/:token/thank_you","/trade/error"],Z=function(){function e(){var r=this;l(this,e),this.fieldMaxAge=2592e6,this.STORAGE_KEY="sl_reference_info",this.COOKIE_KEY="sl_utm",this.LANDING_PAGE_COOKIE="lp_url",this.saveFields=function(e){var t,n,o,i,a=e.referralCode,u=e.sourceType,c=e.UTM,s="unknown";s=document.referrer?0>document.referrer.indexOf("facebook.")&&0>document.referrer.indexOf("google.")?"direct":"platform":"website domain",r.updateLandingPageCookie();var l=+new Date,f={id:x(),landingPage:window.location.origin+window.location.pathname,landingPageHtml:window.location.href,referralInfoHtml:document.referrer,referrerUrl:(null===(t=document.referrer)||void 0===t?void 0:t.split("?")[0])||"",occurredAt:l,source:s,referralCode:a,sourceType:u,utmParameters:c,sourceDescription:(null===(n=window)||void 0===n||null===(o=n.HdSdk)||void 0===o||null===(i=o.baseParams)||void 0===i?void 0:i.getSessionId())||""};try{window.localStorage.setItem(r.STORAGE_KEY,JSON.stringify(f))}catch(e){r.reportSentry("归因保存到localStorage报错",{error:e})}try{var d=window.localStorage.getItem(r.STORAGE_KEY),p=r.getReferenceData();r.reportSentry("调用[localStorage]后尝试获取数据源",{storageData:d,getStorageData:p})}catch(e){r.reportSentry("尝试调用[localStorage]获取数据源报错",{error:e})}},this.init=function(){var e=r.getUrlQuery(),t=e.referralCode,n=void 0===t?"":t,o=e.sourceType,i=void 0===o?"":o,a=e.sl_source_ad_platform,u=void 0===a?"":a,c=e.sl_source_campaign_id,s=void 0===c?"":c,l=e.sl_source_placement,f=void 0===l?"":l,d=e.sl_source_ad_id,p=void 0===d?"":d,m=e.utm_source,y=void 0===m?"":m,g=e.utm_medium,v=void 0===g?"":g,_=e.utm_campaign,x=void 0===_?"":_,b=e.utm_adset,w=void 0===b?"":b,O=e.utm_ad,E=void 0===O?"":O,S=e.utm_content,A=void 0===S?"":S,I=e.utm_term,C=void 0===I?"":I;r.reportSentry("归因所需参数",{urlQuery:e,origin:location.origin,documentReferrer:document.referrer,allLocalStorage:window.localStorage,cookieData:{oldCookieKey:h.get(r.COOKIE_KEY),newCookieData:h.get(r.LANDING_PAGE_COOKIE)}}),r.compatibility();var k=window.location.pathname,j=X.find((function(e){return!!B(e)(k)}));j?console.log("match not reference page",j):(!h.get(r.LANDING_PAGE_COOKIE)||document.referrer&&0>document.referrer.indexOf(location.origin)||n||i||u||s||f||p||y||v||x||w||E||A||C)&&r.saveFields({referralCode:n,sourceType:i,UTM:{sl_source_ad_platform:u,sl_source_campaign_id:s,sl_source_placement:f,sl_source_ad_id:p,utm_source:y,utm_medium:v,utm_campaign:x,utm_adset:w,utm_ad:E,utm_content:A,utm_term:C}})},this.getReferenceData=function(){var e=window.localStorage[r.STORAGE_KEY],t=h.get(r.LANDING_PAGE_COOKIE),n={};if(e)n=JSON.parse(e);else if(t){var o=JSON.parse(t),i=o.occurredAt,a=void 0===i?0:i,u=o.landingPageHtml,c=new URL(u),s=Y.parse(c.search),l=s.referralCode,f=void 0===l?"":l,d=s.sourceType,p=void 0===d?"":d,m=s.sl_source_ad_platform,y=void 0===m?"":m,g=s.sl_source_campaign_id,v=void 0===g?"":g,_=s.sl_source_placement,b=void 0===_?"":_,w=s.sl_source_ad_id,O=void 0===w?"":w,E=s.utm_source,S=void 0===E?"":E,A=s.utm_medium,I=void 0===A?"":A,C=s.utm_campaign,k=void 0===C?"":C,j=s.utm_adset,P=void 0===j?"":j,R=s.utm_ad,N=void 0===R?"":R,T=s.utm_content,D=void 0===T?"":T,F=s.utm_term,M=void 0===F?"":F;n={occurredAt:a,id:x(),sourceDescription:"",source:"unknown",referrerUrl:"",referralInfoHtml:"",landingPage:c.origin+c.pathname,landingPageHtml:u,referralCode:f,sourceType:p,utmParameters:{sl_source_ad_platform:y,sl_source_campaign_id:v,sl_source_placement:b,sl_source_ad_id:O,utm_source:S,utm_medium:I,utm_campaign:k,utm_adset:P,utm_ad:N,utm_content:D,utm_term:M}}}var U=n.occurredAt,L=void 0===U?0:U;return+new Date>Number(L)+r.fieldMaxAge?(0===L?r.reportSentry("归因信息为空",{occurredAt:L,originRefData:e,parseData:n,cookieLandingPageData:t}):(r.reportSentry("归因信息已过期了",{occurredAt:L,originRefData:e,parseData:n,cookieLandingPageData:t}),window.localStorage.removeItem(r.STORAGE_KEY),h.remove(r.LANDING_PAGE_COOKIE)),null):n},this.getUrlQuery=function(){var e,r,t;return window.__LE__&&window.Shopline?(null===(e=window.Shopline)||void 0===e||null===(r=e.uri)||void 0===r?void 0:r.query)||{}:window.__INITIAL_STATE__&&(null===(t=window.__INITIAL_STATE__.uri)||void 0===t?void 0:t.query)||{}},this.updateLandingPageCookie=function(e){var t=null!=e?e:{},n=t.landingPageHtml,o=t.occurredTime,i=new Date;h.set(r.LANDING_PAGE_COOKIE,JSON.stringify({landingPageHtml:null!=n?n:window.location.href,occurredAt:null!=o?o:i.getTime()}),{expires:new Date((null!=o?o:i.getTime())+r.fieldMaxAge),secure:!0})},this.compatibility=function(){var e=window.localStorage.getItem(r.STORAGE_KEY),t=h.get(r.COOKIE_KEY),n=h.get(r.LANDING_PAGE_COOKIE);if(!n&&e){var o=JSON.parse(e);r.updateLandingPageCookie({landingPageHtml:o.landingPageHtml,occurredTime:o.occurredAt})}else if(!n&&t){var i=JSON.parse(t),u=i.occurredAt,c=s(i,W),l=Y.stringifyUrl({url:window.location.origin+window.location.pathname,query:a({},c)});r.updateLandingPageCookie({landingPageHtml:l,occurredTime:u})}h.remove(r.COOKIE_KEY)},this.init()}return d(e,[{key:"reportSentry",value:function(){}}]),e}();window.ReferenceSdk=new Z})); //# sourceMappingURL=reference-sdk.umd.min.js.map