Files
web-alterflixhub/assets/auth-client.js
T
Bkk1234 e6c4ebff48 chore(publish): replace source tree with static export at repo root
Publish the prerendered static export (index.html, 404.html, cinema/,
c/, about/, for-cinemas/, for-film-lovers/, assets/, images/, og/,
sitemap.xml, robots.txt) as the site root and remove the React Router
+ Nitro source tree from this branch. Source remains available in
history at 0548772.

Note: public/sw.js here reports VERSION v2.0.5 while the removed source
tree (v2.1.0) was newer, and .gitignore was not carried over.
2026-11-22 22:24:36 +07:00

2 lines
59 KiB
JavaScript

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderer-DbxObHo0.js","assets/preload-helper-CZgWQFsJ.js","assets/analytics-hbCOwHmS.js","assets/react-B8IZ02wI.js","assets/api-path-DiLUeLL2.js","assets/optional-peer-BHoJSOIB.js","assets/session-replay-endpoint-CkXvYk-L.js"])))=>i.map(i=>d[i]);
import{i as e,t}from"./react-B8IZ02wI.js";import{D as n,b as r,i,t as a,x as o,y as s}from"./api-path-DiLUeLL2.js";import{t as c}from"./client-BXMKfmWK.js";import{t as l}from"./preload-helper-CZgWQFsJ.js";import{t as ee}from"./jsx-runtime-fBfwind-.js";import{a as u,g as d,h as f,i as p,n as te}from"./analytics-hbCOwHmS.js";import{c as m,d as h,u as g}from"./session-replay-endpoint-CkXvYk-L.js";import{o as _,t as ne}from"./use-session-DJs-YY25.js";import{t as v}from"./createReactComponent-C-DRqPhY.js";var y=v(`outline`,`loader-2`,`Loader2`,[[`path`,{d:`M12 3a9 9 0 1 0 9 9`,key:`svg-0`}]]),re=c();function b(e,t){return!t||e.status===429||e.status>=500}function x(e=typeof navigator>`u`?``:navigator.userAgent){return/AgentNativeDesktop/i.test(e)}function ie(e,t){let n=t.origin??(typeof window>`u`?`http://agent-native.local`:window.location.origin),r=new URL(n),i=new URL(e||`/`,r);if(i.origin!==r.origin)throw TypeError(`Identity callback target must be same-origin`);let a=`${i.pathname}${i.search}${i.hash}`;if(!t.enabled||x(t.userAgent))return a;let o=new URL(t.bootstrapPath,n);return o.searchParams.set(`return`,a),`${o.pathname}${o.search}`}function ae(e=typeof navigator>`u`?``:navigator.userAgent){return e.includes(`Electron`)}function oe(e=typeof navigator>`u`?``:navigator.userAgent){return ae(e)&&!x(e)}function se(e,t=typeof window>`u`?`http://agent-native.local`:window.location.origin){try{let n=new URL(e||`/`,t),r=n.pathname||`/`;if(r===`/dispatch/dispatch`)r=`/dispatch`;else if(r.startsWith(`/dispatch/`)){let e=r.slice(10),t=e.split(`/`)[0];t===`dispatch`?r=`/dispatch`+e.slice(t.length):t&&!new Set([`overview`,`apps`,`settings`,`admin`,`metrics`,`vault`,`integrations`,`messaging`,`workspace`,`agents`,`destinations`,`identities`,`approvals`,`audit`,`team`,`thread-debug`,`new-app`]).has(t)&&(r=`/`+e)}return r+n.search+n.hash}catch{return e||`/`}}function ce(){return typeof window>`u`?``:new URL(a(`/_agent-native/oauth/popup`),window.location.href).href}function le({initialUrl:e,features:t}={}){if(typeof window>`u`)return null;let n=new URL(e||ce(),window.location.href);return n.protocol!==`http:`&&n.protocol!==`https:`?null:window.open(n.href,`_blank`,t)}var ue=`alpha`,de={clips:`alpha`,design:`alpha`,slides:`alpha`};function fe(e){return e?de[e.trim().toLowerCase()]??`alpha`:ue}var S={twoFactorTitle:`Two-step verification`,twoFactorSubtitle:`Enter the six-digit code from your authenticator app.`,twoFactorCodeLabel:`Authentication code`,twoFactorCodePlaceholder:`000000`,twoFactorVerify:`Verify code`,twoFactorVerifying:`Verifying...`,twoFactorInvalid:`That code is invalid or expired. Try again.`,twoFactorBack:`Back to sign in`};({...S}),{...S},{...S},{...S},{...S},{...S},{...S},{...S},{...S},{...S},{...S};var C=ee(),w=e(t(),1);function pe({id:e,fields:t,submitLabel:n,className:r,onSubmit:i,submitProps:a,footer:o,messageId:s,message:c,messageClassName:l=`msg`}){let{children:ee,className:u,type:d,...f}=a??{};return(0,C.jsxs)(`form`,{id:e,className:r?`form ${r}`:`form`,onSubmit:i,children:[t.map(e=>(0,C.jsxs)(w.Fragment,{children:[(0,C.jsx)(`label`,{...e.labelProps,htmlFor:e.id,children:e.label}),(0,C.jsx)(`input`,{...e.inputProps,id:e.id})]},e.id)),(0,C.jsx)(`button`,{...f,type:`submit`,className:u,children:n}),o,s?(0,C.jsx)(`p`,{className:l,id:s,children:c}):null]})}var T={fg:[.682,.678,.671],bg:[.039,.039,.039]},me={fg:`#aeadac`,bg:`#0a0a0a`},he={fg:`#00677f`,bg:`#faf9f5`};function ge(e){let t=e.trim().replace(`#`,``);if(!/^[0-9a-fA-F]{6}$/.test(t))return null;let n=Number.parseInt(t,16);return[E((n>>16&255)/255),E((n>>8&255)/255),E((n&255)/255)]}function E(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function _e(e,{matchPageSurface:t=!1}={}){let n=getComputedStyle(e),r=ge(n.getPropertyValue(`--b-hero-shader-fg`)),i=ge(n.getPropertyValue(`--b-bg-page`)),a=r&&i?{fg:r,bg:i}:null,o=document.documentElement,s=o.classList.contains(`dark`)||!o.classList.contains(`light`)&&o.getAttribute(`data-theme`)===`dark`?me:he,c=ge(s.fg)??T.fg,l=ge(s.bg)??T.bg,ee=t?ve(e):null;return{fg:a?.fg??c,bg:ee??a?.bg??l}}function ve(e){for(let t=e.parentElement;t;t=t.parentElement){let e=getComputedStyle(t).backgroundColor.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:\s*[,/]\s*([\d.]+))?\s*\)$/i);if(!(!e||e[4]!==void 0&&Number(e[4])!==1))return[E(Number(e[1])/255),E(Number(e[2])/255),E(Number(e[3])/255)]}return null}var ye=700,be=3e4,xe=6e3;function D({onError:e,onReady:t,frameRate:n=30,className:r=`absolute inset-0 z-[-1]`,matchPageSurface:i=!1}){let a=(0,w.useRef)(null),o=(0,w.useRef)(null),[s,c]=(0,w.useState)(!1),ee=(0,w.useRef)(e),u=(0,w.useRef)(t);ee.current=e,u.current=t,(0,w.useEffect)(()=>{let e=a.current,t=o.current;if(!e||!t)return;let r,s=!1,d=!1,f=[],p,te,m=xe,h=!1,g=()=>{p!==void 0&&(window.clearTimeout(p),p=void 0,m=Math.max(0,m-(Date.now()-(te??Date.now()))),te=void 0)},_=()=>{s||d||!h||document.hidden||p!==void 0||(te=Date.now(),p=window.setTimeout(()=>y(Error(`The ocean wave did not draw a frame`)),m))},ne=()=>{h=!1,g()},v=window.setTimeout(()=>{y(Error(`The ocean wave renderer did not initialize`))},be);f.push(()=>{window.clearTimeout(v),ne()});let y=e=>{s||d||(d=!0,window.clearTimeout(v),ne(),r?.dispose(),ee.current(e))},re=()=>{document.hidden?g():_()};document.addEventListener(`visibilitychange`,re),f.push(()=>document.removeEventListener(`visibilitychange`,re));let b=[0,0,0],x,ie=(t,n)=>{let i=e.getBoundingClientRect();if(i.width<=0||i.height<=0)return;let a=t-i.left,o=n-i.top,s=a>=0&&a<=i.width&&o>=0&&o<=i.height;b=[a/i.width*2-1,1-o/i.height*2,+!!s],r?.setPointer(b)},ae=e=>{x=[e.clientX,e.clientY],ie(e.clientX,e.clientY)},oe=()=>{x&&ie(x[0],x[1])},se=()=>{x=void 0,b=[b[0],b[1],0],r?.setPointer(b)};return document.body.addEventListener(`mousemove`,ae,{passive:!0}),document.body.addEventListener(`mouseleave`,se,{passive:!0}),window.addEventListener(`scroll`,oe,{passive:!0}),window.addEventListener(`blur`,se),f.push(()=>{document.body.removeEventListener(`mousemove`,ae),document.body.removeEventListener(`mouseleave`,se),window.removeEventListener(`scroll`,oe),window.removeEventListener(`blur`,se)}),l(async()=>{let{createRenderer:e}=await import(`./renderer-DbxObHo0.js`);return{createRenderer:e}},__vite__mapDeps([0,1])).then(({createRenderer:a})=>{if(s||d)return;r=a({canvas:t,colors:_e(e,{matchPageSurface:i}),fps:n,onError:y}),r.setPointer(b),r.ready.then(()=>{if(!(s||d))return window.clearTimeout(v),h=!0,_(),r?.firstFrame}).then(()=>{s||d||(ne(),c(!0),u.current())}).catch(y);let o=new MutationObserver(()=>{r?.setColors(_e(e,{matchPageSurface:i}))});o.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`data-theme`]}),f.push(()=>o.disconnect());let l=new IntersectionObserver(([e])=>r?.setPaused(!(e?.isIntersecting??!0)),{threshold:0});l.observe(e),f.push(()=>l.disconnect())}).catch(e=>{y(e)}),()=>{s=!0;for(let e of f)e();r?.dispose()}},[n,i]);let d=`linear-gradient(to bottom, #000 62%, transparent 100%)`;return(0,C.jsx)(`div`,{ref:a,"aria-hidden":`true`,"data-agent-native-wave":`true`,className:r,style:{opacity:s?.3:0,transition:`opacity ${ye}ms ease-out`,maskImage:d,WebkitMaskImage:d},children:(0,C.jsx)(`canvas`,{ref:o,className:`block h-full w-full`,style:{display:`block`,height:`100%`,width:`100%`}})})}async function Se(){let e=navigator.gpu;if(!e||typeof e.requestAdapter!=`function`)return`unsupported`;try{return await e.requestAdapter()?`supported`:`unsupported`}catch{return`probe-failed`}}function Ce({className:e=``,matchPageSurface:t=!1}){let[n,r]=(0,w.useState)(`probing`);(0,w.useEffect)(()=>{let e=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),t=!1,n=0,i=async()=>{let i=++n;if(e?.matches){r(`empty`);return}r(`probing`);try{let e=await Se();if(t||i!==n)return;if(e===`supported`){r(`ocean-loading`);return}e===`probe-failed`&&console.error(`Could not check WebGPU support for the wave background`),r(`empty`)}catch(e){if(t||i!==n)return;console.error(`Could not check WebGPU support for the wave background`,e),r(`empty`)}},a=()=>{i()};return i(),e?.addEventListener(`change`,a),()=>{t=!0,e?.removeEventListener(`change`,a)}},[]);let i=(0,w.useCallback)(e=>{console.error(`Could not start the ocean wave background`,e),r(`empty`)},[]),a=(0,w.useCallback)(()=>r(`ocean`),[]);return n!==`ocean-loading`&&n!==`ocean`?null:(0,C.jsx)(D,{className:e,matchPageSurface:t,onError:i,onReady:a})}var we=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Te=`an.onboarding.tab`,Ee=`an.onboarding.pendingSignupEmail`,De=`/_agent-native/google/auth-url`,Oe=`http://127.0.0.1:8080`,ke=typeof window>`u`?w.useEffect:w.useLayoutEffect;function Ae(e){let t=new URLSearchParams(e);if(r(t.get(`error`)))return!0;let n=s(t.get(`c`));return n?r(new URL(n,`https://agent-native.invalid`).searchParams.get(`error`)):!1}function O(e){return e.trim().toLowerCase()}function k(e){return we.test(O(e))}function je(e,t,n,r){return e[n]?.[r]??e[t]?.[r]??r}function Me(e,t,n){return!e||e===`system`?n:_(e,t.map(e=>e.value))??n}function Ne(e,t){if(typeof navigator>`u`)return t;let n=navigator.languages?.length?navigator.languages:[navigator.language];for(let r of n){let n=Me(r,e,t);if(n!==t||r?.startsWith(t))return n}return t}function Pe(e){let t=e.split(`/`).find(Boolean);return!t||[`_agent-native`,`api`,`sign-in`,`login`,`signup`].includes(t)?``:`/${t}`}function Fe(e,t,n){return e||!t?e:Pe(n)}function Ie(e){try{return window.localStorage.getItem(e)??``}catch{return``}}function Le(e,t){try{window.localStorage.setItem(e,t)}catch{}}function Re(e){try{window.localStorage.removeItem(e)}catch{}}function A(e,t,n=t){if(e.code===`INVITE_ONLY`||e.error===`INVITE_ONLY`)return n;let r=e.error??e.message;if(typeof r!=`string`||!r.trim())return t;let i=r.trim();return/failed query|\bselect\b.*\bfrom\b|\binsert\b.*\binto\b|\bupdate\b.*\bset\b|\bdelete\b.*\bfrom\b|\bsql\b|database|relation .* does not exist|column .* does not exist|syntax error|constraint|connection refused|econn|timeout/i.test(i)?t:i}function ze(e,t,n){return e.ok&&e.status===200&&n&&t.error===`Not authenticated`}function Be(e,t){return e.ok&&typeof t.email==`string`&&!t.error}async function j(e,t={}){let n=new Headers(t.headers);if(typeof window<`u`){let t=new URL(e,window.location.href),r=u();t.origin===window.location.origin&&r&&/^[!-~]{1,127}$/.test(r)&&n.set(`X-Agent-Native-Session-Id`,r)}let r=await fetch(e,{credentials:`include`,...t,headers:n}),i={},a=!1;try{let e=await r.json();e&&typeof e==`object`&&!Array.isArray(e)&&(i=e,a=!0)}catch{}return{response:r,data:i,readable:a}}function Ve(e,t,n={},r){if(!(!k(r)||f(r))&&!g(window.__AGENT_NATIVE_SYNTHETIC_TRAFFIC__))try{let r=window.__AGENT_NATIVE_CONFIG__;if(!r?.agentNativeAnalyticsPublicKey)return;let i=u(),a=new Date().toISOString(),o=h(r.agentNativeAnalyticsEndpoint??`https://analytics.agent-native.com/track`,window.location.hostname),s={app:e,...n},c=[{name:t,properties:s}],l=d(t,s);l&&c.push(l);let ee=r.agentNativeAnalyticsPublicKey;m(e=>{let t=e?p():void 0;for(let n of c){let r=JSON.stringify({publicKey:ee,event:n.name,properties:t?n.properties:{...n.properties,analytics_consent:e?`withheld`:`unknown`},anonymousId:t,sessionId:i,timestamp:a});navigator.sendBeacon?.(o,r)||fetch(o,{method:`POST`,body:r,keepalive:!0,headers:{"Content-Type":`text/plain;charset=UTF-8`}}).catch(()=>void 0)}})}catch{}}function He(){if(typeof window>`u`)return!1;let e=window.location.hostname.toLowerCase();return e===`localhost`||e===`::1`||e===`127.0.0.1`||e.startsWith(`127.`)}function Ue(){if(typeof window>`u`)return!1;let e=window.location.hostname.toLowerCase();return e.endsWith(`.builderio.xyz`)||e.endsWith(`.builderio.dev`)||e.endsWith(`.builder.codes`)||e.endsWith(`.builder.my`)}function We(){try{let e=new URLSearchParams(window.location.search);if(e.has(`builder.preview`)||e.has(`builder.frameEditing`)||e.has(`__builder_editing__`))return window.sessionStorage.setItem(`__an_builder_preview_seen`,`1`),!0;if(window.sessionStorage.getItem(`__an_builder_preview_seen`)===`1`)return!0}catch{}let e=document.referrer;return/builder\.io|builder\.my|builderio\.xyz|builderio\.dev|builder\.codes/i.test(e)}function Ge(e){if(!e.identitySsoAuto||!e.publicOAuthOrigin)return!1;try{return new URL(e.publicOAuthOrigin).origin===new URL(e.currentOrigin).origin}catch{return!1}}function Ke(){try{return window.self!==window.top}catch{return!0}}function M(e,t=typeof window>`u`?``:window.location.origin){if(!e)return``;try{let n=new URL(e).origin;return n===t?``:n}catch{return``}}function N(){if(typeof window>`u`)return``;let e=[window.location.href,document.referrer];try{if(window.location.ancestorOrigins)for(let t of window.location.ancestorOrigins)e.push(t)}catch{}for(let t of e)try{let e=new URL(t),n=e.hostname.toLowerCase(),r=n===`builderio.xyz`||n.endsWith(`.builderio.xyz`)||n===`builderio.dev`||n.endsWith(`.builderio.dev`)||n===`builder.codes`||n.endsWith(`.builder.codes`)||n===`builder.my`||n.endsWith(`.builder.my`);if(e.protocol===`https:`&&r)return e.origin}catch{}return``}function qe(e){return e.previewOrigin||e.workspaceGatewayReturnOrigin||(x(e.userAgent)||oe(e.userAgent)?Oe:``)}function Je(e,t,n=typeof navigator>`u`?``:navigator.userAgent){let r=se(e),i=qe({previewOrigin:N(),workspaceGatewayReturnOrigin:t,userAgent:n});return i?i+r:r}function Ye(e){let t=e.builderPreview?M(e.publicOAuthOrigin,e.currentOrigin):``;return t?`${t}${De}`:`${e.runtimeAppBasePath}${De}`}function Xe(e){if(!e.googleViaIdentitySso)return!1;try{let t=new URL(e.currentOrigin);return t.protocol===`https:`&&/^[a-f0-9]{24}--agent-native-[a-z0-9-]+\.netlify\.app$/.test(t.hostname)}catch{return!1}}function Ze(){try{if(typeof crypto.randomUUID==`function`)return crypto.randomUUID()}catch{}return`agent-native-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Qe(){try{if(typeof crypto.randomUUID==`function`)return crypto.randomUUID()+crypto.randomUUID();if(typeof crypto.getRandomValues==`function`){let e=new Uint8Array(32);crypto.getRandomValues(e);let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}}catch{return``}return``}var $e={blue:`#4285F4`,green:`#34A853`,yellow:`#FBBC05`,red:`#EA4335`};function et(){return w.createElement(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`},w.createElement(`path`,{fill:$e.blue,d:`M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z`}),w.createElement(`path`,{fill:$e.green,d:`M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z`}),w.createElement(`path`,{fill:$e.yellow,d:`M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z`}),w.createElement(`path`,{fill:$e.red,d:`M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z`}))}function tt(e){return e===`login`?{heading:`welcomeBackTitle`,subtitle:`signInSubtitle`}:e===`forgot`?{heading:`resetPasswordTitle`,subtitle:`resetPasswordSubtitle`}:e===`twoFactor`?{heading:`twoFactorTitle`,subtitle:`twoFactorSubtitle`}:e===`verification`?{heading:`checkEmailTitle`,subtitle:`finishAccountSubtitle`}:e===`googleOnly`?{heading:`signInTitle`,subtitle:`googleOnlySubtitle`}:e===`magicLinkSent`?{heading:`magicLinkSent`,subtitle:`magicLinkSentCopy`}:e===`magicLink`?{heading:`magicLinkTitle`,subtitle:`magicLinkSubtitle`}:{heading:`welcomeTitle`,subtitle:`createAccountSubtitle`}}function nt(e,t){return e===`signup`&&t}function rt(e,t){let n=new URLSearchParams(t),r=e.replace(/\/+$/,``)||`/`;return!n.has(`tab`)&&!n.has(`verified`)&&!Ae(t)&&!r.endsWith(`/login`)&&!r.endsWith(`/signup`)}function P(e){let{authMode:t,googleOnly:a,initialPrompt:s,appBasePath:c,homePath:l,initialResumeHref:ee,workspaceRuntime:u,trackingApp:d,defaultLocale:f,localeStorageKey:m,locales:h,localeMetadata:g,localeOptions:_,marketing:v,marketingLocales:re,brandMarkSrc:ae,brandMarkLightSrc:oe,githubUrl:se,appName:ce,showGoogle:ue,organizationSsoEnabled:de=!1,googleViaIdentitySso:S=!1,signupLegalNotice:C,signupLocalModeNote:T,docsAuthUrl:me,identitySsoEnabled:he=!1,identitySsoAuto:ge=!1,publicOAuthOrigin:E,workspaceGatewayReturnOrigin:_e,googleAuthMode:ve,builderPreviewLocalDevEnabled:ye}=e,[be,xe]=w.useState(`system`),[D,Se]=w.useState(f),[we,De]=w.useState(!1);w.useEffect(()=>De(!0),[]);let[Oe,Pe]=w.useState(!1),[M,N]=w.useState(e.initialView),[qe,$e]=w.useState({}),[P,F]=w.useState(null),[it,at]=w.useState(!1),[ot,st]=w.useState(!1),[ct,I]=w.useState(!0),[lt,ut]=w.useState(!1),[L,dt]=w.useState(``),[ft,pt]=w.useState(``),[mt,R]=w.useState(``),[ht,gt]=w.useState(``),[_t,vt]=w.useState(``),[yt,bt]=w.useState(``),[xt,St]=w.useState(``),[Ct,wt]=w.useState(``),[Tt,Et]=w.useState(!1),[Dt,Ot]=w.useState(``),[kt,At]=w.useState(0),[jt,Mt]=w.useState(0),Nt=w.useCallback(()=>{At(0),Mt(e=>e===0?e:Date.now())},[]),[Pt,z]=w.useState(!1),[Ft,It]=w.useState(!1),[Lt,Rt]=w.useState(``),[zt,Bt]=w.useState(!1),[Vt,Ht]=w.useState(!1),Ut=w.useRef(!1),Wt=w.useRef(``),Gt=w.useRef(null),Kt=w.useRef(!1),qt=w.useRef(null),Jt=w.useRef(null),Yt=w.useRef(null),Xt=w.useRef(null),Zt=w.useRef(!1),Qt=w.useRef(null),$t=w.useRef(!1),en=w.useRef(!1),tn=w.useRef(!1),[nn,rn]=w.useState(!1),[an,on]=w.useState(!1),[B,sn]=w.useState(c),[V,cn]=w.useState(!!(c||!u));w.useEffect(()=>{sn(Fe(c,u,window.location.pathname)),cn(!0)},[c,u]);let H=w.useCallback(e=>je(h,f,D,e),[f,D,h]),U=w.useCallback(e=>`${B}${n(e,{publicPrefix:i()})}`,[B]),ln=w.useMemo(()=>U(`/_agent-native/identity/login`),[U]),un=w.useCallback(()=>o(typeof window>`u`||!we?{at:ee??`${B}/`,basePath:B,homePath:l}:{at:window.location.pathname+window.location.search+window.location.hash,continuation:new URLSearchParams(window.location.search).get(`c`),legacyReturn:new URLSearchParams(window.location.search).get(`return`),basePath:B,homePath:l}),[we,l,ee,B]),W=w.useCallback(()=>un().resumeHref,[un]),dn=w.useMemo(()=>`${ln}?${new URLSearchParams({return:W()}).toString()}`,[ln,W]),G=w.useCallback(e=>ie(e||W(),{enabled:he,bootstrapPath:U(`/_agent-native/identity/bootstrap`)}),[U,he,W]),K=w.useCallback(e=>{ne(G(e),`signed_in_app`)},[G]),q=w.useCallback((e,t)=>{$e(n=>({...n,[e]:t}))},[]),J=w.useCallback(e=>{let t=qe[e];return t?w.createElement(`p`,{className:`msg ${t.kind} show`,role:`status`,"aria-live":`polite`},t.text):null},[qe]),fn=w.useCallback((e,t)=>e.code===`DEPLOY_SETTINGS_REQUIRED`?H(`deploySettingsMissingError`):A(e,t,H(`signupInviteOnly`)),[H]),Y=w.useCallback(()=>`${Ee}:${B||`/`}`,[B]),pn=w.useCallback(e=>{e?Le(Y(),O(e)):Re(Y())},[Y]),X=w.useCallback(()=>{let e=Ie(Y());return k(e)?O(e):``},[Y]);w.useEffect(()=>{let e=Ie(m)||`system`,t=e===`system`?Ne(_,f):Me(e,_,f);xe(e),Se(t),document.documentElement.lang=t,document.documentElement.dir=g[t]?.dir||`ltr`,document.documentElement.dataset.locale=t},[f,g,_,m]),w.useEffect(()=>{let e=e=>{let t=e.target;t instanceof Node&&document.querySelector(`.locale-picker`)?.contains(t)||Pe(!1)},t=e=>{e.key===`Escape`&&Pe(!1)};return document.addEventListener(`click`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`keydown`,t)}},[]),w.useEffect(()=>{let e=ce?`${ce} — ${H(`pageTitleSignIn`)}`:H(`pageTitleWelcome`);document.title=e,document.documentElement.lang=D,document.documentElement.dir=g[D]?.dir||`ltr`,document.documentElement.dataset.locale=D},[ce,D,g,H]),w.useEffect(()=>{if(a)return;let e=window.location.pathname.replace(/\/+$/,``)||`/`,n=new URLSearchParams(window.location.search),r=Ae(window.location.search);if(n.get(`verified`)||r){N(`login`);let e=X();e&&vt(e),r&&q(`login`,{kind:`error`,text:H(`verificationLinkInvalid`)});return}if(n.get(`tab`)===`login`||e.endsWith(`/login`)){N(`login`);return}if(n.get(`tab`)===`signup`||e.endsWith(`/signup`)){N(`signup`);return}if(t===`magic-link`){N(`magicLink`);return}if(n.get(`c`)){N(`login`);return}let i=Ie(Te);(i===`login`||i===`signup`)&&N(i)},[t,a,X,q,H]),w.useEffect(()=>{V&&(async()=>{for(let e=0;e<3;e+=1){let t=!1;try{let{response:e,data:n,readable:i}=await j(U(`/_agent-native/auth/session`),{headers:{Accept:`application/json`},cache:`no-store`});if(Be(e,n)){r(new URLSearchParams(window.location.search).get(`error`))||K();return}if(ze(e,n,i)){on(!0);return}t=b(e,i)}catch{t=!0}if(!t||e===2)return;await new Promise(t=>window.setTimeout(t,250*(e+1)))}})().finally(()=>rn(!0))},[U,K,V]),w.useEffect(()=>{if(!Ge({identitySsoAuto:ge,publicOAuthOrigin:E,currentOrigin:window.location.origin})||!V||!nn||!an||x()||M!==`login`&&M!==`signup`)return;let e=new URLSearchParams(window.location.search);if(e.has(`sso`)||e.has(`error`)||e.has(`verified`))return;let t=new URLSearchParams({return:W(),prompt:`none`});ne(`${ln}?${t.toString()}`,`sso_probe`)},[ln,ge,E,W,V,an,nn,M]),w.useEffect(()=>{if(!V||M!==`magicLinkSent`)return;let e=!1,t=!1,n=async()=>{if(!(e||t||document.visibilityState===`hidden`)){t=!0;try{let{response:t,data:n}=await j(U(`/_agent-native/auth/session`),{headers:{Accept:`application/json`},cache:`no-store`});!e&&Be(t,n)&&K()}catch{}finally{t=!1}}},r=()=>{document.visibilityState===`visible`&&n()},i=window.setInterval(()=>void n(),1e3);return window.addEventListener(`focus`,r),document.addEventListener(`visibilitychange`,r),n(),()=>{e=!0,window.clearInterval(i),window.removeEventListener(`focus`,r),document.removeEventListener(`visibilitychange`,r)}},[U,K,V,M]),w.useEffect(()=>{if(p(),V){let e=new URLSearchParams(window.location.search),t=o({at:window.location.pathname,continuation:e.get(`c`),legacyReturn:e.get(`return`),basePath:B,homePath:l}).resumeHref;te({landingPath:new URL(t,window.location.origin).pathname})}let e=O(ft);M!==`signup`||Ut.current||!k(e)||(Ut.current=!0,Ve(d,`auth.signup_viewed`,{surface:`signup`,auth_mode:t,auth_view:M},e))},[t,l,B,V,ft,d,M]);let mn=w.useMemo(()=>He()||ye&&Ue(),[ye]);ke(()=>{!mn||tn.current||!rt(window.location.pathname,window.location.search)||(at(!0),I(!1))},[mn]),w.useEffect(()=>{if(!V||!mn)return;let e=!0;return(async()=>{try{let{response:t,data:n}=await j(U(`/_agent-native/auth/local-dev`),{method:`GET`,cache:`no-store`,headers:{Accept:`application/json`}});if(!e)return;let r=t.ok&&n.available===!0;if(at(r),!r){I(!0);return}if(tn.current){I(!0);return}let i=rt(window.location.pathname,window.location.search);I(e=>e||!i)}catch{e&&(at(!1),I(!0))}})(),()=>{e=!1}},[U,mn,V]),w.useEffect(()=>{let e=new URLSearchParams(window.location.search),t=e.get(`signin`)===`1`||e.get(`upgrade-from-local`)===`1`;t||=Ie(`an_migrate_from_local`)===`1`,ut(t)},[]),w.useEffect(()=>{if(window.parent===window)try{mn&&new URL(window.location.href).searchParams.get(e.betaForceQueryParam)===`true`&&window.sessionStorage.setItem(e.betaForceSessionStorageKey,`1`);let t=new URL(window.location.href),n=t.searchParams.get(e.betaOptOutQueryParam);if(n!==null){let r=Number(n);Number.isFinite(r)&&r>Date.now()&&window.localStorage.setItem(e.betaOptOutStorageKey,String(r)),t.searchParams.delete(e.betaOptOutQueryParam),window.history.replaceState(null,``,t.toString())}}catch{}},[mn,e]);let Z=w.useCallback(()=>{Gt.current!==null&&(window.clearInterval(Gt.current),Gt.current=null),qt.current!==null&&(window.clearInterval(qt.current),qt.current=null),Jt.current!==null&&(window.clearTimeout(Jt.current),Jt.current=null),Kt.current=!1},[]),hn=w.useCallback(()=>{Qt.current!==null&&(window.clearTimeout(Qt.current),Qt.current=null)},[]),Q=w.useCallback(()=>{hn(),Xt.current=null,Zt.current=!1},[hn]);w.useEffect(()=>Z,[Z]),w.useEffect(()=>{if(!x())return;let e=()=>{let e=Xt.current;!e||Zt.current||Gt.current===null||(hn(),Qt.current=window.setTimeout(()=>{Qt.current=null,!(e!==Xt.current||Zt.current||Gt.current===null)&&(Z(),Xt.current=null,Zt.current=!1,z(!1))},5e3))},t=()=>hn(),n=()=>{document.visibilityState===`visible`?e():t()};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,n),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,n),hn()}},[hn,Z]);let gn=w.useCallback((e,t)=>{if(Z(),Q(),z(!1),It(!1),We()&&t)try{let n=new URL(e,window.location.origin);n.searchParams.set(`_session`,t),window.location.replace(n.pathname+n.search+n.hash);return}catch{}K(e)},[K,Q,Z]),_n=w.useCallback((e,t,n,r,i,a)=>{let o=Date.now(),s=async()=>{if(!Kt.current){Kt.current=!0;try{let{data:i}=await j(`${U(`/_agent-native/auth/desktop-exchange`)}?flow_id=${encodeURIComponent(e)}`,{headers:n?{"X-Agent-Native-Desktop-Verifier":n}:void 0});if(e!==Yt.current)return;if(typeof i.email==`string`||typeof i.token==`string`){a?.(typeof i.email==`string`?i.email:void 0),gn(t,typeof i.token==`string`?i.token:void 0);return}if(i.error){Z(),Q(),z(!1),It(!1),r===`magic-link`&&N(`magicLink`),q(r,{kind:`error`,text:A(i,H(r===`magic-link`?`magicLinkFailed`:`googleNotConfigured`),H(`signupInviteOnly`))});return}}catch{}finally{Kt.current=!1}Date.now()-o>300*1e3&&(Z(),Q(),z(!1),It(!1),r===`magic-link`&&N(`magicLink`),q(r,{kind:`error`,text:H(r===`magic-link`?`magicLinkFailed`:`googleNeverFinished`)}))}};Z(),Gt.current=window.setInterval(()=>void s(),1e3),i&&(qt.current=window.setInterval(()=>{let n=!1;try{n=i.closed}catch{n=!0}n&&(qt.current!==null&&(window.clearInterval(qt.current),qt.current=null),Jt.current=window.setTimeout(()=>{Jt.current=null,e===Yt.current&&j(U(`/_agent-native/auth/session`),{headers:{Accept:`application/json`}}).then(({response:n,data:r})=>{if(e===Yt.current){if(n.ok&&typeof r.email==`string`&&!r.error){a?.(r.email),gn(t);return}z(!1)}}).catch(()=>{e===Yt.current&&z(!1)})},5e3))},500)),window.setTimeout(()=>void s(),500)},[U,gn,q,Q,Z,H]),vn=w.useCallback(()=>{if(We())return Ke()?`popup`:`redirect`;let e=new URLSearchParams(window.location.search).get(`authMode`);return e===`popup`||e===`redirect`?e:ve===`popup`||ve===`redirect`?ve:x()?`redirect`:`popup`},[ve]),yn=w.useCallback(()=>Ye({builderPreview:We(),currentOrigin:window.location.origin,publicOAuthOrigin:E,runtimeAppBasePath:B}),[E,B]),bn=w.useCallback(async()=>{if(!ue||Pt)return;z(!0),q(`google`,null);try{window.sessionStorage.setItem(`__an_signin`,`1`)}catch{}let e=W();if(!We()&&!x()&&Xe({googleViaIdentitySso:S,currentOrigin:window.location.origin})){let t=new URLSearchParams({return:e});window.location.replace(`${ln}?${t.toString()}`);return}let t=Ze();Yt.current=t;let n=vn(),r=n===`redirect`&&x(),i=Je(n===`redirect`&&!r?G(e):e,_e);r?(Q(),Xt.current=t,Zt.current=!0):Q();let a=yn();if(n===`redirect`&&!r){let e=new URLSearchParams({return:i,redirect:`1`});window.location.replace(`${a}?${e.toString()}`);return}let o=Qe();if(!o){Q(),z(!1),q(`google`,{kind:`error`,text:H(`failedToConnect`)});return}let s=null;if(n===`popup`){let e=Ke();try{if(s=le({initialUrl:new URL(U(`/_agent-native/oauth/popup`),window.location.origin).href,features:`width=640,height=760`}),!s){if(e){z(!1),q(`google`,{kind:`error`,text:H(`googlePopupHelp`)});return}let t=new URLSearchParams({return:i,redirect:`1`});window.location.replace(`${a}?${t.toString()}`);return}try{s.opener=null}catch{}}catch{if(e){z(!1),q(`google`,{kind:`error`,text:H(`googlePopupHelp`)});return}let t=new URLSearchParams({return:i,redirect:`1`});window.location.replace(`${a}?${t.toString()}`);return}}try{let{response:n,data:c}=await j(`${a}?${new URLSearchParams({return:i,desktop:`1`,flow_id:t}).toString()}`,{method:`POST`,headers:{Accept:`application/json`,"X-Agent-Native-Desktop-Verifier":o}});if(!n.ok||typeof c.url!=`string`||!c.url)throw Error(A(c,H(`failedToConnect`),H(`signupInviteOnly`)));r&&(Zt.current=!1),_n(t,e,o,`google`,s,e=>{e&&Ve(d,M===`login`?`auth.login_clicked`:`auth.signup_clicked`,{surface:M===`login`?`login`:`signup`,method:`google`,auth_view:M},e)}),s?s.location.href=c.url:window.location.href=c.url}catch{try{s?.close()}catch{}Q(),z(!1),q(`google`,{kind:`error`,text:H(`failedToConnect`)})}},[U,yn,Pt,ln,G,S,vn,W,q,ue,_n,Q,H,d,M,_e]),xn=w.useCallback(async()=>{if(!ot){st(!0),q(`local-dev`,null);try{let{response:e}=await j(U(`/_agent-native/auth/local-dev`),{method:`POST`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(`local-dev-auth-failed`);K()}catch{st(!1),at(!1),I(!0),q(`local-dev`,{kind:`error`,text:H(`localDevFailed`)})}}},[U,ot,K,q,H]),Sn=w.useCallback((e,t)=>{let n=O(e);Wt.current=t,Nt(),Ot(n),pn(n),q(`verification`,null),tn.current=!0,I(!0),N(`verification`),Le(Te,`signup`)},[Nt,pn,q]),Cn=w.useCallback(async()=>{let e=Dt||X(),t=Wt.current;if(!e||!t)return{ok:!1,needsManualSignIn:!0};let{response:n,data:r}=await j(U(`/_agent-native/auth/login`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:e,password:t})});if(n.ok)return Re(Y()),K(),{ok:!0,needsManualSignIn:!1};let i=A(r,H(`finishSignInFailed`),H(`signupInviteOnly`));return{ok:!1,needsManualSignIn:!1,error:i,isWaitingForVerification:/not verified|verification/i.test(i)}},[U,Y,X,K,H,Dt]),wn=w.useCallback(async e=>{if(!$t.current){$t.current=!0,q(`verification`,{kind:`success`,text:H(`checkingVerification`)});try{let{response:t,data:n}=await j(U(`/_agent-native/auth/session`),{headers:{Accept:`application/json`}});if(t.ok&&typeof n.email==`string`&&!n.error){Re(Y()),K();return}let r=await Cn();if(r.ok)return;if(r.needsManualSignIn||!r.isWaitingForVerification){vt(Dt||X()),N(`login`),q(`login`,{kind:`success`,text:e||H(`enterPasswordAfterVerification`)});return}q(`verification`,{kind:`error`,text:e||H(`stillWaitingVerification`)})}catch{q(`verification`,{kind:`error`,text:H(`checkVerificationFailed`)})}finally{$t.current=!1}}},[U,Y,X,K,q,H,Cn,Dt]);w.useEffect(()=>{!V||a||en.current||new URLSearchParams(window.location.search).get(`verified`)===`1`&&(en.current=!0,q(`login`,{kind:`success`,text:H(`emailVerifiedFinishing`)}),wn(H(`emailVerifiedSignIn`)))},[wn,a,V,q,H]),w.useEffect(()=>{if(M!==`verification`)return;let e=()=>void wn();return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[wn,M]),w.useEffect(()=>{M!==`verification`&&Nt()},[Nt,M]),w.useEffect(()=>{if(!kt)return;let e=()=>{let e=Date.now();Mt(e),e>=kt&&At(0)};e();let t=window.setInterval(e,1e3);return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.clearInterval(t),window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[kt]);let Tn=kt>jt,En=w.useCallback(async e=>{e.preventDefault();let t=O(ft);if(!k(t)){q(`signup`,{kind:`error`,text:H(`invalidEmail`)});return}if(mt!==ht){q(`signup`,{kind:`error`,text:H(`passwordsMismatch`)});return}F(`signup`),q(`signup`,null),Ve(d,`auth.signup_clicked`,{surface:`signup`,method:`password`,auth_view:M},t);try{let{response:e,data:n}=await j(U(`/_agent-native/auth/register`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:t,password:mt,callbackURL:G(W())})});if(!e.ok){q(`signup`,{kind:`error`,text:fn(n,H(`registrationFailed`))});return}let r=await j(U(`/_agent-native/auth/login`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:t,password:mt})});if(r.response.ok){Re(Y()),q(`signup`,{kind:`success`,text:H(`accountCreatedSigningIn`)}),K();return}let i=fn(r.data,H(`registrationFailed`));if(r.response.status===403&&/not verified|verification/i.test(i)){Sn(t,mt);return}q(`signup`,{kind:`error`,text:i})}catch{q(`signup`,{kind:`error`,text:H(`networkErrorDashRetry`)})}finally{F(null)}},[fn,U,G,Y,K,W,q,Sn,ft,mt,ht,H,d,M]),Dn=w.useCallback(async e=>{e.preventDefault();let t=O(_t);if(!k(t)){q(`login`,{kind:`error`,text:H(`invalidEmail`)});return}F(`login`),q(`login`,null),Ve(d,`auth.login_clicked`,{surface:`login`,method:`password`,auth_view:M},t);try{let{response:e,data:n}=await j(U(`/_agent-native/auth/login`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:t,password:yt})});if(e.ok){if(n.twoFactorRedirect===!0){St(``),N(`twoFactor`);return}Re(Y()),K();return}q(`login`,{kind:`error`,text:fn(n,H(`invalidLogin`))})}catch{q(`login`,{kind:`error`,text:H(`networkErrorDashRetry`)})}finally{F(null)}},[fn,U,_t,yt,Y,K,q,H,d,M]),On=w.useCallback(async e=>{e.preventDefault();let t=xt.trim();if(!/^\d{6,8}$/.test(t)){q(`twoFactor`,{kind:`error`,text:H(`twoFactorInvalid`)});return}F(`twoFactor`),q(`twoFactor`,null);try{let{response:e,data:n}=await j(U(`/_agent-native/auth/two-factor/verify`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:t})});if(e.ok&&n.ok===!0){Re(Y()),K();return}q(`twoFactor`,{kind:`error`,text:A(n,H(`twoFactorInvalid`))})}catch{q(`twoFactor`,{kind:`error`,text:H(`networkErrorDashRetry`)})}finally{F(null)}},[U,Y,K,q,H,xt]),kn=w.useCallback(async e=>{e.preventDefault();let t=O(Ct);if(!k(t)){q(`forgot`,{kind:`error`,text:H(`invalidEmail`)});return}F(`forgot`),q(`forgot`,null);try{let{response:e,data:n}=await j(U(`/_agent-native/auth/ba/request-password-reset`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:t})});if(e.ok){Et(!0),q(`forgot`,{kind:`success`,text:H(`resetEmailSent`)});return}q(`forgot`,{kind:`error`,text:A(n,H(`resetEmailFailed`),H(`signupInviteOnly`))})}catch{q(`forgot`,{kind:`error`,text:H(`networkErrorDashRetry`)})}finally{F(null)}},[U,Ct,q,H]),An=w.useCallback(async e=>{e.preventDefault();let t=O(L);if(!k(t)){q(`magic-link`,{kind:`error`,text:H(`invalidEmail`)});return}It(!0),q(`magic-link`,null),Ve(d,`auth.signup_clicked`,{surface:`signup`,method:`magic_link`,auth_view:M},t);let n=x();try{let{response:e,data:r}=await j(U(`/_agent-native/auth/magic-link`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:t,callbackURL:n?U(`/_agent-native/auth/magic-link/desktop-callback`):G(W())})});if(!e.ok){q(`magic-link`,{kind:`error`,text:A(r,H(`magicLinkFailed`),H(`signupInviteOnly`))});return}dt(t),N(`magicLinkSent`),n&&typeof r.flowId==`string`&&typeof r.verifier==`string`&&(Yt.current=r.flowId,_n(r.flowId,W(),r.verifier,`magic-link`))}catch{q(`magic-link`,{kind:`error`,text:H(`networkErrorDashRetry`)})}finally{It(!1)}},[U,G,L,W,q,_n,H,d,M]),jn=w.useCallback(async e=>{e.preventDefault();let t=O(Lt);if(!k(t)){q(`sso`,{kind:`error`,text:H(`invalidEmail`)});return}Bt(!0),q(`sso`,null);try{let e=new URL(W(),window.location.origin).toString(),{response:n,data:r}=await j(U(`/_agent-native/auth/ba/sign-in/sso`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:t,callbackURL:e,errorCallbackURL:e,newUserCallbackURL:e})});if(!n.ok||typeof r.url!=`string`||!r.url){q(`sso`,{kind:`error`,text:A(r,H(`ssoFailed`),H(`signupInviteOnly`))});return}window.location.assign(r.url)}catch{q(`sso`,{kind:`error`,text:H(`networkErrorDashRetry`)})}finally{Bt(!1)}},[U,W,q,Lt,H]),Mn=w.useCallback(async()=>{let e=Dt||X();if(!(!e||kt>Date.now())){q(`verification`,null);try{let{response:t,data:n}=await j(U(`/_agent-native/auth/ba/send-verification-email`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({email:e,callbackURL:G(W())})});if(t.ok){let e=Date.now()+6e4;Mt(Date.now()),At(e),q(`verification`,{kind:`success`,text:H(`sentVerification`)});return}q(`verification`,{kind:`error`,text:A(n,H(`resendVerificationFailed`),H(`signupInviteOnly`))})}catch{q(`verification`,{kind:`error`,text:H(`networkErrorRetry`)})}}},[U,G,X,W,q,H,Dt,kt]),Nn=w.useCallback(e=>{let t=e===`system`?Ne(_,f):Me(e,_,f);Le(m,e),xe(e),Se(t),Pe(!1)},[f,_,m]),Pn=w.useCallback(t=>{let n=t.currentTarget;n.validity.tooShort?n.setCustomValidity(H(`passwordMinPlaceholder`)):n.validity.tooLong&&n.setCustomValidity(e.passwordMaxCopy)},[e.passwordMaxCopy,H]),Fn=w.useCallback(e=>e.currentTarget.setCustomValidity(``),[]),In=w.useCallback(async()=>{if(T)try{await navigator.clipboard?.writeText(T.command),Ht(!0),window.setTimeout(()=>Ht(!1),1600)}catch{}},[T]),Ln=tt(M),Rn=re[D],$=v?Rn?.authHeadline&&Rn.authDescription?{...v,...Rn}:v:void 0,zn=$?.appName.replace(/^Agent-Native\s+/i,``)??``,Bn=fe(d||zn),Vn=!!$&&(M===`signup`||M===`login`||M===`magicLink`||M===`googleOnly`),Hn=[`card`,it?`local-dev-available`:``,M===`verification`?`verifying`:``,M===`magicLinkSent`?`magic-link-complete`:``].filter(Boolean).join(` `),Un=T?w.createElement(`div`,{className:`signup-local-mode-note`,id:`signup-local-mode-note`,"data-command":T.command},w.createElement(`p`,null,T.text),w.createElement(`code`,null,T.command),w.createElement(`button`,{type:`button`,className:`copy-run-local`,id:`copy-signup-local-mode`,"data-copy-signup-local-mode":`true`,"data-i18n":`copyCommand`,onClick:()=>void In()},H(Vt?`copied`:`copyCommand`))):null,Wn=C?w.createElement(`p`,{className:`legal-note`},w.createElement(`span`,{"data-i18n":`legalPrefix`},C.prefix??H(`legalPrefix`)),` `,w.createElement(`a`,{href:C.termsUrl,target:`_blank`,rel:`noreferrer`,"data-i18n":C.termsLabel?void 0:`legalTerms`},C.termsLabel??H(`legalTerms`)),` `,w.createElement(`span`,{"data-i18n":`legalConnector`},C.connector??H(`legalConnector`)),` `,w.createElement(`a`,{href:C.privacyUrl,target:`_blank`,rel:`noreferrer`,"data-i18n":C.privacyLabel?void 0:`legalPrivacy`},C.privacyLabel??H(`legalPrivacy`)),w.createElement(`span`,{"data-i18n":`legalSuffix`},C.suffix??H(`legalSuffix`))):null,Gn=w.createElement(pe,{id:`signup-form`,className:M===`signup`?`active`:void 0,onSubmit:En,fields:[{id:`s-email`,label:H(`email`),labelProps:{"data-i18n":`email`},inputProps:{type:`email`,autoComplete:`email`,placeholder:H(`emailPlaceholder`),required:!0,value:ft,onChange:e=>pt(e.currentTarget.value)}},{id:`s-pass`,label:H(`password`),labelProps:{"data-i18n":`password`},inputProps:{type:`password`,autoComplete:`new-password`,placeholder:H(`passwordMinPlaceholder`),"data-i18n-placeholder":`passwordMinPlaceholder`,required:!0,minLength:e.passwordMinLength,maxLength:e.passwordMaxLength,value:mt,onChange:e=>R(e.currentTarget.value),onInvalid:Pn,onInput:Fn}},{id:`s-pass2`,label:H(`confirmPassword`),labelProps:{"data-i18n":`confirmPassword`},inputProps:{type:`password`,autoComplete:`new-password`,placeholder:H(`confirmPasswordPlaceholder`),"data-i18n-placeholder":`confirmPasswordPlaceholder`,required:!0,minLength:e.passwordMinLength,maxLength:e.passwordMaxLength,value:ht,onChange:e=>gt(e.currentTarget.value),onInvalid:Pn,onInput:Fn}}],submitLabel:H(`createAccount`),submitProps:{"data-i18n":`createAccount`,disabled:P===`signup`},footer:w.createElement(w.Fragment,null,Wn,Un),messageId:`s-msg`,messageClassName:`msg ${qe.signup?`${qe.signup.kind} show`:``}`,message:qe.signup?.text}),Kn=w.createElement(`div`,{className:Hn},w.createElement(`h1`,{id:`heading`,"data-i18n":Vn?`welcomeToApp`:Ln.heading,"data-auth-marketing-title":Vn?`true`:void 0},Vn?H(`welcomeToApp`).replace(`{appName}`,zn):H(Ln.heading)),w.createElement(`p`,{id:`subtitle`,className:`subtitle`,"data-i18n":Vn?void 0:Ln.subtitle,"data-auth-marketing-subtitle":Vn?`true`:void 0,hidden:!Vn&&nt(M,it)},H(Vn?`welcomeSubtitle`:Ln.subtitle)),w.createElement(`p`,{className:`upgrade-note ${lt?`show`:``}`,id:`upgrade-note`,"data-upgrade-copy":H(`upgradeCopy`),"data-i18n-data-upgrade-copy":`upgradeCopy`},lt?H(`upgradeCopy`):null),he&&!ge&&!a?w.createElement(`div`,{className:`identity-sso-entry`,id:`identity-sso-entry`},w.createElement(`a`,{className:`btn-primary btn-identity-sso`,id:`identity-sso-btn`,href:dn,"aria-describedby":`identity-sso-hint`,"data-i18n":`continueWithAgentNative`},H(`continueWithAgentNative`)),w.createElement(`p`,{className:`identity-sso-hint`,id:`identity-sso-hint`,"data-i18n":`identitySsoHint`},H(`identitySsoHint`))):null,w.createElement(`div`,{className:`local-dev-signin`,id:`local-dev-signin`,hidden:!it},w.createElement(`button`,{type:`button`,className:`btn-local-dev btn-primary`,id:`local-dev-btn`,title:H(`localDevDescription`),"data-i18n":`localDevButton`,"data-i18n-title":`localDevDescription`,"aria-describedby":`local-dev-description`,disabled:ot,onClick:()=>void xn()},H(ot?`localDevSigningIn`:`localDevButton`)),w.createElement(`p`,{className:`local-dev-description`,id:`local-dev-description`},w.createElement(`span`,{"data-i18n":`localDevDescription`},H(`localDevDescription`)),w.createElement(`a`,{className:`local-dev-help`,id:`local-dev-help`,href:me,target:`_blank`,rel:`noreferrer`,"aria-label":H(`localDevHelp`),title:H(`localDevHelp`),"data-i18n-title":`localDevHelp`,"data-i18n-aria-label":`localDevHelp`},w.createElement(`span`,{className:`local-dev-help-glyph`,"aria-hidden":`true`},`?`))),w.createElement(`button`,{type:`button`,className:`local-dev-full-options`,id:`local-dev-full-options`,hidden:!it,"aria-controls":`full-auth-options`,"aria-expanded":ct,"data-i18n":ct?`localDevHideFullOptions`:`localDevFullOptions`,onClick:()=>I(e=>!e)},H(ct?`localDevHideFullOptions`:`localDevFullOptions`)),J(`local-dev`)),w.createElement(`div`,{id:`full-auth-options`,className:`full-auth-options`,hidden:!ct},a&&!ue?w.createElement(`p`,{className:`google-error show`,id:`google-err`,role:`status`,"data-i18n":`googleNotConfigured`},H(`googleNotConfigured`)):null,ue?w.createElement(`div`,{className:`google-signin`,id:`google-signin`},w.createElement(`button`,{className:`btn-google ${M===`magicLink`&&k(L)?`magic-link-secondary`:``}`,id:`google-btn`,type:`button`,disabled:Pt,"aria-busy":Pt,onClick:()=>void bn()},Pt?w.createElement(y,{className:`animate-spin`,"aria-hidden":`true`}):et(),w.createElement(`span`,{"data-i18n":`googleButton`},H(`googleButton`))),J(`google`),w.createElement(`p`,{className:`google-debug`,id:`google-debug`})):null,de&&!a?w.createElement(`form`,{id:`organization-sso-form`,className:`sso-signin`,onSubmit:jn},w.createElement(`label`,{htmlFor:`sso-email`,"data-i18n":`email`},H(`email`)),w.createElement(`input`,{id:`sso-email`,type:`email`,autoComplete:`email`,placeholder:H(`ssoEmailPlaceholder`),required:!0,value:Lt,onChange:e=>Rt(e.currentTarget.value)}),w.createElement(`button`,{type:`submit`,id:`organization-sso-submit`,disabled:zt||!k(Lt),"data-i18n":`ssoButton`},H(zt?`checking`:`ssoButton`)),J(`sso`)):null,!a&&ue?w.createElement(`div`,{className:`divider`,id:`auth-divider`,"data-i18n":`dividerOr`},H(`dividerOr`)):null,!a&&t===`magic-link`?w.createElement(`form`,{id:`magic-link-form`,className:`form ${M===`magicLink`?`active`:``}`,onSubmit:An},w.createElement(`label`,{htmlFor:`m-email`,"data-i18n":`email`},H(`email`)),w.createElement(`input`,{id:`m-email`,type:`email`,autoComplete:`email`,placeholder:H(`emailPlaceholder`),required:!0,value:L,onChange:e=>dt(e.currentTarget.value)}),w.createElement(`button`,{type:`submit`,id:`magic-link-submit`,className:`magic-link-submit`,disabled:Ft||!k(L),"data-i18n":`sendMagicLink`},H(Ft?`sending`:`sendMagicLink`)),J(`magic-link`),w.createElement(`p`,{className:`auth-mode-switch`},w.createElement(`button`,{type:`button`,className:`link-button auth-mode-link`,id:`use-password-link`,"data-i18n":`usePasswordInstead`,onClick:()=>N(`login`)},H(`usePasswordInstead`))),Wn):null,t===`magic-link`?w.createElement(`div`,{className:`magic-link-success ${M===`magicLinkSent`?`is-visible`:``}`,id:`magic-link-success`,"aria-live":`polite`,hidden:M!==`magicLinkSent`},w.createElement(`p`,{className:`magic-link-success-copy`},w.createElement(`span`,{"data-i18n":`magicLinkSentCopy`},H(`magicLinkSentCopy`)),` `,w.createElement(`strong`,{id:`magic-link-success-email`},L),`.`),w.createElement(`button`,{type:`button`,className:`link-button magic-link-back`,id:`magic-link-back`,"data-i18n":`back`,onClick:()=>{dt(``),N(`magicLink`)}},H(`back`))):null,a?null:w.createElement(`div`,{className:`tabs`,id:`auth-tabs`,hidden:M===`magicLink`||M===`magicLinkSent`||M===`twoFactor`},w.createElement(`button`,{className:`tab ${M===`signup`?`active`:``}`,type:`button`,"data-tab":`signup`,"data-i18n":`createAccount`,onClick:()=>{N(`signup`),Le(Te,`signup`)}},H(`createAccount`)),w.createElement(`button`,{className:`tab ${M===`login`||M===`forgot`?`active`:``}`,type:`button`,"data-tab":`login`,"data-i18n":`signIn`,onClick:()=>{N(`login`),Le(Te,`login`)}},H(`signIn`))),a?null:Gn,w.createElement(`div`,{id:`verification-step`,className:`form verification-step ${M===`verification`?`active`:``}`,"aria-live":`polite`},w.createElement(`div`,{className:`step-progress`,"aria-label":H(`signupProgress`),"data-i18n-aria-label":`signupProgress`},w.createElement(`div`,{className:`progress-step complete`},w.createElement(`span`,null,`1`),w.createElement(`strong`,{"data-i18n":`progressAccount`},H(`progressAccount`))),w.createElement(`div`,{className:`progress-step current`},w.createElement(`span`,null,`2`),w.createElement(`strong`,{"data-i18n":`progressVerify`},H(`progressVerify`))),w.createElement(`div`,{className:`progress-step`},w.createElement(`span`,null,`3`),w.createElement(`strong`,{"data-i18n":`progressStart`},H(`progressStart`)))),w.createElement(`div`,{className:`verification-panel`},w.createElement(`p`,{className:`verification-kicker`,"data-i18n":`verificationSent`},H(`verificationSent`)),w.createElement(`p`,{className:`verification-copy`},w.createElement(`span`,{"data-i18n":`verifyCopyPrefix`},H(`verifyCopyPrefix`)),` `,w.createElement(`strong`,{id:`verify-email`},Dt),w.createElement(`span`,{"data-i18n":`verifyCopySuffix`},H(`verifyCopySuffix`))),w.createElement(`p`,{className:`verification-note`,"data-i18n":`verificationNote`},H(`verificationNote`))),w.createElement(`button`,{type:`button`,className:`btn-primary`,id:`verify-continue`,"data-i18n":`continue`,onClick:()=>void wn()},H(`continue`)),w.createElement(`div`,{className:`inline-actions`},w.createElement(`button`,{type:`button`,className:`link-button`,id:`resend-verification`,disabled:Tn,"data-i18n":`resendEmail`,onClick:()=>void Mn()},H(`resendEmail`),Tn?` (${Math.ceil((kt-Date.now())/1e3)}s)`:``),w.createElement(`button`,{type:`button`,className:`link-button`,id:`back-to-signup`,"data-i18n":`back`,onClick:()=>{Nt(),Re(Y()),N(`signup`)}},H(`back`))),J(`verification`)),w.createElement(`form`,{id:`two-factor-form`,className:`form ${M===`twoFactor`?`active`:``}`,onSubmit:On},w.createElement(`label`,{htmlFor:`two-factor-code`,"data-i18n":`twoFactorCodeLabel`},H(`twoFactorCodeLabel`)),w.createElement(`input`,{id:`two-factor-code`,type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,pattern:`[0-9]{6,8}`,maxLength:8,placeholder:H(`twoFactorCodePlaceholder`),value:xt,onChange:e=>St(e.currentTarget.value.replace(/\D/g,``)),required:!0}),w.createElement(`button`,{type:`submit`,"data-i18n":`twoFactorVerify`,disabled:P===`twoFactor`},H(P===`twoFactor`?`twoFactorVerifying`:`twoFactorVerify`)),J(`twoFactor`),w.createElement(`button`,{type:`button`,className:`link-button`,"data-i18n":`twoFactorBack`,onClick:()=>{St(``),q(`twoFactor`,null),N(`login`)}},H(`twoFactorBack`))),w.createElement(`form`,{id:`login-form`,className:`form ${M===`login`?`active`:``}`,onSubmit:Dn},w.createElement(`label`,{htmlFor:`l-email`,"data-i18n":`email`},H(`email`)),w.createElement(`input`,{id:`l-email`,type:`email`,autoComplete:`email`,placeholder:H(`emailPlaceholder`),required:!0,value:_t,onChange:e=>vt(e.currentTarget.value)}),w.createElement(`label`,{htmlFor:`l-pass`,"data-i18n":`password`},H(`password`)),w.createElement(`input`,{id:`l-pass`,type:`password`,autoComplete:`current-password`,placeholder:H(`enterPasswordPlaceholder`),"data-i18n-placeholder":`enterPasswordPlaceholder`,required:!0,value:yt,onChange:e=>bt(e.currentTarget.value),onInvalid:Pn,onInput:Fn}),w.createElement(`button`,{type:`submit`,"data-i18n":`signIn`,disabled:P===`login`},H(P===`login`?`signingIn`:`signIn`)),J(`login`),w.createElement(`p`,{style:{marginTop:`0.75rem`,fontSize:`0.75rem`,textAlign:`right`}},w.createElement(`button`,{type:`button`,id:`forgot-link`,className:`link-button`,"data-i18n":`forgotPassword`,onClick:()=>{wt(_t),N(`forgot`)}},H(`forgotPassword`))),t===`magic-link`?w.createElement(`p`,{style:{marginTop:`0.5rem`,fontSize:`0.75rem`,textAlign:`center`}},w.createElement(`button`,{type:`button`,className:`link-button`,id:`back-to-magic-link`,"data-i18n":`backToMagicLink`,onClick:()=>N(`magicLink`)},H(`backToMagicLink`))):null),w.createElement(`form`,{id:`forgot-form`,className:`form ${M===`forgot`?`active`:``}`,onSubmit:kn},w.createElement(`label`,{htmlFor:`f-email`,"data-i18n":`email`},H(`email`)),w.createElement(`input`,{id:`f-email`,type:`email`,autoComplete:`email`,placeholder:H(`emailPlaceholder`),required:!0,value:Ct,onChange:e=>wt(e.currentTarget.value)}),w.createElement(`button`,{type:`submit`,"data-i18n":`sendResetLink`,disabled:Tt||P===`forgot`},H(Tt?`sent`:P===`forgot`?`sending`:`sendResetLink`)),J(`forgot`),w.createElement(`p`,{style:{marginTop:`0.75rem`,fontSize:`0.75rem`,textAlign:`center`}},w.createElement(`button`,{type:`button`,className:`link-button`,id:`back-to-login`,"data-i18n":`backToSignIn`,onClick:()=>N(`login`)},H(`backToSignIn`)))))),qn=$?w.createElement(`div`,{className:`marketing-content`},w.createElement(`h2`,{className:`app-name`},w.createElement(`picture`,null,oe?w.createElement(`source`,{media:`(prefers-color-scheme: light)`,srcSet:oe}):null,w.createElement(`img`,{className:`brand-mark`,src:ae,alt:``,"aria-hidden":`true`})),w.createElement(`span`,{className:`app-name-label`},zn),w.createElement(`span`,{className:`app-status-badge`},Bn)),w.createElement(`div`,{className:`marketing-copy`},w.createElement(`p`,{className:`auth-marketing-headline`,"data-marketing-field":`headline`},$.authHeadline??$.tagline),($.authDescription??$.description)||$.learnMoreUrl?w.createElement(`p`,{className:`auth-marketing-description`,"data-marketing-field":`description`},$.authDescription??$.description,$.learnMoreUrl?w.createElement(w.Fragment,null,` `,w.createElement(`a`,{className:`auth-marketing-description-link`,href:$.learnMoreUrl,target:`_blank`,rel:`noreferrer`},H(`learnMore`))):null):null,w.createElement(`div`,{className:`marketing-actions`},w.createElement(`a`,{className:`oss-badge`,href:se,target:`_blank`,rel:`noreferrer`},w.createElement(`svg`,{"aria-hidden":`true`,viewBox:`0 0 24 24`,width:16,height:16,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},w.createElement(`path`,{d:`M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5`})),w.createElement(`span`,{"data-i18n":`openSource`},H(`openSource`)))))):null,Jn=$?w.createElement(`main`,{className:`auth-marketing-home`,"data-agent-native-marketing-home":!0},w.createElement(`div`,{className:`auth-marketing-shell`},w.createElement(`div`,{className:`split auth-marketing-layout`},w.createElement(`aside`,{className:`form-panel w-full max-w-md justify-self-end`},Kn),w.createElement(`section`,{className:`marketing-panel`},w.createElement(`div`,{className:`auth-marketing-visual`},qn))))):w.createElement(`div`,{className:`auth-centered`},Kn),Yn=w.createElement(`div`,{className:`locale-picker`},w.createElement(`button`,{type:`button`,className:`locale-trigger`,id:`auth-locale-trigger`,"aria-haspopup":`menu`,"aria-expanded":Oe,"aria-controls":`auth-locale-menu`,"aria-label":H(`languageLabel`),title:H(`languageLabel`),"data-i18n-aria-label":`languageLabel`,"data-i18n-title":`languageLabel`,onClick:()=>Pe(e=>!e)},w.createElement(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`},w.createElement(`path`,{d:`M4 5h7`}),w.createElement(`path`,{d:`M7.5 4v1`}),w.createElement(`path`,{d:`M9.5 5c-.8 4.4-2.6 7.2-5.5 9`}),w.createElement(`path`,{d:`M5 9c1.2 2.1 3.2 3.8 6 5`}),w.createElement(`path`,{d:`M13 20l4-9 4 9`}),w.createElement(`path`,{d:`M14.5 17h5`}))),w.createElement(`div`,{className:`locale-menu`,id:`auth-locale-menu`,role:`menu`,"aria-labelledby":`auth-locale-trigger`,hidden:!Oe},w.createElement(`button`,{type:`button`,className:`locale-menu-item`,role:`menuitemradio`,"aria-checked":be===`system`,"data-locale-value":`system`,onClick:()=>Nn(`system`)},w.createElement(`span`,{className:`locale-menu-check`,"aria-hidden":`true`},`✓`),w.createElement(`span`,{"data-system-language":!0},H(`systemLanguage`))),_.map(e=>w.createElement(`button`,{type:`button`,className:`locale-menu-item`,role:`menuitemradio`,"aria-checked":be===e.value,"data-locale-value":e.value,key:e.value,onClick:()=>Nn(e.value)},w.createElement(`span`,{className:`locale-menu-check`,"aria-hidden":`true`},`✓`),w.createElement(`span`,null,e.label)))));return w.createElement(`div`,{className:`auth-page`,"data-auth-marketing":$&&!s?`true`:void 0},w.createElement(Ce,{className:`auth-wave-background`}),w.createElement(`div`,{className:`auth-page-content`},Yn,s?w.createElement(`div`,{className:`auth-centered`},Kn):Jn))}function F(e){let t=e.indexOf(`/_agent-native/auth/reset`);return t>=0?e.slice(0,t):``}function it(e,t,n,r){let i=e.error??e.message;if(typeof i!=`string`||!i.trim())return t;let a=i.trim();return/failed query|\bselect\b.*\bfrom\b|\binsert\b.*\binto\b|\bupdate\b.*\bset\b|\bdelete\b.*\bfrom\b|\bsql\b|database|relation .* does not exist|column .* does not exist|syntax error|constraint|connection refused|econn|timeout/i.test(a)?t:/password.*(?:at least|minimum|min(?:imum)?|too short)/i.test(a)?`Choose a password with at least ${n} characters.`:/password.*(?:at most|maximum|max(?:imum)?|too long)/i.test(a)?`Choose a password with no more than ${r} characters.`:a}function at({appBasePath:e,passwordMinLength:t,passwordMaxLength:r}){let[a,o]=w.useState(e),[s,c]=w.useState(``),[l,ee]=w.useState(!1),[u,d]=w.useState(``),[f,p]=w.useState(``),[te,m]=w.useState(null),[h,g]=w.useState(!1);w.useEffect(()=>{e||o(F(window.location.pathname)),c(new URLSearchParams(window.location.search).get(`token`)??``),ee(!0)},[e]);let _=w.useCallback(e=>{let n=e.currentTarget;n.validity.tooShort?n.setCustomValidity(`Choose a password with at least ${t} characters.`):n.validity.tooLong&&n.setCustomValidity(`Choose a password with no more than ${r} characters.`)},[r,t]),ne=w.useCallback(e=>{e.currentTarget.setCustomValidity(``)},[]),v=w.useCallback(async e=>{if(e.preventDefault(),u!==f){m({kind:`error`,text:`Passwords do not match.`});return}g(!0),m(null);try{let e=await fetch(`${a}${n(`/_agent-native/auth/ba/reset-password`,{publicPrefix:i()})}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({newPassword:u,token:s})});if(e.ok){m({kind:`success`,text:`Password updated — redirecting to sign in…`}),window.setTimeout(()=>{window.location.href=`${a}/`},1200);return}let o={};try{let t=await e.json();t&&typeof t==`object`&&!Array.isArray(t)&&(o=t)}catch{}m({kind:`error`,text:it(o,`We couldn't update your password. The link may have expired; request a new one.`,t,r)}),g(!1)}catch{m({kind:`error`,text:`We couldn't reach the server. Check your connection and try again.`}),g(!1)}},[f,u,r,t,a,s]),y=l&&!s;return w.createElement(`div`,{className:`card reset-password-card`},w.createElement(`h1`,null,`Choose a new password`),w.createElement(`p`,{className:`subtitle`},`Set a new password for your account.`),w.createElement(`form`,{id:`reset-form`,onSubmit:v,hidden:y},w.createElement(`label`,{htmlFor:`p1`},`New password`),w.createElement(`input`,{id:`p1`,type:`password`,autoComplete:`new-password`,placeholder:`At least ${t} characters`,required:!0,minLength:t,maxLength:r,value:u,onChange:e=>d(e.currentTarget.value),onInvalid:_,onInput:ne}),w.createElement(`label`,{htmlFor:`p2`},`Confirm password`),w.createElement(`input`,{id:`p2`,type:`password`,autoComplete:`new-password`,placeholder:`Confirm password`,required:!0,minLength:t,maxLength:r,value:f,onChange:e=>p(e.currentTarget.value),onInvalid:_,onInput:ne}),w.createElement(`button`,{type:`submit`,disabled:h},h?`Saving…`:`Save new password`),te?w.createElement(`p`,{className:`msg show ${te.kind}`,role:`status`},te.text):null),y?w.createElement(`p`,{className:`msg show error`,role:`alert`},`This password reset link is missing or invalid. Request a new one.`):null,w.createElement(`a`,{className:`back`,id:`back-link`,href:`${a}/`},`Back to sign in`))}var ot=new Set([`/`,`/login`,`/signup`,`/sign-in`,`/_agent-native/sign-in`]),st=[`token`,`code`,`state`,`c`,`access_token`,`refresh_token`,`id_token`,`token_hash`,`session_token`,`auth_token`,`verification_token`,`otp`,`flow_id`,`verifier`,`callbackURL`,`error`],ct=[...st,`email`,`password`,`return`,`invite`,`invite_token`,`invitation`,`invitation_token`,`ticket`,`challenge`],I=[`#magic-link-success-email`,`#verify-email`,`#google-debug`,`#google-err`,`.auth-page .msg`,`[data-sensitive]`,`[data-an-block]`,`[data-an-private]`,`[data-private]`,`.an-block`,`.an-replay-block`,`.an-private`,`.rr-block`,`[autocomplete='cc-number']`,`[autocomplete='cc-csc']`,`[autocomplete='cc-exp']`,`[name*='password' i]`,`[name*='credit' i]`,`[name*='card' i]`,`[name*='ssn' i]`].join(`, `);function lt(e){let t=e.trim();return!t||t===`/`?``:`/${t.replace(/^\/+/,``).replace(/\/+$/,``)}`}function ut(e,t){let n=lt(t),r=e;if(n)if(e===n)r=`/`;else if(e.startsWith(`${n}/`))r=e.slice(n.length);else return!1;return ot.has(r)}function L(e,t){if(t)return!0;let n=new URLSearchParams(e),r=new Set(st.map(e=>e.toLowerCase().replace(/[^a-z0-9]/g,``)));return Array.from(n.keys()).some(e=>r.has(e.toLowerCase().replace(/[^a-z0-9]/g,``)))}function dt(e,t){try{let n=new URL(e,window.location.href),r=lt(t),i=r?n.pathname===r?`/`:n.pathname.startsWith(`${r}/`)?n.pathname.slice(r.length):n.pathname:n.pathname;return L(n.search,n.hash)||i===`/_agent-native/auth`||i.startsWith(`/_agent-native/auth/`)}catch{return!0}}function ft(e){if(/^[a-z][a-z\d+.-]*:\/\//i.test(e)){let t;try{t=new URL(e)}catch(e){if(e instanceof TypeError)return;throw e}if(t.pathname.endsWith(`/api/analytics/track`))return t.pathname=t.pathname.replace(/\/api\/analytics\/track$/,`/api/analytics/replay`),t.search=``,t.hash=``,t.toString();if(t.pathname.endsWith(`/track`))return t.pathname=t.pathname.replace(/\/track$/,`/api/analytics/replay`),t.search=``,t.hash=``,t.toString()}if(e.endsWith(`/api/analytics/track`))return e.replace(/\/api\/analytics\/track$/,`/api/analytics/replay`);if(e.endsWith(`/track`))return e.replace(/\/track$/,`/api/analytics/replay`)}function pt(e,t,n,r,i=``,a=``,o=``){let s=typeof e?.agentNativeAnalyticsPublicKey==`string`?e.agentNativeAnalyticsPublicKey.trim():``;if(e?.authSessionReplay!==!0||!s||!ut(t,n)||L(i,a))return null;let c=typeof e.agentNativeAnalyticsEndpoint==`string`?e.agentNativeAnalyticsEndpoint.trim():``,l=c?ft(c):void 0;return c&&!l?(console.warn(`Skipping optional auth session replay because the configured Analytics endpoint is invalid.`),null):{publicKey:s,...l?{endpoint:h(l,r)}:{},requireSignedInUser:!1,sensitiveQueryParams:ct,blockUrls:[e=>dt(e,n)],maskAllInputs:!0,blockSelector:I,recordCanvas:!1,recordCrossOriginIframes:!1,inlineImages:!1,collectFonts:!1,console:!1,network:!1,extraProperties:{capture_context:`pre_auth`,pre_auth_base_path:lt(n),...o.trim()?{app:o.trim(),app_name:o.trim(),template_name:o.trim()}:{}},shouldStart:()=>ut(window.location.pathname,n)&&!L(window.location.search,window.location.hash)}}function mt(e,t){let n=Fe(t.appBasePath,t.workspaceRuntime,window.location.pathname),r=pt(e,window.location.pathname,n,window.location.hostname,window.location.search,window.location.hash,t.trackingApp);r&&l(async()=>{let{startSessionReplay:e}=await import(`./analytics-hbCOwHmS.js`).then(e=>e.t);return{startSessionReplay:e}},__vite__mapDeps([2,3,4,1,5,6])).then(({startSessionReplay:e})=>e(r)).catch(e=>{console.warn(`Optional auth session replay failed to start.`,e)})}var R=document.getElementById(`agent-native-auth-root`),ht=document.getElementById(`agent-native-auth-data`);if(R&&ht){let e=JSON.parse(ht.textContent??`{}`);if(`pageType`in e&&e.pageType===`reset-password`){let t=(0,C.jsx)(at,{...e});R.dataset.agentNativeAuthFallback?(0,re.createRoot)(R).render(t):(0,re.hydrateRoot)(R,t)}else{let t=e;mt(window.__AGENT_NATIVE_CONFIG__,t);let n=(0,C.jsx)(P,{...t});R.dataset.agentNativeAuthFallback?(0,re.createRoot)(R).render(n):(0,re.hydrateRoot)(R,n)}}export{pt as authSessionReplayOptions,ut as isAuthSessionReplayPathname,mt as startAuthSessionReplay};