1import{c as I}from"./compiler-runtime-CCXcv58m.js";import{j as r}from"./jsx-runtime-Ceax0Cqe.js";import{r as x}from"./index-DWDz34VN.js";import{L as A}from"./LogoutButton-CqrcfmpU.js";import{L as W}from"./LoginButton-CjxGnQ7l.js";import{a as M}from"./components-wqsRDmw0.js";import{R as Y}from"./ResponsiveContentfulImage-BqRSnn5O.js";import{B as R}from"./Button-By0ZQI8n.js";import{k as S}from"./ProductMetadataRow-BArI2erU.js";import{C as G}from"./CardMedia-BtMVlCqG.js";import{C as P}from"./Check-C3cObPd9.js";import{c as U}from"./index-B3n_MkUe.js";import"./index-H8TOHEA2.js";import"./colors-B6mVofl9.js";import"./shopify-BwsgKrBL.js";import"./datetime-DEf05-IO.js";import"./toInteger-XOIsJSTW.js";import"./VideoPlayer-DbnyDq1e.js";import"./preload-helper-nehM1tc2.js";import"./Carousel-DAQkztFI.js";import"./ArrowRight-DJdWvG7d.js";import"./Spinner-Cpb0CpYt.js";import"./Clock-BV7sOvia.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};a.SENTRY_RELEASE={id:"18519aeb6e5c25e91d3cf2b957a8e02440d37150"}}catch{}})();try{(function(){var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new a.Error().stack;e&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[e]="539fb1fc-aaff-448d-a722-f987b64a9d99",a._sentryDebugIdIdentifier="sentry-dbid-539fb1fc-aaff-448d-a722-f987b64a9d99")})()}catch{}const q={heading:"Your referrals",clicked:"Friends clicked",claimed:"Friends claimed",completed:"Friends completed",empty:"No referrals yet â share your link to get the rewards rolling!",error:"We couldn't load your referral stats right now. Your link still works."};function T(a){return typeof a=="number"&&Number.isFinite(a)?a:0}const J="inline-flex items-center gap-2 rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm font-medium text-camp-primary transition-colors hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-dark-500";function _({src:a,srcMobile:e,alt:i=""}){return a?r.jsx(G,{children:r.jsx(Y,{src:a,srcMobile:e,alt:i,"aria-hidden":!i,className:"h-full w-full object-cover object-center",sizeDesktop:"448px",sizeMobile:"100vw"})}):null}function K({imageUrl:a,imageUrlMobile:e,imageAlt:i,shareUrl:s,heading:o="Share with a friend",subheading:n="Give your friends a treat and earn rewards when they join.",shareLinkLabel:m="Your referral link",copyLabel:f="Copy link",copiedLabel:c="Copied",copyResetMs:l=2e3,shareActionsLabel:h="Share via",shareMessage:t="Check this out â use my referral link:",shareTitle:u,stats:d,statsLabels:p,statsError:b=!1,onCopy:g,onShare:v,signOutAction:y}){const j={...q,...p},C=[{key:"clicked",label:j.clicked,value:T(d==null?void 0:d.clicked)},{key:"claimed",label:j.claimed,value:T(d==null?void 0:d.claimed)},{key:"completed",label:j.completed,value:T(d==null?void 0:d.completed)}],E=C.some(w=>w.value>0),[N,L]=x.useState(!1),[O,z]=x.useState(!1),k=x.useRef(null);x.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]),x.useEffect(()=>{z(typeof navigator<"u"&&typeof navigator.share=="function")},[]);const B=x.useCallback(async()=>{try{await navigator.clipboard.writeText(s),L(!0),g==null||g(s),k.current&&clearTimeout(k.current),k.current=setTimeout(()=>L(!1),l)}catch{}},[s,l,g]),H=x.useCallback(async()=>{if(!(typeof navigator>"u"||typeof navigator.share!="function"))try{await navigator.share({title:u??o,text:t,url:s}),v==null||v("native")}catch{}},[s,t,u,o,v]);return r.jsxs(S,{className:"w-full max-w-lg",children:[r.jsx(_,{src:a,srcMobile:e,alt:i}),r.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("h3",{className:"font-semibold text-xl text-camp-primary",children:o}),n?r.jsx("p",{className:"text-base text-gray-300",children:n}):null]}),y?r.jsx("div",{className:"shrink-0 text-sm",children:y}):null]}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("label",{htmlFor:"share-panel-url",className:"text-sm font-medium text-gray-300",children:m}),r.jsx("input",{id:"share-panel-url",type:"text",readOnly:!0,value:s,onFocus:w=>w.currentTarget.select(),className:"w-full rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-base text-camp-primary"})]}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("span",{id:"share-panel-actions-label",className:"text-sm font-medium text-gray-300",children:h}),r.jsxs("div",{className:"flex flex-wrap gap-2",role:"group","aria-labelledby":"share-panel-actions-label",children:[r.jsx(R,{variant:"primary",size:"medium",onClick:B,ariaLabel:N?c:`${f}: ${s}`,icon:N?r.jsx(P,{className:"h-4 w-4"}):void 0,children:N?c:f}),O?r.jsx("button",{type:"button",onClick:H,"aria-label":"Share using your device",className:J,children:"Share"}):null]})]}),r.jsxs("section",{"aria-labelledby":"share-panel-stats-label",className:"flex flex-col gap-2 border-t border-gray-200 pt-4",children:[r.jsx("h4",{id:"share-panel-stats-label",className:"text-sm font-medium text-gray-300",children:j.heading}),b?r.jsx("p",{className:"text-base text-gray-300",children:j.error}):E?r.jsx("dl",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:C.map(w=>r.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.jsx("dt",{className:"text-sm text-gray-300",children:w.label}),r.jsx("dd",{className:"font-semibold text-xl text-camp-primary",children:w.value})]},w.key))}):r.jsx("p",{className:"text-base text-gray-300",children:j.empty})]}),r.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:N?`${c}. Referral link copied to clipboard.`:""})]})]})}function Q({imageUrl:a,imageUrlMobile:e,imageAlt:i,heading:s="Share with a friend",message:o="Sign in to get your referral link and start earning rewards.",signInAction:n}){return r.jsxs(S,{className:"w-full max-w-lg",children:[r.jsx(_,{src:a,srcMobile:e,alt:i}),r.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[r.jsx("h3",{className:"font-semibold text-xl text-camp-primary",children:s}),r.jsx("p",{className:"text-base text-gray-300",children:o}),n]})]})}function F({imageUrl:a,imageUrlMobile:e,imageAlt:i,heading:s="Share with a friend",message:o="We couldn't load your referral link right now. Please try again in a moment.",retryLabel:n="Try again",onRetry:m,signOutAction:f}){return r.jsxs(S,{className:"w-full max-w-lg",children:[r.jsx(_,{src:a,srcMobile:e,alt:i}),r.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsx("h3",{className:"font-semibold text-xl text-camp-primary",children:s}),f?r.jsx("div",{className:"shrink-0 text-sm",children:f}):null]}),r.jsx("p",{role:"alert",className:"text-base text-gray-300",children:o}),m?r.jsx("div",{children:r.jsx(R,{variant:"primary",size:"medium",onClick:m,ariaLabel:n,children:n})}):null]})]})}const V=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function X({copy:a,discountCode:e,status:i,errorKind:s="generic",onSubmit:o,onCopy:n,signOutAction:m}){const[f,c]=x.useState(""),[l,h]=x.useState(!1),[t,u]=x.useState(!1),d=x.useRef(null);x.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);const p=x.useCallback(g=>{if(g.preventDefault(),!V.test(f)){h(!0);return}h(!1),o(f)},[f,o]),b=x.useCallback(async()=>
1{if(e)try{await navigator.clipboard.writeText(e),u(!0),n==null||n(e),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>u(!1),2e3)}catch{}},[e,n]);return r.jsx(S,{className:"w-full max-w-md",children:r.jsx("div",{className:"flex flex-col gap-4 p-6",children:i==="revealed"&&e?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsx("h3",{className:"font-semibold text-xl text-camp-primary",children:a.friendRevealHeading}),m?r.jsx("div",{className:"shrink-0 text-sm",children:m}):null]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("span",{className:"text-sm font-medium text-gray-300",children:a.friendCodeLabel}),r.jsx("span",{className:"font-mono text-lg tracking-wide text-camp-primary",children:e})]}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsx(R,{variant:"secondary",size:"medium",onClick:b,ariaLabel:t?a.friendCopiedLabel:a.friendCopyLabel,icon:t?r.jsx(P,{className:"h-4 w-4"}):void 0,children:t?a.friendCopiedLabel:a.friendCopyLabel}),r.jsx("a",{href:a.friendShopHref,className:"inline-flex items-center rounded-lg bg-camp-primary px-4 py-2 text-sm font-medium text-white",children:a.friendShopCtaLabel})]}),r.jsx("span",{role:"status","aria-live":"polite",className:"sr-only",children:t?`${a.friendCopiedLabel}.`:""})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("h3",{className:"font-semibold text-xl text-camp-primary",children:a.friendHeading}),r.jsx("p",{className:"text-base text-gray-300",children:a.friendSubheading})]}),r.jsxs("form",{className:"flex flex-col gap-2",onSubmit:p,children:[r.jsx("label",{htmlFor:"referral-friend-email",className:"text-sm font-medium text-gray-300",children:a.friendEmailLabel}),r.jsx("input",{id:"referral-friend-email",type:"email",value:f,placeholder:a.friendEmailPlaceholder,onChange:g=>c(g.currentTarget.value),"aria-invalid":l,className:"w-full rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-base text-camp-primary"}),l?r.jsx("p",{role:"alert",className:"text-sm text-red-600",children:a.friendEmailInvalidMessage}):null,i==="error"?r.jsx("p",{role:"alert",className:"text-sm text-red-600",children:s==="invalid_code"?a.friendInvalidCodeMessage:s==="existing_customer"?a.friendExistingCustomerMessage:a.friendErrorMessage}):null,r.jsx("div",{children:r.jsx(R,{type:"submit",variant:"primary",size:"medium",disabled:i==="submitting",ariaLabel:a.friendCtaLabel,children:a.friendCtaLabel})})]})]})})})}const D="/api/referral-me";function Z({data:a,copy:e,imageUrl:i,imageUrlMobile:s,imageAlt:o,onRetry:n,onCopy:m,onShare:f}){if(!a)return null;const c=r.jsx(A,{ctaText:e.signOutLabel,color:"currentColor",underline:!0});return"error"in a?r.jsx(F,{imageUrl:i,imageUrlMobile:s,imageAlt:o,heading:e.heading,message:e.errorMessage,retryLabel:e.errorRetryLabel,onRetry:n,signOutAction:c}):a.loggedIn?!a.referralCode||!a.shareUrl?r.jsx(F,{imageUrl:i,imageUrlMobile:s,imageAlt:o,heading:e.heading,message:e.errorMessage,retryLabel:e.errorRetryLabel,onRetry:n,signOutAction:c}):r.jsx(K,{imageUrl:i,imageUrlMobile:s,imageAlt:o,shareUrl:a.shareUrl,referralCode:a.referralCode,heading:e.heading,subheading:e.subheading,shareLinkLabel:e.shareLinkLabel,shareMessage:e.shareMessage,stats:a.stats,statsError:a.stats===null,statsLabels:{heading:e.statsHeading,clicked:e.statsClickedLabel,claimed:e.statsClaimedLabel,completed:e.statsCompletedLabel,empty:e.statsEmptyMessage,error:e.statsErrorMessage},onCopy:m,onShare:f,signOutAction:c}):r.jsx(Q,{imageUrl:i,imageUrlMobile:s,imageAlt:o,heading:e.heading,message:e.signedOutMessage,signInAction:r.jsx(W,{ctaText:e.signedOutCtaLabel,ariaLabel:e.signedOutCtaLabel,large:!0})})}function ee(a){const e=I.c(15),{copy:i,imageUrl:s,imageUrlMobile:o,imageAlt:n,onCopy:m,onShare:f}=a,c=M(),{load:l,state:h}=c;let t,u;e[0]!==l?(t=()=>{l(D)},u=[l],e[0]=l,e[1]=t,e[2]=u):(t=e[1],u=e[2]),x.useEffect(t,u);let d;e[3]!==l||e[4]!==h?(d=h==="idle"?()=>l(D):void 0,e[3]=l,e[4]=h,e[5]=d):d=e[5];let p;return e[6]!==i||e[7]!==c.data||e[8]!==n||e[9]!==s||e[10]!==o||e[11]!==m||e[12]!==f||e[13]!==d?(p=r.jsx(Z,{data:c.data,copy:i,imageUrl:s,imageUrlMobile:o,imageAlt:n,onRetry:d,onCopy:m,onShare:f}),e[6]=i,e[7]=c.data,e[8]=n,e[9]=s,e[10]=o,e[11]=m,e[12]=f,e[13]=d,e[14]=p):p=e[14],p}const $="/api/referral-create";function re(a){const e=I.c(17),{referralCode:i,copy:s,initialDiscountCode:o,onCopy:n,signOutAction:m}=a,f=o===void 0?null:o,c=M(),l=c.data,h=c.state!=="idle",[t]=U();let u;e[0]!==t?(u=t.get("test_ip"),e[0]=t,e[1]=u):u=e[1];const d=u,p=d?`${$}?test_ip=${encodeURIComponent(d)}`:$;let b="offer",g="generic",v=null;(l==null?void 0:l.ok)===!0?(b="revealed",v=l.friendDiscountCode):h?b="submitting":(l==null?void 0:l.ok)===!1?(b="error",g=l.error):f&&(b="revealed",v=f);let y,j;e[2]!==l?(y=()=>{(l==null?void 0:l.ok)===!1&&l.debugMessage&&console.error("[Referral debug]",l.debugMessage)},j=[l],e[2]=l,e[3]=y,e[4]=j):(y=e[3],j=e[4]),x.useEffect(y,j);let C;
1e[5]!==c||e[6]!==i||e[7]!==p?(C=L=>{c.submit({email:L,referralCode:i},{method:"post",action:p})},e[5]=c,e[6]=i,e[7]=p,e[8]=C):C=e[8];const E=C;let N;return e[9]!==s||e[10]!==v||e[11]!==g||e[12]!==E||e[13]!==n||e[14]!==m||e[15]!==b?(N=r.jsx(X,{copy:s,status:b,errorKind:g,discountCode:v,onSubmit:E,onCopy:n,signOutAction:m}),e[9]=s,e[10]=v,e[11]=g,e[12]=E,e[13]=n,e[14]=m,e[15]=b,e[16]=N):N=e[16],N}const ae="/api/referral-state",ke=a=>{var d,p,b,g;const e=I.c(10),{capsule:i,referralData:s}=a,o=M(),{load:n}=o,m=(d=s==null?void 0:s.friend)==null?void 0:d.referralCode;let f,c;if(e[0]!==n||e[1]!==m?(f=()=>{m&&n(`${ae}?referral_code=${encodeURIComponent(m)}`)},c=[n,m],e[0]=n,e[1]=m,e[2]=f,e[3]=c):(f=e[2],c=e[3]),x.useEffect(f,c),!s)return null;const{copy:l,friend:h}=s,t=o.data;let u;return e[4]!==i||e[5]!==l||e[6]!==h||e[7]!==(t==null?void 0:t.loggedIn)||e[8]!==(t==null?void 0:t.savedDiscountCode)?(u=r.jsx("div",{className:"mx-auto flex max-w-2xl flex-col items-center px-4",children:h?r.jsx(re,{referralCode:h.referralCode,copy:l.friend,initialDiscountCode:t==null?void 0:t.savedDiscountCode,signOutAction:t!=null&&t.loggedIn?r.jsx(A,{ctaText:l.signOutLabel,color:"currentColor",underline:!0}):void 0}):r.jsx(ee,{copy:l,imageUrl:((p=i.image)==null?void 0:p.url)??void 0,imageUrlMobile:((b=i.imageMobile)==null?void 0:b.url)??void 0,imageAlt:((g=i.image)==null?void 0:g.description)??void 0})}),e[4]=i,e[5]=l,e[6]=h,e[7]=t==null?void 0:t.loggedIn,e[8]=t==null?void 0:t.savedDiscountCode,e[9]=u):u=e[9],u};export{ae as REFERRAL_STATE_ROUTE,ke as default}; 2//# sourceMappingURL=Referral-YIg_zbpk.js.map
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.