1import{j as e}from"./index-B0cTFD4s.js";import{h as M,r as l}from"./router-BvNiAcqA.js";import{a as g,o as D,b as W,c as L,d as $,e as F,f as O,q as H,w as N,h as U,i as q}from"./firestore-CXFmaHYU.js";async function G(h){return(await O(H(U(q,"businesses"),N("ownerEmail","==",h)))).docs.map(m=>m.data())}function p(h){const s=window.location.origin.includes("localhost")?window.location.origin:"https://www.viralspin.ai";window.location.href=`${s}/scheduling/admin?s=${h}`}function K(){const[h]=M(),s=h.get("returnTo"),m=h.has("switch"),[S,z]=l.useState(null),[x,d]=l.useState(!0),[v,b]=l.useState(""),[C,A]=l.useState([]),[B,E]=l.useState(!1),[T,P]=l.useState(!1),[r,R]=l.useState("");l.useEffect(()=>{document.title="Schedule, Book, Invoice | ViralSpin Scheduling"},[]);async function k(o){if(s){const t=window.location.origin.includes("localhost")?window.location.origin:"https://www.viralspin.ai",i=s.startsWith("http")?s:`${t}/${s.includes(".")?s:s+".viralspin.ai/admin"}`;window.location.href=i;return}try{const[t,i]=await Promise.all([G(o.email??"").catch(()=>[]),F(o.uid).catch(()=>[])]),a=new Map;for(const n of i)a.set(n.subdomain,{subdomain:n.subdomain,name:n.name,lastAccessed:n.lastAccessed,isOwner:!1});for(const n of t){const f=a.get(n.subdomain);a.set(n.subdomain,{subdomain:n.subdomain,name:n.name||n.subdomain,lastAccessed:(f==null?void 0:f.lastAccessed)??null,isOwner:!0})}const c=Array.from(a.values()).sort((n,f)=>n.lastAccessed!==null&&f.lastAccessed!==null?f.lastAccessed-n.lastAccessed:n.lastAccessed!==null?-1:f.lastAccessed!==null?1:0);c.length===1&&!m?p(c[0].subdomain):c.length>0?(A(c),E(!0),d(!1)):(P(!0),d(!1))}catch{b("Could not load your booking pages. Please try again."),d(!1)}}l.useEffect(()=>{if(!g){d(!1);return}const o=D(g,t=>{z(t),t?k(t):d(!1),o()})},[]);const I=async()=>{d(!0),b("");try{const o=await L(g,$);await k(o.user)}catch(o){o.code!=="auth/popup-closed-by-user"&&b("Sign-in failed. Please try again."),d(!1)}},u="#6366f1",y={minHeight:"100vh",background:"#f8fafc",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"'Outfit', system-ui, sans-serif"},w={textAlign:"center",maxWidth:420,width:"90%",background:"#fff",padding:40,borderRadius:24,border:"1px solid #e2e8f0",boxShadow:"0 10px 25px -5px rgba(0,0,0,0.05)"},j=e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:10,marginBottom:32},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,overflow:"hidden"},children:e.jsx("img",{src:"/images/tornado-icon.jpg",alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}})}),e.jsxs("span",{style:{fontWeight:800,fontSize:20,color:"#0f172a"},children:["ViralSpin",e.jsx("span",{style:{color:"#06b6d4"},children:"AI"}),e.jsx("span",{style:{background:"linear-gradient(135deg, #f97316, #fbbf24)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",fontStyle:"italic",fontWeight:800,marginLeft:5},children:"Scheduling"})]})]});if(B){const o=t=>{if(!t)return null;const i=Date.now()-t,a=Math.floor(i/6e4);if(a<2)return"Just now";if(a<60)return`${a}m ago`;const c=Math.floor(a/60);if(c<24)return`${c}h ago`;const n=Math.floor(c/24);return n<7?`${n}d ago`:new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})};return e.jsx("div",{style:y,children:e.jsxs("div",{style:{...w,maxWidth:480},children:[j,e.jsx("h1",{style:{fontSize:22,fontWeight:800,marginBottom:8,color:"#0f172a"},children:"Your Booking Pages"}),S&&e.jsxs("p",{style:{color:"#94a3b8",fontSize:12,marginBottom:20,fontWeight:600},children:["Signed in as ",S.email]}),e.jsx("p",{style:{color:"#64748b",marginBottom:20,fontSize:14,lineHeight:1.6},children:"Select a dashboard to open."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:C.map(t=>e.jsxs("button",{onClick:()=>p(t.subdomain),style:{display:"flex",alignItems:"center",justifyContent:"space-between",background:"#f8fafc",border:"1.5px solid #e2e8f0",borderRadius:14,padding:"14px 20px",cursor:"pointer",transition:"all 0.15s",textAlign:"left",width:"100%"},onMouseEnter:i=>{i.currentTarget.style.borderColor=u,i.currentTarget.style.background=`${u}08`},onMouseLeave:i=>{i.currentTarget.style.borderColor="#e2e8f0",i.currentTarget.style.background="#f8fafc"},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:2},children:[e.jsx("span",{style:{fontWeight:800,fontSize:15,color:"#0f172a"},children:t.name||t.subdomain}),t.isOwner&&e.jsx("span",{style:{fontSize:10,fontWeight:700,background:`${u}15`,color:u,borderRadius:6,padding:"2px 7px"},children:"OWNER"})]}),e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[e.jsxs("span",{style:{fontSize:12,color:"#94a3b8",fontWeight:600},children:[t.subdomain,".viralspin.ai"]}),o(t.lastAccessed)&&e.jsxs("span",{style:{fontSize:11,color:"#cbd5e1",fontWeight:600},children:["· ",o(t.lastAccessed)]})]})]}),e.jsx("span",{style:{color:u,fontSize:18,flexShrink:0},children:"â"})]},t.subdomain))}
1),e.jsxs("div",{style:{marginTop:24,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("a",{href:"https://www.viralspin.ai/scheduling",style:{color:"#94a3b8",fontSize:13,textDecoration:"none",fontWeight:600},children:"â Back to Scheduling"}),e.jsx("button",{onClick:()=>W(g).then(()=>{window.location.href="https://www.viralspin.ai/scheduling"}),style:{background:"none",border:"none",color:"#cbd5e1",fontSize:12,fontWeight:600,cursor:"pointer"},children:"Sign out completely"})]})]})})}return T?e.jsx("div",{style:y,children:e.jsxs("div",{style:{...w,maxWidth:460},children:[j,e.jsx("h1",{style:{fontSize:22,fontWeight:800,marginBottom:8,color:"#0f172a"},children:"Which booking page?"}),e.jsx("p",{style:{color:"#64748b",marginBottom:24,lineHeight:1.6,fontSize:14},children:"No pages were found linked to your email. Enter the subdomain of the booking page you want to manage."}),e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[e.jsxs("div",{style:{flex:1,position:"relative"},children:[e.jsx("span",{style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",fontSize:13,color:"#94a3b8",fontWeight:600,pointerEvents:"none"},children:"subdomain.viralspin.ai"}),e.jsx("input",{type:"text",value:r,onChange:o=>R(o.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),onKeyDown:o=>{o.key==="Enter"&&r&&p(r)},placeholder:"e.g. myfriendmd",style:{width:"100%",boxSizing:"border-box",border:"1.5px solid #e2e8f0",borderRadius:10,padding:"12px 14px",fontSize:15,outline:"none",fontWeight:600,color:"#0f172a"},autoFocus:!0})]}),e.jsx("button",{onClick:()=>{r&&p(r)},disabled:!r,style:{background:r?u:"#e2e8f0",color:r?"#fff":"#94a3b8",border:"none",borderRadius:10,padding:"12px 20px",fontWeight:700,fontSize:15,cursor:r?"pointer":"not-allowed",transition:"all 0.15s",whiteSpace:"nowrap"},children:"Go â"})]}),e.jsxs("div",{style:{borderTop:"1px solid #f1f5f9",paddingTop:20,marginTop:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("a",{href:"https://www.viralspin.ai/scheduling",style:{color:"#94a3b8",fontSize:13,textDecoration:"none",fontWeight:600},children:"â Create a new booking page"}),e.jsx("button",{onClick:()=>W(g).then(()=>{window.location.href="https://www.viralspin.ai/scheduling"}),style:{background:"none",border:"none",color:"#cbd5e1",fontSize:12,fontWeight:600,cursor:"pointer"},children:"Sign out completely"})]})]})}):e.jsx("div",{style:y,children:e.jsxs("div",{style:w,children:[j,e.jsx("h1",{style:{fontSize:28,fontWeight:800,marginBottom:12,color:"#0f172a"},children:"Dashboard Login"}),e.jsx("p",{style:{color:"#64748b",marginBottom:32,lineHeight:1.6},children:"Sign in to manage your scheduling, services, and branding."}),v&&e.jsx("div",{style:{background:"#fef2f2",color:"#ef4444",padding:"12px",borderRadius:12,marginBottom:20,fontSize:13,fontWeight:600},children:v}),e.jsx("button",{onClick:I,disabled:x,style:{display:"flex",alignItems:"center",gap:12,justifyContent:"center",background:"#0f172a",color:"#fff",border:"none",borderRadius:12,padding:"14px 28px",cursor:"pointer",fontWeight:700,fontSize:15,width:"100%",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",transition:"all 0.2s",opacity:x?.7:1},children:x?e.jsx("div",{style:{width:20,height:20,border:"2px solid rgba(255,255,255,0.3)",borderTopColor:"#fff",borderRadius:"50%",animation:"spin 0.8s linear infinite"}}):e.jsxs(e.Fragment,{children:[e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 48 48",children:[e.jsx("path",{fill:"#EA4335",d:"M24 9.5c3.5 0 6.6 1.2 9 3.2l6.7-6.7C35.6 2.4 30.1 0 24 0 14.8 0 6.9 5.4 3 13.3l7.8 6C12.7 13 18 9.5 24 9.5z"}),e.jsx("path",{fill:"#4285F4",d:"M46.5 24.5c0-1.6-.1-3.1-.4-4.5H24v8.5h12.7c-.6 3-2.3 5.5-4.8 7.2l7.5 5.8c4.4-4 7.1-10 7.1-17z"}),e.jsx("path",{fill:"#FBBC05",d:"M10.8 28.7A14.5 14.5 0 0 1 9.5 24c0-1.6.3-3.2.8-4.7L2.5 13.3A23.9 23.9 0 0 0 0 24c0 3.9.9 7.5 2.5 10.7l8.3-6z"}),e.jsx("path",{fill:"#34A853",d:"M24 48c6.1 0 11.2-2 14.9-5.4l-7.5-5.8c-2 1.4-4.6 2.2-7.4 2.2-5.9 0-10.9-4-12.7-9.3l-8 6.2C6.8 42.5 14.8 48 24 48z"})]}),"Continue with Google"]})}),e.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg) } }"})]})})}export{K as default};
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.