UNPKG

@bgscore/react-router

Version:

Automatic React Router generator for Vite with TypeScript support

2 lines (1 loc) 30.2 kB
import{useLocation as t,useParams as n,Link as e,useNavigate as r,useNavigation as o,useRouteError as i,useMatches as u,useRouteLoaderData as f,useNavigationType as c}from"react-router-dom";import a from"side-channel";import l,{useRef as s,useEffect as p,useMemo as d}from"react";function y(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var v,b,m,h,g,j,w,O,_,E;function $(){if(b)return v;b=1;var t=String.prototype.replace,n=/%20/g,e="RFC3986";return v={default:e,formatters:{RFC1738:function(e){return t.call(e,n,"+")},RFC3986:function(t){return String(t)}},RFC1738:"RFC1738",RFC3986:e}}function x(){if(h)return m;h=1;var t=$(),n=Object.prototype.hasOwnProperty,e=Array.isArray,r=function(){for(var t=[],n=0;n<256;++n)t.push("%"+((n<16?"0":"")+n.toString(16)).toUpperCase());return t}(),o=function(t,n){for(var e=n&&n.plainObjects?{__proto__:null}:{},r=0;r<t.length;++r)void 0!==t[r]&&(e[r]=t[r]);return e},i=1024;return m={arrayToObject:o,assign:function(t,n){return Object.keys(n).reduce((function(t,e){return t[e]=n[e],t}),t)},combine:function(t,n){return[].concat(t,n)},compact:function(t){for(var n=[{obj:{o:t},prop:"o"}],r=[],o=0;o<n.length;++o)for(var i=n[o],u=i.obj[i.prop],f=Object.keys(u),c=0;c<f.length;++c){var a=f[c],l=u[a];"object"==typeof l&&null!==l&&-1===r.indexOf(l)&&(n.push({obj:u,prop:a}),r.push(l))}return function(t){for(;t.length>1;){var n=t.pop(),r=n.obj[n.prop];if(e(r)){for(var o=[],i=0;i<r.length;++i)void 0!==r[i]&&o.push(r[i]);n.obj[n.prop]=o}}}(n),t},decode:function(t,n,e){var r=t.replace(/\+/g," ");if("iso-8859-1"===e)return r.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(r)}catch(t){return r}},encode:function(n,e,o,u,f){if(0===n.length)return n;var c=n;if("symbol"==typeof n?c=Symbol.prototype.toString.call(n):"string"!=typeof n&&(c=String(n)),"iso-8859-1"===o)return escape(c).replace(/%u[0-9a-f]{4}/gi,(function(t){return"%26%23"+parseInt(t.slice(2),16)+"%3B"}));for(var a="",l=0;l<c.length;l+=i){for(var s=c.length>=i?c.slice(l,l+i):c,p=[],d=0;d<s.length;++d){var y=s.charCodeAt(d);45===y||46===y||95===y||126===y||y>=48&&y<=57||y>=65&&y<=90||y>=97&&y<=122||f===t.RFC1738&&(40===y||41===y)?p[p.length]=s.charAt(d):y<128?p[p.length]=r[y]:y<2048?p[p.length]=r[192|y>>6]+r[128|63&y]:y<55296||y>=57344?p[p.length]=r[224|y>>12]+r[128|y>>6&63]+r[128|63&y]:(d+=1,y=65536+((1023&y)<<10|1023&s.charCodeAt(d)),p[p.length]=r[240|y>>18]+r[128|y>>12&63]+r[128|y>>6&63]+r[128|63&y])}a+=p.join("")}return a},isBuffer:function(t){return!(!t||"object"!=typeof t||!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t)))},isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},maybeMap:function(t,n){if(e(t)){for(var r=[],o=0;o<t.length;o+=1)r.push(n(t[o]));return r}return n(t)},merge:function t(r,i,u){if(!i)return r;if("object"!=typeof i&&"function"!=typeof i){if(e(r))r.push(i);else{if(!r||"object"!=typeof r)return[r,i];(u&&(u.plainObjects||u.allowPrototypes)||!n.call(Object.prototype,i))&&(r[i]=!0)}return r}if(!r||"object"!=typeof r)return[r].concat(i);var f=r;return e(r)&&!e(i)&&(f=o(r,u)),e(r)&&e(i)?(i.forEach((function(e,o){if(n.call(r,o)){var i=r[o];i&&"object"==typeof i&&e&&"object"==typeof e?r[o]=t(i,e,u):r.push(e)}else r[o]=e})),r):Object.keys(i).reduce((function(e,r){var o=i[r];return n.call(e,r)?e[r]=t(e[r],o,u):e[r]=o,e}),f)}},m}function A(){if(O)return w;O=1;var t=x(),n=Object.prototype.hasOwnProperty,e=Array.isArray,r={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:t.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},o=function(t){return t.replace(/&#(\d+);/g,(function(t,n){return String.fromCharCode(parseInt(n,10))}))},i=function(t,n,e){if(t&&"string"==typeof t&&n.comma&&t.indexOf(",")>-1)return t.split(",");if(n.throwOnLimitExceeded&&e>=n.arrayLimit)throw new RangeError("Array limit exceeded. Only "+n.arrayLimit+" element"+(1===n.arrayLimit?"":"s")+" allowed in an array.");return t},u=function(e,r,o,u){if(e){var f=o.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,c=/(\[[^[\]]*])/g,a=o.depth>0&&/(\[[^[\]]*])/.exec(f),l=a?f.slice(0,a.index):f,s=[];if(l){if(!o.plainObjects&&n.call(Object.prototype,l)&&!o.allowPrototypes)return;s.push(l)}for(var p=0;o.depth>0&&null!==(a=c.exec(f))&&p<o.depth;){if(p+=1,!o.plainObjects&&n.call(Object.prototype,a[1].slice(1,-1))&&!o.allowPrototypes)return;s.push(a[1])}if(a){if(!0===o.strictDepth)throw new RangeError("Input depth exceeded depth option of "+o.depth+" and strictDepth is true");s.push("["+f.slice(a.index)+"]")}return function(n,e,r,o){var u=0;if(n.length>0&&"[]"===n[n.length-1]){var f=n.slice(0,-1).join("");u=Array.isArray(e)&&e[f]?e[f].length:0}for(var c=o?e:i(e,r,u),a=n.length-1;a>=0;--a){var l,s=n[a];if("[]"===s&&r.parseArrays)l=r.allowEmptyArrays&&(""===c||r.strictNullHandling&&null===c)?[]:t.combine([],c);else{l=r.plainObjects?{__proto__:null}:{};var p="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,d=r.decodeDotInKeys?p.replace(/%2E/g,"."):p,y=parseInt(d,10);r.parseArrays||""!==d?!isNaN(y)&&s!==d&&String(y)===d&&y>=0&&r.parseArrays&&y<=r.arrayLimit?(l=[])[y]=c:"__proto__"!==d&&(l[d]=c):l={0:c}}c=l}return c}(s,r,o,u)}};return w=function(f,c){var a=function(n){if(!n)return r;if(void 0!==n.allowEmptyArrays&&"boolean"!=typeof n.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==n.decodeDotInKeys&&"boolean"!=typeof n.decodeDotInKeys)throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==n.decoder&&void 0!==n.decoder&&"function"!=typeof n.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==n.charset&&"utf-8"!==n.charset&&"iso-8859-1"!==n.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0!==n.throwOnLimitExceeded&&"boolean"!=typeof n.throwOnLimitExceeded)throw new TypeError("`throwOnLimitExceeded` option must be a boolean");var e=void 0===n.charset?r.charset:n.charset,o=void 0===n.duplicates?r.duplicates:n.duplicates;if("combine"!==o&&"first"!==o&&"last"!==o)throw new TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===n.allowDots?!0===n.decodeDotInKeys||r.allowDots:!!n.allowDots,allowEmptyArrays:"boolean"==typeof n.allowEmptyArrays?!!n.allowEmptyArrays:r.allowEmptyArrays,allowPrototypes:"boolean"==typeof n.allowPrototypes?n.allowPrototypes:r.allowPrototypes,allowSparse:"boolean"==typeof n.allowSparse?n.allowSparse:r.allowSparse,arrayLimit:"number"==typeof n.arrayLimit?n.arrayLimit:r.arrayLimit,charset:e,charsetSentinel:"boolean"==typeof n.charsetSentinel?n.charsetSentinel:r.charsetSentinel,comma:"boolean"==typeof n.comma?n.comma:r.comma,decodeDotInKeys:"boolean"==typeof n.decodeDotInKeys?n.decodeDotInKeys:r.decodeDotInKeys,decoder:"function"==typeof n.decoder?n.decoder:r.decoder,delimiter:"string"==typeof n.delimiter||t.isRegExp(n.delimiter)?n.delimiter:r.delimiter,depth:"number"==typeof n.depth||!1===n.depth?+n.depth:r.depth,duplicates:o,ignoreQueryPrefix:!0===n.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof n.interpretNumericEntities?n.interpretNumericEntities:r.interpretNumericEntities,parameterLimit:"number"==typeof n.parameterLimit?n.parameterLimit:r.parameterLimit,parseArrays:!1!==n.parseArrays,plainObjects:"boolean"==typeof n.plainObjects?n.plainObjects:r.plainObjects,strictDepth:"boolean"==typeof n.strictDepth?!!n.strictDepth:r.strictDepth,strictNullHandling:"boolean"==typeof n.strictNullHandling?n.strictNullHandling:r.strictNullHandling,throwOnLimitExceeded:"boolean"==typeof n.throwOnLimitExceeded&&n.throwOnLimitExceeded}}(c);if(""===f||null==f)return a.plainObjects?{__proto__:null}:{};for(var l="string"==typeof f?function(u,f){var c={__proto__:null},a=f.ignoreQueryPrefix?u.replace(/^\?/,""):u;a=a.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var l=f.parameterLimit===1/0?void 0:f.parameterLimit,s=a.split(f.delimiter,f.throwOnLimitExceeded?l+1:l);if(f.throwOnLimitExceeded&&s.length>l)throw new RangeError("Parameter limit exceeded. Only "+l+" parameter"+(1===l?"":"s")+" allowed.");var p,d=-1,y=f.charset;if(f.charsetSentinel)for(p=0;p<s.length;++p)0===s[p].indexOf("utf8=")&&("utf8=%E2%9C%93"===s[p]?y="utf-8":"utf8=%26%2310003%3B"===s[p]&&(y="iso-8859-1"),d=p,p=s.length);for(p=0;p<s.length;++p)if(p!==d){var v,b,m=s[p],h=m.indexOf("]="),g=-1===h?m.indexOf("="):h+1;-1===g?(v=f.decoder(m,r.decoder,y,"key"),b=f.strictNullHandling?null:""):(v=f.decoder(m.slice(0,g),r.decoder,y,"key"),b=t.maybeMap(i(m.slice(g+1),f,e(c[v])?c[v].length:0),(function(t){return f.decoder(t,r.decoder,y,"value")}))),b&&f.interpretNumericEntities&&"iso-8859-1"===y&&(b=o(String(b))),m.indexOf("[]=")>-1&&(b=e(b)?[b]:b);var j=n.call(c,v);j&&"combine"===f.duplicates?c[v]=t.combine(c[v],b):j&&"last"!==f.duplicates||(c[v]=b)}return c}(f,a):f,s=a.plainObjects?{__proto__:null}:{},p=Object.keys(l),d=0;d<p.length;++d){var y=p[d],v=u(y,l[y],a,"string"==typeof f);s=t.merge(s,v,a)}return!0===a.allowSparse?s:t.compact(s)}}function R(){if(E)return _;E=1;var t=function(){if(j)return g;j=1;var t=a,n=x(),e=$(),r=Object.prototype.hasOwnProperty,o={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,n){return t+"["+n+"]"},repeat:function(t){return t}},i=Array.isArray,u=Array.prototype.push,f=function(t,n){u.apply(t,i(n)?n:[n])},c=Date.prototype.toISOString,l=e.default,s={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:n.encode,encodeValuesOnly:!1,filter:void 0,format:l,formatter:e.formatters[l],indices:!1,serializeDate:function(t){return c.call(t)},skipNulls:!1,strictNullHandling:!1},p={},d=function e(r,o,u,c,a,l,d,y,v,b,m,h,g,j,w,O,_,E){for(var $,x=r,A=E,R=0,S=!1;void 0!==(A=A.get(p))&&!S;){var D=A.get(r);if(R+=1,void 0!==D){if(D===R)throw new RangeError("Cyclic object value");S=!0}void 0===A.get(p)&&(R=0)}if("function"==typeof b?x=b(o,x):x instanceof Date?x=g(x):"comma"===u&&i(x)&&(x=n.maybeMap(x,(function(t){return t instanceof Date?g(t):t}))),null===x){if(l)return v&&!O?v(o,s.encoder,_,"key",j):o;x=""}if("string"==typeof($=x)||"number"==typeof $||"boolean"==typeof $||"symbol"==typeof $||"bigint"==typeof $||n.isBuffer(x))return v?[w(O?o:v(o,s.encoder,_,"key",j))+"="+w(v(x,s.encoder,_,"value",j))]:[w(o)+"="+w(String(x))];var C,I=[];if(void 0===x)return I;if("comma"===u&&i(x))O&&v&&(x=n.maybeMap(x,v)),C=[{value:x.length>0?x.join(",")||null:void 0}];else if(i(b))C=b;else{var T=Object.keys(x);C=m?T.sort(m):T}var F=y?String(o).replace(/\./g,"%2E"):String(o),k=c&&i(x)&&1===x.length?F+"[]":F;if(a&&i(x)&&0===x.length)return k+"[]";for(var U=0;U<C.length;++U){var N=C[U],P="object"==typeof N&&N&&void 0!==N.value?N.value:x[N];if(!d||null!==P){var L=h&&y?String(N).replace(/\./g,"%2E"):String(N),Q=i(x)?"function"==typeof u?u(k,L):k:k+(h?"."+L:"["+L+"]");E.set(r,R);var B=t();B.set(p,E),f(I,e(P,Q,u,c,a,l,d,y,"comma"===u&&O&&i(x)?null:v,b,m,h,g,j,w,O,_,B))}}return I};return g=function(n,u){var c,a=n,l=function(t){if(!t)return s;if(void 0!==t.allowEmptyArrays&&"boolean"!=typeof t.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==t.encodeDotInKeys&&"boolean"!=typeof t.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==t.encoder&&void 0!==t.encoder&&"function"!=typeof t.encoder)throw new TypeError("Encoder has to be a function.");var n=t.charset||s.charset;if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var u=e.default;if(void 0!==t.format){if(!r.call(e.formatters,t.format))throw new TypeError("Unknown format option provided.");u=t.format}var f,c=e.formatters[u],a=s.filter;if(("function"==typeof t.filter||i(t.filter))&&(a=t.filter),f=t.arrayFormat in o?t.arrayFormat:"indices"in t?t.indices?"indices":"repeat":s.arrayFormat,"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var l=void 0===t.allowDots?!0===t.encodeDotInKeys||s.allowDots:!!t.allowDots;return{addQueryPrefix:"boolean"==typeof t.addQueryPrefix?t.addQueryPrefix:s.addQueryPrefix,allowDots:l,allowEmptyArrays:"boolean"==typeof t.allowEmptyArrays?!!t.allowEmptyArrays:s.allowEmptyArrays,arrayFormat:f,charset:n,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:s.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:void 0===t.delimiter?s.delimiter:t.delimiter,encode:"boolean"==typeof t.encode?t.encode:s.encode,encodeDotInKeys:"boolean"==typeof t.encodeDotInKeys?t.encodeDotInKeys:s.encodeDotInKeys,encoder:"function"==typeof t.encoder?t.encoder:s.encoder,encodeValuesOnly:"boolean"==typeof t.encodeValuesOnly?t.encodeValuesOnly:s.encodeValuesOnly,filter:a,format:u,formatter:c,serializeDate:"function"==typeof t.serializeDate?t.serializeDate:s.serializeDate,skipNulls:"boolean"==typeof t.skipNulls?t.skipNulls:s.skipNulls,sort:"function"==typeof t.sort?t.sort:null,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:s.strictNullHandling}}(u);"function"==typeof l.filter?a=(0,l.filter)("",a):i(l.filter)&&(c=l.filter);var p=[];if("object"!=typeof a||null===a)return"";var y=o[l.arrayFormat],v="comma"===y&&l.commaRoundTrip;c||(c=Object.keys(a)),l.sort&&c.sort(l.sort);for(var b=t(),m=0;m<c.length;++m){var h=c[m],g=a[h];l.skipNulls&&null===g||f(p,d(g,h,y,v,l.allowEmptyArrays,l.strictNullHandling,l.skipNulls,l.encodeDotInKeys,l.encode?l.encoder:null,l.filter,l.sort,l.allowDots,l.serializeDate,l.format,l.formatter,l.encodeValuesOnly,l.charset,b))}var j=p.join(l.delimiter),w=!0===l.addQueryPrefix?"?":"";return l.charsetSentinel&&("iso-8859-1"===l.charset?w+="utf8=%26%2310003%3B&":w+="utf8=%E2%9C%93&"),j.length>0?w+j:""}}(),n=A(),e=$();return _={formats:e,parse:n,stringify:t}}var S=y(R());function D(t,n){return t===n||t!=t&&n!=n}function C(t,n){for(var e=t.length;e--;)if(D(t[e][0],n))return e;return-1}var I=Array.prototype.splice;function T(t){var n=-1,e=null==t?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}T.prototype.clear=function(){this.i=[],this.size=0},T.prototype.delete=function(t){var n=this.i,e=C(n,t);return!(e<0||(e==n.length-1?n.pop():I.call(n,e,1),--this.size,0))},T.prototype.get=function(t){var n=this.i,e=C(n,t);return e<0?void 0:n[e][1]},T.prototype.has=function(t){return C(this.i,t)>-1},T.prototype.set=function(t,n){var e=this.i,r=C(e,t);return r<0?(++this.size,e.push([t,n])):e[r][1]=n,this};var F="object"==typeof global&&global&&global.Object===Object&&global,k="object"==typeof self&&self&&self.Object===Object&&self,U=F||k||Function("return this")(),N=U.Symbol,P=Object.prototype,L=P.hasOwnProperty,Q=P.toString,B=N?N.toStringTag:void 0,K=Object.prototype.toString,q=N?N.toStringTag:void 0;function H(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":q&&q in Object(t)?function(t){var n=L.call(t,B),e=t[B];try{t[B]=void 0;var r=!0}catch(t){}var o=Q.call(t);return r&&(n?t[B]=e:delete t[B]),o}(t):function(t){return K.call(t)}(t)}function M(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}function z(t){if(!M(t))return!1;var n=H(t);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}var V,G=U["u"],J=(V=/[^.]+$/.exec(G&&G.keys&&G.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",W=Function.prototype.toString,X=/^\[object .+?Constructor\]$/,Y=Function.prototype,Z=Object.prototype,tt=Y.toString,nt=Z.hasOwnProperty,et=RegExp("^"+tt.call(nt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function rt(t,n){var e=function(t,n){return null==t?void 0:t[n]}(t,n);return function(t){return!(!M(t)||(n=t,J&&J in n))&&(z(t)?et:X).test(function(t){if(null!=t){try{return W.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var n}(e)?e:void 0}var ot=rt(U,"Map"),it=rt(Object,"create"),ut=Object.prototype.hasOwnProperty,ft=Object.prototype.hasOwnProperty;function ct(t){var n=-1,e=null==t?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}function at(t,n){var e,r,o=t.i;return("string"==(r=typeof(e=n))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==e:null===e)?o["string"==typeof n?"string":"hash"]:o.map}function lt(t){var n=-1,e=null==t?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}function st(t){var n=this.i=new T(t);this.size=n.size}ct.prototype.clear=function(){this.i=it?it(null):{},this.size=0},ct.prototype.delete=function(t){var n=this.has(t)&&delete this.i[t];return this.size-=n?1:0,n},ct.prototype.get=function(t){var n=this.i;if(it){var e=n[t];return"__lodash_hash_undefined__"===e?void 0:e}return ut.call(n,t)?n[t]:void 0},ct.prototype.has=function(t){var n=this.i;return it?void 0!==n[t]:ft.call(n,t)},ct.prototype.set=function(t,n){var e=this.i;return this.size+=this.has(t)?0:1,e[t]=it&&void 0===n?"__lodash_hash_undefined__":n,this},lt.prototype.clear=function(){this.size=0,this.i={hash:new ct,map:new(ot||T),string:new ct}},lt.prototype.delete=function(t){var n=at(this,t).delete(t);return this.size-=n?1:0,n},lt.prototype.get=function(t){return at(this,t).get(t)},lt.prototype.has=function(t){return at(this,t).has(t)},lt.prototype.set=function(t,n){var e=at(this,t),r=e.size;return e.set(t,n),this.size+=e.size==r?0:1,this},st.prototype.clear=function(){this.i=new T,this.size=0},st.prototype.delete=function(t){var n=this.i,e=n.delete(t);return this.size=n.size,e},st.prototype.get=function(t){return this.i.get(t)},st.prototype.has=function(t){return this.i.has(t)},st.prototype.set=function(t,n){var e=this.i;if(e instanceof T){var r=e.i;if(!ot||r.length<199)return r.push([t,n]),this.size=++e.size,this;e=this.i=new lt(r)}return e.set(t,n),this.size=e.size,this};var pt=function(){try{var t=rt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function dt(t,n,e){"__proto__"==n&&pt?pt(t,n,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[n]=e}function yt(t,n,e){(void 0!==e&&!D(t[n],e)||void 0===e&&!(n in t))&&dt(t,n,e)}var vt="object"==typeof exports&&exports&&!exports.nodeType&&exports,bt=vt&&"object"==typeof module&&module&&!module.nodeType&&module,mt=bt&&bt.exports===vt?U.Buffer:void 0;mt&&mt.allocUnsafe;var ht,gt,jt=U.Uint8Array,wt=Object.create,Ot=function(){function t(){}return function(n){if(!M(n))return{};if(wt)return wt(n);t.prototype=n;var e=new t;return t.prototype=void 0,e}}(),_t=(ht=Object.getPrototypeOf,gt=Object,function(t){return ht(gt(t))}),Et=Object.prototype;function $t(t){var n=t&&t.constructor;return t===("function"==typeof n&&n.prototype||Et)}function xt(t){return null!=t&&"object"==typeof t}function At(t){return xt(t)&&"[object Arguments]"==H(t)}var Rt=Object.prototype,St=Rt.hasOwnProperty,Dt=Rt.propertyIsEnumerable,Ct=At(function(){return arguments}())?At:function(t){return xt(t)&&St.call(t,"callee")&&!Dt.call(t,"callee")},It=Array.isArray;function Tt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function Ft(t){return null!=t&&Tt(t.length)&&!z(t)}var kt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ut=kt&&"object"==typeof module&&module&&!module.nodeType&&module,Nt=Ut&&Ut.exports===kt?U.Buffer:void 0,Pt=(Nt?Nt.isBuffer:void 0)||function(){return!1},Lt=Function.prototype,Qt=Object.prototype,Bt=Lt.toString,Kt=Qt.hasOwnProperty,qt=Bt.call(Object),Ht={};Ht["[object Float32Array]"]=Ht["[object Float64Array]"]=Ht["[object Int8Array]"]=Ht["[object Int16Array]"]=Ht["[object Int32Array]"]=Ht["[object Uint8Array]"]=Ht["[object Uint8ClampedArray]"]=Ht["[object Uint16Array]"]=Ht["[object Uint32Array]"]=!0,Ht["[object Arguments]"]=Ht["[object Array]"]=Ht["[object ArrayBuffer]"]=Ht["[object Boolean]"]=Ht["[object DataView]"]=Ht["[object Date]"]=Ht["[object Error]"]=Ht["[object Function]"]=Ht["[object Map]"]=Ht["[object Number]"]=Ht["[object Object]"]=Ht["[object RegExp]"]=Ht["[object Set]"]=Ht["[object String]"]=Ht["[object WeakMap]"]=!1;var Mt="object"==typeof exports&&exports&&!exports.nodeType&&exports,zt=Mt&&"object"==typeof module&&module&&!module.nodeType&&module,Vt=zt&&zt.exports===Mt&&F.process,Gt=function(){try{return zt&&zt.require&&zt.require("util").types||Vt&&Vt.binding&&Vt.binding("util")}catch(t){}}(),Jt=Gt&&Gt.isTypedArray,Wt=Jt?function(t){return function(n){return t(n)}}(Jt):function(t){return xt(t)&&Tt(t.length)&&!!Ht[H(t)]};function Xt(t,n){if(("constructor"!==n||"function"!=typeof t[n])&&"__proto__"!=n)return t[n]}var Yt=Object.prototype.hasOwnProperty;function Zt(t,n,e){var r=t[n];Yt.call(t,n)&&D(r,e)&&(void 0!==e||n in t)||dt(t,n,e)}var tn=/^(?:0|[1-9]\d*)$/;function nn(t,n){var e=typeof t;return!!(n=null==n?9007199254740991:n)&&("number"==e||"symbol"!=e&&tn.test(t))&&t>-1&&t%1==0&&t<n}var en=Object.prototype.hasOwnProperty;function rn(t){return Ft(t)?function(t){var n=It(t),e=!n&&Ct(t),r=!n&&!e&&Pt(t),o=!n&&!e&&!r&&Wt(t),i=n||e||r||o,u=i?function(t,n){for(var e=-1,r=Array(t);++e<t;)r[e]=n(e);return r}(t.length,String):[],f=u.length;for(var c in t)i&&("length"==c||r&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||nn(c,f))||u.push(c);return u}(t):function(t){if(!M(t))return function(t){var n=[];if(null!=t)for(var e in Object(t))n.push(e);return n}(t);var n=$t(t),e=[];for(var r in t)("constructor"!=r||!n&&en.call(t,r))&&e.push(r);return e}(t)}function on(t,n,e,r,o){t!==n&&function(t,n,e){for(var r=-1,o=Object(t),i=e(t),u=i.length;u--;){var f=i[++r];if(!1===n(o[f],f))break}}(n,(function(i,u){if(o||(o=new st),M(i))!function(t,n,e,r,o,i,u){var f,c,a,l,s=Xt(t,e),p=Xt(n,e),d=u.get(p);if(d)yt(t,e,d);else{var y,v=i?i(s,p,e+"",t,n,u):void 0,b=void 0===v;if(b){var m=It(p),h=!m&&Pt(p),g=!m&&!h&&Wt(p);v=p,m||h||g?It(s)?v=s:xt(y=s)&&Ft(y)?v=function(t,n){var e=-1,r=t.length;for(n||(n=Array(r));++e<r;)n[e]=t[e];return n}(s):h?(b=!1,v=p.slice()):g?(b=!1,a=new(c=(f=p).buffer).constructor(c.byteLength),new jt(a).set(new jt(c)),l=a,v=new f.constructor(l,f.byteOffset,f.length)):v=[]:function(t){if(!xt(t)||"[object Object]"!=H(t))return!1;var n=_t(t);if(null===n)return!0;var e=Kt.call(n,"constructor")&&n.constructor;return"function"==typeof e&&e instanceof e&&Bt.call(e)==qt}(p)||Ct(p)?(v=s,Ct(s)?v=function(t){return function(t,n,e){var r=!e;e||(e={});for(var o=-1,i=n.length;++o<i;){var u=n[o],f=void 0;void 0===f&&(f=t[u]),r?dt(e,u,f):Zt(e,u,f)}return e}(t,rn(t))}(s):M(s)&&!z(s)||(v=function(t){return"function"!=typeof t.constructor||$t(t)?{}:Ot(_t(t))}(p))):b=!1}b&&(u.set(p,v),o(v,p,r,i,u),u.delete(p)),yt(t,e,v)}}(t,n,u,e,on,r,o);else{var f=r?r(Xt(t,u),i,u+"",t,n,o):void 0;void 0===f&&(f=i),yt(t,u,f)}}),rn)}function un(t){return t}var fn,cn=Math.max,an=pt?function(t,n){return pt(t,"toString",{configurable:!0,enumerable:!1,value:(e=n,function(){return e}),writable:!0});var e}:un,ln=Date.now,sn=function(t){var n=0,e=0;return function(){var r=ln(),o=16-(r-e);if(e=r,o>0){if(++n>=800)return arguments[0]}else n=0;return t.apply(void 0,arguments)}}(an),pn=(fn=function(t,n,e){on(t,n,e)},function(t){return sn(function(t,n,e){return n=cn(void 0===n?t.length-1:n,0),function(){for(var r=arguments,o=-1,i=cn(r.length-n,0),u=Array(i);++o<i;)u[o]=r[n+o];o=-1;for(var f=Array(n+1);++o<n;)f[o]=r[o];return f[n]=e(u),function(t,n,e){switch(e.length){case 0:return t.call(n);case 1:return t.call(n,e[0]);case 2:return t.call(n,e[0],e[1]);case 3:return t.call(n,e[0],e[1],e[2])}return t.apply(n,e)}(t,this,f)}}(t,void 0,un),t+"")}((function(t,n){var e=-1,r=n.length,o=r>1?n[r-1]:void 0,i=r>2?n[2]:void 0;for(o=fn.length>3&&"function"==typeof o?(r--,o):void 0,i&&function(t,n,e){if(!M(e))return!1;var r=typeof n;return!!("number"==r?Ft(e)&&nn(n,e.length):"string"==r&&n in e)&&D(e[n],t)}(n[0],n[1],i)&&(o=r<3?void 0:o,r=1),t=Object(t);++e<r;){var u=n[e];u&&fn(t,u,e)}return t})));function dn(t,n,e=" | "){const r=s(document.title);p((()=>{const o=r.current,i=[],u=document.head,f=t.templateTitle?t.templateTitle:!0===n?o:n,c=t.sparatorTitle||e;return!1===n&&"boolean"==typeof n||(t.title?document.title=f?`${t.title}${c}${f}`:t.title:document.title=`${f||""}`),[{name:"description",content:t.description},{name:"application-name",content:t.applicationName},{name:"keywords",content:t.keywords?.join(", ")},{name:"robots",content:"string"==typeof t.robots?t.robots:t.robots?[t.robots.index?"index":"noindex",t.robots.follow?"follow":"nofollow",t.robots.nocache&&"nocache",t.robots.noimageindex&&"noimageindex",t.robots.nosnippet&&"nosnippet"].filter(Boolean).join(", "):null}].forEach((({name:t,content:n})=>{if(!n)return;let e=document.querySelector(`meta[name="${t}"]`);e||(e=document.createElement("meta"),e.setAttribute("name",t),u.appendChild(e),i.push(e)),e.setAttribute("content",n)})),document.querySelectorAll('meta[name="author"], link[rel="author"]').forEach((t=>t.remove())),t.authors?.forEach((t=>{const n=document.createElement("meta");if(n.name="author",n.content=t.name,u.appendChild(n),i.push(n),t.url){const n=document.createElement("link");n.rel="author",n.href=t.url,u.appendChild(n),i.push(n)}})),document.querySelectorAll('meta[property^="og:"]').forEach((t=>t.remove())),t.openGraph&&([{property:"og:type",content:t.openGraph.type||"website"},{property:"og:title",content:t.openGraph.title||t.title},{property:"og:description",content:t.openGraph.description||t.description},{property:"og:url",content:t.openGraph.url},{property:"og:site_name",content:t.openGraph.siteName}].forEach((({property:t,content:n})=>{if(!n)return;const e=document.createElement("meta");e.setAttribute("property",t),e.content=n,u.appendChild(e),i.push(e)})),t.openGraph.images?.forEach((t=>{[{property:"og:image",content:t.url},{property:"og:image:width",content:t.width?.toString()},{property:"og:image:height",content:t.height?.toString()},{property:"og:image:alt",content:t.alt}].forEach((({property:t,content:n})=>{if(!n)return;const e=document.createElement("meta");e.setAttribute("property",t),e.content=n,u.appendChild(e),i.push(e)}))}))),()=>{i.forEach((t=>t.remove())),t.title&&(document.title="")}}),[t])}const yn=({data:r,to:o="",children:i,query:u,queryData:f,preserveQuery:c,replaceSameName:a,ignoreTrailingSlash:s,...p})=>{const y=t(),v=n(),b=d((()=>{let t=`${o||""}`;const n=S.parse(y.search,{ignoreQueryPrefix:!0}),e=mn({...v,...n});if(c&&y.search&&!bn(u)&&(t+=y.search),u){const n=a?{...e,...u}:pn({},c?e:{},u);t+=`${t.includes("?")?"&":"?"}${hn(n)}`}if(r&&f){let n={};Object.entries(f).forEach((([t,e])=>{const o=vn(r,e);bn(o)&&(n[t]=o)})),t+=`${t.includes("?")?"&":"?"}${hn(n)}`}return r&&(t=t.replace(/:(\w+)/g,((t,n)=>{const e=vn(r,n);return bn(e)?encodeURIComponent(String(e)):""}))),s||(t=t.replace(/\/+/g,"/")),t}),[o,r,y.search,c,a,u,f,v,s]);return l.createElement(e,{to:b,...p},i)},vn=(t,n,e)=>{if(!t)return e;if(t.hasOwnProperty(n))return t[n];const r=n.replace(/\[(\d+)\]/g,".$1").split(".");let o=t;for(const t of r){if(null==o)return e;o=o[t]}return void 0===o?e:o};function bn(t){return!(null==t||"string"==typeof t&&""===t.trim()||Array.isArray(t)&&0===t.length||"object"==typeof t&&null!==t&&!Array.isArray(t)&&0===Object.keys(t).length)}function mn(t){if("null"===t)return null;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=mn(t[n]);else if(t&&"object"==typeof t)for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=mn(t[n]));return t}function hn(t,n=""){const e=[];for(const r in t)if(t.hasOwnProperty(r)){const o=t[r],i=n?`${n}[${encodeURIComponent(r)}]`:encodeURIComponent(r);if(!bn(o))continue;Array.isArray(o)?o.forEach((t=>{e.push(`${i}=${encodeURIComponent(t)}`)})):"object"==typeof o&&null!==o?e.push(hn(o,i)):e.push(`${i}=${encodeURIComponent(o)}`)}return e.join("&")}function gn(){const e=n(),a=t(),l=r(),s=o(),p=i(),y=u(),v=y[y.length-1],b=v?.id??"",m=f(b)||{},h=c();return d((()=>{const t=S.parse(a.search,{ignoreQueryPrefix:!0}),n=On({...e,...t}),r=y.find((t=>t.pathname===a.pathname&&t.data))?.data||{},o={...r?.metadata,...m?.metadata},i={...r?.data,...m?.data};return o&&(delete o?.loader,delete o?.errorElement),{push:(t,e)=>{if("string"==typeof t){let r=t;const{preserveQuery:o,replaceSameName:i,query:u,queryData:f,data:c,...s}=e||{};if(o&&a.search&&!u&&(r+=a.search),u){const t=i?{...n,...u}:pn({},o?n:{},u);r+=`${r.includes("?")?"&":"?"}${jn(t)}`}if(c&&f){let t={};Object.entries(f).forEach((([n,e])=>{const r=_n(c,e);wn(r)&&(t[n]=r)})),r+=`${r.includes("?")?"&":"?"}${jn(t)}`}const p=r.replace(/:(\w+)/g,((t,n)=>{const e=_n(c,n);return wn(e)?encodeURIComponent(e):""}));l(p,s)}else l(t,e)},pathname:a.pathname,query:n,location:a,navigate:l,goBack:function(t){try{l("PUSH"===h?-1:t)}catch(t){}},metadata:o,data:i,navigation:s,loading:"loading"===s.state,idle:"idle"===s.state,submitting:"submitting"===s.state,error:p,matches:y,id:b}}),[e,a,l,y])}function jn(t,n=""){const e=[];for(const r in t)if(t.hasOwnProperty(r)){const o=t[r],i=n?`${n}[${encodeURIComponent(r)}]`:encodeURIComponent(r);if(!wn(o))continue;Array.isArray(o)?o.forEach((t=>{e.push(`${i}=${encodeURIComponent(t)}`)})):"object"==typeof o&&null!==o?e.push(jn(o,i)):e.push(`${i}=${encodeURIComponent(o)}`)}return e.join("&")}function wn(t){return!(null==t||"string"==typeof t&&""===t.trim()||Array.isArray(t)&&0===t.length||"object"==typeof t&&null!==t&&!Array.isArray(t)&&0===Object.keys(t).length)}function On(t){if("null"===t)return null;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=On(t[n]);else if(t&&"object"==typeof t)for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=On(t[n]));return t}const _n=(t,n,e)=>{if(!t)return e;if(t.hasOwnProperty(n))return t[n];const r=n.replace(/\[(\d+)\]/g,".$1").split(".");let o=t;for(const t of r){if(null==o)return e;o=o[t]}return void 0===o?e:o};export{yn as Link,gn as default,dn as useMetadata,gn as useRouter};