1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[36653],{5254:(e,t,r)=>{r.d(t,{A:()=>b});var a=r(95155),i=r(12115),s=r(10518),n=r(15599),o=r(19637),l=r(50172),c=r(73672),d=r(61840),u=r(30285),h=r(62523),m=r(54165),p=r(56671),g=r(21868),w=r(6874),f=r.n(w),x=r(33055);let y="share-nudge-post-add";var v=r(65243);function b(e){let{isOpen:t,onClose:r,wishlistId:w,wishlistSlug:b,wishlistTitle:_,headline:j="Done adding items?",description:S="Share your wishlist with friends and family.",showKeepShopping:k=!0,viewHref:C}=e,{user:N}=(0,g.A)(),[I,P]=(0,i.useState)(""),[E,T]=(0,i.useState)(!1),[F,A]=(0,i.useState)(!1),[D,O]=(0,i.useState)(""),[R,U]=(0,i.useState)(!1),[L,M]=(0,i.useState)(!1),W="".concat(window.location.origin,"/wishlists/").concat(b),q=C||"/wishlists/".concat(b),$=(0,i.useCallback)(async()=>{if(w&&b){T(!0);try{let e=window.location.origin,t="".concat(e,"/wishlists/").concat(b),r=await fetch("/api/attribution/generate-link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({originalUrl:t,campaignType:"social_share",wishlistId:w})});if(!r.ok)throw Error("Failed to generate link");let a=await r.json();P(a.link.short_url)}catch(e){console.error("Error generating shortlink:",e),P(W)}finally{T(!1)}}},[w,b,W]);(0,i.useEffect)(()=>{t&&(P(""),A(!1),O(""),M(!1),$(),(0,x.Fg)("share_nudge_shown",{wishlist_id:w,variant:"control",...(0,x.CP)(y,"control")}))},[t,$,w]);let B=async()=>{let e=I||W;try{await navigator.clipboard.writeText(e),A(!0),setTimeout(()=>A(!1),2e3),(0,v.Az)(w,"copy_link"),(0,x.Fg)("share_nudge_link_copied",{wishlist_id:w,variant:"control",...(0,x.CP)(y,"control")})}catch(e){p.toast.error("Failed to copy link")}},H=async()=>{if(!D.trim()||!N)return;let e=D.split(/[,;\s]+/).map(e=>e.trim()).filter(Boolean),t=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,r=e.filter(e=>!t.test(e));if(r.length>0){p.toast.error("Invalid email".concat(r.length>1?"s":"",": ").concat(r.join(", ")));return}U(!0);try{if(!(await fetch("/api/wishlist/send-invites",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wishlistId:w,wishlistTitle:_,wishlistSlug:b,emails:e,personalMessage:'Check out my wishlist "'.concat(_,'"!')})})).ok)throw Error("Failed to send");p.toast.success("Sent to ".concat(e.length," friend").concat(e.length>1?"s":"","!")),O(""),M(!0),(0,v.Az)(w,"email"),(0,x.Fg)("share_nudge_email_sent",{wishlist_id:w,recipient_count:e.length,variant:"control",...(0,x.CP)(y,"control")})}catch(e){p.toast.error("Failed to send share email")}finally{U(!1)}},J=I||(E?"Generating link...":W);return(0,a.jsx)(m.lG,{open:t,onOpenChange:e=>{e||r()},children:(0,a.jsxs)(m.Cf,{className:"sm:max-w-md",onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:[(0,a.jsxs)(m.c7,{children:[(0,a.jsx)(m.L3,{children:j}),(0,a.jsx)(m.rr,{children:S})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Your share link"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(h.p,{readOnly:!0,value:J,className:"text-sm bg-gray-50 font-mono",onClick:e=>e.target.select()}),(0,a.jsx)(u.$,{variant:"outline",onClick:B,disabled:E,className:"flex-shrink-0",children:F?(0,a.jsx)(s.A,{className:"w-4 h-4 text-green-600"}):(0,a.jsx)(n.A,{className:"w-4 h-4"})})]})]}),N&&(0,a.jsxs)("div",{className:"border-t border-gray-200 pt-4",children:[(0,a.jsxs)("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:[(0,a.jsx)(o.A,{className:"w-4 h-4 inline mr-1.5 -mt-0.5"}),"Send to friends & family"]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(h.p,{type:"text",placeholder:"[email protected], [email protected]",value:D,onChange:e=>{O(e.target.value),M(!1)},className:"text-sm",onKeyDown:e=>{"Enter"===e.key&&H()}}),(0,a.jsx)(u.$,{onClick:H,disabled:R||!D.trim(),className:"flex-shrink-0 bg-brand hover:bg-brand-hover text-white",children:R?(0,a.jsx)(l.A,{className:"w-4 h-4 animate-spin"}):L?(0,a.jsx)(s.A,{className:"w-4 h-4"}):(0,a.jsx)(c.A,{className:"w-4 h-4"})})]}),(0,a.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Separate multiple emails with commas"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 pt-2",children:[(0,a.jsx)(u.$,{onClick:B,disabled:E,className:"w-full bg-brand hover:bg-brand-hover text-white font-semibold",children:F?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.A,{className:"w-4 h-4 mr-2"}),"Link Copied!"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.A,{className:"w-4 h-4 mr-2"}),"Copy Share Link"]})}),k&&(0,a.jsx)(u.$,{variant:"outline",onClick:r,className:"w-full",children:"No, Keep Shopping"}),(0,a.jsxs)(f(),{href:q,className:"text-sm text-brand hover:text-brand-hover text-center flex items-center justify-center gap-1 py-1",children:[(0,a.jsx)(d.A,{className:"w-3.5 h-3.5"}),"View your wishlist"]})]})]})]})})}},9697:(e,t,r)=>{r.d(t,{n:()=>f});var a=r(95155),i=r(12115),s=r(68098),n=r(12543),o=r(30285),l=r(54165),c=r(62523),d=r(56671),u=r(52643),h=r(41927),m=r(14591),p=r(94251),g=r(52178),w=r(1539);function f(e){let{isOpen:t,onClose:r,productTitle:f}=e,[x,y]=(0,i.useState)("auth"),[v,b]=(0,i.useState)(""),[_,j]=(0,i.useState)(""),[S,k]=(0,i.useState)(!1),[C,N]=(0,i.useState)({email:!1,code:!1,google:!1,facebook:!1,apple:!1}),I=(0,i.useRef)(null);(0,i.useEffect)(()=>{k((0,p.lg)())},[]),(0,i.useEffect)(()=>()=>{var e;null===(e=I.current)||void 0===e||e.call(I)},[]);let P=()=>{var e;null===(e=I.current)||void 0===e||e.call(I),y("auth"),b(""),j(""),N({email:!1,code:!1,google:!1,facebook:!1,apple:!1}),r()},E=async e=>{if(e.preventDefault(),!v||!v.includes("@")){d.toast.error("Please enter a valid email address");return}try{N({...C,email:!0});let{ok:e}=await (0,m.q)(v,"wishlist-modal");if(!e){N({...C,email:!1});return}localStorage.setItem("auth_email",v);let t=(0,u.createClient)(),{error:r}=await t.auth.signInWithOtp({email:v,options:{emailRedirectTo:"".concat(window.location.origin,"/auth/callback?email=").concat(encodeURIComponent(v),"&redirect=").concat(encodeURIComponent(window.location.pathname+window.location.search))}});if(r)throw r;d.toast.success("Check your email for a 6-digit code!"),y("verify")}catch(r){console.error("Email signup error:",r);let e=r instanceof Error?r.message:"Failed to send verification code. Please try again.";d.toast.error(e);let t=e.toLowerCase();t.includes("15 seconds")||t.includes("security purposes")||(0,w.s)({source:"auth.wishlist_modal.email_signup",error:r,context:{emailDomain:v.split("@")[1]||null,productTitle:null!=f?f:null}})}finally{N({...C,email:!1})}},T=async e=>{if(e.preventDefault(),!_||6!==_.length){d.toast.error("Please enter the 6-digit code");return}try{N({...C,code:!0});let e=(0,u.createClient)(),{error:t}=await e.auth.verifyOtp({email:v,token:_,type:"email"});if(t)throw t;try{let e=await fetch("/api/auth/post-signup",{method:"POST",headers:{"Content-Type":"application/json"}});e.ok&&(await e.json()).isNewUser&&await (0,h.y)("sign_up",v?{email:v}:void 0)}catch(e){console.error("Post-signup API call failed:",e)}d.toast.success("Successfully signed in!"),r(),window.location.reload()}catch(r){console.error("Code verification error:",r);let e=r instanceof Error?r.message:"Invalid code. Please try again.";d.toast.error(e);let t=e.toLowerCase();t.includes("invalid")||t.includes("expired")||t.includes("token")||(0,w.s)({source:"auth.wishlist_modal.code_verify",error:r})}finally{N({...C,code:!1})}},F=async e=>{try{var t;null===(t=I.current)||void 0===t||t.call(I),N(t=>({...t,[e]:!0}));let r=(0,u.createClient)(),{error:a}=await r.auth.signInWithOAuth({provider:e,options:{redirectTo:"".concat(window.location.origin,"/auth/callback?redirect=").concat(encodeURIComponent(window.location.pathname+window.location.search))}});if(a)throw a;I.current=(0,g.K)(e,()=>{N(t=>({...t,[e]:!1}))})}catch(t){console.error("".concat(e," login error:"),t),d.toast.error("Failed to sign in with ".concat(e,". Please try again.")),N(t=>({...t,[e]:!1}))}};return(0,a.jsx)(l.lG,{open:t,onOpenChange:e=>{e||P()},children:(0,a.jsx)(l.Cf,{className:"sm:max-w-md",onPointerDown:e=>e.stopPropagation(),children:"auth"===x?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(l.c7,{children:[(0,a.jsxs)(l.L3,{className:"flex items-center gap-2",children:[(0,a.jsx)(s.A,{className:"w-5 h-5 text-rose-500"}
1),"Save to Wishlist"]}),(0,a.jsxs)("p",{className:"text-sm text-gray-600",children:["Sign in to add ",f?'"'.concat(f.length>40?f.substring(0,40)+"...":f,'"'):"this product"," to your wishlist. We'll track the price too!"]})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)(o.$,{type:"button",onClick:e=>{e.stopPropagation(),F("google")},disabled:C.google,variant:"outline",className:"w-full",children:[C.google?(0,a.jsx)("div",{className:"w-4 h-4 border-2 border-gray-400 border-t-transparent rounded-full animate-spin"}):(0,a.jsxs)("svg",{className:"w-4 h-4 mr-2",viewBox:"0 0 24 24",children:[(0,a.jsx)("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),(0,a.jsx)("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),(0,a.jsx)("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),(0,a.jsx)("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),"Continue with Google"]}),(0,a.jsxs)(o.$,{type:"button",onClick:e=>{e.stopPropagation(),F("facebook")},disabled:C.facebook,className:"w-full bg-[#1877F2] hover:bg-[#166FE5] text-white",children:[C.facebook?(0,a.jsx)("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,a.jsx)("svg",{className:"w-4 h-4 mr-2",fill:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),"Continue with Facebook"]}),S&&(0,a.jsxs)(o.$,{onClick:()=>F("apple"),disabled:C.apple,className:"w-full bg-black hover:bg-gray-900 text-white",children:[C.apple?(0,a.jsx)("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,a.jsx)("svg",{className:"w-4 h-4 mr-2",fill:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M17.05 20.28c-.98.95-2.05.88-3.08.4-1.09-.5-2.08-.48-3.24 0-1.44.62-2.2.44-3.06-.4C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z"})}),"Continue with Apple"]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:"absolute inset-0 flex items-center",children:(0,a.jsx)("div",{className:"w-full border-t border-gray-300"})}),(0,a.jsx)("div",{className:"relative flex justify-center text-sm",children:(0,a.jsx)("span",{className:"px-2 bg-white text-gray-500",children:"or"})})]}),(0,a.jsxs)("form",{onSubmit:E,className:"space-y-3",children:[(0,a.jsx)(c.p,{type:"email",value:v,onChange:e=>b(e.target.value),placeholder:"Enter your email address",disabled:C.email}),(0,a.jsx)(o.$,{type:"submit",disabled:C.email||!v,className:"w-full",children:C.email?(0,a.jsx)("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):"Continue with Email"})]})]}),(0,a.jsx)(l.Es,{children:(0,a.jsx)("p",{className:"text-xs text-gray-500 text-center w-full",children:"By continuing, you agree to our Terms of Service and Privacy Policy"})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(l.c7,{children:[(0,a.jsxs)(l.L3,{className:"flex items-center gap-2",children:[(0,a.jsx)("button",{onClick:()=>y("auth"),className:"p-1 rounded-md hover:bg-gray-100 mr-1",children:(0,a.jsx)(n.A,{className:"w-4 h-4"})}),"Enter Verification Code"]}),(0,a.jsxs)("p",{className:"text-sm text-gray-600",children:["We sent a 6-digit code to ",(0,a.jsx)("strong",{children:v})]})]}),(0,a.jsxs)("form",{onSubmit:T,className:"space-y-4",children:[(0,a.jsx)(c.p,{type:"text",value:_,onCh
1ange:e=>j(e.target.value.replace(/\D/g,"").slice(0,6)),placeholder:"Enter 6-digit code",disabled:C.code,className:"text-center text-lg tracking-widest",maxLength:6}),(0,a.jsx)(o.$,{type:"submit",disabled:C.code||6!==_.length,className:"w-full",children:C.code?(0,a.jsx)("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):"Verify Code"})]}),(0,a.jsx)(l.Es,{children:(0,a.jsx)("p",{className:"text-xs text-gray-500 text-center w-full",children:"Didn't receive the code? Check your spam folder or try again."})})]})})})}},20782:(e,t,r)=>{r.d(t,{A:()=>D});var a=r(95155),i=r(12115),s=r(68098),n=r(30285),o=r(21868),l=r(52643),c=r(44677),d=r(56671),u=r(59434),h=r(6874),m=r.n(h),p=r(44838);function g(e){let{productId:t,integrated:r=!1,className:n="",slug:o}=e,[c,d]=(0,i.useState)(null),[h,g]=(0,i.useState)([]),[w,f]=(0,i.useState)(!0),[x,y]=(0,i.useState)(!1),v=e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e);return((0,i.useEffect)(()=>{if(!o&&!v(t)){f(!1),d(0);return}(async()=>{try{f(!0);let e=(0,l.createClient)(),{data:r}=await e.from("wishlists").select("id").in("visibility",["public","unlisted"]);if(!r||0===r.length){d(0);return}let a=r.map(e=>e.id),{data:i,error:s}=await e.from("wishlist_products").select("wishlist_id").eq("product_id",t).in("wishlist_id",a);if(s){console.error("Error counting wishlists:",s),d(0);return}let n=i?[...new Set(i.map(e=>e.wishlist_id))]:[];if(d(n.length),n.length>0){let{data:t,error:r}=await e.from("wishlists").select("id, title, user_id, slug").in("id",n);if(r)console.error("Error fetching wishlist details:",r);else{let e=(null==t?void 0:t.map(e=>({id:e.id,title:e.title,slug:e.slug})))||[];g(e)}}}catch(e){console.error("Error in wishlist count component:",e),d(0)}finally{f(!1)}})()},[t,o]),w||!c||0===c)?null:r?(0,a.jsxs)(p.rI,{open:x,onOpenChange:y,children:[(0,a.jsx)(p.ty,{asChild:!0,children:(0,a.jsx)("button",{className:(0,u.cn)("text-xs text-gray-500 hover:text-gray-700 hover:underline focus:outline-none",n),onClick:e=>e.stopPropagation(),children:1===c?"In 1 wishlist":"In ".concat(c," wishlists")})}),(0,a.jsxs)(p.SQ,{align:"end",className:"w-64",children:[(0,a.jsx)("div",{className:"px-2 py-1.5 text-xs text-gray-500 font-medium",children:"Wishlists containing this product:"}),(0,a.jsx)(p.mB,{}),h.slice(0,5).map(e=>(0,a.jsx)(p._2,{asChild:!0,children:(0,a.jsxs)(m(),{href:"/wishlists/".concat(e.slug),className:"cursor-pointer text-sm",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)(s.A,{className:"mr-2 h-3.5 w-3.5 text-red-500"}),(0,a.jsx)("span",{className:"font-medium",children:e.title})]})},e.id)),c>5&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p.mB,{}),(0,a.jsx)(p._2,{asChild:!0,children:(0,a.jsxs)(m(),{href:"/wishlists/browse?productId=".concat(t),className:"cursor-pointer text-sm text-brand",onClick:e=>e.stopPropagation(),children:["See all ",c," wishlists"]})})]})]})]}):(0,a.jsxs)(p.rI,{children:[(0,a.jsx)(p.ty,{asChild:!0,children:(0,a.jsxs)("button",{className:(0,u.cn)("text-gray-500 hover:text-gray-700 flex items-center focus:outline-none",n),onClick:e=>e.stopPropagation(),children:[(0,a.jsx)(s.A,{className:"h-3.5 w-3.5 mr-1.5 text-red-500"}),(0,a.jsx)("span",{children:1===c?"In 1 wishlist":"In ".concat(c," wishlists")})]})}),(0,a.jsxs)(p.SQ,{align:"end",className:"w-64",children:[(0,a.jsx)("div",{className:"px-2 py-1.5 text-xs text-gray-500 font-medium",children:"Wishlists containing this product:"}),(0,a.jsx)(p.mB,{}),h.slice(0,5).map(e=>(0,a.jsx)(p._2,{asChild:!0,children:(0,a.jsxs)(m(),{href:"/wishlists/".concat(e.slug),className:"cursor-pointer text-sm",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)(s.A,{className:"mr-2 h-3.5 w-3.5 text-red-500"}),(0,a.jsx)("span",{className:"font-medium",children:e.title})]})},e.id)),c>5&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p.mB,{}),(0,a.jsx)(p._2,{asChild:!0,children:(0,a.jsxs)(m(),{href:"/wishlists/browse?productId=".concat(t),className:"cursor-pointer text-sm text-brand",onClick:e=>e.stopPropagation(),children:["See all ",c," wishlists"]})})]})]})]})}var w=r(35695),f=r(54165),x=r(84050),y=r(37705),v=r(94088),b=r(80853);class _{trackSignup(e){if(window.twq)try{window.twq("event",this.eventId,{email_address:e.email||null})}catch(e){console.error("â Twitter conversion tracking error:",e)}}constructor(){this.eventId="tw-q07x9-q0818"}}class j{trackSignup(e){try{let t=(0,b.l1)(),r=e.fbc||(0,v.S_)()||void 0,a=e.fbp||(0,v.mS)()||void 0;(0,v.Ym)({content_name:"User Signup",value:0,currency:"USD",status:!0,event_id:t}),this.trackSignupServerSide({...e,fbc:r,fbp:a},t)}catch(t){console.error("â Meta pixel conversion tracking error:",t),this.trackSignupServerSide(e)}}async trackSignupServerSide(e,t){try{let r=(0,b.bJ)({email:e.email,userId:e.userId,ip:e.ip,userAgent:e.userAgent,fbc:e.fbc,fbp:e.fbp}),a=await fetch("/api/conversions/meta",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventName:"CompleteRegistration",eventId:t||(0,b.l1)(),eventSourceUrl:e.eventSourceUrl||window.location.href,userData:r,customData:{contentName:"User Signup",value:0,currency:"USD",status:"completed"}})});a.ok||console.error("â Meta server-side conversion tracking failed:",a.status)}catch(e){console.error("â Meta server-side conversion tracking error:",e)}}}class S{trackSignup(e){if(window.pintrk)try{window.pintrk("track","signup",{email_address:e.email||void 0})}catch(e){console.error("â Pinterest conversion tracking error:",e)}}}
1class k{trackSignup(e){this.trackers.forEach(t=>{try{t.trackSignup(e)}catch(e){console.error("â Conversion tracker error:",e)}}),this.trackInternalSignup(e)}trackAddToWishlist(e){this.trackers.forEach(t=>{try{t.trackAddToWishlist&&t.trackAddToWishlist(e)}catch(e){console.error("â Add to wishlist tracker error:",e)}}),this.trackInternalAddToWishlist(e)}async trackInternalSignup(e){try{await fetch("/api/analytics/track",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:"user_signup_conversion",properties:{source:e.source||"direct",timestamp:e.timestamp||Date.now(),user_id:e.userId,has_email:!!e.email}})})}catch(e){console.error("â Internal conversion tracking error:",e)}}async trackInternalAddToWishlist(e){try{await fetch("/api/analytics/track",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:"add_to_wishlist_conversion",properties:{product_id:e.productId,product_name:e.productName,value:e.value||0,currency:e.currency||"USD",category:e.category,user_id:e.userId,timestamp:Date.now()}})})}catch(e){console.error("â Internal add to wishlist conversion tracking error:",e)}}constructor(){this.trackers=[],this.trackers=[new _,new j,new S]}}let C=new k,N=e=>{C.trackAddToWishlist(e)};var I=r(9697),P=r(41927),E=r(5254),T=r(37182),F=r(82158);let A=(e,t,r)=>{let[a,s]=(0,i.useState)(0),[n,o]=(0,i.useState)(!0),c=e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e);return(0,i.useEffect)(()=>{if(!t&&!c(e)||r){o(!1),s(0);return}let a="wishlist_count_".concat(e),i=localStorage.getItem(a),n=localStorage.getItem("".concat(a,"_time"));if(i&&n&&Date.now()-parseInt(n)<216e5){s(parseInt(i)),o(!1);return}let d=setTimeout(async()=>{var t,r,i,n;try{o(!0);let i=(0,l.createClient)(),{count:n,error:c}=await i.from("wishlist_products").select("wishlist_id",{count:"exact",head:!0}).eq("product_id",e);if(c){"PGRST301"===c.code||(null===(t=c.message)||void 0===t?void 0:t.includes("JWT"))||(null===(r=c.message)||void 0===r?void 0:r.includes("Failed to fetch"))||console.error("Error counting wishlists:",c),s(0);return}let d=n||0;s(d),localStorage.setItem(a,d.toString()),localStorage.setItem("".concat(a,"_time"),Date.now().toString())}catch(e){(null==e?void 0:null===(i=e.message)||void 0===i?void 0:i.includes("Failed to fetch"))||(null==e?void 0:null===(n=e.message)||void 0===n?void 0:n.includes("NetworkError"))||console.error("Error in wishlist count hook:",e),s(0)}finally{o(!1)}},200*Math.random()+100);return()=>clearTimeout(d)},[e,t]),{count:a,isLoading:n}},D=(0,i.forwardRef)(function(e,t){let{productId:r,compact:h=!1,compactText:m=!1,size:p="sm",variant:b="outline",showCount:_=!0,hideCount:j=!1,className:S,title:k,description:C,price:D,original_price:O,currency_code:R,image_urls:U,rating:L,category:M,affiliate_url:W,direct_url:q,integration_type:$,external_id:B,brand:H,merchant:J,on_sale:z,sale_discount:K,review_count:Q,slug:V,merchant_id:G,metadata:X,children:Y,onAdded:Z}=e,{user:ee,isLoading:et,refreshSession:er}=(0,o.A)(),ea=(0,w.useRouter)(),{triggerFirstWishlistReminder:ei}=(0,y.X)(),[es,en]=(0,i.useState)(!1),[eo,el]=(0,i.useState)(!1),[ec,ed]=(0,i.useState)(!1),[eu,eh]=(0,i.useState)(!1),[em,ep]=(0,i.useState)([]),[eg,ew]=(0,i.useState)(""),[ef,ex]=(0,i.useState)(!1),[ey,ev]=(0,i.useState)(""),[eb,e_]=(0,i.useState)(""),[ej,eS]=(0,i.useState)(!1),[ek,eC]=(0,i.useState)(1),[eN,eI]=(0,i.useState)(null),{count:eP}=A(r,V,j);(0,i.useEffect)(()=>{eS(!1)},[ee,r,V]),(0,i.useEffect)(()=>{es&&ee&&(async()=>{ed(!0);try{let e=(0,l.createClient)(),{data:t,error:r}=await e.from("wishlists").select("id, title, slug").eq("user_id",ee.id).order("created_at",{ascending:!1});if(r)throw r;ep(t||[]),t&&t.length>0?(ew(t[0].id),ex(!1)):(ex(!0),ew(""))}catch(e){console.error("Error fetching wishlists:",e),d.toast.error("Failed to load your wishlists")}finally{ed(!1)}})()},[es,ee]),(0,i.useImperativeHandle)(t,()=>({openModal:()=>eE()}));let eE=async()=>{if(!ee){if(await (0,c.$)()){er(),en(!0);return}el(!0);return}en(!0)},eT=()=>{en(!1),ex(!1),ev(""),ew(""),eC(1)},eF=async()=>
1{if(!ee){if(!await (0,c.$)()){ea.push("/auth/login");return}er()}try{ed(!0);let e=(0,l.createClient)(),{data:{user:t},error:a}=await e.auth.getUser();if(a||!t){console.error("Authentication error:",a),ea.push("/auth/login");return}let i=eg,s=r;if($&&"internal"!==$&&B){eh(!0);try{let e=J&&J.trim()||(null==X?void 0:X.merchant_name)||(0,F.MJ)({affiliate_url:W,direct_url:q,metadata:X,integration_type:$,merchant_id:G,brand:H}),t=await fetch("/api/products/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({external_id:B,integration_type:$,title:k,description:C,price:D,original_price:O,currency_code:R||"USD",image_urls:U,affiliate_url:W,direct_url:q,rating:L,review_count:Q||0,brand:H,merchant:e,merchant_name:e,metadata:{...X,category:M,source_integration:$,merchant_name:e||(null==X?void 0:X.merchant_name)},on_sale:z,sale_discount:K,merchant_id:G})});if(!t.ok){let e=await t.json();throw Error(e.error||"Failed to import product")}s=(await t.json()).id,d.toast.success("Product imported successfully")}catch(e){throw console.error("â Failed to import product:",e),d.toast.error("Failed to import product: ".concat(e.message)),e}finally{eh(!1)}}if(ef&&ey.trim()){let e={title:ey.trim(),is_public:!1};eb.trim()&&(e.slug=eb.trim());let t=await fetch("/api/wishlists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.text();throw Error(e||"Failed to create wishlist")}let r=await t.json();i=r.id,ep(e=>[{id:r.id,title:ey.trim(),slug:r.slug},...e]),ew(r.id),ex(!1),ev(""),e_("")}if(!i){d.toast.error("Please select or create a wishlist");return}let{data:n,error:o}=await e.from("wishlist_products").insert({wishlist_id:i,product_id:s,position:0,requested_quantity:ek}).select("id").single();if(o)throw o;(null==n?void 0:n.id)&&(null==ee?void 0:ee.id)&&fetch("/api/internal/queue-watch-creation",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wishlist_product_id:n.id,product_id:s,user_id:ee.id,metadata:{source:"frontend_add_to_wishlist"}})}).catch(e=>{console.error("Failed to trigger watch creation queue:",e)});try{let e="string"==typeof D?parseFloat(D):D;(0,v.Fu)({content_category:(null==X?void 0:X.category)||M||void 0,content_ids:B?[function(e){if(e)return e.replace(/['"]/g,"").trim()}(B)].filter(Boolean):void 0,content_name:k||"Unknown Product",value:e||0,currency:R||"USD"},null==ee?void 0:ee.id)}catch(e){console.error("Error tracking AddToWishlist event:",e)}try{let e="string"==typeof D?parseFloat(D):D;N({productId:r,productName:k||"Unknown Product",value:e||0,currency:R||"USD",category:(null==X?void 0:X.category)||M||void 0,userId:null==ee?void 0:ee.id})}catch(e){console.error("Error tracking add-to-wishlist conversion:",e)}try{let e="string"==typeof D?parseFloat(D):D;(0,P.y)("add_to_wishlist",{value:e||0,currency:R||"USD"})}catch(e){console.error("Error tracking ad conversion:",e)}eS(!0),null==Z||Z(),window.dispatchEvent(new CustomEvent("lmk:product-added")),eT();let c=em.find(e=>e.id===i);c&&eI(c);try{await ei()}catch(e){console.error("Error checking for first wishlist reminder:",e)}}catch(e){console.error("Error adding to wishlist:",e),d.toast.error(e.message||"Failed to add to wishlist")}finally{ed(!1),eh(!1)}},eA=()=>eN?(0,a.jsx)(E.A,{isOpen:!!eN,onClose:()=>eI(null),wishlistId:eN.id,wishlistSlug:eN.slug,wishlistTitle:eN.title}):null,eD=()=>(0,a.jsx)(f.lG,{open:es,onOpenChange:eT,children:(0,a.jsxs)(f.Cf,{onClick:e=>e.stopPropagation(),onPointerDownOutside:e=>{var t,r,a,i;let s=null!==(i=null===(r=e.detail)||void 0===r?void 0:null===(t=r.originalEvent)||void 0===t?void 0:t.target)&&void 0!==i?i:e.target;(null==s?void 0:null===(a=s.closest)||void 0===a?void 0:a.call(s,"[data-lmk-searchable-select-dropdown]"))&&e.preventDefault()},children:[(0,a.jsx)(f.c7,{children:(0,a.jsx)(f.L3,{children:"Wishlist This"})}),(0,a.jsxs)("div",{className:"mb-4",children:[em.length>0&&(0,a.jsx)(x.A,{options:[...em.map(e=>({value:e.id,label:e.title})),{value:"__create_new__",label:"Create New..."}],value:ef?"__create_new__":eg,onChange:e=>{"__create_new__"===e?(ex(!0),ew("")):(ew(e),ex(!1)),ev("")},placeholder:"Select or search wishlist...",label:"Select a wishlist",className:"mb-2"}),(0===em.length||ef)&&(0,a.jsx)("input",{type:"text",className:"w-full border border-gray-300 rounded-md px-3 py-2 mt-2",placeholder:em.length>0?"Enter new wishlist name...":"Create your first wishlist...",value:ey,onChange:e=>{ev(e.target.value),ex(!!e.target.value||0===em.length),em.length>0&&ew("")},onClick:e=>e.stopPropagation(),maxLength:60}),(0===em.length||ef)&&ey.trim()&&(0,a.jsx)("input",{type:"text",className:"w-full border border-gray-300 rounded-md px-3 py-2 mt-2 text-sm",placeholder:"Custom link (optional), e.g. kitchen-essentials",value:eb,onChange:e=>e_((0,T.n)(e.target.value)),onClick:e=>e.stopPropagation()}),(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsx)("label",{htmlFor:"quantity",className:"block text-sm font-medium text-gray-700 mb-2",children:"Quantity"}),(0,a.jsx)("input",{id:"quantity",type:"number",min:"1",max:"100",value:ek,onChange:e=>eC(Math.max(1,Math.min(100,parseInt(e.target.value)||1))),className:"w-full border border-gray-300 rounded-md px-3 py-2 text-sm",placeholder:"1",onClick:e=>e.stopPropagation()}),(0,a.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"How many you want"})]})]}),(0,a.jsxs)(f.Es,{children:[(0,a.jsx)(n.$,{variant:"outline",onClick:e=>{e.preventDefault(),e.stopPropagation(),eT()},disabled:ec,children:"Cancel"}),(0,a.jsx)(n.$,{onClick:e=>{e.preventDefault(),e.stopPropagation(),eF()},disabled:ec||eu||!eg&&!ey.trim(),children:eu?"Importing...":ec?"Adding...":"Wishlist This"})]})]})}),eO=["default","outline","ghost","link","destructive"].includes(b)?b:void 0,eR=(0,a.jsx)(n.$,{type:"button",onClick:eE,disabled:ec||eu,className:S,variant:eO,children:Y||(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.A,{className:"mr-2 h-4 w-4"}),ej?"In wishlist":"Wishlist This"]})});if(h)return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),eE()},onPointerDown:e=>e.stopPropagation(),className:"relative flex items-center justify-center focus:outline-none min-h-[44px] min-w-[44px] touch-manipulation group","aria-label":ej?"Remove from wishlist":"Add to wishlist",children:[(0,a.jsx)(s.A,{className:"absolute h-6 w-6 text-white fill-white"}),(0,a.jsx)(s.A,{className:(0,u.cn)("relative h-5 w-5 transition-all duration-200 drop-shadow-sm",ej?"fill-red-500 text-red-500":"text-red-500 hover:fill-red-500 group-hover:scale-110")})]}),ee&&eD(),(0,a.jsx)(I.n,{isOpen:eo,onClose:()=>el(!1),productTitle:k}),eA()]});if(m){let e=_&&eP>0;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("div",{className:"flex items-center text-right",children:(0,a.jsx)("button",{type:"button",onClick:eE,className:(0,u.cn)("cursor-pointer whitespace-nowrap font-medium flex items-center text-right focus:outline-none touch-manipulation","bg-white border border-gray-200 px-3 py-1 text-xs shadow-sm min-h-[44px]","hover:border-gray-300 hover:shadow-md transition-all",e?"rounded-t-md":"rounded-md",ej?"text-red-500 border-red-200 bg-red-50":"text-brand"),children:Y||(ej?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.A,{className:"h-3 w-3 fill-red-500 text-red-500 mr-1"}),(0,a.jsx)("span",{children:"Wishlisted!"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.A,{className:"h-3 w-3 mr-1"}),(0,a.jsx)("span",{children:"Wishlist"})]}))})}),e&&!j&&(0,a.jsx)("div",{className:"bg-orange-50 border border-t-0 border-gray-200 rounded-b-md px-3 py-0.5",children:(0,a.jsx)(g,{productId:r,integrated:!0,className:"text-xs text-gray-600 text-right",slug:V})})]}),ee&&eD(),(0,a.jsx)(I.n,{isOpen:eo,onClose:()=>el(!1),productTitle:k}),eA()]})}return(0,a.jsxs)(a.Fragment,{children:[eR,ee&&eD(),(0,a.jsx)(I.n,{isOpen:eo,onClose:()=>el(!1),productTitle:k}),eA()]})})},36848:(e,t,r)=>{function a(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"USD",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"en-US",a=arguments.length>3?arguments[3]:void 0;if(0===e||isNaN(e))return(null==a?void 0:a.allowFree)?"Free":"Click For Price";try{return new Intl.NumberFormat(r,{style:"currency",currency:t.toUpperCase(),minimumFractionDigits:2,maximumFractionDigits:2}).format(e)}catch(t){return"$".concat(e.toFixed(2))}}function i(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";return 1e3>Math.abs(e)?new Intl.NumberFormat(t).format(e):new Intl.NumberFormat(t,{notation:"compact",maximumFractionDigits:1}).format(e)}function s(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"USD",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"en-US";return 1e3>Math.abs(e)?new Intl.NumberFormat(r,{style:"currency",currency:t.toUpperCase(),minimumFractionDigits:2,maximumFractionDigits:2}).format(e||0):new Intl.NumberFormat(r,{style:"currency",currency:t.toUpperCase(),notation:"compact",maximumFractionDigits:1}).format(e)}r.d(t,{$g:()=>a,ML:()=>s,wk:()=>i})},37182:(e,t,r)=>{r.d(t,{n:()=>a});function a(e){return e.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+/,"")}},44677:(e,t,r)=>{r.d(t,{$:()=>i});var a=r(52643);async function i(){let e=(0,a.createClient)(),{data:{user:t}}=await e.auth.getUser();if(t)return!0;
1if(!("undefined"!=typeof document&&document.cookie.split(";").some(e=>e.trim().startsWith("".concat("lmk_partner_pending","=")))))return!1;let r=await fetch("/api/auth/partner/escalate",{method:"POST",credentials:"include"});if(!r.ok)return!1;let i=await r.json();if(i.access_token&&i.refresh_token){let{error:t}=await e.auth.setSession({access_token:i.access_token,refresh_token:i.refresh_token});return!t}let{data:s}=await e.auth.getSession();return!!s.session}},65243:(e,t,r)=>{r.d(t,{Az:()=>c,BM:()=>d,bE:()=>l,gP:()=>o,wL:()=>n});var a=r(30440);let i={FIND_SEARCH_STARTED:"wl_find_search_started",FIND_RESULTS_SHOWN:"wl_find_results_shown",FIND_RESULT_CLICKED:"wl_find_result_clicked",SHARE_CLICKED:"wl_share_clicked",TOP20_PRODUCT_CLICKED:"wl_top20_product_clicked"};function s(e){let t=e.trim();return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?"email":t.includes("-")&&!t.includes(" ")?"slug":"name"}function n(e){u({event:i.FIND_SEARCH_STARTED,properties:{q_type:s(e),query_length:e.trim().length}})}function o(e,t){u({event:i.FIND_RESULTS_SHOWN,properties:{q_type:s(e),results_count:t,query_length:e.trim().length}})}function l(e,t){u({event:i.FIND_RESULT_CLICKED,properties:{wishlist_id:e,position:t}})}function c(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"copy";u({event:i.SHARE_CLICKED,properties:{wishlist_id:e,share_method:t}}),(0,a.c)(a.l.WISHLIST_SHARED,{wishlist_id:e,share_method:t})}function d(e,t){u({event:i.TOP20_PRODUCT_CLICKED,properties:{product_id:e,leaderboard_position:t}})}async function u(e){try{await fetch("/api/analytics/track",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,timestamp:e.timestamp||new Date().toISOString()})})}catch(e){console.error("Failed to send analytics event:",e)}}},82549:(e,t,r)=>{r.d(t,{R:()=>y});var a=r(95155),i=r(7390),s=r(86318),n=r(93498),o=r(44965),l=r(9917),c=r(70389),d=r(12115),u=r(35695),h=r(6209);async function m(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{await fetch("/api/analytics/track",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:e,properties:{...t,source:"client_attribution",timestamp:Date.now(),page:window.location.pathname,session_id:localStorage.getItem("_attr_session")}})})}catch(e){}}function p(e){if("undefined"==typeof document)return null;let t="; ".concat(document.cookie).split("; ".concat(e,"="));if(2===t.length){var r;return(null===(r=t.pop())||void 0===r?void 0:r.split(";").shift())||null}return null}var g=r(21868),w=r(56671),f=r(16862),x=r(41927);function y(e){let{title:t,description:r,imageUrl:y,url:v,wishlistId:b,className:_="",showQRCode:j=!0}=e,[S,k]=(0,d.useState)(!1),[C,N]=(0,d.useState)(!1),[I,P]=(0,d.useState)(new Set),{user:E}=(0,g.A)(),{shareWithAttribution:T}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=(0,u.useSearchParams)(),[r,a]=(0,d.useState)({source:"direct"}),[i]=(0,d.useState)(()=>localStorage.getItem("_attr_session")||"client_".concat(Date.now(),"_").concat(Math.random().toString(36).substr(2,9)));(0,d.useEffect)(()=>{(async()=>{try{let e=i;"ssr-placeholder"===i&&(e=localStorage.getItem("_attr_session")||"client_".concat(Date.now(),"_").concat(Math.random().toString(36).substr(2,9)),localStorage.setItem("_attr_session",e));let r=(0,h.j)(new URLSearchParams(t.toString()));if(r){a({source:"paid",paidSource:r}),localStorage.setItem("_attr_session",e),document.cookie="_attr_session=".concat(e,"; path=/; max-age=").concat(2592e3,"; samesite=lax");try{await fetch("/api/attribution/sync",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:e,paid_source:r,gclid:t.get("gclid")||void 0,gads:t.get("gads")||void 0,utm_medium:t.get("utm_medium"),utm_campaign:t.get("utm_campaign"),utm_term:t.get("utm_term"),utm_content:t.get("utm_content"),fbadid:t.get("fbadid")})})}catch(e){console.error("Failed to sync attribution (non-critical):",e)}await m("paid_source_detected",{paid_source:r,detected_on:window.location.pathname,session_id:e});return}let s=localStorage.getItem("_ext-source"),n=localStorage.getItem("_ext-source-expiry");if(s&&n&&Date.now()<parseInt(n)){a({source:"paid",paidSource:s});return}let o=p("_attr_creator"),l=p("_attr_wishlist"),c=p("_attr_link");if(o){a({source:"creator",creatorId:o,wishlistId:l,linkCode:c});return}a({source:"direct"})}catch(e){console.error("Error updating attribution:",e),a({source:"direct"})}})()},[t,i]),(0,d.useEffect)(()=>{e.trackPageViews&&m("page_view",{page:window.location.pathname,attribution_source:r.source,creator_id:r.creatorId,paid_source:r.paidSource,wishlist_id:r.wishlistId})},[r,e.trackPageViews]);let s=(0,d.useCallback)(async function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"social";try{var a;let i,s=await fetch("/api/attribution/generate-link",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({originalUrl:e,wishlistId:t,campaignType:r,metadata:{generated_from:"client_share",page:window.location.pathname,user_agent:navigator.userAgent}})});if(!s.ok){let a=await s.text();return console.error("Failed to generate share link, using original URL",{status:s.status,statusText:s.statusText,error:a,originalUrl:e,wishlistId:t,campaignType:r}),e}try{i=await s.json()}catch(t){return console.error("Failed to parse JSON response from share link API:",t),e}let n=null===(a=i.link)||void 0===a?void 0:a.short_url;if(n)return await m("share_link_generated",{original_url:e,short_url:n,campaign_type:r,wishlist_id:t}),n;return console.error("Share link API returned success but no short_url:",i),e}catch(t){return console.error("Error generating share link:",t),e}},[]),n=(0,d.useCallback)(async function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};await m("content_shared",{platform:e,url:t,attribution_source:r.source,creator_id:r.creatorId,...a})},[r]),o=(0,d.useCallback)(async function(e,t,a,i){let s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};await m("conversion",{conversion_type:e,conversion_value:t,commission_value:a,product_id:i,attribution_source:r.source,creator_id:r.creatorId,paid_source:r.paidSource,wishlist_id:r.wishlistId,...s})},[r]),l=(0,d.useCallback)(async function(e,t,r){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"social";try{let i=await s(e,r,a);return await n(t,i,{original_url:e,wishlist_id:r,campaign_type:a}),i}catch(t){return console.error("Error in shareWithAttribution:",t),e}},[s,n]);return{attribution:r,sessionId:i,generateShareLink:s,trackShare:n,trackConversion:o,shareWithAttribution:l}}(),F=(0,d.useRef)(null),A=(e,t)=>
1{P(r=>{let a=new Set(r);return t?a.add(e):a.delete(e),a})},D=r?r.replace(/<[^>]*>/g,"").trim():"",O=async e=>{try{let r=new URL(e);r.searchParams.append("_ext-source","qrcode");let a=r.toString(),i=document.createElement("canvas"),s=i.getContext("2d");if(!s)throw Error("Could not get canvas context");i.width=400,i.height=480,s.fillStyle="#ffffff",s.fillRect(0,0,i.width,i.height);let n=await f.toDataURL(a,{errorCorrectionLevel:"M",type:"image/png",margin:1,color:{dark:"#000000",light:"#ffffff"},width:300}),o=new Image;await new Promise((e,t)=>{o.onload=e,o.onerror=t,o.src=n});let l=(i.width-300)/2;s.drawImage(o,l,40,300,300);try{let e=new Image;e.crossOrigin="anonymous",await new Promise((t,r)=>{e.onload=t,e.onerror=r,e.src="/images/logos/lmk.today.icon.png"});let t=i.width/2;s.fillStyle="#ffffff",s.beginPath(),s.arc(t,190,25,0,2*Math.PI),s.fill(),s.drawImage(e,t-20,170,40,40)}catch(e){}s.fillStyle="#1f2937",s.font="bold 18px Inter, -apple-system, BlinkMacSystemFont, sans-serif",s.textAlign="center";let c=t,d=i.width-40,u=s.measureText(c).width;if(u>d){for(;u>d-20&&c.length>3;)c=c.slice(0,-1),u=s.measureText(c+"...").width;c+="..."}return s.fillText(c,i.width/2,370),s.font="14px Inter, -apple-system, BlinkMacSystemFont, sans-serif",s.fillStyle="#6b7280",s.fillText("SCAN TO VIEW WISHLIST",i.width/2,395),i.toDataURL("image/png",.95)}catch(e){throw console.error("Error generating QR code:",e),e}},R=async()=>{try{N(!0);let e=b?await T(v,"qrcode",b):v,r=await O(e),a=document.createElement("a");a.download="".concat(t.replace(/[^a-z0-9]/gi,"_").toLowerCase(),"_qr_code.png"),a.href=r,document.body.appendChild(a),a.click(),document.body.removeChild(a),w.toast.success("QR code downloaded successfully!")}catch(e){console.error("Error downloading QR code:",e),w.toast.error("Failed to generate QR code")}finally{N(!1)}},U=[{name:"Send",icon:i.A,color:"bg-slate-600 hover:bg-slate-700 text-white",action:async()=>{try{A("Send",!0);let e=b?await T(v,"social",b):v;navigator.share?await navigator.share({title:t,text:D,url:e}):k(!0)}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;console.error("Error sharing:",e),k(!0)}finally{A("Send",!1)}}},{name:"Copy",icon:s.A,color:"bg-emerald-600 hover:bg-emerald-700 text-white",action:async()=>{try{A("Copy",!0);let e=b?await T(v,"social",b):v;await navigator.clipboard.writeText(e),w.toast.success("Link copied to clipboard!"),(0,x.y)("share")}catch(e){console.error("Failed to copy link:",e),w.toast.error("Failed to copy link")}finally{A("Copy",!1)}}},{name:"Facebook",icon:n.A,color:"bg-blue-600 hover:bg-blue-700 text-white",action:async()=>{try{A("Facebook",!0);let e=b?await T(v,"social",b):v,t="https://www.facebook.com/sharer/sharer.php?u=".concat(encodeURIComponent(e));window.open(t,"_blank","width=600,height=600")}finally{A("Facebook",!1)}}},{name:"X",icon:o.A,color:"bg-black hover:bg-gray-800 text-white",action:async()=>{try{A("X",!0);let e=b?await T(v,"social",b):v,r=D?"".concat(t," â ").concat(D):t,a="https://twitter.com/intent/tweet?text=".concat(encodeURIComponent(r),"&url=").concat(encodeURIComponent(e));window.open(a,"_blank","width=600,height=600")}finally{A("X",!1)}}},{name:"Pinterest",icon:l.A,color:"bg-red-500 hover:bg-red-600 text-white",action:async()=>{try{A("Pinterest",!0);let e=b?await T(v,"social",b):v,r=new URLSearchParams({url:e,description:t});y&&r.set("media",y),window.open("https://pinterest.com/pin/create/button/?".concat(r.toString()),"_blank","width=600,height=600")}finally{A("Pinterest",!1)}}}];return(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-2 ".concat(_),children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[U.map(e=>{let t=I.has(e.name);return(0,a.jsxs)("button",{onClick:e.action,disabled:t,className:"group flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-medium transition-all duration-200 hover:scale-105 active:scale-95 shadow-sm hover:shadow-md ".concat(e.color," disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:scale-100"),title:"Share via ".concat(e.name),children:[t?(0,a.jsx)("div",{className:"w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin"}):(0,a.jsx)(e.icon,{className:"w-3.5 h-3.5"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:e.name})]},e.name)}),j&&(0,a.jsxs)("button",{onClick:R,disabled:C,className:"group flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-medium transition-all duration-200 hover:scale-105 active:scale-95 shadow-sm hover:shadow-md bg-primary hover:bg-primary-hover text-white disabled:opacity-50 disabled:cursor-not-allowed",title:"Download QR Code",children:[C?(0,a.jsx)("div",{className:"w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin"}):(0,a.jsx)(c.A,{className:"w-3.5 h-3.5"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"QR Code"})]})]}),(0,a.jsx)("canvas",{ref:F,style:{display:"none"}})]})}r(30285),r(44838)},84050:(e,t,r)=>{r.d(t,{A:()=>n});var a=r(95155),i=r(12115),s=r(75074);function n(e){let{options:t,value:r,onChange:n,placeholder:o="Search...",className:l="",label:c}=e,[d,u]=(0,i.useState)(!1),[h,m]=(0,i.useState)(""),p=(0,i.useRef)(null),g=(0,i.useRef)(null);(0,i.useEffect)(()=>{function e(e){var t,r;let a=e.target,i=null===(t=p.current)||void 0===t?void 0:t.contains(a),s=null===(r=g.current)||void 0===r?void 0:r.contains(a);i||s||u(!1)}if(d)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[d]);let w=t.filter(e=>e.label.toLowerCase().includes(h.toLowerCase())),f=t.find(e=>e.value===r);return(0,a.jsxs)("div",{className:"relative ".concat(l),ref:p,children:[c&&(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:c}),(0,a.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),e.preventDefault(),u(!d)},onMouseDown:e=>e.stopPropagation(),className:"w-full flex items-center justify-between bg-white border border-gray-200 rounded-lg px-3 py-2 text-left focus:outline-none focus:ring-2 focus:ring-brand focus:border-brand",children:[(0,a.jsx)("span",{className:"block truncate",children:f?f.label:o}),(0,a.jsx)("span",{className:"pointer-events-none",children:(0,a.jsx)("svg",{className:"h-5 w-5 text-gray-400",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",children:(0,a.jsx)("path",{d:"M7 7l3-3 3 3m0 6l-3 3-3-3",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),d&&(0,a.jsxs)("div",{ref:g,"data-lmk-searchable-select-dropdown":!0,className:"absolute left-0 right-0 top-full z-[120] mt-1 bg-white rounded-md shadow-lg border border-gray-200",onPointerDown:e=>e.stopPropagation(),children:[(0,a.jsx)("div",{className:"p-2",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(s.A,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),(0,a.jsx)("input",{type:"text",className:"w-full pl-9 pr-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-brand focus:border-brand",placeholder:"Search...",value:h,onChange:e=>m(e.target.value),onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),autoFocus:!0})]})}),(0,a.jsxs)("ul",{className:"max-h-60 min-h-[120px] overflow-auto py-1",children:[(0,a.jsx)("li",{children:(0,a.jsx)("button",{type:"button",className:"w-full text-left px-3 py-2 hover:bg-gray-100 ".concat(r?"":"bg-primary/10 font-medium"),onClick:e=>{e.stopPropagation(),e.preventDefault(),n(""),u(!1),m("")},onMouseDown:e=>e.stopPropagation(),children:o})}),w.map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("button",{type:"button",className:"w-full text-left px-3 py-2 hover:bg-gray-100 ".concat(r===e.value?"bg-primary/10 font-medium":""),onClick:t=>{t.stopPropagation(),t.preventDefault(),n(e.value),u(!1),m("")},onMouseDown:e=>e.stopPropagation(),children:e.label})},e.value)),0===w.length&&(0,a.jsx)("li",{className:"px-3 py-2 text-gray-500 text-sm",children:"No results found"})]})]})]})}}}]);
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.