1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6712],{62179:(e,t,r)=>{r.d(t,{A:()=>f,AuthProvider:()=>m});var a=r(11974),i=r(17094),s=r(86015),l=r(84956),n=r(2723),o=r(96418),u=r(5130),c=r(43714);let d=(0,i.createContext)(void 0);async function h(){let e=1e3;for(let t=0;t<5;t++)try{return await u.authApi.getCurrentUser()}catch(r){if(r instanceof u.ApiError&&401===r.status||4===t)throw r;await new Promise(t=>setTimeout(t,e)),e=Math.min(2*e,8e3)}throw Error("Unreachable")}function m(e){let{children:t}=e,[r,m]=(0,i.useState)(null),[f,p]=(0,i.useState)(null),[g,w]=(0,i.useState)(!0),[v,y]=(0,i.useState)(!1),x=(0,s.useRouter)(),b=(0,i.useRef)(!1),k=(0,i.useCallback)(e=>{b.current=e},[]),_=!!r&&!!f;(0,i.useEffect)(()=>{let e=(0,l.hg)(n.e,async e=>{if(p(e),e){if(!r&&!b.current)try{let e=await h();e&&(m(e),y(!1))}catch(e){c.dh.error("Failed to hydrate user data:",e),e instanceof u.ApiError&&401===e.status?(await n.auth.signOut(),m(null)):y(!0)}}else m(null);w(!1)});return()=>e()},[r]);let S=async(e,t)=>{try{await n.auth.signIn(e,t);let r=await u.authApi.getCurrentUser();if(!["company_user","agency_user","super_user"].includes(r.user_type))throw await n.auth.signOut(),new u.ApiError(401,"Invalid credentials");m(r),x.push("/")}catch(e){throw c.dh.error("Login failed:",e),e}},A=(0,i.useCallback)(async e=>{o.oR.dismiss();let t=e?"/login?reason=".concat(e):"/login";try{await n.auth.signOut(),m(null),p(null),y(!1),x.push(t)}catch(e){c.dh.error("Logout failed:",e),m(null),p(null),y(!1),x.push(t)}},[x]),C=(0,i.useCallback)(async()=>{if(!f)return void A();y(!1),w(!0);try{let e=await h();m(e)}catch(e){c.dh.error("Retry hydration failed:",e),e instanceof u.ApiError&&401===e.status?(await n.auth.signOut(),m(null)):y(!0)}w(!1)},[f,A]),E=async()=>{try{if(!f)return void A();await f.getIdToken(!0);let e=await u.authApi.getCurrentUser();m(e)}catch(e){c.dh.error("Failed to refresh user:",e),e instanceof u.ApiError&&401===e.status&&A()}};(0,i.useEffect)(()=>{let e=()=>{c.dh.debug("Received auth:logout event â session expired"),A()};return window.addEventListener("auth:logout",e),()=>window.removeEventListener("auth:logout",e)},[A]);let j=(0,i.useCallback)(e=>{m(e)},[]);return(0,a.jsx)(d.Provider,{value:{user:r,isLoading:g,isAuthenticated:_,hydrationError:v,login:S,logout:A,refreshUser:E,retryHydration:C,setUserData:j,suppressHydration:k},children:t})}function f(){let e=(0,i.useContext)(d);if(void 0===e)throw Error("useAuth must be used within an AuthProvider");return e}},83597:(e,t,r)=>{r.d(t,{L:()=>l});var a=r(11974);r(17094);var i=r(84707),s=r(84931);function l(e){let{currentStep:t,totalSteps:r,stepLabels:l=[]}=e;return(0,a.jsx)("nav",{className:"w-full","aria-label":"Wizard progress",children:(0,a.jsxs)("div",{className:"relative flex items-center justify-between",role:"list",children:[(0,a.jsx)("div",{className:"absolute top-5 left-0 right-0 h-0.5 bg-muted"}),(0,a.jsx)("div",{className:"absolute top-5 left-0 h-0.5 bg-gradient-to-r from-primary to-primary/80 transition-all duration-500 ease-out",style:{width:r>1?"".concat((Math.max(1,Math.min(t,r))-1)/(r-1)*100,"%"):"0%"}}),Array.from({length:r},(e,r)=>{let n=r+1,o=n<t,u=n===t,c=l[r];return(0,a.jsxs)("div",{className:"relative flex flex-col items-center",children:[(0,a.jsx)("div",{role:"listitem","aria-label":"Step ".concat(n).concat(c?": ".concat(c):"").
1concat(o?" (completed)":u?" (current)":""),"aria-current":u?"step":void 0,className:(0,s.cn)("relative z-10 w-10 h-10 rounded-full flex items-center justify-center","border-2 transition-all duration-300 bg-background",o&&"border-primary bg-primary text-primary-foreground",u&&"border-primary text-primary ring-4 ring-primary/20",!o&&!u&&"border-muted text-muted-foreground"),children:o?(0,a.jsx)(i.A,{className:"w-5 h-5 animate-in zoom-in duration-300"}):(0,a.jsx)("span",{className:"text-sm font-semibold",children:n})}),c&&(0,a.jsx)("span",{className:(0,s.cn)("hidden sm:block mt-2 text-xs font-medium text-center whitespace-nowrap","transition-colors duration-300",u&&"text-primary font-semibold",o&&"text-foreground",!o&&!u&&"text-muted-foreground"),children:c})]},n)})]})})}},92028:(e,t,r)=>{r.d(t,{$:()=>d,h:()=>h});var a=r(11974),i=r(17094),s=r(5130),l=r(43714),n=r(62179);let o="nudg3_selected_workspace_id",u=(0,i.createContext)(void 0);function c(e){let t=e.filter(e=>e.is_active);if(0===t.length)return;let r=t.map(e=>{var t;let r=0,a=null==(t=e.subscription_status)?void 0:t.toLowerCase();return"active"===a?r=3:e.is_trial?r=2:("expired"===a||"cancelled"===a)&&(r=1),{workspace:e,score:r}});return r.sort((e,t)=>t.score-e.score),r[0].workspace}function d(e){let{children:t,skipAutoLoad:r=!1}=e,[d,h]=(0,i.useState)([]),[m,f]=(0,i.useState)(null),[p,g]=(0,i.useState)(!1),[w,v]=(0,i.useState)(!1),[y,x]=(0,i.useState)(null),{isAuthenticated:b,user:k}=(0,n.A)(),_=(0,i.useRef)(!1),S=(0,i.useCallback)(e=>{f(e),e?localStorage.setItem(o,e.id):localStorage.removeItem(o)},[]),A=(0,i.useCallback)(async()=>{try{g(!0),x(null);let e=(await s.companyApi.getWorkspaces({include_inactive:!1,limit:100})).items;h(e);let t=localStorage.getItem(o);if(t){let r=e.find(e=>e.id===t);if(r)_.current&&(_.current=!1),S(r);else{localStorage.removeItem(o);let t=c(e);t&&S(t)}}else{let t=c(e);t&&S(t)}}catch(e){l.r8.error("Failed to load workspaces:",e),e instanceof s.ApiError?x(e.message):x("Failed to load workspaces")}finally{g(!1),v(!0)}},[S]);(0,i.useEffect)(()=>{!r&&(b&&k?p||w||A():b||(h([]),S(null),v(!1),localStorage.removeItem(o)))},[r,b,k,p,w,A,S]);let C=(0,i.useCallback)(async e=>{e&&(localStorage.setItem(o,e),_.current=!0),await A()},[A]),E=!!((null==m?void 0:m.is_pitch)||(null==m?void 0:m.pitch_locked_at));return(0,i.useEffect)(()=>{sessionStorage.setItem("is_pitch_workspace",String(E))},[E]),(0,a.jsx)(u.Provider,{value:{workspaces:d,selectedWorkspace:m,isPitchWorkspace:E,isLoading:p,hasLoadedOnce:w,error:y,setSelectedWorkspace:S,refreshWorkspaces:C},children:t})}function h(){let e=(0,i.useContext)(u);if(void 0===e)throw Error("useWorkspace must be used within a WorkspaceProvider");return e}}}]);
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.