"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6218],{2599:(e,t,r)=>{r.d(t,{NT:()=>l,sf:()=>n,uK:()=>s,yF:()=>i});var a=r(2115);let o={};function s(e,t){if(void 0!==o[e])return o[e];try{let t=localStorage.getItem(e);if(t){let r=JSON.parse(t);return o[e]=r,r}}catch(e){}return t}function n(e,t){o[e]=t;try{localStorage.setItem(e,JSON.stringify(t)),window.dispatchEvent(new CustomEvent("knotelle_cache_updated",{detail:{key:e}}))}catch(e){}}function l(e,t){return[(0,a.useSyncExternalStore)(t=>{let r=r=>{(r.key===e||"knotelle_media_updated"===r.key||"knotelle_contact_updated"===r.key||"knotelle_about_updated"===r.key||"knotelle_media_sync"===r.key)&&t()},a=r=>{let a=r?.detail;a&&a.key!==e||t()};return window.addEventListener("storage",r),window.addEventListener("knotelle_cache_updated",a),()=>{window.removeEventListener("storage",r),window.removeEventListener("knotelle_cache_updated",a)}},()=>s(e,t),()=>t),t=>{n(e,t)}]}function i(e){let t=null;if("BroadcastChannel"in window)try{(t=new BroadcastChannel("knotelle_media_sync")).onmessage=t=>{let r=t?.data?.type||"";("MEDIA_UPDATED"===r||"knotelle_media_updated"===r||"knotelle_contact_updated"===r||"knotelle_about_updated"===r||"KNOTELLE_SYNC"===r)&&e()}}catch(e){console.warn("BroadcastChannel error:",e)}let r=t=>{("knotelle_media_updated"===t.key||"knotelle_media_sync"===t.key||t.key?.startsWith("knotelle_cache_"))&&e()},a=()=>{"visible"===document.visibilityState&&e()};return window.addEventListener("storage",r),window.addEventListener("focus",e),document.addEventListener("visibilitychange",a),()=>{t&&t.close(),window.removeEventListener("storage",r),window.removeEventListener("focus",e),document.removeEventListener("visibilitychange",a)}}},4710:(e,t,r)=>{r.d(t,{CartProvider:()=>c,_:()=>d});var a=r(5155),o=r(2115),s=r(8221),n=r(7529),l=r(4734);let i=(0,o.createContext)(void 0);function c({children:e}){let{media:t}=(0,l.r)(),[r,d]=(0,o.useState)([]),[u,m]=(0,o.useState)(!1),[f,p]=(0,o.useState)(""),[h,x]=(0,o.useState)(0),[v,g]=(0,o.useState)(!1),{showToast:b}=(0,s.d)(),w=Number(t?.global?.free_shipping_min??t?.settings?.free_shipping_min??999),y=Number(t?.global?.default_shipping_rate??t?.settings?.default_shipping_rate??99);(0,o.useEffect)(()=>{try{let e=localStorage.getItem("knotelle_cart");e&&d(JSON.parse(e));let t=localStorage.getItem("knotelle_promo");if(t){let e=JSON.parse(t);p(e.code),x(e.discount)}}catch(e){console.error("Failed to load cart from localStorage",e)}finally{g(!0)}},[]),(0,o.useEffect)(()=>{if(v)try{localStorage.setItem("knotelle_cart",JSON.stringify(r))}catch(e){console.error("Failed to save cart to localStorage",e)}},[r,v]);let C=(e,t=!1)=>{d(t=>t.filter(t=>t.id!==e)),t||b("Item Removed","Your cart has been updated.","info")},E=async e=>{let t=e.trim().toUpperCase();if(!t)return!1;let a=r.reduce((e,t)=>e+t.price*t.quantity,0);try{let e=await (0,n.oY)(t,a);if(e&&e.success){p(t);let r=10;return e.offer?.offer_type==="percentage"&&e.offer?.discount_value?r=Number(e.offer.discount_value):e.discount_amount&&a>0&&(r=Math.round(e.discount_amount/a*100)),x(r),localStorage.setItem("knotelle_promo",JSON.stringify({code:t,discount:r})),b("Coupon Applied! \uD83C\uDF89",e.message||`${t} discount applied.`,"success"),!0}if(e&&e.message&&!e.message.includes("Connection error"))return b("Coupon Error",e.message,"error"),!1}catch(e){console.warn("Backend offer validation network fallback",e)}return"KNOTELLE10"===t||"WELCOME10"===t?(p(t),x(10),localStorage.setItem("knotelle_promo",JSON.stringify({code:t,discount:10})),b("Coupon Applied! \uD83C\uDF89","10% handmade love discount applied to your order.","success"),!0):"STITCH20"===t?(p(t),x(20),localStorage.setItem("knotelle_promo",JSON.stringify({code:t,discount:20})),b("Special Discount! ✨","20% discount applied to your order.","success"),!0):(b("Invalid Coupon Code","Please check the code and try again.","error"),!1)},_=r.reduce((e,t)=>e+t.quantity,0),k=r.reduce((e,t)=>e+t.price*t.quantity,0),N=Math.round(k*h/100),S=k>=w||0===k?0:y,j=Math.max(0,k-N+S),A=Math.max(0,w-k);return(0,a.jsx)(i.Provider,{value:{items:r,addItem:(e,t=1,r)=>{var a;let o,s,n,l=(a=e.id,o=r?.color?.name||"default",s=r?.size||"default",n=r?.customText||"",`${a}-${o}-${s}-${n}`);d(a=>{let o=a.findIndex(e=>e.id===l);if(!(o>-1))return[...a,{id:l,productId:e.id,product:e,quantity:t,customization:r,price:e.price}];{let e=[...a];return e[o].quantity+=t,e}}),b("Added to Your Cart \uD83E\uDDFA",`${t}x ${e.name} ready for you.`,"cart")},removeItem:C,updateQuantity:(e,t)=>{t<=0?C(e):d(r=>r.map(r=>r.id===e?{...r,quantity:t}:r))},clearCart:()=>{d([]),p(""),x(0),localStorage.removeItem("knotelle_cart"),localStorage.removeItem("knotelle_promo")},isCartOpen:u,setIsCartOpen:m,totalItemsCount:_,subtotal:k,shipping:S,discount:N,total:j,promoCode:f,applyPromoCode:E,removePromoCode:()=>{p(""),x(0),localStorage.removeItem("knotelle_promo"),b("Coupon Removed","Discount has been removed.","info")},freeShippingThreshold:w,amountToFreeShipping:A},children:e})}function d(){let e=(0,o.useContext)(i);if(!e)throw Error("useCart must be used within a CartProvider");return e}},4734:(e,t,r)=>{r.d(t,{MediaProvider:()=>c,r:()=>d});var a=r(5155),o=r(2115),s=r(7529),n=r(2599);let l="knotelle_cache_media",i=(0,o.createContext)(void 0);function c({children:e,initialMedia:t=null}){let[r,d]=(0,o.useState)(t),[u,m]=(0,o.useState)(!t),[f,p]=(0,o.useState)(Date.now()),h=(0,o.useRef)(!1);(0,o.useEffect)(()=>{try{let e=localStorage.getItem(l);if(e){let t=JSON.parse(e);t&&d(t)}}catch{}},[]);let x=(0,o.useCallback)(async()=>{if(!h.current){h.current=!0;try{let e=await (0,s.Z2)();if(e){d(e),p(Date.now());try{localStorage.setItem(l,JSON.stringify(e))}catch{}}}catch(e){console.warn("Live media sync notice:",e)}finally{h.current=!1,m(!1)}}},[]);return(0,o.useEffect)(()=>{x();let e=(0,n.yF)(()=>{x()}),t=setInterval(()=>{"visible"===document.visibilityState&&x()},6e4);return()=>{e(),clearInterval(t)}},[x]),(0,a.jsx)(i.Provider,{value:{media:r,loading:u,lastUpdated:f,refetchMedia:x},children:e})}function d(){let e=(0,o.useContext)(i);if(!e)throw Error("useWebsiteMedia must be used within a MediaProvider");return e}},6218:(e,t,r)=>{r.d(t,{A:()=>v});var a=r(5155),o=r(2115),s=r(5772),n=r(8500),l=r.n(n),i=r(6272),c=r(4757),d=r(6720),u=r(5182),m=r(4710),f=r(1507),p=r(7529),h=r(6572),x=r(9512);function v({product:e,priority:t=!1}){let{addItem:r,setIsCartOpen:n}=(0,m._)(),{toggleWishlist:g,isInWishlist:b}=(0,f.n)(),[w,y]=(0,o.useState)(!1),C=b(e.id),E=(0,p.Me)(w&&e.images?.[1]?e.images[1]:e.main_image||e.images?.[0],"/images/products/bunny-keychain.jpg"),[_,k]=(0,o.useState)(E);o.useEffect(()=>{k(E)},[E]);let N=t=>{t.preventDefault(),t.stopPropagation(),r(e,1,{color:e.colors[0],size:e.sizes?.[0]}),n(!0)};return(0,a.jsxs)("div",{className:"group relative flex flex-col bg-white rounded-3xl border border-[#E7D1CC]/90 overflow-hidden shadow-boutique hover:shadow-boutique-hover transition-all duration-300 transform hover:-translate-y-1",onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),children:[(0,a.jsxs)("div",{className:"relative aspect-[4/4.8] w-full bg-[#FFF9F6] overflow-hidden",children:[(0,a.jsx)(l(),{href:`/product/${e.slug}`,className:"block w-full h-full relative",children:(0,a.jsx)(s.default,{src:_,alt:e.name,fill:!0,sizes:"(max-width: 640px) 50vw, (max-width: 1024px) 33vw, 25vw",className:"object-cover object-center transition-transform duration-700 ease-out group-hover:scale-105",priority:t,onError:()=>{"/images/products/bunny-keychain.jpg"!==_&&k("/images/products/bunny-keychain.jpg")}})}),(0,a.jsxs)("div",{className:"absolute top-3 left-3 flex flex-col gap-1.5 z-10 pointer-events-none",children:[e.isBestSeller&&(0,a.jsx)(x.E,{variant:"rose",className:"shadow-xs text-[10px] uppercase font-bold tracking-wider",children:"Best Seller"}),e.isNew&&!e.isBestSeller&&(0,a.jsx)(x.E,{variant:"pink",className:"shadow-xs text-[10px] uppercase font-bold tracking-wider",children:"New"}),e.isCustomizable&&(0,a.jsxs)(x.E,{variant:"gold",className:"shadow-xs text-[10px] uppercase font-bold tracking-wider flex items-center gap-1",children:[(0,a.jsx)(i.A,{className:"w-2.5 h-2.5"}),"Customizable"]})]}),(0,a.jsx)("button",{onClick:t=>{t.preventDefault(),t.stopPropagation(),g(e)},"aria-label":C?"Remove from wishlist":"Add to wishlist",className:"absolute top-3 right-3 z-10 w-8 h-8 rounded-full bg-white/90 backdrop-blur-md border border-[#E7D1CC] flex items-center justify-center text-[#786864] hover:text-[#913638] hover:bg-white transition-all shadow-xs active:scale-90",children:(0,a.jsx)(c.A,{className:`w-4 h-4 transition-all ${C?"fill-[#913638] text-[#913638] scale-110":"hover:scale-110"}`})}),(0,a.jsxs)("div",{className:"absolute inset-x-3 bottom-3 hidden sm:flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-all duration-300 transform translate-y-2 group-hover:translate-y-0 z-10",children:[(0,a.jsxs)("button",{onClick:N,className:"flex-1 py-2 px-3 rounded-full bg-[#913638] hover:bg-[#74292B] active:scale-[0.98] text-white text-xs font-semibold tracking-normal flex items-center justify-center gap-1.5 shadow-xs transition-all cursor-pointer",children:[(0,a.jsx)(d.A,{className:"w-3.5 h-3.5"}),(0,a.jsx)("span",{children:"Quick Add"})]}),(0,a.jsx)(l(),{href:`/product/${e.slug}`,className:"w-8 h-8 rounded-full bg-white text-[#2E211E] hover:text-[#913638] hover:bg-[#FCE9E5] border border-[#E7D1CC] flex items-center justify-center shadow-xs transition-colors shrink-0 active:scale-[0.98]","aria-label":`View ${e.name}`,children:(0,a.jsx)(u.A,{className:"w-3.5 h-3.5"})})]})]}),(0,a.jsxs)("div",{className:"p-3.5 sm:p-4 flex flex-col flex-1 bg-white",children:[(0,a.jsx)(l(),{href:`/product/${e.slug}`,className:"font-serif-luxury text-sm sm:text-base font-bold text-[#2E211E] group-hover:text-[#913638] transition-colors line-clamp-1 mb-1",children:e.name}),(0,a.jsxs)("div",{className:"mt-auto pt-1 flex items-center justify-between gap-1 flex-wrap",children:[(0,a.jsxs)("div",{className:"flex items-baseline gap-1.5",children:[(0,a.jsxs)("span",{className:"text-sm sm:text-base font-bold text-[#913638]",children:["₹",e.price.toLocaleString("en-IN")]}),e.comparePrice&&(0,a.jsxs)("span",{className:"text-[10px] sm:text-xs text-[#786864] line-through",children:["₹",e.comparePrice.toLocaleString("en-IN")]})]}),(0,a.jsx)(h.G,{rating:e.rating,size:"sm",showNumber:!0,reviewCount:e.reviewCount})]}),(0,a.jsxs)("button",{onClick:N,className:"mt-3 sm:hidden w-full py-2 px-3 rounded-full bg-white text-[#2E211E] hover:bg-[#FCE9E5] hover:text-[#913638] border border-[#E7D1CC] active:bg-[#913638] active:text-white active:scale-[0.98] text-xs font-semibold flex items-center justify-center gap-1.5 transition-all shadow-xs cursor-pointer",children:[(0,a.jsx)(d.A,{className:"w-3.5 h-3.5 text-[#913638]"}),(0,a.jsx)("span",{children:"Add to Cart"})]})]})]})}},6572:(e,t,r)=>{r.d(t,{G:()=>s});var a=r(5155);r(2115);var o=r(5697);function s({rating:e,maxRating:t=5,size:r="sm",showNumber:n=!1,reviewCount:l,className:i=""}){let c={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"};return(0,a.jsxs)("div",{className:`flex items-center gap-1.5 ${i}`,children:[(0,a.jsx)("div",{className:"flex items-center text-[#C69A5A]",children:Array.from({length:t}).map((t,s)=>{let n=s{r.d(t,{E:()=>n});var a=r(5155);r(2115);var o=r(9722),s=r(622);function n({children:e,variant:t="secondary",className:r}){return(0,a.jsx)("span",{className:(0,s.QP)((0,o.$)("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium tracking-wide",{rose:"bg-[#913638] text-white",pink:"bg-[#FCE9E5] text-[#913638] border border-[#E7D1CC]",gold:"bg-[#FDF6E9] text-[#C69A5A] border border-[#C69A5A]/30",secondary:"bg-[#FCE9E5] text-[#913638] border border-[#E7D1CC]",outline:"border border-[#E7D1CC] text-[#786864] bg-white/80",success:"bg-emerald-50 text-emerald-800 border border-emerald-200"}[t],r)),children:e})}}}]);