try{let e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`ebd6892b-9d0b-4008-946c-f07394c5db0f`,e._sentryDebugIdIdentifier=`sentry-dbid-ebd6892b-9d0b-4008-946c-f07394c5db0f`)}catch{}import{o as e}from"./rolldown-runtime-nx40z1zs.js";import{t}from"./useIntraDialogHistory-id9u91ur.js";import{t as n}from"./useLocation-gval357w.js";import{Ag as r,Ol as i,Qm as a,Sp as o,fp as s,jg as c}from"./entry.client-mpghtlrl.js";import{t as l}from"./DialogShellContext-grfsno45.js";var u=r(),d=e(c(),1),f=(0,d.createContext)(void 0);function p(){return(0,d.useContext)(f)}function m(){return p()?.host===`widget`}function h(e,t){if(!t)return`unknown`;try{return e.matchRoutes(t,{}).at(-1)?.fullPath??`unknown`}catch{return`unknown`}}var g=()=>{let e=(0,u.c)(7),t=p(),r=s(),c=o(),{trackUserAction:l}=a(),f=n(),m=(0,d.useRef)(f),g=(0,d.useRef)(c),_;e[0]!==f||e[1]!==c?(_=()=>{m.current=f,g.current=c},e[0]=f,e[1]=c,e[2]=_):_=e[2],(0,d.useEffect)(_);let v;return e[3]!==t||e[4]!==r||e[5]!==l?(v=e=>{if(t?.navigate){t.navigate({to:e.to,params:e.params,search:e.search,replace:e.replace});return}let n=m.current,a=i(e),o=new URL(`https://example.com${a}`).pathname;r({to:e.to,params:e.params,search:e.search,replace:e.replace,state:{prevPath:o===n.pathname?n.state?.prevPath:n.pathname}}),o!==n.pathname&&l(`NavigateInModal`,{destination:e.to,source:h(g.current,n.pathname)},`Press`)},e[3]=t,e[4]=r,e[5]=l,e[6]=v):v=e[6],v},_=()=>{let e=(0,u.c)(8),r=p(),i=(0,d.useContext)(l),s=t(),{trackUserAction:c}=a(),f=n(),m=o(),g;e[0]!==s||e[1]!==c||e[2]!==m||e[3]!==f.state||e[4]!==f.pathname?(g=()=>{s.goBack(),c(`NavigateInModal`,{destination:h(m,f.state?.prevPath??``),source:h(m,f.pathname)},`Press`)},e[0]=s,e[1]=c,e[2]=m,e[3]=f.state,e[4]=f.pathname,e[5]=g):g=e[5];let _=g,v;e[6]===i?v=e[7]:(v=()=>{i?.onClose()},e[6]=i,e[7]=v);let y=v;return r?.navigateBack?r.navigateBack:s.index===0?y:_};export{m as a,p as i,_ as n,f as r,g as t};