import{c as e,t}from"./UJE8BsR4.js";import{t as n}from"./tmK-_Zu8.js";const r=(e=>e===`pathname`?`pathname`:`hash`)(void 0);var i=e=>{if(!e)return`/`;let t=e.trim();return t?(t.startsWith(`/`)?t:`/${t}`).replace(/\/+/g,`/`):`/`};const a=e=>{if(!e)return`/`;let t=e.trim();if(!t)return`/`;let n=t.replace(/^#/,``),[r]=n.split(`?`),a=i(r??n);return a.length>1&&a.endsWith(`/`)?a.slice(0,-1):a};var o=[`/`,`/dashboard`,`/providers`,`/licensing`,`/actions`,`/lead-scoring`,`/settings`],s=/^(?:[a-z][a-z0-9+.-]*:)?\/\//i;const c=e=>{if(!e)return!0;let t=e.trim();if(!t)return!0;if(s.test(t))return!1;let n=a(t);return o.some(e=>e===`/`?n===`/`:n===e||n.startsWith(`${e}/`))};var l=[{path:`/providers`,matches:e=>e===`/providers`||e.startsWith(`/providers/`)},{path:`/actions/custom`,matches:e=>e===`/actions/custom`||e.startsWith(`/actions/custom/`)},{path:`/actions/log`,matches:e=>e===`/actions/log`||e.startsWith(`/actions/log/`)},{path:`/lead-scoring`,matches:e=>e===`/lead-scoring`||e.startsWith(`/lead-scoring/`)},{path:`/actions`,matches:e=>e===`/actions`||e.startsWith(`/actions/`)},{path:`/settings/migration`,matches:e=>e===`/settings/migration`},{path:`/settings`,matches:e=>e===`/settings`||e.startsWith(`/settings/`)},{path:`/dashboard`,matches:e=>e===`/dashboard`},{path:`/licensing`,matches:e=>e===`/licensing`}];const u=e=>{let t=a(e);return l.find(e=>e.matches(t))?.path??null},d=()=>typeof window>`u`||window.location===void 0?`/`:a(window.location.hash.replace(/^#/,``)),f=(t,n)=>{let a=n?.routerType??r,o=n?.basePath??e,s=i(t);if(a===`hash`)return`#${s}`.replace(`#//`,`#/`);let c=`${o}${s}`.replace(/\/+/g,`/`);return c===``?`/`:c},p=f,m=(t,n)=>{let i=n?.routerType??r,o=n?.basePath??e;if(i===`hash`)return a(t.hash?.replace(/^#/,``)??``);let s=t.pathname||`/`;if(!o||o===`/`)return a(s||`/`);if(s.startsWith(o)){let e=s.slice(o.length)||`/`;return a(e.startsWith(`/`)?e:`/${e}`)}return a(s)},h=async(e,r)=>{if(!n)return;if(!c(e)){window.location.assign(e);return}let i=f(e);try{await t(i,r)}catch(e){console.error(`navigateToAppPath fallback`,e),typeof window<`u`&&window.location!==void 0&&(window.location.hash=i.startsWith(`#`)?i:`#${i.replace(/^#/,``)}`)}};export{u as a,d as i,m as n,r as o,h as r,p as t};