PageSourceSearch

https://tryhavyn.com/assets/checkout-CdhPp_MM.js

js tryhavyn.com collected 2026-09-24 14:56:32 UTC 24,469 bytes, 1 lines download raw bytes

1import{c as ve,j as e,r as c,$ as Z,n as je,t as R,aS as Ne,X as Ce,aD as we,u as ee,a as I,ai as Te,i as te,k as re,aT as ke,aU as _e,G as Pe,L as X,am as Ee,aV as Se,aW as Re,aX as De,aY as Ae,aq as Le,as as Me,P as Oe,O as Ie,Q as Fe}from"./index-BUCFbuLp.js";import{u as Y}from"./useMutation-CJdcrmxg.js";import{S as He}from"./StateSelect-J961r3J-.js";import{f as C,a as $e}from"./format-CRbf4Bhs.js";import{b as qe,d as Ge,u as Qe,a as Ve,c as E,P as se,f as Ye,D as Be}from"./index-DVnQU8aj.js";import{c as ne,R as Ke,A as Ue,C as We,a as Xe}from"./index-3obEmoLj.js";import{R as ze}from"./index-DGB_PqOf.js";import{C as oe}from"./check-CQuVRh8U.js";import{L as Je}from"./loader-circle-DDgcSI5K.js";import{T as Ze}from"./truck-pht-RlHw.js";import{S as et}from"./store-0eX-45yJ.js";import{M as B}from"./map-pin-CNa6gMHi.js";import{L as tt}from"./lock-CSU6RVfe.js";import{H as rt,B as st}from"./house-C3jFyjZP.js";const nt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ot=ve("circle-question-mark",nt);var at=Symbol("radix.slottable");function it(t){const n=({children:r})=>e.jsx(e.Fragment,{children:r});return n.displayName=`${t}.Slottable`,n.__radixId=at,n}var[F]=qe("Tooltip",[ne]),H=ne(),ae="TooltipProvider",lt=700,Q="tooltip.open",[ct,K]=F(ae),ie=t=>{const{__scopeTooltip:n,delayDuration:r=lt,skipDelayDuration:s=300,disableHoverableContent:o=!1,children:i}=t,a=c.useRef(!0),p=c.useRef(!1),d=c.useRef(0);return c.useEffect(()=>{const l=d.current;return()=>window.clearTimeout(l)},[]),e.jsx(ct,{scope:n,isOpenDelayedRef:a,delayDuration:r,onOpen:c.useCallback(()=>{window.clearTimeout(d.current),a.current=!1},[]),onClose:c.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>a.current=!0,s)},[s]),isPointerInTransitRef:p,onPointerInTransitChange:c.useCallback(l=>{p.current=l},[]),disableHoverableContent:o,children:i})};ie.displayName=ae;var D="Tooltip",[dt,A]=F(D),le=t=>{const{__scopeTooltip:n,children:r,open:s,defaultOpen:o,onOpenChange:i,disableHoverableContent:a,delayDuration:p}=t,d=K(D,t.__scopeTooltip),l=H(n),[u,x]=c.useState(null),m=Ge(),h=c.useRef(0),y=a??d.disableHoverableContent,g=p??d.delayDuration,v=c.useRef(!1),[j,b]=Qe({prop:s,defaultProp:o??!1,onChange:L=>{L?(d.onOpen(),document.dispatchEvent(new CustomEvent(Q))):d.onClose(),i?.(L)},caller:D}),N=c.useMemo(()=>j?v.current?"delayed-open":"instant-open":"closed",[j]),T=c.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,b(!0)},[b]),k=c.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),w=c.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,b(!0),h.current=0},g)},[g,b]);return c.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),e.jsx(Ke,{...l,children:e.jsx(dt,{scope:n,contentId:m,open:j,stateAttribute:N,trigger:u,onTriggerChange:x,onTriggerEnter:c.useCallback(()=>{d.isOpenDelayedRef.current?w():T()},[d.isOpenDelayedRef,w,T]),onTriggerLeave:c.useCallback(()=>{y?k():(window.clearTimeout(h.current),h.current=0)},[k,y]),onOpen:T,onClose:k,disableHoverableContent:y,children:r})})};le.displayName=D;var V="TooltipTrigger",ce=c.forwardRef((t,n)=>{const{__scopeTooltip:r,...s}=t,o=A(V,r),i=K(V,r),a=H(r),p=c.useRef(null),d=Z(n,p,o.onTriggerChange),l=c.useRef(!1),u=c.useRef(!1),x=c.useCallback(()=>l.current=!1,[]);return c.useEffect(()=>()=>document.removeEventListener("pointerup",x),[x]),e.jsx(Ue,{asChild:!0,...a,children:e.jsx(Ve.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...s,ref:d,onPointerMove:E(t.onPointerMove,m=>{m.pointerType!=="touch"&&!u.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),u.current=!0)}),onPointerLeave:E(t.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:E(t.onPointerDown,()=>{o.open&&o.onClose(),l.current=!0,document.addEventListener("pointerup",x,{once:!0})}),onFocus:E(t.onFocus,()=>{l.current||o.onOpen()}),onBlur:E(t.onBlur,o.onClose),onClick:E(t.onClick,o.onClose)})})});ce.displayName=V;var U="TooltipPortal",[ut,mt]=F(U,{forceMount:void 0}),de=t=>{const{__scopeTooltip:n,forceMount:r,children:s,container:o}=t,i=A(U,n);return e.jsx(ut,{scope:n,forceMount:r,children:e.jsx(se,{present:r||i.open,children:e.jsx(Ye,{asChild:!0,container:o,children:s})})})};de.displayName=U;
1var S="TooltipContent",ue=c.forwardRef((t,n)=>{const r=mt(S,t.__scopeTooltip),{forceMount:s=r.forceMount,side:o="top",...i}=t,a=A(S,t.__scopeTooltip);return e.jsx(se,{present:s||a.open,children:a.disableHoverableContent?e.jsx(me,{side:o,...i,ref:n}):e.jsx(pt,{side:o,...i,ref:n})})}),pt=c.forwardRef((t,n)=>{const r=A(S,t.__scopeTooltip),s=K(S,t.__scopeTooltip),o=c.useRef(null),i=Z(n,o),[a,p]=c.useState(null),{trigger:d,onClose:l}=r,u=o.current,{onPointerInTransitChange:x}=s,m=c.useCallback(()=>{p(null),x(!1)},[x]),h=c.useCallback((y,g)=>{const v=y.currentTarget,j={x:y.clientX,y:y.clientY},b=bt(j,v.getBoundingClientRect()),N=gt(j,b),T=vt(g.getBoundingClientRect()),k=Nt([...N,...T]);p(k),x(!0)},[x]);return c.useEffect(()=>()=>m(),[m]),c.useEffect(()=>{if(d&&u){const y=v=>h(v,u),g=v=>h(v,d);return d.addEventListener("pointerleave",y),u.addEventListener("pointerleave",g),()=>{d.removeEventListener("pointerleave",y),u.removeEventListener("pointerleave",g)}}},[d,u,h,m]),c.useEffect(()=>{if(a){const y=g=>{const v=g.target,j={x:g.clientX,y:g.clientY},b=d?.contains(v)||u?.contains(v),N=!jt(j,a);b?m():N&&(m(),l())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[d,u,a,l,m]),e.jsx(me,{...t,ref:i})}),[xt,ft]=F(D,{isInside:!1}),ht=it("TooltipContent"),me=c.forwardRef((t,n)=>{const{__scopeTooltip:r,children:s,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...p}=t,d=A(S,r),l=H(r),{onClose:u}=d;return c.useEffect(()=>(document.addEventListener(Q,u),()=>document.removeEventListener(Q,u)),[u]),c.useEffect(()=>{if(d.trigger){const x=m=>{m.target?.contains(d.trigger)&&u()};return window.addEventListener("scroll",x,{capture:!0}),()=>window.removeEventListener("scroll",x,{capture:!0})}},[d.trigger,u]),e.jsx(Be,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:x=>x.preventDefault(),onDismiss:u,children:e.jsxs(We,{"data-state":d.stateAttribute,...l,...p,ref:n,style:{...p.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(ht,{children:s}),e.jsx(xt,{scope:r,isInside:!0,children:e.jsx(ze,{id:d.contentId,role:"tooltip",children:o||s})})]})})});ue.displayName=S;var pe="TooltipArrow",yt=c.forwardRef((t,n)=>{const{__scopeTooltip:r,...s}=t,o=H(r);return ft(pe,r).isInside?null:e.jsx(Xe,{...o,...s,ref:n})});yt.displayName=pe;function bt(t,n){const r=Math.abs(n.top-t.y),s=Math.abs(n.bottom-t.y),o=Math.abs(n.right-t.x),i=Math.abs(n.left-t.x);switch(Math.min(r,s,o,i)){case i:return"left";case o:return"right";case r:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function gt(t,n,r=5){const s=[];
1switch(n){case"top":s.push({x:t.x-r,y:t.y+r},{x:t.x+r,y:t.y+r});break;case"bottom":s.push({x:t.x-r,y:t.y-r},{x:t.x+r,y:t.y-r});break;case"left":s.push({x:t.x+r,y:t.y-r},{x:t.x+r,y:t.y+r});break;case"right":s.push({x:t.x-r,y:t.y-r},{x:t.x-r,y:t.y+r});break}return s}function vt(t){const{top:n,right:r,bottom:s,left:o}=t;return[{x:o,y:n},{x:r,y:n},{x:r,y:s},{x:o,y:s}]}function jt(t,n){const{x:r,y:s}=t;let o=!1;for(let i=0,a=n.length-1;i<n.length;a=i++){const p=n[i],d=n[a],l=p.x,u=p.y,x=d.x,m=d.y;u>s!=m>s&&r<(x-l)*(s-u)/(m-u)+l&&(o=!o)}return o}function Nt(t){const n=t.slice();return n.sort((r,s)=>r.x<s.x?-1:r.x>s.x?1:r.y<s.y?-1:r.y>s.y?1:0),Ct(n)}function Ct(t){if(t.length<=1)return t.slice();const n=[];for(let s=0;s<t.length;s++){const o=t[s];for(;n.length>=2;){const i=n[n.length-1],a=n[n.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}n.pop();const r=[];for(let s=t.length-1;s>=0;s--){const o=t[s];for(;r.length>=2;){const i=r[r.length-1],a=r[r.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))r.pop();else break}r.push(o)}return r.pop(),n.length===1&&r.length===1&&n[0].x===r[0].x&&n[0].y===r[0].y?n:n.concat(r)}
1var wt=ie,Tt=le,kt=ce,_t=de,xe=ue;const Pt=wt,Et=Tt,St=kt,fe=c.forwardRef(({className:t,sideOffset:n=4,...r},s)=>e.jsx(_t,{children:e.jsx(xe,{ref:s,sideOffset:n,className:je("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-tooltip-content-transform-origin)",t),...r})}));fe.displayName=xe.displayName;function Rt({sellerId:t,listingId:n,mode:r="buy-now",applied:s,onApply:o,onClear:i}){const[a,p]=c.useState(""),d=Y({mutationFn:u=>Ne({code:u,mode:r,...n?{listing_id:n}:{},...t?{seller_id:t}:{}}),onSuccess:u=>{o(u),p("")},onError:u=>R.error(u.message||"Invalid voucher code")});if(s)return e.jsxs("div",{className:"mt-5",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground",children:"Voucher"}),e.jsxs("div",{className:"mt-2 flex items-center justify-between rounded-xl border border-primary/40 bg-primary/5 px-3 py-2.5 text-sm",children:[e.jsxs("span",{className:"inline-flex items-center gap-2 font-medium",children:[e.jsx(oe,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-mono uppercase",children:s.code}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["− ",C(s.discount)]})]}),e.jsx("button",{type:"button",onClick:i,className:"grid h-7 w-7 place-items-center rounded-full text-muted-foreground hover:bg-background","aria-label":"Remove voucher",children:e.jsx(Ce,{className:"h-3.5 w-3.5"})})]})]});const l=()=>{const u=a.trim();u&&d.mutate(u)};return e.jsxs("div",{className:"mt-5",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground",children:"Voucher code"}),e.jsxs("div",{className:"mt-2 flex items-stretch gap-2",children:[e.jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-xl border border-border bg-background px-3",children:[e.jsx(we,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("input",{value:a,onChange:u=>p(u.target.value.toUpperCase()),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),l())},placeholder:"Enter code",className:"flex-1 bg-transparent py-2.5 text-sm outline-none uppercase placeholder:normal-case placeholder:text-muted-foreground"})]}),e.jsx("button",{type:"button",onClick:l,disabled:!a.trim()||d.isPending,className:"rounded-xl border border-border px-4 text-xs font-semibold hover:bg-muted disabled:opacity-50",children:d.isPending?e.jsx(Je,{className:"h-4 w-4 animate-spin"}):"Apply"})]})]})}function Dt({subtotal:t,discount:n=0,enabled:r=!0}){const{isAuthenticated:s}=ee(),o=I({queryKey:["referral-wallet"],queryFn:Te,enabled:s&&r,staleTime:6e4,retry:1}),i=o.isSuccess&&Number.isFinite(o.data.spending.available)?Math.max(0,Math.round(o.data.spending.available)):0,a=Math.max(0,Math.round(t)-Math.max(0,Math.round(n))),p=Math.min(i,a);return{available:i,estimated:p,isLoading:o.isLoading}}const he=[{key:"home",title:"Home",icon:rt},{key:"work",title:"Work",icon:st},{key:"other",title:"Other",icon:B}];function At({label:t}){const n=(t??"").toLowerCase(),r=he.find(i=>i.key===n),s=r?.icon??B,o=r?.title??(t?t.charAt(0).toUpperCase()+t.slice(1):"Address");return e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium",children:[e.jsx(s,{className:"h-3.5 w-3.5 text-muted-foreground"}),o]})}const Lt=4,Mt=2;function z(t){const n=new Date;return n.setDate(n.getDate()+t),`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`}function Jt(){const{isAuthenticated:t}=ee(),n=te(),r=re(),{seller:s}=ke.useSearch(),{data:o}=I({..._e,enabled:t}),{data:i}=I({...Pe,enabled:t}),[a,p]=c.useState({});if(!t)return e.jsxs("div",{className:"mx-auto max-w-md py-20 text-center",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Sign in to checkout"}),e.jsxs(X,{to:"/login",className:"mt-6 inline-flex items-center gap-1.5 rounded-full brand-gradient px-6 py-3 text-sm font-semibold text-primary-foreground",children:[e.jsx(Ee,{className:"h-4 w-4"})," Sign in"]})]});const d=o??{sellers:[]},l=s?d.sellers.filter(m=>m.seller_id===s):d.sellers,u=l.filter(m=>!a[m.seller_id]),x=l.length>0&&u.length===0;return e.jsx(Pt,{children:e.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-8 md:px-6",children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Checkout"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s?"You're checking out a single seller's order.":"Havyn places one order per seller. Place each one separately."}),s&&d.sellers.length>1&&e.jsx("button",{onClick:()=>n({to:"/checkout",search:{}}
1),className:"mt-2 text-xs font-semibold text-primary hover:underline",children:"← Show all sellers in my bag"}),l.length===0&&e.jsx("div",{className:"mt-8 rounded-2xl border border-border bg-card p-6 text-sm text-muted-foreground",children:s?"That seller is no longer in your bag.":"Your bag is empty."}),e.jsx("div",{className:"mt-6 space-y-6",children:l.map(m=>e.jsx(Ot,{seller:m,addresses:i??[],placed:!!a[m.seller_id],onPlaced:()=>{p(h=>({...h,[m.seller_id]:!0})),r.invalidateQueries({queryKey:["cart"]}),r.invalidateQueries({queryKey:["orders","user"]})}},m.seller_id))}),x&&e.jsxs("div",{className:"mt-6 rounded-2xl border border-primary/30 bg-primary/5 p-4 text-sm",children:["All orders placed."," ",e.jsx(X,{to:"/orders",className:"font-semibold text-primary underline",children:"View orders →"})]})]})})}function Ot({seller:t,addresses:n,placed:r,onPlaced:s}){const o=re(),i=te(),a=Se(t),p=Re(t),d=a?"delivery":"pickup",[l,u]=c.useState(d),[x,m]=c.useState(null),h=n.find(f=>f.is_default)?.id??n[0]?.id??null,[y,g]=c.useState(h);!y&&h&&g(h);const v=typeof t.weight=="number"&&t.weight>0?t.weight:Lt,j=l==="delivery"&&!!t.pickup_address_id&&!!y,b=I({queryKey:["delivery-options",t.seller_id,t.pickup_address_id,y,v],queryFn:()=>De({pickup_address_id:t.pickup_address_id,address_id:y,weight:v}),enabled:j,staleTime:6e4,retry:1}),N=l==="delivery"?Math.round(Number(b.data?.delivery_fee_data?.price??0)):0,T=l==="delivery"&&!!b.data?.is_free_delivery,k=l==="delivery"&&Number(b.data?.estimated_delivery_time_days??b.data?.delivery_fee_data?.estimated_delivery_time_days??0)||null,w=t.subtotal,L=Ie(w),$=Fe(w),M=x?Math.max(0,Math.round(x.discount)):0,{estimated:O}=Dt({subtotal:w,discount:M}),W=Math.max(0,w+$+N-M-O),q=Y({mutationFn:()=>{const f=z(l==="delivery"?Mt:0);return Ae({seller_id:t.seller_id,fee:$,...x?{voucher_code:x.code}:{},...l==="delivery"?{fulfillment_type:"delivery",delivery_fee:N,...y?{dropoff_address_id:y}:{},pickup_date:f}:{fulfillment_type:"pickup",pickup_date:f}})},onSuccess:f=>{const _=f.orders?.[0];if(!_?.order_id){R.error("Order created but no order ID returned");return}s(),i({to:"/order/$id",params:{id:String(_.order_id)}})},onError:f=>{const _=f.message||"Could not place order";R.error(_),x&&/voucher/i.test(_)&&m(null)}}),ye=l==="delivery"&&(!y||!t.pickup_address_id||b.isFetching||b.isError),be=l!=="delivery"||b.isSuccess&&(N>0||T),ge=!r&&!q.isPending&&(l==="pickup"||l==="delivery"&&!ye&&be);return e.jsxs("section",{className:"rounded-2xl border border-border bg-card p-5",children:[e.jsxs("header",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-bold",children:$e(t.seller_name)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.items.length," ",t.items.length===1?"item":"items"," · ",C(w)]})]}),r&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary",children:[e.jsx(oe,{className:"h-3 w-3"})," Placed"]})]}),e.jsx("ul",{className:"mt-4 space-y-3 text-sm",children:t.items.map(f=>e.jsxs("li",{className:"flex gap-3",children:[e.jsx("img",{src:f.primary_photo??"",alt:"",className:"h-12 w-12 rounded-lg object-cover bg-muted"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"truncate",children:f.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Qty ",f.quantity]})]}),e.jsx("span",{className:"font-medium",children:C(f.item_total)})]},f.id))}),e.jsxs("div",{className:"mt-5",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground",children:"Fulfillment"}),e.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-2",children:[e.jsx(J,{icon:e.jsx(Ze,{className:"h-4 w-4"}),label:"Delivery",sub:"Pay logistics fee",active:l==="delivery",disabled:!a,onClick:()=>u("delivery")}),e.jsx(J,{icon:e.jsx(et,{className:"h-4 w-4"}),label:"Pickup",sub:"From seller",active:l==="pickup",disabled:!p,onClick:()=>u("pickup")})]}),!a&&!p&&e.jsx("p",{className:"mt-2 text-xs text-destructive",children:"No fulfillment option matches all items in this group."})]}),l==="delivery"&&e.jsxs("div",{className:"mt-5",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground",children:"Deliver to"}),n.length===0?e.jsx(It,{onCreated:f=>{o.setQueryData(["addresses"],_=>[f,..._??[]]),g(f.id)}}):e.jsx("div",{className:"mt-2 space-y-2",children:n.map(f=>e.jsxs("label",{className:`flex cursor-pointer items-start gap-3 rounded-xl border p-3 text-sm ${y===f.id?"border-primary bg-primary/5":"border-border bg-background"}`,children:[e.jsx("input",{type:"radio",name:`addr-${t.seller_id}`,className:"mt-1",checked:y===f.id,onChange:()=>g(f.id)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"font-medium",children:[e.jsx(At,{label:f.label}),f.is_default&&e.jsx("span",{className:"ml-2 text-[10px] font-semibold uppercase tracking-wide text-primary",children:"Default"})]}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:Le(f)})]}),e.jsx(B,{className:"h-4 w-4 text-muted-foreground"})]},f.id))}),l==="delivery"&&!t.pickup_address_id&&e.jsx("p",{className:"mt-2 text-xs text-destructive",children:"Seller has no pickup address set — delivery can't be quoted."}),l==="delivery"&&b.isError&&e.jsx("p",{className:"mt-2 text-xs text-destructive",children:"Couldn't get a delivery quote. Try a different address."}),l==="delivery"&&b.isFetching&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Getting delivery quote…"})]}),e.jsx(Rt,{mode:"cart",sellerId:t.seller_id,applied:x,onApply:m,onClear:()=>m(null)}),e.jsx("div",{className:"my-5 border-t border-border"}),e.jsxs("dl",{className:"space-y-1.5 text-sm",children:[e.jsx(P,{label:"Subtotal",value:C(w)}),M>0&&e.jsx(P,{label:e.jsxs("span",{className:"text-primary",children:["Voucher (",x?.code,")"]}),value:e.jsxs("span",{className:"text-primary",children:["− ",C(M)]})}),O>0&&e.jsx(P,{label:e.jsx("span",{className:"text-primary",children:"Referral credit (automatic)"}),tooltip:"Your Havyn shopping credit is applied automatically when payment starts. It reduces the item amount only.",value:e.jsxs("span",{className:"text-primary",children:["− ",C(O)]})}),e.jsx(P,{label:`Protection fee (${L}%)`,tooltip:"This fee helps us cover payment processor fees and refunds if they need to happen, as we get charged for those.",value:C($)}),l==="delivery"&&e.jsx(P,{label:e.jsxs("span",{children:["Delivery",k?e.jsxs("span",{className:"ml-1 text-xs text-muted-foreground",children:["· ~",k,"d"]}):null]}),tooltip:"This is the amount charged by the courier and is paid directly to them.",value:b.isFetching&&!b.data?"…":T?"Free":C(N)}),l==="pickup"&&e.jsx(P,{label:"Pickup",value:"Free"}),e.jsx(P,{label:e.jsx("span",{className:"font-bold",children:"Total"}),value:e.jsx("span",{className:"font-bold",children:C(W)})})]}),O>0&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Your available Havyn shopping credit will be applied automatically when payment starts."}),e.jsxs("p",{className:"mt-5 inline-flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(tt,{className:"h-3 w-3"})," You'll pay via bank transfer on the next step."]}),e.jsx("button",{type:"button",onClick:()=>q.mutate(),disabled:!ge,className:"mt-4 w-full rounded-full brand-gradient py-3 text-sm font-semibold text-primary-foreground shadow-soft disabled:opacity-60",children:r?"Paid":q.isPending?"Creating order…":`Continue to payment · ${C(W)}`})]})}function J({icon:t,label:n,sub:r,active:s,disabled:o,onClick:i}){return e.jsxs("button",{type:"button",onClick:i,disabled:o,className:`flex items-start gap-2 rounded-xl border p-3 text-left text-sm transition ${s?"border-primary bg-primary/5":"border-border bg-background"} ${o?"opacity-40 cursor-not-allowed":"hover:border-primary/60"}`,children:[e.jsx("span",{className:s?"text-primary":"text-muted-foreground",children:t}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-semibold",children:n}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:r})]})]})}function It({onCreated:t}){const[n,r]=c.useState(!1),[s,o]=c.useState({label:"home",street:"",area:"",city:"",state:""}),i=Y({mutationFn:()=>Me({label:s.label||void 0,street:s.street,area:s.area||void 0,city:s.city,state:s.state}),onSuccess:a=>{R.success("Address saved"),t(a),r(!1)},onError:a=>R.error(a.message)});return n?e.jsxs("div",{className:"mt-2 grid gap-2 rounded-xl border border-border p-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("span",{className:"block text-xs font-medium text-muted-foreground",children:"Label"}),e.jsx("div",{className:"mt-1 flex items-center gap-2",children:he.map(a=>{const p=s.label===a.key,d=a.icon;return e.jsxs("button",{type:"button",onClick:()=>o({...s,label:a.key}),className:`inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-semibold transition ${p?"bg-primary text-primary-foreground":"border border-border bg-background text-foreground hover:bg-muted"}`,children:[e.jsx(d,{className:"h-3.5 w-3.5"}),a.title]},a.key)})})]}),e.jsx(G,{label:"Street",value:s.street,onChange:a=>o({...s,street:a})}),e.jsx(G,{label:"Area",value:s.area,onChange:a=>o({...s,area:a})}),e.jsx(G,{label:"City",value:s.city,onChange:a=>o({...s,city:a})}),e.jsxs("label",{className:"sm:col-span-2",children:[e.jsx("span",{className:"block text-xs font-medium text-muted-foreground",children:"State"}),e.jsx(He,{value:s.state,onChange:a=>o({...s,state:a}),className:"mt-1"})]}),e.jsxs("div",{className:"sm:col-span-2 flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(!1),className:"rounded-full px-3 py-1.5 text-xs",children:"Cancel"}),e.jsx("button",{type:"button",disabled:i.isPending||!s.street||!s.city||!s.state,onClick:()=>i.mutate(),className:"rounded-full brand-gradient px-4 py-1.5 text-xs font-semibold text-primary-foreground disabled:opacity-60",children:i.isPending?"Saving…":"Save address"})]})]}):e.jsxs("button",{type:"button",onClick:()=>r(!0),className:"mt-2 inline-flex items-center gap-1.5 rounded-full border border-border px-4 py-2 text-xs font-semibold hover:bg-muted",children:[e.jsx(Oe,{className:"h-3.5 w-3.5"})," Add a delivery address"]})}function G({label:t,value:n,onChange:r,className:s}){return e.jsxs("label",{className:s,children:[e.jsx("span",{className:"block text-xs font-medium text-muted-foreground",children:t}),e.jsx("input",{value:n,onChange:o=>r(o.target.value),className:"mt-1 w-full rounded-xl border border-border bg-background px-3 py-2 text-sm outline-none focus:border-primary"})]})}function P({label:t,value:n,tooltip:r}){return e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[t,r&&e.jsxs(Et,{children:[e.jsx(St,{asChild:!0,children:e.jsx(ot,{className:"h-3 w-3 cursor-help"})}),e.jsx(fe,{side:"top",className:"max-w-xs",children:e.jsx("p",{children:r})})]})]}),e.jsx("span",{children:n})]})}export{Jt as component};

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.