import{a as k,b as re}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-VRXE3SXE.js";import{$ as D,f as ae,g as N,i as J}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-3AWCCX5S.js";import{p as g,q as d}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-Y6K5Z6SS.js";import{a as m}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-OMYQV4CB.js";import{e as ne}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-UMJHMB76.js";import{a as f}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-4WUWJLQN.js";import{a as ee,b as w,f as te,m as oe,t as M,x as G}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-GSUAV5SD.js";import{a as y}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-T3SAXWHR.js";import{a as I}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-ZQ5CXEJV.js";import{d as c}from"https://cdn.shopify.com/oxygen-v2/26431/10783/22349/1653411/build/_shared/chunk-ISGSLAJR.js";var i=c(I());var O=c(I());var a=c(y()),se=({open:t,onClose:e})=>(0,a.jsx)(d,{appear:!0,show:t,as:O.Fragment,children:(0,a.jsxs)(g,{as:"div",className:"relative z-[10000]",onClose:e,children:[(0,a.jsx)(d.Child,{as:O.Fragment,enter:"ease-out duration-500",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-500",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{"aria-hidden":"true",className:"pointer-events-none fixed inset-0 z-40 bg-black bg-opacity-20"})}),(0,a.jsx)(d.Child,{as:O.Fragment,enter:"ease-in-out duration-500",enterFrom:"translate-x-full",enterTo:"translate-x-0",leave:"ease-in-out duration-500",leaveFrom:"translate-x-0",leaveTo:"translate-x-full",children:(0,a.jsxs)(g.Panel,{className:f("rounded-l-none overflow-y-none fixed bottom-0 left-0 right-0 top-0 z-40 flex h-full w-full flex-col bg-white md:bottom-auto md:left-auto md:w-[627px]","md:rounded-l-xl"),children:[(0,a.jsx)(qe,{onClose:e}),(0,a.jsx)("div",{className:"flex w-full flex-col px-8 pb-8",children:(0,a.jsx)("p",{className:"text-md font-[400] leading-[1.4] text-[#505D68]",children:"Medshop supplies controlled drugs exclusively to prequalified business and licensed clients. Please request access these products."})}),(0,a.jsx)(_e,{handleCancel:e})]})})]})}),qe=({onClose:t})=>(0,a.jsx)("header",{className:f("sticky top-0 z-[1] mb-2 flex h-header-sm items-center justify-between bg-white px-4 pt-6 pt-6 lg:mb-4 lg:px-8 lg:pt-[40px]","lg:min-h-header-lg"),children:(0,a.jsxs)("div",{className:"flex w-full items-center justify-between pb-2",children:[(0,a.jsx)("div",{className:"flex text-xl font-bold leading-[1.2] text-black",children:"Request access to controlled drugs"}),(0,a.jsx)("button",{type:"button",className:"outline-none",onClick:t,children:(0,a.jsx)(N,{src:D.closeCart,aspectRatio:1,className:"h-6 w-6 md:h-5 md:w-5",alt:"close"})})]})}),_e=({handleCancel:t})=>{let e=w();return(0,a.jsx)("footer",{className:"sticky bottom-0 bg-white px-4 pb-6 lg:px-8 lg:pb-[41px]",children:(0,a.jsxs)("div",{className:"relative flex gap-4",children:[(0,a.jsx)(m.Primary,{className:"rounded-lg",onClick:()=>e("/pages/apply-pharmaceuticals"),children:"Request access"}),(0,a.jsx)(m.Secondary,{onClick:t,children:"Close"})]})})};var B=c(I());var n=c(y()),ie=({open:t,onClose:e})=>(0,n.jsx)(d,{appear:!0,show:t,as:B.Fragment,children:(0,n.jsxs)(g,{as:"div",className:"relative z-[10000]",onClose:e,children:[(0,n.jsx)(d.Child,{as:B.Fragment,enter:"ease-out duration-500",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-500",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,n.jsx)("div",{"aria-hidden":"true",className:"pointer-events-none fixed inset-0 z-40 bg-black bg-opacity-20"})}),(0,n.jsx)(d.Child,{as:B.Fragment,enter:"ease-in-out duration-500",enterFrom:"translate-x-full",enterTo:"translate-x-0",leave:"ease-in-out duration-500",leaveFrom:"translate-x-0",leaveTo:"translate-x-full",children:(0,n.jsxs)(g.Panel,{className:f("rounded-l-none overflow-y-none fixed bottom-0 left-0 right-0 top-0 z-40 flex h-full w-full flex-col bg-white md:bottom-auto md:left-auto md:w-[627px]","md:rounded-l-xl"),children:[(0,n.jsx)(Ee,{onClose:e}),(0,n.jsx)("div",{className:"flex w-full flex-col px-8 pb-8",children:(0,n.jsx)("p",{className:"text-md font-[400] leading-[1.4] text-[#505D68]",children:"Medshop supplies pharmaceuticals exclusively to prequalified business and licensed clients. Please request access these products."})}),(0,n.jsx)(ze,{handleCancel:e})]})})]})}),Ee=({onClose:t})=>(0,n.jsx)("header",{className:f("sticky top-0 z-[1] mb-2 flex h-header-sm items-center justify-between bg-white px-4 pt-6 pt-6 lg:mb-4 lg:px-8 lg:pt-[40px]","lg:min-h-header-lg"),children:(0,n.jsxs)("div",{className:"flex w-full items-center justify-between pb-2",children:[(0,n.jsx)("div",{className:"flex text-xl font-bold leading-[1.2] text-black",children:"Request access to pharmaceuticals"}),(0,n.jsx)("button",{type:"button",className:"outline-none",onClick:t,children:(0,n.jsx)(N,{src:D.closeCart,aspectRatio:1,className:"h-6 w-6 md:h-5 md:w-5",alt:"close"})})]})}),ze=({handleCancel:t})=>{let e=w();return(0,n.jsx)("footer",{className:"sticky bottom-0 bg-white px-4 pb-6 lg:px-8 lg:pb-[41px]",children:(0,n.jsxs)("div",{className:"relative flex gap-4",children:[(0,n.jsx)(m.Primary,{className:"rounded-lg",onClick:()=>e("/pages/apply-pharmaceuticals"),children:"Request access"}),(0,n.jsx)(m.Secondary,{onClick:t,children:"Close"})]})})};var R=c(I());var o=c(y()),le=({open:t,onClose:e})=>{let l=w(),p=()=>{l("/pages/pharmaceuticals-access")};return(0,o.jsx)(d,{appear:!0,show:t,as:R.Fragment,children:(0,o.jsxs)(g,{as:"div",className:"relative z-[10000]",onClose:e,children:[(0,o.jsx)(d.Child,{as:R.Fragment,enter:"ease-out duration-500",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-500",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,o.jsx)("div",{"aria-hidden":"true",className:"pointer-events-none fixed inset-0 z-40 bg-black bg-opacity-20"})}),(0,o.jsx)(d.Child,{as:R.Fragment,enter:"ease-in-out duration-500",enterFrom:"translate-x-full",enterTo:"translate-x-0",leave:"ease-in-out duration-500",leaveFrom:"translate-x-0",leaveTo:"translate-x-full",children:(0,o.jsxs)(g.Panel,{className:f("rounded-l-none overflow-y-none fixed bottom-0 left-0 right-0 top-0 z-40 flex h-full w-full flex-col bg-white md:bottom-auto md:left-auto md:w-[627px]","md:rounded-l-xl"),children:[(0,o.jsx)(je,{onClose:e}),(0,o.jsxs)("div",{className:"flex w-full flex-col gap-8 p-8 pb-8",children:[(0,o.jsxs)("p",{className:"text-md font-[400] leading-[1.4] text-[#505D68]",children:["Medshop supplies pharmaceuticals exclusively to prequalified business and licensed clients. Please log in to your business account to access these products."," "]}),(0,o.jsxs)("p",{className:"text-md font-[400] leading-[1.4] text-[#505D68]",children:["If you\u2019re interested in becoming a prequalified client,"," ",(0,o.jsx)("span",{className:"cursor-pointer underline",onClick:p,children:"click here to learn more."})]})]}),(0,o.jsx)(Me,{handleCancel:e})]})})]})})},je=({onClose:t})=>(0,o.jsx)("header",{className:f("sticky top-0 z-[1] mb-2 flex h-header-sm items-center justify-between bg-white px-4 pt-6 pt-6 lg:mb-4 lg:px-8 lg:pt-[40px]","lg:min-h-header-lg"),children:(0,o.jsxs)("div",{className:"flex w-full items-center justify-between pb-2",children:[(0,o.jsx)("div",{className:"flex text-xl font-bold leading-[1.2] text-black",children:"Login to your business account"}),(0,o.jsx)("button",{type:"button",className:"outline-none",onClick:t,children:(0,o.jsx)(N,{src:D.closeCart,aspectRatio:1,className:"h-6 w-6 md:h-5 md:w-5",alt:"close"})})]})}),Me=({handleCancel:t})=>{let e=w(),l=()=>{e("/account/b2b/login"),t()};return(0,o.jsx)("footer",{className:"sticky bottom-0 bg-white px-4 pb-6 lg:px-8 lg:pb-[41px]",children:(0,o.jsxs)("div",{className:"relative flex gap-4",children:[(0,o.jsx)(m.Primary,{className:"rounded-lg",onClick:l,children:"B2B Login"}),(0,o.jsx)(m.Secondary,{onClick:()=>e("/pages/pharmaceuticals-access"),children:"Learn more"})]})})};var W=t=>t?.map(l=>{let p=l?.attributes?.filter(C=>C.value);if(!p?.length){let{attributes:C,...x}=l;return{...x}}return{...l,attributes:p}});var r=c(y()),Ge=({quantity:t,isB2bAuth:e,isPharma:l,isDrug:p,accessToDrugs:C,accessToPharma:x,children:A="Add to cart",lines:P,analytics:S,mode:F="default",customizations:h,showRequired:q,cleanContext:ce,addButtonMode:H,toggleShowMessage:de,selectedVariant:u,product:T,soldOut:me,freeItem:pe,algoliaEventPayload:ue,afterSubmitEffect:U,buttonType:K="default",triggerCartDrawer:fe=!0})=>{let[L]=M(),[Q,ge]=(0,i.useState)(null),{isOpen:_,openDrawer:X,closeDrawer:he}=k(),{isOpen:ve,openDrawer:be,closeDrawer:ye}=k(),{isOpen:xe,openDrawer:we,closeDrawer:Ce}=k(),{isOpen:Ne,openDrawer:De,closeDrawer:Te}=k(),E=ae("ADD_TO_CART"),ke=te(),z=ee(),v=G(),Ae=oe().some(s=>s.formAction==="/cart"),Pe=ke.state!=="idle",Fe=L.data?.cart,Y=L?.data?.selectedLocale,Le=L.data.envs?.googleAnalyticsId,Ie=L.data.envs.nodeEnv,j=(0,i.useMemo)(()=>new URLSearchParams(z.search),[z.search]),Oe=(0,i.useCallback)(()=>{Ie!=="development"&&Le&>ag("event","add_to_cart",ue??(u&&T&&{ecomm_prodid:[u?.id||""],ecomm_totalvalue:Number(u.price.amount),ecomm_pagetype:"cart",value:Number(u.price.amount),currency:u.price.currencyCode,items:[{id:u?.id||"",name:T?.title||"",brand:T?.vendor,category:T?.collections.edges[0].node.title||"",price:Number(u.price.amount)||0,quantity:t,variant:u.title}]}))},[u,T]),Be=(0,i.useCallback)(s=>{if(H||(s.preventDefault(),de(!0)),!h.haveCustomization){let b=new Event("addToCart");window.dispatchEvent(b),Oe();return}if(h.haveRequired||!h.agreedWithTerms){q(),s.preventDefault();return}setTimeout(ce,2e3)},[h,H]),Re=s=>{s.preventDefault(),e||we(),e&&(p&&!C&&De(),l&&!x&&be())},Z=s=>{(l||p)&&!e||e&&(p&&!C||l&&!x)?Re(s):Be(s)},Se=(0,i.useMemo)(()=>W(P.map(s=>{let b=s?.attributes?.filter(V=>V.key!=="objectID"&&V.key!=="queryID");return{...s,attributes:b}})),[P]),$=Ae||Pe||pe||me||v.state==="submitting"||t===0||h?.haveRequired&&!h?.agreedWithTerms;return(0,i.useEffect)(()=>{if(typeof window<"u"){let s=sessionStorage.getItem("queryID")||j.get("queryID"),b=sessionStorage.getItem("objectID")||j.get("objectID");b&&ge({queryID:s,objectID:b})}},[z.pathname,j]),(0,i.useEffect)(()=>{let s=document.getElementById("headlessui-portal-root");_||E.length===0||E[0].state==="submitting"||s||fe&&X()},[E,_,X]),(0,i.useEffect)(()=>{let s=v?.data?.errors;if(v?.data&&s?.length)for(let b of s)ne(b.message,"error");v.data&&U&&U()},[v.data]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(le,{open:xe,onClose:Ce}),(0,r.jsx)(se,{open:Ne,onClose:Te}),(0,r.jsx)(ie,{open:ve,onClose:ye}),(0,r.jsx)(i.Suspense,{children:(0,r.jsx)(re,{cart:Fe,open:_,onClose:he})}),(0,r.jsxs)(v.Form,{action:"/cart",method:"post",className:F=="inline"?"inline":"",children:[(0,r.jsx)("input",{type:"hidden",name:"cartAction",value:"ADD_TO_CART"}),Y&&(0,r.jsx)("input",{type:"hidden",name:"countryCode",value:Y.country}),(0,r.jsx)("input",{type:"hidden",name:"lines",value:JSON.stringify(Se)}),Q&&(0,r.jsx)("input",{type:"hidden",name:"algolia",value:JSON.stringify(Q)}),(0,r.jsx)("input",{type:"hidden",name:"analytics",value:JSON.stringify(S)}),K==="default"&&(0,r.jsx)(m.Primary,{className:"h-12 rounded-lg font-[600]",disabled:$,onClick:Z,children:v.state==="submitting"?(0,r.jsx)(J,{width:24,height:24}):A}),K==="secondary"&&(0,r.jsx)("button",{type:"submit",disabled:$,onClick:Z,className:"flex h-12 w-full items-center justify-center rounded-lg border-2 border-ORANGE_ONE bg-white font-[600] text-ORANGE_ONE hover:border-ORANGE_TWO hover:bg-white hover:text-ORANGE_TWO disabled:cursor-not-allowed",children:v.state==="submitting"?(0,r.jsx)(J,{width:24,height:24}):A})]})]})};function wt({children:t="Add to cart",lines:e,analytics:l,mode:p="default",buttonClassName:C,loadingContent:x,...A}){let[P]=M(),S=P?.data?.selectedLocale,F=G(),h=W(e),q=()=>{F.submit({cartAction:"ADD_TO_CART",countryCode:S?.country,lines:JSON.stringify(h),analytics:JSON.stringify(l)},{method:"post",action:"/cart?index"})};return(0,r.jsx)(m.Primary,{className:"h-12 rounded-lg",onClick:q,...A,children:F.state==="submitting"&&x?x:t})}var Ct=Ge;export{wt as a,Ct as b};