PageSourceSearch

https://swastikcamphor.lovable.app/assets/ProductCard-CeCKeq9B.js

js swastikcamphor.lovable.app collected 2026-10-03 03:40:43 UTC 7,143 bytes, 1 lines download raw bytes

1import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{t}from"./react-6C37rxNK.js";import{n,t as r}from"./createServerFn-Dr7KzJlB.js";import{t as i}from"./jsx-runtime-DiK4U9sA.js";import{t as a}from"./useServerFn-DFja4LiL.js";import{t as o}from"./auth-middleware-JDjVgB0Q.js";import{r as s,t as c}from"./useQuery-C4dHuv7P.js";import{t as l}from"./useMutation-Csmofbcc.js";import{n as u,r as d}from"./catalog-CnZQMkhR.js";import{t as f}from"./shield-check-amzTehde.js";import{a as p,i as m,l as h,m as g,n as _,p as v}from"./products-DptJO1sV.js";import{Bt as y,Ut as b,Wt as x,an as S,ct as C,zt as w}from"./index-CHqFSFs5.js";import{t as T}from"./StarRating-DJmnHzPd.js";import{n as E,t as D}from"./PriceTag-CCaDNOEh.js";var O=e(t(),1),k=r({method:`POST`}).middleware([o]).handler(n(`1ecf5a677983f94fc9d10492f9c82b1b70d1bf6c9b60381e6cfefa6e9cd8b682`)),A=r({method:`POST`}).middleware([o]).handler(n(`7f0921ab5eab54f8dd35139a2c4ebad89601dc32a00e2cbe69ac28c41470eed4`));function j(){let{session:e}=b(),t=s(),n=a(k),r=a(A),i=c({queryKey:[`wishlist`],enabled:!!e,queryFn:()=>n({data:void 0})}),o=l({mutationFn:e=>r({data:{slug:e}}),onSuccess:()=>t.invalidateQueries({queryKey:[`wishlist`]})}),u=i.data??[];return{slugs:u,signedIn:!!e,has:e=>u.includes(e),toggle:e=>o.mutateAsync(e),loading:i.isLoading}}var M=i();function N({product:e,reveal:t=!0,index:n=0}){let r=S(),{lines:i,add:a}=w(),{freeShippingAbove:o}=x(),{session:s}=b(),{has:c,toggle:l}=j(),{t:k}=y(),A=u(),N=(0,O.useMemo)(()=>e.sizeOptions??[],[e.sizeOptions]),P=N.length>1,[F,I]=(0,O.useState)(null),L=P?N.find(e=>e.label===F)??_(e):N.length===1?N[0]:null,R=L?.price??e.price,z=L?.mrp??e.mrp??e.price,B=h(z,R),V=L?g(e,L):null,H=L&&p(L)?N.find(e=>!p(e)&&e.unit_grams===L.unit_grams):null,U=L&&H?H.price*(L.pack_count||2):null,W=V!=null&&U?Math.floor(V/U*100):null,G=L?L.stock??e.stock??null:e.stock??null,K=L?v(e,L):(e.stock??1)>0,q=L?.image??e.image,J=i.find(t=>t.slug===e.slug&&t.size===(L?.label??``)),Y=c(e.slug);L?.label?`${e.slug}${encodeURIComponent(L.label)}`:`${e.slug}`;let X=()=>{P&&L?.label?r({to:`/products/$slug`,params:{slug:e.slug},search:{size:L.label}}):r({to:`/products/$slug`,params:{slug:e.slug}})},Z=()=>{if(!s){C.info(`Sign in to save favourites.`),r({to:`/auth`});return}l(e.slug)};return(0,M.jsxs)(`article`,{onClick:X,onKeyDown:e=>{e.key===`Enter`&&e.target===e.currentTarget&&X()},tabIndex:0,role:`link`,"aria-label":`View ${e.name}`,className:`card-premium group flex cursor-pointer flex-col overflow-hidden transition-shadow hover:shadow-lg ${t?`reveal`:``}`,style:t&&n?{transitionDelay:`${n*70}ms`}:void 0,children:[(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(`img`,{src:q,alt:L?`${e.name} – ${L.label}`:`${e.name} by Swastik Camphor`,loading:`lazy`,className:`aspect-square w-full object-cover transition-transform duration-700 group-hover:scale-105`}),B>0&&(0,M.jsxs)(`span`,{className:`absolute left-2 top-2 rounded-full bg-accent px-2.5 py-1 text-xs font-bold text-accent-foreground shadow`,children:[B,`% OFF`]}),(0,M.jsx)(`button`,{type:`button`,"aria-label":Y?`Remove from wishlist`:`Add to wishlist`,"aria-pressed":Y,onClick:e=>{e.stopPropagation(),Z()},className:`absolute right-2 top-2 grid h-9 w-9 place-items-center rounded-full bg-background/90 shadow transition-transform hover:scale-105`,children:(0,M.jsx)(d,{className:`h-4 w-4 ${Y?`fill-accent text-accent`:`text-muted-foreground`}`})}),!K&&(0,M.jsx)(`span`,{className:`absolute inset-x-0 bottom-0 bg-background/90 py-1 text-center text-xs font-medium text-destructive`,children:`Out of stock`})]}),(0,M.jsxs)(`div`,{className:`flex flex-1 flex-col p-4`,children:[(0,M.jsx)(`h3`,{className:`font-body text-base font-semibold leading-snug`,children:e.name}),typeof e.rating==`number`&&e.rating>0&&(e.ratingCount??0)>0?(0,M.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5`,children:[(0,M.jsx)(T,{rating:e.rating}),(0,M.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,(e.ratingCount??0).toLocaleString(`en-IN`),`)`]})]}):(0,M.jsxs)(`p`,{className:`mt-1 flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,M.jsx)(f,{className:`h-3.5 w-3.5 shrink-0 text-accent`,"aria-hidden":`true`}),k(`Trusted in 5,000+ stores across India`)]}),P&&(0,M.jsxs)(`div`,{className:`mt-3`,onClick:e=>e.stopPropagation(),children:[(0,M.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Pack`}),(0,M.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,role:`radiogroup`,"aria-label":`Pack size`,children:N.map(t=>{let n=v(e,t),r=L?.label===t.label,i=h(t.mrp,t.price);return(0,M.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,disabled:!n,onClick:()=>I(t.label),className:`flex min-h-9 items-center gap-1 rounded-full border px-2.5 text-xs transition-colors ${r?`border-primary bg-primary/10 font-medium`:p(t)?`border-gold/60 hover:border-primary/60`:`border-gold/40 hover:border-primary/60`} ${n?``:`opacity-50 line-through`}`,children:[t.short_label??t.label,i>0&&(0,M.jsxs)(`span`,{className:`font-semibold text-primary`,children:[i,`%`]})]},t.label)})})]}),(0,M.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-baseline gap-x-2`,children:[(0,M.jsx)(D,{amount:R,className:`text-[22px] text-maroon-deep md:text-[26px]`}),z>R&&(0,M.jsx)(`span`,{className:`tnum text-base text-muted-foreground line-through md:text-lg`,children:m(z)}),B>0&&(0,M.jsxs)(`span`,{className:`text-base font-bold text-emerald-700 md:text-lg`,children:[B,`% `,k(`OFF`)]})]}),(0,M.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-snug text-muted-foreground`,children:`Inclusive of all taxes`}),V!=null&&W!=null&&U!=null?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`p`,{className:`tnum mt-0.5 text-[11px] text-muted-foreground`,children:[L?.pack_count||2,` `,k(`jars separately`),`: `,m(U)]}),(0,M.jsxs)(`p`,{className:`tnum mt-0.5 text-xs font-semibold text-emerald-700`,children:[k(`S
1ave`),` `,m(V),` (`,W,`%) `,k(`vs 2 single jars`)]})]}):B>=1?(0,M.jsxs)(`p`,{className:`tnum mt-0.5 text-xs font-semibold text-emerald-700`,children:[k(`You save`),` `,m(z-R),` `,k(`on MRP`)]}):null,G!=null&&G>=1&&G<=10&&(0,M.jsxs)(`p`,{className:`mt-0.5 text-xs font-medium text-amber-700`,children:[k(`Only`),` `,G,` `,k(`left`)]}),R>=o&&(0,M.jsx)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:`Free shipping`}),(()=>{let t=A[e.slug]?.[L?.label??``]??0;return t<10?null:(0,M.jsx)(`p`,{className:`mt-0.5 text-[11px] font-medium text-primary`,children:k(`${Math.floor(t/10)*10}+ bought in the past month`)})})(),(0,M.jsxs)(`div`,{className:`mt-auto flex flex-col gap-2 pt-3 lg:flex-row`,onClick:e=>e.stopPropagation(),children:[(0,M.jsx)(`div`,{className:`lg:flex-1`,children:(0,M.jsx)(E,{slug:e.slug,size:L?.label??``,max:L?L.stock??e.stock??null:null,disabled:!K||!L})}),(0,M.jsx)(`button`,{type:`button`,disabled:!K||!L,onClick:()=>{L&&(J||a(e.slug,L.label,1,{skipUpsell:!0}),r({to:`/checkout`}))},className:`h-11 w-full whitespace-nowrap rounded-full border border-gold/50 px-4 text-xs font-semibold transition-colors hover:bg-accent/15 disabled:opacity-50 lg:flex-1`,children:k(`Buy now`)})]})]})]})}export{j as n,N as t};

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.