1import{c as H,G as I,J as T,j as e,r as b,B as y,b as p,t as o,e as k,N as P,O as F,f as D,q as v,aI as q,a4 as w,a9 as G,L as _,a as C,U as M,D as K,l as L,m as V,n as U,E as Q,M as W,u as Y,v as J,h as N,o as X,y as Z,at as ee}from"./index-N0wys5lg.js";import{u as B}from"./useHostAccess-CKqxFKMW.js";import{S as te}from"./shield-alert-CTaaI8PH.js";import{S as ae,a as se,b as re,c as ne,d as ie}from"./select-DZWRa5aR.js";import{P as le}from"./plus-DdrBQJ9E.js";import{T as de}from"./trash-2-C9LLEaRO.js";import{i as A}from"./isAfter-D2Dti35Q.js";import{h as E}from"./hostSafeIdentity-Dm1QHshc.js";import{V as ce}from"./video-DsHov2gy.js";import{C as oe}from"./circle-check-brUdtkO3.js";import{C as me}from"./calendar-clock-DTG6_67E.js";import{C as xe}from"./circle-x-Cpt_eX19.js";import"./index-CfnEu8Sg.js";import"./chevron-up-C1laQmVo.js";/** 2 * @license lucide-react v0.475.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ue=[["path",{d:"M18 7c0-5.333-8-5.333-8 0",key:"1prm2n"}],["path",{d:"M10 7v14",key:"18tmcs"}],["path",{d:"M6 21h12",key:"4dkmi1"}],["path",{d:"M6 13h10",key:"ybwr4a"}]],he=H("PoundSterling",ue);function z({amountGbp:a,className:c="",hideApprox:n=!1}){const{region:r}=I(),d=T(a,"GBP"),i=!n&&(r==null?void 0:r.currency)&&r.currency!=="GBP";return e.jsxs("span",{className:c,children:[d,i&&e.jsxs("span",{className:"ml-1.5 text-xs font-normal text-muted-foreground whitespace-nowrap",title:"Approximate only â your card is charged in GBP at your bank's exchange rate.",children:["(approx ",T(a,r.currency),")"]})]})}function ge({action:a="do this"}){const{loading:c,hasSubscription:n,stripeConnected:r,canBroadcast:d}=B(),[i,h]=b.useState(!1);if(c||d)return null;const u=async()=>{var g,f,s,l;h(!0);try{const x=await p.functions.invoke("createConnectOnboardingLink",{returnOrigin:window.location.origin});
6if((g=x.data)!=null&&g.url)window.location.href=x.data.url;else throw new Error(((f=x.data)==null?void 0:f.error)||"Could not start Stripe setup")}catch(x){o.error(((l=(s=x.response)==null?void 0:s.data)==null?void 0:l.error)||x.message||"Could not start Stripe setup"),h(!1)}};return e.jsxs("div",{className:"rounded-xl border border-yellow-500/30 bg-yellow-500/5 p-3 space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-foreground flex items-center gap-2",children:[e.jsx(te,{className:"w-4 h-4 text-yellow-400"}),"Payment setup required"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["You need an active host plan and completed Stripe payment details before you can ",a," â this is how you get paid."]}),n?r?null:e.jsx(y,{size:"sm",onClick:u,disabled:i,children:i?"Opening Stripeâ¦":"Finish Stripe Setup"}):e.jsx(y,{size:"sm",onClick:()=>window.location.href="/onboarding/host",children:"Choose a Host Plan"})]})}const pe=1.5;function fe({offers:a,user:c,onRefresh:n}){const r=(a==null?void 0:a[0])||null,{canBroadcast:d}=B(),i=async()=>{if(r){if(!d){o.error("Complete your host plan and Stripe payment setup first");return}try{await p.entities.OneOnOneOffer.update(r.id,{is_available:!r.is_available}),o.success(r.is_available?"Paused":"Activated"),n()}catch{o.error("Failed to update")}}};return e.jsxs(k,{className:"bg-card border-border",children:[e.jsxs(P,{className:"pb-3",children:[e.jsxs(F,{className:"flex items-center gap-2 font-heading text-lg",children:[e.jsx(he,{className:"w-5 h-5 text-primary"}),"Reading Rate"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Private readings are charged at the fixed platform rate."})]}),e.jsxs(D,{className:"space-y-4",children:[e.jsxs("div",{className:"bg-secondary/30 border border-border rounded-lg p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("span",{className:"text-2xl font-bold text-foreground font-heading",children:["£",pe.toFixed(2)]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"/ minute"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"You keep 40% · Platform takes 60%"})]}),e.jsx(ge,{action:"go Available Now and take readings"}),r&&e.jsxs("div",{className:`flex items-center justify-between bg-secondary/20 border border-border rounded-lg px-4 py-3 ${d?"":"opacity-50"}`,children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:"Availability"}),e.jsx(v,{className:`relative text-xs cursor-pointer before:content-[''] before:absolute before:inset-[-11px] before:cursor-pointer ${r.is_available?"bg-green-500/20 text-green-400 border-green-500/30":"bg-muted text-muted-foreground border-border"} border`,onClick:i,children:r.is_available?"â Active":"â Paused"})]})]})]})}function be({slots:a,offers:c,user:n,onRefresh:r}){const[d,i]=b.useState(!1),[h,u]=b.useState(!1),[g,f]=b.useState(null),[s,l]=b.useState({offering_id:"",date:"",start_time:"",end_time:""}),x=(a==null?void 0:a.filter(t=>A(new Date(t.start_time),new Date)).sort((t,m)=>new Date(t.start_time)-new Date(m.start_time)))||[],j=async()=>{if(!s.offering_id||!s.date||!s.start_time||!s.end_time){o.error("Please fill all fields");return}const t=new Date(`${s.date}T${s.start_time}`),m=new Date(`${s.date}T${s.end_time}`);if(!A(m,t)){o.error("End time must be after start time");return}u(!0);try{const R=c.find($=>$.id===s.offering_id);await p.entities.AvailabilitySlot.create({host_email:n.email,host_name:n.full_name,offering_id:s.offering_id,start_time:t.toISOString(),end_time:m.toISOString(),is_booked:!1}),o.success("Slot added!"),i(!1),l({offering_id:"",date:"",start_time:"",end_time:""}),r()}catch{o.error("Failed to add slot")}finally{u(!1)}},O=async t=>{if(t.is_booked){o.error("Cannot delete a booked slot");return}f(t.id);try{await p.entities.AvailabilitySlot.delete(t.id),o.success("Slot removed"),r()}catch{o.error("Failed to remove slot")}finally{f(null)}};return e.jsxs(k,{className:"bg-card border-border",children:[e.jsx(P,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(F,{className:"flex items-center gap-2 font-heading text-lg",children:[e.jsx(q,{className:"w-5 h-5 text-primary"}),"Availability"]}),e.jsxs(y,{size:"sm",onClick:()=>i(t=>
6!t),className:"bg-primary text-primary-foreground",children:[e.jsx(le,{className:"w-4 h-4 mr-1"}),"Add Slot"]})]})}),e.jsxs(D,{className:"space-y-4",children:[d&&e.jsxs("div",{className:"bg-secondary/30 border border-primary/30 rounded-lg p-4 space-y-3",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"New Availability Slot"}),e.jsxs(ae,{value:s.offering_id,onValueChange:t=>l(m=>({...m,offering_id:t})),children:[e.jsx(se,{className:"w-full h-11 bg-background border-border text-foreground text-sm",children:e.jsx(re,{placeholder:"Select session type..."})}),e.jsx(ne,{children:c==null?void 0:c.map(t=>e.jsxs(ie,{value:t.id,children:[t.session_type==="video"?"Video":"Audio"," Reading"]},t.id))})]}),e.jsx("input",{type:"date",min:w(G(new Date),"yyyy-MM-dd"),value:s.date,onChange:t=>l(m=>({...m,date:t.target.value})),className:"w-full px-3 py-2 rounded-lg bg-background border border-border text-foreground text-sm"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"Start time"}),e.jsx("input",{type:"time",value:s.start_time,onChange:t=>l(m=>({...m,start_time:t.target.value})),className:"w-full px-3 py-2 rounded-lg bg-background border border-border text-foreground text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"End time"}),e.jsx("input",{type:"time",value:s.end_time,onChange:t=>l(m=>({...m,end_time:t.target.value})),className:"w-full px-3 py-2 rounded-lg bg-background border border-border text-foreground text-sm"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>i(!1),className:"flex-1",children:"Cancel"}),e.jsx(y,{size:"sm",onClick:j,disabled:h,className:"flex-1 bg-primary text-primary-foreground",children:h?e.jsx(_,{className:"w-4 h-4 animate-spin"}):"Save"})]})]}),x.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground text-sm",children:[e.jsx(q,{className:"w-8 h-8 mx-auto mb-2 opacity-30"}),"No upcoming availability slots"]}):e.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:x.map(t=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 rounded-lg bg-secondary/20 border border-border",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(C,{className:"w-4 h-4 text-primary shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:w(new Date(t.start_time),"EEE, MMM d")}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[w(new Date(t.start_time),"HH:mm")," â ",w(new Date(t.end_time),"HH:mm")]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t.is_booked?e.jsx(v,{className:"bg-primary/20 text-primary border-primary/30 border text-xs",children:"Booked"}):e.jsx(v,{variant:"outline",className:"text-xs text-muted-foreground",children:"Open"}),!t.is_booked&&e.jsx(y,{variant:"ghost",size:"icon",className:"relative w-6 h-6 text-muted-foreground hover:text-destructive before:content-[''] before:absolute before:inset-[-9px] before:cursor-pointer",onClick:()=>O(t),disabled:g===t.id,children:g===t.id?e.jsx(_,{className:"w-3 h-3 animate-spin"}):e.jsx(de,{className:"w-3 h-3"})})]})]},t.id))})]})]})}function ye({sessions:a,onRefresh:c}){const[n,r]=b.useState(null),[d,i]=b.useState(""),[h,u]=b.useState(null),g=(a==null?void 0:a.filter(t=>t.status==="pending").sort((t,m)=>new Date(t.start_time)-new Date(m.start_time)))||[],f=(a==null?void 0:a.filter(t=>t.status==="active"||t.status==="pending"&&A(new Date(t.start_time),new Date)).sort((t,m)=>new Date(t.start_time)-new Date(m.start_time)))||[],s=async t=>{u(t.id+"_confirm");try{await p.entities.OneOnOneSession.update(t.id,{status:"active"}),await p.functions.invoke("notifySessionClient",{session_id:t.id,kind:"confirmed"}),o.success("Session confirmed â client notified"),c()}catch{o.error("Failed to confirm session")}finally{u(null)}},l=async t=>{u(t.id+"_cancel");try{await p.entities.OneOnOneSession.update(t.id,{status:"cancelled"}),o.success("Session cancelled"),c()}catch{o.error("Failed to cancel")}finally{u(null)}},x=async()=>
6{if(!(!d||!n)){u(n.id+"_reschedule");try{const t=new Date(d);await p.entities.OneOnOneSession.update(n.id,{start_time:t.toISOString(),status:"pending"}),await p.functions.invoke("notifySessionClient",{session_id:n.id,kind:"rescheduled",new_start_time:t.toISOString()}),o.success("Session rescheduled â awaiting confirmation"),r(null),i(""),c()}catch{o.error("Failed to reschedule")}finally{u(null)}}},j=t=>({pending:"bg-amber-500/20 text-amber-400 border-amber-500/30",active:"bg-green-500/20 text-green-400 border-green-500/30",completed:"bg-muted text-muted-foreground border-border",cancelled:"bg-destructive/20 text-destructive border-destructive/30"})[t]||"bg-secondary text-foreground border-border",O=({session:t})=>{var m;return e.jsxs("div",{className:"bg-secondary/20 border border-border rounded-lg p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[(m=t.hundredms_room_id)!=null&&m.includes("video")?e.jsx(ce,{className:"w-4 h-4 text-primary shrink-0"}):e.jsx(W,{className:"w-4 h-4 text-primary shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm text-foreground",children:E(t.listener_name,t.listener_email)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Client contact kept private by the platform"})]})]}),e.jsx(v,{className:`${j(t.status)} border text-xs capitalize shrink-0`,children:t.status})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(C,{className:"w-3 h-3"}),t.start_time?w(new Date(t.start_time),"EEE, MMM d · HH:mm"):"Time TBA"]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Rate:"}),e.jsx(z,{amountGbp:t.rate_per_minute||0,className:"font-medium text-foreground"}),e.jsx("span",{children:"/min"})]}),t.status==="pending"&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(y,{size:"sm",className:"flex-1 bg-green-600 hover:bg-green-700 text-white",onClick:()=>s(t),disabled:!!h,children:h===t.id+"_confirm"?e.jsx(_,{className:"w-3 h-3 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"w-3 h-3 mr-1"}),"Confirm"]})}),e.jsxs(y,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>{var R;r(t),i(((R=t.start_time)==null?void 0:R.slice(0,16))||"")},children:[e.jsx(me,{className:"w-3 h-3 mr-1"}),"Reschedule"]}),e.jsx(y,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>l(t),disabled:!!h,children:h===t.id+"_cancel"?e.jsx(_,{className:"w-3 h-3 animate-spin"}):e.jsx(xe,{className:"w-3 h-3"})})]})]})};return e.jsxs(e.Fragment,{children:[e.jsxs(k,{className:"bg-card border-border",children:[e.jsx(P,{className:"pb-3",children:e.jsxs(F,{className:"flex items-center gap-2 font-heading text-lg",children:[e.jsx(M,{className:"w-5 h-5 text-primary"}),"Session Requests",g.length>0&&e.jsxs(v,{className:"bg-amber-500/20 text-amber-400 border-amber-500/30 border text-xs ml-1",children:[g.length," pending"]})]})}),e.jsx(D,{className:"space-y-3",children:(a==null?void 0:a.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground text-sm",children:[e.jsx(M,{className:"w-8 h-8 mx-auto mb-2 opacity-30"}),"No session requests yet"]}):e.jsx("div",{className:"space-y-3 max-h-[500px] overflow-y-auto",children:[...g,...f.filter(t=>t.status!=="pending")].map(t=>e.jsx(O,{session:t},t.id))})})]}),e.jsx(K,{open:!!n,onOpenChange:()=>r(null),children:e.jsxs(L,{className:"bg-card border-border max-w-sm",children:[e.jsxs(V,{children:[e.jsx(U,{className:"font-heading",children:"Reschedule Session"}),e.jsxs(Q,{children:["Choose a new time for ",E(n==null?void 0:n.listener_name,n==null?void 0:n.listener_email),"'s session."]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-foreground mb-1.5 block",children:"New Date & Time"}),e.jsx("input",{type:"datetime-local",value:d,onChange:t=>i(t.target.value),className:"w-full px-3 py-2 rounded-lg bg-background border border-border text-foreground text-sm"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{variant:"outline",onClick:()=>r(null),className:"flex-1",children:"Cancel"}),e.jsx(y,{onClick:x,disabled:!!h,className:"flex-1 bg-primary text-primary-foreground",children:h?e.jsx(_,{className:"w-4 h-4 animate-spin"}):"Confirm"})]})]})]})})]})}const je="https://qtrypzzcjebvfcihiynt.supabase.co/storage/v1/object/public/base44-prod/public/notification-ring.mp3";function Ne({hostEmail:a}){const c=Y(),n=b.useRef(null),r=b.useRef(null);return b.useEffect(()=>{const d=new Audio(je);return d.loop=!0,r.current=d,()=>{try{d.pause()}catch{}r.current=null}},[]),b.useEffect(()=>{if(!a)return;let d=!1;const i=()=>{var s;try{(s=r.current)==null||s.pause()}catch{}},h=()=>{const s=r.current;s&&(s.currentTime=0,s.play().catch(()=>{}),setTimeout(i,3e4))},u=s=>{h(),o.custom(l=>e.jsxs("div",{className:"bg-gray-900 border border-green-600 rounded-xl p-4 shadow-xl w-[320px]",children:[e.jsxs("p",{className:"text-green-400 font-semibold mb-1 flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400 animate-pulse"}
6),s.is_instant?"Incoming reading":"New booking"]}),e.jsxs("p",{className:"text-white text-sm",children:[s.client_name||s.client_email," booked a"," ",s.duration_minutes,"-min reading",s.is_instant?" â starting now.":` on ${s.scheduled_date||"a scheduled date"}${s.scheduled_time?` at ${s.scheduled_time}`:""}.`]}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[s.is_instant&&e.jsx("button",{onClick:()=>{i(),o.dismiss(l),c(`/private-session?session=${s.id}`)},className:"flex-1 bg-green-600 hover:bg-green-700 text-white text-sm font-semibold py-2 rounded-lg transition",children:"Enter Room"}),e.jsx("button",{onClick:()=>{i(),o.dismiss(l)},className:"px-3 text-gray-400 hover:text-gray-200 text-sm transition",children:"Dismiss"})]})]}),{duration:3e4})},g=async()=>{try{const s=await p.entities.PrivateReadingBooking.filter({host_email:a,status:"confirmed"},"-created_date",20);if(d)return;if(!n.current){n.current=new Set(s.map(l=>l.id));return}s.filter(l=>!n.current.has(l.id)).forEach(l=>{n.current.add(l.id),u(l)})}catch{}};g();const f=setInterval(g,15e3);return()=>{d=!0,clearInterval(f),i()}},[a]),null}function Me(){J();const{data:a}=N({queryKey:["me"],queryFn:()=>p.auth.me()}),{data:c=[],refetch:n}=N({queryKey:["my-offers",a==null?void 0:a.email],queryFn:()=>p.entities.OneOnOneOffer.filter({host_email:a.email}),enabled:!!(a!=null&&a.email)}),{data:r=[],refetch:d}=N({queryKey:["my-slots",a==null?void 0:a.email],queryFn:()=>p.entities.AvailabilitySlot.filter({host_email:a.email}),enabled:!!(a!=null&&a.email)}),{data:i=[],refetch:h}=N({queryKey:["my-psychic-sessions",a==null?void 0:a.email],queryFn:()=>p.entities.OneOnOneSession.filter({psychic_email:a.email}),enabled:!!(a!=null&&a.email)}),{data:u=[]}=N({queryKey:["my-reviews",a==null?void 0:a.email],queryFn:()=>p.entities.SessionReview.filter({psychic_email:a.email}),enabled:!!(a!=null&&a.email)}),{data:g}=N({queryKey:["my-wallet",a==null?void 0:a.email],queryFn:async()=>(await p.entities.Wallet.filter({host_email:a.email}))[0]||null,enabled:!!(a!=null&&a.email)}),f=u.length?(u.reduce((x,j)=>x+(j.rating||0),0)/u.length).toFixed(1):null,s=i.filter(x=>x.status==="completed"),l=s.reduce((x,j)=>x+(j.duration_minutes||0),0);return e.jsxs("div",{className:"min-h-screen bg-background p-4 md:p-6",children:[e.jsx(Ne,{hostEmail:a==null?void 0:a.email}),e.jsxs("div",{className:"max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"font-heading text-3xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(X,{className:"w-7 h-7 text-primary"}),"Psychic Dashboard"]}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Manage your readings, rates, and schedule"})]}),a&&e.jsx(v,{variant:"outline",className:"text-sm px-3 py-1",children:a.full_name})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(S,{label:"Wallet Balance",value:e.jsx(z,{amountGbp:(g==null?void 0:g.available_balance)||0}),icon:Z}),e.jsx(S,{label:"Completed Sessions",value:s.length,icon:C}),e.jsx(S,{label:"Total Minutes",value:l,icon:C}),e.jsx(S,{label:"Avg Rating",value:f?`${f} â
`:"â",icon:ee})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"space-y-6 lg:col-span-1",children:[e.jsx(fe,{offers:c,user:a,onRefresh:n}),e.jsx(be,{slots:r,offers:c,user:a,onRefresh:d})]}),e.jsx("div",{className:"lg:col-span-2",children:e.jsx(ye,{sessions:i,onRefresh:h})})]})]})]})}function S({label:a,value:c,icon:n}){return e.jsx(k,{className:"bg-card border-border",children:e.jsxs(D,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(n,{className:"w-4 h-4 text-primary"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a})]}),e.jsx("p",{className:"text-xl font-bold text-foreground font-heading",children:c})]})})}export{Me 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.