"use strict";(globalThis.webpackChunkbooktics=globalThis.webpackChunkbooktics||[]).push([[6361],{3038:(e,t,a)=>{a.d(t,{A:()=>c});var n=a(47143),o=a(47767),i=a(40309),r=a(11534),l=a(56580),s=a(88802);const c=function(){const e=(0,n.useSelect)(e=>e(i.services).getServicesState(),[]),{selectedServices:t}=(0,n.useSelect)(e=>e(i.team).getTeamState(),[]),{setServicesState:a}=(0,n.useDispatch)(i.services),{setTeamState:c}=(0,n.useDispatch)(i.team),d=(0,l.useAdminLicense)(),{searchQuery:m,serviceList:p=[],total:u,singleService:g,selectedTeamMembers:b,selectedExtraServices:h=[],schedule:f,selectedLocations:x}=e,k=(0,o.Zp)(),{id:v}=(0,o.g)(),y=async(e={})=>{e?.resetFilter&&(e={search:"",category_id:"",team_member_id:""});const t={...m,...e};a({isFiltering:!0});try{const e=await(r.A?.service?.allServices(t));e?.success&&a({serviceList:e?.data?.items,total:e?.data?.total,searchQuery:t})}catch(e){console.error("Error fetching services:",e)}finally{return a({isFiltering:!1}),{complete:!0}}};return{createService:async(e,n=!0)=>{try{a({isFiltering:!0});const o=await(r.A?.service?.createService(e));o?.success&&(a({serviceList:[o?.data,...p||[]],total:u+1}),n?k(`/services/update/${o?.data.id}`):(a({visibleCreateServiceModal:!1}),c({selectedServices:[o.data.id,...t]})))}catch(e){console.error("Error creating service:",e)}finally{a({isFiltering:!1})}},updateService:async(e,t="deactive",n=!1)=>{if(n||a({loadingServiceId:!0}),e?.custom_field){let t=Array.isArray(e?.custom_field?.fields)?e?.custom_field?.fields?.map(e=>"global"===e?.from?e:{...e,from:"service"}):void 0;e.custom_field={...e?.custom_field,fields:t}}try{const n={...g,...e,status:t,extra_services:h,team_member:b,schedule:e.enable_custom_schedule?f:{},show_end_time:Number(e.show_end_time)||!1};delete n.extra_service_details,d||(delete n.extra_services,delete n.custom_field);const o=await r.A.service.updateService(v,n);if(o?.success){const e=p?.map(e=>e?.id===o?.data?.id?o?.data:e);a({serviceList:e}),a({loadingServiceId:!1})}return o}catch(e){console.error("Error updating service:",e)}finally{a({loadingServiceId:!1})}},updateStatus:async({id:e,...t})=>{try{delete t.extra_service_details;const a=await(r.A?.service?.updateService(e,t));if(a?.success){const e=(0,n.select)(i.services).getServicesState("serviceList"),t=e?.map(e=>e.id===a.data.id?a.data:e);(0,n.dispatch)(i.services).setServicesState({serviceList:t})}return a}catch(e){console.error("Error updating status:",e)}finally{(0,n.dispatch)(i.services).setServicesState({loadingServiceId:null})}},getServices:y,deleteSingleService:async e=>{try{const t=await(r.A?.service?.deleteSingleService(e));if(t?.success){const{serviceList:t,total:a}=(0,n.select)(i.services).getServicesState();(0,n.dispatch)(i.services).setServicesState({serviceList:t?.filter(t=>t.id!==e),total:a-1})}return t}catch(e){console.error("Error deleting service:",e)}},bulkDeleteService:async(e=[])=>{try{const t=await(r.A?.service?.bulkDeleteService({ids:e}));if(t?.success&&(a({serviceList:p.filter(t=>!e.includes(t.id))}),e.length<u)){const{paged:e="",per_page:t=""}=m;y({paged:e,per_page:t})}}catch(e){console.error("Error bulk deleting services:",e)}finally{return{complete:!0}}},duplicateService:async e=>{try{a({isFiltering:!0});const t=await(r.A?.service?.cloneService(e));if(t?.success){const n=p.findIndex(t=>t.id===e);if(-1===n)throw new Error("Service not found for duplication.");const o=[...p.slice(0,n+1),t.data,...p.slice(n+1)];a({serviceList:o,total:u+1})}}catch(e){console.error("Error duplicating service:",e)}finally{a({isFiltering:!1})}},getSingleService:async()=>{try{const e=await r.A.service.singleService(v);e.success&&a({singleService:{...e?.data,custom_field:{...e?.data?.custom_field,fields:e?.data?.custom_field?.fields?.length?e?.data?.custom_field?.fields:s.defaultFields}}})}catch(e){console.log(e)}},onPaginationChange:(e,t)=>{y({paged:e,per_page:t})}}}},12017:(e,t,a)=>{a.d(t,{A:()=>C});var n=a(51609),o=a(47143),i=a(86087),r=a(84976),l=a(23973),s=a(3038),c=a(40309),d=a(22564),m=a(87492),p=a(27723);const u=({onCancel:e,onSave:t,isSaving:a=!1})=>(0,n.createElement)(d.Flex,{gap:12,justify:"flex-end"},(0,n.createElement)(d.PrimaryButton,{type:"default",variant:"solid",onClick:e},(0,p.__)("Close","booktics")),(0,n.createElement)(d.PrimaryButton,{type:"primary",onClick:t,loading:a},(0,p.__)("Save Now","booktics")));var g=a(59e3);const b=g.A.div`
    .ant-drawer {
        /* .ant-drawer-content{ */
        .ant-drawer-body {
            background: #f8f9fa !important;
        }

        .ant-drawer-footer {
            padding: 20px !important;
            border-top: 1px solid #e8e9ea !important;
            background: #fff !important;
        }

        .ant-drawer-close {
            color: #8c8c8c;

            &:hover {
                color: #262626;
            }
        }
        /* } */
    }

    .bkt-drawer-content {
        height: 100%;

        .bkt-no-appointment {
            text-align: center;
            padding: 48px 24px;
            color: #8c8c8c;
        }
    }
`,h=g.A.p`
    padding:6px 11px;
    border:1px solid lightgray;
    font-size:14px;
    color:black;
    border-radius:4px;
`,f=g.A.div`
    background: #fff;
    margin-bottom: 1rem;
`,x=g.A.div`
    background: #fff;
    .bkt-title-wrapper {
        border-bottom: 1px solid #e8e9ea;
    }

    .bkt-section-title {
        font-size: 16px;
        font-weight: 600;
        color: #1a1a1a;
        margin-bottom: 0.5rem;
    }
`,k=(g.A.div`
    background: #fff;

    .bkt-section-title {
        font-size: 16px;
        font-weight: 600;
        color: #1a1a1a;
         margin-bottom: 0.5rem;
    }

     /* Payment status select styling */
    .bkt-payment-status {
        .ant-form-item {
            margin-bottom: 0 !important;
            min-width: 150px;
        }

        .ant-select {
            min-width: 150px;
        }
    }

    .bkt-cost-breakdown {
        .bkt-breakdown-title {
            font-size: 14px;
            font-weight: 600;
            color: #374151;
        }

        .bkt-breakdown-items {
            margin-bottom: 16px;

            .bkt-breakdown-item {
                padding: 12px 0;
                border-bottom: 1px solid #f3f4f6;

                &:last-child {
                    border-bottom: none;
                }

                .bkt-item-info {
                    .bkt-item-label {
                        font-size: 14px;
                        color: #1a1a1a;
                        font-weight: 500;
                        margin: 0;
                    }

                    .bkt-item-detail {
                        font-size: 12px;
                        color: #6b7280;
                        margin-top: 2px;
                        margin-bottom: 0;
                    }
                }

                .bkt-item-price {
                    font-size: 14px;
                    font-weight: 500;
                    color: #1a1a1a;
                }
            }
        }

        .bkt-breakdown-total {
            padding-top: 16px;
            border-top: 2px solid #e5e7eb;

            .bkt-total-label,
            .bkt-total-amount {
                font-size: 16px;
                font-weight: 700;
                color: #1a1a1a;
            }
        }
    }
`,g.A.div`    
    .bkt-order-info {
        margin-bottom: 8px;
        
        p {
            margin: 0;
            font-size: 14px;
            color: #4b5563;
            
            strong {
                font-weight: 600;
                color: #1f2937;
            }
        }
        .ant-divider{
            color: #4b5563;
        }
    }
    
    .bkt-status-selects {
        .bkt-status-field {
            flex: 1;
            min-width: 0;
            
            .bkt-status-label {
                display: block;
                margin-bottom: 6px;
                font-size: 14px;
                font-weight: 500;
                color: #4b5563;
            }
        }
    }
`),v=({items:e})=>e?.[0]?.cancel_note?(0,n.createElement)(n.Fragment,null,(0,n.createElement)("div",{className:"bkt-cancel-note-section"},(0,n.createElement)("h4",{className:"bkt-section-title"},(0,p.__)("Cancellation message from customer","booktics")),(0,n.createElement)(h,null,e[0].cancel_note))):null,y=()=>(0,n.createElement)(x,null,(0,n.createElement)("h4",{className:"bkt-section-title"},(0,p.__)("Customer Details","booktics")),(0,n.createElement)(d.Divider,{size:"small"}),(0,n.createElement)(d.Row,{gutter:[16]},(0,n.createElement)(d.Col,{xs:24,md:12},(0,n.createElement)(d.TextInput,{name:["customer","name"],label:(0,p.__)("Full Name","booktics"),placeholder:(0,p.__)("Enter your full name","booktics")})),(0,n.createElement)(d.Col,{xs:24,md:12},(0,n.createElement)(d.EmailInput,{name:["customer","email"],label:(0,p.__)("Email","booktics"),placeholder:(0,p.__)("Enter email","booktics")})),(0,n.createElement)(d.Col,{xs:24,md:12},(0,n.createElement)(d.CountryPhoneInput,{name:["customer","phone"],label:(0,p.__)("Mobile","booktics")})),(0,n.createElement)(d.Col,{xs:24,md:12},(0,n.createElement)(d.NumberInput,{name:"total_attendees",label:(0,p.__)("Total Attendees","booktics"),disabled:!0,readOnly:!0})),(0,n.createElement)(d.Col,{xs:24},(0,n.createElement)(d.TextInput,{name:["customer","note"],label:(0,p.__)("Note","booktics"),placeholder:(0,p.__)("Write notes","booktics")})))),w=({items:e})=>(0,n.createElement)(f,null,(0,n.createElement)(d.SingleBookingBox,{bookingItem:e[0],isEditMode:!0})),E=[{label:(0,p.__)("Open","booktics"),value:"open"},{label:(0,p.__)("Canceled","booktics"),value:"canceled"},{label:(0,p.__)("Completed","booktics"),value:"completed"}];var _=a(76797);const A=({singleOrder:e})=>(0,n.createElement)(k,null,(0,n.createElement)("div",{className:"bkt-order-info"},(0,n.createElement)(d.Flex,{gap:16},(0,n.createElement)("p",null,(0,n.createElement)("strong",null,(0,p.__)("Order ID:","booktics"))," ",e?.id),(0,n.createElement)("p",null,(0,n.createElement)("strong",null,(0,p.__)("Code:","booktics"))," ",e?.order_no))),(0,n.createElement)(d.Divider,{size:"middle"}),(0,n.createElement)("div",{className:"bkt-status-selects"},(0,n.createElement)(d.Flex,{gap:16,align:"flex-start"},(0,n.createElement)("div",{className:"bkt-status-field"},(0,n.createElement)("label",{className:"bkt-status-label"},(0,p.__)("Order Status","booktics")),(0,n.createElement)(d.FormItem,{name:"status",className:"bkt-status-form-item"},(0,n.createElement)(d.SelectInput,{options:E,placeholder:(0,p.__)("Order Status","booktics"),getPopupContainer:()=>document.body.querySelector(".bkt-status-field")}))),(0,n.createElement)("div",{className:"bkt-status-field"},(0,n.createElement)("label",{className:"bkt-status-label"},(0,p.__)("Payments Status","booktics")),(0,n.createElement)(d.FormItem,{name:"payment_status",className:"bkt-status-form-item"},(0,n.createElement)(d.SelectInput,{options:(0,_.DB)(),placeholder:(0,p.__)("Payment Status","booktics"),getPopupContainer:()=>document.body.querySelector(".bkt-status-field")})))))),{Drawer:S}=window?.booktics?.library||{},C=()=>{const[e]=(0,r.ok)(),{singleOrder:t,singleOrderLoading:a}=(0,o.useSelect)(e=>e(c.orders).getOrdersState(),[]),{serviceList:g}=(e.get("view"),(0,o.useSelect)(e=>e(c.services).getServicesState(),[])),{getServices:h}=(0,s.A)(),{updateOrder:f}=(0,l.A)();(0,i.useEffect)(()=>{g||h()},[g]);const[x]=d.Form.useForm(),{editDrawerOpen:k}=(0,o.useSelect)(e=>e(c?.appointments).getAppointmentState()),{setAppointmentState:E}=(0,o.useDispatch)(c?.appointments),_=()=>{E({editDrawerOpen:!1})};return(0,i.useEffect)(()=>{if(t){const e={customer:t?.customer,payment_status:t?.payment_status,status:t?.status,total_attendees:Number(t?.items?.[0]?.total_attendees),cancel_note:String(t?.items?.[0]?.cancel_note)}||{};x.setFieldsValue(e)}},[t]),t?(0,n.createElement)(b,null,(0,n.createElement)(S,{title:(0,p.__)("Edit Order","booktics"),width:480,placement:"right",onClose:_,open:k,destroyOnHidden:!0,zIndex:999999,footer:(0,n.createElement)(u,{onCancel:_,onSave:x.submit})},a?(0,n.createElement)(d.RowSkeleton,null):(0,n.createElement)("div",{className:"bkt-drawer-content"},(0,n.createElement)(n.Fragment,null,(0,n.createElement)(d.Form,{form:x,layout:"vertical",onFinish:async e=>{const a={...t,...e,customer:{...e.customer,id:t.customer.id}};(await f(a.id,a)).success&&_()}},(0,n.createElement)(A,{singleOrder:t}),t?.directorist_id&&(0,n.createElement)(m.A,{singleOrder:t}),(0,n.createElement)("br",null),(0,n.createElement)(w,{items:t?.items}),(0,n.createElement)(y,null),(0,n.createElement)(v,{items:t?.items})))))):null}},13414:(e,t,a)=>{a.d(t,{A:()=>s});var n=a(47143),o=a(47767),i=a(40309),r=a(11534),l=a(95358);const s=()=>{const e=(0,o.Zp)(),{appointments:t,availability:a,use24h:s,serviceCartList:c,calendarAppointments:d,calendarDateRange:m}=(0,n.useSelect)(e=>e(i?.appointments).getAppointmentState()),{ordersList:p=[],total:u}=(0,n.useSelect)(e=>e(i?.orders).getOrdersState()),{setOrdersState:g}=(0,n.useDispatch)(i?.orders),{setAppointmentState:b}=(0,n.useDispatch)(i?.appointments),h=async(e={})=>{e?.resetFilter&&(e={search:"",paged:"",per_page:"",status:"",service_id:"",payment_status:"",team_member_id:""});const t={...e};b({isFiltering:!0});try{const e=await r.A.appointment.getAppointments(t);if(e.success){const t={appointments:e.data};b(t)}return e}catch(e){console.log(e)}finally{return b({isFiltering:!1}),{complete:!0}}};return{getCartItems:async()=>{if(!c)try{const e=await(r.A?.cart?.getCartItems());e?.success&&b({serviceCartList:e?.data?.items,total_amount:e?.data?.total})}catch(e){console.error("Error retrieving cart items:",e)}},addServiceToCart:async e=>{try{b({isFiltering:!0});const t=await(r.A?.cart.addToCart(e));return t?.success&&b({serviceCartList:[t?.data,...c||[]]}),t}catch(e){console.error("Error creating service:",e)}finally{b({isFiltering:!1})}},editCartItem:async(e,t)=>{try{const a=await(r.A?.cart?.editCart(e,t));if(a?.success){const t=c.map(t=>t?.uuid===e?{...t,...a?.data}:t);b({serviceCartList:t})}return a}catch(e){console.error("Error editing cart item:",e)}},removeFromCart:async e=>{try{const t=await(r.A?.cart?.deleteCartItem(e));t?.success&&b({serviceCartList:c?.filter(t=>t?.uuid!==e)})}catch(e){console.error("Error removing from cart:",e)}},createOrder:async t=>{g({isSavingAppointment:!0});try{const a=c?.map(({uuid:e,team_member_id:t,service_id:a,date:n,start_time:o,end_time:i,price:r,additional_duration_id:l})=>({uuid:e,team_member_id:Number(t),service_id:Number(a),date:n,start_time:o,end_time:i,price:r,additional_duration_id:l})),n=c.reduce((e,t)=>e+parseInt(t.total),0),o=t?.payment_method&&"pay_later"!==t?.payment_method,i={note:t.note,payment_status:t.payment_status,customer:{email:t.email,first_name:t.first_name,last_name:t.last_name},subtotal:n,total:n,items:a,pay_now:o,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone},l=await(r.A?.orders?.createOrder(i));l?.success&&(g({ordersList:[l.data,...p||[]],total:u+1}),b({serviceCartList:[]})),e("/appointments")}catch(e){console.error("Error adding to cart:",e)}finally{g({isSavingAppointment:!1})}},getTimeSlot:async e=>{let t;try{const n=await(r.A?.appointment?.getTimeSlot(e));if(n?.success){let o=(0,l.convertScheduleTimeFormat)({timeSlots:n?.data?.slots,to24Hour:s});e&&(o={...a?.timeSlots,...o});const i=Object.entries(o).filter(([,e])=>Array.isArray(e)&&0===e.length).map(([e])=>e);t={...e,timeSlots:o,disabledDates:i}}return t}catch(e){console.error("Error fetching services:",e)}finally{b({availability:{...t||a,loading:!1}})}},getAllAppointments:h,getCalendarAppointments:async(e={})=>{if(m&&m.start===e.start_date&&m.end===e.end_date)return{success:!0,data:d};try{b({isLoadingCalendar:!0});const t=await r.A.appointment.getCalendarAppointments(e);return t.success&&b({calendarAppointments:t.data.appointments||[],calendarDateRange:{start:e.start_date,end:e.end_date,month:t.data.month}}),t}catch(e){return console.error("Error fetching calendar appointments:",e),{success:!1,message:"Failed to fetch calendar appointments"}}finally{b({isLoadingCalendar:!1})}},bulkDeleteAppointment:async(e=[])=>{try{const a=await(r.A?.appointment.appointmentBulkDelete({ids:e})),n=t.items.filter(t=>!e.includes(t.id));a.success&&b({appointments:{...t,items:n,total:t.items.length}})}catch(e){console.error("Error bulk deleting services:",e)}finally{return{complete:!0}}},deleteSingleAppointment:async(e,a=!1)=>{try{const n=await(r.A?.appointment.deleteSingleAppointment(e));if(n?.success)if(a){const t=d.filter(t=>t.id!==e);b({calendarAppointments:t,editDrawerOpen:!1,selectedAppointment:null,isEditMode:!1})}else{const a=t.items.filter(t=>t.id!==e);b({appointments:{...t,total:a.length,items:a},editDrawerOpen:!1,selectedAppointment:null,isEditMode:!1})}}catch(e){console.error("Error deleting service:",e)}},updateSingleAppointment:async(e,a,n=!1)=>{try{b({isSavingAppointment:!0});const o={...e,...a},i=await r.A.appointment.updateSingleAppointment(e?.id,o);if(i?.success)if(n){const t=d.map(t=>t.id===e?.id?{...t,...i?.data}:t);b({calendarAppointments:t,editDrawerOpen:!1,selectedAppointment:null,isEditMode:!1})}else{const a=t.items.map(t=>t.id===e?.id?i?.data:t);b({appointments:{...t,items:a},editDrawerOpen:!1,selectedAppointment:null,isEditMode:!1})}return i}catch(e){console.log("error updating appointment",e)}finally{b({isSavingAppointment:!1})}},onPaginationChange:(e,t)=>{h({paged:e,per_page:t})}}}},23973:(e,t,a)=>{a.d(t,{A:()=>r});var n=a(47143),o=a(40309),i=a(11534);const r=function(){const{ordersLists:e,searchQuery:t,total:a}=(0,n.useSelect)(e=>e(o.orders).getOrdersState(),[]),{setOrdersState:r}=(0,n.useDispatch)(o.orders),{setAppointmentState:l}=(0,n.useDispatch)(o?.appointments),{appointments:s}=(0,n.useSelect)(e=>e(o?.appointments).getAppointmentState()),c=async e=>{r({singleOrderLoading:!0});try{const t=await(i.A?.orders.singleOrder(e));return t.success&&r({singleOrder:t?.data}),t}catch(e){console.log(e)}finally{r({singleOrderLoading:!1})}};return{updateOrder:async(t,a)=>{try{const n=await(i.A?.orders?.updateOrder(t,a));if(n?.success){const t=e?.map(e=>e.id===n.data.id?n.data:e),a=s?.items.find(e=>e.order_id===n?.data.id);if(r({ordersLists:t,singleOrder:n.data}),a){const e=s.items.map(e=>e.order_id===n.data.id?{...e,payment_status:n?.data.payment_status}:e);l({appointments:{...s,items:e}})}}return n}catch(e){console.error("Error updating orders:",e)}},getOrders:async(e={})=>{e?.resetFilter&&(e={search:"",paged:"",payment_method:"",payment_status:"",order_date:""});const a={...t,...e};r({isFiltering:!0});try{const e=await(i.A?.orders?.allOrders(a));e?.success&&r({ordersLists:e?.data?.items,total:e?.data?.total,searchQuery:a})}catch(e){console.error("Error fetching services:",e)}finally{return r({isFiltering:!1}),{complete:!0}}},singleOrderDelete:async t=>{try{const n=await(i.A?.orders.deleteSingleOrder(t));n?.success&&r({ordersLists:e?.filter(e=>e.id!==t),total:a-1})}catch(e){console.error("Error deleting service:",e)}},bulkDeleteOrder:async(t=[])=>{try{const a=await(i.A?.orders?.bulkDeleteOrders({ids:t}));if(a?.success&&a?.data){const t=e.map(e=>e.id===id?a.data:e);r({ordersLists:t})}}catch(e){console.error("Error bulk deleting services:",e)}finally{return{complete:!0}}},getSingleOrder:c,onPaginationChange:(e,t)=>{getServices({paged:e,per_page:t})},handleOrderEdit:async e=>{l({editDrawerOpen:!0}),await c(e)}}}},25723:(e,t,a)=>{e.exports=a.p+"images/user_avtar.d4c06dd9.png"},30151:(e,t,a)=>{a.d(t,{Ac:()=>l,DA:()=>r,OV:()=>i});var n=a(59e3),o=a(22564);const i=n.A.div`
    .ant-tag {
        font-size: 12px;
        font-weight: 600;
        padding: 6px 8px;
        margin-right: 0px;
        span{
            line-height: 1.2;
            text-transform: capitalize;
        }
    }
`,r=(0,n.A)(o.Flex)`
    .btk-re-invite-btn{
        height: 36px;
        border-radius: 4px;
        box-shadow: none;
        font-weight: 500;
        font-size: 14px;
    }
    .btk-edit-btn{
        height: 36px !important;
    }
`,l=(0,n.A)(o.SelectInput)`
    min-width: 190px;
    width: 100%;
`},52911:(e,t,a)=>{a.d(t,{A:()=>l});var n=a(47143),o=a(47767),i=a(40309),r=a(11534);const l=()=>{const{setTeamState:e}=(0,n.useDispatch)(i?.team),{setServicesState:t}=(0,n.useDispatch)(i?.services),{id:a}=(0,o.g)(),{teamMembers:l,enable_custom_availability:s,selectedServices:c,profileInfo:d,customSchedule:m,holiday:p,schedule:u,searchQuery:g}=(0,n.useSelect)(i?.team).getTeamState(),{serviceList:b}=(0,n.useSelect)(i?.services).getServicesState(),h=async(t={})=>{t?.resetFilter&&(t={service_id:"",paged:"",per_page:""});const a={...g,...t};e({isFiltering:!0});try{const t=await r.A.team.allTeamMembers(a);t.success&&e({teamMembers:{...t?.data},searchQuery:a})}catch(e){console.log(e)}};return{getMyprofileInfo:async()=>{try{const t=await r.A.team.getTeamMemberProfile();t.success&&e({profileInfo:t.data})}catch(e){console.log(e)}},getTeamMembers:h,addTeamMember:async t=>{try{e({editLoading:!0});const a=await r.A.team.createTeamMember(t);a.success&&e({teamMembers:{...l,total:l.total+1,items:[{...a?.data},...l.items]},visibleModal:!1}),e({editLoading:!1})}catch(t){console.log(t),e({editLoading:!1})}finally{e({editLoading:!1})}},deleteTeamMember:async t=>{try{if((await r.A.team.deleteSingleTeamMember(t)).success){const a=l.items.filter(e=>e.id!==t);e({teamMembers:{...l,total:a.length,items:a}})}}catch(e){console.log(e)}},getSingleTeamMember:async()=>{try{const t=await r.A.team.singleTeamMember(a);t.success&&e({singleTeamMember:{...t?.data},selectedServices:t?.data?.services})}catch(e){console.log(e)}},teamMemberBulkDelete:async(t=[])=>{try{if((await r.A.team.bulkDeleteTeamMember({ids:t})).success){const a=l.items.filter(e=>!t.includes(e.id));e({teamMembers:{...l,items:a}})}}catch(e){console.log(e)}},editTeamMember:async n=>{const o={...n,schedule:u,services:c,custom:n.enable_custom_schedule?m:[],holiday:n.enable_custom_holiday?p:[],enable_custom_availability:s},i=a||d.id;try{e({editLoading:!0});const a=await r.A.team.updateTeamMember(i,o);if(a?.success){const n=l?.items?.map(e=>e?.id===a?.data?.id?a?.data:e);e({teamMembers:{...l,items:n},editLoading:!1});const o=b?.map(e=>Array.isArray(e.team_member)&&e.team_member.includes(a?.data?.id)&&Array.isArray(e.team_member_details)?{...e,team_member_details:e.team_member_details.map(e=>e.id===a?.data?.id?{...e,image:a?.data?.image}:e)}:e);t({serviceList:o})}}catch(e){console.error("Failed to update team member:",e)}finally{e({editLoading:!1})}},reInviteTeam:async e=>{try{const t=await r.A.team.reInviteTeamMember(e);t.success&&window.wp?.hooks.doAction("notification",{type:"success",message:t?.message})}catch(e){console.log(e)}},onPaginationChange:(e,t)=>{h({paged:e,per_page:t})}}}},76797:(e,t,a)=>{a.d(t,{DB:()=>o,Dl:()=>r,JZ:()=>i});var n=a(27723);const o=()=>[{label:(0,n.__)("Not Paid","booktics"),value:"not_paid"},{label:(0,n.__)("Fully Paid","booktics"),value:"fully_paid"},{label:(0,n.__)("Processing","booktics"),value:"processing"}],i=[{label:(0,n.__)("Local","booktics"),value:"pay_later"},{label:(0,n.__)("Stripe","booktics"),value:"stripe"},{label:(0,n.__)("Paypal","booktics"),value:"paypal"}],r={not_paid:"#ef4444",partially_paid:"#3b82f6",paid:"#10b981",processing:"#f59e0b"}},87492:(e,t,a)=>{a.d(t,{A:()=>r});var n=a(51609),o=a(22564),i=a(27723);const r=({singleOrder:e})=>(0,n.createElement)("div",null,e?.directorist_id&&(0,n.createElement)(n.Fragment,null,(0,n.createElement)(o.Title,{level:5,text:(0,i.__)("Directory Listing","booktics")}),(0,n.createElement)(o.Link,{href:e?.directorist_url,text:e?.directorist_title})))},89841:(e,t,a)=>{a.d(t,{$4:()=>m,A1:()=>i,Ac:()=>r,LI:()=>l,V9:()=>c,nu:()=>d,vI:()=>s});var n=a(59e3),o=a(22564);const i=(0,n.A)(o.Tag)`
    &.ant-tag {
        color: ${({textColor:e})=>e||null} !important;
        background-color: ${({bg:e})=>e||null};
    }
`,r=(0,n.A)(o.SelectInput)`
    &.ant-select .ant-select-selection-item {
        color: ${({textColor:e})=>e||null};
        font-weight: 500;
    }
`,l=n.A.h4`
    font-size: 14px;
    color: ${({textColor:e})=>e||null};
    margin: 0;
`,s=(0,n.A)(o.Tag)`
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
`,c=(0,n.A)(o.Flex)`
    background-color: #fafafa;
    border-radius: 10px;
    min-height: 140px;
    margin-bottom: 40px;
`,d=n.A.div`
    .bkt-service-text {
        font-size: 12px;
        color: #36364d;
        display: block;
        margin-bottom: 12px;
    }
    .bkt-cost-breakdown {
        color: #36364d;
        font-size: 14px;
        font-weight: 500;
    }
    .bkt-payment-service-text {
        position: relative;
        margin-left: 16px;
        &::before {
            content: "";
            position: absolute;
            width: 6px;
            height: 6px;
            border-radius: 100px;
            background-color: black;
            left: -16px;
            top: 8px;
        }
    }
    .btk-semi-bold-text {
        font-size: 16px;
        font-weight: 600;
        color: #36364d;
    }
    margin-bottom: 10px;
`,m=n.A.div`
    border-radius: 8px;
    padding: 20px;
    background-color: #fafafa;
    width: 100%;
    margin-bottom: 12px;

    h3 {
        font-size: 16px;
        font-weight: 500;
        color: #36364d;
        margin-bottom: 12px !important;
    }
    .bkt-duration-wrapper {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    .bkt-extra-service-card {
    }
`},96361:(e,t,a)=>{a.r(t),a.d(t,{default:()=>it});var n=a(51609),o=a(47143),i=a(86087),r=a(47767),l=a(84976),s=a(48876),c=a(22639),d=a(40309),m=a(22564),p=a(56580),u=a(13414),g=a(12017),b=a(23973),h=a(11804),f=a(59e3),x=a(27723);const k=[{label:(0,x.__)("Pending","booktics"),value:"pending"},{label:(0,x.__)("Approved","booktics"),value:"approved"},{label:(0,x.__)("Canceled","booktics"),value:"canceled"},{label:(0,x.__)("Completed","booktics"),value:"completed"}],v=[{label:(0,x.__)("Not Paid","booktics"),value:"not_paid"},{label:(0,x.__)("Partially Paid","booktics"),value:"partially_paid"},{label:(0,x.__)("Fully Paid","booktics"),value:"fully_paid"}],y={pending:{color:"#F5AC05"},approved:{color:"#52C41A"},canceled:{color:"#F50505"},completed:{color:"#36364D"}},w=f.A.div`
  .bkt-customer-email {
      font-size: 14px;
      color: #36364D;
      padding: 5px 10px;
    }
  .bkt-appointment-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0;
    padding-right: 5px;
    padding: 5px 10px;
    
    .customer-info {
      flex: 1;
      min-width: 0; 
      h4 {
        margin: 0 0 4px 0;
        font-size: 20px;
        font-weight: 600;
        color: #36364D;
      }
      
    }
    
    .action-buttons {
      display: flex;
      gap: 8px;
      margin-left: auto;
      flex-shrink: 0;
      .ant-btn {
       background: #F5F5F5;
      border:none;
        &:hover {
          background: #f5f5f5;
          color: #262626;
        }
      }
    }
  }
  
  .bkt-tooltip-divider {
    margin: 12px 0;
    border-color: #f0f0f0;
  }
  
  .bkt-tooltip-body {
    margin-bottom: 0;
    padding: 5px 10px;
    .bkt-tooltip-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 8px;
      
      &:last-child {
        margin-bottom: 0;
      }
      
      .label {
        font-size: 14px;
        color: #7A7A99;
        font-weight: 500;
        min-width: 60px;
      }
      
      .value {
        font-size: 14px;
        color: #36364D;
        text-align: right;
        flex: 1;
        font-weight: 500;
      }
    }
  }

  .tooltip-footer {
    margin-bottom: 0;
    padding-bottom:  10px;
    .bkt-tooltip-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 0;
      
      .label {
        font-size: 14px;
        color: #7A7A99;
        font-weight: 500;
        min-width: 60px;
      }
      
      .value {
        font-size: 14px;
        color: #36364D;
        text-align: right;
        flex: 1;
        font-weight: 500;
      }
    }
  }

  // Status section styling
  .bkt-status-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding:5px 10px;
    
    .status-label {
      font-size: 14px;
      color: #7A7A99;
      font-weight: 500;
    }
    
  }
`,E=f.A.div`
  .calendar-content {
    padding: 0 0 16px;

    .ant-picker-body {
      padding: 0;
    }

    thead {
     border-bottom: 1px solid #f0f0f0;
     background: #f3f5f7;  
     
     th {
       padding: 12px 8px;
       text-align: center;
       font-weight: 500;
       color: #595959;
       font-size: 14px;
     }
    }
  }

  .ant-picker-calendar {
    .ant-picker-panel {
      background: transparent;

      .ant-picker-body {
        th {
          padding: 10px;
        }
        
        tbody {
          border-bottom: 1px solid rgba(5, 5, 5, 0.06);
        }
      }
    }
    
    .ant-picker-calendar-date {
      height: 120px;
      overflow-y: auto;
      margin: 0;
      border-right: 2px solid rgba(5, 5, 5, 0.06);
      padding: 4px 0 0;
      border-bottom: 1px solid rgba(5, 5, 5, 0.06);
      
      &::-webkit-scrollbar {
        width: 2px;
      }
      
      &::-webkit-scrollbar-track {
        background: transparent;
      }
      
      &::-webkit-scrollbar-thumb {
        background: #d9d9d9;
        border-radius: 2px;
      }

      .ant-picker-calendar-date-value {
        top: 4px;
        right: 23px;
      }
    }
    
    .ant-picker-calendar-date-value {
      position: absolute;
      top: 8px;
      right: 12px;
      font-weight: 500;
      z-index: 1;
    }
  }

  // Global tooltip styling with higher specificity
  .ant-tooltip {
    max-width: 300px !important;
    
    .ant-tooltip-content {
      .ant-tooltip-inner {
        background: #fff !important;
        color: #262626 !important;
        border: 1px solid #e8e8e8 !important;
        border-radius: 8px !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
        padding: 16px !important;
        font-size: 14px !important;
      }
    }
    
    .ant-tooltip-arrow {
      &::before {
        background: #fff !important;
        border: 1px solid #e8e8e8 !important;
      }
      
      &::after {
        background: #fff !important;
      }
    }
  }

  // Status dropdown in tooltip - global override
  .ant-tooltip .ant-select-dropdown {
    .ant-select-item {
      padding: 8px 12px !important;
      font-size: 14px !important;
      
      .status-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        display: inline-block;
        margin-right: 8px;
      }
    }
    
    .ant-select-item-option-selected {
      background: #e6f7ff !important;
      color: #1890ff !important;
    }
    
    .ant-select-item-option-active {
      background: #f5f5f5 !important;
    }
  }
`,_=(f.A.div`
  .ant-segmented {
    background: #fff;
    border-radius: 8px;
    padding: 2px;
    border: 1px solid #d9d9d9;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);

    .ant-segmented-item {
      padding: 6px 16px;
      font-size: 12px;
      font-weight: 500;
      
      &.ant-segmented-item-selected {
        border: 0.5px solid #22b855;
        color: #22b855;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
      }
    }
  }
`,f.A.div`
  padding: 24px 8px 8px 8px;
  height: 100%;
  
`),A=f.A.div`
  display: flex;
  flex-direction: column;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;

  .bkt-week-header {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e8e8e8;
    
    .bkt-time-column-header {
      width: 60px;
      min-width: 60px;
      border-right: 1px solid #e8e8e8;
      background: #fafafa;
    }
    
    .bkt-week-day-header {
      flex: 1;
      text-align: center;
      padding: 12px 8px;
      border-right: 1px solid #e8e8e8;
      
      &:last-child {
        border-right: none;
      }
      
      .bkt-day-name {
        font-size: 12px;
        color: #666;
        font-weight: 500;
        margin-bottom: 4px;
        text-transform: capitalize;
      }
      
      .bkt-day-number {
        font-size: 16px;
        font-weight: 600;
        color: #333;
        position: relative;
        
        .bkt-today-indicator {
          color: #1890ff;
          margin-right: 4px;
        }
      }
    }
  }
  
  .bkt-week-time-grid {
    max-height: 600px; /* Maximum height for scrolling */
    overflow-y: auto;
    
    /* Custom scrollbar styling */
    &::-webkit-scrollbar {
      width: 6px;
    }
    
    &::-webkit-scrollbar-track {
      background: #f1f1f1;
      border-radius: 3px;
    }
    
    &::-webkit-scrollbar-thumb {
      background: #c1c1c1;
      border-radius: 3px;
      
      &:hover {
        background: #a8a8a8;
      }
    }
    
    .bkt-time-row {
      display: flex;
      border-bottom: 1px solid #f0f0f0;
      min-height: 60px;
      max-height: 120px; /* Maximum height per row */
      
      &:last-child {
        border-bottom: none;
      }
      
      .bkt-time-label {
        width: 60px;
        min-width: 60px;
        padding: 8px 4px;
        font-size: 11px;
        color: #666;
        text-align: center;
        border-right: 1px solid #e8e8e8;
        background: #fafafa;
        display: flex;
        align-items: flex-start;
        justify-content: center;
        font-weight: 500;
        position: sticky;
        left: 0;
        z-index: 1;
      }
      
      .bkt-time-slot {
        flex: 1;
        padding: 4px 8px;
        border-right: 1px solid #f0f0f0;
        min-height: 60px;
        max-height: 120px;
        position: relative;
        overflow-y: auto;
        
        &:last-child {
          border-right: none;
        }
        
        &:hover {
          background: #f8f9fa;
        }
        
        /* Custom scrollbar for time slots */
        &::-webkit-scrollbar {
          width: 3px;
        }
        
        &::-webkit-scrollbar-track {
          background: transparent;
        }
        
        &::-webkit-scrollbar-thumb {
          background: #d9d9d9;
          border-radius: 2px;
        }
      }
    }
  }
`,S=f.A.div`
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  overflow: hidden;
  
  .bkt-day-header {
    text-align: center;
    padding: 16px;
    border-bottom: 1px solid #e8e8e8;
    background: #f8f9fa;
    
    .bkt-day-title {
      margin: 0;
      font-size: 18px;
      font-weight: 600;
      color: #333;
    }
  }
  
  .bkt-day-time-grid {
    max-height: 600px; /* Maximum height for scrolling */
    overflow-y: auto;
    
    /* Custom scrollbar styling */
    &::-webkit-scrollbar {
      width: 6px;
    }
    
    &::-webkit-scrollbar-track {
      background: #f1f1f1;
      border-radius: 3px;
    }
    
    &::-webkit-scrollbar-thumb {
      background: #c1c1c1;
      border-radius: 3px;
      
      &:hover {
        background: #a8a8a8;
      }
    }
    
    .bkt-time-row {
      display: flex;
      border-bottom: 1px solid #f0f0f0;
      min-height: 60px;
      max-height: 150px; /* Maximum height per row */
      
      &:last-child {
        border-bottom: none;
      }
      
      .bkt-time-label {
        width: 60px;
        min-width: 60px;
        padding: 8px 4px;
        font-size: 11px;
        color: #666;
        text-align: center;
        border-right: 1px solid #e8e8e8;
        background: #fafafa;
        display: flex;
        align-items: flex-start;
        justify-content: center;
        font-weight: 500;
        position: sticky;
        left: 0;
        z-index: 1;
      }
      
      .bkt-time-slot {
        flex: 1;
        padding: 8px 16px;
        min-height: 60px;
        max-height: 150px;
        position: relative;
        overflow-y: auto;
        
        &:hover {
          background: #f8f9fa;
        }
        
        .bkt-empty-slot {
          height: 100%;
          width: 100%;
        }
        
        /* Responsive grid layout for appointments */
        .bkt-appointments-grid {
          display: grid;
          gap: 8px;
          
          /* Mobile: 1 column */
          grid-template-columns: 1fr;
          
          /* Tablet: 2 columns */
          @media (min-width: 768px) {
            grid-template-columns: repeat(2, 1fr);
          }
          
          /* Desktop: 3 columns */
          @media (min-width: 1024px) {
            grid-template-columns: repeat(3, 1fr);
          }
          
          /* Large screens: maintain 3 columns but with better spacing */
          @media (min-width: 1440px) {
            grid-template-columns: repeat(3, 1fr);
            gap: 12px;
          }
        }
        
        /* Custom scrollbar for time slots */
        &::-webkit-scrollbar {
          width: 3px;
        }
        
        &::-webkit-scrollbar-track {
          background: transparent;
        }
        
        &::-webkit-scrollbar-thumb {
          background: #d9d9d9;
          border-radius: 2px;
        }
      }
    }
  }

  // Legacy styles for old day view (if still needed)
  .day-content {
    padding: 16px;
    
    .no-appointments {
      text-align: center;
      color: #8c8c8c;
      font-size: 14px;
      padding: 32px;
    }
    
    .day-appointment {
      margin-bottom: 12px;
      padding: 16px;
      
      &:last-child {
        margin-bottom: 0;
      }
    }
  }
`,C=f.A.div`
  /* Existing styles */
  background: ${e=>`${y[e.status]?.color}20`||"#fafafa"};
  border: 1px solid ${e=>y[e.status]?.color||"#d9d9d9"};
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 11px;
  margin-bottom: 4px;
  width: 100%;
  box-sizing: border-box;
  
  &:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
  
  .bkt-appointment-time {
    font-weight: 600;
    color: #262626;
    font-size: 10px;
    margin-bottom: 4px;
  }
  
  .bkt-appointment-title {
    color: #595959;
    font-size: 10px;
    font-weight: 500;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  
  // Week view specific styles - for time grid
  &.bkt-week-appointment {
    margin-bottom: 2px;
    padding: 4px 6px;
    
    .bkt-appointment-time {
      font-size: 9px;
    }
    
    .bkt-appointment-title {
      font-size: 10px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
  
  // Day view specific styles - for responsive grid
  &.bkt-day-appointment {
    font-size: 12px;
    padding: 10px 12px;
    margin-bottom: 0; /* Remove margin since grid handles spacing */
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    
    .bkt-appointment-time {
      font-size: 11px;
      margin-bottom: 6px;
    }
    
    .bkt-appointment-title {
      font-size: 11px;
      line-height: 1.3;
      white-space: normal;
      overflow: visible;
      text-overflow: unset;
    }
    
    /* Responsive font sizes */
    @media (max-width: 767px) {
      padding: 8px 10px;
      min-height: 50px;
      
      .bkt-appointment-time {
        font-size: 10px;
      }
      
      .bkt-appointment-title {
        font-size: 10px;
      }
    }
  }

  /* Add new styles for source icons and layout */
  .bkt-appointment-content {
    display: flex;
    align-items: flex-start;
    gap: 4px;
  }
  
  .bkt-source-icon-wrapper {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    
    svg {
      width: 14px;
      height: 14px;
    }
  }
  
  .bkt-appointment-details {
    flex-grow: 1;
    min-width: 0; /* Important for text truncation */
  }
  

  .bkt-appointment-time {
    font-weight: 500;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    color: #595959;
    text-overflow: ellipsis;
  }
  
  .bkt-appointment-title {
    color: #262626;
    font-size: 12px;
    line-height:14px;
    white-space: nowrap;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Week view specific styles */
  &.bkt-week-appointment {
    .bkt-source-icon-wrapper svg {
      width: 12px;
      height: 12px;
    }
  }

  /* Day view specific styles */
  &.bkt-day-appointment {
    .bkt-source-icon-wrapper svg {
      width: 16px;
      height: 16px;
    }
    
    .bkt-appointment-time {
      font-size: 11px;
    }
    
    .bkt-appointment-title {
      font-size: 11px;
    }
  }
`,D=f.A.div`
  .bkt-calendar-custom-header {
    padding: 0 16px 24px;
    
    .calendar-title {
      margin: 0;
      font-size: 18px;
      font-weight: 600;
      color: #262626;
      
      @media (max-width: 767px) {
        font-size: 16px;
      }
    }
    
    /* Mobile Layout (hidden on desktop) */
    .btk-mobile-header {
      display: flex;
      flex-direction: column;
      gap: 12px;
      
      @media (min-width: 768px) {
        display: none;
      }
      
      .mobile-title-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        
        .mobile-nav-buttons {
          display: flex;
          gap: 4px;
          
          .nav-btn {
            min-width: 32px;
            height: 32px;
            padding: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 6px;
            border: 1px solid #d9d9d9;
            background: #fff;
            
            &:hover {
              border-color: #22b855;
              color: #22b855;
            }
          }
        }
      }
      
      .mobile-controls-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        
        .today-btn {
          padding: 4px 12px;
          height: 32px;
          font-size: 12px;
          border-radius: 6px;
          border: 1px solid #d9d9d9;
          background: #fff;
          
          &:hover {
            border-color: #22b855;
            color: #22b855;
          }
        }
        
        .mobile-view-tabs {
          .ant-segmented {
            background: #fff;
            border-radius: 6px;
            padding: 2px;
            border: 1px solid #d9d9d9;
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);

            .ant-segmented-item {
              padding: 4px 8px;
              font-size: 11px;
              font-weight: 500;
              min-width: auto;
              
              &.ant-segmented-item-selected {
                border: 0.5px solid #22b855;
                color: #22b855;
                box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
              }
            }
          }
        }
      }
    }
    
    /* Desktop Layout (hidden on mobile) */
    .btk-desktop-header {
      display: none;
      
      @media (min-width: 768px) {
        display: block;
      }
      
      .desktop-view-tabs {
        .ant-segmented {
          background: #fff;
          border-radius: 8px;
          padding: 2px;
          border: 1px solid #d9d9d9;
          box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);

          .ant-segmented-item {
            padding: 6px 16px;
            font-size: 12px;
            font-weight: 500;
            
            @media (max-width: 1024px) {
              padding: 6px 12px;
              font-size: 11px;
            }
            
            &.ant-segmented-item-selected {
              border: 0.5px solid #22b855;
              color: #22b855;
              box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
            }
          }
        }
      }
      
      /* Tablet adjustments */
      @media (max-width: 1024px) {
        .ant-btn {
          padding: 4px 12px;
          font-size: 12px;
        }
      }
    }
  }
`,M=({viewTitle:e,calendarView:t,onViewChange:a,onPrevious:o,onNext:i,onToday:r})=>(0,n.createElement)(D,null,(0,n.createElement)("div",{className:"bkt-calendar-custom-header"},(0,n.createElement)("div",{className:"btk-mobile-header"},(0,n.createElement)("div",{className:"mobile-title-row"},(0,n.createElement)("h3",{className:"calendar-title"},e),(0,n.createElement)("div",{className:"mobile-nav-buttons"},(0,n.createElement)(m.Button,{size:"small",onClick:o,className:"nav-btn"},"←"),(0,n.createElement)(m.Button,{size:"small",onClick:i,className:"nav-btn"},"→"))),(0,n.createElement)("div",{className:"mobile-controls-row"},(0,n.createElement)(m.Button,{size:"small",onClick:r,className:"today-btn"},(0,x.__)("Today","booktics")),(0,n.createElement)("div",{className:"mobile-view-tabs"},(0,n.createElement)(h.A,{value:t,onChange:a,size:"small",options:[{label:(0,x.__)("Month","booktics"),value:"Month"},{label:(0,x.__)("Week","booktics"),value:"Week"},{label:(0,x.__)("Day","booktics"),value:"Day"}]})))),(0,n.createElement)("div",{className:"btk-desktop-header"},(0,n.createElement)(m.Flex,{justify:"space-between",align:"center"},(0,n.createElement)("h3",{className:"calendar-title"},e),(0,n.createElement)(m.Flex,{gap:12,align:"center"},(0,n.createElement)(m.Flex,{gap:8},(0,n.createElement)(m.Button,{onClick:o},"←"),(0,n.createElement)(m.Button,{onClick:r},(0,x.__)("Today","booktics")),(0,n.createElement)(m.Button,{onClick:i},"→")),(0,n.createElement)("div",{className:"desktop-view-tabs"},(0,n.createElement)(h.A,{value:t,onChange:a,options:[{label:(0,x.__)("Month","booktics"),value:"Month"},{label:(0,x.__)("Week","booktics"),value:"Week"},{label:(0,x.__)("Day","booktics"),value:"Day"}]})))))));var N=a(74353),F=a.n(N);const $=()=>{const e=[];for(let t=0;t<24;t++){const a=0===t?"12am":t<12?`${t}am`:12===t?"12pm":t-12+"pm";e.push({hour:t,display:a,time24:`${t.toString().padStart(2,"0")}:00`})}return e},z=(e,t)=>e.filter(e=>parseInt(e.start_time?.split(":")[0]||"0")===t.hour);var O=a(46714),T=a(89841);const I=({record:e={},onSelect:t})=>{const{status:a="pending"}=e,{isAdmin:o}=(0,p.useUserRole)(),[r,l]=(0,i.useState)(a);return(0,n.createElement)("div",{onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation()},(0,n.createElement)(T.Ac,{options:k,defaultValue:a,textColor:y[r]?.color,onChange:a=>{l(a),t(a,e)},disabled:!o,optionRender:e=>(0,n.createElement)(T.LI,{textColor:y[e.value||"pending"]?.color},e.label)}))},Y=({record:e,isCalender:t=!1})=>{const{updateSingleAppointment:a}=(0,u.A)(),o=(0,i.useCallback)(async n=>{await a(e,{status:n},t)},[]);return(0,n.createElement)(I,{record:e,onSelect:o})},P=({appointment:e})=>(0,n.createElement)(n.Fragment,null,(0,n.createElement)("div",{className:"bkt-status-section"},(0,n.createElement)("span",{className:"status-label"},(0,x.__)("Appointment Status","booktics")),(0,n.createElement)(Y,{record:e,isCalender:!0})),(0,n.createElement)(m.Divider,{className:"bkt-tooltip-divider"})),L=({appointment:e,isExternalAppointment:t=!1})=>(0,n.createElement)("div",{className:"bkt-tooltip-body"},t?null:(0,n.createElement)("div",{className:"bkt-tooltip-row"},(0,n.createElement)("span",{className:"label"},(0,x.__)("Service:","booktics")),(0,n.createElement)("span",{className:"value"},e?.service?.title||(0,x.__)("N/A","booktics"))),(0,n.createElement)("div",{className:"bkt-tooltip-row"},(0,n.createElement)("span",{className:"label"},(0,x.__)("Time:","booktics")),(0,n.createElement)("span",{className:"value"},e?.start_time&&e?.end_time?`${e.start_time} - ${e.end_time}`:(0,x.__)("Time not specified","booktics"))),t?null:(0,n.createElement)(n.Fragment,null,(0,n.createElement)(m.Divider,{className:"bkt-tooltip-divider"}),(0,n.createElement)("div",{className:"tooltip-footer"},(0,n.createElement)("div",{className:"bkt-tooltip-row"},(0,n.createElement)("span",{className:"label"},(0,x.__)("Team:","booktics")),(0,n.createElement)("span",{className:"value"},e?.team_member?.display_name||(0,x.__)("Unassigned","booktics")))))),{MoreOutlined:R}=window?.booktics?.libraryIcons||{},B=({appointment:e,onEdit:t,dropdownItems:a,isExternalAppointment:o})=>(0,n.createElement)(n.Fragment,null,(0,n.createElement)("div",{className:"bkt-appointment-tooltip-header"},(0,n.createElement)("div",{className:"customer-info"},(0,n.createElement)("h4",null,e?.customer?.name||(0,x.__)("Customer","booktics"))),o?null:(0,n.createElement)("div",{className:"action-buttons"},(0,n.createElement)(m.Can,null,(0,n.createElement)(m.Tooltip,{title:(0,x.__)("Edit Appointment","booktics")},(0,n.createElement)(m.Button,{title:(0,x.__)("Edit","booktics"),icon:(0,n.createElement)(O.EditIcon,null),onClick:t,size:"middle"}))),(0,n.createElement)(m.Can,null,(0,n.createElement)(m.Dropdown,{menu:{items:a},placement:"bottomRight",arrow:!1,trigger:"hover"},(0,n.createElement)(m.Button,{title:(0,x.__)("More","booktics"),icon:(0,n.createElement)(R,null),size:"middle"}))))),(0,n.createElement)("span",{className:"bkt-customer-email"},e?.customer?.email||(0,x.__)("No email provided","booktics")),(0,n.createElement)(m.Divider,{className:"bkt-tooltip-divider"})),{DeleteOutlined:j}=window?.booktics?.libraryIcons||{},W=({appointment:e,children:t,placement:a="right",isExternalAppointment:r})=>{const{deleteSingleAppointment:l}=(0,u.A)(),{getSingleOrder:s}=(0,b.A)(),{setAppointmentState:c}=(0,o.useDispatch)(d?.appointments),p=(0,i.useCallback)(()=>{window.wp?.hooks?.doAction("delete_confirmation",{title:(0,x.__)("Are you sure you want to delete the appointment","booktics"),onOk:()=>l(e?.id,!0)})},[l,e?.id]),g=(0,i.useCallback)(()=>{r||c({editDrawerOpen:!0,selectedAppointment:e,isEditMode:!1})},[e]),h=(0,i.useMemo)(()=>[{key:"preview",label:(0,n.createElement)(m.Flex,{gap:6},(0,n.createElement)(O.PreviewIcon,null)," ",(0,x.__)("Preview","booktics")),onClick:g},{key:"delete",label:(0,n.createElement)(m.Flex,{gap:6},(0,n.createElement)(j,null)," ",(0,x.__)("Delete","booktics")),danger:!0,onClick:p}],[p]),f=(0,i.useCallback)(async()=>{r||e?.order_id&&(c({editDrawerOpen:!0}),await s(e?.order_id))},[e]);return(0,n.createElement)(m.Tooltip,{title:(0,n.createElement)(w,{onClick:e=>e.stopPropagation()},(0,n.createElement)(B,{appointment:e,onEdit:f,dropdownItems:h,isExternalAppointment:r}),(0,n.createElement)(m.Can,null,!r&&(0,n.createElement)(P,{appointment:e})),(0,n.createElement)(L,{appointment:e,isExternalAppointment:r})),placement:a,color:"#fff",trigger:"hover"},t)},H={google:(0,n.createElement)(O.GoogleIcon,null),outlook:(0,n.createElement)(O.OutLookCalenderIcon,null)},V=(0,i.memo)(({appointment:e,onClick:t,placement:a="top",className:o=""})=>{const{start_time:i,end_time:r,service:l={},source:s="booktics"}=e,c=H[s],d="booktics"!==s;return(0,n.createElement)(W,{appointment:e,placement:a,isExternalAppointment:d},(0,n.createElement)(C,{status:e.status,onClick:a=>{a.preventDefault(),a.stopPropagation(),t(e)},className:`bkt-source-${s} ${o}`},(0,n.createElement)("div",{className:"bkt-appointment-content"},c&&(0,n.createElement)("div",{className:"bkt-source-icon-wrapper"},c),(0,n.createElement)("div",{className:"bkt-appointment-details"},(0,n.createElement)("div",{className:"bkt-appointment-title"},l?.title||""),(0,n.createElement)("div",{className:"bkt-appointment-time"},i,"- ",r)))))}),Q=({selectedDate:e,appointmentsByDate:t,onEditAppointment:a})=>{const o=t[e.format("YYYY-MM-DD")]||[],i=$();return(0,n.createElement)(S,null,(0,n.createElement)("div",{className:"bkt-day-header"},(0,n.createElement)("div",{className:"bkt-day-title"},e.format("dddd"))),(0,n.createElement)("div",{className:"bkt-day-time-grid"},i.map((e,t)=>{const i=z(o,e);return(0,n.createElement)("div",{key:t,className:"bkt-time-row"},(0,n.createElement)("div",{className:"bkt-time-label"},e.display),(0,n.createElement)("div",{className:"bkt-time-slot"},0===i.length?(0,n.createElement)("div",{className:"bkt-empty-slot"}):(0,n.createElement)("div",{className:"bkt-appointments-grid"},i.map(e=>(0,n.createElement)(V,{key:e.id,appointment:e,onClick:a,placement:"top",className:"bkt-day-appointment"})))))})))};var X=a(52699),K=a(46942),q=a.n(K),Z=a(61860),G=a(12533),U=a(62279),J=a(19155),ee=a(94241),te=a(70464),ae=a(55352),ne=a(36492);function oe(e){const{fullscreen:t,validRange:a,generateConfig:o,locale:i,prefixCls:r,value:l,onChange:s,divRef:c}=e,d=o.getYear(l||o.getNow());let m=d-10,p=m+20;a&&(m=o.getYear(a[0]),p=o.getYear(a[1])+1);const u=i&&"年"===i.year?"年":"",g=[];for(let e=m;e<p;e++)g.push({label:`${e}${u}`,value:e});return n.createElement(ne.A,{size:t?void 0:"small",options:g,value:d,className:`${r}-year-select`,onChange:e=>{let t=o.setYear(l,e);if(a){const[e,n]=a,i=o.getYear(t),r=o.getMonth(t);i===o.getYear(n)&&r>o.getMonth(n)&&(t=o.setMonth(t,o.getMonth(n))),i===o.getYear(e)&&r<o.getMonth(e)&&(t=o.setMonth(t,o.getMonth(e)))}s(t)},getPopupContainer:()=>c.current})}function ie(e){const{prefixCls:t,fullscreen:a,validRange:o,value:i,generateConfig:r,locale:l,onChange:s,divRef:c}=e,d=r.getMonth(i||r.getNow());let m=0,p=11;if(o){const[e,t]=o,a=r.getYear(i);r.getYear(t)===a&&(p=r.getMonth(t)),r.getYear(e)===a&&(m=r.getMonth(e))}const u=l.shortMonths||r.locale.getShortMonths(l.locale),g=[];for(let e=m;e<=p;e+=1)g.push({label:u[e],value:e});return n.createElement(ne.A,{size:a?void 0:"small",className:`${t}-month-select`,value:d,options:g,onChange:e=>{s(r.setMonth(i,e))},getPopupContainer:()=>c.current})}function re(e){const{prefixCls:t,locale:a,mode:o,fullscreen:i,onModeChange:r}=e;return n.createElement(te.A,{onChange:({target:{value:e}})=>{r(e)},value:o,size:i?void 0:"small",className:`${t}-mode-switch`},n.createElement(ae.A,{value:"month"},a.month),n.createElement(ae.A,{value:"year"},a.year))}const le=function(e){const{prefixCls:t,fullscreen:a,mode:o,onChange:i,onModeChange:r}=e,l=n.useRef(null),s=(0,n.useContext)(ee.$W),c=(0,n.useMemo)(()=>Object.assign(Object.assign({},s),{isFormItemInput:!1}),[s]),d=Object.assign(Object.assign({},e),{fullscreen:a,divRef:l});return n.createElement("div",{className:`${t}-header`,ref:l},n.createElement(ee.$W.Provider,{value:c},n.createElement(oe,Object.assign({},d,{onChange:e=>{i(e,"year")}})),"month"===o&&n.createElement(ie,Object.assign({},d,{onChange:e=>{i(e,"month")}}))),n.createElement(re,Object.assign({},d,{onModeChange:r})))};var se=a(24685),ce=a(54018),de=a(97165),me=a(44602),pe=a(25905),ue=a(37358),ge=a(67906);const be=e=>{const{calendarCls:t,componentCls:a,fullBg:n,fullPanelBg:o,itemActiveBg:i}=e;return{[t]:Object.assign(Object.assign(Object.assign({},(0,de.m)(e)),(0,pe.dF)(e)),{background:n,"&-rtl":{direction:"rtl"},[`${t}-header`]:{display:"flex",justifyContent:"flex-end",padding:`${(0,ce.zA)(e.paddingSM)} 0`,[`${t}-year-select`]:{minWidth:e.yearControlWidth},[`${t}-month-select`]:{minWidth:e.monthControlWidth,marginInlineStart:e.marginXS},[`${t}-mode-switch`]:{marginInlineStart:e.marginXS}}}),[`${t} ${a}-panel`]:{background:o,border:0,borderTop:`${(0,ce.zA)(e.lineWidth)} ${e.lineType} ${e.colorSplit}`,borderRadius:0,[`${a}-month-panel, ${a}-date-panel`]:{width:"auto"},[`${a}-body`]:{padding:`${(0,ce.zA)(e.paddingXS)} 0`},[`${a}-content`]:{width:"100%"}},[`${t}-mini`]:{borderRadius:e.borderRadiusLG,[`${t}-header`]:{paddingInlineEnd:e.paddingXS,paddingInlineStart:e.paddingXS},[`${a}-panel`]:{borderRadius:`0 0 ${(0,ce.zA)(e.borderRadiusLG)} ${(0,ce.zA)(e.borderRadiusLG)}`},[`${a}-content`]:{height:e.miniContentHeight,th:{height:"auto",padding:0,lineHeight:(0,ce.zA)(e.weekHeight)}},[`${a}-cell::before`]:{pointerEvents:"none"}},[`${t}${t}-full`]:{[`${a}-panel`]:{display:"block",width:"100%",textAlign:"end",background:n,border:0,[`${a}-body`]:{"th, td":{padding:0},th:{height:"auto",paddingInlineEnd:e.paddingSM,paddingBottom:e.paddingXXS,lineHeight:(0,ce.zA)(e.weekHeight)}}},[`${a}-cell-week ${a}-cell-inner`]:{display:"block",borderRadius:0,borderTop:`${(0,ce.zA)(e.lineWidthBold)} ${e.lineType} ${e.colorSplit}`,width:"100%",height:e.calc(e.dateValueHeight).add(e.dateContentHeight).add(e.calc(e.paddingXS).div(2)).add(e.lineWidthBold).equal()},[`${a}-cell`]:{"&::before":{display:"none"},"&:hover":{[`${t}-date`]:{background:e.controlItemBgHover}},[`${t}-date-today::before`]:{display:"none"},[`&-in-view${a}-cell-selected`]:{[`${t}-date, ${t}-date-today`]:{background:i}},"&-selected, &-selected:hover":{[`${t}-date, ${t}-date-today`]:{[`${t}-date-value`]:{color:e.colorPrimary}}}},[`${t}-date`]:{display:"block",width:"auto",height:"auto",margin:`0 ${(0,ce.zA)(e.calc(e.marginXS).div(2).equal())}`,padding:`${(0,ce.zA)(e.calc(e.paddingXS).div(2).equal())} ${(0,ce.zA)(e.paddingXS)} 0`,border:0,borderTop:`${(0,ce.zA)(e.lineWidthBold)} ${e.lineType} ${e.colorSplit}`,borderRadius:0,transition:`background ${e.motionDurationSlow}`,"&-value":{lineHeight:(0,ce.zA)(e.dateValueHeight),transition:`color ${e.motionDurationSlow}`},"&-content":{position:"static",width:"auto",height:e.dateContentHeight,overflowY:"auto",color:e.colorText,lineHeight:e.lineHeight,textAlign:"start"},"&-today":{borderColor:e.colorPrimary,[`${t}-date-value`]:{color:e.colorText}}}},[`@media only screen and (max-width: ${(0,ce.zA)(e.screenXS)}) `]:{[t]:{[`${t}-header`]:{display:"block",[`${t}-year-select`]:{width:"50%"},[`${t}-month-select`]:{width:`calc(50% - ${(0,ce.zA)(e.paddingXS)})`},[`${t}-mode-switch`]:{width:"100%",marginTop:e.marginXS,marginInlineStart:0,"> label":{width:"50%",textAlign:"center"}}}}}}},he=(0,ue.OF)("Calendar",e=>{const t=`${e.componentCls}-calendar`,a=(0,ge.oX)(e,(0,me._n)(e),{calendarCls:t,pickerCellInnerCls:`${e.componentCls}-cell-inner`,dateValueHeight:e.controlHeightSM,weekHeight:e.calc(e.controlHeightSM).mul(.75).equal(),dateContentHeight:e.calc(e.calc(e.fontHeightSM).add(e.marginXS)).mul(3).add(e.calc(e.lineWidth).mul(2)).equal()});return[be(a)]},e=>Object.assign({fullBg:e.colorBgContainer,fullPanelBg:e.colorBgContainer,itemActiveBg:e.controlItemBgActive,yearControlWidth:80,monthControlWidth:70,miniContentHeight:256},(0,me.Jj)(e))),fe=(e,t,a)=>{const{getYear:n}=a;return e&&t&&n(e)===n(t)},xe=(e,t,a)=>{const{getMonth:n}=a;return fe(e,t,a)&&n(e)===n(t)},ke=(e,t,a)=>{const{getDate:n}=a;return xe(e,t,a)&&n(e)===n(t)},ve=e=>t=>{const{prefixCls:a,className:o,rootClassName:i,style:r,dateFullCellRender:l,dateCellRender:s,monthFullCellRender:c,monthCellRender:d,cellRender:m,fullCellRender:p,headerRender:u,value:g,defaultValue:b,disabledDate:h,mode:f,validRange:x,fullscreen:k=!0,showWeek:v,onChange:y,onPanelChange:w,onSelect:E}=t,{getPrefixCls:_,direction:A,className:S,style:C}=(0,U.TP)("calendar"),D=_("picker",a),M=`${D}-calendar`,[N,F,$]=he(D,M),z=e.getNow(),[O,T]=(0,G.A)(()=>g||e.getNow(),{defaultValue:b,value:g}),[I,Y]=(0,G.A)("month",{value:f}),P=n.useMemo(()=>"year"===I?"month":"date",[I]),L=n.useCallback(t=>!!x&&(e.isAfter(x[0],t)||e.isAfter(t,x[1]))||!!(null==h?void 0:h(t)),[h,x]),R=(e,t)=>{null==w||w(e,t)},B=e=>{Y(e),R(O,e)},j=(t,a)=>{(t=>{T(t),ke(t,O,e)||(("date"===P&&!xe(t,O,e)||"month"===P&&!fe(t,O,e))&&R(t,I),null==y||y(t))})(t),null==E||E(t,{source:a})},W=n.useCallback((t,a)=>p?p(t,a):l?l(t):n.createElement("div",{className:q()(`${D}-cell-inner`,`${M}-date`,{[`${M}-date-today`]:ke(z,t,e)})},n.createElement("div",{className:`${M}-date-value`},String(e.getDate(t)).padStart(2,"0")),n.createElement("div",{className:`${M}-date-content`},m?m(t,a):null==s?void 0:s(t))),[l,s,m,p]),H=n.useCallback((t,a)=>{if(p)return p(t,a);if(c)return c(t);const o=a.locale.shortMonths||e.locale.getShortMonths(a.locale.locale);return n.createElement("div",{className:q()(`${D}-cell-inner`,`${M}-date`,{[`${M}-date-today`]:xe(z,t,e)})},n.createElement("div",{className:`${M}-date-value`},o[e.getMonth(t)]),n.createElement("div",{className:`${M}-date-content`},m?m(t,a):null==d?void 0:d(t)))},[c,d,m,p]),[V]=(0,J.A)("Calendar",se.A),Q=Object.assign(Object.assign({},V),t.locale);return N(n.createElement("div",{className:q()(M,{[`${M}-full`]:k,[`${M}-mini`]:!k,[`${M}-rtl`]:"rtl"===A},S,o,i,F,$),style:Object.assign(Object.assign({},C),r)},u?u({value:O,type:I,onChange:e=>{j(e,"customize")},onTypeChange:B}):n.createElement(le,{prefixCls:M,value:O,generateConfig:e,mode:I,fullscreen:k,locale:null==Q?void 0:Q.lang,validRange:x,onChange:j,onModeChange:B}),n.createElement(Z.zs,{value:O,prefixCls:D,locale:null==Q?void 0:Q.lang,generateConfig:e,cellRender:(e,t)=>"date"===t.type?W(e,t):"month"===t.type?H(e,Object.assign(Object.assign({},t),{locale:null==Q?void 0:Q.lang})):void 0,onSelect:e=>{j(e,P)},mode:P,picker:P,disabledDate:L,hideHeader:!0,showWeek:v})))},ye=ve(X.A);ye.generateCalendar=ve;const we=ye,Ee=({selectedDate:e,appointmentsByDate:t,onSelect:a,onEditAppointment:o})=>{const[r,l]=(0,i.useState)({}),s=(0,i.useCallback)((e,t)=>{t.stopPropagation(),l(t=>({...t,[e]:!t[e]}))},[]);return(0,n.createElement)(we,{value:e,onSelect:a,cellRender:e=>{const a=e.format("YYYY-MM-DD"),i=t[a]||[];if(0===i.length)return null;const l=r[a],c=l?i:i.slice(0,2),d=i.length>2;return(0,n.createElement)(_,null,c.map(e=>(0,n.createElement)(V,{key:e.id,appointment:e,onClick:o,placement:"right"})),d&&!l&&(0,n.createElement)(m.Button,{type:"text",size:"small",onClick:e=>s(a,e)},"+",i.length-2," ","more"),l&&d&&(0,n.createElement)(m.Button,{type:"text",size:"small",onClick:e=>s(a,e)},(0,x.__)("Show less","booktics")))},headerRender:()=>null})},_e=({selectedDate:e,appointmentsByDate:t,onEditAppointment:a})=>{const o=$(),i=((e,t)=>{const a=e.startOf("week"),n=[];for(let e=0;e<7;e++){const o=a.clone().add(e,"day"),i=t[o.format("YYYY-MM-DD")]||[];n.push({date:o,appointments:i})}return n})(e,t);return(0,n.createElement)(A,null,(0,n.createElement)("div",{className:"bkt-week-header"},(0,n.createElement)("div",{className:"bkt-time-column-header"}),i.map((t,a)=>(0,n.createElement)("div",{key:a,className:"bkt-week-day-header"},(0,n.createElement)("div",{className:"bkt-day-name"},t.date.format("dddd")),(0,n.createElement)("div",{className:"bkt-day-number"},t.date.format("DD")===e.format("DD")&&(0,n.createElement)("span",{className:"bkt-today-indicator"},"●"),(t.date.format("DD"),e.format("DD"),t.date.format("DD")))))),(0,n.createElement)("div",{className:"bkt-week-time-grid"},o.map((e,t)=>(0,n.createElement)("div",{key:t,className:"bkt-time-row"},(0,n.createElement)("div",{className:"bkt-time-label"},e.display),i.map((t,o)=>{const i=z(t.appointments,e);return(0,n.createElement)("div",{key:o,className:"bkt-time-slot"},i.map(e=>(0,n.createElement)(V,{key:e.id,appointment:e,onClick:a,placement:"top",className:"bkt-week-appointment"})))})))))},Ae=()=>{const{calendarView:e,selectedDate:t,appointmentsByDate:a,isLoadingCalendar:r,getViewTitle:l,handleViewChange:s,handleDateSelect:c,goToPrevious:g,goToNext:h,goToToday:f}=(()=>{const[e,t]=(0,i.useState)(F()()),[a,n]=(0,i.useState)("Month"),{getCalendarAppointments:r}=(0,u.A)(),{calendarAppointments:l,isLoadingCalendar:s}=(0,o.useSelect)(e=>e(d?.appointments).getAppointmentState()),c=(0,i.useCallback)(()=>{let t,n;switch(a){case"Month":t=e.startOf("month").startOf("week").format("YYYY-MM-DD"),n=e.endOf("month").endOf("week").format("YYYY-MM-DD");break;case"Week":t=e.startOf("week").format("YYYY-MM-DD"),n=e.endOf("week").format("YYYY-MM-DD");break;case"Day":t=e.format("YYYY-MM-DD"),n=e.format("YYYY-MM-DD");break;default:t=e.startOf("month").format("YYYY-MM-DD"),n=e.endOf("month").format("YYYY-MM-DD")}return{start_date:t,end_date:n}},[e,a]),m=(0,i.useCallback)(async()=>{const e=c();await r(e)},[c,r]);(0,i.useEffect)(()=>{m()},[e,a]);const p=(0,i.useMemo)(()=>{const e={};return l&&l.forEach(t=>{const a=t.date;e[a]||(e[a]=[]),e[a].push(t)}),e},[l]),g=(0,i.useCallback)(()=>{t(F()())},[]),b=(0,i.useCallback)(e=>{t(e)},[]),h=(0,i.useCallback)(e=>{n(e)},[]),f=(0,i.useCallback)(()=>{switch(a){case"Month":default:return e.format("MMMM YYYY");case"Week":const t=e.startOf("week"),a=e.endOf("week");return`${t.format("MMM DD")} - ${a.format("MMM DD, YYYY")}`;case"Day":return e.format("dddd, MMMM DD, YYYY")}},[a,e]);return{selectedDate:e,calendarView:a,appointmentsByDate:p,isLoadingCalendar:s,getViewTitle:f,refreshCalendarData:m,handleDateSelect:b,handleViewChange:h,goToPrevious:function(){console.log("Clicked!! goToPrevious");const e="Month"===a?"month":"Week"===a?"week":"day";t(t=>t.subtract(1,e))},goToNext:function(){console.log("Clicked!! next");const e="Month"===a?"month":"Week"===a?"week":"day";t(t=>t.add(1,e))},goToToday:g}})(),{getSingleOrder:x}=(0,b.A)(),{setAppointmentState:k}=(0,o.useDispatch)(d?.appointments),{isAdmin:v}=(0,p.useUserRole)(),y={selectedDate:t,appointmentsByDate:a,onSelect:c,onEditAppointment:async e=>{e?.order_id&&(await x(e?.order_id),k({editDrawerOpen:!0,isEditMode:!!v}))}};return(0,n.createElement)(E,null,(0,n.createElement)(m.Card,null,(0,n.createElement)(M,{viewTitle:l(),calendarView:e,onViewChange:s,onPrevious:g,onNext:h,onToday:f}),(0,n.createElement)("div",{className:"calendar-content"},r?(0,n.createElement)(m.RowSkeleton,null):(()=>{switch(e){case"Month":return(0,n.createElement)(Ee,{...y});case"Week":return(0,n.createElement)(_e,{...y});case"Day":return(0,n.createElement)(Q,{...y});default:return null}})())))},{PlusOutlined:Se,CalendarOutlined:Ce,BarsOutlined:De}=window?.booktics?.libraryIcons||{},Me=[{value:"Calender",icon:(0,n.createElement)(Ce,null)},{value:"table",icon:(0,n.createElement)(De,null)}],Ne=()=>{const e=(0,r.Zp)();return(0,n.createElement)(m.Flex,{gap:8,align:"center"},(0,n.createElement)(m.ViewSelector,{defaultView:"table",viewOptions:Me}),(0,n.createElement)(m.Can,null,(0,n.createElement)(m.PrimaryButton,{text:(0,x.__)("New Booking","booktics"),icon:(0,n.createElement)(Se,null),onClick:()=>e(c.FC)})))};var Fe=a(4581);const{__}=wp?.i18n||{},$e=({setIsFiltered:e,selectedRowKeys:t,setSelectedRowKeys:a})=>{const{bulkDeleteAppointment:o,getAllAppointments:i}=(0,u.A)();return(0,n.createElement)(n.Fragment,null,t.length?(0,n.createElement)(m.BulkDelete,{selectedRowKeys:t,setSelectedRowKeys:a,deleteApi:o}):(0,n.createElement)(m.Flex,{gap:6},(0,n.createElement)(m.SecondaryOutlineButton,{icon:(0,n.createElement)(O.FilterIcon,null),text:__("Filter","booktics"),onClick:()=>e(e=>!e),className:"bkt-filter-button"}),(0,n.createElement)(Fe.A,{searchFunc:i})))};var ze=a(88802),Oe=a(3038),Te=a(52911);const{paged:Ie,per_page:Ye}=ze.pagination,Pe=()=>{const{searchQuery:e,appointments:t}=(0,o.useSelect)(e=>e(d?.appointments).getAppointmentState()),{serviceList:a}=(0,o.useSelect)(e=>e(d.services).getServicesState(),[]),{teamMembers:n}=(0,o.useSelect)(e=>e(d.team).getTeamState(),[]),{getServices:i}=(0,Oe.A)(),{getAllAppointments:r}=(0,u.A)(),{setAppointmentState:l}=(0,o.useDispatch)(d?.appointments),{getTeamMembers:s}=(0,Te.A)();return{searchQuery:e,appointments:t,serviceList:a,teamMembers:n,getServices:i,getTeamMembers:s,getAllAppointments:r,handleClearAll:()=>{l({searchQuery:{paged:Ie,per_page:Ye},appointments:null}),r({resetFilter:!0})},handleFilterByPayment:t=>{const a={...e,paged:1,payment_status:t||""};l({searchQuery:a}),r(a)},handleFilterByService:t=>{const a={...e,paged:1,service_id:t||""};l({searchQuery:a}),r(a)},handleFilterByStatus:t=>{const a={...e,paged:1,status:t||""};l({searchQuery:a}),r(a)},handleFilterByTeam:t=>{const a={...e,paged:1,team_member_id:t||""};l({searchQuery:a}),r(a)}}},Le=()=>{const{handleFilterByPayment:e}=Pe();return(0,n.createElement)(m.Col,{xs:24,md:4},(0,n.createElement)(m.SelectInput,{placeholder:(0,x.__)("Select Payment Method","booktics"),options:v,onChange:e}))},Re=()=>{const{getServices:e,serviceList:t,searchQuery:a,handleFilterByService:o}=Pe();return(0,i.useEffect)(()=>{t||e()},[]),t?(0,n.createElement)(m.Col,{xs:24,md:4},(0,n.createElement)(m.SelectInput,{showSearch:!0,optionFilterProp:"label",value:a?.service_id||void 0,placeholder:(0,x.__)("Select Service","booktics"),options:Array.isArray(t)?t.map(e=>({label:e?.title,value:e?.id})):[],onChange:o})):null},Be=()=>{const{handleFilterByStatus:e}=Pe();return(0,n.createElement)(m.Col,{xs:24,md:4},(0,n.createElement)(m.SelectInput,{placeholder:(0,x.__)("Select Status","booktics"),options:k,onChange:e}))},je=()=>{const{getTeamMembers:e,teamMembers:t,searchQuery:a,handleFilterByTeam:o}=Pe();return(0,i.useEffect)(()=>{t||e()},[]),t?(0,n.createElement)(m.Col,{xs:24,md:4},(0,n.createElement)(m.SelectInput,{showSearch:!0,optionFilterProp:"label",value:a?.team_member_id||void 0,placeholder:(0,x.__)("Select Team","booktics"),options:Array.isArray(t?.items)?t?.items.map(e=>({label:e?.display_name,value:e?.id})):[],onChange:o})):null},We=()=>{const{getAllAppointments:e}=Pe();return window?.wp?.hooks.applyFilters("booktics_appointment_filter_by_location",null,{getAllAppointments:e})},He=()=>{const{searchQuery:e,handleClearAll:t}=Pe();return(0,n.createElement)(n.Fragment,null,(0,n.createElement)(Re,null),(0,n.createElement)(Le,null),(0,n.createElement)(m.Can,null,(0,n.createElement)(je,null)),(0,n.createElement)(Be,null),(0,n.createElement)(We,null),(e?.team_member_id||e?.service_id||e?.payment_status||e?.status)&&(0,n.createElement)(m.Col,{xs:24,md:4},(0,n.createElement)(m.Button,{color:"red",variant:"link",onClick:t},(0,x.__)("All Clear","booktics"))))},Ve=({selectedRowKeys:e,setSelectedRowKeys:t})=>{const[a]=(0,l.ok)(),[o,r]=(0,i.useState)(!1),s=a.get("view")||"table";return(0,n.createElement)(m.SecondaryMenu,{selectedView:s,filteredTopMenu:(0,n.createElement)(n.Fragment,null,(0,n.createElement)($e,{setIsFiltered:r,selectedRowKeys:e,setSelectedRowKeys:t}),(0,n.createElement)(Ne,null)),isFiltered:o,filteredOptions:(0,n.createElement)(He,null)})};var Qe=a(30151);const Xe=({record:e})=>{const{deleteSingleAppointment:t}=(0,u.A)(),{handleOrderEdit:a}=(0,b.A)(),{setAppointmentState:r}=(0,o.useDispatch)(d?.appointments),l=(0,i.useCallback)(()=>{window.wp?.hooks?.doAction("delete_confirmation",{title:(0,x.__)("Are you sure you want to delete the appointment","booktics"),onOk:()=>t(e.id)})},[t,e.id]);return(0,n.createElement)(Qe.DA,{justify:"flex-end",align:"center",gap:8,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation()},(0,n.createElement)(m.Can,null,(0,n.createElement)(m.Tooltip,{title:(0,x.__)("Edit Appointment","booktics")},(0,n.createElement)(m.IconButton,{icon:(0,n.createElement)(O.EditIcon,null),className:"btk-edit-btn",onClick:()=>a(e?.order_id)}))),(0,n.createElement)(m.Can,null,(0,n.createElement)(m.DeleteButton,{onClick:l})))},Ke=({record:e})=>{if(!e?.customer)return null;const{name:t,email:a}=e?.customer||{};return(0,n.createElement)(m.Flex,{vertical:!0,gap:4},(0,n.createElement)(m.Title,{level:5,text:null!=t?t:""}),(0,n.createElement)(m.Description,{text:a}))};var qe=a(95358);const Ze=({record:e})=>(0,n.createElement)(m.Flex,{gap:4,vertical:!0},(0,n.createElement)(m.Title,{level:5,text:(0,qe.formattedDate)(e?.date)}),(0,n.createElement)(m.Description,{text:`${e?.start_time} to ${e.end_time}`})),Ge=({record:e})=>(0,n.createElement)(m.DurationTag,{time:e?.duration}),Ue={not_paid:{text:"Not Paid",color:"#DB3915",bg:"#FFF0F0"},partially_paid:{text:"Partially Paid",color:"#009959",bg:"#F5FFF0"},fully_paid:{text:"Fully Paid",color:"#009959",bg:"#F5FFF0"},processing:{text:"Processing",color:"#009959",bg:"#F5FFF0"}},Je=({record:e={}})=>{const{payment_status:t="not_paid"}=e,{text:a,color:o,bg:i}=Ue[t]||Ue.not_paid;return(0,n.createElement)(T.A1,{textColor:o,bg:i},a)},et=({record:e})=>{const{title:t}=e?.service||{};return(0,n.createElement)(m.Flex,{gap:2,wrap:!0},t&&(0,n.createElement)(m.Tooltip,{title:t},(0,n.createElement)(T.vI,null,t)))};var tt=a(25723);const at=({record:e})=>{const{display_name:t,image:a}=e.team_member||{};return(0,n.createElement)(m.Tooltip,{title:t,placement:"top"},(0,n.createElement)(m.Avatar,{src:a||tt,alt:t}))},nt=({record:e})=>(0,n.createElement)("span",null,e?.location?.title||"N/A"),ot=({selectedRowKeys:e,setSelectedRowKeys:t})=>{const{appointments:a}=(0,o.useSelect)(e=>e(d?.appointments).getAppointmentState()),{onPaginationChange:r}=(0,u.A)(),{handleOrderEdit:l}=(0,b.A)(),{isAdmin:s}=(0,p.useUserRole)(),c={selectedRowKeys:e,onChange:e=>t(e)},g=(()=>{const e=(0,p.useAdminLicense)(),[t,a]=(0,i.useState)([]);return(0,i.useEffect)(()=>{const t=[{title:(0,x.__)("Date and Time","booktics"),dataIndex:"time",key:"date_and_time",fixed:"left",width:"200px",render:(e,t)=>(0,n.createElement)(Ze,{record:t})},{title:(0,x.__)("Customer","booktics"),dataIndex:"customer",key:"customer",width:"200px",render:(e,t)=>(0,n.createElement)(Ke,{record:t})},{title:(0,x.__)("Service","booktics"),dataIndex:"service",key:"service",width:"200px",render:(e,t)=>(0,n.createElement)(et,{record:t})},{title:(0,x.__)("Duration","booktics"),dataIndex:"duration",key:"duration",width:"100px",render:(e,t)=>t?.duration?(0,n.createElement)(Ge,{record:t}):null},{title:(0,x.__)("Team","booktics"),dataIndex:"team",key:"team",width:"150px",render:(e,t)=>(0,n.createElement)(at,{record:t})}],o={title:(0,x.__)("Location","booktics"),dataIndex:"location",key:"location",width:"150px",render:(e,t)=>(0,n.createElement)(nt,{record:t})},i=[{title:(0,x.__)("Payment","booktics"),dataIndex:"payment",key:"payment",width:"130px",render:(e,t)=>(0,n.createElement)(Je,{record:t})},{title:(0,x.__)("Status","booktics"),dataIndex:"status",key:"status",width:"150px",render:(e,t)=>(0,n.createElement)(Y,{record:t})},{title:(0,x.__)("Action","booktics"),dataIndex:"action",key:"action",fixed:"right",width:"150px",render:(e,t)=>(0,n.createElement)(Xe,{record:t})}];let r=[...t];e&&r.push(o),r=[...r,...i],a(r)},[e]),t})();return(0,n.createElement)(m.Table,{total:a.total,pageSize:a.per_page||a.total,currentPage:a.paged,dataSource:a.items,columns:g,scroll:{x:1e3},rowSelection:!!s&&c,onPaginationChange:r,onRow:e=>({onClick:()=>{l(e?.order_id)}})})},it=()=>{const[e,t]=(0,i.useState)([]),{getAllAppointments:a}=(0,u.A)(),b=(0,r.Zp)(),{appointments:h,searchQuery:f}=(0,o.useSelect)(e=>e(d?.appointments).getAppointmentState()),{resetAppointments:k}=(0,o.useDispatch)(d?.appointments),{isQueried:v}=(0,p.useSearchEmptyState)(f),[y]=(0,l.ok)(),w=y.get("view")||"table",E=(0,i.useMemo)(()=>"table"===w?(0,n.createElement)(ot,{selectedRowKeys:e,setSelectedRowKeys:t}):(0,n.createElement)(Ae,null),[w,e]);return(0,i.useEffect)(()=>{a()},[]),h?v||0!==h.items.length?(0,n.createElement)(n.Fragment,null,(0,n.createElement)(s.A,{title:(0,x.__)("Appointments","booktics")}),(0,n.createElement)(m.ResponsiveContainer,null,(0,n.createElement)(Ve,{selectedRowKeys:e,setSelectedRowKeys:t}),v&&0===h.items.length?(0,n.createElement)(m.SearchNotFoundScreen,{searchQuery:f?.search||"",onClear:()=>(k(),void a())}):E,(0,n.createElement)(g.A,null))):(0,n.createElement)(n.Fragment,null,(0,n.createElement)(s.A,{title:(0,x.__)("Appointments","booktics")}),(0,n.createElement)(m.ResponsiveContainer,null,(0,n.createElement)(m.EmptyScreen,{title:(0,x.__)("No appointments found","booktics"),description:(0,x.__)("Create a new appointment to get started.","booktics"),addButtonText:(0,x.__)("Add New Appointment","booktics"),onAddButtonClick:()=>b(c.FC)}))):(0,n.createElement)(m.RowSkeleton,null)}}}]);