1import{K as M,j as e,r as i,a as U,S as z}from"./@react-core-DAiQxeIm.js";import{L as H}from"./Loader-DjujnbAx.js";import{M as P}from"./MainLayout-D6Rhokwx.js";import{M as O}from"./MetaHeader-DkjMiv94.js";import{M as $}from"./MyAccountWrapper-B6glI-at.js";import{B as S,u as D}from"./useModal-BKP0Oacy.js";import{I as h,d as V,c as W}from"./WrapperLayout-CmKMUl1z.js";import{f as G}from"./ProductUtils-CVQOiUIx.js";import{s as B}from"./fetch-DIMp6ACm.js";import{q as Q,c as L}from"./app-ZtUJbowM.js";import{u as q}from"./useThemeVisuals-B1RdzApi.js";import{B as J}from"./Box-B1wcVOkm.js";import"./renderComponents-Due9YHQN.js";import"./useIsOnlineLightingShop-CZ-toRlz.js";import"./FormatPrice-DHQ3sYHY.js";const X=({store:a,onChangeStore:r,onRemoveStore:l})=>{var t,c,d,m,f,_,p,g;const{t:n}=M().props,s=n==null?void 0:n.my_store;return a?e.jsxs("div",{className:"rounded-lg border border-gray-efl-100 bg-white p-6 sm:p-8",children:[e.jsx("h3",{className:"text-lg font-medium mb-4",children:G(a)}),e.jsxs("div",{className:"grid gap-3 text-sm mb-6",children:[a.address&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(h,{name:"map-pin",classIcon:"text-lg text-gray-500 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500 mb-0.5",children:(t=s==null?void 0:s.store_info)==null?void 0:t.address}),e.jsx("p",{children:a.address})]})]}),a.hours&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(h,{name:"clock",classIcon:"text-lg text-gray-500 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500 mb-0.5",children:(c=s==null?void 0:s.store_info)==null?void 0:c.hours}),e.jsx("p",{children:a.hours})]})]}),a.phone&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(h,{name:"phone",classIcon:"text-lg text-gray-500 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500 mb-0.5",children:(d=s==null?void 0:s.store_info)==null?void 0:d.phone}),e.jsx("a",{href:`tel:${a.phone}`,className:"hover:underline",children:a.phone})]})]}),a.email&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(h,{name:"envelope",classIcon:"text-lg text-gray-500 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500 mb-0.5",children:(m=s==null?void 0:s.store_info)==null?void 0:m.email}),e.jsx("a",{href:`mailto:${a.email}`,className:"hover:underline",children:a.email})]})]}),a.services&&a.services.length>0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(h,{name:"wrench-screwdriver",classIcon:"text-lg text-gray-500 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500 mb-0.5",children:(f=s==null?void 0:s.store_info)==null?void 0:f.services}),e.jsx("ul",{className:"flex flex-wrap gap-2",children:a.services.map((x,j)=>{var u;return e.jsx("li",{className:"text-xs bg-gray-efl-50 border border-gray-efl-100 rounded px-2 py-1",children:((u=s==null?void 0:s.store_info)==null?void 0:u[`service_${x}`])??x},j)})})]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 pt-4 border-t border-gray-efl-100",children:[a.cms_link&&e.jsx(S,{typeStyles:"outline",size:"S",hrefButton:a.cms_link,classButton:"text-sm",children:(_=s==null?void 0:s.store_info)==null?void 0:_.visit_page}),(()=>{var u;const x=a.latitude&&a.longitude&&a.latitude!==0&&a.longitude!==0;if(!x&&!a.address)return null;const j=[a.address,a.postcode,a.city,a.province].filter(Boolean).join(", ");return e.jsx(S,{typeStyles:"outline",size:"S",hrefButton:x?`https://www.google.com/maps/dir/?api=1&destination=${a.latitude},${a.longitude}`:`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(j)}`,isBlank:!0,classButton:"text-sm",children:(u=s==null?void 0:s.store_info)==null?void 0:u.get_directions})})(),e.jsx(S,{typeStyles:"outline",size:"S",action:r,classButton:"text-sm",children:(p=s==null?void 0:s.actions)==null?void 0:p.change}),e.jsx(S,{typeStyles:"ghost",size:"S",action:l,classButton:"text-sm text-red-600 hover:text-red-700",children:(g=s==null?void 0:s.actions)==null?void 0:g.remove})]})]}):null},Y=({onSelectStore:a})=>{var n;const{t:r}=M().props,l=(n=r==null?void 0:r.my_store)==null?void 0:n.no_store;return e.jsxs("div",{className:"rounded-lg border border-dashed border-gray-efl-200 bg-gray-efl-50 p-8 text-center",children:[e.jsx(h,{name:"building-storefront",classIcon:"text-4xl text-gray-400 mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:l==null?void 0:l.title}),e.jsx("p",{className:"text-sm text-gray-500 mb-6 max-w-md mx-auto",children:l==null?void 0:l.description}),e.jsx(S,{typeStyles:"filled",size:"M",action:a,children:l==null?void 0:l.button})]})},Z=({store:a,onSelect:r,isLoading:l})=>{var t,c,d;const{t:n}=M().props,s=n==null?void 0:n.my_store;return e.jsxs("div",{className:"rounded-lg border border-gray-efl-100 bg-white p-5 flex flex-col sm:flex-row sm:items-center gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm mb-1",children:G(a)}),a.address&&e.jsxs("p",{className:"text-xs text-gray-500 flex items-center gap-1.5 mb-1",children:[e.jsx(h,{name:"map-pin",classIcon:"text-sm text-gray-400"}),a.address,a.city&&`, ${a.city}`]}),a.hours&&e.jsxs("p",{className:"text-xs text-gray-500 flex items-center gap-1.5",children:[e.jsx(h,{name:"clock",classIcon:"text-sm text-gray-400"}),a.hours]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[a.distance_km!=null&&e.jsx("span",{className:"text-xs text-gray-400 whitespace-nowrap",children:(c=(t=s==null?void 0:s.search)==null?void 0:t.distance)==null?void 0:c.replace("{distance}",a.distance_km.toFixed(1))}),e.jsx(S,{typeStyles:"filled",size:"S",action:()=>r(a.store_id??a.id),classButton:"text-xs whitespace-nowrap",isDisabled:l,children:(d=s==null?void 0:s.search)==null?void 0:d.select})]})]})},ee="/ajax/customer/store/assign",se="/ajax/customer/store/search",F=2,te=400,ae=({isOpen:a,closeModal:r,onStoreAssigned:l,stores:n=[]})=>{var A,k,T;const{t:s}=M().props,t=(A=s==null?void 0:s.my_store)==null?void 0:A.search,c=(k=s==null?void 0:s.my_store)==null?void 0:k.messages,d=Q("#portal-root"),[m,f]=i.useState(""),[_,p]=i.useState(!1),[g,x]=i.useState(!1),[j,u]=i.useState(null),[R,b]=i.useState(null),w=i.useRef(null),v=i.useRef(null);i.useEffect(()=>{a&&setTimeout(()=>{var o;
1return(o=w.current)==null?void 0:o.focus()},100)},[a]),i.useEffect(()=>{v.current&&clearTimeout(v.current);const o=m==null?void 0:m.trim();if(!o||o.length<F){u(null),x(!1);return}return x(!0),v.current=setTimeout(async()=>{try{const y=await B(se,{query_search:o}),K=(y==null?void 0:y.stores)??y??[];u(K)}catch(y){L(y,{tags:{component:"my_store_search"},level:"warning"}),u([])}finally{x(!1)}},te),()=>{v.current&&clearTimeout(v.current)}},[m]);const N=j!==null?j:n,C=i.useCallback(async o=>{p(!0),b(null);try{await B(ee,{store_id:o}),l(),r()}catch(y){L(y),b(c==null?void 0:c.error)}finally{p(!1)}},[l,r,c]),I=()=>{f(""),u(null),b(null),r()},E=((T=m==null?void 0:m.trim())==null?void 0:T.length)>=F;return d?U.createPortal(e.jsx(V,{isOpen:a,closeModal:I,classModal:"max-w-2xl",children:e.jsxs("div",{className:"p-6 sm:p-8",children:[e.jsx("h2",{className:"text-xl font-medium mb-2",children:t==null?void 0:t.title}),e.jsx("p",{className:"text-sm text-gray-500 mb-5",children:t==null?void 0:t.description}),e.jsxs("div",{className:"relative mb-6",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-efl-400",children:e.jsx(h,{name:"magnifying-glass",classIcon:"text-lg"})}),e.jsx("input",{ref:w,type:"text",value:m,onChange:o=>f(o.target.value),placeholder:t==null?void 0:t.placeholder,className:"w-full bg-gray-efl-50 border-0 rounded-full pl-10 pr-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-gray-efl-200 transition-colors placeholder:text-gray-efl-400"})]}),R&&e.jsx("p",{className:"text-sm text-red-600 mb-4",children:R}),g&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(H,{classContainer:"!relative !bg-transparent !top-auto !left-auto !bottom-auto !right-auto"})}),!g&&E&&N.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(h,{name:"map-pin",classIcon:"text-4xl text-gray-efl-200 mb-3"}),e.jsx("p",{className:"text-sm text-gray-500",children:t==null?void 0:t.no_results})]}),!g&&N.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-gray-500 mb-3",children:[N.length," ",N.length===1?t==null?void 0:t.store_found:t==null?void 0:t.stores_found]}),e.jsx("div",{className:"flex flex-col gap-3 max-h-[400px] overflow-y-auto",children:N.map(o=>e.jsx(Z,{store:o,onSelect:C,isLoading:_},o.store_id??o.id))})]})]})}),d):null},le=({isOpen:a,closeModal:r,onConfirm:l,isLoading:n})=>{var d;const{t:s}=M().props,t=(d=s==null?void 0:s.my_store)==null?void 0:d.confirm_remove,c=Q("#portal-root");return c?U.createPortal(e.jsx(V,{isOpen:a,closeModal:r,classModal:"max-w-md",children:e.jsxs("div",{className:"p-6 sm:p-8 text-center",children:[e.jsx("h3",{className:"text-lg font-medium mb-3",children:t==null?void 0:t.title}),e.jsx("p",{className:"text-sm text-gray-500 mb-6",children:t==null?void 0:t.description}),e.jsxs("div",{className:"flex justify-center gap-3",children:[e.jsx(S,{typeStyles:"outline",size:"M",action:r,isDisabled:n,children:t==null?void 0:t.cancel}),e.jsx(S,{typeStyles:"filled",size:"M",action:l,isDisabled:n,classButton:"bg-red-600 hover:bg-red-700 border-red-600",children:t==null?void 0:t.confirm})]})]})}),c):null},re="/ajax/customer/store/remove";function be(){var C;const{metas:a,t:r,stores:l,userMenuCustomerArea:n,customerStore:s}=M().props,t=r==null?void 0:r.my_store,c=W(),{showMultistore:d}=q({specificSection:"multistore"}),[m,f]=i.useState(!1),[_,p]=i.useState(!1),[g,x,j]=D(),[u,R,b]=D(),w=i.useMemo(()=>!(s!=null&&s.id)||!l?null:(Array.isArray(l)?l:[]).find(E=>E.id===s.id||E.store_id===s.id),[s,l]),v=i.useCallback(()=>{p(!0),z.reload({onFinish:()=>p(!1)})},[]),N=i.useCallback(async()=>{f(!0);try{await B(re,{}),b(),p(!0),z.reload({onFinish:()=>p(!1)})}catch(I){L(I)}finally{f(!1)}},[b]);return!d||!c?e.jsxs(P,{children:[e.jsx(O,{metas:a}),e.jsx($,{titlePage:t==null?void 0:t.title_page,dataMenu:n,children:e.jsx("p",{className:"text-sm text-gray-500",children:(C=t==null?void 0:t.no_store)==null?void 0:C.description})})]}):e.jsxs(P,{children:[e.jsx(O,{metas:a}),e.jsxs($,{titlePage:t==null?void 0:t.title_page,dataMenu:n,children:[_&&e.jsx(H,{}
1),e.jsx(J,{title:t==null?void 0:t.section_title,description:t==null?void 0:t.section_description,hasClose:!1,classContainer:"mb-6"}),w?e.jsx(X,{store:w,onChangeStore:x,onRemoveStore:R}):e.jsx(Y,{onSelectStore:x}),e.jsx(ae,{isOpen:g,closeModal:j,onStoreAssigned:v,stores:Array.isArray(l)?l:[]}),e.jsx(le,{isOpen:u,closeModal:b,onConfirm:N,isLoading:m})]})]})}export{be as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.