import{c as t}from"./p-9bfc48ee.js";let e;const r=r=>{var n;const o=window,s=new URL(o.location.href),l=null!==(n=null==r?void 0:r.parseURL)&&void 0!==n?n:i,{state:u,onChange:p,dispose:f}=t({url:s,activePath:l(s)},((t,e,r)=>"url"===r?t.href!==e.href:t!==e)),c=t=>{history.pushState(null,null,t);const e=new URL(t,document.baseURI);u.url=e,u.activePath=l(e)},v=t=>{const{activePath:e}=u;for(let r of t){const n=a(e,r.path);if(n){if(null!=r.to){const n="string"==typeof r.to?r.to:r.to(e);return c(n),v(t)}return{params:n,route:r}}}},d=()=>{const t=new URL(o.location.href);u.url=t,u.activePath=l(t)},g=e={Switch:(t,e)=>{const r=v(e);if(r)return"function"==typeof r.route.jsx?r.route.jsx(r.params):r.route.jsx},get url(){return u.url},get activePath(){return u.activePath},push:c,onChange:p,dispose:()=>{e=void 0,o.removeEventListener("popstate",d),f()}};return d(),o.addEventListener("popstate",d),g},n=(t,e)=>{var r;return"to"in t?{path:t.path,to:t.to}:{path:t.path,id:t.id,jsx:null!==(r=t.render)&&void 0!==r?r:e}},o=(t,r=e)=>({href:t,onClick:e=>{e.metaKey||e.ctrlKey||2!=e.which&&1!=e.button&&(e.preventDefault(),r.push(t))}}),a=(t,e)=>{if("string"==typeof e){if(e===t)return{}}else if("function"==typeof e){const r=e(t);if(r)return!0===r?{}:{...r}}else{const r=e.exec(t);if(r)return e.lastIndex=0,{...r}}},i=t=>t.pathname.toLowerCase(),s=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g"),l=t=>t.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),u=t=>t.replace(/([=!:$/()])/g,"\\$1"),p=t=>t&&t.sensitive?"":"i",f=(t,e,r)=>{for(var n=(r=r||{}).strict,o=!1!==r.end,a=l(r.delimiter||"/"),i=r.delimiters||"./",s=[].concat(r.endsWith||[]).map(l).concat("$").join("|"),u="",f=!1,c=0;c<t.length;c++){var v=t[c];if("string"==typeof v)u+=l(v),f=c===t.length-1&&i.indexOf(v[v.length-1])>-1;else{var d=l(v.prefix||""),g=v.repeat?"(?:"+v.pattern+")(?:"+d+"(?:"+v.pattern+"))*":v.pattern;e&&e.push(v),u+=v.optional?v.partial?d+"("+g+")?":"(?:"+d+"("+g+"))?":d+"("+g+")"}}return o?(n||(u+="(?:"+a+")?"),u+="$"===s?"$":"(?="+s+")"):(n||(u+="(?:"+a+"(?="+s+"))?"),f||(u+="(?="+a+"|"+s+")")),new RegExp("^"+u,p(r))},c=(t,e,r)=>t instanceof RegExp?((t,e)=>{if(!e)return t;var r=t.source.match(/\((?!\?)/g);if(r)for(var n=0;n<r.length;n++)e.push({name:n,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return t})(t,e):Array.isArray(t)?((t,e,r)=>{for(var n=[],o=0;o<t.length;o++)n.push(c(t[o],e,r).source);return new RegExp("(?:"+n.join("|")+")",p(r))})(t,e,r):((t,e,r)=>f(((t,e)=>{for(var r,n=[],o=0,a=0,i="",p=e&&e.delimiter||"/",f=e&&e.delimiters||"./",c=!1;null!==(r=s.exec(t));){var v=r[0],d=r[1],g=r.index;if(i+=t.slice(a,g),a=g+v.length,d)i+=d[1],c=!0;else{var h="",m=t[a],w=r[2],y=r[3],x=r[4],$=r[5];if(!c&&i.length){var R=i.length-1;f.indexOf(i[R])>-1&&(h=i[R],i=i.slice(0,R))}i&&(n.push(i),i="",c=!1);var E=h||p,b=y||x;n.push({name:w||o++,prefix:h,delimiter:E,optional:"?"===$||"*"===$,repeat:"+"===$||"*"===$,partial:""!==h&&void 0!==m&&m!==h,pattern:b?u(b):"[^"+l(E)+"]+?"})}}return(i||a<t.length)&&n.push(i+t.substr(a)),n})(t,r),e,r))(t,e,r);let v=0;const d={},g=(t,e={})=>{const{exact:r=!1,strict:n=!1}=e,{re:o,keys:a}=((t,e)=>{const r=`${e.end}${e.strict}`,n=d[r]||(d[r]={}),o=JSON.stringify(t);if(n[o])return n[o];const a=[],i={re:c(t,a,e),keys:a};return v<1e4&&(n[o]=i,v+=1),i})(t,{end:r,strict:n});return t=>{const e=o.exec(t);if(!e)return;const[n,...i]=e;return r&&t!==n?void 0:a.reduce(((t,e,r)=>(t[e.name]=i[r],t)),{})}},{state:h,set:m}=(t({router:r()}),t({router:r(),routes:null,mode:null,wrapper:null,recommendations:null,layout:null,plugins:null})),{state:w}=t({tabs:[]});export{n as R,g as a,m as b,o as h,w as m,h as r}