import{j as e,r as i}from"./client-BbMi5ewG.js";import{u as De,A as es}from"./ActionButton-CK3Uoxvt.js";import{w as ke}from"./withIconDefaults-C8UfSjn1.js";import{C as ss}from"./CrudLayout-Cx6KhKUY.js";import{a as ue,s as z,u as X}from"./store-jX25q14N.js";import{e as ts,T as rs,a as le,b as I,c as ls,d as V}from"./Table-DCeFiyCp.js";import{c as Ae,a as Ee}from"./utils-Q0fnGDhj.js";import{D as q}from"./DollarCircle-DjPBQZLr.js";import{E as ns}from"./Eye-1IT8gO2L.js";import{D as Me,a as Re,b as He,c as Le,P as Oe}from"./dialog-C9IQloQy.js";import{B as O,c as is,a as os,u as cs,d as $e,b as Z,P as as,D as ds}from"./Button-1dacbE2T.js";import{I as Y}from"./input-DhCVOJC-.js";import{L as B}from"./label-1wXMewvs.js";import{S as ne,a as ie,b as oe,c as ce,f as k,R as xs,g as ms}from"./select-CPHcJnpt.js";import{T as us}from"./textarea-QytFj8hO.js";import{C as A,b as M,c as R,a as E}from"./card-CZBIFpqn.js";import{B as Ne}from"./badge-C2Ir4HoT.js";import{S as ae}from"./separator-DZRbPm0x.js";import{b as hs,C as js,S as ps}from"./CalenderCheck-BuHSX8YD.js";import{U as fs}from"./user-jdISm6se.js";import{C as bs}from"./calendar-CjyQ6Zau.js";import{D as ve}from"./dollar-sign-DRtWdm2i.js";import{k as we,T as gs,l as Ce,c as _e,f as Ns,u as vs,R as ws,g as W}from"./index-CM0LBdHD.js";import{C as Ve}from"./circle-check-big-uMTsaxsq.js";import{p as Cs,g as _s,d as ys,a as Ps}from"./pdf-generator-BTm1p4ZJ.js";import{f as S}from"./priceFormatter-Dg4GlACg.js";import{s as Ts,e as Ss}from"./toast-1-c8k_LJ.js";import{l as Fs}from"./lodash-Bd-B7UeG.js";import{D as ks}from"./download-DYVVCiUT.js";import{S as As}from"./send-DOmmtWUO.js";import{C as Es}from"./crown-BdDHOvET.js";import{F as Ms}from"./file-text-DLx-plKT.js";import{P as Rs}from"./Pagination-YytuLjdY.js";import{S as Hs}from"./SkeletonTableRows-BrALmXl-.js";import{S as w}from"./skeleton-ImO4uxQ7.js";import{C as D}from"./CountCard-B-uGF0Vj.js";import{S as Ls}from"./search-C6CI7Qpa.js";import{F as Os}from"./funnel-BsgaQc1H.js";import{R as $s,A as Vs,c as Ie,C as Is,b as zs}from"./index-CeptMk_f.js";import{C as Bs}from"./Calender-DPznisyw.js";import{U as Gs}from"./Users-D3Mtn5jq.js";import{C as ye}from"./CreditCard-Bmei54hq.js";import{P as Zs}from"./PaymentSection-BdBEJKqf.js";import"./vendor-DDjlQeP6.js";import"./loader-circle--S58donA.js";import"./ArrowLeftIcon-DrGyoHe_.js";import"./defineProperty-DbXIQDXj.js";import"./typeof-QjJsDpFa.js";import"./apiConfig-D-T4C2Ae.js";import"./index-D59bwJy3.js";import"./index-C4Ytkwtd.js";import"./index-BbWn2ja9.js";import"./check-DMod5j-l.js";import"./preload-helper-Dp1pzeXC.js";import"./tag-CvsOfBQf.js";import"./shield-Bmp_421z.js";import"./proxy-DChtKkEh.js";/**
 * @license lucide-react v0.525.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const qs=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]],Us=Ae("calculator",qs);/**
 * @license lucide-react v0.525.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ws=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],Js=Ae("printer",Ws);function Xs(){return e.jsx("svg",{width:"13",height:"16",viewBox:"0 0 13 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M7.47559 0C7.63622 0.000129609 7.79065 0.064214 7.90332 0.178711L12.0283 4.37891C12.1384 4.49108 12.2002 4.64266 12.2002 4.7998V13.1992C12.2002 13.7261 11.995 14.2345 11.626 14.6104C11.2566 14.9864 10.7527 15.1991 10.2256 15.1992H1.97559C1.44845 15.1992 0.944676 14.9863 0.575195 14.6104C0.206038 14.2345 0 13.7262 0 13.1992V2C0 1.47302 0.206038 0.964737 0.575195 0.588867C0.944676 0.212884 1.44845 0 1.97559 0H7.47559ZM1.97559 1.19922C1.77383 1.19922 1.57779 1.28119 1.43164 1.42969C1.28507 1.57892 1.2002 1.78437 1.2002 2V13.1992C1.2002 13.4148 1.28507 13.6203 1.43164 13.7695C1.57779 13.918 1.77383 14 1.97559 14H10.2256C10.4273 13.9999 10.6235 13.9181 10.7695 13.7695C10.916 13.6203 11.001 13.4147 11.001 13.1992V5.39941H7.47559C7.14428 5.39941 6.87608 5.13109 6.87598 4.7998V1.19922H1.97559ZM8.85059 10.5C9.18173 10.5003 9.4502 10.7684 9.4502 11.0996C9.4502 11.4308 9.18173 11.699 8.85059 11.6992H3.35059C3.01922 11.6992 2.75098 11.431 2.75098 11.0996C2.75098 10.7682 3.01922 10.5 3.35059 10.5H8.85059ZM8.85059 7.69922C9.18173 7.69948 9.4502 7.9686 9.4502 8.2998C9.45009 8.63092 9.18167 8.89915 8.85059 8.89941H3.35059C3.01928 8.89941 2.75108 8.63109 2.75098 8.2998C2.75098 7.96843 3.01922 7.69922 3.35059 7.69922H8.85059ZM4.72559 4.89941C5.05673 4.89968 5.3252 5.16879 5.3252 5.5C5.32498 5.83103 5.0566 6.09935 4.72559 6.09961H3.35059C3.01935 6.09961 2.75119 5.83119 2.75098 5.5C2.75098 5.16863 3.01922 4.89941 3.35059 4.89941H4.72559ZM8.0752 4.19922H10.1699L8.0752 2.06543V4.19922Z",fill:"currentColor"})})}const Ys=ke(Xs);function Ks(){return e.jsx("svg",{width:"19",height:"19",viewBox:"0 0 19 19",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M12.5859 0C14.1548 0.000449071 15.4266 1.27189 15.4268 2.84082V4.60352H15.7617C17.331 4.60352 18.6033 5.87511 18.6035 7.44434V11.7275C18.6035 13.2969 17.3311 14.5693 15.7617 14.5693H15.4268V16.832C15.4265 17.8096 14.6338 18.6023 13.6562 18.6025H4.94727C3.96967 18.6023 3.17699 17.8096 3.17676 16.832V14.5693H2.8418C1.27239 14.5693 0 13.2969 0 11.7275V7.44434C0.000214542 5.87511 1.27253 4.60352 2.8418 4.60352H3.17676V2.84082C3.17687 1.27162 4.44932 0 6.01855 0H12.5859ZM4.57715 16.832C4.57738 17.0364 4.74287 17.2019 4.94727 17.2021H13.6562C13.8606 17.2019 14.0271 17.0364 14.0273 16.832V13.8779C14.0273 13.875 14.0264 13.8721 14.0264 13.8691C14.0264 13.8659 14.0273 13.8626 14.0273 13.8594V11.7139H4.57715V16.832ZM10.7295 14.8818C11.116 14.8819 11.4297 15.1955 11.4297 15.582C11.4297 15.9686 11.116 16.2821 10.7295 16.2822H7.87402C7.48742 16.2822 7.17383 15.9686 7.17383 15.582C7.17383 15.1954 7.48742 14.8818 7.87402 14.8818H10.7295ZM10.7295 12.5977C11.116 12.5978 11.4297 12.9113 11.4297 13.2979C11.4297 13.6844 11.116 13.998 10.7295 13.998H7.87402C7.48742 13.998 7.17383 13.6845 7.17383 13.2979C7.17383 12.9113 7.48742 12.5977 7.87402 12.5977H10.7295ZM2.8418 6.00293C2.04572 6.00293 1.40061 6.64831 1.40039 7.44434V11.7275C1.40039 12.5237 2.04559 13.1689 2.8418 13.1689H3.17676V11.7139H3.02051C2.63391 11.7139 2.32031 11.4003 2.32031 11.0137C2.32031 10.6271 2.63391 10.3135 3.02051 10.3135H15.584C15.9705 10.3136 16.2842 10.6271 16.2842 11.0137C16.2842 11.4002 15.9705 11.7138 15.584 11.7139H15.4268V13.1689H15.7617C16.5579 13.1689 17.2031 12.5237 17.2031 11.7275V7.44434C17.2029 6.64831 16.5578 6.00293 15.7617 6.00293H14.7373C14.7341 6.00298 14.7308 6.0039 14.7275 6.00391H3.87695C3.87385 6.00391 3.87028 6.00297 3.86719 6.00293H2.8418ZM4.7334 6.88672C5.12 6.88672 5.43359 7.20031 5.43359 7.58691C5.43359 7.97351 5.12 8.28711 4.7334 8.28711H3.02051C2.63391 8.28711 2.32031 7.97351 2.32031 7.58691C2.32031 7.20031 2.63391 6.88672 3.02051 6.88672H4.7334ZM6.01855 1.39941C5.22252 1.39941 4.57726 2.04481 4.57715 2.84082V4.60352H14.0273V2.84082C14.0272 2.04509 13.3816 1.39986 12.5859 1.39941H6.01855Z",fill:"currentColor"})})}const Qs=ke(Ks);function Ds({open:t,onClose:l}){const[s,n]=i.useState("form"),[r,u]=i.useState({customer_name:"",customer_email:"",service_name:"",amount:"",payment_method:"offline",notes:""}),[m,h]=i.useState(""),[c,a]=i.useState(0),[b,o]=i.useState(!1);i.useEffect(()=>{const f=Number.parseFloat(m)||0,d=Number.parseFloat(r.amount)||0;a(Math.max(0,f-d))},[m,r.amount]);const p=f=>{f.preventDefault(),s==="form"&&n("payment")},N=(f,d)=>{u(v=>({...v,[f]:d}))},C=()=>{o(!0),n("confirmation")},y=()=>{n("form"),u({customer_name:"",customer_email:"",service_name:"",amount:"",payment_method:"offline",notes:""}),h(""),a(0),o(!1),l()},j=["25","50","75","100","150","200"];return e.jsx(Me,{open:t,onOpenChange:l,children:e.jsxs(Re,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(He,{children:e.jsxs(Le,{className:"flex items-center gap-2",children:[e.jsx(hs,{className:"w-5 h-5"}),s==="form"&&"Process Cash Payment",s==="payment"&&"Cash Payment Processing",s==="confirmation"&&"Payment Completed"]})}),s==="form"&&e.jsxs("form",{onSubmit:p,className:"space-y-6",children:[e.jsxs(A,{children:[e.jsx(M,{children:e.jsxs(R,{className:"flex items-center gap-2 text-lg",children:[e.jsx(fs,{className:"w-4 h-4"}),"Customer Information"]})}),e.jsx(E,{className:"space-y-4",children: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(B,{htmlFor:"customer_name",children:"Customer Name *"}),e.jsx(Y,{id:"customer_name",value:r.customer_name,onChange:f=>N("customer_name",f.target.value),placeholder:"Enter customer name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"customer_email",children:"Email (Optional)"}),e.jsx(Y,{id:"customer_email",type:"email",value:r.customer_email,onChange:f=>N("customer_email",f.target.value),placeholder:"customer@example.com"})]})]})})]}),e.jsxs(A,{children:[e.jsx(M,{children:e.jsxs(R,{className:"flex items-center gap-2 text-lg",children:[e.jsx(bs,{className:"w-4 h-4"}),"Service Information"]})}),e.jsxs(E,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"service_name",children:"Service *"}),e.jsxs(ne,{onValueChange:f=>N("service_name",f),required:!0,children:[e.jsx(ie,{children:e.jsx(oe,{placeholder:"Select service"})}),e.jsxs(ce,{children:[e.jsx(k,{value:"hair_cut",children:"Hair Cut - $25"}),e.jsx(k,{value:"beard_trim",children:"Beard Trim - $15"}),e.jsx(k,{value:"hair_wash",children:"Hair Wash - $10"}),e.jsx(k,{value:"styling",children:"Hair Styling - $35"}),e.jsx(k,{value:"full_service",children:"Full Service - $50"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"amount",children:"Amount *"}),e.jsxs("div",{className:"relative",children:[e.jsx(ve,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Y,{id:"amount",type:"number",step:"0.01",value:r.amount,onChange:f=>N("amount",f.target.value),placeholder:"0.00",className:"pl-10",required:!0})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Quick amounts:"}),j.map(f=>e.jsxs(O,{type:"button",variant:"outline",size:"sm",onClick:()=>N("amount",f),className:"h-8 px-3",children:["$",f]},f))]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"payment_method",children:"Payment Method"}),e.jsxs(ne,{value:r.payment_method,onValueChange:f=>N("payment_method",f),children:[e.jsx(ie,{children:e.jsx(oe,{})}),e.jsxs(ce,{children:[e.jsx(k,{value:"cash",children:"Cash"}),e.jsx(k,{value:"card",children:"Card"}),e.jsx(k,{value:"check",children:"Check"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"notes",children:"Notes (Optional)"}),e.jsx(us,{id:"notes",value:r.notes,onChange:f=>N("notes",f.target.value),placeholder:"Additional notes...",rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx(O,{type:"button",variant:"outline",onClick:l,children:"Cancel"}),e.jsx(O,{type:"submit",className:"bg-primary hover:bg-primary/90",children:"Continue to Payment"})]})]}),s==="payment"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs(A,{children:[e.jsx(M,{children:e.jsxs(R,{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4"}),"Payment Summary"]})}),e.jsx(E,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Customer:"}),e.jsx("span",{className:"font-medium",children:r.customer_name})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Service:"}),e.jsx("span",{className:"font-medium capitalize",children:r.service_name.replace("_"," ")})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Payment Method:"}),e.jsx(Ne,{variant:"outline",className:"capitalize",children:r.payment_method})]}),e.jsx(ae,{}),e.jsxs("div",{className:"flex justify-between text-lg font-bold",children:[e.jsx("span",{children:"Total Amount:"}),e.jsxs("span",{className:"text-primary",children:["$",r.amount]})]})]})})]}),r.payment_method==="cash"&&e.jsxs(A,{children:[e.jsx(M,{children:e.jsxs(R,{className:"flex items-center gap-2",children:[e.jsx(Us,{className:"w-4 h-4"}),"Cash Payment"]})}),e.jsxs(E,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"cash_received",children:"Cash Received"}),e.jsxs("div",{className:"relative",children:[e.jsx(ve,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Y,{id:"cash_received",type:"number",step:"0.01",value:m,onChange:f=>h(f.target.value),placeholder:"0.00",className:"pl-10 text-lg"})]})]}),m&&e.jsxs("div",{className:"p-4 bg-muted rounded-lg space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Amount Due:"}),e.jsxs("span",{className:"font-medium",children:["$",r.amount]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Cash Received:"}),e.jsxs("span",{className:"font-medium",children:["$",m]})]}),e.jsx(ae,{}),e.jsxs("div",{className:"flex justify-between text-lg font-bold",children:[e.jsx("span",{children:"Change Due:"}),e.jsxs("span",{className:c>0?"text-primary":"text-foreground",children:["$",c.toFixed(2)]})]}),Number.parseFloat(m)<Number.parseFloat(r.amount)&&e.jsxs("div",{className:"text-sm text-destructive",children:["Insufficient payment. Need $",(Number.parseFloat(r.amount)-Number.parseFloat(m)).toFixed(2)," more."]})]})]})]}),e.jsxs("div",{className:"flex justify-between pt-4",children:[e.jsx(O,{variant:"outline",onClick:()=>n("form"),children:"Back to Form"}),e.jsx(O,{onClick:C,disabled:r.payment_method==="cash"&&(Number.parseFloat(m)<Number.parseFloat(r.amount)||!m),className:"bg-primary hover:bg-primary/90",children:"Process Payment"})]})]}),s==="confirmation"&&e.jsxs("div",{className:"space-y-6 text-center",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(Ve,{className:"w-16 h-16 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-bold text-primary mb-2",children:"Payment Successful!"}),e.jsxs("p",{className:"text-muted-foreground",children:["Cash payment has been processed successfully for ",r.customer_name]})]}),e.jsx(A,{children:e.jsx(E,{className:"pt-6",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Service:"}),e.jsx("span",{className:"font-medium capitalize",children:r.service_name.replace("_"," ")})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Amount Paid:"}),e.jsxs("span",{className:"font-medium",children:["$",r.amount]})]}),r.payment_method==="cash"&&c>0&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Change Given:"}),e.jsxs("span",{className:"font-medium text-primary",children:["$",c.toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Payment Method:"}),e.jsx(Ne,{variant:"outline",className:"capitalize",children:r.payment_method})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Transaction Time:"}),e.jsx("span",{className:"font-medium",children:new Date().toLocaleString()})]})]})})}),e.jsxs("div",{className:"flex justify-center gap-3 pt-4",children:[e.jsxs(O,{variant:"outline",children:[e.jsx(we,{className:"w-4 h-4 mr-2"}),"Print Receipt"]}),e.jsx(O,{onClick:y,className:"bg-primary hover:bg-primary/90",children:"Process Another Payment"})]})]})]})})}const Pe=()=>({invoiceNumber:"TXN_1756724274529",invoiceDate:"2025-01-02",dueDate:"2025-02-01",status:"paid",customer:{name:"Jhon Due",email:"jhon@yourdomain.com",phone:"",address:""},business:{name:"",address:"",phone:"",email:"",website:""},services:[{id:"1",name:"Hair cut",description:"",employee:"Shahin Hasan Khan",date:"2025-01-01",duration:"60 minutes",price:300,quantity:1}],subtotal:300,paidAmount:300,dueAmount:0,tax:0,discount:0,total:300,paymentMethod:"offline",notes:"Thank you for choosing our services!"}),ze=()=>{const[t,l]=i.useState(Pe()),[s,n]=i.useState(!1),[r,u]=i.useState(!1),[m,h]=i.useState(!1),c=i.useCallback(d=>{"invoiceNumber"in d&&Object.keys(d).length>5?l(d):l(v=>({...v,...d}))},[]),a=i.useCallback(async(d={})=>{u(!0);try{await Cs("invoice-template",`invoice-${d.invoiceNumber}.pdf`)}catch(v){console.error("Failed to generate PDF:",v)}finally{u(!1)}},[t]),b=i.useCallback(async()=>{n(!0);try{await _s("invoice-template",`invoice-${t.invoiceNumber}.pdf`)}catch(d){console.error("Failed to generate PDF:",d),await ys(t,`invoice-${t.invoiceNumber}.pdf`)}finally{n(!1)}},[t]),o=i.useCallback(()=>{Ps(t,`invoice-${t.invoiceNumber}.html`)},[t]),p=i.useCallback(async(d,v=null)=>{var P,T,H;if(!((P=window.radius_booking_param)!=null&&P.is_pro))return{success:!1,message:"Send Invoice is a Pro feature. Please upgrade to Pro."};h(!0);try{const F=((T=window.radius_booking_param)==null?void 0:T.rest_root)||"/wp-json/",$=await fetch(`${F}radius-booking/v1/invoice/send`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":((H=window.radius_booking_param)==null?void 0:H.nonce)||""},body:JSON.stringify({invoice_data:d,recipient_email:v})}),L=await $.json();if(!$.ok)throw new Error(L.message||"Failed to send invoice");return{success:!0,message:L.message||"Invoice sent successfully"}}catch(F){return console.error("Failed to send invoice:",F),{success:!1,message:F.message||"Failed to send invoice. Please try again."}}finally{h(!1)}},[t]),N=i.useCallback((d,v,P,T)=>{const H=d.reduce((x,g)=>x+g.price*g.quantity,0),F=H+v-P,$=T!==void 0?T:t.paidAmount,L=Math.max(0,F-$),G=L<=0?"paid":"pending";l(x=>({...x,services:d,subtotal:H,tax:v,discount:P,total:F,paidAmount:$,dueAmount:L,status:G}))},[t.paidAmount]),C=i.useCallback(d=>{l(v=>{const P=Math.max(0,v.total-d),T=P<=0?"paid":"pending";return{...v,paidAmount:d,dueAmount:P,status:T}})},[]),y=i.useCallback(d=>{try{const v=JSON.parse(d);return v.invoiceNumber&&v.customer&&v.business&&v.services?(l(v),!0):!1}catch(v){return console.error("Invalid JSON data:",v),!1}},[]),j=i.useCallback(()=>{l(Pe())},[]),f=i.useCallback(()=>{const d=`TXN_${Date.now()}`,v=new Date().toISOString().split("T")[0],P=new Date(Date.now()+720*60*60*1e3).toISOString().split("T")[0];l(T=>({...T,invoiceNumber:d,invoiceDate:v,dueDate:P,status:"pending",paidAmount:0,dueAmount:T.total}))},[]);return{invoiceData:t,updateInvoiceData:c,generatePDF:b,downloadHTML:o,sendInvoice:p,recalculateInvoice:N,updatePayment:C,loadInvoiceFromJSON:y,resetToDefault:j,duplicateInvoice:f,isGenerating:s,printInvoice:a,isGeneratingInvoice:r,isSending:m}},et=({status:t})=>{const l={paid:{icon:Ve,color:"text-green-600 bg-green-50 border-green-200",text:"Paid"},pending:{icon:js,color:"text-yellow-600 bg-yellow-50 border-yellow-200",text:"Pending"},overdue:{icon:Ce,color:"text-red-600 bg-red-50 border-red-200",text:"Overdue"},cancelled:{icon:Ce,color:"text-title2 bg-gray-50 border-border",text:"Cancelled"}},s=l[t]||l.pending,n=s.icon;return e.jsxs("span",{className:`inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium border ${s.color}`,children:[e.jsx(n,{className:"w-3 h-3 mr-1"}),s.text]})},st=({invoiceData:t,onDownloadHTML:l,onGeneratePDF:s,isGenerating:n,printInvoice:r,isGeneratingInvoice:u,sendInvoice:m,isSending:h})=>{var o;const c=!!((o=window.radius_booking_param)!=null&&o.is_pro),a=p=>{const N=new Date(p);if(isNaN(N))return p;const C=N.toLocaleString("en-US",{month:"short"}),y=String(N.getDate()).padStart(2,"0"),j=N.getFullYear();return`${y}${C},${j}`},b=async()=>{if(!c)return;const p=await m(t);p.success?Ts(p.message||"Invoice sent successfully!"):Ss(p.message||"Failed to send invoice. Please try again.")};return e.jsxs("div",{className:"min-h-screen bg-gray-50 py-4 sm:py-8",children:[e.jsxs("div",{className:"max-w-4xl mx-auto px-4 mb-4 sm:mb-8",children:[e.jsx(gs,{}),e.jsx("div",{className:"bg-white rounded-lg shadow-sm border p-4 sm:p-6",children:e.jsx("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-6",children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(O,{size:"sm",onClick:s,disabled:n,children:[n?e.jsx("div",{className:"w-4 h-4 mr-2 animate-spin rounded-full border-2 border-white border-t-transparent"}):e.jsx(ks,{className:"w-4 h-4 mr-2"}),n?"Generating...":"Download PDF"]}),e.jsxs("div",{className:"relative inline-flex",children:[e.jsxs(O,{variant:"outline",size:"sm",onClick:b,className:`hover:bg-primary hover:text-white ${c?"":"opacity-60 cursor-not-allowed"}`,disabled:h||!c,children:[h?e.jsx("div",{className:"w-4 h-4 mr-2 animate-spin rounded-full border-2 border-white border-t-transparent"}):e.jsx(As,{className:"w-4 h-4 mr-2"}),h?"Sending...":" Send Invoice"]}),!c&&e.jsxs("span",{className:"absolute -top-2 -right-2 inline-flex items-center gap-0.5 rounded-full bg-gradient-to-r from-amber-400 to-orange-500 px-1.5 py-0.5 text-[9px] font-semibold text-white shadow-sm",children:[e.jsx(Es,{className:"h-2.5 w-2.5"}),"PRO"]})]}),e.jsxs(O,{variant:"outline",size:"sm",onClick:r,children:[u?e.jsx("div",{className:"w-4 h-4 mr-2 animate-spin rounded-full border-2 border-white border-t-transparent"}):e.jsx(Js,{className:"w-4 h-4"}),u?"Generating...":"Print Invoice"]})]})})})]}),e.jsx("div",{className:"max-w-4xl mx-auto px-4",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border overflow-hidden",id:"invoice-template",children:[e.jsxs("div",{className:"p-4 sm:p-8 border-b border-border",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row print:flex-row lg:flex-row justify-between items-start gap-6 mb-6 sm:mb-8",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-primary",children:"INVOICE"}),e.jsx(et,{status:t.status})]}),e.jsxs("div",{className:"text-sm text-title2 space-y-1",children:[e.jsxs("p",{children:["Invoice #: ",t.invoiceNumber]}),e.jsxs("p",{children:["Date: ",a(t.invoiceDate)]}),e.jsxs("p",{children:["Due Date: ",a(t.dueDate)]})]})]}),e.jsxs("div",{className:"flex-1 sm:text-right print:text-right",children:[e.jsx("div",{className:"text-lg sm:text-xl font-bold text-title mb-2",children:t.business.name}),e.jsxs("div",{className:"text-sm text-title2 space-y-1",children:[e.jsx("p",{children:t.business.address}),t.business.phone&&e.jsxs("p",{children:["Phone: ",t.business.phone]}),e.jsxs("p",{children:["Email: ",t.business.email]}),t.business.website&&e.jsxs("p",{children:["Web: ",t.business.website]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between gap-6",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-sm font-semibold text-title mb-2",children:"BILL TO:"}),e.jsxs("div",{className:"text-sm text-title space-y-1",children:[e.jsx("p",{className:"font-semibold",children:t.customer.name}),t.customer.email&&e.jsxs("p",{children:["Email: ",t.customer.email]}),t.customer.phone&&e.jsxs("p",{children:["Phone: ",t.customer.phone]}),t.customer.address&&e.jsx("p",{children:t.customer.address})]})]}),e.jsxs("div",{className:"flex-1 sm:text-right",children:[e.jsx("h3",{className:"text-sm font-semibold text-title mb-2",children:"PAYMENT INFO:"}),e.jsxs("div",{className:"text-sm text-title space-y-1",children:[e.jsxs("p",{children:["Method: ",t.paymentMethod.charAt(0).toUpperCase()+t.paymentMethod.slice(1)]}),e.jsxs("p",{children:["Amount Paid: ",S(t.paidAmount.toFixed(2),t.currency)]}),t.dueAmount>0&&e.jsxs("p",{className:"text-red-600 font-semibold",children:["Due: ",S(t.dueAmount.toFixed(2),t.currency)]})]})]})]})]}),e.jsxs("div",{className:"p-4 sm:p-8",children:[e.jsx("div",{className:"hidden lg:block",children:e.jsxs("table",{className:"w-full mb-8",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b-2 border-border",children:[e.jsx("th",{className:"text-left py-3 px-2 font-semibold text-title",children:"Service"}),e.jsx("th",{className:"text-left py-3 px-2 font-semibold text-title w-32",children:"Staff"}),e.jsx("th",{className:"text-center py-3 px-2 font-semibold text-title w-24",children:"Date"}),e.jsx("th",{className:"text-center py-3 px-2 font-semibold text-title w-20",children:"Duration"}),e.jsx("th",{className:"text-right py-3 px-2 font-semibold text-title w-20",children:"Persons"}),e.jsx("th",{className:"text-right py-3 px-2 font-semibold text-title w-24",children:"Price"}),e.jsx("th",{className:"text-right py-3 px-2 font-semibold text-title w-28",children:"Total"})]})}),e.jsx("tbody",{children:t.services.map(p=>e.jsxs("tr",{className:"border-b border-border",children:[e.jsxs("td",{className:"py-4 px-2",children:[e.jsx("div",{className:"font-semibold text-title",children:p.name}),p.description&&e.jsx("div",{className:"text-sm text-title2",children:p.description})]}),e.jsx("td",{className:"py-4 px-2 text-sm text-title",children:p.employee}),e.jsx("td",{className:"text-center py-4 px-2 text-sm text-title",children:a(p.date)}),e.jsx("td",{className:"text-center py-4 px-2 text-sm text-title",children:p.duration}),e.jsx("td",{className:"text-center py-4 px-2 text-title",children:Fs.parseInt(t==null?void 0:t.persons)+1||1}),e.jsx("td",{className:"text-right py-4 px-2 text-title",children:S(p.price.toFixed(2),t.currency)}),e.jsx("td",{className:"text-right py-4 px-2 font-semibold text-title",children:S(t.totalAmount.toFixed(2),t.currency)})]},p.id))})]})}),e.jsx("div",{className:"lg:hidden space-y-4 mb-8",children:t.services.map(p=>e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-title text-lg",children:p.name}),p.description&&e.jsx("div",{className:"text-sm text-title2",children:p.description})]}),e.jsxs("div",{className:"text-right font-semibold text-title text-lg",children:["$",(p.price*p.quantity).toFixed(2)]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-title2",children:"Employee:"}),e.jsx("div",{className:"font-medium",children:p.employee})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-title2",children:"Date:"}),e.jsx("div",{className:"font-medium",children:a(p.date)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-title2",children:"Duration:"}),e.jsx("div",{className:"font-medium",children:p.duration})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-title2",children:"Price:"}),e.jsxs("div",{className:"font-medium",children:["$",p.price.toFixed(2)," × ",p.quantity]})]})]})]},p.id))}),e.jsx("div",{className:"flex justify-end",children:e.jsxs("div",{className:"w-full sm:w-72",children:[e.jsxs("div",{className:"flex justify-between py-2 border-b border-border",children:[e.jsx("span",{className:"text-title",children:"Subtotal:"}),e.jsx("span",{className:"font-semibold text-title",children:S(t.subtotal.toFixed(2),t.currency)})]}),t.discount>0&&e.jsxs("div",{className:"flex justify-between py-2 border-b border-border",children:[e.jsxs("span",{className:"text-title",children:["Discount",t.couponCode?` (${t.couponCode})`:"",":"]}),e.jsxs("span",{className:"font-semibold text-green-600",children:["-",S(t.discount.toFixed(2),t.currency)]})]}),t.tax>0&&e.jsxs("div",{className:"flex justify-between py-2 border-b border-border",children:[e.jsxs("span",{className:"text-title",children:[t.taxLabel||"Tax",t.taxInclusive?" (incl.)":" (excl.)",":"]}),e.jsx("span",{className:"font-semibold text-title",children:S(t.tax.toFixed(2),t.currency)})]}),e.jsxs("div",{className:"flex justify-between py-3 border-b-2 border-border mb-2",children:[e.jsx("span",{className:"text-lg font-bold text-title",children:"Total:"}),e.jsx("span",{className:"text-lg font-bold text-primary",children:S(t.total.toFixed(2),t.currency)})]}),e.jsxs("div",{className:"flex justify-between py-2 text-green-600",children:[e.jsx("span",{className:"font-semibold",children:"Paid:"}),e.jsx("span",{className:"font-semibold",children:S(t.paidAmount.toFixed(2),t.currency)})]}),t.dueAmount>0&&e.jsxs("div",{className:"flex justify-between py-2 text-red-600",children:[e.jsx("span",{className:"font-semibold",children:"Due:"}),e.jsx("span",{className:"font-semibold",children:S(t.dueAmount.toFixed(2),t.currency)})]})]})}),t.notes&&e.jsxs("div",{className:"mt-8 p-4 bg-blue-50 rounded-lg",children:[e.jsx("h4",{className:"font-semibold text-title mb-2",children:"Notes:"}),e.jsx("p",{className:"text-sm text-title",children:t.notes})]}),e.jsxs("div",{className:"mt-8 pt-6 border-t border-border text-center text-sm text-title2",children:[e.jsx("p",{children:"Thank you for choosing our services!"}),e.jsxs("p",{className:"mt-1",children:["For questions about this invoice, please contact us at ",t.business.email]})]})]})]})}),e.jsx("style",{jsx:!0,children:`
                @media print {
                    body { margin: 0; }
                    .min-h-screen { min-height: auto; }
                    .py-4, .py-8, .px-4 { padding: 0 !important; }
                    .mb-4, .mb-8 { margin-bottom: 0 !important; }
                    .bg-gray-50 { background: white !important; }
                    .shadow-lg, .shadow-sm { box-shadow: none !important; }
                    .rounded-lg { border-radius: 0 !important; }
                    .border { border: none !important; }
                    .overflow-hidden { overflow: visible !important; }
                    .status-badge { display: none !important; }
                    #invoice-template {
                        box-shadow: none !important;
                        border: none !important;
                        border-radius: 0 !important;
                        margin: 0 !important;
                    }
                    .print-hidden { display: none !important; }
                }

                @page {
                    margin: 0.5in;
                    size: A4;
                }
            `})]})},tt=t=>{const{data:l}=t,{generatePDF:s,downloadHTML:n,isGenerating:r,printInvoice:u,isGeneratingInvoice:m,sendInvoice:h,isSending:c}=ze();return e.jsx(st,{invoiceData:l,onDownloadHTML:n,onGeneratePDF:s,isGenerating:r,printInvoice:u,isGeneratingInvoice:m,sendInvoice:h,isSending:c})};function Be({open:t,onClose:l,paymentData:s}){var c,a,b,o,p,N,C,y;const[n,r]=i.useState("preview"),[u,m]=i.useState({invoiceNumber:s==null?void 0:s.transaction_id,invoiceDate:new Date().toISOString().split("T")[0],dueDate:new Date(Date.now()+720*60*60*1e3).toISOString().split("T")[0],status:s.status,customer:{name:(s==null?void 0:s.customer_name)||"",email:(s==null?void 0:s.customer_email)||"",phone:"",address:""},business:{name:((c=s==null?void 0:s.business_settings)==null?void 0:c.companyName)||"",address:((a=s==null?void 0:s.business_settings)==null?void 0:a.address)||"",phone:((b=s==null?void 0:s.business_settings)==null?void 0:b.phone)||"",email:(s==null?void 0:s.admin_email)||"",website:(s==null?void 0:s.site_url)||""},services:[{id:s.service_id,name:s==null?void 0:s.service_name,description:"",employee:(s==null?void 0:s.employee_name)||"Staff Member",date:((o=s==null?void 0:s.booking_date_time)==null?void 0:o.split(" ")[0])||new Date().toISOString().split("T")[0],duration:s.duration/60+" minutes",price:Number.parseFloat((s==null?void 0:s.price)||"0"),quantity:1}],subtotal:(()=>{var v,P;const j=Number.parseFloat((s==null?void 0:s.totalAmount)||"0"),f=Number.parseFloat((s==null?void 0:s.tax_amount)||"0"),d=!!((P=(v=window.radius_booking_param)==null?void 0:v.tax_settings)!=null&&P.inclusive);return f>0&&!d?j-f:j})(),paidAmount:Number.parseFloat((s==null?void 0:s.paidAmount)||"0"),totalAmount:Number.parseFloat((s==null?void 0:s.totalAmount)||"0"),dueAmount:Number.parseFloat(s.dueAmount||"0"),persons:Number.parseFloat((s==null?void 0:s.persons)||"0"),tax:Number.parseFloat((s==null?void 0:s.tax_amount)||"0"),taxRate:(s==null?void 0:s.tax_rate)||"",taxLabel:(s==null?void 0:s.tax_label)||((N=(p=window.radius_booking_param)==null?void 0:p.tax_settings)==null?void 0:N.label)||"Tax",taxInclusive:!!((y=(C=window.radius_booking_param)==null?void 0:C.tax_settings)!=null&&y.inclusive),discount:Number.parseFloat((s==null?void 0:s.discount_amount)||"0"),couponCode:(s==null?void 0:s.coupon_code)||"",total:Number.parseFloat((s==null?void 0:s.totalAmount)||"0"),paymentMethod:(s==null?void 0:s.payment_method)||"",notes:"Thank you for choosing our services!",currency:s.currency}),h=i.useRef();return ze(),e.jsx(Me,{open:t,onOpenChange:l,children:e.jsxs(Re,{className:"max-w-6xl max-h-[90vh] overflow-y-auto",children:[e.jsx(He,{children:e.jsxs(Le,{className:"flex items-center gap-2",children:[e.jsx(Ms,{className:"w-5 h-5"}),n==="form"?"Generate Invoice":"Invoice Preview"]})}),n==="preview"&&e.jsx("div",{className:"space-y-6",children:e.jsx("div",{ref:h,children:e.jsx(tt,{data:u})})})]})})}function rt(t){const{loading:l,totalRevenue:s,paidPayments:n,pendingPayments:r}=t;return e.jsx(e.Fragment,{children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-1 xl:grid-cols-2 2xl:grid-cols-4 gap-4 mb-6",children:l?e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"h-[120px] w-full rounded-lg animate-none"}),e.jsx(w,{className:"h-[120px] w-full rounded-lg animate-none"}),e.jsx(w,{className:"h-[120px] w-full rounded-lg animate-none"}),e.jsx(w,{className:"h-[120px] w-full rounded-lg animate-none"})]}):e.jsxs(e.Fragment,{children:[e.jsx(D,{title:"Total",description:"Earning Revenue",value:s??"",icon:e.jsx(q,{className:"text-primary",size:"20px"}),iconBg:"bg-[#DFEEFB]"}),e.jsx(D,{title:"Total",description:"Paid Payment",value:n??"",icon:e.jsx(q,{color:"#16803C",size:"20px"}),iconBg:"bg-[#DCFCE7]"}),e.jsx(D,{title:"Total",description:"Pending Payment",value:r,icon:e.jsx(q,{color:"#c98905",size:"20px"}),iconBg:"bg-[#fef9c2]"}),e.jsx(D,{title:"Total",description:"Cancel Payment",value:r??"",icon:e.jsx(q,{color:"#E4002D",size:"20px"}),iconBg:"bg-[#FFE1E7]"})]})})})}const lt=t=>{const{searchTerm:l,setSearchTerm:s,statusFilter:n,setStatusFilter:r}=t;return e.jsxs("div",{children:[e.jsx("h3",{className:"rtrb-title-18 mb-3",children:"All Payments"}),e.jsxs("div",{className:"flex gap-4 py-4",children:[e.jsxs("div",{className:"mr-auto relative",children:[e.jsx(Y,{placeholder:"Search by ID or transaction ID...",value:l,onChange:u=>s(u.target.value),className:"w-full md:w-[300px] xl:w-[400px] rounded-[6px] pr-8"}),e.jsx(Ls,{className:"text-small-font absolute right-3 top-[15px]",size:"14px"})]}),e.jsxs(ne,{value:n,onValueChange:r,children:[e.jsxs(ie,{className:"max-w-[44px] md:max-w-[180px] rounded-[6px] text-small-font",children:[e.jsx(Os,{className:"w-4 h-4 min-w-4 mr-2"}),e.jsx(oe,{placeholder:"Filter by status"})]}),e.jsxs(ce,{children:[e.jsx(k,{value:"all",children:"All Status"}),e.jsx(k,{value:"paid",children:"Paid"}),e.jsx(k,{value:"pending",children:"Pending"}),e.jsx(k,{value:"partial_payment",children:"Partially Paid"}),e.jsx(k,{value:"cancelled",children:"Cancelled"}),e.jsx(k,{value:"failed",children:"Failed"}),e.jsx(k,{value:"refunded",children:"Refunded"})]})]})]})]})};function nt(t,l=[]){let s=[];function n(u,m){const h=i.createContext(m),c=s.length;s=[...s,m];const a=o=>{var f;const{scope:p,children:N,...C}=o,y=((f=p==null?void 0:p[t])==null?void 0:f[c])||h,j=i.useMemo(()=>C,Object.values(C));return e.jsx(y.Provider,{value:j,children:N})};a.displayName=u+"Provider";function b(o,p){var y;const N=((y=p==null?void 0:p[t])==null?void 0:y[c])||h,C=i.useContext(N);if(C)return C;if(m!==void 0)return m;throw new Error(`\`${o}\` must be used within \`${u}\``)}return[a,b]}const r=()=>{const u=s.map(m=>i.createContext(m));return function(h){const c=(h==null?void 0:h[t])||u;return i.useMemo(()=>({[`__scope${t}`]:{...h,[t]:c}}),[h,c])}};return r.scopeName=t,[n,it(r,...l)]}function it(...t){const l=t[0];if(t.length===1)return l;const s=()=>{const n=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(u){const m=n.reduce((h,{useScope:c,scopeName:a})=>{const o=c(u)[`__scope${a}`];return{...h,...o}},{});return i.useMemo(()=>({[`__scope${l.scopeName}`]:m}),[m])}};return s.scopeName=l.scopeName,s}function ot(t){const l=ct(t),s=i.forwardRef((n,r)=>{const{children:u,...m}=n,h=i.Children.toArray(u),c=h.find(dt);if(c){const a=c.props.children,b=h.map(o=>o===c?i.Children.count(a)>1?i.Children.only(null):i.isValidElement(a)?a.props.children:null:o);return e.jsx(l,{...m,ref:r,children:i.isValidElement(a)?i.cloneElement(a,void 0,b):null})}return e.jsx(l,{...m,ref:r,children:u})});return s.displayName=`${t}.Slot`,s}function ct(t){const l=i.forwardRef((s,n)=>{const{children:r,...u}=s;if(i.isValidElement(r)){const m=mt(r),h=xt(u,r.props);return r.type!==i.Fragment&&(h.ref=n?is(n,m):m),i.cloneElement(r,h)}return i.Children.count(r)>1?i.Children.only(null):null});return l.displayName=`${t}.SlotClone`,l}var Ge=Symbol("radix.slottable");function at(t){const l=({children:s})=>e.jsx(e.Fragment,{children:s});return l.displayName=`${t}.Slottable`,l.__radixId=Ge,l}function dt(t){return i.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Ge}function xt(t,l){const s={...l};for(const n in l){const r=t[n],u=l[n];/^on[A-Z]/.test(n)?r&&u?s[n]=(...h)=>{const c=u(...h);return r(...h),c}:r&&(s[n]=r):n==="style"?s[n]={...r,...u}:n==="className"&&(s[n]=[r,u].filter(Boolean).join(" "))}return{...t,...s}}function mt(t){var n,r;let l=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,s=l&&"isReactWarning"in l&&l.isReactWarning;return s?t.ref:(l=(r=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:r.get,s=l&&"isReactWarning"in l&&l.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}var ut=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ht=ut.reduce((t,l)=>{const s=ot(`Primitive.${l}`),n=i.forwardRef((r,u)=>{const{asChild:m,...h}=r,c=m?s:l;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(c,{...h,ref:u})});return n.displayName=`Primitive.${l}`,{...t,[l]:n}},{}),[ee]=nt("Tooltip",[Ie]),se=Ie(),Ze="TooltipProvider",jt=700,de="tooltip.open",[pt,he]=ee(Ze),qe=t=>{const{__scopeTooltip:l,delayDuration:s=jt,skipDelayDuration:n=300,disableHoverableContent:r=!1,children:u}=t,m=i.useRef(!0),h=i.useRef(!1),c=i.useRef(0);return i.useEffect(()=>{const a=c.current;return()=>window.clearTimeout(a)},[]),e.jsx(pt,{scope:l,isOpenDelayedRef:m,delayDuration:s,onOpen:i.useCallback(()=>{window.clearTimeout(c.current),m.current=!1},[]),onClose:i.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>m.current=!0,n)},[n]),isPointerInTransitRef:h,onPointerInTransitChange:i.useCallback(a=>{h.current=a},[]),disableHoverableContent:r,children:u})};qe.displayName=Ze;var K="Tooltip",[ft,Q]=ee(K),Ue=t=>{const{__scopeTooltip:l,children:s,open:n,defaultOpen:r,onOpenChange:u,disableHoverableContent:m,delayDuration:h}=t,c=he(K,t.__scopeTooltip),a=se(l),[b,o]=i.useState(null),p=os(),N=i.useRef(0),C=m??c.disableHoverableContent,y=h??c.delayDuration,j=i.useRef(!1),[f,d]=cs({prop:n,defaultProp:r??!1,onChange:F=>{F?(c.onOpen(),document.dispatchEvent(new CustomEvent(de))):c.onClose(),u==null||u(F)},caller:K}),v=i.useMemo(()=>f?j.current?"delayed-open":"instant-open":"closed",[f]),P=i.useCallback(()=>{window.clearTimeout(N.current),N.current=0,j.current=!1,d(!0)},[d]),T=i.useCallback(()=>{window.clearTimeout(N.current),N.current=0,d(!1)},[d]),H=i.useCallback(()=>{window.clearTimeout(N.current),N.current=window.setTimeout(()=>{j.current=!0,d(!0),N.current=0},y)},[y,d]);return i.useEffect(()=>()=>{N.current&&(window.clearTimeout(N.current),N.current=0)},[]),e.jsx($s,{...a,children:e.jsx(ft,{scope:l,contentId:p,open:f,stateAttribute:v,trigger:b,onTriggerChange:o,onTriggerEnter:i.useCallback(()=>{c.isOpenDelayedRef.current?H():P()},[c.isOpenDelayedRef,H,P]),onTriggerLeave:i.useCallback(()=>{C?T():(window.clearTimeout(N.current),N.current=0)},[T,C]),onOpen:P,onClose:T,disableHoverableContent:C,children:s})})};Ue.displayName=K;var xe="TooltipTrigger",We=i.forwardRef((t,l)=>{const{__scopeTooltip:s,...n}=t,r=Q(xe,s),u=he(xe,s),m=se(s),h=i.useRef(null),c=$e(l,h,r.onTriggerChange),a=i.useRef(!1),b=i.useRef(!1),o=i.useCallback(()=>a.current=!1,[]);return i.useEffect(()=>()=>document.removeEventListener("pointerup",o),[o]),e.jsx(Vs,{asChild:!0,...m,children:e.jsx(ht.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...n,ref:c,onPointerMove:Z(t.onPointerMove,p=>{p.pointerType!=="touch"&&!b.current&&!u.isPointerInTransitRef.current&&(r.onTriggerEnter(),b.current=!0)}),onPointerLeave:Z(t.onPointerLeave,()=>{r.onTriggerLeave(),b.current=!1}),onPointerDown:Z(t.onPointerDown,()=>{r.open&&r.onClose(),a.current=!0,document.addEventListener("pointerup",o,{once:!0})}),onFocus:Z(t.onFocus,()=>{a.current||r.onOpen()}),onBlur:Z(t.onBlur,r.onClose),onClick:Z(t.onClick,r.onClose)})})});We.displayName=xe;var je="TooltipPortal",[bt,gt]=ee(je,{forceMount:void 0}),Je=t=>{const{__scopeTooltip:l,forceMount:s,children:n,container:r}=t,u=Q(je,l);return e.jsx(bt,{scope:l,forceMount:s,children:e.jsx(Oe,{present:s||u.open,children:e.jsx(as,{asChild:!0,container:r,children:n})})})};Je.displayName=je;var U="TooltipContent",Xe=i.forwardRef((t,l)=>{const s=gt(U,t.__scopeTooltip),{forceMount:n=s.forceMount,side:r="top",...u}=t,m=Q(U,t.__scopeTooltip);return e.jsx(Oe,{present:n||m.open,children:m.disableHoverableContent?e.jsx(Ye,{side:r,...u,ref:l}):e.jsx(Nt,{side:r,...u,ref:l})})}),Nt=i.forwardRef((t,l)=>{const s=Q(U,t.__scopeTooltip),n=he(U,t.__scopeTooltip),r=i.useRef(null),u=$e(l,r),[m,h]=i.useState(null),{trigger:c,onClose:a}=s,b=r.current,{onPointerInTransitChange:o}=n,p=i.useCallback(()=>{h(null),o(!1)},[o]),N=i.useCallback((C,y)=>{const j=C.currentTarget,f={x:C.clientX,y:C.clientY},d=yt(f,j.getBoundingClientRect()),v=Pt(f,d),P=Tt(y.getBoundingClientRect()),T=Ft([...v,...P]);h(T),o(!0)},[o]);return i.useEffect(()=>()=>p(),[p]),i.useEffect(()=>{if(c&&b){const C=j=>N(j,b),y=j=>N(j,c);return c.addEventListener("pointerleave",C),b.addEventListener("pointerleave",y),()=>{c.removeEventListener("pointerleave",C),b.removeEventListener("pointerleave",y)}}},[c,b,N,p]),i.useEffect(()=>{if(m){const C=y=>{const j=y.target,f={x:y.clientX,y:y.clientY},d=(c==null?void 0:c.contains(j))||(b==null?void 0:b.contains(j)),v=!St(f,m);d?p():v&&(p(),a())};return document.addEventListener("pointermove",C),()=>document.removeEventListener("pointermove",C)}},[c,b,m,a,p]),e.jsx(Ye,{...t,ref:u})}),[vt,wt]=ee(K,{isInside:!1}),Ct=at("TooltipContent"),Ye=i.forwardRef((t,l)=>{const{__scopeTooltip:s,children:n,"aria-label":r,onEscapeKeyDown:u,onPointerDownOutside:m,...h}=t,c=Q(U,s),a=se(s),{onClose:b}=c;return i.useEffect(()=>(document.addEventListener(de,b),()=>document.removeEventListener(de,b)),[b]),i.useEffect(()=>{if(c.trigger){const o=p=>{const N=p.target;N!=null&&N.contains(c.trigger)&&b()};return window.addEventListener("scroll",o,{capture:!0}),()=>window.removeEventListener("scroll",o,{capture:!0})}},[c.trigger,b]),e.jsx(ds,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:u,onPointerDownOutside:m,onFocusOutside:o=>o.preventDefault(),onDismiss:b,children:e.jsxs(Is,{"data-state":c.stateAttribute,...a,...h,ref:l,style:{...h.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(Ct,{children:n}),e.jsx(vt,{scope:s,isInside:!0,children:e.jsx(xs,{id:c.contentId,role:"tooltip",children:r||n})})]})})});Xe.displayName=U;var Ke="TooltipArrow",_t=i.forwardRef((t,l)=>{const{__scopeTooltip:s,...n}=t,r=se(s);return wt(Ke,s).isInside?null:e.jsx(zs,{...r,...n,ref:l})});_t.displayName=Ke;function yt(t,l){const s=Math.abs(l.top-t.y),n=Math.abs(l.bottom-t.y),r=Math.abs(l.right-t.x),u=Math.abs(l.left-t.x);switch(Math.min(s,n,r,u)){case u:return"left";case r:return"right";case s:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function Pt(t,l,s=5){const n=[];switch(l){case"top":n.push({x:t.x-s,y:t.y+s},{x:t.x+s,y:t.y+s});break;case"bottom":n.push({x:t.x-s,y:t.y-s},{x:t.x+s,y:t.y-s});break;case"left":n.push({x:t.x+s,y:t.y-s},{x:t.x+s,y:t.y+s});break;case"right":n.push({x:t.x-s,y:t.y-s},{x:t.x-s,y:t.y+s});break}return n}function Tt(t){const{top:l,right:s,bottom:n,left:r}=t;return[{x:r,y:l},{x:s,y:l},{x:s,y:n},{x:r,y:n}]}function St(t,l){const{x:s,y:n}=t;let r=!1;for(let u=0,m=l.length-1;u<l.length;m=u++){const h=l[u],c=l[m],a=h.x,b=h.y,o=c.x,p=c.y;b>n!=p>n&&s<(o-a)*(n-b)/(p-b)+a&&(r=!r)}return r}function Ft(t){const l=t.slice();return l.sort((s,n)=>s.x<n.x?-1:s.x>n.x?1:s.y<n.y?-1:s.y>n.y?1:0),kt(l)}function kt(t){if(t.length<=1)return t.slice();const l=[];for(let n=0;n<t.length;n++){const r=t[n];for(;l.length>=2;){const u=l[l.length-1],m=l[l.length-2];if((u.x-m.x)*(r.y-m.y)>=(u.y-m.y)*(r.x-m.x))l.pop();else break}l.push(r)}l.pop();const s=[];for(let n=t.length-1;n>=0;n--){const r=t[n];for(;s.length>=2;){const u=s[s.length-1],m=s[s.length-2];if((u.x-m.x)*(r.y-m.y)>=(u.y-m.y)*(r.x-m.x))s.pop();else break}s.push(r)}return s.pop(),l.length===1&&s.length===1&&l[0].x===s[0].x&&l[0].y===s[0].y?l:l.concat(s)}var At=qe,Et=Ue,Mt=We,Rt=Je,Qe=Xe;const Te=At,Se=Et,Fe=Mt,me=i.forwardRef(({className:t,sideOffset:l=4,...s},n)=>e.jsx(Rt,{children:e.jsx("div",{className:"rtrb-root",children:e.jsx(Qe,{ref:n,sideOffset:l,className:Ee("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",t),...s})})}));me.displayName=Qe.displayName;function Ht(){const{getPayments:t,setPaymentFilter:l,setPaymentLoading:s,getPaymentDashboard:n}=ue(z),{filters:r,paymentsData:u,loading:m,pagination:h,dashboardData:c}=X(x=>{const g=x(z);return{filters:g.getPaymentFilters(),paymentsData:g.getPayments(),loading:g.paymentLoading(),pagination:g.getPaymentPagination(),dashboardData:g.getPaymentDashboard()}},[]),a=i.useMemo(()=>JSON.stringify(r),[r]);i.useEffect(()=>{n()},[]),i.useEffect(()=>{let x=!0;return(async()=>{s(!0),x&&t(r),s(!1)})(),()=>{x=!1}},[t,a]);const b=(u==null?void 0:u.map(x=>{var pe,fe,be,ge;const g=x.appointment_data,_=g==null?void 0:g.payment,te=(g==null?void 0:g.booking_type)||"service_booking";let re=(g==null?void 0:g.service_name)||"N/A";return te==="meeting"?re=(g==null?void 0:g.meeting_type_name)||"Meeting":te==="event"&&(re=(g==null?void 0:g.event_name)||"Event"),{..._,customer_name:((fe=(pe=g==null?void 0:g.customer)==null?void 0:pe.customer_info)==null?void 0:fe.name)||"N/A",customer_email:((ge=(be=g==null?void 0:g.customer)==null?void 0:be.customer_info)==null?void 0:ge.email)||"N/A",service_name:re,booking_type:te,employee_name:(g==null?void 0:g.employee_name)||"N/A",id:_==null?void 0:_.id,price:g==null?void 0:g.customer.price,paidAmount:_==null?void 0:_.amount,totalAmount:_==null?void 0:_.total_amount,dueAmount:_==null?void 0:_.due_amount,amount:_==null?void 0:_.amount,status:_==null?void 0:_.status,booking_date_time:_==null?void 0:_.booking_date_time,transaction_id:(_==null?void 0:_.transaction_id)||"N/A",payment_method:_==null?void 0:_.payment_method,service_id:g==null?void 0:g.service_id,duration:g==null?void 0:g.customer.duration,currency:x==null?void 0:x.currency,appointment_id:g==null?void 0:g.id,business_settings:x==null?void 0:x.business_settings,admin_email:x==null?void 0:x.admin_email,site_url:x==null?void 0:x.site_url}}))||[],[o,p]=i.useState(!1),[N,C]=i.useState(!1),[y,j]=i.useState(null),[f,d]=i.useState(""),v=i.useRef(null),P=i.useCallback(x=>{d(x),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{l({field:"search",value:x}),l({field:"page",value:1})},500)},[l]);i.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]);const T=i.useCallback(x=>{l({field:"status",value:x==="all"?"":x}),l({field:"page",value:1})},[l]),H=S(c==null?void 0:c.total_revenue,c==null?void 0:c.currency),F=S(c==null?void 0:c.total_paid,c==null?void 0:c.currency),$=S(c==null?void 0:c.total_pending,c==null?void 0:c.currency),L=x=>{j(x),C(!0)},G=i.useMemo(()=>(h==null?void 0:h.total)>0,[h==null?void 0:h.total]);return e.jsxs("div",{className:"flex-1 gap-6 space-y-6",children:[e.jsx(rt,{loading:m,totalRevenue:H,paidPayments:F,pendingPayments:$}),e.jsxs("div",{className:"rtrb-card p-[30px]",children:[e.jsx(lt,{searchTerm:f,setSearchTerm:P,statusFilter:r.status||"all",setStatusFilter:T}),e.jsxs(ts,{children:[e.jsx(rs,{children:e.jsxs(le,{className:"bg-muted/50",children:[e.jsx(I,{className:"text-title py-3 bg-[#F6F8FA] font-semibold",children:"ID"}),e.jsx(I,{className:"text-title py-3 bg-[#F6F8FA] font-semibold",children:"Customer"}),e.jsx(I,{className:"text-title py-3 bg-[#F6F8FA] font-semibold min-w-[160px]",children:"Service"}),e.jsx(I,{className:"text-title py-3 bg-[#F6F8FA] font-semibold min-w-[120px]",children:"Total "}),e.jsx(I,{className:"text-title py-3 bg-[#F6F8FA] font-semibold min-w-[120px]",children:"Paid "}),e.jsx(I,{className:"text-title py-3 bg-[#F6F8FA] font-semibold min-w-[140px]",children:"Date"}),e.jsx(I,{className:"text-title py-3 bg-[#F6F8FA] font-semibold min-w-[140px]",children:"Status"}),e.jsx(I,{className:"text-title py-3 bg-[#F6F8FA] font-semibold w-[100px] text-center min-w-[80px]",children:"Actions"})]})}),e.jsx(ls,{children:m?e.jsx(Hs,{rowCount:10,columns:[5,3,2,2,2,1,1,1]}):(b==null?void 0:b.length)>0?b.map(x=>{var g,_;return e.jsxs(le,{className:"hover:bg-muted/30 transition-colors even:bg-[#F6F8FA]",children:[e.jsx(V,{className:"border-t border-border",children:e.jsxs(_e,{to:`/payments/${x.id}/details`,className:"text-primary hover:text-primary font-medium hover:underline transition-colors inline-flex items-center gap-1",children:["#",x==null?void 0:x.appointment_id]})}),e.jsx(V,{className:"border-t border-border",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("div",{className:"font-medium",children:x.customer_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:x.customer_email})]})}),e.jsx(V,{className:"border-t border-border",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-medium",children:x.service_name}),x.booking_type&&x.booking_type!=="service_booking"&&e.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium ${x.booking_type==="meeting"?"bg-purple-50 text-purple-700 border border-purple-200":"bg-teal-50 text-teal-700 border border-teal-200"}`,children:x.booking_type==="meeting"?"Meeting":"Event"})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:x.employee_name})]})}),e.jsx(V,{className:"font-semibold border-t border-border",children:S(x==null?void 0:x.total_amount,x==null?void 0:x.currency)}),e.jsx(V,{className:"font-semibold border-t border-border",children:S(x==null?void 0:x.amount,x==null?void 0:x.currency)}),e.jsx(V,{className:"border-t border-border",children:new Date(x.booking_date_time).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}),e.jsx(V,{className:"border-t border-border",children:e.jsx("span",{className:Ee("text-xs font-medium px-3 py-1 border","label-"+(x==null?void 0:x.status)),children:(x==null?void 0:x.status)==="partial_payment"?"Partially Paid":((g=x==null?void 0:x.status)==null?void 0:g.charAt(0).toUpperCase())+((_=x==null?void 0:x.status)==null?void 0:_.slice(1))})}),e.jsxs(V,{className:"border-t border-border text-center",children:[e.jsx(Te,{children:e.jsxs(Se,{children:[e.jsx(Fe,{asChild:!0,children:e.jsx("button",{className:"text-center p-[3px_5px] hover:bg-transparent",title:"View Details",children:e.jsx(_e,{to:`/payments/${x.id}/details`,className:"text-title2 hover:text-primary",children:e.jsx(ns,{className:"inline-flex",size:"18px"})})})}),e.jsx(me,{children:e.jsx("p",{children:"View Details"})})]})}),e.jsx(Te,{children:e.jsxs(Se,{children:[e.jsx(Fe,{asChild:!0,children:e.jsx("button",{onClick:()=>L(x),className:"text-center p-[3px_5px] hover:bg-transparent text-title2 hover:text-primary",children:e.jsx(Ys,{className:"inline-flex -translate-y-[1px]",size:"16px"})})}),e.jsx(me,{children:e.jsx("p",{children:"Generate Invoice"})})]})})]})]},x.id)}):e.jsx(le,{children:e.jsx(V,{colSpan:8,className:"text-center py-12",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(q,{className:"text-muted-foreground/50"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:"No payments found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f||r.status?"Try adjusting your filters":"Payments will appear here once customers complete transactions"})]})})})})]}),G&&e.jsx(Rs,{pagination:h,loading:m,type:"Payments",onPageChange:x=>{l({field:"page",value:x})}})]}),e.jsx(Ds,{open:o,onClose:()=>p(!1)}),N&&e.jsx(Be,{open:N,onClose:()=>{C(!1),j(null)},paymentData:y})]})}function Lt(){return e.jsx("div",{className:"min-h-screen bg-background p-6",children:e.jsx("div",{className:"max-w-7xl mx-auto space-y-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(w,{className:"h-9 w-32"}),e.jsx(w,{className:"h-9 w-20"}),e.jsx(w,{className:"h-9 w-28"})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(A,{children:[e.jsx(M,{children:e.jsxs(R,{className:"flex items-center gap-2",children:[e.jsx(w,{className:"w-5 h-5"}),e.jsx(w,{className:"h-6 w-40"})]})}),e.jsx(E,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(w,{className:"h-4 w-12 mb-2"}),e.jsx(w,{className:"h-5 w-32"})]}),e.jsxs("div",{children:[e.jsx(w,{className:"h-4 w-12 mb-2"}),e.jsx(w,{className:"h-5 w-48"})]}),e.jsxs("div",{children:[e.jsx(w,{className:"h-4 w-12 mb-2"}),e.jsx(w,{className:"h-5 w-28"})]})]})})]}),e.jsxs(A,{children:[e.jsx(M,{children:e.jsxs(R,{className:"flex items-center gap-2",children:[e.jsx(w,{className:"w-5 h-5"}),e.jsx(w,{className:"h-6 w-36"})]})}),e.jsx(E,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(w,{className:"h-4 w-16 mb-2"}),e.jsx(w,{className:"h-5 w-24"})]}),e.jsxs("div",{children:[e.jsx(w,{className:"h-4 w-20 mb-2"}),e.jsx(w,{className:"h-5 w-36"})]}),e.jsxs("div",{children:[e.jsx(w,{className:"h-4 w-24 mb-2"}),e.jsx(w,{className:"h-5 w-44"})]}),e.jsxs("div",{children:[e.jsx(w,{className:"h-4 w-16 mb-2"}),e.jsx(w,{className:"h-5 w-20"})]})]})})]}),e.jsxs(A,{children:[e.jsx(M,{children:e.jsxs(R,{className:"flex items-center gap-2",children:[e.jsx(w,{className:"w-5 h-5"}),e.jsx(w,{className:"h-6 w-40"})]})}),e.jsx(E,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(t=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(w,{className:"w-2 h-2 rounded-full"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(w,{className:"h-5 w-32 mb-1"}),e.jsx(w,{className:"h-4 w-40"})]})]},t))})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(A,{children:[e.jsx(M,{children:e.jsxs(R,{className:"flex items-center gap-2",children:[e.jsx(w,{className:"w-5 h-5"}),e.jsx(w,{className:"h-6 w-32"})]})}),e.jsx(E,{className:"space-y-4",children:e.jsxs("div",{className:"space-y-3",children:[[1,2,3].map(t=>e.jsxs("div",{className:"flex justify-between",children:[e.jsx(w,{className:"h-4 w-24"}),e.jsx(w,{className:"h-4 w-16"})]},t)),e.jsx(ms,{}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx(w,{className:"h-6 w-12"}),e.jsx(w,{className:"h-6 w-20"})]})]})})]}),e.jsxs(A,{children:[e.jsx(M,{children:e.jsxs(R,{className:"flex items-center gap-2",children:[e.jsx(w,{className:"w-5 h-5"}),e.jsx(w,{className:"h-6 w-28"})]})}),e.jsx(E,{className:"space-y-4",children:[1,2,3].map(t=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(w,{className:"h-4 w-20"}),e.jsx(w,{className:"h-6 w-24"})]},t))})]})]})]})]})})})}function Ot(){var p,N,C,y;const{id:t}=Ns(),{getPayment:l,setPaymentLoading:s,setInvoiceMode:n}=ue(z),r=X(j=>j(z).getPayment(),[]),u=X(j=>j(z).paymentLoading(),[]),m=X(j=>j(z).getPaymentInvoiceModelOpen(),[]),h=X(j=>j(z).getPaymentInvoiceMode(),[]),c=()=>{var v,P,T;if(!r)return null;const j=r==null?void 0:r.appointment_data,f=(v=j==null?void 0:j.customer)==null?void 0:v.customer_info,d=j==null?void 0:j.payment;return{transaction_id:d==null?void 0:d.transaction_id,status:d==null?void 0:d.status,customer_name:f==null?void 0:f.name,customer_email:f==null?void 0:f.email,customer_phone:f==null?void 0:f.phone,service_id:j==null?void 0:j.service_id,service_name:j==null?void 0:j.service_name,employee_name:j==null?void 0:j.employee_name,booking_date_time:d==null?void 0:d.booking_date_time,duration:j.customer.duration,price:(P=j==null?void 0:j.customer)==null?void 0:P.price,persons:(T=j==null?void 0:j.customer)==null?void 0:T.persons,paidAmount:d==null?void 0:d.amount,totalAmount:d==null?void 0:d.total_amount,dueAmount:d==null?void 0:d.due_amount,amount:d==null?void 0:d.amount,payment_method:d==null?void 0:d.payment_method,coupon_code:d==null?void 0:d.coupon_code,discount_amount:d==null?void 0:d.discount_amount,tax_amount:d==null?void 0:d.tax_amount,tax_rate:d==null?void 0:d.tax_rate,currency:r==null?void 0:r.currency,business_settings:r.business_settings,admin_email:r.admin_email,site_url:r.site_url}};if(i.useEffect(()=>{let j=!1;async function f(){s(!0),!j&&(j=!0,await l(t),s(!1))}t&&f()},[t,l]),u)return e.jsx(Lt,{});const a=r==null?void 0:r.appointment_data,b=a==null?void 0:a.customer.customer_info,o=a==null?void 0:a.payment;return e.jsxs("div",{children:[e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 2xl:grid-cols-3 gap-6",children:[e.jsx("div",{className:"xl:col-span-1 2xl:col-span-2",children:e.jsxs("div",{className:"rtrb-card overflow-hidden",children:[e.jsx("div",{className:"bg-lighter-2 h-[50px] pl-[30px] flex items-center border-b border-border",children:e.jsx("h2",{children:"Payment Details"})}),e.jsxs("div",{className:"space-y-6 p-[30px]",children:[e.jsxs(A,{className:"rtrb-card shadow-none",children:[e.jsx(M,{children:e.jsxs(R,{className:"flex items-center gap-2 text-[20px] text-title",children:[e.jsx(Gs,{size:"20px",className:"text-primary"}),e.jsx("span",{children:"Customer Information"})]})}),e.jsx(E,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 2xl:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] text-title2",children:"Name"}),e.jsx("p",{className:"font-medium text-[14px] text-title",children:b==null?void 0:b.name})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] text-title2",children:"Email"}),e.jsx("p",{className:"font-medium text-[14px] text-title",children:b==null?void 0:b.email})]}),(b==null?void 0:b.phone)&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] text-title2",children:"Phone"}),e.jsx("p",{className:"font-medium text-[14px] text-title",children:b==null?void 0:b.phone})]})]})})]}),e.jsxs(A,{className:"rtrb-card shadow-none",children:[e.jsx(M,{children:e.jsxs(R,{className:"flex items-center gap-2 text-[20px] text-title",children:[e.jsx(Bs,{size:"20px",className:"text-primary"}),e.jsx("span",{children:"Service Information"})]})}),e.jsxs(E,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 2xl:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] text-title2",children:"Service"}),e.jsx("p",{className:"font-medium text-[14px] text-title",children:a==null?void 0:a.service_name})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] text-title2",children:"Employee"}),e.jsx("p",{className:"font-medium text-[14px] text-title",children:a==null?void 0:a.employee_name})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] text-title2",children:"Date & Time"}),e.jsx("p",{className:"font-medium text-[14px] text-title",children:new Date(o==null?void 0:o.booking_date_time).toLocaleString()})]}),((p=a==null?void 0:a.location_info)==null?void 0:p.name)&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] text-title2",children:"Location"}),e.jsx("p",{className:"font-medium text-[14px] text-title",children:(N=a==null?void 0:a.location_info)==null?void 0:N.name})]})]}),(a==null?void 0:a.notes)&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] text-title2",children:"Notes"}),e.jsx("p",{className:"font-medium text-[14px] text-title",children:a==null?void 0:a.notes})]})]})]}),e.jsxs(A,{className:"rtrb-card shadow-none",children:[e.jsx(M,{children:e.jsxs(R,{className:"flex items-center gap-2 text-[20px] text-title",children:[e.jsx(ye,{size:"20px",className:"text-primary"}),e.jsx("span",{children:"Transaction Timeline"})]})}),e.jsx(E,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-[14px] text-title",children:"Payment Created"}),e.jsx("p",{className:"text-[13px] text-title2",children:new Date(o==null?void 0:o.created_at).toLocaleString()})]})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-[14px] text-title",children:"Payment Processed"}),e.jsx("p",{className:"text-[13px] text-title2",children:new Date(o==null?void 0:o.updated_at).toLocaleString()})]})}),(o==null?void 0:o.paid_at)&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-[14px] text-title",children:"Payment Completed"}),e.jsx("p",{className:"text-[13px] text-title2",children:new Date(o==null?void 0:o.paid_at).toLocaleString()})]})]})]})})]})]})]})}),e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"rtrb-card overflow-hidden",children:[e.jsx("div",{className:"bg-lighter-2 h-[50px] pl-[30px] flex items-center border-b border-border",children:e.jsx("h2",{children:"Payment Details"})}),e.jsxs("div",{className:"space-y-6 p-[30px]",children:[e.jsxs(A,{className:"rtrb-card shadow-none",children:[e.jsx(M,{children:e.jsxs(R,{className:"flex items-center gap-2 text-[20px] text-title leading-1",children:[e.jsx(q,{size:"20px",className:"text-primary"}),e.jsx("span",{children:"Payment Summary"})]})}),e.jsx(E,{children:(()=>{var L,G,x,g;const j=parseFloat((o==null?void 0:o.total_amount)||0),f=parseFloat((o==null?void 0:o.tax_amount)||0),d=parseFloat((o==null?void 0:o.amount)||0),v=parseFloat((o==null?void 0:o.due_amount)||0),P=parseFloat((o==null?void 0:o.discount_amount)||0),T=!!((G=(L=window.radius_booking_param)==null?void 0:L.tax_settings)!=null&&G.inclusive),H=((g=(x=window.radius_booking_param)==null?void 0:x.tax_settings)==null?void 0:g.label)||"Tax",F=f>0,$=F&&!T?j-f:j;return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-title2 text-[14px]",children:"Subtotal"}),e.jsx("span",{className:"font-semibold text-title text-[16px] break-all",children:S($,a==null?void 0:a.currency)})]}),P>0&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-title2 text-[14px]",children:["Coupon ",(o==null?void 0:o.coupon_code)&&e.jsxs("span",{className:"font-mono text-xs bg-green-50 text-green-700 px-1.5 py-0.5 rounded",children:["(",o.coupon_code,")"]})]}),e.jsxs("span",{className:"font-semibold text-green-600 text-[16px] break-all",children:["-",S(P,a==null?void 0:a.currency)]})]}),F&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-title2 text-[14px]",children:[H," (",o.tax_rate,"%)",T?" (incl.)":""]}),e.jsxs("span",{className:"font-semibold text-title2 text-[14px] break-all",children:[T?"":"+",S(f,a==null?void 0:a.currency)]})]}),e.jsx(ae,{className:"flex m-[7px_0]"}),e.jsxs("div",{className:"flex justify-between text-lg font-bold gap-2",children:[e.jsx("span",{className:"text-title",children:"Total"}),e.jsx("span",{className:"text-primary break-all",children:S(j,a==null?void 0:a.currency)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-title2 text-[14px]",children:d>=j?"Paid":"Paid (Deposit)"}),e.jsx("span",{className:"font-semibold text-green-600 text-[16px] break-all",children:S(d,a==null?void 0:a.currency)})]}),v>0&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-red-600 text-[14px] font-medium",children:"Due Amount"}),e.jsx("span",{className:"font-semibold text-red-600 text-[16px] break-all",children:S(v,a==null?void 0:a.currency)})]})]})})()})]}),e.jsxs(A,{className:"rtrb-card shadow-none",children:[e.jsx(M,{children:e.jsxs(R,{className:"flex items-center gap-2 text-[20px] text-title",children:[e.jsx(ye,{size:"20px",className:"text-primary"}),e.jsx("span",{children:"Payment Method"})]})}),e.jsxs(E,{className:"space-y-1 text-[14px]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-title2",children:"Method"}),e.jsx("span",{className:"capitalize font-medium text-title text-4",children:o==null?void 0:o.payment_method})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-title2",children:"Status"}),e.jsx("span",{className:"capitalize font-medium text-title text-4",children:(o==null?void 0:o.status)==="partial_payment"?"Partially Paid":((C=o==null?void 0:o.status)==null?void 0:C.charAt(0).toUpperCase())+((y=o==null?void 0:o.status)==null?void 0:y.slice(1))})]}),(o==null?void 0:o.transaction_id)&&e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-title2",children:"Transaction ID"}),e.jsx("span",{className:"font-mono text-sm text-title break-all",children:o.transaction_id})]}),e.jsx("div",{className:"pt-3"}),e.jsx(Zs,{appointment:a,module:"payment"})]})]})]})]})})]})}),m&&e.jsx(Be,{open:m,onClose:()=>n(!1),paymentData:c(),mode:h})]})}function $t(){const t=De("/payments"),{mode:l}=t,s=ue();vs();const n=()=>{switch(l){case"list":return e.jsx(Ht,{});case"edit":case"details":return e.jsx(Ot,{});default:return null}},m=({details:[{key:"invoice-generate",variant:"outline",label:"Print Invoice",icon:Qs,onClick:()=>{s(z).setInvoiceMode(!0,"preview")}}]}[l]||[]).map(h=>e.jsx(es,{label:h.label,icon:h.icon,onClick:h.onClick,loading:h.loading||!1},h.key));return e.jsx("div",{children:e.jsx(ss,{title:"Payments",description:"Manage your payments",showBack:l!=="list",onBack:t.navigateTo.list,actions:m,icon:e.jsx(ps,{className:"w-5 h-5 text-primary-colordefault"}),children:n()})})}const J=i.memo($t);function Br(){return e.jsxs(ws,{children:[e.jsx(W,{path:"/",element:e.jsx(J,{})}),e.jsx(W,{path:"create",element:e.jsx(J,{})}),e.jsx(W,{path:":id",element:e.jsx(J,{})}),e.jsx(W,{path:":id/edit",element:e.jsx(J,{})}),e.jsx(W,{path:":id/details",element:e.jsx(J,{})})]})}export{Br as default};
//# sourceMappingURL=index-DJwoTeGg.js.map
