import{r as h,j as e,_ as t,s as E}from"./wp-i18n-shim-DUX0OV_V.js";import{S as A,P as M}from"./Save-jKoE2q3L.js";import{a as N,s as r,u as k}from"./store-rDqSxbzb.js";import{I as $}from"./input-Dw-69aYW.js";import{S as H,a as R,c as V,f as S}from"./select-BFNitOb0.js";import{S as z}from"./search-P9p39fmP.js";import{C as O,a as U}from"./card-CNcjg1NV.js";import{S as v}from"./skeleton-DfFmlQ5i.js";import{M as D,u as F,R as Z,e as C}from"./index-D01LF5Le.js";import{P as q}from"./Pagination-D4i_uNKG.js";import{T as X,a as L,b as j,c as J,d as g,e as G}from"./Table-p19l2S6r.js";import{C as I}from"./checkbox-CQ-dG0Dh.js";import{A as K,a as Q,b as W}from"./avatar-kVfFVfuh.js";import{B as _}from"./Button-BveKhP38.js";import{S as Y}from"./SkeletonTableRows-yUolPLdf.js";import{E as ee}from"./Edit-ChdaRnpE.js";import{T as se}from"./Trash-BkcPMnbK.js";import{c as P,X as T}from"./utils-Bl0WAcve.js";import{C as ae}from"./ConfirmDialog-Bbm_78dn.js";import{L as te}from"./AddLocationForm-tGWpYZPP.js";import{u as oe,A as ne}from"./ActionButton-Cr4Z2a1F.js";import{C as ie}from"./CrudLayout-DRSWmVk9.js";import{P as re}from"./ProUpgradeBanner-B_761Fa7.js";import"./vendor-DDjlQeP6.js";import"./withIconDefaults-BJCqj2oX.js";import"./lodash-Bd-B7UeG.js";import"./defineProperty-DbXIQDXj.js";import"./typeof-QjJsDpFa.js";import"./apiConfig-BA13wrqF.js";import"./index-CLZ4-rw6.js";import"./toast-1-c8k_LJ.js";import"./index-Bl84CzKv.js";import"./Combination-BuKwnoTc.js";import"./preload-helper-Dp1pzeXC.js";import"./CalenderCheck-2TB2QVYq.js";import"./calendar-Cz3-D5io.js";import"./tag-8m_NofXN.js";import"./shield-DVSNyXBB.js";import"./proxy-CtW-P0pQ.js";import"./circle-check-big-Bxgqw2u9.js";import"./dialog-EtKUcLIM.js";import"./index-BrYiunaL.js";import"./index-f2RCAr_u.js";import"./textarea-CG8MgAEa.js";import"./FormField-8HG4dTZR.js";import"./label-CwRAQd0m.js";import"./circle-alert-COuSc4NK.js";import"./ImageUpload-CcSoaEux.js";import"./trash-2-CS5zm_gd.js";import"./StatusSwitcher-BMMLTfxu.js";import"./badge-DBj5X-b5.js";import"./switch-I41RT0Bn.js";import"./useMediaUploader-DCuR6epV.js";import"./loader-circle-CcSu72zH.js";import"./ArrowLeftIcon-C8q2jgKs.js";import"./crown-CcV7MJml.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 ce=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],le=P("locate-fixed",ce);/**
 * @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 de=[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],me=P("search-x",de);function xe({locations:o,filter:s}){const c=N(),p=n=>{const{id:i,value:x}=n.target;c(r).setFilter({field:i,value:x})},d=n=>i=>{{const x=i.split("-")[0],m=i.split("-")[1];c(r).setFilter({field:"order_by",value:x}),c(r).setFilter({field:"order",value:m})}};return e.jsxs("div",{className:"",children:[e.jsx("h3",{className:"rtrb-title-18 mb-5",children:t("All Locations","radius-booking")}),e.jsxs("div",{className:"flex flex-row gap-4",children:[e.jsxs("div",{className:"relative min-w-[400px] mr-auto",children:[e.jsx(z,{className:"w-4 h-4 absolute top-3.5 left-3 text-text-titel-color80"}),e.jsx($,{id:"search_data",placeholder:t("Search Locations...","radius-booking"),className:"h-11 rtrb-input pl-10",onChange:p})]}),e.jsxs(H,{onValueChange:d(),id:"order",value:(s==null?void 0:s.order_by)+"-"+(s==null?void 0:s.order),children:[e.jsx(R,{className:"rtrb-input w-[220px] h-11 ",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"shrink-0",children:e.jsx("path",{d:"M7.5 13.5H10.5V12H7.5V13.5ZM1.5 4.5V6H16.5V4.5H1.5ZM4.5 9.75H13.5V8.25H4.5V9.75Z",fill:"#B6B8BC"})}),e.jsx("span",{className:"text-text-titel-color80 text-sm",children:(s==null?void 0:s.order_by)==="name"&&(s==null?void 0:s.order)==="asc"?t("Name Ascending","radius-booking"):(s==null?void 0:s.order_by)==="name"&&(s==null?void 0:s.order)==="desc"?t("Name Descending","radius-booking"):(s==null?void 0:s.order_by)==="created_at"&&(s==null?void 0:s.order)==="asc"?t("Date Ascending","radius-booking"):(s==null?void 0:s.order_by)==="created_at"&&(s==null?void 0:s.order)==="desc"?t("Date Descending","radius-booking"):t("Sort By","radius-booking")})]})})}),e.jsxs(V,{children:[e.jsx(S,{value:"name-asc",children:t("Name Ascending","radius-booking")}),e.jsx(S,{value:"name-desc",children:t("Name Descending","radius-booking")}),e.jsx(S,{value:"created_at-asc",children:t("Date Ascending","radius-booking")}),e.jsx(S,{value:"created_at-desc",children:t("Date Descending","radius-booking")})]})]})]})]})}const pe=h.memo(xe);function he(){return e.jsxs(O,{className:"bg-bg-5 rounded-md border border-solid border-[#f1f1f1] relative",children:[e.jsx(v,{className:"absolute top-3 right-3 w-6 h-6 rounded-full"}),e.jsxs(U,{className:"flex flex-col items-center pt-12 pb-8",children:[e.jsx(v,{className:"w-16 h-16 rounded-full mb-4"}),e.jsx(v,{className:"h-6 w-3/4 mb-3"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(D,{className:"w-3.5 h-3.5 text-gray-300 flex-shrink-0"}),e.jsx(v,{className:"h-4 w-1/2"})]}),e.jsx("div",{className:"mt-4 pt-4 border-t border-border border-opacity-30 w-full flex justify-center",children:e.jsx(v,{className:"h-8 w-24 rounded-md"})})]})]})}function ue({locations:o=[]}){const s=k(n=>n(r).getSelectedLocationIds()||[],[o]),{setSelectedLocations:c}=N(r),p=n=>{c(n?o.map(i=>i.id):[])},d=(s==null?void 0:s.length)===o.length&&o.length>0;return e.jsx(X,{children:e.jsxs(L,{children:[e.jsx(j,{className:"w-12",children:e.jsx(I,{checked:d,onCheckedChange:p})}),e.jsx(j,{children:t("ID","radius-booking")}),e.jsx(j,{children:t("Name","radius-booking")}),e.jsx(j,{children:t("Address","radius-booking")}),e.jsx(j,{children:t("Phone","radius-booking")}),e.jsx(j,{children:t("Status","radius-booking")}),e.jsx(j,{children:t("Created At","radius-booking")}),e.jsx(j,{className:"w-20"})]})})}function ge({LocationData:o=[],setIsModalOpen:s,setSelectedId:c}){const p=F(),d=k(a=>a(r).loading(),[]),n=k(a=>a(r).getSelectedLocationIds()||[],[o]),{setSelectedLocations:i}=N(r),x=(a,b)=>{i(b?[...n,a]:n.filter(y=>y!==a))},m=a=>{c(a),s(!0)};return e.jsx(J,{children:d?e.jsx(Y,{rowCount:10,columns:[5,3,2,2,2,2,1]}):(o==null?void 0:o.length)>0?o.map(a=>e.jsxs(L,{className:"even:bg-[#F6F8FA]",children:[e.jsx(g,{className:"py-2",children:e.jsx(I,{checked:n==null?void 0:n.includes(a.id),onCheckedChange:b=>x(a.id,b)})}),e.jsx(g,{className:"py-2",children:a.id}),e.jsx(g,{className:"py-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{className:"h-8 w-8",children:[e.jsx(Q,{src:a==null?void 0:a.picture_full_path,alt:a==null?void 0:a.name}),e.jsx(W,{children:e.jsx(le,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"font-medium",children:a==null?void 0:a.name})]})}),e.jsx(g,{className:"py-2 align-middle",children:a.address}),e.jsx(g,{className:"py-2 align-middle",children:a.phone??"-"}),e.jsx(g,{className:"py-2",children:e.jsx("span",{className:`label-${a.status}`,children:a.status})}),e.jsx(g,{className:"py-2 align-middle",children:a.created_at?new Date(a.created_at).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-"}),e.jsx(g,{className:"py-2 align-middle",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"ghost",className:"p-0  hover:bg-transparent",size:"sm",onClick:()=>{p(`/locations/${a.id}/edit`)},children:e.jsx(ee,{className:"w-4 h-4 text-primary hover:scale-110 transition"})}),e.jsx(_,{variant:"ghost",size:"sm",className:"p-0 hover:text-title hover:bg-transparent",onClick:()=>m(a.id),children:e.jsx(se,{className:"w-4 h-4 text-[#E4002D]  hover:scale-110 transition"})})]})})]},a.id)):e.jsx(L,{children:e.jsx(g,{colSpan:7,className:"text-center py-4 text-muted-foreground",children:t("No Location found.","radius-booking")})})})}const je=({locations:o=[],onExport:s=()=>{},onDelete:c=()=>{},resourceLabel:p=t("item(s)","radius-booking")})=>{const d=k(x=>x(r).getSelectedLocationIds()||[],[o]),n=d.length,i=o.length;return n===0||o.length===0?null:e.jsxs("div",{className:"flex items-center justify-between py-2 px-4 bg-muted rounded-md mb-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:E(t("%1$d of %2$d %3$s selected.","radius-booking"),n,i,p)}),e.jsx("div",{className:"flex gap-2",children:e.jsx(_,{variant:"outline",size:"sm",className:"text-red-600 hover:text-red-700",onClick:()=>c(d),children:t("Delete Selected","radius-booking")})})]})},be=h.memo(()=>e.jsxs("div",{className:"col-span-full flex flex-col items-center justify-center py-16 px-4 bg-gray-50 rounded-lg border border-dashed border-border text-title2",children:[e.jsx(me,{className:"w-12 h-12 mb-4 text-gray-400"}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:t("No Locations Found","radius-booking")})]}));be.displayName="EmptyState";const ke=h.memo(()=>e.jsx(e.Fragment,{children:Array.from({length:6},(o,s)=>e.jsx(he,{},s))}));ke.displayName="LoadingSkeletons";function ye(){const o=N(),[s,c]=h.useState(!1),[p,d]=h.useState(""),{filters:n,locations:i,loading:x,pagination:m}=k(u=>{const f=u(r);return{filters:f.getFilters(),locations:f.getLocations(),loading:f.loading(),pagination:f.getPagination()}},[]),a=h.useMemo(()=>JSON.stringify(n),[n]);h.useEffect(()=>{o(r).getLocations(n)},[o,a]);const b=h.useCallback(u=>{Array.isArray(u)?o(r).bulkDeleteLocations(u,n):o(r).removeLocation(u,n),c(!1)},[o,n]),y=h.useMemo(()=>(m==null?void 0:m.total)>0,[m==null?void 0:m.total]),l=u=>{c(!0),d(u),o(r).setSelectedLocations([])};return e.jsxs("main",{className:"rtrb-card p-10a flex-1 p-[30px] gap-6 space-y-6",children:[e.jsx(pe,{locations:i,filter:n}),e.jsx(je,{locations:i,onDelete:l,resourceLabel:t("location(s)","radius-booking")}),e.jsxs(G,{children:[e.jsx(ue,{locations:i}),e.jsx(ge,{LocationData:i,setIsModalOpen:c,setSelectedId:d})]}),e.jsx(ae,{open:s,onClose:()=>c(!1),onConfirm:()=>b(p),title:t("Are you sure?","radius-booking"),description:t("This action will permanently delete this location.","radius-booking"),confirmText:t("Delete","radius-booking")}),y&&e.jsx(q,{pagination:m,loading:x,type:"Location",onPageChange:u=>{o(r).setFilter({field:"page",value:u})}})]})}const B=h.memo(ye);function ve(){var y;const o=oe("/locations"),{mode:s}=o,c=N(),p=F(),d=k(l=>l(r).getLocation(),[]),n=k(l=>l(r).isLocationSaving(),[]),i=!!((y=window.radius_booking_param)!=null&&y.is_pro),x=async()=>{const l=await c(r).saveLocation(d);l&&p(`/locations/${l}/edit`)},m=()=>{if(!i)return e.jsxs("div",{children:[e.jsx(re,{title:t("Locations","radius-booking"),type:"setting"}),e.jsx("div",{className:"pointer-events-none select-none opacity-50 mt-4",children:e.jsx(B,{demo:!0})})]});switch(s){case"list":return e.jsx(B,{});case"edit":case"create":return e.jsx(te,{});default:return null}},a={list:[{key:"add-location",label:t("Add Location","radius-booking"),icon:M,onClick:o.navigateTo.create,variant:"primary"}],create:[{key:"save-location",label:t("Save","radius-booking"),icon:A,onClick:x,loading:n,variant:"primary"},{key:"cancel-location",label:t("Cancel","radius-booking"),icon:T,onClick:o.navigateTo.list,variant:"cancel"}],edit:[{key:"update-location",label:t("Update","radius-booking"),icon:A,onClick:x,loading:n,variant:"primary"},{key:"cancel-location",label:t("Cancel","radius-booking"),icon:T,onClick:o.navigateTo.list,variant:"cancel"}]},b=i?(a[s]||[]).map(l=>e.jsx(ne,{label:l.label,icon:l.icon,onClick:l.onClick,loading:l.loading||!1,variant:l.variant||"primary"},l.key)):[];return e.jsx("div",{children:e.jsx(ie,{title:t("Locations","radius-booking"),description:t("Manage your locations","radius-booking"),showBack:i&&s!=="list",onBack:o.navigateTo.list,actions:b,icon:e.jsx(D,{className:"w-5 h-5 text-primary-colordefault"}),children:m()})})}const w=h.memo(ve);function Ss(){return e.jsxs(Z,{children:[e.jsx(C,{path:"/",element:e.jsx(w,{})}),e.jsx(C,{path:"create",element:e.jsx(w,{})}),e.jsx(C,{path:":id",element:e.jsx(w,{})}),e.jsx(C,{path:":id/edit",element:e.jsx(w,{})})]})}export{Ss as default};
//# sourceMappingURL=index-DyQUHAvt.js.map
