1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-2LIJBWOq.js","assets/index-BnV_cV3S.css"])))=>i.map(i=>d[i]); 2import{c as As,i as Be,a2 as ne,j as e,C as O,a as H,b as W,e as K,f as $,B as v,h as Qe,r,L as X,P as Ae,w as Y,v as p,s as b,a0 as st,a1 as Ps,U as Oe,V as $e,W as Re,Y as Ue,Z as we,t as me,a3 as he,g as ce,ac as oe,u as A,bl as Se,bC as Fe,bD as is,bE as ns,b2 as Ve,bF as ls,bb as cs,aN as os,p as Ds,I as Fs,aU as Ze,b1 as Ge,D as He,bG as tt,ad as at,al as rt,_ as ue,a6 as Es,aL as it,aA as We,l as Ts,b5 as nt,b6 as lt,d as Ms,ao as ds,R as ct,T as ms,ap as ot,aK as Me,b7 as dt,E as mt,a5 as ut,J as qs,K as Is,M as ht,N as Bs,O as xt,Q as pt,$ as ft,a4 as gt,a9 as Ls,aa as zs,ab as fe,ah as ge,bH as jt,X as Os,bI as yt,n as us,k as vt,A as Nt,a7 as _t,aM as bt,ag as wt,m as St,o as Ct,q as kt,y as At,ay as Pt,z as Ce,bJ as Dt,F as Ee,G as Ye,H as Ft,bK as Et,bL as Tt}from"./index-2LIJBWOq.js";import{S as hs}from"./shield-check-y4jIiUK7.js";import{C as qe}from"./circle-check-big-CagJY7VN.js";import{E as Ie}from"./external-link-DU82lmg8.js";import{S as xs}from"./shield-x-iVym7qGT.js";import{S as le}from"./shield-4kdzRxWC.js";import{M as Mt}from"./MobileBottomNav-_-xYxjl7.js";import{u as qt}from"./useBottomNavPadding-ecjOvRUi.js";import{S as Z}from"./switch-DaumbRAt.js";import{u as $s}from"./useFeatureFlags-BqWd_2YG.js";import{u as It}from"./useSitterAddonCharges-BmsqGycf.js";import{T as Le}from"./trash-2-BpIIYXYF.js";import{S as xe}from"./save-BTUMDwi1.js";import{p as ps}from"./parse-Us5kSGF0.js";import{g as Bt}from"./geocoding-CK5lr7E2.js";import{D as Lt}from"./DeleteAccountDialog-0Hhgl2tc.js";import{S as zt,I as Ot}from"./ImageCropDialog-CjzoY2sj.js";import{a as $t,p as Rt}from"./photoCapture-CHAgPO3x.js";import{I as fs}from"./image-B-pHC-uG.js";import{P as Ut}from"./PushSettingsDialog-JdH2ozTI.js";import{L as ze}from"./lock-D_N6qKFA.js";import{a as Gt}from"./googleCalendarSync-BJiXZtM4.js";import{R as Yt}from"./refresh-cw-BpYlNNJ8.js";import{L as Vt}from"./link-2-DWYNvCQ2.js";import{C as ke}from"./checkbox-BAcUXGLC.js";import{C as Ht,a as Wt,b as Kt}from"./collapsible-BaUGzLa5.js";import{S as Xt}from"./StripeEmbeddedOnboarding-BuYBaRzL.js";import{W as Rs}from"./wallet-jdfzTL7v.js";import{B as Us}from"./banknote-Drdua-5P.js";import{D as Qt}from"./dog-G3wQVhjm.js";import{A as gs}from"./arrow-right-BgBwMj2g.js";import{C as Ke}from"./circle-help-DkJwyUW1.js";import{U as Xe}from"./user-XpDt6acz.js";import{B as Zt}from"./building-ub-1VTNZ.js";import{R as Jt}from"./RoleSwitcher-B48YuS44.js";import{S as ea}from"./send-BFTzVCK4.js";import{I as sa}from"./info-Dgtyklfj.js";import{R as ta}from"./rotate-ccw-C7n9iHWV.js";import{U as Gs}from"./upload-C8GwlAQI.js";import{A as aa}from"./AppStoreCancellationBanner-CT8sKT1P.js";import{S as ra}from"./SetPasswordCard-DKOf0FsS.js";import{P as ia}from"./pencil-B2OkroFb.js";import{L as na}from"./log-out-CpiHZbSk.js";import{T as js}from"./triangle-alert-Hz9m6Ab9.js";import"./preloadRoutes-CEl9hjdS.js";import"./calendar-days-B00Riqsb.js";import"./alert-dialog-B-xeFh-4.js";import"./alert-D5_j6gUn.js";import"./arrow-right-left-gJRqCYS7.js";/** 3 * @license lucide-react v0.462.0 - ISC 4 * 5 * This source code is licensed under the ISC license. 6 * See the LICENSE file in the root directory of this source tree. 7 */const ys=As("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/** 8 * @license lucide-react v0.462.0 - ISC 9 * 10 * This source code is licensed under the ISC license. 11 * See the LICENSE file in the root directory of this source tree. 12 */const la=As("Unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]);function ca({status:s,verifiedAt:a}
12){const S=Be(),c=a?ne(new Date(a),"MMMM d, yyyy"):null;return s==="passed"?e.jsxs(O,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20 dark:border-amber-800",children:[e.jsxs(H,{children:[e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsx(hs,{className:"w-5 h-5 text-amber-600"}),"Trust & Safety"]}),e.jsx(K,{children:"Your profile is background verified"})]}),e.jsxs($,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 bg-amber-100/50 dark:bg-amber-900/30 rounded-lg",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-amber-100 dark:bg-amber-900/50 flex items-center justify-center",children:e.jsx(hs,{className:"w-6 h-6 text-amber-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-amber-900 dark:text-amber-100",children:"Background Check Verified"}),c&&e.jsxs("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:["Verified on ",c]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(qe,{className:"h-4 w-4 text-green-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm",children:"Your profile displays a verified badge"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(qe,{className:"h-4 w-4 text-green-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm",children:"You appear higher in search results"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(qe,{className:"h-4 w-4 text-green-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm",children:"Pet owners can see you're background verified"})]})]}),e.jsxs(v,{variant:"ghost",size:"sm",className:"text-amber-700 dark:text-amber-300 hover:text-amber-800",onClick:()=>S("/background-check-info"),children:["Learn More",e.jsx(Ie,{className:"h-4 w-4 ml-2"})]})]})]}):s==="failed"?e.jsxs(O,{className:"border-destructive/50 bg-destructive/5",children:[e.jsxs(H,{
12children:[e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsx(xs,{className:"w-5 h-5 text-destructive"}),"Trust & Safety"]}),e.jsx(K,{children:"Background check was not passed"})]}),e.jsxs($,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 bg-destructive/10 rounded-lg",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-destructive/20 flex items-center justify-center",children:e.jsx(xs,{className:"w-6 h-6 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-destructive",children:"Background Check Not Passed"}),c&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Reviewed on ",c]})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"If you believe this is an error, you may submit again for review."}),e.jsxs(v,{variant:"secondary",onClick:()=>window.open("https://mifurbaby.quickapp.pro/forms/28838","_blank","noopener,noreferrer"),children:[e.jsx(le,{className:"h-4 w-4 mr-2"}),"Submit Again",e.jsx(Ie,{className:"h-4 w-4 ml-2"})]})]})]}
12):e.jsxs(O,{children:[e.jsxs(H,{children:[e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsx(le,{className:"w-5 h-5"}),"Trust & Safety"]}),e.jsx(K,{children:"Earn pet parent trust with a verified profile"})]}),e.jsxs($,{className:"space-y-4",children:[e.jsxs("div",{className:"bg-muted p-4 rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(le,{className:"h-4 w-4 text-primary flex-shrink-0 mt-0.5"}),e.jsxs("p",{className:"text-sm",children:["Earn a ",e.jsx("strong",{children:"verified badge"})," on your profile"]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(le,{className:"h-4 w-4 text-primary flex-shrink-0 mt-0.5"}),e.jsxs("p",{className:"text-sm",children:["Verified sitters receive ",e.jsx("strong",{children:"3x more booking requests"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(le,{className:"h-4 w-4 text-primary flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm",children:"Includes national criminal database & sex offender registry checks"})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{children:"$25 one-time fee"})," · Paid directly to verification provider"]}),e.jsxs(v,{variant:"secondary",onClick:()=>window.open("https://mifurbaby.quickapp.pro/forms/28838","_blank","noopener,noreferrer"),children:[e.jsx(le,{className:"h-4 w-4 mr-2"}),"Start Background Check",e.jsx(Ie,{className:"h-4 w-4 ml-2"})]})]})]})}const vs=[{name:"Extended Stay Fee",default_amount:25},{name:"Bath",default_amount:20},{name:"Special Drop-off / Pickup",default_amount:15},{name:"Extra Pet",default_amount:10},{name:"Holiday Surcharge",default_amount:15}];function oa({sitterId:s}){const{addons:a,loading:S,refetch:c}=It(s),{toast:f}=Qe(),[C,F]=r.useState(""),[T,N]=r.useState(""),[j,I]=r.useState(!1),[P,g]=r.useState({});r.useEffect(()=>{const l={};a.forEach(n=>{l[n.id]=n.default_amount>0?n.default_amount.toFixed(2):""}),g(l)},[a]);const w=r.useMemo(()=>new Set(a.map(l=>l.name.toLowerCase())),[a]),B=async(l,n)=>{if(!l.trim()){f({title:"Name required",description:"Give this add-on a name.",variant:"destructive"});return}if(!Number.isFinite(n)||n<=0){f({title:"Amount required",description:"Set a default amount greater than $0.",variant:"destructive"});return}I(!0);try{const{error:t}=await b.from("sitter_addon_charges").insert({sitter_id:s,name:l.trim(),default_amount:n,default_quantity:1,active:!0});if(t)throw t;F(""),N(""),await c()}catch(t){f({title:"Couldn't save",description:t.message,variant:"destructive"})}finally{I(!1)}},k=async(l,n)=>{try{const{error:t}=await b.from("sitter_addon_charges").update(n).eq("id",l.id);if(t)throw t;await c()}catch(t){f({title:"Update failed",description:t.message,variant:"destructive"})}},i=async l=>{try{const{error:n}=await b.from("sitter_addon_charges").delete().eq("id",l.id);if(n)throw n;await c()}catch(n){f({title:"Delete failed",description:n.message,variant:"destructive"})}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Add-on Charges"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Save reusable extra fees (extended stay, bath, holiday surcharge, etc.) and attach them when sending an invoice."})]}),S&&a.length===0?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(X,{className:"w-4 h-4 animate-spin"})," Loading add-onsâ¦"]}):e.jsxs(e.Fragment,{children:[vs.filter(l=>!w.has(l.name.toLowerCase())).length>0&&e.jsxs("div",{className:"rounded-lg border bg-muted/30 p-4 space-y-3",children:[e.jsx("p",{className:"text-sm",children:"Quick start â tap to add a common add-on:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:vs.filter(l=>!w.has(l.name.toLowerCase())).map(l=>e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>B(l.name,l.default_amount),disabled:j,children:[e.jsx(Ae,{className:"w-3.5 h-3.5 mr-1"}),l.name," · $",l.default_amount]},l.name))})]}),a.length>
120&&e.jsx("div",{className:"space-y-2",children:a.map(l=>e.jsxs("div",{className:"relative rounded-lg border bg-card p-3 space-y-2 sm:flex sm:items-center sm:gap-3 sm:space-y-0",children:[e.jsx(Y,{defaultValue:l.name,placeholder:"Add-on name",className:"h-10 sm:flex-1 pr-12 sm:pr-3",onBlur:n=>{const t=n.target.value.trim();t&&t!==l.name&&k(l,{name:t})}}),e.jsxs("div",{className:"relative w-full max-w-[140px] sm:w-32 sm:max-w-none",children:[e.jsx("span",{className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),e.jsx(Y,{type:"text",inputMode:"decimal",value:P[l.id]??"",onChange:n=>{const t=n.target.value.replace(/[^0-9.]/g,"");g(h=>({...h,[l.id]:t}))},onBlur:n=>{const t=parseFloat(n.target.value);Number.isFinite(t)&&t>0&&t!==l.default_amount&&k(l,{default_amount:t})},placeholder:"0.00",className:"h-10 pl-7"})]}),e.jsx(v,{variant:"ghost",size:"icon",onClick:()=>i(l),"aria-label":"Delete add-on",className:"absolute top-2 right-2 h-9 w-9 text-muted-foreground hover:text-destructive sm:static sm:order-last",children:e.jsx(Le,{className:"w-4 h-4"})}),e.jsx("div",{className:"flex items-center justify-between border-t pt-2 sm:border-0 sm:pt-0 sm:w-auto",children:e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[e.jsx(Z,{checked:l.active,onCheckedChange:n=>k(l,{active:n})}),e.jsx("span",{className:`text-xs font-medium ${l.active?"text-foreground":"text-muted-foreground"}`,children:l.active?"Active":"Paused"})]})})]},l.id))})]}),e.jsxs("div",{className:"grid grid-cols-12 gap-2 items-end border rounded-lg p-3 bg-muted/20",children:[e.jsxs("div",{className:"col-span-12 sm:col-span-7 space-y-1",children:[e.jsx(p,{className:"text-xs",children:"New add-on name"}),e.jsx(Y,{placeholder:"e.g. Late pickup fee",value:C,onChange:l=>F(l.target.value)})]}),e.jsxs("div",{className:"col-span-8 sm:col-span-3 space-y-1",children:[e.jsx(p,{className:"text-xs",children:"Default amount"}),e.jsx(Y,{type:"text",inputMode:"decimal",placeholder:"0.00",value:T,onChange:l=>N(l.target.value.replace(/[^0-9.]/g,""))})]}),e.jsx("div",{className:"col-span-4 sm:col-span-2",children:e.jsxs(v,{onClick:()=>B(C,parseFloat(T)),disabled:j||!C.trim()||!T,className:"w-full",children:[e.jsx(Ae,{className:"w-4 h-4 mr-1"})," Add"]})})]})]})}const da=["Walking","Sitting","Drop-In","Overnight","Daycare â Half Day","Daycare â Full Day"],Ns=[15,30,45,60,75,90,105,120,135,150,165,180,240,360,480],_s=s=>{if(s<60)return`${s} min`;if(s%60===0){const c=s/60;return`${c} hour${c===1?"":"s"}`}const a=Math.floor(s/60),S=s%60;return`${a}h ${S}m`},ma=new Set(["Overnight","Daycare","Daycare â Half Day","Daycare â Full Day","Daycare - Half Day","Daycare - Full Day"]),bs=s=>ma.has(s);function ua({userId:s}){const{isFeatureEnabled:a}=$s(),[S,c]=r.useState(!1),[f,C]=r.useState([]),[F,T]=r.useState([]),[N,j]=r.useState({slot_interval_minutes:30,booking_advance_days:30,max_overnight_pets:3,offers_boarding_at_home:!0,offers_inhome_sitting:!0,offers_daycare:!1,max_daycare_pets:3}),[I,P]=r.useState(""),[g,w]=r.useState("30"),[B,k]=r.useState({}),{toast:i}=Qe();r.useEffect(()=>{if(f.length>0){const x={};f.forEach((d,u)=>{x[`std-${u}`]=d.price>0?d.price.toFixed(2):""}),F.forEach((d,u)=>{x[`cst-${u}`]=d.price>0?d.price.toFixed(2):""}),k(d=>({...d,...x}))}},[f.length,F.length]);const l=(x,d)=>{const u=d.replace(/[^0-9.]/g,""),o=u.split("."),_=o.length>2?o[0]+"."+o.slice(1).join(""):u;o.length===2&&o[1].length>2||k(L=>({...L,[x]:_}))},n=(x,d,u)=>{const o=B[x]||"0",_=parseFloat(o)||0,L=_.toFixed(2);k(y=>({...y,[x]:L})),z(d,"price",_)},t=st(),{data:h,isLoading:E}=Ps({queryKey:["business-settings",s],queryFn:async()=>{const[x,d]=await Promise.all([b.from("sitter_services").select("*").eq("sitter_id",s).order("service_name"),b.from("sitter_booking_settings").select("*").eq("sitter_id",s).maybeSingle()]);if(x.error)throw x.error;if(d.error)throw d.error;return{services:x.data||[],settings:d.data}}});r.useEffect(()=>{if(!h)return;const x={Walking:15,Sitting:40,"Drop-In":30,Overnight:50,"Daycare â Half Day":25,"Daycare â Full Day":40},d=[],u=[];
12da.forEach(o=>{const _=h.services.find(L=>L.service_name===o);d.push(_||{service_name:o,price:x[o]||0,default_duration_minutes:30,is_custom:!1,active:!0})}),h.services.forEach(o=>{o.is_custom&&u.push(o)}),C(d),T(u),h.settings&&(j({slot_interval_minutes:h.settings.slot_interval_minutes,booking_advance_days:h.settings.booking_advance_days,max_overnight_pets:h.settings.max_overnight_pets??3,offers_boarding_at_home:h.settings.offers_boarding_at_home??!0,offers_inhome_sitting:h.settings.offers_inhome_sitting??!0,offers_daycare:h.settings.offers_daycare??!1,max_daycare_pets:h.settings.max_daycare_pets??3}),w(h.settings.booking_advance_days.toString()))},[h]);const U=async()=>{c(!0);try{const x=[...f,...F].filter(u=>u.active||u.id);for(const u of x)if(u.id){const{error:o}=await b.from("sitter_services").update({price:u.price,default_duration_minutes:u.default_duration_minutes,active:u.active}).eq("id",u.id);if(o)throw o}else{const{error:o}=await b.from("sitter_services").insert({sitter_id:s,service_name:u.service_name,price:u.price,default_duration_minutes:u.default_duration_minutes,is_custom:u.is_custom,active:u.active});if(o)throw o}const{error:d}=await b.from("sitter_booking_settings").upsert({sitter_id:s,slot_interval_minutes:N.slot_interval_minutes,booking_advance_days:N.booking_advance_days,max_overnight_pets:N.max_overnight_pets,offers_boarding_at_home:N.offers_boarding_at_home,offers_inhome_sitting:N.offers_inhome_sitting,offers_daycare:N.offers_daycare,max_daycare_pets:N.max_daycare_pets},{onConflict:"sitter_id"});if(d)throw d;i({title:"Success",description:"Settings saved successfully"}),t.invalidateQueries({queryKey:["business-settings",s]})}catch(x){i({title:"Error saving settings",description:x.message,variant:"destructive"})}finally{c(!1)}},z=(x,d,u)=>{const o=[...f];o[x]={...o[x],[d]:u},C(o)};return E&&f.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"Standard Services"}),e.jsx("div",{className:"space-y-3 sm:space-y-4",children:f.map((x,d)=>e.jsxs("div",{className:"p-3 sm:p-4 border rounded-lg",children:[e.jsxs("div",{className:"block sm:hidden space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:x.service_name}),e.jsx(Z,{checked:x.active,onCheckedChange:u=>z(d,"active",u)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-xs text-muted-foreground mb-1 block",children:"Price"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),e.jsx(Y,{type:"text",inputMode:"decimal",className:"pl-7 h-9",value:B[`std-${d}`]??x.price.toFixed(2),onChange:u=>l(`std-${d}`,u.target.value),onBlur:()=>n(`std-${d}`,d)})]})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-xs text-muted-foreground mb-1 block",children:"Duration"}),bs(x.service_name)?e.jsx("div",{className:"h-9 flex items-center text-xs text-muted-foreground italic",children:"Set by # of pets"}):e.jsxs(Oe,{value:x.default_duration_minutes.toString(),onValueChange:u=>z(d,"default_duration_minutes",parseInt(u)),children:[e.jsx($e,{className:"h-9",children:e.jsx(Re,{})}),e.jsx(Ue,{children:Ns.map(u=>e.jsx(we,{value:u.toString(),children:_s(u)},u))})]})]})]})]}),e.jsxs("div",{className:"hidden sm:grid sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"Service"}),e.jsx(Y,{value:x.service_name,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"Price ($)"}),e.jsx(Y,{type:"text",inputMode:"decimal",value:B[`std-${d}`]??x.price.toFixed(2),onChange:u=>l(`std-${d}`,u.target.value),onBlur:()=>n(`std-${d}`,d)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"Duration"}),bs(x.service_name)?e.jsx("div",{className:"h-10 flex items-center text-sm text-muted-foreground italic",children:"Set by # of pets"}):e.jsxs(Oe,{value:x.default_duration_minutes.toString(),onValueChange:u=>z(d,"default_duration_minutes",parseInt(u)),children:[e.jsx($e,{children:e.jsx(Re,{})}),e.jsx(Ue,{children:Ns.map(u=>e.jsx(we,{value:u.toString(),children:_s(u)},u))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"Active"}),e.jsx("div",{className:"flex items-center h-10",children:e.jsx(Z,{checked:x.active,onCheckedChange:u=>z(d,"active",u)})})]})]})]},x.service_name))})]}),e.jsx(me,{}),a("custom_services")?e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Custom Services"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Create your own unique service offerings"})]}):e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Custom Services"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create your own unique service offerings"})]}),e.jsx(he,{variant:"secondary",children:"Coming Soon"})]}),e.jsx(me,{}),e.jsx(oa,{sitterId:s}),e.jsx(me,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Booking Settings"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"Time Slot Interval"}),e.jsxs(Oe,{value:N.slot_interval_minutes.toString(),onValueChange:x=>j(d=>({...d,slot_interval_minutes:parseInt(x)})),children:[e.jsx($e,{children:e.jsx(Re,{})}),e.jsxs(Ue,{children:[e.jsx(we,{value:"15",children:"15 minutes"}),e.jsx(we,{value:"30",children:"30 minutes"}),e.jsx(we,{value:"60",children:"60 minutes"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"Advance Booking (days)"}),e.jsx(Y,{type:"text",inputMode:"numeric",pattern:"[0-9]*",value:g,onChange:x=>{const d=x.target.value.replace(/[^0-9]/g,"");w(d)},onBlur:()=>{const x=parseInt(g)||30,d=Math.min(365,Math.max(1,x));w(d.toString()),j(u=>({...u,booking_advance_days:d}))}}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"1-365 days"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"Max Overnight Pets (at your home)"}),e.jsx(Y,{type:"number",min:"1",max:"20",value:N.max_overnight_pets,onChange:x=>j(d=>({...d,max_overnight_pets:parseInt(x.target.value)||3})),disabled:!N.offers_boarding_at_home}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Maximum pets you can board at your home at once"})]}),e.jsxs("div",{className:"md:col-span-2 space-y-4 p-4 border rounded-lg bg-muted/30",children:[e.jsx(p,{className:"text-sm font-medium",children:"Overnight Service Options"}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-2",children:"Choose which overnight options you offer. At least one must be enabled if Overnight service is active."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{htmlFor:"offers_boarding",className:"font-normal",children:"Offer boarding at my home"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Pets stay at your location"})]}),e.jsx(Z,{id:"offers_boarding",checked:N.offers_boarding_at_home,onCheckedChange:x=>{if(!x&&!N.offers_inhome_sitting){i({title:"At least one option required",description:"You must offer at least one overnight option",variant:"destructive"});return}j(d=>({...d,offers_boarding_at_home:x}))}})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{htmlFor:"offers_inhome",className:"font-normal",children:"Offer in-home sitting"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"You stay at the pet owner's home"})]}),e.jsx(Z,{id:"offers_inhome",checked:N.offers_inhome_sitting,onCheckedChange:x=>{if(!x&&!N.offers_boarding_at_home){i({title:"At least one option required",description:"You must offer at least one overnight option",variant:"destructive"});return}j(d=>({...d,offers_inhome_sitting:x}))}})]})]})]}),e.jsxs("div",{className:"md:col-span-2 space-y-4 p-4 border rounded-lg bg-muted/30",children:[e.jsx(p,{className:"text-sm font-medium",children:"Daycare Service Options"}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-2",children:"Single-day care at your home (no overnight). Enable the Daycare â Half Day and/or Daycare â Full Day services above to set pricing."}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{htmlFor:"offers_daycare",className:"font-normal",children:"Offer daycare at my home"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Pets stay at your place for the day"})]}),e.jsx(Z,{id:"offers_daycare",checked:N.offers_daycare,onCheckedChange:x=>j(d=>({...d,offers_daycare:x}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"Max daycare pets at once"}),e.jsx(Y,{type:"number",min:"1",max:"20",value:N.max_daycare_pets,onChange:x=>j(d=>({...d,max_daycare_pets:parseInt(x.target.value)||3})),disabled:!N.offers_daycare}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Maximum pets you can host for daycare at the same time"})]})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(v,{onClick:U,disabled:S,children:S?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary-foreground mr-2"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})})]})}const ws=s=>{try{const a=ps(s,"HH:mm:ss",new Date);return ne(a,"h:mm a")}catch{try{const a=ps(s,"HH:mm",new Date);return ne(a,"h:mm a")}catch{return s}}}
12,Ss=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function ha(){const{user:s}=ce(),[a,S]=r.useState([]),[c,f]=r.useState(!1),[C,F]=r.useState(!0),[T,N]=r.useState(1),[j,I]=r.useState(""),[P,g]=r.useState("09:00"),[w,B]=r.useState("17:00"),k=async()=>{if(s){f(!0);try{const{data:n,error:t}=await b.from("sitter_availability").select("*").eq("sitter_id",s.id).order("day_of_week",{ascending:!0});if(t)throw t;S(n||[])}catch(n){A.error("Failed to load availability"),console.error(n)}finally{f(!1)}}};r.useEffect(()=>{k()},[s]);const i=async()=>{if(s){if(!C&&!j){A.error("Please select a specific date");return}try{const{error:n}=await b.from("sitter_availability").insert({sitter_id:s.id,day_of_week:C?T:null,specific_date:C?null:j,start_time:P,end_time:w,recurring:C});if(n)throw n;A.success("Availability added"),k(),g("09:00"),B("17:00"),I("")}catch(n){A.error(n.message)}}},l=async n=>{try{const{error:t}=await b.from("sitter_availability").delete().eq("id",n);if(t)throw t;A.success("Availability removed"),k()}catch(t){A.error(t.message)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(O,{children:e.jsxs($,{className:"pt-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(p,{htmlFor:"recurring",className:"text-sm font-medium",children:"Recurring Weekly"}),e.jsx(Z,{id:"recurring",checked:C,onCheckedChange:F})]}),C?e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"day",className:"text-sm",children:"Day of Week"}),e.jsx("select",{id:"day",value:T,onChange:n=>N(Number(n.target.value)),className:"w-full p-2 border rounded-md bg-background text-foreground",children:Ss.map((n,t)=>e.jsx("option",{value:t,children:n},n))})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"date",className:"text-sm",children:"Specific Date"}),e.jsx(Y,{id:"date",type:"date",value:j,onChange:n=>I(n.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"start",className:"text-sm",children:"Start Time"}),e.jsx(Y,{id:"start",type:"time",value:P,onChange:n=>g(n.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"end",className:"text-sm",children:"End Time"}),e.jsx(Y,{id:"end",type:"time",value:w,onChange:n=>B(n.target.value)})]})]}),e.jsx(v,{onClick:i,className:"w-full",children:"Add Availability"})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Current Availability"}),c?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."}):a.length===0?e.jsx(O,{children:e.jsxs($,{className:"p-8 text-center",children:[e.jsx(oe,{className:"w-12 h-12 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No availability set"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Add your first availability slot above to get started"})]})}):e.jsx("div",{className:"space-y-2",children:a.map(n=>e.jsx(O,{children:e.jsxs($,{className:"p-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(oe,{className:`w-5 h-5 ${n.recurring?"text-muted-foreground":"text-primary"}`}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:n.recurring?Ss[n.day_of_week]:new Date(n.specific_date).toLocaleDateString()}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[ws(n.start_time)," - ",ws(n.end_time)]})]})]}),e.jsx(v,{variant:"ghost",size:"sm",onClick:()=>l(n.id),className:"hover:bg-destructive/10",children:e.jsx(Le,{className:"w-4 h-4 text-destructive"})})]})},n.id))})]})]})}function xa(){const{user:s}=ce(),[a,S]=r.useState([]),[c,f]=r.useState(!0),[C,F]=r.useState(!1),[T,N]=r.useState(!1),[j,I]=r.useState(""),[P,g]=r.useState(),[w,B]=r.useState("09:00"),[k,i]=r.useState(),[l,n]=r.useState("17:00"),[t,h]=r.useState("");r.useEffect(()=>{s!=null&&s.id&&E()},[s==null?void 0:s.id]),r.useEffect(()=>{P&&!k&&i(P)},[P]);const E=async()=>{if(s!=null&&s.id)try{const{data:o,error:_}=await b.from("sitter_time_blocks").select("*").eq("sitter_id",s.id).order("start_date",{ascending:!0});if(_)throw _;S(o||[])}catch(o){console.error("Failed to fetch time blocks:",o)}finally{f(!1)}},U=async()=>
12{if(!(s!=null&&s.id)||!P||!k)return;h("");const o=ne(P,"yyyy-MM-dd"),_=ne(k,"yyyy-MM-dd");if(_<o||_===o&&l<=w){h("End date/time must be after start date/time");return}F(!0);try{const{error:L}=await b.from("sitter_time_blocks").insert({sitter_id:s.id,title:j.trim()||null,start_date:o,start_time:w+":00",end_date:_,end_time:l+":00"});if(L)throw L;I(""),g(void 0),B("09:00"),i(void 0),n("17:00"),N(!1),await E()}catch(L){console.error("Failed to add time block:",L),h(L.message||"Failed to save")}finally{F(!1)}},z=async o=>{try{const{error:_}=await b.from("sitter_time_blocks").delete().eq("id",o);if(_)throw _;S(L=>L.filter(y=>y.id!==o))}catch(_){console.error("Failed to delete time block:",_)}},x=o=>{const _=ne(new Date(o.start_date+"T00:00:00"),"MMM d, yyyy"),L=ne(new Date(o.end_date+"T00:00:00"),"MMM d, yyyy"),y=d(o.start_time),te=d(o.end_time);return o.start_date===o.end_date?`${_} · ${y} â ${te}`:`${_} ${y} â ${L} ${te}`},d=o=>{const[_,L]=o.split(":"),y=parseInt(_),te=y>=12?"PM":"AM";return`${y===0?12:y>12?y-12:y}:${L} ${te}`},u=a.filter(o=>!Se(new Date(o.end_date+"T23:59:59"),Fe(new Date)));return a.filter(o=>Se(new Date(o.end_date+"T23:59:59"),Fe(new Date))),c?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading time blocks..."}):e.jsxs("div",{className:"space-y-4",children:[u.length===0&&!T&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No time blocks set. Add one to block off time when you're unavailable."}),u.map(o=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-border bg-muted/30 p-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[o.title&&e.jsx("p",{className:"text-sm font-medium truncate",children:o.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:x(o)})]}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 text-destructive hover:text-destructive",onClick:()=>z(o.id),children:e.jsx(Le,{className:"h-4 w-4"})})]},o.id)),T?e.jsxs("div",{className:"space-y-4 rounded-lg border border-border p-4",children:[e.jsxs("div",{children:[e.jsx(p,{htmlFor:"tb-title",className:"text-sm",children:"Label (optional)"}),e.jsx(Y,{id:"tb-title",placeholder:"e.g. Vacation, Doctor appointment",value:j,onChange:o=>I(o.target.value),maxLength:100,className:"mt-1"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Only visible to you â not shown to clients"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-sm",children:"Start Date"}),e.jsxs(is,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(v,{variant:"outline",className:Ve("w-full justify-start text-left font-normal mt-1",!P&&"text-muted-foreground"),children:[e.jsx(oe,{className:"mr-2 h-4 w-4"}),P?ne(P,"MMM d, yyyy"):"Pick date"]})}),e.jsx(ls,{className:"w-auto p-0",align:"start",children:e.jsx(cs,{mode:"single",selected:P,onSelect:o=>{g(o),o&&(!k||Se(k,o))&&i(o)},disabled:o=>Se(o,Fe(new Date)),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-sm",children:"Start Time"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(os,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Y,{type:"time",value:w,onChange:o=>B(o.target.value),className:"pl-9"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-sm",children:"End Date"}),e.jsxs(is,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(v,{variant:"outline",className:Ve("w-full justify-start text-left font-normal mt-1",!k&&"text-muted-foreground"),children:[e.jsx(oe,{className:"mr-2 h-4 w-4"}),k?ne(k,"MMM d, yyyy"):"Pick date"]})}),e.jsx(ls,{className:"w-auto p-0",align:"start",children:e.jsx(cs,{mode:"single",selected:k,onSelect:i,disabled:o=>Se(o,P||Fe(new Date)),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-sm",children:"End Time"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(os,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}
12),e.jsx(Y,{type:"time",value:l,onChange:o=>n(o.target.value),className:"pl-9"})]})]})]}),t&&e.jsx("p",{className:"text-sm text-destructive",children:t}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{onClick:U,disabled:C||!P||!k,className:"flex-1",children:C?"Saving...":"Save Time Block"}),e.jsx(v,{variant:"outline",onClick:()=>N(!1),className:"flex-1",children:"Cancel"})]})]}):e.jsxs(v,{variant:"outline",onClick:()=>N(!0),className:"w-full",children:[e.jsx(Ae,{className:"mr-2 h-4 w-4"}),"Block Time Off"]})]})}const Te=20;function pa(){const{user:s}=ce(),[a,S]=r.useState([]),[c,f]=r.useState(!0),[C,F]=r.useState(!1),[T,N]=r.useState(null),[j,I]=r.useState(null),[P,g]=r.useState("");r.useEffect(()=>{s!=null&&s.id&&w()},[s==null?void 0:s.id]);const w=async()=>{if(s!=null&&s.id)try{const{data:t,error:h}=await b.from("sitter_gallery_photos").select("*").eq("sitter_id",s.id).order("display_order",{ascending:!0});if(h)throw h;S(t||[])}catch(t){A.error("Failed to load gallery photos"),console.error("Error fetching gallery photos:",t)}finally{f(!1)}},B=async()=>{if(s!=null&&s.id){if(a.length>=Te){A.error(`Maximum ${Te} photos allowed`);return}F(!0);try{const t=await $t();if(!t){F(!1);return}const{file:h}=t;if(h.size>10*1024*1024){A.error("Please upload an image smaller than 10MB"),F(!1);return}const E=h.name.split(".").pop()||"jpg",U=`${Date.now()}-${Math.random().toString(36).substring(7)}.${E}`,z=`${s.id}/${U}`,{error:x}=await b.storage.from("sitter_gallery").upload(z,h);if(x)throw x;const{data:{publicUrl:d}}=b.storage.from("sitter_gallery").getPublicUrl(z),u=a.length>0?Math.max(...a.map(L=>L.display_order))+1:0,{data:o,error:_}=await b.from("sitter_gallery_photos").insert({sitter_id:s.id,image_url:d,display_order:u}).select().single();if(_)throw _;S(L=>[...L,o]),A.success("Photo added to gallery!")}catch(t){console.error("Upload error:",t),A.error(t.message||"Failed to upload photo")}finally{F(!1)}}},k=async t=>{if(s!=null&&s.id){N(t.id);try{const h=t.image_url.split("/sitter_gallery/");if(h.length>1){const U=h[1].split("?")[0];await b.storage.from("sitter_gallery").remove([U])}const{error:E}=await b.from("sitter_gallery_photos").delete().eq("id",t.id);if(E)throw E;S(U=>U.filter(z=>z.id!==t.id)),A.success("Photo deleted")}catch(h){console.error("Delete error:",h),A.error("Failed to delete photo")}finally{N(null)}}},i=t=>{I(t.id),g(t.caption||"")},l=async t=>{try{const{error:h}=await b.from("sitter_gallery_photos").update({caption:P||null}).eq("id",t);if(h)throw h;S(E=>E.map(U=>U.id===t?{...U,caption:P||null}:U)),I(null),A.success("Caption updated")}catch{A.error("Failed to update caption")}},n=async(t,h)=>{const E=a.findIndex(d=>d.id===t);if(E===-1)return;const U=h==="up"?E-1:E+1;if(U<0||U>=a.length)return;const z=[...a];[z[E],z[U]]=[z[U],z[E]];const x=z.map((d,u)=>({id:d.id,display_order:u}));S(z.map((d,u)=>({...d,display_order:u})));try{for(const d of x)await b.from("sitter_gallery_photos").update({display_order:d.display_order}).eq("id",d.id)}catch{A.error("Failed to reorder photos"),w()}};return c?e.jsx(O,{children:e.jsx($,{className:"p-8 flex justify-center",children:e.jsx(X,{className:"w-8 h-8 animate-spin text-muted-foreground"})})}):e.jsxs(O,{children:[e.jsx(H,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"w-5 h-5"}),"Photo Gallery"]}),e.jsxs(K,{children:["Add photos to showcase your services and facilities (",a.length,"/",Te,")"]})]}),e.jsx(v,{onClick:B,disabled:C||a.length>=Te,size:"sm",children:C?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ae,{className:"w-4 h-4 mr-2"}),"Add Photo"]})})]})}),e.jsxs($,{children:[a.length===0?e.jsxs("div",{className:"text-center py-12 border-2 border-dashed rounded-lg",children:[e.jsx(fs,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"No photos yet"}),e.jsxs(v,{onClick:B,disabled:C,variant:"outline",children:[e.jsx(Ae,{className:"w-4 h-4 mr-2"}),"Add Your First Photo"]})]}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:a.map((t,h)=>e.jsxs("div",{className:"relative group rounded-lg overflow-hidden border bg-muted",children:[e.jsx("img",{src:Ds(t.image_url,Fs.GALLERY_THUMB),alt:t.caption||"Gallery photo",className:"w-full aspect-square object-cover",loading:"lazy"}),e.jsxs("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors flex items-center justify-center gap-2 opacity-0 group-hover:opacity-100",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[h>0&&e.jsx(v,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:()=>n(t.id,"up"),title:"Move up",children:e.jsx(ys,{className:"w-4 h-4 rotate-90"})}),h<a.length-1&&e.jsx(v,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:()=>n(t.id,"down"),title:"Move down",children:e.jsx(ys,{className:"w-4 h-4 -rotate-90"})})]}),e.jsx(v,{size:"icon",variant:"destructive",className:"h-8 w-8",onClick:()=>k(t),disabled:T===t.id,children:T===t.id?e.jsx(X,{className:"w-4 h-4 animate-spin"}):e.jsx(Le,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"p-2 bg-background",children:j===t.id?e.jsxs("div",{className:"flex gap-1",children:[e.jsx(Y,{value:P,onChange:E=>g(E.target.value),placeholder:"Add caption...",className:"h-8 text-xs",maxLength:100,onKeyDown:E=>
12{E.key==="Enter"&&l(t.id),E.key==="Escape"&&I(null)},autoFocus:!0}),e.jsx(v,{size:"sm",className:"h-8 px-2",onClick:()=>l(t.id),children:"Save"})]}):e.jsx("p",{className:"text-xs text-muted-foreground truncate cursor-pointer hover:text-foreground",onClick:()=>i(t),title:"Click to edit caption",children:t.caption||"Add caption..."})}),h===0&&e.jsx("div",{className:"absolute top-2 left-2 bg-primary text-primary-foreground text-xs px-2 py-1 rounded",children:"Featured"})]},t.id))}),a.length>0&&e.jsx("p",{className:"text-xs text-muted-foreground mt-4",children:"Tip: The first photo will be featured as the main image on your profile. Drag to reorder."})]})]})}function fa(){const s=Be(),{user:a}=ce(),{tier:S}=Ze(),[c,f]=r.useState({enabled:!1,custom_prompt:null,auto_respond_delay_seconds:30,q_unique_selling_points:null,q_discounts_deals:null,q_rules_requirements:null,q_anything_else:null}),[C,F]=r.useState(!0),[T,N]=r.useState(!1),j=S==="plus";r.useEffect(()=>{a!=null&&a.id&&I()},[a==null?void 0:a.id]);const I=async()=>{try{const{data:g,error:w}=await b.from("sitter_ai_settings").select("*").eq("sitter_id",a==null?void 0:a.id).maybeSingle();if(w&&w.code!=="PGRST116")throw w;g&&f({enabled:g.enabled,custom_prompt:g.custom_prompt,auto_respond_delay_seconds:g.auto_respond_delay_seconds,q_unique_selling_points:g.q_unique_selling_points,q_discounts_deals:g.q_discounts_deals,q_rules_requirements:g.q_rules_requirements,q_anything_else:g.q_anything_else})}catch(g){console.error("Error fetching AI settings:",g)}finally{F(!1)}},P=async()=>{if(a!=null&&a.id){N(!0);try{const{error:g}=await b.from("sitter_ai_settings").upsert({sitter_id:a.id,enabled:c.enabled,custom_prompt:c.custom_prompt,auto_respond_delay_seconds:c.auto_respond_delay_seconds,q_unique_selling_points:c.q_unique_selling_points,q_discounts_deals:c.q_discounts_deals,q_rules_requirements:c.q_rules_requirements,q_anything_else:c.q_anything_else},{onConflict:"sitter_id"});if(g)throw g;A.success("Milo settings saved")}catch(g){console.error("Error saving AI settings:",g),A.error("Failed to save settings")}finally{N(!1)}}};return C?e.jsx(O,{children:e.jsx($,{className:"py-8",children:e.jsx("div",{className:"flex items-center justify-center",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})})}
12):j?e.jsxs(O,{className:"overflow-hidden",children:[e.jsxs(H,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ge,{mood:"happy",size:"sm"}),e.jsx(W,{children:"Milo Your AI Assistant"}),e.jsxs(he,{variant:"secondary",className:"ml-2",children:[e.jsx(He,{className:"h-3 w-3 mr-1"}),"Top Dog"]})]}),e.jsx(K,{children:"Let Milo answer common questions from pet parents when you're busy. Milo uses your profile, services, and availability to provide helpful responses."})]}),e.jsxs($,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{htmlFor:"ai-enabled",children:"Enable Milo"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically respond to new messages from pet parents"})]}),e.jsx(Z,{id:"ai-enabled",checked:c.enabled,onCheckedChange:g=>f(w=>({...w,enabled:g})),disabled:!j})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{children:"Response Delay"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[c.auto_respond_delay_seconds," seconds"]})]}),e.jsx(zt,{value:[c.auto_respond_delay_seconds],onValueChange:([g])=>f(w=>({...w,auto_respond_delay_seconds:g})),min:10,max:120,step:10,disabled:!j}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Wait this long before sending an AI response, giving you time to respond personally"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-base font-medium",children:"Tell Milo about your business"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Answer these questions to help Milo respond more accurately on your behalf"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"q-unique",className:"text-sm",children:"What makes you unique as a pet sitter?"}),e.jsx(ue,{id:"q-unique",placeholder:"I specialize in senior dogs, have 10+ years experience, am a certified vet tech...",value:c.q_unique_selling_points||"",onChange:g=>f(w=>({...w,q_unique_selling_points:g.target.value})),rows:3,disabled:!j})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"q-discounts",className:"text-sm",children:"Do you offer any discounts or promotions?"}),e.jsx(ue,{id:"q-discounts",placeholder:"10% off weekly recurring bookings, free meet & greet for first-time clients...",value:c.q_discounts_deals||"",onChange:g=>f(w=>({...w,q_discounts_deals:g.target.value})),rows:3,disabled:!j})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"q-rules",className:"text-sm",children:"What are your rules or requirements?"}),e.jsx(ue,{id:"q-rules",placeholder:"Dogs must be up-to-date on vaccinations, no aggressive dogs, cats must be indoor-only...",value:c.q_rules_requirements||"",onChange:g=>f(w=>({...w,q_rules_requirements:g.target.value})),rows:3,disabled:!j})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"q-anything",className:"text-sm",children:"Anything else pet parents should know?"}),e.jsx(ue,{id:"q-anything",placeholder:"I send photo updates every 2 hours, I have a friendly cat at home, I'm CPR certified for pets...",value:c.q_anything_else||"",onChange:g=>f(w=>({...w,q_anything_else:g.target.value})),rows:3,disabled:!j})]})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-4 space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:"How it works"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1",children:[e.jsx("li",{children:"⢠Milo responds when pet parents message you"}),e.jsx("li",{children:"⢠Responses are clearly marked as from Milo"}),e.jsx("li",{children:"⢠Uses your profile, services, and availability info"}),e.jsx("li",{children:"⢠Rate limited to prevent spam (max 1 response per 2 min)"}),e.jsx("li",{children:"⢠Complex questions are deferred to you personally"})]})]}),e.jsx(v,{onClick:P,disabled:T||!j,className:"w-full",children:T?"Saving...":"Save Settings"})]})]}):e.jsxs(O,{className:"overflow-hidden",children:[e.jsx(H,{className:"bg-gradient-to-r from-primary/10 to-primary/5 border-b",children:e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ge,{mood:"happy",size:"sm"}),e.jsx(ze,{className:"h-3 w-3 absolute -bottom-1 -right-1 text-muted-foreground"})]}),"Milo Your AI Assistant",e.jsxs(he,{variant:"secondary",className:"ml-auto",children:[e.jsx(He,{className:"h-3 w-3 mr-1"}),"Top Dog"]})]})}),e.jsxs($,{className:"py-8",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(Ge,{mood:"happy",size:"lg"})}),e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h3",{className:"text-2xl font-bold mb-2",children:"Meet Milo, Your AI Assistant"}),e.jsx("p",{className:"text-muted-foreground",children:"Milo answers pet parent questions 24/7 â so you can focus on what you love"})]}),e.jsxs("div",{className:"grid gap-4 mb-8 max-w-md mx-auto",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(tt,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Instant Responses"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Reply to inquiries in seconds, even while you're on a walk"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(oe,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Knows Your Schedule"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically shares your availability and pricing"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(at,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Personalized Answers"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uses your profile and preferences to sound just like you"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(rt,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Works While You Sleep"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Capture late-night inquiries before they book elsewhere"})]})]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx(v,{size:"lg",onClick:()=>s("/subscription-plans"),children:"Unlock Milo"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Included with Top Dog plan ⢠Cancel anytime"})]})]})]})}function ga(){const{user:s}=ce(),[a,S]=Es(),[c,f]=r.useState(null),[C,F]=r.useState(!0),[T,N]=r.useState(!1),[j,I]=r.useState(!1),[P,g]=r.useState(!1),[w,B]=r.useState(!1);r.useEffect(()=>{const t=a.get("gcal_connected"),h=a.get("gcal_error");
12if(t==="true")A.success("Google Calendar connected successfully!"),a.delete("gcal_connected"),S(a,{replace:!0}),k();else if(h){const E={missing_params:"Missing authorization parameters",invalid_state:"Invalid authorization state",token_exchange_failed:"Failed to complete authorization",storage_failed:"Failed to save connection",not_configured:"Google Calendar integration not configured",unknown:"An unknown error occurred"};A.error(E[h]||`Connection error: ${h}`),a.delete("gcal_error"),S(a,{replace:!0})}},[a,S]);const k=async()=>{if(s!=null&&s.id)try{const{data:t,error:h}=await b.from("sitter_google_calendar").select("*").eq("sitter_id",s.id).maybeSingle();if(h)throw h;f(t)}catch(t){console.error("Error fetching Google Calendar connection:",t)}finally{F(!1)}};r.useEffect(()=>{k()},[s==null?void 0:s.id]);const i=async()=>{N(!0);try{await We();const{data:t,error:h}=await b.functions.invoke("google-calendar-auth-url",{body:{origin:window.location.origin}});if(h)throw h;if(t!=null&&t.url)window.location.href=t.url;else throw new Error("No authorization URL returned")}catch(t){console.error("Error connecting Google Calendar:",t),A.error(t.message||"Failed to start Google Calendar connection"),N(!1)}},l=async()=>{I(!0);try{await We();const{error:t}=await b.functions.invoke("google-calendar-disconnect");
12if(t)throw t;f(null),A.success("Google Calendar disconnected")}catch(t){console.error("Error disconnecting Google Calendar:",t),A.error(t.message||"Failed to disconnect Google Calendar")}finally{I(!1)}},n=async t=>{if(s!=null&&s.id){g(!0);try{const{error:h}=await b.from("sitter_google_calendar").update({auto_sync_enabled:t,updated_at:new Date().toISOString()}).eq("sitter_id",s.id);if(h)throw h;f(E=>E?{...E,auto_sync_enabled:t}:null),A.success(t?"Auto-sync enabled":"Auto-sync disabled")}catch(h){console.error("Error updating sync settings:",h),A.error("Failed to update settings")}finally{g(!1)}}};return C?e.jsxs(O,{children:[e.jsx(H,{children:e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-5 w-5"}),"Google Calendar"]})}),e.jsx($,{className:"flex items-center justify-center py-6",children:e.jsx(X,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]}):e.jsxs(O,{children:[e.jsxs(H,{children:[e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-5 w-5"}),"Google Calendar"]}),e.jsx(K,{children:"Sync your appointments with Google Calendar to stay organized"})]}),e.jsx($,{className:"space-y-4",children:c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-full bg-green-100 dark:bg-green-900/30",children:e.jsx(qe,{className:"h-5 w-5 text-green-600 dark:text-green-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Connected"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Last updated: ",new Date(c.updated_at).toLocaleDateString()]})]})]}),e.jsx(he,{variant:"secondary",className:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",children:"Active"})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{htmlFor:"auto-sync",className:"text-base",children:"Auto-sync appointments"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically add new appointments to Google Calendar"})]}),e.jsx(Z,{id:"auto-sync",checked:c.auto_sync_enabled??!0,onCheckedChange:n,disabled:P})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"Sync existing appointments"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Push all confirmed appointments to Google Calendar"})]}),e.jsx(v,{variant:"outline",size:"sm",onClick:async()=>{B(!0);try{const t=await Gt();t>0?A.success(`Syncing ${t} appointment${t>1?"s":""} to Google Calendar`):A.info("All appointments are already synced")}catch(t){console.error("Sync failed:",t),A.error("Failed to sync appointments")}finally{B(!1)}},disabled:w,children:w?e.jsx(X,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Yt,{className:"h-4 w-4 mr-1"}),"Sync Now"]})})]})]}),e.jsx("div",{className:"pt-4",children:e.jsx(v,{variant:"outline",onClick:l,disabled:j,className:"w-full text-destructive hover:text-destructive hover:bg-destructive/10",children:j?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-4 w-4 mr-2 animate-spin"}),"Disconnecting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(la,{className:"h-4 w-4 mr-2"}),"Disconnect Google Calendar"]})})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(it,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Not connected"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect to sync appointments automatically"})]})]})}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground",children:"Benefits of connecting:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-2",children:[e.jsx("li",{children:"Appointments automatically added to your calendar"}),e.jsx("li",{children:"Get reminders through Google Calendar"}),e.jsx("li",{children:"See all your appointments in one place"})]})]}),e.jsx(v,{onClick:i,disabled:T,className:"w-full",children:T?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-4 w-4 mr-2 animate-spin"}),"Connecting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Connect Google Calendar"]})})]})})]})}const ja=()=>e.jsxs("div",{className:"bg-gradient-to-r from-green-50 to-blue-50 dark:from-green-950/30 dark:to-blue-950/30 rounded-xl p-5",children:[e.jsx("p",{className:"text-sm font-medium text-center mb-4 text-muted-foreground",children:"How Credit Card Payments Work"}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 text-center",children:[e.jsx("div",{className:"mx-auto w-12 h-12 bg-background rounded-full flex items-center justify-center shadow-sm mb-2 border",children:e.jsx(Qt,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"text-xs font-medium",children:"Pet Parent"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"books & pays"})]}),e.jsx(gs,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"flex-1 text-center",children:[e.jsx("div",{className:"mx-auto w-12 h-12 bg-background rounded-full flex items-center justify-center shadow-sm mb-2 border",children:e.jsx(le,{className:"h-6 w-6 text-green-600"})}),e.jsx("p",{className:"text-xs font-medium",children:"Secure"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"processing"})]}),e.jsx(gs,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"flex-1 text-center",children:[e.jsx("div",{className:"mx-auto w-12 h-12 bg-background rounded-full flex items-center justify-center shadow-sm mb-2 border",children:e.jsx(Us,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"text-xs font-medium",children:"Your Bank"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"in 2-3 days"})]})]})]}),ya=()=>e.jsxs(Ht,{children:[e.jsx(Wt,{asChild:!0,children:e.jsxs(v,{variant:"ghost",className:"w-full justify-between h-auto py-3 text-sm",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4"}),"What info will I need to provide?"]}),e.jsx(ot,{className:"h-4 w-4"})]})}),e.jsx(Kt,{className:"px-4 pb-4",children:e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Xe,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Your name & birthday"}),e.jsx("p",{className:"text-muted-foreground",children:"To verify your identity"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Zt,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Bank account details"}),e.jsx("p",{className:"text-muted-foreground",children:"So we know
12where to send your earnings"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Me,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Last 4 of your SSN"}),e.jsx("p",{className:"text-muted-foreground",children:"Required by law for payments over $600/year"})]})]}),e.jsxs("div",{className:"mt-3 p-3 bg-muted rounded-lg text-xs text-muted-foreground",children:[e.jsx(ze,{className:"h-3 w-3 inline mr-1"}),"This info goes directly to our secure payment partner and is never stored by MiFurBaby."]})]})})]});function va({userId:s}){const[a,S]=r.useState(!1),[c,f]=r.useState(""),[C,F]=r.useState(""),[T,N]=r.useState(!1),[j,I]=r.useState(!1),[P,g]=r.useState(!1),[w,B]=r.useState(!1),[k,i]=r.useState("false"),[l,n]=r.useState(!1),[t,h]=r.useState(!0),[E,U]=r.useState(null),{toast:z}=Qe(),x=!!(c.trim()||C.trim()||P),d=x&&!l,u=E===!0,o=Ts.isNativePlatform(),{isLoading:_}=Ps({queryKey:["payment-integrations",s],queryFn:async()=>{var Q;const[y,te]=await Promise.all([b.from("profiles").select("venmo_link, cashapp_link, pass_fees_to_customer, direct_payment_attestation, auto_charge_enabled, accepts_cash").eq("id",s).maybeSingle(),b.from("sitter_stripe_accounts").select("charges_enabled").eq("sitter_id",s).maybeSingle()]);if(y.error)throw y.error;const D=((Q=te.data)==null?void 0:Q.charges_enabled)===!0;if(U(D),y.data){const je=y.data.venmo_link||"",M=y.data.cashapp_link||"";f(je),F(M),N(je.trim().length>0),I(M.trim().length>0),g(y.data.accepts_cash||!1),i(y.data.pass_fees_to_customer?"true":"false"),n(y.data.direct_payment_attestation||!1),h(D&&y.data.auto_charge_enabled!==!1),D&&B(!0)}return y.data}}),L=async()=>{S(!0);try{const{error:y}=await b.from("profiles").update({venmo_link:c.trim()||null,cashapp_link:C.trim()||null,pass_fees_to_customer:k==="true",direct_payment_attestation:x?l:!1,auto_charge_enabled:t,accepts_cash:P}).eq("id",s);if(y)throw y;z({title:"Success",description:"Payment settings saved successfully"})}catch(y){z({title:"Error saving settings",description:y.message,variant:"destructive"})}finally{S(!1)}};return _&&!c&&!C?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:[e.jsx(Rs,{className:"h-4 w-4"}),"Payment Methods"]}),e.jsx("h2",{className:"text-xl font-semibold",children:"How would you like to accept payments?"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select all that apply."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>g(!P),children:[e.jsx(ke,{id:"cash-method",checked:P,onCheckedChange:y=>g(y===!0)}),e.jsx(Us,{className:"h-5 w-5 text-green-600 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(p,{htmlFor:"cash-method",className:"cursor-pointer font-medium text-sm",children:"Cash"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Accept cash payments in person"})]})]})}),e.jsx("div",{className:"border-t"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>{const y=!T;N(y),y||f("")},children:[e.jsx(ke,{id:"venmo-method",checked:T,onCheckedChange:y=>{N(y===!0),y||f("")}}),e.jsx("img",{src:nt,alt:"Venmo",className:"h-5 w-5 object-contain flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(p,{htmlFor:"venmo-method",className:"cursor-pointer font-medium text-sm",children:"Venmo"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add your Venmo payment link"})]})]}),T&&e.jsxs("div",{className:"pl-11 space-y-1.5",children:[e.jsx(Y,{id:"venmo-link",type:"url",placeholder:"https://venmo.com/u/yourusername",value:c,onChange:y=>f(y.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Open Venmo â Settings â tap your QR code â copy link"})]})]}),e.jsx("div",{className:"border-t"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>{const y=!j;I(y),y||F("")},children:[e.jsx(ke,{id:"cashapp-method",checked:j,onCheckedChange:y=>{I(y===!0),y||F("")}}),e.jsx("img",{src:lt,alt:"Cash App",className:"h-5 w-5 object-contain flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(p,{htmlFor:"cashapp-method",className:"cursor-pointer font-medium text-sm",children:"Cash App"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add your Cash App payment link"})]})]}),j&&e.jsxs("div",{className:"pl-11 space-y-1.5",children:[e.jsx(Y,{id:"cashapp-link",type:"url",placeholder:"https://cash.app/$yourusername",value:C,onChange:y=>F(y.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Open Cash App â tap profile â copy your $cashtag link"})]})]}),e.jsx("div",{className:"border-t"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>B(!w),children:[e.jsx(ke,{id:"cc-method",checked:w,onCheckedChange:y=>B(y===!0)}),e.jsx(Ms,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(p,{htmlFor:"cc-method",className:"cursor-pointer font-medium text-sm",children:"Credit Card"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Accept credit card payments online"})]})]}),w&&e.jsxs("div",{className:"pl-11 space-y-4",children:[e.jsx(ja,{}),E?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-green-50 dark:bg-green-950/50 rounded-lg",children:[e.jsx(ds,{className:"h-5 w-5 text-green-600 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-green-900 dark:text-green-100",children:"Bank account connected!"}),e.jsx("p",{className:"text-xs text-green-700 dark:text-green-300",children:"You're ready to accept credit card payments"})]})]}):o?e.jsx(Na,{}):e.jsx(Xt,{}),e.jsx(ya,{}),e.jsxs("div",{className:"border-t pt-4 space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Credit Card Processing Fee Handling"}),e.jsxs(ct,{value:k,onValueChange:i,children:[e.jsxs("div",{className:"flex items-start space-x-3 p-3 border rounded-lg",children:[e.jsx(ms,{value:"false",id:"sitter-pays"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(p,{htmlFor:"sitter-pays",className:"font-medium cursor-pointer text-sm",children:"I'll pay the fees"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Customers see lower prices, but you receive less after fees"}),k==="false"&&e.jsx("div",{className:"mt-2 text-xs bg-muted p-2 rounded",children:"Example: $100 invoice â Customer pays $100 â You net ~$91.80"})]})]}),e.jsxs("div",{className:"flex items-start space-x-3 p-3 border rounded-lg",children:[e.jsx(ms,{value:"true",id:"customer-pays"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(p,{htmlFor:"customer-pays",className:"font-medium cursor-pointer text-sm",children:"Pass fees to customers"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Your service prices will be displayed with all fees included. Customers see one clear price â no surprise fees at checkout."}),k==="true"&&e.jsxs("div",{className:"mt-2 text-xs bg-muted p-2 rounded space-y-1",children:[e.jsx("p",{children:"Example: You set $100 for a service"}),e.jsx("p",{children:"â Displayed price: ~$108.43 (includes all fees)"}),e.jsx("p",{children:"â ACH bank transfer discount: ~$105.84"}),e.jsx("p",{children:"â You always net $100"})]})]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Card processing fees are capped at actual processing costs per payment network rules."})]}),x&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(p,{htmlFor:"auto-charge",className:Ve("font-medium text-sm",!u&&"text-muted-foreground"),children:"Auto-charge credit card on invoice"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u?"When enabled, we'll automatically charge the customer's saved card when you complete an appointment. When disabled, customers receive an invoice link and can choose to pay via credit card, Venmo, or CashApp.":"Complete Stripe setup above to enable auto-charging customers' saved cards."})]}),e.jsx(Z,{id:"auto-charge",checked:t,onCheckedChange:h,disabled:!u})]}
12),u&&!t&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 mt-2",children:"â ï¸ Customers will receive an invoice link with payment options instead of being auto-charged."})]}),e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"*Standard credit card processing fees apply"}),e.jsxs("div",{className:"flex gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(le,{className:"h-3 w-3"})," Bank-level encryption"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ze,{className:"h-3 w-3"})," PCI compliant"]})]})]})]})]}),x&&e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ds,{className:"h-4 w-4 text-primary mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium text-foreground",children:"You're in control of your payments"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Venmo, Cash App, and cash keep 100% of every dollar in your hands â no platform taking a cut, ever. You collect directly from your clients."}),e.jsx("p",{className:"text-[11px] text-muted-foreground/80 italic",children:"MiFurBaby doesn't process or guarantee these payments â that's by design. Your money goes straight to you."})]})]}),e.jsxs("div",{className:"flex items-start gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(ke,{id:"payment-attestation",checked:l,onCheckedChange:y=>n(y===!0),className:"mt-0.5"}),e.jsx(p,{htmlFor:"payment-attestation",className:"cursor-pointer text-sm",children:"I understand and accept my payment collection responsibilities"})]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[d&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Confirm above that you'll collect payments directly from your clients."}),e.jsx(v,{onClick:L,disabled:a||d,children:a?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"h-4 w-4 mr-2"}),"Save Payment Settings"]})})]})]})}function Na(){const[s,a]=r.useState(!1),S=async()=>{a(!0);try{const{Browser:c}=await dt(async()=>{const{Browser:f}=await import("./index-2LIJBWOq.js").then(C=>C.ek);return{Browser:f}},__vite__mapDeps([0,1]));await c.open({url:"https://mifurbaby.com/stripe-onboarding"})}finally{a(!1)}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set up your bank account to accept credit card payments."}),e.jsxs(v,{onClick:S,disabled:s,className:"w-full",children:[s?e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Ms,{className:"mr-2 h-4 w-4"}),"Connect Your Bank Account â"]})]})}const _a=["Small (under 25 lbs)","Medium (25-50 lbs)","Large (50-100 lbs)","Giant (100+ lbs)"],ba=["Puppy (under 1 yr)","Young (1-3 yrs)","Adult (3-7 yrs)","Senior (7+ yrs)"],wa=["Medication administration","Mobility issues","Anxiety/behavioral","Diabetic care","Post-surgery recovery","Blind/deaf"],Sa=["Low","Medium","High","Very High"],Ca={comfortable_sizes:[],age_specialties:[],special_needs_experience:[],breed_experience:"",max_energy_level:"",years_experience:null,comfortable_with_cats:!1,comfortable_with_multiple_pets:!1};function ka(){const{user:s}=ce(),[a,S]=r.useState(!1),[c,f]=r.useState(Ca),[C,F]=r.useState(!1),[T,N]=r.useState(!1),[j,I]=r.useState(!1);r.useEffect(()=>{s&&(async()=>{const{data:i}=await b.from("sitter_specialties").select("*").eq("sitter_id",s.id).maybeSingle();i&&f({comfortable_sizes:i.comfortable_sizes??[],age_specialties:i.age_specialties??[],special_needs_experience:i.special_needs_experience??[],breed_experience:i.breed_experience??"",max_energy_level:i.max_energy_level??"",years_experience:i.years_experience,comfortable_with_cats:i.comfortable_with_cats??!1,comfortable_with_multiple_pets:i.comfortable_with_multiple_pets??!1}),I(!0)})()},[s]);const P=r.useCallback(()=>{let i=0;const l=8;return c.comfortable_sizes.length>0&&i++,c.age_specialties.length>0&&i++,c.special_needs_experience.length>0&&i++,c.breed_experience&&i++,c.max_energy_level&&i++,c.years_experience!==null&&i++,c.comfortable_with_cats&&i++,c.comfortable_with_multiple_pets&&i++,Math.round(i/l*100)},[c]),g=(i,l)=>{f(n=>{const t=n[i];return{...n,[i]:t.includes(l)?t.filter(h=>h!==l):[...t,l]}}),N(!1)},w=async()=>
12{if(s){F(!0);try{const i={sitter_id:s.id,comfortable_sizes:c.comfortable_sizes,age_specialties:c.age_specialties,special_needs_experience:c.special_needs_experience,breed_experience:c.breed_experience||null,max_energy_level:c.max_energy_level||null,years_experience:c.years_experience,comfortable_with_cats:c.comfortable_with_cats,comfortable_with_multiple_pets:c.comfortable_with_multiple_pets},{error:l}=await b.from("sitter_specialties").upsert(i,{onConflict:"sitter_id"});if(l)throw l;N(!0)}catch(i){console.error("Error saving specialties:",i)}finally{F(!1)}}};if(!j)return null;const B=P(),k=i=>`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors min-h-[44px] ${i?"bg-primary text-primary-foreground border-primary":"bg-muted text-muted-foreground border-border hover:border-primary/50"}`;return e.jsxs(e.Fragment,{children:[e.jsxs(O,{className:"border-primary/20 cursor-pointer hover:border-primary/40 transition-colors",onClick:()=>S(!0),children:[e.jsxs(H,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(He,{className:"w-5 h-5 text-primary"}),e.jsx(W,{className:"text-lg",children:"Stand Out to Pet Parents"})]}),e.jsx(mt,{className:"w-5 h-5 text-muted-foreground"})]}),e.jsx(K,{children:"Share your expertise so the right families can find you faster."})]}),B>0&&e.jsx($,{className:"pt-0",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"Profile completeness"}),e.jsxs("span",{children:[B,"%"]})]}),e.jsx(ut,{value:B,className:"h-2"})]})})]}),e.jsx(qs,{open:a,onOpenChange:S,children:e.jsxs(Is,{fullscreenOnMobile:!0,hideCloseButton:!0,children:[e.jsxs(ht,{children:[e.jsx(Bs,{children:"Stand Out to Pet Parents"}),e.jsx(xt,{children:"Share your expertise so the right families find you."})]}),e.jsxs(pt,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{className:"text-sm font-medium",children:"Comfortable with dog sizes"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:_a.map(i=>e.jsx("button",{type:"button",onClick:()=>g("comfortable_sizes",i),className:k(c.comfortable_sizes.includes(i)),children:i},i))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{className:"text-sm font-medium",children:"Age groups you specialize in"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ba.map(i=>e.jsx("button",{type:"button",onClick:()=>g("age_specialties",i),className:k(c.age_specialties.includes(i)),children:i},i))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{className:"text-sm font-medium",children:"Special needs experience"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:wa.map(i=>e.jsx("button",{type:"button",onClick:()=>g("special_needs_experience",i),className:k(c.special_needs_experience.includes(i)),children:i},i))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{className:"text-sm font-medium",children:"Highest energy level you're comfortable with"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Sa.map(i=>e.jsx("button",{type:"button",onClick:()=>{f(l=>({...l,max_energy_level:l.max_energy_level===i?"":i})),N(!1)},className:k(c.max_energy_level===i),children:i},i))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{className:"text-sm font-medium",children:"Years of pet sitting experience"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[1,2,3,5,10].map(i=>e.jsxs("button",{type:"button",onClick:()=>{f(l=>({...l,years_experience:l.years_experience===i?null:i})),N(!1)},className:k(c.years_experience===i),children:[i,"+ years"]},i))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{className:"text-sm font-medium",children:"Breed experience (optional)"}),e.jsx(ue,{placeholder:"e.g. Golden Retrievers, Bulldogs, German Shepherds...",value:c.breed_experience,onChange:i=>{f(l=>({...l,breed_experience:i.target.value})),N(!1)}
12,className:"min-h-[60px]"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{className:"text-sm font-medium",children:"Comfortable with cats"}),e.jsx(Z,{checked:c.comfortable_with_cats,onCheckedChange:i=>{f(l=>({...l,comfortable_with_cats:i})),N(!1)}})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{className:"text-sm font-medium",children:"Comfortable with multiple pets"}),e.jsx(Z,{checked:c.comfortable_with_multiple_pets,onCheckedChange:i=>{f(l=>({...l,comfortable_with_multiple_pets:i})),N(!1)}})]})]})]}),e.jsx(ft,{children:e.jsx(v,{onClick:w,disabled:C||T,className:"w-full sm:w-auto",children:C?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"w-4 h-4 mr-2 animate-spin"})," Saving..."]}):T?e.jsxs(e.Fragment,{children:[e.jsx(gt,{className:"w-4 h-4 mr-2"})," Saved"]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 mr-2"})," Save Specialties"]})})})]})})]})}const Cs={invites:!1,reminders:!0,invoices:!0,appointments:!0,reviews:!0},Aa=[{key:"invites",label:"New client invites",desc:"Welcome text when you add a new client."},{key:"appointments",label:"Booking confirmations & changes",desc:"When you accept, reschedule, or cancel an appointment (including meet & greets)."},{key:"reminders",label:"Appointment reminders",desc:"24-hour and day-of reminder texts."},{key:"invoices",label:"Invoices & payment links",desc:"Text the payment link when you send an invoice."},{key:"reviews",label:"Review requests",desc:"A polite ask after a completed appointment."}];function Pa(){const{user:s,profile:a,refreshProfile:S}=ce(),[c,f]=r.useState(Cs),[C,F]=r.useState(!1);r.useEffect(()=>{const j=a==null?void 0:a.client_sms_prefs;f({...Cs,...j||{}})},[a]);const T=j=>I=>f(P=>({...P,[j]:I})),N=async()=>{if(s){F(!0);try{const{error:j}=await b.from("profiles").update({client_sms_prefs:c}).eq("id",s.id);if(j)throw j;await S(),A.success("Client communication preferences saved")}catch(j){A.error(j.message||"Failed to save")}finally{F(!1)}}};
12return e.jsxs(O,{children:[e.jsxs(H,{children:[e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsx(ea,{className:"w-5 h-5"}),"Client Communications"]}),e.jsxs(K,{children:["Control which automated texts go to ",e.jsx("strong",{children:"your clients"})," on your behalf."]})]}),e.jsxs($,{className:"space-y-3",children:[Aa.map(j=>e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5 min-w-0",children:[e.jsx(p,{htmlFor:`csms_${j.key}`,className:"text-sm font-medium",children:j.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:j.desc})]}),e.jsx(Z,{id:`csms_${j.key}`,checked:c[j.key],onCheckedChange:T(j.key)})]},j.key)),e.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-muted/50 p-3 text-xs text-muted-foreground",children:[e.jsx(sa,{className:"w-4 h-4 shrink-0 mt-0.5"}),e.jsxs("p",{children:["Most sitters leave these on â automated texts are a big reason clients pay on time and rebook. Clients can also reply ",e.jsx("strong",{children:"STOP"})," any time to opt out."]})]}),e.jsx("div",{className:"pt-2",children:e.jsx(v,{onClick:N,disabled:C,className:"w-full",children:C?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),"Save Communications"]})})})]})]})}const Da=`# Welcome â a few things before we get started 13 14Hi {client_name}! I'm so excited to help care for {pet_names}. Before our first visit, here are a few simple things I like to put in writing so we're on the same page. Nothing tricky â just the basics. 15 16## How cancellations work 17Life happens! If you need to cancel, just give me 24 hours notice and there's no charge. Cancellations inside 24 hours may be billed at half the visit rate so I can hold the time for you. 18 19## Payment 20I'll send an invoice through MiFurBaby after each visit (or weekly for ongoing care). Payment is due within 7 days. 21 22## If something comes up with {pet_names} 23If your pet seems unwell or gets hurt, I'll always try to reach you first. If I can't get a hold of you, you're giving me permission to take them to your vet (or the nearest emergency vet) and approve reasonable care. You'll cover any vet costs. 24 25## Keys, codes, and your home 26Anything you share with me â keys, alarm codes, garage codes â stays private and secure. I only use them for our scheduled visits. 27 28## Photos 29I love sending pup-dates! I may share cute photos of {pet_names} on my social media or website unless you'd rather I didn't â just let me know. 30 31## Either of us can stop anytime 32If this isn't working for either of us, we can cancel future visits anytime. Any visits already completed still get paid. 33 34--- 35 36By typing your name below, you're saying you've read this and you're good with it. Thanks for trusting me with {pet_names}! 37 38**Signed:** {client_name} 39**Date:** {signed_date} 40`,Fa=new Set(["plus","essentials"]),ks="service-agreements",Ea=10*1024*1024,Ta=new Set(["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"]),Ma=[".pdf",".doc",".docx"];function qa(s){return s?s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/1024/1024).toFixed(1)} MB`:""}function Ia(){const{user:s}=ce(),{tier:a}=Ze(),S=Be(),c=Fa.has(a),[f,C]=r.useState(!0),[F,T]=r.useState(!1),[N,j]=r.useState(!1),[I,P]=r.useState("Service Agreement"),[g,w]=r.useState(""),[B,k]=r.useState(null),[i,l]=r.useState(!1),[n,t]=r.useState("markdown"),[h,E]=r.useState(null),[U,z]=r.useState(null),[x,d]=r.useState(null),[u,o]=r.useState(null),[_,L]=r.useState(null),y=r.useRef(null);r.useEffect(()=>{if(!(s!=null&&s.id)||!c){C(!1);return}(async()=>{const{data:M}=await b.from("sitter_service_agreements").select("id, title, body_markdown, version, is_active, source_type, file_storage_path, file_name, file_mime_type, file_size_bytes").eq("sitter_id",s.id).eq("is_active",!0).order("version",{ascending:!1}).limit(1).maybeSingle();if(M){const V=M;j(!0),P(V.title),w(V.body_markdown??""),k(V.version),t(V.source_type||"markdown"),E(V.file_name),z(V.file_size_bytes),d(V.file_mime_type),o(V.file_storage_path)}C(!1)})()},[s==null?void 0:s.id,c]);const te=()=>w(Da),D=M=>{var ie;if(!M)return;const V="."+((ie=M.name.split(".").pop())==null?void 0:ie.toLowerCase());if(!Ta.has(M.type)&&!Ma.includes(V)){alert("Only PDF, DOC, and DOCX files are allowed.");return}if(M.size>Ea){alert("File is too large. Max 10 MB.");return}L(M)},Q=async()=>
40{if(!u)return;const{data:M,error:V}=await b.storage.from(ks).createSignedUrl(u,300);if(V||!(M!=null&&M.signedUrl)){alert("Could not generate preview link.");return}window.open(M.signedUrl,"_blank","noopener")},je=async()=>{var M;if(s!=null&&s.id){if(n==="markdown"){if(!g.trim()||g.trim().length<50){alert("Agreement body is too short. Add some content or load the template.");return}}else if(!_&&!u){alert("Please upload a PDF, DOC, or DOCX file.");return}T(!0);try{const V=(B??0)+1;let ie=u,ye=h,ve=x,Ne=U;if(n==="upload"&&_){const pe=((M=_.name.split(".").pop())==null?void 0:M.toLowerCase())||"bin",de=`${s.id}/v${V}-${Date.now()}.${pe}`,{error:ae}=await b.storage.from(ks).upload(de,_,{cacheControl:"3600",upsert:!1,contentType:_.type||void 0});if(ae)throw ae;ie=de,ye=_.name,ve=_.type||(pe==="pdf"?"application/pdf":"application/octet-stream"),Ne=_.size}await b.from("sitter_service_agreements").update({is_active:!1}).eq("sitter_id",s.id).eq("is_active",!0);const re={sitter_id:s.id,version:V,title:I,is_active:N,source_type:n};n==="markdown"?re.body_markdown=g:(re.file_storage_path=ie,re.file_name=ye,re.file_mime_type=ve,re.file_size_bytes=Ne);const{error:_e}=await b.from("sitter_service_agreements").insert(re);if(_e)throw _e;k(V),n==="upload"&&(o(ie),E(ye),d(ve),z(Ne),L(null))}catch(V){alert(V.message||"Could not save agreement.")}finally{T(!1)}}};
40return c?e.jsxs(O,{children:[e.jsxs(H,{children:[e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(Me,{className:"h-5 w-5"}),"Service Agreement"]}),e.jsx(K,{children:"A friendly one-pager your clients sign once â covers cancellations, vet emergencies, and how you handle keys."})]}),e.jsx($,{className:"space-y-4",children:f?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(X,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:"Require new clients to sign"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"When on, the signing link is included in client invites and the booking flow prompts you to send it."})]}),e.jsx(Z,{checked:N,onCheckedChange:j})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"agreement-title",children:"Title"}),e.jsx(Y,{id:"agreement-title",value:I,onChange:M=>P(M.target.value),maxLength:100})]}),e.jsxs(Ls,{value:n,onValueChange:M=>t(M),children:[e.jsxs(zs,{className:"grid grid-cols-2 w-full",children:[e.jsx(fe,{value:"markdown",children:"Write text"}),e.jsx(fe,{value:"upload",children:"Upload a file"})]}),e.jsxs(ge,{value:"markdown",className:"space-y-2 pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{htmlFor:"agreement-body",children:"Agreement text (Markdown)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(v,{type:"button",variant:"ghost",size:"sm",onClick:te,className:"gap-1",children:[e.jsx(ta,{className:"h-3.5 w-3.5"})," Load template"]}),e.jsxs(v,{type:"button",variant:"ghost",size:"sm",onClick:()=>l(!0),className:"gap-1",disabled:!g,children:[e.jsx(jt,{className:"h-3.5 w-3.5"})," Preview"]})]})]}),e.jsx(ue,{id:"agreement-body",value:g,onChange:M=>w(M.target.value),rows:14,placeholder:"Click 'Load template' for a starting point, then edit to fit your business.",className:"font-mono text-xs"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Merge fields rendered at signing: ",e.jsx("code",{children:"{sitter_business_name}"}),", ",e.jsx("code",{children:"{client_name}"}),", ",e.jsx("code",{children:"{pet_names}"}),", ",e.jsx("code",{children:"{signed_date}"}),"."]})]}),e.jsxs(ge,{value:"upload",className:"space-y-3 pt-4",children:[(u||_)&&e.jsxs("div",{className:"rounded-md border bg-muted/40 p-3 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2 min-w-0",children:[e.jsx(Me,{className:"h-5 w-5 text-primary mt-0.5 shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[_?_.name:h,_&&e.jsx("span",{className:"ml-2 text-xs text-amber-600",children:"(unsaved)"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:qa(_?_.size:U)})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[u&&!_&&e.jsxs(v,{type:"button",variant:"ghost",size:"sm",onClick:Q,className:"gap-1",children:[e.jsx(Ie,{className:"h-3.5 w-3.5"})," Preview"]}),_&&e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:()=>L(null),children:e.jsx(Os,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{ref:y,type:"file",accept:".pdf,.doc,.docx,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",className:"hidden",onChange:M=>{var V;return D(((V=M.target.files)==null?void 0:V[0])??null)}}),e.jsxs(v,{type:"button",variant:"outline",onClick:()=>{var M;return(M=y.current)==null?void 0:M.click()},className:"gap-2",children:[e.jsx(Gs,{className:"h-4 w-4"}),u||_?"Replace file":"Choose file"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"PDF, DOC, or DOCX · Max 10 MB"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Merge fields don't apply to uploaded files â clients sign the document as-is."})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:B?`Version ${B} active`:"Not saved yet"}),e.jsxs(v,{onClick:je,disabled:F,className:"gap-2",children:[F?e.jsx(X,{className:"h-4 w-4 animate-spin"}):e.jsx(xe,{className:"h-4 w-4"}),"Save"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground border-t pt-3",children:"This is a starter template â not legal advice. We recommend reviewing it with a local attorney before requiring signatures."})]})}),e.jsx(qs,{open:i,onOpenChange:l,children:e.jsxs(Is,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsx(yt,{children:e.jsx(Bs,{children:I})}),e.jsx("div",{className:"prose prose-sm max-w-none whitespace-pre-wrap",children:g})]})})]}
40):e.jsxs(O,{children:[e.jsxs(H,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(Me,{className:"h-5 w-5"}),"Service Agreement"]}),e.jsxs(he,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(ze,{className:"h-3 w-3"})," Top Dog"]})]}),e.jsx(K,{children:"Have new clients sign your policies once â covering cancellation, payment, key handling, vet authorization, and liability."})]}),e.jsx($,{children:e.jsx(v,{onClick:()=>S("/subscription-plans"),children:"Upgrade to Top Dog"})})]})}const Ba=[{value:"America/New_York",label:"Eastern Time (ET)"},{value:"America/Chicago",label:"Central Time (CT)"},{value:"America/Denver",label:"Mountain Time (MT)"},{value:"America/Los_Angeles",label:"Pacific Time (PT)"},{value:"America/Anchorage",label:"Alaska Time (AKT)"},{value:"Pacific/Honolulu",label:"Hawaii Time (HT)"}];function Mr(){const{user:s,profile:a,refreshProfile:S,signOut:c}=ce(),{subscription:f,tier:C}=Ze(),{isFeatureEnabled:F}=$s(),T=Be(),[N]=Es(),j=qt(),[I,P]=r.useState(!1),[g,w]=r.useState(!1),[B,k]=r.useState(!1),[i,l]=r.useState(!1),[n,t]=r.useState(null),[h,E]=r.useState(!1),[U,z]=r.useState(""),[x,d]=r.useState(!1),[u,o]=r.useState(""),[_,L]=r.useState(!1),[y,te]=r.useState(null),[D,Q]=r.useState({full_name:"",email:"",phone_number:"",phone_country_code:"+1",bio:"",address:"",city:"",state:"",zip_code:"",country:"USA",timezone:"America/New_York",notification_sms:!1,notification_push:!0}),[je,M]=r.useState("prompt"),[V,ie]=r.useState(!1),[ye,ve]=r.useState(""),[Ne,re]=r.useState(!1),[_e,pe]=r.useState(!1),[de,ae]=r.useState("idle"),[Je,J]=r.useState("");r.useEffect(()=>{if(a){const m=[a.address,a.city,a.state,a.zip_code].filter(Boolean).join(", ");Q({full_name:a.full_name||"",email:a.email||"",phone_number:vt(a.phone_number),phone_country_code:us(a.phone_country_code),bio:a.bio||"",address:a.address||"",city:a.city||"",state:a.state||"",zip_code:a.zip_code||"",country:a.country||"USA",timezone:a.timezone||"America/New_York",notification_sms:a.notification_sms??!1,notification_push:a.notification_push??!0}),z(m),o(a.business_name||""),t(a.avatar_url?`${a.avatar_url}?t=${Date.now()}`:null),(async()=>{if(Ce()){const R=await Ee(),G=!!(a!=null&&a.push_token),ee=R==="granted"&&G;Q(se=>({...se,notification_push:ee})),M(R)}})()}},[a]),r.useEffect(()=>{if(!Ts.isNativePlatform())return;const m=async R=>{if(R.isActive){const G=await Ee();if(M(G),_e&&G==="granted"&&(s!=null&&s.id)){ae("registering"),J("Connecting to notification service...");const ee=await Ye(s.id);ee.token?(Q(se=>({...se,notification_push:!0})),ae("success"),J("Connected! Push notifications enabled."),pe(!1),await S()):(ae("error"),ee.error==="firebase_not_configured"?J("Notification service not configured. Please reinstall after the next app update."):J(ee.errorMessage||"Could not connect. Try the retry button below."))}}},q=Nt.addListener("appStateChange",m);return()=>{q.then(R=>R.remove())}},[_e,s==null?void 0:s.id,S]);const Pe=m=>{const{name:q,value:R}=m.target;Q(G=>({...G,[q]:R}))},Ys=m=>{m.lat&&m.lon?te({lat:parseFloat(m.lat),lon:parseFloat(m.lon)}):te(null),Q(q=>{var R,G,ee,se,be,De;return{...q,address:m.display_name,city:((R=m.address)==null?void 0:R.city)||((G=m.address)==null?void 0:G.town)||((ee=m.address)==null?void 0:ee.village)||q.city,state:((se=m.address)==null?void 0:se.state)||q.state,zip_code:((be=m.address)==null?void 0:be.postcode)||q.zip_code,country:((De=m.address)==null?void 0:De.country)||q.country}})},Vs=async m=>{if(!m){Q(G=>({...G,notification_push:!1}));return}if(!Ce()||!(s!=null&&s.id)){Ce()||Q(G=>({...G,notification_push:!0}));return}if(await Ee()==="denied"){pe(!0),J("After enabling in Settings, return here to complete setup."),re(!0);return}ae("registering"),J("Connecting to notification service...");const R=await Ye(s.id);R.token?(M("granted"),Q(G=>({...G,notification_push:!0})),ae("success"),J("Connected! Push notifications enabled."),pe(!1),await S()):(ae("error"),R.error==="firebase_not_configured"?J("Notification service not configured. Please reinstall after the next app update."):J(R.errorMessage||"Could not connect. Try again or restart the app."))},Hs=async()=>
40{if(!(s!=null&&s.id)||!Ce())return;if(await Ee()!=="granted"){J("Please enable notifications in your device Settings first."),re(!0);return}ae("registering"),J("Retrying connection...");const q=await Ye(s.id);q.token?(M("granted"),Q(R=>({...R,notification_push:!0})),ae("success"),J("Connected! Push notifications enabled."),await S()):(ae("error"),q.error==="firebase_not_configured"?J("Notification service not configured. Please reinstall after the next app update."):J(q.errorMessage||"Still could not connect. Please restart the app and try again."))},es=async(m,q)=>{if(m==="notification_push"){await Vs(q);return}Q(R=>({...R,[m]:q}))},Ws=async()=>{if(s)try{const m=await Rt();if(!m)return;if(m.file.size>5*1024*1024){A.error("Please upload an image smaller than 5MB");return}ve(m.dataUrl),ie(!0)}catch(m){A.error(m.message||"Failed to select photo")}},Ks=async(m,q)=>{var R;if(s){E(!0);try{if(n){const rs=(R=n.split("/").pop())==null?void 0:R.split("?")[0];rs&&await b.storage.from("avatars").remove([`${s.id}/${rs}`])}const G=`${Math.random()}.jpg`,ee=`${s.id}/${G}`,{error:se}=await b.storage.from("avatars").upload(ee,m);if(se)throw se;const{data:{publicUrl:be}}=b.storage.from("avatars").getPublicUrl(ee),De=`${be}?t=${Date.now()}`,{error:as}=await b.from("profiles").update({avatar_url:be}).eq("id",s.id);if(as)throw as;t(De),await S(),URL.revokeObjectURL(q),A.success("Avatar updated!")}catch(G){A.error(G.message)}finally{E(!1)}}},Xs=async()=>{if(!(!s||!n)){E(!0);try{const m=n.split("/").pop();m&&await b.storage.from("avatars").remove([`${s.id}/${m}`]);const{error:q}=await b.from("profiles").update({avatar_url:null}).eq("id",s.id);if(q)throw q;t(null),await S(),A.success("Avatar removed")}catch(m){A.error(m.message)}finally{E(!1)}}},Qs=async m=>{if(m.preventDefault(),!!s){P(!0);try{const q=[D.address,D.city,D.state,D.zip_code].filter(Boolean).join(", "),R=q!==U&&D.address.length>=3,G={full_name:D.full_name,phone_number:Ft(D.phone_number,D.phone_country_code),phone_country_code:us(D.phone_country_code),bio:D.bio,address:D.address,city:D.city,state:D.state,zip_code:D.zip_code,country:D.country,timezone:D.timezone,notification_sms:D.notification_sms,notification_push:D.notification_push};if(R&&y)G.latitude=y.lat,G.longitude=y.lon;else if(R){const se=await Bt(D.address,s.id);se&&(G.latitude=se.latitude,G.longitude=se.longitude)}const{error:ee}=await b.from("profiles").update(G).eq("id",s.id);if(ee)throw ee;z(q),te(null),await S(),A.success(R?"Profile and location updated successfully!":"Profile updated!")}catch(q){A.error(q.message)}finally{P(!1)}}},[ss,ts]=r.useState(""),Zs=async()=>{k(!0),ts("");try{await We();const{data:m,error:q}=await b.functions.invoke("customer-portal");if(q)throw q;if(m!=null&&m.error)throw new Error(m.error);m!=null&&m.url&&window.open(m.url,"_blank")}catch(m){ts((m==null?void 0:m.message)||"Failed to open billing portal. Please try again.")}finally{k(!1)}},Js=async()=>{if(s!=null&&s.id){L(!0);try{const{error:m}=await b.from("profiles").update({business_name:u}).eq("id",s.id);if(m)throw m;A.success("Business name updated!"),d(!1)}catch(m){A.error(m.message)}finally{L(!1)}}},et=()=>{o((a==null?void 0:a.business_name)||""),d(!1)};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(_t,{}),e.jsx(Ot,{open:V,onOpenChange:ie,imageSrc:ye,onCropComplete:Ks}),e.jsx(Ut,{open:Ne,onOpenChange:re}),e.jsxs("main",{className:`container mx-auto pt-nav-sitter px-4 md:px-6 ${j}`,children:[e.jsx("div",{className:"mb-6",children:e.jsx("h1",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:"Settings"})}),e.jsxs(Ls,{defaultValue:N.get("tab")||"profile",className:"space-y-6",children:[e.jsxs(zs,{className:"grid w-full grid-cols-4",children:[e.jsxs(fe,{value:"profile",className:"gap-2",children:[e.jsx(Xe,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"My Profile"})]}),e.jsxs(fe,{value:"services",className:"gap-2",children:[e.jsx(bt,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Services & Scheduling"})]}),e.jsxs(fe,{value:"payments",className:"gap-2",children:[e.jsx(Rs,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Payments & Tools"})]}),e.jsxs(fe,{value:"settings",className:"gap-2",children:[e.jsx(wt,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Settings"})]})]}),e.jsxs(ge,{value:"profile",className:"space-y-6",children:[e.jsxs(O,{children:[e.jsxs(H,{
40children:[e.jsx(W,{children:"Personal Information"}),e.jsx(K,{children:"Your public profile details"})]}),e.jsx($,{children:e.jsxs("form",{onSubmit:Qs,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Profile Picture"}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4 sm:gap-6",children:[e.jsx(St,{className:"w-24 h-24 shrink-0",children:n?e.jsx(Ct,{src:Ds(n,Fs.AVATAR_LG),alt:D.full_name}):e.jsx(kt,{className:"bg-primary/10 text-primary text-2xl",children:D.full_name.split(" ").map(m=>m[0]).join("")})}),e.jsxs("div",{className:"flex flex-col gap-2 w-full sm:w-auto",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(v,{type:"button",variant:"outline",size:"sm",disabled:h,onClick:Ws,children:h?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Gs,{className:"w-4 h-4 mr-2"}),"Upload Photo"]})}),n&&e.jsxs(v,{type:"button",variant:"ghost",size:"sm",disabled:h,onClick:Xs,children:[e.jsx(Os,{className:"w-4 h-4 mr-2"}),"Remove"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"JPG, PNG or WEBP. Max 5MB."})]})]})]}),e.jsx(me,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{children:"Business Name"}),!x&&e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(!0),className:"h-8 px-2",children:e.jsx(ia,{className:"h-4 w-4"})})]}),x?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Y,{value:u,onChange:m=>o(m.target.value),placeholder:"Enter your business name",disabled:_}),e.jsx(v,{type:"button",size:"sm",onClick:Js,disabled:_,children:_?e.jsx(X,{className:"h-4 w-4 animate-spin"}):"Save"}),e.jsx(v,{type:"button",size:"sm",variant:"ghost",onClick:et,disabled:_,children:"Cancel"})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:(a==null?void 0:a.business_name)||"Not set"})]}),e.jsx(me,{}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"full_name",children:"Full Name"}),e.jsx(Y,{id:"full_name",name:"full_name",value:D.full_name,onChange:Pe,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"email",children:"Email"}),e.jsx(Y,{id:"email",name:"email",type:"email",value:D.email,disabled:!0,className:"bg-muted"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"phone_country_code",children:"Country Code"}),e.jsx(Y,{id:"phone_country_code",name:"phone_country_code",value:D.phone_country_code,onChange:Pe,placeholder:"+1"})]}),e.jsxs("div",{className:"space-y-2 md:col-span-2",children:[e.jsx(p,{htmlFor:"phone_number",children:"Phone Number"}),e.jsx(Y,{id:"phone_number",name:"phone_number",value:D.phone_number,onChange:Pe,placeholder:"(555) 123-4567"})]})]}),e.jsx(me,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"About Me"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"bio",children:"Bio"}),e.jsx(ue,{id:"bio",name:"bio",value:D.bio,onChange:Pe,placeholder:"Tell pet parents about yourself, your experience, and why you love caring for pets...",rows:5,maxLength:1e3}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This will be displayed on your public profile. ",D.bio.length,"/1000 characters"]})]})]}),e.jsx(me,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Address"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"address",children:"Street Address"}),e.jsx(At,{value:D.address,onChange:m=>Q(q=>({...q,address:m})),onSelect:Ys,placeholder:"Enter zip code or start typing address",maxLength:200}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Start typing to see address suggestions. City, state, and zip will be saved automatically."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"timezone",children:"Timezone"}),e.jsx("select",{id:"timezone",value:D.timezone,onChange:m=>Q(q=>({...q,timezone:m.target.value})),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm r
40ing-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:Ba.map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for scheduling appointments and reminders"})]})]}),e.jsx(v,{type:"submit",disabled:I,className:"w-full",children:I?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),"Save Profile"]})})]})})]}),e.jsx(pa,{})]}),e.jsxs(ge,{value:"services",className:"space-y-6",children:[F("matching_algorithm_v1")&&e.jsx(ka,{}),e.jsxs(O,{children:[e.jsxs(H,{children:[e.jsx(W,{children:"Availability"}),e.jsx(K,{children:"Set your weekly schedule and specific dates"})]}),e.jsx($,{children:e.jsx(ha,{})})]}),e.jsxs(O,{children:[e.jsxs(H,{children:[e.jsx(W,{children:"Time Off"}),e.jsx(K,{children:"Block off dates or times when you're unavailable"})]}),e.jsx($,{children:e.jsx(xa,{})})]}
40),e.jsxs(O,{children:[e.jsxs(H,{children:[e.jsx(W,{children:"Services & Pricing"}),e.jsx(K,{children:"Configure your services and booking settings"})]}),e.jsx($,{children:(s==null?void 0:s.id)&&e.jsx(ua,{userId:s.id})})]}),e.jsx(Ia,{}),F("google_calendar_sync")?e.jsx(ga,{}):e.jsx(O,{children:e.jsxs(H,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(oe,{className:"h-5 w-5"}),"Google Calendar"]}),e.jsx(he,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),e.jsx(K,{className:"text-sm",children:"Sync your appointments automatically - launching soon!"})]})})]}),e.jsxs(ge,{value:"payments",className:"space-y-6",children:[(s==null?void 0:s.id)&&e.jsx(va,{userId:s.id}),F("ai_auto_responder")&&e.jsx(fa,{})]}),e.jsxs(ge,{value:"settings",className:"space-y-6",children:[e.jsxs(O,{children:[e.jsxs(H,{children:[e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsx(Pt,{className:"w-5 h-5"}),"Notifications"]}),e.jsx(K,{children:"Choose how you want to be notified"})]}),e.jsxs($,{className:"space-y-3",children:[Ce()&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{htmlFor:"notification_push",className:"text-sm",children:"Push notifications (this device)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Receive instant alerts when app is closed"})]}),e.jsx(Z,{id:"notification_push",checked:D.notification_push,onCheckedChange:m=>es("notification_push",m),disabled:de==="registering"})]}),de==="registering"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"â³ Connecting..."}),de==="error"&&Je&&e.jsx("p",{className:"text-xs text-destructive",children:Je}),de==="error"&&e.jsx(v,{type:"button",variant:"link",size:"sm",className:"h-auto p-0 text-xs text-primary",onClick:Hs,disabled:!1,children:"â» Retry connecting this device"})]}),e.jsxs("div",{className:"rounded-lg border-2 border-primary/20 bg-primary/5 p-2.5 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{htmlFor:"notification_sms",className:"text-sm font-medium",children:"SMS reminders & updates"}),e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-2 py-0.5 rounded-full font-medium",children:"Recommended"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Get optional reminders about upcoming appointments"})]}),e.jsx(Z,{id:"notification_sms",checked:D.notification_sms,onCheckedChange:m=>es("notification_sms",m)})]}),e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Important updates like confirmations and payments are always sent."})]}),e.jsx("div",{className:"pt-3",children:e.jsx(v,{onClick:async()=>{if(s){w(!0);try{const{error:m}=await b.from("profiles").update({notification_sms:D.notification_sms,notification_push:D.notification_push}).eq("id",s.id);if(m)throw m;await S(),A.success("Notification preferences saved!")}catch(m){A.error(m.message)}finally{w(!1)}}},disabled:g,className:"w-full",children:g?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),"Save Notifications"]})})})]})]}),e.jsx(Pa,{}),e.jsx(La,{}),e.jsx(ca,{status:a==null?void 0:a.background_check_status,verifiedAt:a==null?void 0:a.background_check_verified_at}),e.jsx(aa,{subscription:f}
40),f&&e.jsxs(O,{children:[e.jsxs(H,{children:[e.jsx(W,{children:"Subscription"}),e.jsx(K,{children:"Your current plan and billing"})]}),e.jsx($,{children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-4 border rounded-lg gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"font-semibold",children:[Dt(C)," Plan"]}),e.jsx(he,{variant:C==="free"?"secondary":"default",children:f.status})]}),f.billing_period&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Billed ",f.billing_period,f.current_period_end&&e.jsxs(e.Fragment,{children:[" ⢠Next billing: ",new Date(f.current_period_end).toLocaleDateString()]})]})]}),e.jsx("div",{className:"flex flex-col sm:flex-row gap-2",children:C==="free"?e.jsx(v,{onClick:()=>T("/subscription-plans"),className:"w-full sm:w-auto",children:"Upgrade Plan"}):e.jsxs(e.Fragment,{children:[e.jsx(v,{onClick:()=>T("/subscription-plans"),className:"w-full sm:w-auto",children:"Change Plan"}),f.purchase_source==="stripe"?e.jsxs(e.Fragment,{children:[e.jsx(v,{variant:"outline",onClick:Zs,disabled:B,className:"w-full sm:w-auto",children:B?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"w-4 h-4 mr-2 animate-spin"}),"Loading..."]}):"Manage Billing"}),ss&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:ss})]}):f.purchase_source==="revenuecat_ios"?e.jsx(v,{variant:"outline",onClick:()=>window.open("itms-apps://apps.apple.com/account/subscriptions","_blank"),className:"w-full sm:w-auto",children:"Manage in App Store"}):f.purchase_source==="revenuecat_android"?e.jsx(v,{variant:"outline",onClick:()=>window.open("https://play.google.com/store/account/subscriptions","_blank"),className:"w-full sm:w-auto",children:"Manage in Play Store"}):null]})})]})})]}
40),e.jsxs(O,{children:[e.jsxs(H,{children:[e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsx(Xe,{className:"w-5 h-5"}),"Switch Account Type"]}),e.jsx(K,{children:"Use MiFurBaby as a Pet Parent"})]}),e.jsx($,{children:e.jsx(Jt,{targetRole:"pet_owner"})})]}),e.jsxs(O,{children:[e.jsx(H,{children:e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsx(Ke,{className:"w-5 h-5"}),"Support"]})}),e.jsxs($,{className:"space-y-4",children:[e.jsxs(v,{variant:"outline",onClick:()=>T("/support"),className:"w-full",children:[e.jsx(Ke,{className:"w-4 h-4 mr-2"}),"Support & Help"]}),e.jsxs(v,{variant:"secondary",onClick:async()=>{await c(),T("/auth")},className:"w-full bg-primary/10 hover:bg-primary/20 text-primary border border-primary/30",children:[e.jsx(na,{className:"w-4 h-4 mr-2"}),"Log Out"]})]})]}),e.jsx(ra,{}),e.jsxs(O,{className:"border-destructive",children:[e.jsxs(H,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(js,{className:"h-5 w-5"}),e.jsx(W,{children:"Danger Zone"})]}),e.jsx(K,{children:"Permanently delete your account and all associated data"})]}),e.jsxs($,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsx("p",{className:"font-medium",children:"What will be deleted:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 text-muted-foreground ml-2",children:[e.jsx("li",{children:"Your profile and personal information"}),e.jsx("li",{children:"Your services and availability"}),e.jsx("li",{children:"Access to the app"})]})]}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsx("p",{className:"font-medium",children:"What will be kept (anonymized):"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 text-muted-foreground ml-2",children:[e.jsx("li",{children:"Completed appointment history"}),e.jsx("li",{children:"Care reports shared with clients"}),e.jsx("li",{children:"Payment records (required for tax/legal purposes)"})]})]}),e.jsxs(v,{variant:"destructive",onClick:()=>l(!0),className:"w-full",children:[e.jsx(js,{className:"w-4 h-4 mr-2"}
40),"Delete My Account"]})]})]})]})]})]}),e.jsx(Mt,{}),e.jsx(Lt,{open:i,onOpenChange:l,userEmail:(a==null?void 0:a.email)||""})]})}function La(){const s=Et();return s.isAvailable?e.jsxs(O,{children:[e.jsxs(H,{children:[e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsx(le,{className:"w-5 h-5"}),"Security"]}),e.jsx(K,{children:"Manage your sign-in preferences"})]}),e.jsx($,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5 flex-1 mr-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Tt,{className:"w-4 h-4 text-primary"}),e.jsxs("p",{className:"font-medium text-sm",children:[s.biometryType," Login"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.isEnabled?`Sign in instantly with ${s.biometryType}`:`Use ${s.biometryType} for faster sign-in`})]}),e.jsx(v,{variant:s.isEnabled?"destructive":"default",size:"sm",disabled:s.isLoading,onClick:async()=>{s.isEnabled&&await s.disable()},children:s.isLoading?e.jsx(X,{className:"w-4 h-4 animate-spin"}):s.isEnabled?"Disable":"Enable on next login"})]})})]}):null}export{Mr 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.