1import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-DiVRNtpo.js";import{t as n}from"./jsx-runtime-BdxMnOeJ.js";import{i as r}from"./localStorage-PprGnQFF.js";import{n as i}from"./preload-helper-Dezw8xDO.js";import{a,f as o,i as s,r as c}from"./authnService-CfwUXyap.js";import{r as l}from"./AuthenticationContext-CxUMRNXp.js";import{t as u}from"./useTokenDetails-DtpWP_Hz.js";import{t as d}from"./logger-C-AWbIL0.js";import{n as f}from"./lib-BeTWPfFW.js";var p=e(t(),1),m={Loading:`loading`,LoginRequired:`login_required`,Authenticated:`authenticated`,Failed:`failed`},h=e=>({origin:`auth0`,code:e.code,message:e.message}),g=e(i(),1),_=`unfi`,v=e=>!!e?.providerData.some(e=>e?.providerId===_),y=()=>{let e=c(),{idpUser:t,loading:n,idp:i,idpDisplayName:y}=l(),{tokenDetails:b,tokenLoading:x}=u(),[S,C]=(0,p.useState)();(0,p.useEffect)(()=>{o(a.AUTH0)},[]);let w=(0,p.useMemo)(()=>()=>{let t=e.provider===a.AUTH0?e:o(a.AUTH0);if(t.provider!==a.AUTH0)return;let n=`${window.location.pathname}${window.location.search}`;t.signInWithRedirect(_,void 0,{redirect_uri:`${window.location.origin}${f}`},{returnTo:n}).catch(e=>{s(e)?(d.error(`UnfiInsightsEmbedded - Auth0 sign-in redirect error:`,e),C(h(e))):(d.error(`UnfiInsightsEmbedded - Auth0 sign-in unexpected error:`,e),C({origin:`auth0`,code:`auth0/unknown`,message:e instanceof Error?e.message:String(e)}))})},[e]),T=(0,p.useMemo)(()=>{switch(!0){case!!S:return m.Failed;case n:return m.Loading;case!!t&&v(t):return m.Authenticated;default:return m.LoginRequired}},[S,n,t]);return(0,p.useEffect)(()=>(r.unfiInsightsEmbedded.getIdpUser=()=>t?g.default.pick(t,`displayName`,`email`,`providerData`):void 0,()=>{r.unfiInsightsEmbedded.getIdpUser=()=>void 0}),[t]),{state:T,error:S,idpUser:t,idpUserToken:b??void 0,idpUserTokenLoading:x,idp:i,idpDisplayName:y,signInWithRedirect:w}},b=n(),x=p.createContext({state:m.Loading,idpUser:void 0,idpUserToken:void 0,idpUserTokenLoading:!1,idp:a.AUTH0,idpDisplayName:`Auth0`,error:void 0,signInWithRedirect:()=>void 0}),S=()=>(0,p.useContext)(x),C=({children:e})=>{let t=y();return(0,b.jsx)(x.Provider,{value:t,children:e})};export{S as n,m as r,C as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.