@anker-in/campaign-ui 0.5.0-beta.11 → 0.5.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,5 +5,5 @@ type MemberPopupProps = MemberPopupContextValue & {
5
5
  copy: MemberPopupCopy;
6
6
  bottomOffset?: string;
7
7
  };
8
- export declare function MemberPopup({ copy, bottomOffset, ...providerProps }: MemberPopupProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function MemberPopup({ copy, bottomOffset, ...providerProps }: MemberPopupProps): import("react/jsx-runtime").JSX.Element | null;
9
9
  export {};
@@ -1,2 +1,2 @@
1
- "use strict";"use client";var W=Object.create;var g=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var Q=(e,i)=>{for(var n in i)g(e,n,{get:i[n],enumerable:!0})},O=(e,i,n,u)=>{if(i&&typeof i=="object"||typeof i=="function")for(let l of G(i))!K.call(e,l)&&l!==n&&g(e,l,{get:()=>i[l],enumerable:!(u=q(i,l))||u.enumerable});return e};var d=(e,i,n)=>(n=e!=null?W(J(e)):{},O(i||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),X=e=>O(g({},"__esModule",{value:!0}),e);var ae={};Q(ae,{MemberPopup:()=>ie});module.exports=X(ae);var t=require("react/jsx-runtime"),r=require("react"),V=require("@anker-in/headless-ui"),f=require("@anker-in/lib"),s=require("./type"),R=require("./context/provider"),H=require("./context/provider"),z=require("./context/viewStack"),a=require("./icons"),E=require("../../constants");const Y=(0,r.lazy)(()=>import("./panels/EarnCredits")),Z=(0,r.lazy)(()=>import("./panels/ConsumeCredits")),$=(0,r.lazy)(()=>import("./panels/Referral")),ee=(0,r.lazy)(()=>import("./panels/EarnCredits/CompleteProfilePanel")),te=(0,r.lazy)(()=>import("./panels/ActivitiesSubscribePanel")),se=(0,r.lazy)(()=>import("./panels/EarnCredits/SubscribeEmailPanel")),oe=(0,r.lazy)(()=>import("./panels/EarnCredits/ActivatePanel")),re=(0,r.lazy)(()=>import("./panels/ConsumeCredits/RedeemCouponPanel"));function ie({copy:e,bottomOffset:i="24px",...n}){return(0,t.jsx)(R.MemberPopupProvider,{...n,earnCreditsCopy:e.earnCredits,children:(0,t.jsx)(ne,{copy:e,bottomOffset:i})})}function ne({copy:e,bottomOffset:i}){const{profile:n,openSignInPopup:u,openSignUpPopup:l}=(0,H.useMemberPopupContext)(),{brand:x,storeDomain:C}=(0,f.useHeadlessContext)(),v=E.ROUNDED_BRANDS.includes(x),T=!!n,[P,w]=(0,r.useState)(!1),[h,S]=(0,r.useState)([]),[j,_]=(0,r.useState)(!1),[N,D]=(0,r.useState)(!1),[F,L]=(0,r.useState)(!1),[U,y]=(0,r.useState)(!1),o=h[h.length-1]??null,I=(0,r.useMemo)(()=>{const p=e.pageConfig;if(!p)return!0;const m=typeof window<"u"?window.location.pathname:"",M=p.pages.some(A=>m===A||m.startsWith(A+"/"));switch(p.scope){case s.MemberPopupPageScope.Include:return M;case s.MemberPopupPageScope.Exclude:return!M;default:return!0}},[e.pageConfig]),b=(0,r.useCallback)(p=>{S(m=>[...m,p])},[]),c=(0,r.useCallback)(()=>{S(p=>p.slice(0,-1))},[]);if(console.log("isVisible",I),!I)return null;function B(p,m){switch(p){case s.MemberPopupActionType.ExternalLink:m&&window.open(m,"_blank","noopener,noreferrer");break;case s.MemberPopupActionType.OpenEarnCredits:b({type:s.MemberPopupPanelType.EarnCredits});break;case s.MemberPopupActionType.OpenConsumeCredits:b({type:s.MemberPopupPanelType.ConsumeCredits});break;case s.MemberPopupActionType.OpenReferral:b({type:s.MemberPopupPanelType.Referral});break;case s.MemberPopupActionType.OpenSubscribe:b({type:s.MemberPopupPanelType.Subscribe});break}}function k(){w(!1),S([]),y(!1)}return(0,t.jsxs)(z.ViewStackContext.Provider,{value:{pushView:b,popView:c},children:[P&&(0,t.jsx)("div",{className:"fixed inset-0 z-[998]",onClick:k}),(0,t.jsxs)("div",{className:"fixed right-0 z-[999] flex flex-row items-end pr-[16px] md:flex-col md:items-end md:right-0 md:w-screen md:pr-0 md:pl-0",style:{bottom:i},children:[P&&(0,t.jsxs)("div",{className:(0,f.classNames)("relative mr-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[500px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] md:mr-0 md:mb-[8px] md:mx-[16px] md:w-[calc(100vw-32px)] md:max-w-[400px]",v?"rounded-[12px]":"rounded-none"),style:{maxHeight:"min(80vh, 606px)"},onClick:p=>p.stopPropagation(),children:[(0,t.jsx)("div",{className:"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white md:bottom-[-8px] md:left-auto md:right-[29px] md:top-auto md:border-x-8 md:border-b-transparent md:border-t-white"}),(0,t.jsxs)("div",{className:"flex items-center justify-end pl-[10px] pr-[16px] pb-[8px] pt-[16px]",children:[o!==null&&(0,t.jsx)("button",{className:"mr-auto flex size-[24px] cursor-pointer items-center justify-center",onClick:c,"aria-label":"Back",children:(0,t.jsx)(a.IconSwitch,{})}),(0,t.jsx)("button",{className:"flex size-[24px] cursor-pointer items-center justify-center",onClick:k,"aria-label":"Close",children:(0,t.jsx)(a.IconClose,{})})]}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]",children:[o===null&&(0,t.jsxs)(t.Fragment,{children:[(e.title||e.subtitle)&&(0,t.jsxs)("div",{className:"flex flex-col gap-[4px]",children:[e.title&&(0,t.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:e.title}),e.subtitle&&(0,t.jsx)("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:e.subtitle})]}),e.list.map((p,m)=>(0,t.jsx)(pe,{item:p,onAction:B,rounded:v},m))]}),o!==null&&(0,t.jsxs)(r.Suspense,{fallback:(0,t.jsx)("div",{className:"flex items-center justify-center py-[32px]",children:(0,t.jsx)("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}),children:[o.type===s.MemberPopupPanelType.EarnCredits&&e.earnCredits&&(0,t.jsx)(Y,{copy:e.earnCredits,onClose:c,isSubscribeSuccess:j,isActivateSuccess:N,isProfileCompleteSuccess:F,onSubscribeSuccess:()=>_(!0),onActivateSuccess:()=>D(!0),onProfileCompleteSuccess:()=>L(!0)}),o.type===s.MemberPopupPanelType.ConsumeCredits&&e.consumeCredits&&(0,t.jsx)(Z,{copy:e.consumeCredits,onClose:c,isActivateSuccess:N}),o.type===s.MemberPopupPanelType.Referral&&e.referral&&(0,t.jsx)($,{copy:e.referral,onClose:c}),o.type===s.MemberPopupPanelType.CompleteProfile&&e.earnCredits&&(0,t.jsx)(ee,{copy:e.earnCredits.completeProfile,shopifyStoreDomain:C,onClose:c,onSuccess:o.props?.onSuccess}),o.type===s.MemberPopupPanelType.Subscribe&&e.activitiesSubscribe&&(0,t.jsx)(te,{copy:e.activitiesSubscribe,email:n?.email,onSuccess:o.props?.onSuccess,hideForm:U,onHideForm:()=>y(!0)}),o.type===s.MemberPopupPanelType.SubscribeEmail&&e.earnCredits&&(0,t.jsx)(se,{copy:e.earnCredits.subscribe,email:n?.email,onClose:c,onSuccess:o.props?.onSuccess}),o.type===s.MemberPopupPanelType.Activate&&e.earnCredits&&(0,t.jsx)(oe,{copy:e.earnCredits.authCodeActivate,onClose:c,onSuccess:o.props?.onSuccess}),o.type===s.MemberPopupPanelType.RedeemCoupon&&o.props&&e.consumeCredits&&(0,t.jsx)(re,{itemTitle:o.props.itemTitle,itemCredits:o.props.itemCredits,itemImage:o.props.itemImage,itemValue:o.props.itemValue,itemOff:o.props.itemOff,itemRules:o.props.itemRules,redeemId:o.props.redeemId,userId:o.props.userId,alpcConfig:o.props.alpcConfig,copy:e.consumeCredits.redeemModal,pointUnit:e.consumeCredits.pointUnit,onClose:c})]})]}),e.footer&&!T&&(0,t.jsx)("div",{className:"border-t border-[#dadce0] p-[16px]",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-[16px]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[14px] font-[700] text-[#080a0f]",children:e.footer.loginHint}),(0,t.jsx)("button",{className:"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline",onClick:u,children:e.footer.loginLabel})]}),(0,t.jsx)("div",{className:"flex shrink-0 items-center gap-[8px]",children:(0,t.jsx)("button",{className:(0,f.classNames)("cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]",v?"rounded-[4px]":"rounded-none"),onClick:l,children:e.footer.joinLabel})})]})})]}),(0,t.jsx)("button",{className:"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg md:ml-auto md:mr-[16px]",onClick:()=>w(p=>!p),"aria-label":e.triggerImg.alt??"Open member popup",children:(0,t.jsx)(V.Picture,{source:e.triggerImg.url,alt:e.triggerImg.alt??"",className:"size-[58px]"})})]})]})}function pe({item:e,onAction:i,rounded:n}){const u={[s.MemberPopupActionType.OpenEarnCredits]:a.IconCredit,[s.MemberPopupActionType.OpenConsumeCredits]:a.IconBag,[s.MemberPopupActionType.OpenReferral]:a.IconReferral,[s.MemberPopupActionType.OpenSubscribe]:a.IconSubscription};return(0,t.jsxs)("div",{className:(0,f.classNames)("flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]",n?"rounded-[8px]":"rounded-none"),children:[(0,t.jsxs)("div",{className:"flex flex-col gap-[4px]",children:[(0,t.jsx)("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#1e2024]",children:e.title}),e.description&&(0,t.jsx)("p",{className:"text-[14px] font-[700] leading-[1.43] text-[#1e2024]",children:e.description})]}),(0,t.jsx)("div",{className:"flex flex-col gap-[16px]",children:e.links.map((l,x)=>{const C=u[l.type];return(0,t.jsxs)("div",{children:[x>0&&(0,t.jsx)("div",{className:"mb-[16px] h-px bg-[#dadce0]"}),(0,t.jsxs)("button",{className:"flex w-full cursor-pointer items-center gap-[12px]",onClick:()=>i(l.type,l.url),children:[C&&(0,t.jsx)(C,{className:"size-[24px] shrink-0"}),(0,t.jsx)("span",{className:"flex-1 text-left text-[14px] font-[700] text-[#1e2024]",children:l.label}),(0,t.jsx)(a.IconArrow,{className:"size-[16px] shrink-0"})]})]},x)})})]})}
1
+ "use strict";"use client";var L=Object.create;var v=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var G=(e,i)=>{for(var n in i)v(e,n,{get:i[n],enumerable:!0})},M=(e,i,n,c)=>{if(i&&typeof i=="object"||typeof i=="function")for(let p of B(i))!q.call(e,p)&&p!==n&&v(e,p,{get:()=>i[p],enumerable:!(c=U(i,p))||c.enumerable});return e};var d=(e,i,n)=>(n=e!=null?L(W(e)):{},M(i||!e||!e.__esModule?v(n,"default",{value:e,enumerable:!0}):n,e)),J=e=>M(v({},"__esModule",{value:!0}),e);var ie={};G(ie,{MemberPopup:()=>se});module.exports=J(ie);var t=require("react/jsx-runtime"),o=require("react"),O=require("@anker-in/headless-ui"),C=require("@anker-in/lib"),s=require("./type"),A=require("./context/provider"),V=require("./context/provider"),R=require("./context/viewStack"),a=require("./icons"),E=require("../../constants");const K=(0,o.lazy)(()=>import("./panels/EarnCredits")),Q=(0,o.lazy)(()=>import("./panels/ConsumeCredits")),X=(0,o.lazy)(()=>import("./panels/Referral")),Y=(0,o.lazy)(()=>import("./panels/EarnCredits/CompleteProfilePanel")),Z=(0,o.lazy)(()=>import("./panels/ActivitiesSubscribePanel")),$=(0,o.lazy)(()=>import("./panels/EarnCredits/SubscribeEmailPanel")),ee=(0,o.lazy)(()=>import("./panels/EarnCredits/ActivatePanel")),te=(0,o.lazy)(()=>import("./panels/ConsumeCredits/RedeemCouponPanel"));function se({copy:e,bottomOffset:i="24px",...n}){const c=(0,o.useMemo)(()=>{const p=e.pageConfig;if(!p)return!0;const u=typeof window<"u"?window.location.pathname:"",f=p.pages.some(b=>u===b||u.startsWith(b+"/"));switch(p.scope){case s.MemberPopupPageScope.Include:return f;case s.MemberPopupPageScope.Exclude:return!f;default:return!0}},[e.pageConfig]);return console.log("isVisible",c),c?(0,t.jsx)(A.MemberPopupProvider,{...n,earnCreditsCopy:e.earnCredits,children:(0,t.jsx)(oe,{copy:e,bottomOffset:i})}):null}function oe({copy:e,bottomOffset:i}){const{profile:n,openSignInPopup:c,openSignUpPopup:p}=(0,V.useMemberPopupContext)(),{brand:u,storeDomain:f}=(0,C.useHeadlessContext)(),b=E.ROUNDED_BRANDS.includes(u),H=!!n,[S,w]=(0,o.useState)(!1),[h,P]=(0,o.useState)([]),[z,N]=(0,o.useState)(!1),[y,T]=(0,o.useState)(!1),[j,_]=(0,o.useState)(!1),[D,I]=(0,o.useState)(!1),r=h[h.length-1]??null,g=(0,o.useCallback)(l=>{P(x=>[...x,l])},[]),m=(0,o.useCallback)(()=>{P(l=>l.slice(0,-1))},[]);function F(l,x){switch(l){case s.MemberPopupActionType.ExternalLink:x&&window.open(x,"_blank","noopener,noreferrer");break;case s.MemberPopupActionType.OpenEarnCredits:g({type:s.MemberPopupPanelType.EarnCredits});break;case s.MemberPopupActionType.OpenConsumeCredits:g({type:s.MemberPopupPanelType.ConsumeCredits});break;case s.MemberPopupActionType.OpenReferral:g({type:s.MemberPopupPanelType.Referral});break;case s.MemberPopupActionType.OpenSubscribe:g({type:s.MemberPopupPanelType.Subscribe});break}}function k(){w(!1),P([]),I(!1)}return(0,t.jsxs)(R.ViewStackContext.Provider,{value:{pushView:g,popView:m},children:[S&&(0,t.jsx)("div",{className:"fixed inset-0 z-[998]",onClick:k}),(0,t.jsxs)("div",{className:"fixed right-0 z-[999] flex flex-row items-end pr-[16px] md:flex-col md:items-end md:right-0 md:w-screen md:pr-0 md:pl-0",style:{bottom:i},children:[S&&(0,t.jsxs)("div",{className:(0,C.classNames)("relative mr-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[500px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] md:mr-0 md:mb-[8px] md:mx-[16px] md:w-[calc(100vw-32px)] md:max-w-[400px]",b?"rounded-[12px]":"rounded-none"),style:{maxHeight:"min(80vh, 606px)"},onClick:l=>l.stopPropagation(),children:[(0,t.jsx)("div",{className:"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white md:bottom-[-8px] md:left-auto md:right-[29px] md:top-auto md:border-x-8 md:border-b-transparent md:border-t-white"}),(0,t.jsxs)("div",{className:"flex items-center justify-end pl-[10px] pr-[16px] pb-[8px] pt-[16px]",children:[r!==null&&(0,t.jsx)("button",{className:"mr-auto flex size-[24px] cursor-pointer items-center justify-center",onClick:m,"aria-label":"Back",children:(0,t.jsx)(a.IconSwitch,{})}),(0,t.jsx)("button",{className:"flex size-[24px] cursor-pointer items-center justify-center",onClick:k,"aria-label":"Close",children:(0,t.jsx)(a.IconClose,{})})]}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]",children:[r===null&&(0,t.jsxs)(t.Fragment,{children:[(e.title||e.subtitle)&&(0,t.jsxs)("div",{className:"flex flex-col gap-[4px]",children:[e.title&&(0,t.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:e.title}),e.subtitle&&(0,t.jsx)("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:e.subtitle})]}),e.list.map((l,x)=>(0,t.jsx)(re,{item:l,onAction:F,rounded:b},x))]}),r!==null&&(0,t.jsxs)(o.Suspense,{fallback:(0,t.jsx)("div",{className:"flex items-center justify-center py-[32px]",children:(0,t.jsx)("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}),children:[r.type===s.MemberPopupPanelType.EarnCredits&&e.earnCredits&&(0,t.jsx)(K,{copy:e.earnCredits,onClose:m,isProfileCompleteSuccess:j,isSubscribeSuccess:z,isActivateSuccess:y}),r.type===s.MemberPopupPanelType.ConsumeCredits&&e.consumeCredits&&(0,t.jsx)(Q,{copy:e.consumeCredits,onClose:m,isActivateSuccess:y}),r.type===s.MemberPopupPanelType.Referral&&e.referral&&(0,t.jsx)(X,{copy:e.referral,onClose:m}),r.type===s.MemberPopupPanelType.CompleteProfile&&e.earnCredits&&(0,t.jsx)(Y,{copy:e.earnCredits.completeProfile,shopifyStoreDomain:f,onClose:m,onSuccess:()=>_(!0)}),r.type===s.MemberPopupPanelType.Subscribe&&e.activitiesSubscribe&&(0,t.jsx)(Z,{copy:e.activitiesSubscribe,email:n?.email,onSuccess:()=>N(!0),hideForm:D,onHideForm:()=>I(!0)}),r.type===s.MemberPopupPanelType.SubscribeEmail&&e.earnCredits&&(0,t.jsx)($,{copy:e.earnCredits.subscribe,email:n?.email,onClose:m,onSuccess:()=>N(!0)}),r.type===s.MemberPopupPanelType.Activate&&e.earnCredits&&(0,t.jsx)(ee,{copy:e.earnCredits.authCodeActivate,onClose:m,onSuccess:()=>{T(!0)}}),r.type===s.MemberPopupPanelType.RedeemCoupon&&r.props&&e.consumeCredits&&(0,t.jsx)(te,{itemTitle:r.props.itemTitle,itemCredits:r.props.itemCredits,itemImage:r.props.itemImage,itemValue:r.props.itemValue,itemOff:r.props.itemOff,itemRules:r.props.itemRules,redeemId:r.props.redeemId,userId:r.props.userId,alpcConfig:r.props.alpcConfig,copy:e.consumeCredits.redeemModal,pointUnit:e.consumeCredits.pointUnit,onClose:m})]})]}),e.footer&&!H&&(0,t.jsx)("div",{className:"border-t border-[#dadce0] p-[16px]",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-[16px]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[14px] font-[700] text-[#080a0f]",children:e.footer.loginHint}),(0,t.jsx)("button",{className:"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline",onClick:c,children:e.footer.loginLabel})]}),(0,t.jsx)("div",{className:"flex shrink-0 items-center gap-[8px]",children:(0,t.jsx)("button",{className:(0,C.classNames)("cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]",b?"rounded-[4px]":"rounded-none"),onClick:p,children:e.footer.joinLabel})})]})})]}),(0,t.jsx)("button",{className:"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg md:ml-auto md:mr-[16px]",onClick:()=>w(l=>!l),"aria-label":e.triggerImg.alt??"Open member popup",children:(0,t.jsx)(O.Picture,{source:e.triggerImg.url,alt:e.triggerImg.alt??"",className:"size-[58px]"})})]})]})}function re({item:e,onAction:i,rounded:n}){const c={[s.MemberPopupActionType.OpenEarnCredits]:a.IconCredit,[s.MemberPopupActionType.OpenConsumeCredits]:a.IconBag,[s.MemberPopupActionType.OpenReferral]:a.IconReferral,[s.MemberPopupActionType.OpenSubscribe]:a.IconSubscription};return(0,t.jsxs)("div",{className:(0,C.classNames)("flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]",n?"rounded-[8px]":"rounded-none"),children:[(0,t.jsxs)("div",{className:"flex flex-col gap-[4px]",children:[(0,t.jsx)("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#1e2024]",children:e.title}),e.description&&(0,t.jsx)("p",{className:"text-[14px] font-[700] leading-[1.43] text-[#1e2024]",children:e.description})]}),(0,t.jsx)("div",{className:"flex flex-col gap-[16px]",children:e.links.map((p,u)=>{const f=c[p.type];return(0,t.jsxs)("div",{children:[u>0&&(0,t.jsx)("div",{className:"mb-[16px] h-px bg-[#dadce0]"}),(0,t.jsxs)("button",{className:"flex w-full cursor-pointer items-center gap-[12px]",onClick:()=>i(p.type,p.url),children:[f&&(0,t.jsx)(f,{className:"size-[24px] shrink-0"}),(0,t.jsx)("span",{className:"flex-1 text-left text-[14px] font-[700] text-[#1e2024]",children:p.label}),(0,t.jsx)(a.IconArrow,{className:"size-[16px] shrink-0"})]})]},u)})})]})}
2
2
  //# sourceMappingURL=MemberPopup.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/memberPopup/MemberPopup.tsx"],
4
- "sourcesContent": ["'use client'\n\nimport { lazy, Suspense, useState, useCallback, useMemo } from 'react'\nimport { Picture } from '@anker-in/headless-ui'\nimport { type HeadlessConfig, useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport {\n MemberPopupActionType,\n MemberPopupPageScope,\n MemberPopupPanelType,\n type MemberPopupCopy,\n type MemberPopupContextValue,\n type MemberPopupItem,\n} from './type'\nimport { MemberPopupProvider } from './context/provider'\nimport { useMemberPopupContext } from './context/provider'\nimport { ViewStackContext, type ViewPayload } from './context/viewStack'\nimport { IconClose, IconArrow, IconCredit, IconBag, IconReferral, IconSwitch, IconSubscription } from './icons'\nimport { ROUNDED_BRANDS } from '../../constants'\n\nconst EarnCredits = lazy(() => import('./panels/EarnCredits'))\nconst ConsumeCredits = lazy(() => import('./panels/ConsumeCredits'))\nconst Referral = lazy(() => import('./panels/Referral'))\nconst CompleteProfile = lazy(() => import('./panels/EarnCredits/CompleteProfilePanel'))\nconst ActivitiesSubscribe = lazy(() => import('./panels/ActivitiesSubscribePanel'))\nconst SubscribeEmail = lazy(() => import('./panels/EarnCredits/SubscribeEmailPanel'))\nconst Activate = lazy(() => import('./panels/EarnCredits/ActivatePanel'))\nconst RedeemCoupon = lazy(() => import('./panels/ConsumeCredits/RedeemCouponPanel'))\n\ntype MemberPopupProps = MemberPopupContextValue & {\n headlessConfig: HeadlessConfig\n copy: MemberPopupCopy\n bottomOffset?: string\n}\n\nexport function MemberPopup({ copy, bottomOffset = '24px', ...providerProps }: MemberPopupProps) {\n return (\n <MemberPopupProvider {...providerProps} earnCreditsCopy={copy.earnCredits}>\n <MemberPopupContent copy={copy} bottomOffset={bottomOffset} />\n </MemberPopupProvider>\n )\n}\n\ntype MemberPopupContentProps = {\n copy: MemberPopupCopy\n bottomOffset: string\n}\n\nfunction MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {\n const { profile, openSignInPopup, openSignUpPopup } = useMemberPopupContext()\n const { brand, storeDomain } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n const isLogin = !!profile\n const [isOpen, setIsOpen] = useState(false)\n const [viewStack, setViewStack] = useState<ViewPayload[]>([])\n const [isSubscribeSuccess, setIsSubscribeSuccess] = useState(false)\n const [isActivateSuccess, setIsActivateSuccess] = useState(false)\n const [isProfileCompleteSuccess, setIsProfileCompleteSuccess] = useState(false)\n const [isSubscribeFormHidden, setIsSubscribeFormHidden] = useState(false)\n\n const currentView = viewStack[viewStack.length - 1] ?? null\n\n const isVisible = useMemo(() => {\n const config = copy.pageConfig\n if (!config) return true\n const pathname = typeof window !== 'undefined' ? window.location.pathname : ''\n const matches = config.pages.some(page => pathname === page || pathname.startsWith(page + '/'))\n switch (config.scope) {\n case MemberPopupPageScope.Include:\n return matches\n case MemberPopupPageScope.Exclude:\n return !matches\n default:\n return true\n }\n }, [copy.pageConfig])\n\n const pushView = useCallback((view: ViewPayload) => {\n setViewStack(prev => [...prev, view])\n }, [])\n\n const popView = useCallback(() => {\n setViewStack(prev => prev.slice(0, -1))\n }, [])\n\n console.log('isVisible', isVisible)\n if (!isVisible) return null\n\n function handleAction(type: MemberPopupActionType, url?: string) {\n switch (type) {\n case MemberPopupActionType.ExternalLink:\n if (url) window.open(url, '_blank', 'noopener,noreferrer')\n break\n case MemberPopupActionType.OpenEarnCredits:\n pushView({ type: MemberPopupPanelType.EarnCredits })\n break\n case MemberPopupActionType.OpenConsumeCredits:\n pushView({ type: MemberPopupPanelType.ConsumeCredits })\n break\n case MemberPopupActionType.OpenReferral:\n pushView({ type: MemberPopupPanelType.Referral })\n break\n case MemberPopupActionType.OpenSubscribe:\n pushView({ type: MemberPopupPanelType.Subscribe })\n break\n }\n }\n\n function handleClose() {\n setIsOpen(false)\n setViewStack([])\n setIsSubscribeFormHidden(false)\n }\n\n return (\n <ViewStackContext.Provider value={{ pushView, popView }}>\n {isOpen && <div className=\"fixed inset-0 z-[998]\" onClick={handleClose} />}\n <div\n className=\"fixed right-0 z-[999] flex flex-row items-end pr-[16px] md:flex-col md:items-end md:right-0 md:w-screen md:pr-0 md:pl-0\"\n style={{ bottom: bottomOffset }}\n >\n {isOpen && (\n <div\n className={cn(\n 'relative mr-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[500px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] md:mr-0 md:mb-[8px] md:mx-[16px] md:w-[calc(100vw-32px)] md:max-w-[400px]',\n rounded ? 'rounded-[12px]' : 'rounded-none'\n )}\n style={{ maxHeight: 'min(80vh, 606px)' }}\n onClick={e => e.stopPropagation()}\n >\n <div className=\"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white md:bottom-[-8px] md:left-auto md:right-[29px] md:top-auto md:border-x-8 md:border-b-transparent md:border-t-white\" />\n <div className=\"flex items-center justify-end pl-[10px] pr-[16px] pb-[8px] pt-[16px]\">\n {currentView !== null && (\n <button\n className=\"mr-auto flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={popView}\n aria-label=\"Back\"\n >\n <IconSwitch />\n </button>\n )}\n <button\n className=\"flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={handleClose}\n aria-label=\"Close\"\n >\n <IconClose />\n </button>\n </div>\n\n <div className=\"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]\">\n {currentView === null && (\n <>\n {(copy.title || copy.subtitle) && (\n <div className=\"flex flex-col gap-[4px]\">\n {copy.title && (\n <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>\n )}\n {copy.subtitle && (\n <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>\n )}\n </div>\n )}\n {copy.list.map((item, i) => (\n <HomeCard key={i} item={item} onAction={handleAction} rounded={rounded} />\n ))}\n </>\n )}\n\n {currentView !== null && (\n <Suspense\n fallback={\n <div className=\"flex items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n }\n >\n {currentView.type === MemberPopupPanelType.EarnCredits && copy.earnCredits && (\n <EarnCredits\n copy={copy.earnCredits}\n onClose={popView}\n isSubscribeSuccess={isSubscribeSuccess}\n isActivateSuccess={isActivateSuccess}\n isProfileCompleteSuccess={isProfileCompleteSuccess}\n onSubscribeSuccess={() => setIsSubscribeSuccess(true)}\n onActivateSuccess={() => setIsActivateSuccess(true)}\n onProfileCompleteSuccess={() => setIsProfileCompleteSuccess(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.ConsumeCredits && copy.consumeCredits && (\n <ConsumeCredits\n copy={copy.consumeCredits}\n onClose={popView}\n isActivateSuccess={isActivateSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Referral && copy.referral && (\n <Referral copy={copy.referral} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.CompleteProfile && copy.earnCredits && (\n <CompleteProfile\n copy={copy.earnCredits.completeProfile}\n shopifyStoreDomain={storeDomain}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Subscribe && copy.activitiesSubscribe && (\n <ActivitiesSubscribe\n copy={copy.activitiesSubscribe}\n email={profile?.email}\n onSuccess={currentView.props?.onSuccess}\n hideForm={isSubscribeFormHidden}\n onHideForm={() => setIsSubscribeFormHidden(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.SubscribeEmail && copy.earnCredits && (\n <SubscribeEmail\n copy={copy.earnCredits.subscribe}\n email={profile?.email}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Activate && copy.earnCredits && (\n <Activate\n copy={copy.earnCredits.authCodeActivate}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.RedeemCoupon &&\n currentView.props &&\n copy.consumeCredits && (\n <RedeemCoupon\n itemTitle={currentView.props.itemTitle}\n itemCredits={currentView.props.itemCredits}\n itemImage={currentView.props.itemImage}\n itemValue={currentView.props.itemValue}\n itemOff={currentView.props.itemOff}\n itemRules={currentView.props.itemRules}\n redeemId={currentView.props.redeemId}\n userId={currentView.props.userId}\n alpcConfig={currentView.props.alpcConfig}\n copy={copy.consumeCredits.redeemModal}\n pointUnit={copy.consumeCredits.pointUnit}\n onClose={popView}\n />\n )}\n </Suspense>\n )}\n </div>\n\n {copy.footer && !isLogin && (\n <div className=\"border-t border-[#dadce0] p-[16px]\">\n <div className=\"flex items-center justify-between gap-[16px]\">\n <div className=\"flex items-center gap-[4px]\">\n <span className=\"text-[14px] font-[700] text-[#080a0f]\">{copy.footer.loginHint}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline\"\n onClick={openSignInPopup}\n >\n {copy.footer.loginLabel}\n </button>\n </div>\n <div className=\"flex shrink-0 items-center gap-[8px]\">\n <button\n className={cn(\n 'cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n onClick={openSignUpPopup}\n >\n {copy.footer.joinLabel}\n </button>\n </div>\n </div>\n </div>\n )}\n </div>\n )}\n\n <button\n className=\"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg md:ml-auto md:mr-[16px]\"\n onClick={() => setIsOpen(prev => !prev)}\n aria-label={copy.triggerImg.alt ?? 'Open member popup'}\n >\n <Picture source={copy.triggerImg.url} alt={copy.triggerImg.alt ?? ''} className=\"size-[58px]\" />\n </button>\n </div>\n </ViewStackContext.Provider>\n )\n}\n\ntype HomeCardProps = {\n item: MemberPopupItem\n onAction: (type: MemberPopupActionType, url?: string) => void\n rounded: boolean\n}\n\nfunction HomeCard({ item, onAction, rounded }: HomeCardProps) {\n const ACTION_ICON: Partial<Record<MemberPopupActionType, typeof IconCredit>> = {\n [MemberPopupActionType.OpenEarnCredits]: IconCredit,\n [MemberPopupActionType.OpenConsumeCredits]: IconBag,\n [MemberPopupActionType.OpenReferral]: IconReferral,\n [MemberPopupActionType.OpenSubscribe]: IconSubscription,\n }\n\n return (\n <div className={cn('flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <div className=\"flex flex-col gap-[4px]\">\n <h3 className=\"text-[20px] font-[700] leading-[1.2] text-[#1e2024]\">{item.title}</h3>\n {item.description && <p className=\"text-[14px] font-[700] leading-[1.43] text-[#1e2024]\">{item.description}</p>}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n {item.links.map((link, i) => {\n const IconComponent = ACTION_ICON[link.type]\n return (\n <div key={i}>\n {i > 0 && <div className=\"mb-[16px] h-px bg-[#dadce0]\" />}\n <button\n className=\"flex w-full cursor-pointer items-center gap-[12px]\"\n onClick={() => onAction(link.type, link.url)}\n >\n {IconComponent && <IconComponent className=\"size-[24px] shrink-0\" />}\n <span className=\"flex-1 text-left text-[14px] font-[700] text-[#1e2024]\">{link.label}</span>\n <IconArrow className=\"size-[16px] shrink-0\" />\n </button>\n </div>\n )\n })}\n </div>\n </div>\n )\n}\n"],
5
- "mappings": "ukBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,iBAAAE,KAAA,eAAAC,EAAAH,IAqCM,IAAAI,EAAA,6BAnCNC,EAA+D,iBAC/DC,EAAwB,iCACxBC,EAA0E,yBAC1EC,EAOO,kBACPC,EAAoC,8BACpCA,EAAsC,8BACtCC,EAAmD,+BACnDC,EAAsG,mBACtGC,EAA+B,2BAE/B,MAAMC,KAAc,QAAK,IAAM,OAAO,sBAAsB,CAAC,EACvDC,KAAiB,QAAK,IAAM,OAAO,yBAAyB,CAAC,EAC7D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AK,MAAM,KACrF,OAAC,aAAU,UAAU,uBAAuB,GAC9C,IATQJ,CAUV,CAEJ,CAAC,EACH,GACF,CAEJ",
6
- "names": ["MemberPopup_exports", "__export", "MemberPopup", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_type", "import_provider", "import_viewStack", "import_icons", "import_constants", "EarnCredits", "ConsumeCredits", "Referral", "CompleteProfile", "ActivitiesSubscribe", "SubscribeEmail", "Activate", "RedeemCoupon", "copy", "bottomOffset", "providerProps", "MemberPopupContent", "profile", "openSignInPopup", "openSignUpPopup", "brand", "storeDomain", "rounded", "isLogin", "isOpen", "setIsOpen", "viewStack", "setViewStack", "isSubscribeSuccess", "setIsSubscribeSuccess", "isActivateSuccess", "setIsActivateSuccess", "isProfileCompleteSuccess", "setIsProfileCompleteSuccess", "isSubscribeFormHidden", "setIsSubscribeFormHidden", "currentView", "isVisible", "config", "pathname", "matches", "page", "pushView", "view", "prev", "popView", "handleAction", "type", "url", "handleClose", "cn", "e", "item", "i", "HomeCard", "onAction", "ACTION_ICON", "link", "IconComponent"]
4
+ "sourcesContent": ["'use client'\n\nimport { lazy, Suspense, useState, useCallback, useMemo, useEffect } from 'react'\nimport { Picture } from '@anker-in/headless-ui'\nimport { type HeadlessConfig, useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport {\n MemberPopupActionType,\n MemberPopupPageScope,\n MemberPopupPanelType,\n type MemberPopupCopy,\n type MemberPopupContextValue,\n type MemberPopupItem,\n} from './type'\nimport { MemberPopupProvider } from './context/provider'\nimport { useMemberPopupContext } from './context/provider'\nimport { ViewStackContext, type ViewPayload } from './context/viewStack'\nimport { IconClose, IconArrow, IconCredit, IconBag, IconReferral, IconSwitch, IconSubscription } from './icons'\nimport { ROUNDED_BRANDS } from '../../constants'\n\nconst EarnCredits = lazy(() => import('./panels/EarnCredits'))\nconst ConsumeCredits = lazy(() => import('./panels/ConsumeCredits'))\nconst Referral = lazy(() => import('./panels/Referral'))\nconst CompleteProfile = lazy(() => import('./panels/EarnCredits/CompleteProfilePanel'))\nconst ActivitiesSubscribe = lazy(() => import('./panels/ActivitiesSubscribePanel'))\nconst SubscribeEmail = lazy(() => import('./panels/EarnCredits/SubscribeEmailPanel'))\nconst Activate = lazy(() => import('./panels/EarnCredits/ActivatePanel'))\nconst RedeemCoupon = lazy(() => import('./panels/ConsumeCredits/RedeemCouponPanel'))\n\ntype MemberPopupProps = MemberPopupContextValue & {\n headlessConfig: HeadlessConfig\n copy: MemberPopupCopy\n bottomOffset?: string\n}\n\nexport function MemberPopup({ copy, bottomOffset = '24px', ...providerProps }: MemberPopupProps) {\n const isVisible = useMemo(() => {\n const config = copy.pageConfig\n if (!config) return true\n const pathname = typeof window !== 'undefined' ? window.location.pathname : ''\n const matches = config.pages.some(page => pathname === page || pathname.startsWith(page + '/'))\n switch (config.scope) {\n case MemberPopupPageScope.Include:\n return matches\n case MemberPopupPageScope.Exclude:\n return !matches\n default:\n return true\n }\n }, [copy.pageConfig])\n\n console.log('isVisible', isVisible)\n\n return isVisible ? (\n <MemberPopupProvider {...providerProps} earnCreditsCopy={copy.earnCredits}>\n <MemberPopupContent copy={copy} bottomOffset={bottomOffset} />\n </MemberPopupProvider>\n ) : null\n}\n\ntype MemberPopupContentProps = {\n copy: MemberPopupCopy\n bottomOffset: string\n}\n\nfunction MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {\n const { profile, openSignInPopup, openSignUpPopup } = useMemberPopupContext()\n const { brand, storeDomain } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n const isLogin = !!profile\n const [isOpen, setIsOpen] = useState(false)\n const [viewStack, setViewStack] = useState<ViewPayload[]>([])\n const [isSubscribeSuccess, setIsSubscribeSuccess] = useState(false)\n const [isActivateSuccess, setIsActivateSuccess] = useState(false)\n const [isProfileCompleteSuccess, setIsProfileCompleteSuccess] = useState(false)\n const [isSubscribeFormHidden, setIsSubscribeFormHidden] = useState(false)\n\n const currentView = viewStack[viewStack.length - 1] ?? null\n\n const pushView = useCallback((view: ViewPayload) => {\n setViewStack(prev => [...prev, view])\n }, [])\n\n const popView = useCallback(() => {\n setViewStack(prev => prev.slice(0, -1))\n }, [])\n\n function handleAction(type: MemberPopupActionType, url?: string) {\n switch (type) {\n case MemberPopupActionType.ExternalLink:\n if (url) window.open(url, '_blank', 'noopener,noreferrer')\n break\n case MemberPopupActionType.OpenEarnCredits:\n pushView({ type: MemberPopupPanelType.EarnCredits })\n break\n case MemberPopupActionType.OpenConsumeCredits:\n pushView({ type: MemberPopupPanelType.ConsumeCredits })\n break\n case MemberPopupActionType.OpenReferral:\n pushView({ type: MemberPopupPanelType.Referral })\n break\n case MemberPopupActionType.OpenSubscribe:\n pushView({ type: MemberPopupPanelType.Subscribe })\n break\n }\n }\n\n function handleClose() {\n setIsOpen(false)\n setViewStack([])\n setIsSubscribeFormHidden(false)\n }\n\n return (\n <ViewStackContext.Provider value={{ pushView, popView }}>\n {isOpen && <div className=\"fixed inset-0 z-[998]\" onClick={handleClose} />}\n <div\n className=\"fixed right-0 z-[999] flex flex-row items-end pr-[16px] md:flex-col md:items-end md:right-0 md:w-screen md:pr-0 md:pl-0\"\n style={{ bottom: bottomOffset }}\n >\n {isOpen && (\n <div\n className={cn(\n 'relative mr-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[500px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] md:mr-0 md:mb-[8px] md:mx-[16px] md:w-[calc(100vw-32px)] md:max-w-[400px]',\n rounded ? 'rounded-[12px]' : 'rounded-none'\n )}\n style={{ maxHeight: 'min(80vh, 606px)' }}\n onClick={e => e.stopPropagation()}\n >\n <div className=\"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white md:bottom-[-8px] md:left-auto md:right-[29px] md:top-auto md:border-x-8 md:border-b-transparent md:border-t-white\" />\n <div className=\"flex items-center justify-end pl-[10px] pr-[16px] pb-[8px] pt-[16px]\">\n {currentView !== null && (\n <button\n className=\"mr-auto flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={popView}\n aria-label=\"Back\"\n >\n <IconSwitch />\n </button>\n )}\n <button\n className=\"flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={handleClose}\n aria-label=\"Close\"\n >\n <IconClose />\n </button>\n </div>\n\n <div className=\"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]\">\n {currentView === null && (\n <>\n {(copy.title || copy.subtitle) && (\n <div className=\"flex flex-col gap-[4px]\">\n {copy.title && (\n <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>\n )}\n {copy.subtitle && (\n <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>\n )}\n </div>\n )}\n {copy.list.map((item, i) => (\n <HomeCard key={i} item={item} onAction={handleAction} rounded={rounded} />\n ))}\n </>\n )}\n\n {currentView !== null && (\n <Suspense\n fallback={\n <div className=\"flex items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n }\n >\n {currentView.type === MemberPopupPanelType.EarnCredits && copy.earnCredits && (\n <EarnCredits\n copy={copy.earnCredits}\n onClose={popView}\n isProfileCompleteSuccess={isProfileCompleteSuccess}\n isSubscribeSuccess={isSubscribeSuccess}\n isActivateSuccess={isActivateSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.ConsumeCredits && copy.consumeCredits && (\n <ConsumeCredits\n copy={copy.consumeCredits}\n onClose={popView}\n isActivateSuccess={isActivateSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Referral && copy.referral && (\n <Referral copy={copy.referral} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.CompleteProfile && copy.earnCredits && (\n <CompleteProfile\n copy={copy.earnCredits.completeProfile}\n shopifyStoreDomain={storeDomain}\n onClose={popView}\n onSuccess={() => setIsProfileCompleteSuccess(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.Subscribe && copy.activitiesSubscribe && (\n <ActivitiesSubscribe\n copy={copy.activitiesSubscribe}\n email={profile?.email}\n onSuccess={() => setIsSubscribeSuccess(true)}\n hideForm={isSubscribeFormHidden}\n onHideForm={() => setIsSubscribeFormHidden(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.SubscribeEmail && copy.earnCredits && (\n <SubscribeEmail\n copy={copy.earnCredits.subscribe}\n email={profile?.email}\n onClose={popView}\n onSuccess={() => setIsSubscribeSuccess(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.Activate && copy.earnCredits && (\n <Activate\n copy={copy.earnCredits.authCodeActivate}\n onClose={popView}\n onSuccess={() => {\n setIsActivateSuccess(true)\n }}\n />\n )}\n {currentView.type === MemberPopupPanelType.RedeemCoupon &&\n currentView.props &&\n copy.consumeCredits && (\n <RedeemCoupon\n itemTitle={currentView.props.itemTitle}\n itemCredits={currentView.props.itemCredits}\n itemImage={currentView.props.itemImage}\n itemValue={currentView.props.itemValue}\n itemOff={currentView.props.itemOff}\n itemRules={currentView.props.itemRules}\n redeemId={currentView.props.redeemId}\n userId={currentView.props.userId}\n alpcConfig={currentView.props.alpcConfig}\n copy={copy.consumeCredits.redeemModal}\n pointUnit={copy.consumeCredits.pointUnit}\n onClose={popView}\n />\n )}\n </Suspense>\n )}\n </div>\n\n {copy.footer && !isLogin && (\n <div className=\"border-t border-[#dadce0] p-[16px]\">\n <div className=\"flex items-center justify-between gap-[16px]\">\n <div className=\"flex items-center gap-[4px]\">\n <span className=\"text-[14px] font-[700] text-[#080a0f]\">{copy.footer.loginHint}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline\"\n onClick={openSignInPopup}\n >\n {copy.footer.loginLabel}\n </button>\n </div>\n <div className=\"flex shrink-0 items-center gap-[8px]\">\n <button\n className={cn(\n 'cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n onClick={openSignUpPopup}\n >\n {copy.footer.joinLabel}\n </button>\n </div>\n </div>\n </div>\n )}\n </div>\n )}\n\n <button\n className=\"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg md:ml-auto md:mr-[16px]\"\n onClick={() => setIsOpen(prev => !prev)}\n aria-label={copy.triggerImg.alt ?? 'Open member popup'}\n >\n <Picture source={copy.triggerImg.url} alt={copy.triggerImg.alt ?? ''} className=\"size-[58px]\" />\n </button>\n </div>\n </ViewStackContext.Provider>\n )\n}\n\ntype HomeCardProps = {\n item: MemberPopupItem\n onAction: (type: MemberPopupActionType, url?: string) => void\n rounded: boolean\n}\n\nfunction HomeCard({ item, onAction, rounded }: HomeCardProps) {\n const ACTION_ICON: Partial<Record<MemberPopupActionType, typeof IconCredit>> = {\n [MemberPopupActionType.OpenEarnCredits]: IconCredit,\n [MemberPopupActionType.OpenConsumeCredits]: IconBag,\n [MemberPopupActionType.OpenReferral]: IconReferral,\n [MemberPopupActionType.OpenSubscribe]: IconSubscription,\n }\n\n return (\n <div className={cn('flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <div className=\"flex flex-col gap-[4px]\">\n <h3 className=\"text-[20px] font-[700] leading-[1.2] text-[#1e2024]\">{item.title}</h3>\n {item.description && <p className=\"text-[14px] font-[700] leading-[1.43] text-[#1e2024]\">{item.description}</p>}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n {item.links.map((link, i) => {\n const IconComponent = ACTION_ICON[link.type]\n return (\n <div key={i}>\n {i > 0 && <div className=\"mb-[16px] h-px bg-[#dadce0]\" />}\n <button\n className=\"flex w-full cursor-pointer items-center gap-[12px]\"\n onClick={() => onAction(link.type, link.url)}\n >\n {IconComponent && <IconComponent className=\"size-[24px] shrink-0\" />}\n <span className=\"flex-1 text-left text-[14px] font-[700] text-[#1e2024]\">{link.label}</span>\n <I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AAU,2BACZ,SAAAA,EAAK,MAAM,IAAI,CAACK,EAAMJ,IAAM,CAC3B,MAAMK,EAAgBF,EAAYC,EAAK,IAAI,EAC3C,SACE,QAAC,OACE,UAAAJ,EAAI,MAAK,OAAC,OAAI,UAAU,8BAA8B,KACvD,QAAC,UACC,UAAU,qDACV,QAAS,IAAME,EAASE,EAAK,KAAMA,EAAK,GAAG,EAE1C,UAAAC,MAAiB,OAACA,EAAA,CAAc,UAAU,uBAAuB,KAClE,OAAC,QAAK,UAAU,yDAA0D,SAAAD,EAAK,MAAM,KACrF,OAAC,aAAU,UAAU,uBAAuB,GAC9C,IATQJ,CAUV,CAEJ,CAAC,EACH,GACF,CAEJ",
6
+ "names": ["MemberPopup_exports", "__export", "MemberPopup", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_type", "import_provider", "import_viewStack", "import_icons", "import_constants", "EarnCredits", "ConsumeCredits", "Referral", "CompleteProfile", "ActivitiesSubscribe", "SubscribeEmail", "Activate", "RedeemCoupon", "copy", "bottomOffset", "providerProps", "isVisible", "config", "pathname", "matches", "page", "MemberPopupContent", "profile", "openSignInPopup", "openSignUpPopup", "brand", "storeDomain", "rounded", "isLogin", "isOpen", "setIsOpen", "viewStack", "setViewStack", "isSubscribeSuccess", "setIsSubscribeSuccess", "isActivateSuccess", "setIsActivateSuccess", "isProfileCompleteSuccess", "setIsProfileCompleteSuccess", "isSubscribeFormHidden", "setIsSubscribeFormHidden", "currentView", "pushView", "view", "prev", "popView", "handleAction", "type", "url", "handleClose", "cn", "e", "item", "i", "HomeCard", "onAction", "ACTION_ICON", "link", "IconComponent"]
7
7
  }
@@ -5,9 +5,6 @@ type Props = {
5
5
  isSubscribeSuccess?: boolean;
6
6
  isActivateSuccess?: boolean;
7
7
  isProfileCompleteSuccess?: boolean;
8
- onSubscribeSuccess?: () => void;
9
- onActivateSuccess?: () => void;
10
- onProfileCompleteSuccess?: () => void;
11
8
  };
12
- declare function EarnCredits({ copy, onClose, isSubscribeSuccess, isActivateSuccess, isProfileCompleteSuccess, onSubscribeSuccess, onActivateSuccess, onProfileCompleteSuccess, }: Props): import("react/jsx-runtime").JSX.Element;
9
+ declare function EarnCredits({ copy, onClose, isSubscribeSuccess, isActivateSuccess, isProfileCompleteSuccess, }: Props): import("react/jsx-runtime").JSX.Element;
13
10
  export default EarnCredits;
@@ -1,2 +1,2 @@
1
- "use strict";var g=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var F=(t,s)=>{for(var d in s)g(t,d,{get:s[d],enumerable:!0})},O=(t,s,d,f)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of R(s))!y.call(t,o)&&o!==d&&g(t,o,{get:()=>s[o],enumerable:!(f=M(s,o))||f.enumerable});return t};var V=t=>O(g({},"__esModule",{value:!0}),t);var G={};F(G,{default:()=>q});module.exports=V(G);var e=require("react/jsx-runtime"),m=require("react"),p=require("@anker-in/lib"),w=require("../../context/provider"),P=require("../../context/viewStack"),E=require("./hooks/useSubscribed"),n=require("../../type"),r=require("../../icons"),N=require("../../../credits/context/utils"),T=require("../../../../constants");function z({id:t,className:s}){switch(t){case n.EarnCreditsTaskType.Activate:return(0,e.jsx)(r.IconLock,{className:s});case n.EarnCreditsTaskType.Subscribe:return(0,e.jsx)(r.IconSubscription,{className:s});case n.EarnCreditsTaskType.Shop:return(0,e.jsx)(r.IconBag,{className:s});case n.EarnCreditsTaskType.CompleteProfile:return(0,e.jsx)(r.IconOrders,{className:s})}}function H({copy:t,onClose:s,isSubscribeSuccess:d=!1,isActivateSuccess:f=!1,isProfileCompleteSuccess:o=!1,onSubscribeSuccess:I,onActivateSuccess:_,onProfileCompleteSuccess:A}){const{profile:a,openSignUpPopup:x,alpcConfig:h,creditInfo:b}=(0,w.useMemberPopupContext)(),{pushView:u}=(0,P.useViewStack)(),{locale:B}=h,{brand:C}=(0,p.useHeadlessContext)(),v=T.ROUNDED_BRANDS.includes(C);console.log("creditInfo",b);const l=!!a,k=(0,E.useSubscribed)({userId:a?.user_id,brand:C,email:a?.email,locale:B,apiBaseUrl:h.apiBaseUrl}),S=(0,m.useMemo)(()=>o||!!(a?.first_name||a?.last_name)&&!!a?.phone_number&&!!a?.dob,[a,o]),L=(0,m.useMemo)(()=>({[n.EarnCreditsTaskType.Activate]:{finished:!!a?.activated||f,onClick:l?()=>u({type:n.MemberPopupPanelType.Activate,props:{onSuccess:_}}):x},[n.EarnCreditsTaskType.CompleteProfile]:{finished:S,onClick:l?()=>u({type:n.MemberPopupPanelType.CompleteProfile,props:{onSuccess:A}}):x},[n.EarnCreditsTaskType.Subscribe]:{finished:k||d,onClick:l?()=>u({type:n.MemberPopupPanelType.SubscribeEmail,props:{onSuccess:I}}):x},[n.EarnCreditsTaskType.Shop]:{finished:!1,link:t.goShopLink,onClick:l?void 0:x}}),[a,l,f,o,S,k,d,x,u,t.goShopLink]),U=(0,m.useMemo)(()=>t.list.map(i=>{const c=L[i.id];if(!c)return null;const D=c.finished?t.completed:l?j(i.id,t):t.joinNow;return{...i,...c,buttonLabel:D}}).filter(Boolean),[t,L,l]);return(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[(0,e.jsx)("div",{className:"flex flex-col gap-[8px]",children:t.title&&(0,e.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title})}),l&&(0,e.jsxs)("div",{className:(0,p.classNames)("flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]",v?"rounded-[8px]":"rounded-none"),children:[(0,e.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,e.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:t.balanceLabel??"AnkerCredits Balance"}),(0,e.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,e.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,N.numberFormat)(b?.available_credit??0)}),(0,e.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:t.creditUnit??"ankercredits"})]})]}),(0,e.jsx)("div",{className:"h-full w-px bg-[#dadce0]"}),(0,e.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,e.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:t.comingSoonLabel??"Coming Soon"}),(0,e.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,e.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,N.numberFormat)(b?.pending_credit??0)}),(0,e.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:t.creditUnit??"ankercredits"})]})]})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[t.subtitle&&(0,e.jsx)("p",{className:"text-[16px] font-[700] text-[#1e2024]",children:t.subtitle}),(0,e.jsx)("div",{className:"flex flex-col",children:U.map((i,c)=>(0,e.jsxs)("div",{className:"relative py-[16px]",children:[c>0&&(0,e.jsx)("div",{className:"absolute left-0 right-0 top-0 h-px bg-[#dadce0]"}),(0,e.jsxs)("div",{className:(0,p.classNames)("flex items-center gap-[12px]",i.finished&&"opacity-60"),children:[(0,e.jsx)(z,{id:i.id,className:"size-[24px] shrink-0"}),(0,e.jsxs)("div",{className:"flex-1",children:[(0,e.jsx)("div",{className:"text-[16px] font-[700] text-[#1e2024]",children:i.title}),i.description&&(0,e.jsx)("div",{className:"mt-[4px] text-[14px] font-[700] text-[#4a4c56]",children:i.description})]}),!i.finished&&i.link&&l?(0,e.jsx)("a",{href:i.link,target:"_blank",rel:"noopener noreferrer",className:(0,p.classNames)("cursor-pointer bg-[#080a0f] min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",v?"rounded-[4px]":"rounded-none"),children:i.buttonLabel}):(0,e.jsx)("button",{className:(0,p.classNames)("cursor-pointer min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",i.finished?"bg-[#767880]":"bg-[#080a0f]",v?"rounded-[4px]":"rounded-none"),disabled:i.finished,onClick:i.finished?void 0:i.onClick,children:i.buttonLabel})]})]},c))})]})]})}function j(t,s){switch(t){case n.EarnCreditsTaskType.Activate:return s.activate;case n.EarnCreditsTaskType.CompleteProfile:return s.completeProfileLabel;case n.EarnCreditsTaskType.Subscribe:return s.subscribeLabel;case n.EarnCreditsTaskType.Shop:return s.shopNow}}var q=H;
1
+ "use strict";var g=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var M=(t,i)=>{for(var d in i)g(t,d,{get:i[d],enumerable:!0})},R=(t,i,d,f)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of U(i))!D.call(t,o)&&o!==d&&g(t,o,{get:()=>i[o],enumerable:!(f=B(i,o))||f.enumerable});return t};var y=t=>R(g({},"__esModule",{value:!0}),t);var H={};M(H,{default:()=>z});module.exports=y(H);var e=require("react/jsx-runtime"),u=require("react"),p=require("@anker-in/lib"),w=require("../../context/provider"),E=require("../../context/viewStack"),P=require("./hooks/useSubscribed"),a=require("../../type"),r=require("../../icons"),N=require("../../../credits/context/utils"),T=require("../../../../constants");function F({id:t,className:i}){switch(t){case a.EarnCreditsTaskType.Activate:return(0,e.jsx)(r.IconLock,{className:i});case a.EarnCreditsTaskType.Subscribe:return(0,e.jsx)(r.IconSubscription,{className:i});case a.EarnCreditsTaskType.Shop:return(0,e.jsx)(r.IconBag,{className:i});case a.EarnCreditsTaskType.CompleteProfile:return(0,e.jsx)(r.IconOrders,{className:i})}}function O({copy:t,onClose:i,isSubscribeSuccess:d=!1,isActivateSuccess:f=!1,isProfileCompleteSuccess:o=!1}){const{profile:s,openSignUpPopup:x,alpcConfig:h,creditInfo:b}=(0,w.useMemberPopupContext)(),{pushView:m}=(0,E.useViewStack)(),{locale:I}=h,{brand:C}=(0,p.useHeadlessContext)(),v=T.ROUNDED_BRANDS.includes(C);console.log("creditInfo",b);const l=!!s,k=(0,P.useSubscribed)({userId:s?.user_id,brand:C,email:s?.email,locale:I,apiBaseUrl:h.apiBaseUrl}),S=(0,u.useMemo)(()=>o||!!(s?.first_name||s?.last_name)&&!!s?.phone_number&&!!s?.dob,[s,o]),L=(0,u.useMemo)(()=>({[a.EarnCreditsTaskType.Activate]:{finished:!!s?.activated||f,onClick:l?()=>m({type:a.MemberPopupPanelType.Activate}):x},[a.EarnCreditsTaskType.CompleteProfile]:{finished:S,onClick:l?()=>m({type:a.MemberPopupPanelType.CompleteProfile}):x},[a.EarnCreditsTaskType.Subscribe]:{finished:k||d,onClick:l?()=>m({type:a.MemberPopupPanelType.SubscribeEmail}):x},[a.EarnCreditsTaskType.Shop]:{finished:!1,link:t.goShopLink,onClick:l?void 0:x}}),[s,l,f,o,S,k,d,x,m,t.goShopLink]),_=(0,u.useMemo)(()=>t.list.map(n=>{const c=L[n.id];if(!c)return null;const A=c.finished?t.completed:l?V(n.id,t):t.joinNow;return{...n,...c,buttonLabel:A}}).filter(Boolean),[t,L,l]);return(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[(0,e.jsx)("div",{className:"flex flex-col gap-[8px]",children:t.title&&(0,e.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title})}),l&&(0,e.jsxs)("div",{className:(0,p.classNames)("flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]",v?"rounded-[8px]":"rounded-none"),children:[(0,e.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,e.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:t.balanceLabel??"AnkerCredits Balance"}),(0,e.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,e.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,N.numberFormat)(b?.available_credit??0)}),(0,e.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:t.creditUnit??"ankercredits"})]})]}),(0,e.jsx)("div",{className:"h-full w-px bg-[#dadce0]"}),(0,e.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,e.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:t.comingSoonLabel??"Coming Soon"}),(0,e.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,e.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,N.numberFormat)(b?.pending_credit??0)}),(0,e.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:t.creditUnit??"ankercredits"})]})]})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[t.subtitle&&(0,e.jsx)("p",{className:"text-[16px] font-[700] text-[#1e2024]",children:t.subtitle}),(0,e.jsx)("div",{className:"flex flex-col",children:_.map((n,c)=>(0,e.jsxs)("div",{className:"relative py-[16px]",children:[c>0&&(0,e.jsx)("div",{className:"absolute left-0 right-0 top-0 h-px bg-[#dadce0]"}),(0,e.jsxs)("div",{className:(0,p.classNames)("flex items-center gap-[12px]",n.finished&&"opacity-60"),children:[(0,e.jsx)(F,{id:n.id,className:"size-[24px] shrink-0"}),(0,e.jsxs)("div",{className:"flex-1",children:[(0,e.jsx)("div",{className:"text-[16px] font-[700] text-[#1e2024]",children:n.title}),n.description&&(0,e.jsx)("div",{className:"mt-[4px] text-[14px] font-[700] text-[#4a4c56]",children:n.description})]}),!n.finished&&n.link&&l?(0,e.jsx)("a",{href:n.link,target:"_blank",rel:"noopener noreferrer",className:(0,p.classNames)("cursor-pointer bg-[#080a0f] min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",v?"rounded-[4px]":"rounded-none"),children:n.buttonLabel}):(0,e.jsx)("button",{className:(0,p.classNames)("cursor-pointer min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",n.finished?"bg-[#767880]":"bg-[#080a0f]",v?"rounded-[4px]":"rounded-none"),disabled:n.finished,onClick:n.finished?void 0:n.onClick,children:n.buttonLabel})]})]},c))})]})]})}function V(t,i){switch(t){case a.EarnCreditsTaskType.Activate:return i.activate;case a.EarnCreditsTaskType.CompleteProfile:return i.completeProfileLabel;case a.EarnCreditsTaskType.Subscribe:return i.subscribeLabel;case a.EarnCreditsTaskType.Shop:return i.shopNow}}var z=O;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/EarnCredits/index.tsx"],
4
- "sourcesContent": ["import { useMemo } from 'react'\nimport { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useSubscribed } from './hooks/useSubscribed'\nimport { EarnCreditsTaskType, MemberPopupPanelType, type EarnCreditsCopy } from '../../type'\nimport { IconBag, IconLock, IconSubscription, IconOrders } from '../../icons'\nimport { numberFormat } from '../../../credits/context/utils'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\nfunction TaskIcon({ id, className }: { id: EarnCreditsTaskType; className?: string }) {\n switch (id) {\n case EarnCreditsTaskType.Activate:\n return <IconLock className={className} />\n case EarnCreditsTaskType.Subscribe:\n return <IconSubscription className={className} />\n case EarnCreditsTaskType.Shop:\n return <IconBag className={className} />\n case EarnCreditsTaskType.CompleteProfile:\n return <IconOrders className={className} />\n }\n}\n\ntype Props = {\n copy: EarnCreditsCopy\n onClose: () => void\n isSubscribeSuccess?: boolean\n isActivateSuccess?: boolean\n isProfileCompleteSuccess?: boolean\n onSubscribeSuccess?: () => void\n onActivateSuccess?: () => void\n onProfileCompleteSuccess?: () => void\n}\n\nfunction EarnCredits({\n copy,\n onClose,\n isSubscribeSuccess = false,\n isActivateSuccess = false,\n isProfileCompleteSuccess = false,\n onSubscribeSuccess,\n onActivateSuccess,\n onProfileCompleteSuccess,\n}: Props) {\n const { profile, openSignUpPopup, alpcConfig, creditInfo } = useMemberPopupContext()\n const { pushView } = useViewStack()\n const { locale } = alpcConfig\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n console.log('creditInfo', creditInfo)\n\n const isLogin = !!profile\n\n const isSubscribed = useSubscribed({\n userId: profile?.user_id,\n brand: brand,\n email: profile?.email,\n locale,\n apiBaseUrl: alpcConfig.apiBaseUrl,\n })\n\n const profileCompleted = useMemo(() => {\n return (\n isProfileCompleteSuccess ||\n (!!(profile?.first_name || profile?.last_name) && !!profile?.phone_number && !!profile?.dob)\n )\n }, [profile, isProfileCompleteSuccess])\n\n const taskStates: Record<EarnCreditsTaskType, { finished: boolean; onClick?: () => void; link?: string }> = useMemo(\n () => ({\n [EarnCreditsTaskType.Activate]: {\n finished: !!profile?.activated || isActivateSuccess,\n onClick: isLogin\n ? () =>\n pushView({\n type: MemberPopupPanelType.Activate,\n props: { onSuccess: onActivateSuccess },\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.CompleteProfile]: {\n finished: profileCompleted,\n onClick: isLogin\n ? () =>\n pushView({\n type: MemberPopupPanelType.CompleteProfile,\n props: { onSuccess: onProfileCompleteSuccess },\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.Subscribe]: {\n finished: isSubscribed || isSubscribeSuccess,\n onClick: isLogin\n ? () =>\n pushView({\n type: MemberPopupPanelType.SubscribeEmail,\n props: { onSuccess: onSubscribeSuccess },\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.Shop]: {\n finished: false,\n link: copy.goShopLink,\n onClick: isLogin ? undefined : openSignUpPopup,\n },\n }),\n [\n profile,\n isLogin,\n isActivateSuccess,\n isProfileCompleteSuccess,\n profileCompleted,\n isSubscribed,\n isSubscribeSuccess,\n openSignUpPopup,\n pushView,\n copy.goShopLink,\n ]\n )\n\n const list = useMemo(() => {\n return copy.list\n .map(item => {\n const state = taskStates[item.id]\n if (!state) return null\n const buttonLabel = state.finished\n ? copy.completed\n : isLogin\n ? getNotFinishedLabel(item.id, copy)\n : copy.joinNow\n return { ...item, ...state, buttonLabel }\n })\n .filter(Boolean) as ((typeof copy.list)[number] & {\n finished: boolean\n onClick?: () => void\n link?: string\n buttonLabel: string\n })[]\n }, [copy, taskStates, isLogin])\n\n return (\n <div className=\"flex flex-col gap-[16px]\">\n <div className=\"flex flex-col gap-[16px]\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\n </div>\n\n {isLogin && (\n <div\n className={cn(\n 'flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]',\n rounded ? 'rounded-[8px]' : 'rounded-none'\n )}\n >\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.balanceLabel ?? 'AnkerCredits Balance'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.available_credit ?? 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n <div className=\"h-full w-px bg-[#dadce0]\" />\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.comingSoonLabel ?? 'Coming Soon'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.pending_credit ?? 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n </div>\n )}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n {copy.subtitle && <p className=\"text-[16px] font-[700] text-[#1e2024]\">{copy.subtitle}</p>}\n\n <div className=\"flex flex-col\">\n {list.map((item, idx) => (\n <div key={idx} className=\"relative py-[16px]\">\n {idx > 0 && <div className=\"absolute left-0 right-0 top-0 h-px bg-[#dadce0]\" />}\n <div className={cn('flex items-center gap-[12px]', item.finished && 'opacity-60')}>\n <TaskIcon id={item.id} className=\"size-[24px] shrink-0\" />\n <div className=\"flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024]\">{item.title}</div>\n {item.description && (\n <div className=\"mt-[4px] text-[14px] font-[700] text-[#4a4c56]\">{item.description}</div>\n )}\n </div>\n {!item.finished && item.link && isLogin ? (\n <a\n href={item.link}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={cn(\n 'cursor-pointer bg-[#080a0f] min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n >\n {item.buttonLabel}\n </a>\n ) : (\n <button\n className={cn(\n 'cursor-pointer min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n item.finished ? 'bg-[#767880]' : 'bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={item.finished}\n onClick={!item.finished ? item.onClick : undefined}\n >\n {item.buttonLabel}\n </button>\n )}\n </div>\n </div>\n ))}\n </div>\n </div>\n </div>\n )\n}\n\nfunction getNotFinishedLabel(id: EarnCreditsTaskType, copy: EarnCreditsCopy): string {\n switch (id) {\n case EarnCreditsTaskType.Activate:\n return copy.activate\n case EarnCreditsTaskType.CompleteProfile:\n return copy.completeProfileLabel\n case EarnCreditsTaskType.Subscribe:\n return copy.subscribeLabel\n case EarnCreditsTaskType.Shop:\n return copy.shopNow\n }\n}\n\nexport default EarnCredits\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE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kB,cAC9B,EAEC,SAAAM,EAAK,YACR,KAEA,OAAC,UACC,aAAW,EAAAI,YACT,6GACAJ,EAAK,SAAW,eAAiB,eACjCN,EAAU,gBAAkB,cAC9B,EACA,SAAUM,EAAK,SACf,QAAUA,EAAK,SAA0B,OAAfA,EAAK,QAE9B,SAAAA,EAAK,YACR,GAEJ,IAnCQK,CAoCV,CACD,EACH,GACF,GACF,CAEJ,CAEA,SAASF,EAAoB3B,EAAyBG,EAA+B,CACnF,OAAQH,EAAI,CACV,KAAK,sBAAoB,SACvB,OAAOG,EAAK,SACd,KAAK,sBAAoB,gBACvB,OAAOA,EAAK,qBACd,KAAK,sBAAoB,UACvB,OAAOA,EAAK,eACd,KAAK,sBAAoB,KACvB,OAAOA,EAAK,OAChB,CACF,CAEA,IAAOhB,EAAQe",
6
- "names": ["EarnCredits_exports", "__export", "EarnCredits_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_lib", "import_provider", "import_viewStack", "import_useSubscribed", "import_type", "import_icons", "import_utils", "import_constants", "TaskIcon", "id", "className", "EarnCredits", "copy", "onClose", "isSubscribeSuccess", "isActivateSuccess", "isProfileCompleteSuccess", "onSubscribeSuccess", "onActivateSuccess", "onProfileCompleteSuccess", "profile", "openSignUpPopup", "alpcConfig", "creditInfo", "pushView", "locale", "brand", "rounded", "isLogin", "isSubscribed", "profileCompleted", "taskStates", "list", "item", "state", "buttonLabel", "getNotFinishedLabel", "cn", "idx"]
4
+ "sourcesContent": ["import { useMemo } from 'react'\nimport { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useSubscribed } from './hooks/useSubscribed'\nimport { EarnCreditsTaskType, MemberPopupPanelType, type EarnCreditsCopy } from '../../type'\nimport { IconBag, IconLock, IconSubscription, IconOrders } from '../../icons'\nimport { numberFormat } from '../../../credits/context/utils'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\nfunction TaskIcon({ id, className }: { id: EarnCreditsTaskType; className?: string }) {\n switch (id) {\n case EarnCreditsTaskType.Activate:\n return <IconLock className={className} />\n case EarnCreditsTaskType.Subscribe:\n return <IconSubscription className={className} />\n case EarnCreditsTaskType.Shop:\n return <IconBag className={className} />\n case EarnCreditsTaskType.CompleteProfile:\n return <IconOrders className={className} />\n }\n}\n\ntype Props = {\n copy: EarnCreditsCopy\n onClose: () => void\n isSubscribeSuccess?: boolean\n isActivateSuccess?: boolean\n isProfileCompleteSuccess?: boolean\n}\n\nfunction EarnCredits({\n copy,\n onClose,\n isSubscribeSuccess = false,\n isActivateSuccess = false,\n isProfileCompleteSuccess = false,\n}: Props) {\n const { profile, openSignUpPopup, alpcConfig, creditInfo } = useMemberPopupContext()\n const { pushView } = useViewStack()\n const { locale } = alpcConfig\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n console.log('creditInfo', creditInfo)\n\n const isLogin = !!profile\n\n const isSubscribed = useSubscribed({\n userId: profile?.user_id,\n brand: brand,\n email: profile?.email,\n locale,\n apiBaseUrl: alpcConfig.apiBaseUrl,\n })\n\n const profileCompleted = useMemo(() => {\n return (\n isProfileCompleteSuccess ||\n (!!(profile?.first_name || profile?.last_name) && !!profile?.phone_number && !!profile?.dob)\n )\n }, [profile, isProfileCompleteSuccess])\n\n const taskStates: Record<EarnCreditsTaskType, { finished: boolean; onClick?: () => void; link?: string }> = useMemo(\n () => ({\n [EarnCreditsTaskType.Activate]: {\n finished: !!profile?.activated || isActivateSuccess,\n onClick: isLogin\n ? () =>\n pushView({\n type: MemberPopupPanelType.Activate,\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.CompleteProfile]: {\n finished: profileCompleted,\n onClick: isLogin\n ? () =>\n pushView({\n type: MemberPopupPanelType.CompleteProfile,\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.Subscribe]: {\n finished: isSubscribed || isSubscribeSuccess,\n onClick: isLogin\n ? () =>\n pushView({\n type: MemberPopupPanelType.SubscribeEmail,\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.Shop]: {\n finished: false,\n link: copy.goShopLink,\n onClick: isLogin ? undefined : openSignUpPopup,\n },\n }),\n [\n profile,\n isLogin,\n isActivateSuccess,\n isProfileCompleteSuccess,\n profileCompleted,\n isSubscribed,\n isSubscribeSuccess,\n openSignUpPopup,\n pushView,\n copy.goShopLink,\n ]\n )\n\n const list = useMemo(() => {\n return copy.list\n .map(item => {\n const state = taskStates[item.id]\n if (!state) return null\n const buttonLabel = state.finished\n ? copy.completed\n : isLogin\n ? getNotFinishedLabel(item.id, copy)\n : copy.joinNow\n return { ...item, ...state, buttonLabel }\n })\n .filter(Boolean) as ((typeof copy.list)[number] & {\n finished: boolean\n onClick?: () => void\n link?: string\n buttonLabel: string\n })[]\n }, [copy, taskStates, isLogin])\n\n return (\n <div className=\"flex flex-col gap-[16px]\">\n <div className=\"flex flex-col gap-[16px]\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\n </div>\n\n {isLogin && (\n <div\n className={cn(\n 'flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]',\n rounded ? 'rounded-[8px]' : 'rounded-none'\n )}\n >\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.balanceLabel ?? 'AnkerCredits Balance'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.available_credit ?? 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n <div className=\"h-full w-px bg-[#dadce0]\" />\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.comingSoonLabel ?? 'Coming Soon'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.pending_credit ?? 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n </div>\n )}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n {copy.subtitle && <p className=\"text-[16px] font-[700] text-[#1e2024]\">{copy.subtitle}</p>}\n\n <div className=\"flex flex-col\">\n {list.map((item, idx) => (\n <div key={idx} className=\"relative py-[16px]\">\n {idx > 0 && <div className=\"absolute left-0 right-0 top-0 h-px bg-[#dadce0]\" />}\n <div className={cn('flex items-center gap-[12px]', item.finished && 'opacity-60')}>\n <TaskIcon id={item.id} className=\"size-[24px] shrink-0\" />\n <div className=\"flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024]\">{item.title}</div>\n {item.description && (\n <div className=\"mt-[4px] text-[14px] font-[700] text-[#4a4c56]\">{item.description}</div>\n )}\n </div>\n {!item.finished && item.link && isLogin ? (\n <a\n href={item.link}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={cn(\n 'cursor-pointer bg-[#080a0f] min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n >\n {item.buttonLabel}\n </a>\n ) : (\n <button\n className={cn(\n 'cursor-pointer min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n item.finished ? 'bg-[#767880]' : 'bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={item.finished}\n onClick={!item.finished ? item.onClick : undefined}\n >\n {item.buttonLabel}\n </button>\n )}\n </div>\n </div>\n ))}\n </div>\n </div>\n </div>\n )\n}\n\nfunction getNotFinishedLabel(id: EarnCreditsTaskType, copy: EarnCreditsCopy): string {\n switch (id) {\n case EarnCreditsTaskType.Activate:\n return copy.activate\n case EarnCreditsTaskType.CompleteProfile:\n return copy.completeProfileLabel\n case EarnCreditsTaskType.Subscribe:\n return copy.subscribeLabel\n case EarnCreditsTaskType.Shop:\n return copy.shopNow\n }\n}\n\nexport default EarnCredits\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAaa,IAAAI,EAAA,6BAbbC,EAAwB,iBACxBC,EAAqD,yBACrDC,EAAsC,kCACtCC,EAA6B,mCAC7BC,EAA8B,iCAC9BC,EAAgF,sBAChFC,EAAgE,uBAChEC,EAA6B,0CAC7BC,EAA+B,iCAE/B,SAASC,EAAS,CAAE,GAAAC,EAAI,UAAAC,CAAU,EAAoD,CACpF,OAAQD,EAAI,CACV,KAAK,sBAAoB,SACvB,SAAO,OAAC,YAAS,UAAWC,EAAW,EACzC,KAAK,sBAAoB,UACvB,SAAO,OAAC,oBAAiB,UAAWA,EAAW,EACjD,KAAK,sBAAoB,KACvB,SAAO,OAAC,WAAQ,UAAWA,EAAW,EACxC,KAAK,sBAAoB,gBACvB,SAAO,OAAC,cAAW,UAAWA,EAAW,CAC7C,CACF,CAUA,SAASC,EAAY,CACnB,KAAAC,EACA,QAAAC,EACA,mBAAAC,EAAqB,GACrB,kBAAAC,EAAoB,GACpB,yBAAAC,EAA2B,EAC7B,EAAU,CACR,KAAM,CAAE,QAAAC,EAAS,gBAAAC,EAAiB,WAAAC,EAAY,WAAAC,CAAW,KAAI,yBAAsB,EAC7E,CAAE,SAAAC,CAAS,KAAI,gBAAa,EAC5B,CAAE,OAAAC,CAAO,EAAIH,EACb,CAAE,MAAAI,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,iBAAe,SAASD,CAAK,EAE7C,QAAQ,IAAI,aAAcH,CAAU,EAEpC,MAAMK,EAAU,CAAC,CAACR,EAEZS,KAAe,iBAAc,CACjC,OAAQT,GAAS,QACjB,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AYA,EAAK,MAAQL,KAC9B,OAAC,KACC,KAAMK,EAAK,KACX,OAAO,SACP,IAAI,sBACJ,aAAW,EAAAI,YACT,0HACAV,EAAU,gBAAkB,cAC9B,EAEC,SAAAM,EAAK,YACR,KAEA,OAAC,UACC,aAAW,EAAAI,YACT,6GACAJ,EAAK,SAAW,eAAiB,eACjCN,EAAU,gBAAkB,cAC9B,EACA,SAAUM,EAAK,SACf,QAAUA,EAAK,SAA0B,OAAfA,EAAK,QAE9B,SAAAA,EAAK,YACR,GAEJ,IAnCQK,CAoCV,CACD,EACH,GACF,GACF,CAEJ,CAEA,SAASF,EAAoBxB,EAAyBG,EAA+B,CACnF,OAAQH,EAAI,CACV,KAAK,sBAAoB,SACvB,OAAOG,EAAK,SACd,KAAK,sBAAoB,gBACvB,OAAOA,EAAK,qBACd,KAAK,sBAAoB,UACvB,OAAOA,EAAK,eACd,KAAK,sBAAoB,KACvB,OAAOA,EAAK,OAChB,CACF,CAEA,IAAOhB,EAAQe",
6
+ "names": ["EarnCredits_exports", "__export", "EarnCredits_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_lib", "import_provider", "import_viewStack", "import_useSubscribed", "import_type", "import_icons", "import_utils", "import_constants", "TaskIcon", "id", "className", "EarnCredits", "copy", "onClose", "isSubscribeSuccess", "isActivateSuccess", "isProfileCompleteSuccess", "profile", "openSignUpPopup", "alpcConfig", "creditInfo", "pushView", "locale", "brand", "rounded", "isLogin", "isSubscribed", "profileCompleted", "taskStates", "list", "item", "state", "buttonLabel", "getNotFinishedLabel", "cn", "idx"]
7
7
  }
@@ -5,5 +5,5 @@ type MemberPopupProps = MemberPopupContextValue & {
5
5
  copy: MemberPopupCopy;
6
6
  bottomOffset?: string;
7
7
  };
8
- export declare function MemberPopup({ copy, bottomOffset, ...providerProps }: MemberPopupProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function MemberPopup({ copy, bottomOffset, ...providerProps }: MemberPopupProps): import("react/jsx-runtime").JSX.Element | null;
9
9
  export {};
@@ -1,2 +1,2 @@
1
- "use client";import{Fragment as me,jsx as t,jsxs as r}from"react/jsx-runtime";import{lazy as l,Suspense as F,useState as d,useCallback as O,useMemo as L}from"react";import{Picture as U}from"@anker-in/headless-ui";import{useHeadlessContext as B,classNames as S}from"@anker-in/lib";import{MemberPopupActionType as a,MemberPopupPageScope as V,MemberPopupPanelType as i}from"./type";import{MemberPopupProvider as W}from"./context/provider";import{useMemberPopupContext as q}from"./context/provider";import{ViewStackContext as G}from"./context/viewStack";import{IconClose as J,IconArrow as K,IconCredit as Q,IconBag as X,IconReferral as Y,IconSwitch as Z,IconSubscription as $}from"./icons";import{ROUNDED_BRANDS as ee}from"../../constants";const te=l(()=>import("./panels/EarnCredits")),se=l(()=>import("./panels/ConsumeCredits")),oe=l(()=>import("./panels/Referral")),re=l(()=>import("./panels/EarnCredits/CompleteProfilePanel")),ie=l(()=>import("./panels/ActivitiesSubscribePanel")),ne=l(()=>import("./panels/EarnCredits/SubscribeEmailPanel")),pe=l(()=>import("./panels/EarnCredits/ActivatePanel")),ae=l(()=>import("./panels/ConsumeCredits/RedeemCouponPanel"));function Pe({copy:e,bottomOffset:u="24px",...c}){return t(W,{...c,earnCreditsCopy:e.earnCredits,children:t(le,{copy:e,bottomOffset:u})})}function le({copy:e,bottomOffset:u}){const{profile:c,openSignInPopup:C,openSignUpPopup:m}=q(),{brand:b,storeDomain:x}=B(),g=ee.includes(b),R=!!c,[P,w]=d(!1),[h,v]=d([]),[H,z]=d(!1),[N,E]=d(!1),[T,j]=d(!1),[_,y]=d(!1),s=h[h.length-1]??null,I=L(()=>{const o=e.pageConfig;if(!o)return!0;const p=typeof window<"u"?window.location.pathname:"",M=o.pages.some(A=>p===A||p.startsWith(A+"/"));switch(o.scope){case V.Include:return M;case V.Exclude:return!M;default:return!0}},[e.pageConfig]),f=O(o=>{v(p=>[...p,o])},[]),n=O(()=>{v(o=>o.slice(0,-1))},[]);if(console.log("isVisible",I),!I)return null;function D(o,p){switch(o){case a.ExternalLink:p&&window.open(p,"_blank","noopener,noreferrer");break;case a.OpenEarnCredits:f({type:i.EarnCredits});break;case a.OpenConsumeCredits:f({type:i.ConsumeCredits});break;case a.OpenReferral:f({type:i.Referral});break;case a.OpenSubscribe:f({type:i.Subscribe});break}}function k(){w(!1),v([]),y(!1)}return r(G.Provider,{value:{pushView:f,popView:n},children:[P&&t("div",{className:"fixed inset-0 z-[998]",onClick:k}),r("div",{className:"fixed right-0 z-[999] flex flex-row items-end pr-[16px] md:flex-col md:items-end md:right-0 md:w-screen md:pr-0 md:pl-0",style:{bottom:u},children:[P&&r("div",{className:S("relative mr-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[500px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] md:mr-0 md:mb-[8px] md:mx-[16px] md:w-[calc(100vw-32px)] md:max-w-[400px]",g?"rounded-[12px]":"rounded-none"),style:{maxHeight:"min(80vh, 606px)"},onClick:o=>o.stopPropagation(),children:[t("div",{className:"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white md:bottom-[-8px] md:left-auto md:right-[29px] md:top-auto md:border-x-8 md:border-b-transparent md:border-t-white"}),r("div",{className:"flex items-center justify-end pl-[10px] pr-[16px] pb-[8px] pt-[16px]",children:[s!==null&&t("button",{className:"mr-auto flex size-[24px] cursor-pointer items-center justify-center",onClick:n,"aria-label":"Back",children:t(Z,{})}),t("button",{className:"flex size-[24px] cursor-pointer items-center justify-center",onClick:k,"aria-label":"Close",children:t(J,{})})]}),r("div",{className:"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]",children:[s===null&&r(me,{children:[(e.title||e.subtitle)&&r("div",{className:"flex flex-col gap-[4px]",children:[e.title&&t("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:e.title}),e.subtitle&&t("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:e.subtitle})]}),e.list.map((o,p)=>t(ce,{item:o,onAction:D,rounded:g},p))]}),s!==null&&r(F,{fallback:t("div",{className:"flex items-center justify-center py-[32px]",children:t("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}),children:[s.type===i.EarnCredits&&e.earnCredits&&t(te,{copy:e.earnCredits,onClose:n,isSubscribeSuccess:H,isActivateSuccess:N,isProfileCompleteSuccess:T,onSubscribeSuccess:()=>z(!0),onActivateSuccess:()=>E(!0),onProfileCompleteSuccess:()=>j(!0)}),s.type===i.ConsumeCredits&&e.consumeCredits&&t(se,{copy:e.consumeCredits,onClose:n,isActivateSuccess:N}),s.type===i.Referral&&e.referral&&t(oe,{copy:e.referral,onClose:n}),s.type===i.CompleteProfile&&e.earnCredits&&t(re,{copy:e.earnCredits.completeProfile,shopifyStoreDomain:x,onClose:n,onSuccess:s.props?.onSuccess}),s.type===i.Subscribe&&e.activitiesSubscribe&&t(ie,{copy:e.activitiesSubscribe,email:c?.email,onSuccess:s.props?.onSuccess,hideForm:_,onHideForm:()=>y(!0)}),s.type===i.SubscribeEmail&&e.earnCredits&&t(ne,{copy:e.earnCredits.subscribe,email:c?.email,onClose:n,onSuccess:s.props?.onSuccess}),s.type===i.Activate&&e.earnCredits&&t(pe,{copy:e.earnCredits.authCodeActivate,onClose:n,onSuccess:s.props?.onSuccess}),s.type===i.RedeemCoupon&&s.props&&e.consumeCredits&&t(ae,{itemTitle:s.props.itemTitle,itemCredits:s.props.itemCredits,itemImage:s.props.itemImage,itemValue:s.props.itemValue,itemOff:s.props.itemOff,itemRules:s.props.itemRules,redeemId:s.props.redeemId,userId:s.props.userId,alpcConfig:s.props.alpcConfig,copy:e.consumeCredits.redeemModal,pointUnit:e.consumeCredits.pointUnit,onClose:n})]})]}),e.footer&&!R&&t("div",{className:"border-t border-[#dadce0] p-[16px]",children:r("div",{className:"flex items-center justify-between gap-[16px]",children:[r("div",{className:"flex items-center gap-[4px]",children:[t("span",{className:"text-[14px] font-[700] text-[#080a0f]",children:e.footer.loginHint}),t("button",{className:"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline",onClick:C,children:e.footer.loginLabel})]}),t("div",{className:"flex shrink-0 items-center gap-[8px]",children:t("button",{className:S("cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]",g?"rounded-[4px]":"rounded-none"),onClick:m,children:e.footer.joinLabel})})]})})]}),t("button",{className:"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg md:ml-auto md:mr-[16px]",onClick:()=>w(o=>!o),"aria-label":e.triggerImg.alt??"Open member popup",children:t(U,{source:e.triggerImg.url,alt:e.triggerImg.alt??"",className:"size-[58px]"})})]})]})}function ce({item:e,onAction:u,rounded:c}){const C={[a.OpenEarnCredits]:Q,[a.OpenConsumeCredits]:X,[a.OpenReferral]:Y,[a.OpenSubscribe]:$};return r("div",{className:S("flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]",c?"rounded-[8px]":"rounded-none"),children:[r("div",{className:"flex flex-col gap-[4px]",children:[t("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#1e2024]",children:e.title}),e.description&&t("p",{className:"text-[14px] font-[700] leading-[1.43] text-[#1e2024]",children:e.description})]}),t("div",{className:"flex flex-col gap-[16px]",children:e.links.map((m,b)=>{const x=C[m.type];return r("div",{children:[b>0&&t("div",{className:"mb-[16px] h-px bg-[#dadce0]"}),r("button",{className:"flex w-full cursor-pointer items-center gap-[12px]",onClick:()=>u(m.type,m.url),children:[x&&t(x,{className:"size-[24px] shrink-0"}),t("span",{className:"flex-1 text-left text-[14px] font-[700] text-[#1e2024]",children:m.label}),t(K,{className:"size-[16px] shrink-0"})]})]},b)})})]})}export{Pe as MemberPopup};
1
+ "use client";import{Fragment as ae,jsx as t,jsxs as o}from"react/jsx-runtime";import{lazy as l,Suspense as j,useState as x,useCallback as M,useMemo as _}from"react";import{Picture as D}from"@anker-in/headless-ui";import{useHeadlessContext as F,classNames as P}from"@anker-in/lib";import{MemberPopupActionType as a,MemberPopupPageScope as O,MemberPopupPanelType as r}from"./type";import{MemberPopupProvider as L}from"./context/provider";import{useMemberPopupContext as U}from"./context/provider";import{ViewStackContext as B}from"./context/viewStack";import{IconClose as W,IconArrow as q,IconCredit as G,IconBag as J,IconReferral as K,IconSwitch as Q,IconSubscription as X}from"./icons";import{ROUNDED_BRANDS as Y}from"../../constants";const Z=l(()=>import("./panels/EarnCredits")),$=l(()=>import("./panels/ConsumeCredits")),ee=l(()=>import("./panels/Referral")),te=l(()=>import("./panels/EarnCredits/CompleteProfilePanel")),se=l(()=>import("./panels/ActivitiesSubscribePanel")),oe=l(()=>import("./panels/EarnCredits/SubscribeEmailPanel")),re=l(()=>import("./panels/EarnCredits/ActivatePanel")),ie=l(()=>import("./panels/ConsumeCredits/RedeemCouponPanel"));function ve({copy:e,bottomOffset:C="24px",...c}){const u=_(()=>{const n=e.pageConfig;if(!n)return!0;const m=typeof window<"u"?window.location.pathname:"",d=n.pages.some(f=>m===f||m.startsWith(f+"/"));switch(n.scope){case O.Include:return d;case O.Exclude:return!d;default:return!0}},[e.pageConfig]);return console.log("isVisible",u),u?t(L,{...c,earnCreditsCopy:e.earnCredits,children:t(ne,{copy:e,bottomOffset:C})}):null}function ne({copy:e,bottomOffset:C}){const{profile:c,openSignInPopup:u,openSignUpPopup:n}=U(),{brand:m,storeDomain:d}=F(),f=Y.includes(m),A=!!c,[S,w]=x(!1),[h,v]=x([]),[V,N]=x(!1),[y,R]=x(!1),[E,H]=x(!1),[z,I]=x(!1),s=h[h.length-1]??null,g=M(i=>{v(b=>[...b,i])},[]),p=M(()=>{v(i=>i.slice(0,-1))},[]);function T(i,b){switch(i){case a.ExternalLink:b&&window.open(b,"_blank","noopener,noreferrer");break;case a.OpenEarnCredits:g({type:r.EarnCredits});break;case a.OpenConsumeCredits:g({type:r.ConsumeCredits});break;case a.OpenReferral:g({type:r.Referral});break;case a.OpenSubscribe:g({type:r.Subscribe});break}}function k(){w(!1),v([]),I(!1)}return o(B.Provider,{value:{pushView:g,popView:p},children:[S&&t("div",{className:"fixed inset-0 z-[998]",onClick:k}),o("div",{className:"fixed right-0 z-[999] flex flex-row items-end pr-[16px] md:flex-col md:items-end md:right-0 md:w-screen md:pr-0 md:pl-0",style:{bottom:C},children:[S&&o("div",{className:P("relative mr-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[500px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] md:mr-0 md:mb-[8px] md:mx-[16px] md:w-[calc(100vw-32px)] md:max-w-[400px]",f?"rounded-[12px]":"rounded-none"),style:{maxHeight:"min(80vh, 606px)"},onClick:i=>i.stopPropagation(),children:[t("div",{className:"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white md:bottom-[-8px] md:left-auto md:right-[29px] md:top-auto md:border-x-8 md:border-b-transparent md:border-t-white"}),o("div",{className:"flex items-center justify-end pl-[10px] pr-[16px] pb-[8px] pt-[16px]",children:[s!==null&&t("button",{className:"mr-auto flex size-[24px] cursor-pointer items-center justify-center",onClick:p,"aria-label":"Back",children:t(Q,{})}),t("button",{className:"flex size-[24px] cursor-pointer items-center justify-center",onClick:k,"aria-label":"Close",children:t(W,{})})]}),o("div",{className:"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]",children:[s===null&&o(ae,{children:[(e.title||e.subtitle)&&o("div",{className:"flex flex-col gap-[4px]",children:[e.title&&t("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:e.title}),e.subtitle&&t("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:e.subtitle})]}),e.list.map((i,b)=>t(pe,{item:i,onAction:T,rounded:f},b))]}),s!==null&&o(j,{fallback:t("div",{className:"flex items-center justify-center py-[32px]",children:t("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}),children:[s.type===r.EarnCredits&&e.earnCredits&&t(Z,{copy:e.earnCredits,onClose:p,isProfileCompleteSuccess:E,isSubscribeSuccess:V,isActivateSuccess:y}),s.type===r.ConsumeCredits&&e.consumeCredits&&t($,{copy:e.consumeCredits,onClose:p,isActivateSuccess:y}),s.type===r.Referral&&e.referral&&t(ee,{copy:e.referral,onClose:p}),s.type===r.CompleteProfile&&e.earnCredits&&t(te,{copy:e.earnCredits.completeProfile,shopifyStoreDomain:d,onClose:p,onSuccess:()=>H(!0)}),s.type===r.Subscribe&&e.activitiesSubscribe&&t(se,{copy:e.activitiesSubscribe,email:c?.email,onSuccess:()=>N(!0),hideForm:z,onHideForm:()=>I(!0)}),s.type===r.SubscribeEmail&&e.earnCredits&&t(oe,{copy:e.earnCredits.subscribe,email:c?.email,onClose:p,onSuccess:()=>N(!0)}),s.type===r.Activate&&e.earnCredits&&t(re,{copy:e.earnCredits.authCodeActivate,onClose:p,onSuccess:()=>{R(!0)}}),s.type===r.RedeemCoupon&&s.props&&e.consumeCredits&&t(ie,{itemTitle:s.props.itemTitle,itemCredits:s.props.itemCredits,itemImage:s.props.itemImage,itemValue:s.props.itemValue,itemOff:s.props.itemOff,itemRules:s.props.itemRules,redeemId:s.props.redeemId,userId:s.props.userId,alpcConfig:s.props.alpcConfig,copy:e.consumeCredits.redeemModal,pointUnit:e.consumeCredits.pointUnit,onClose:p})]})]}),e.footer&&!A&&t("div",{className:"border-t border-[#dadce0] p-[16px]",children:o("div",{className:"flex items-center justify-between gap-[16px]",children:[o("div",{className:"flex items-center gap-[4px]",children:[t("span",{className:"text-[14px] font-[700] text-[#080a0f]",children:e.footer.loginHint}),t("button",{className:"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline",onClick:u,children:e.footer.loginLabel})]}),t("div",{className:"flex shrink-0 items-center gap-[8px]",children:t("button",{className:P("cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]",f?"rounded-[4px]":"rounded-none"),onClick:n,children:e.footer.joinLabel})})]})})]}),t("button",{className:"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg md:ml-auto md:mr-[16px]",onClick:()=>w(i=>!i),"aria-label":e.triggerImg.alt??"Open member popup",children:t(D,{source:e.triggerImg.url,alt:e.triggerImg.alt??"",className:"size-[58px]"})})]})]})}function pe({item:e,onAction:C,rounded:c}){const u={[a.OpenEarnCredits]:G,[a.OpenConsumeCredits]:J,[a.OpenReferral]:K,[a.OpenSubscribe]:X};return o("div",{className:P("flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]",c?"rounded-[8px]":"rounded-none"),children:[o("div",{className:"flex flex-col gap-[4px]",children:[t("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#1e2024]",children:e.title}),e.description&&t("p",{className:"text-[14px] font-[700] leading-[1.43] text-[#1e2024]",children:e.description})]}),t("div",{className:"flex flex-col gap-[16px]",children:e.links.map((n,m)=>{const d=u[n.type];return o("div",{children:[m>0&&t("div",{className:"mb-[16px] h-px bg-[#dadce0]"}),o("button",{className:"flex w-full cursor-pointer items-center gap-[12px]",onClick:()=>C(n.type,n.url),children:[d&&t(d,{className:"size-[24px] shrink-0"}),t("span",{className:"flex-1 text-left text-[14px] font-[700] text-[#1e2024]",children:n.label}),t(q,{className:"size-[16px] shrink-0"})]})]},m)})})]})}export{ve as MemberPopup};
2
2
  //# sourceMappingURL=MemberPopup.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/memberPopup/MemberPopup.tsx"],
4
- "sourcesContent": ["'use client'\n\nimport { lazy, Suspense, useState, useCallback, useMemo } from 'react'\nimport { Picture } from '@anker-in/headless-ui'\nimport { type HeadlessConfig, useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport {\n MemberPopupActionType,\n MemberPopupPageScope,\n MemberPopupPanelType,\n type MemberPopupCopy,\n type MemberPopupContextValue,\n type MemberPopupItem,\n} from './type'\nimport { MemberPopupProvider } from './context/provider'\nimport { useMemberPopupContext } from './context/provider'\nimport { ViewStackContext, type ViewPayload } from './context/viewStack'\nimport { IconClose, IconArrow, IconCredit, IconBag, IconReferral, IconSwitch, IconSubscription } from './icons'\nimport { ROUNDED_BRANDS } from '../../constants'\n\nconst EarnCredits = lazy(() => import('./panels/EarnCredits'))\nconst ConsumeCredits = lazy(() => import('./panels/ConsumeCredits'))\nconst Referral = lazy(() => import('./panels/Referral'))\nconst CompleteProfile = lazy(() => import('./panels/EarnCredits/CompleteProfilePanel'))\nconst ActivitiesSubscribe = lazy(() => import('./panels/ActivitiesSubscribePanel'))\nconst SubscribeEmail = lazy(() => import('./panels/EarnCredits/SubscribeEmailPanel'))\nconst Activate = lazy(() => import('./panels/EarnCredits/ActivatePanel'))\nconst RedeemCoupon = lazy(() => import('./panels/ConsumeCredits/RedeemCouponPanel'))\n\ntype MemberPopupProps = MemberPopupContextValue & {\n headlessConfig: HeadlessConfig\n copy: MemberPopupCopy\n bottomOffset?: string\n}\n\nexport function MemberPopup({ copy, bottomOffset = '24px', ...providerProps }: MemberPopupProps) {\n return (\n <MemberPopupProvider {...providerProps} earnCreditsCopy={copy.earnCredits}>\n <MemberPopupContent copy={copy} bottomOffset={bottomOffset} />\n </MemberPopupProvider>\n )\n}\n\ntype MemberPopupContentProps = {\n copy: MemberPopupCopy\n bottomOffset: string\n}\n\nfunction MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {\n const { profile, openSignInPopup, openSignUpPopup } = useMemberPopupContext()\n const { brand, storeDomain } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n const isLogin = !!profile\n const [isOpen, setIsOpen] = useState(false)\n const [viewStack, setViewStack] = useState<ViewPayload[]>([])\n const [isSubscribeSuccess, setIsSubscribeSuccess] = useState(false)\n const [isActivateSuccess, setIsActivateSuccess] = useState(false)\n const [isProfileCompleteSuccess, setIsProfileCompleteSuccess] = useState(false)\n const [isSubscribeFormHidden, setIsSubscribeFormHidden] = useState(false)\n\n const currentView = viewStack[viewStack.length - 1] ?? null\n\n const isVisible = useMemo(() => {\n const config = copy.pageConfig\n if (!config) return true\n const pathname = typeof window !== 'undefined' ? window.location.pathname : ''\n const matches = config.pages.some(page => pathname === page || pathname.startsWith(page + '/'))\n switch (config.scope) {\n case MemberPopupPageScope.Include:\n return matches\n case MemberPopupPageScope.Exclude:\n return !matches\n default:\n return true\n }\n }, [copy.pageConfig])\n\n const pushView = useCallback((view: ViewPayload) => {\n setViewStack(prev => [...prev, view])\n }, [])\n\n const popView = useCallback(() => {\n setViewStack(prev => prev.slice(0, -1))\n }, [])\n\n console.log('isVisible', isVisible)\n if (!isVisible) return null\n\n function handleAction(type: MemberPopupActionType, url?: string) {\n switch (type) {\n case MemberPopupActionType.ExternalLink:\n if (url) window.open(url, '_blank', 'noopener,noreferrer')\n break\n case MemberPopupActionType.OpenEarnCredits:\n pushView({ type: MemberPopupPanelType.EarnCredits })\n break\n case MemberPopupActionType.OpenConsumeCredits:\n pushView({ type: MemberPopupPanelType.ConsumeCredits })\n break\n case MemberPopupActionType.OpenReferral:\n pushView({ type: MemberPopupPanelType.Referral })\n break\n case MemberPopupActionType.OpenSubscribe:\n pushView({ type: MemberPopupPanelType.Subscribe })\n break\n }\n }\n\n function handleClose() {\n setIsOpen(false)\n setViewStack([])\n setIsSubscribeFormHidden(false)\n }\n\n return (\n <ViewStackContext.Provider value={{ pushView, popView }}>\n {isOpen && <div className=\"fixed inset-0 z-[998]\" onClick={handleClose} />}\n <div\n className=\"fixed right-0 z-[999] flex flex-row items-end pr-[16px] md:flex-col md:items-end md:right-0 md:w-screen md:pr-0 md:pl-0\"\n style={{ bottom: bottomOffset }}\n >\n {isOpen && (\n <div\n className={cn(\n 'relative mr-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[500px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] md:mr-0 md:mb-[8px] md:mx-[16px] md:w-[calc(100vw-32px)] md:max-w-[400px]',\n rounded ? 'rounded-[12px]' : 'rounded-none'\n )}\n style={{ maxHeight: 'min(80vh, 606px)' }}\n onClick={e => e.stopPropagation()}\n >\n <div className=\"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white md:bottom-[-8px] md:left-auto md:right-[29px] md:top-auto md:border-x-8 md:border-b-transparent md:border-t-white\" />\n <div className=\"flex items-center justify-end pl-[10px] pr-[16px] pb-[8px] pt-[16px]\">\n {currentView !== null && (\n <button\n className=\"mr-auto flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={popView}\n aria-label=\"Back\"\n >\n <IconSwitch />\n </button>\n )}\n <button\n className=\"flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={handleClose}\n aria-label=\"Close\"\n >\n <IconClose />\n </button>\n </div>\n\n <div className=\"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]\">\n {currentView === null && (\n <>\n {(copy.title || copy.subtitle) && (\n <div className=\"flex flex-col gap-[4px]\">\n {copy.title && (\n <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>\n )}\n {copy.subtitle && (\n <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>\n )}\n </div>\n )}\n {copy.list.map((item, i) => (\n <HomeCard key={i} item={item} onAction={handleAction} rounded={rounded} />\n ))}\n </>\n )}\n\n {currentView !== null && (\n <Suspense\n fallback={\n <div className=\"flex items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n }\n >\n {currentView.type === MemberPopupPanelType.EarnCredits && copy.earnCredits && (\n <EarnCredits\n copy={copy.earnCredits}\n onClose={popView}\n isSubscribeSuccess={isSubscribeSuccess}\n isActivateSuccess={isActivateSuccess}\n isProfileCompleteSuccess={isProfileCompleteSuccess}\n onSubscribeSuccess={() => setIsSubscribeSuccess(true)}\n onActivateSuccess={() => setIsActivateSuccess(true)}\n onProfileCompleteSuccess={() => setIsProfileCompleteSuccess(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.ConsumeCredits && copy.consumeCredits && (\n <ConsumeCredits\n copy={copy.consumeCredits}\n onClose={popView}\n isActivateSuccess={isActivateSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Referral && copy.referral && (\n <Referral copy={copy.referral} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.CompleteProfile && copy.earnCredits && (\n <CompleteProfile\n copy={copy.earnCredits.completeProfile}\n shopifyStoreDomain={storeDomain}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Subscribe && copy.activitiesSubscribe && (\n <ActivitiesSubscribe\n copy={copy.activitiesSubscribe}\n email={profile?.email}\n onSuccess={currentView.props?.onSuccess}\n hideForm={isSubscribeFormHidden}\n onHideForm={() => setIsSubscribeFormHidden(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.SubscribeEmail && copy.earnCredits && (\n <SubscribeEmail\n copy={copy.earnCredits.subscribe}\n email={profile?.email}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Activate && copy.earnCredits && (\n <Activate\n copy={copy.earnCredits.authCodeActivate}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.RedeemCoupon &&\n currentView.props &&\n copy.consumeCredits && (\n <RedeemCoupon\n itemTitle={currentView.props.itemTitle}\n itemCredits={currentView.props.itemCredits}\n itemImage={currentView.props.itemImage}\n itemValue={currentView.props.itemValue}\n itemOff={currentView.props.itemOff}\n itemRules={currentView.props.itemRules}\n redeemId={currentView.props.redeemId}\n userId={currentView.props.userId}\n alpcConfig={currentView.props.alpcConfig}\n copy={copy.consumeCredits.redeemModal}\n pointUnit={copy.consumeCredits.pointUnit}\n onClose={popView}\n />\n )}\n </Suspense>\n )}\n </div>\n\n {copy.footer && !isLogin && (\n <div className=\"border-t border-[#dadce0] p-[16px]\">\n <div className=\"flex items-center justify-between gap-[16px]\">\n <div className=\"flex items-center gap-[4px]\">\n <span className=\"text-[14px] font-[700] text-[#080a0f]\">{copy.footer.loginHint}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline\"\n onClick={openSignInPopup}\n >\n {copy.footer.loginLabel}\n </button>\n </div>\n <div className=\"flex shrink-0 items-center gap-[8px]\">\n <button\n className={cn(\n 'cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n onClick={openSignUpPopup}\n >\n {copy.footer.joinLabel}\n </button>\n </div>\n </div>\n </div>\n )}\n </div>\n )}\n\n <button\n className=\"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg md:ml-auto md:mr-[16px]\"\n onClick={() => setIsOpen(prev => !prev)}\n aria-label={copy.triggerImg.alt ?? 'Open member popup'}\n >\n <Picture source={copy.triggerImg.url} alt={copy.triggerImg.alt ?? ''} className=\"size-[58px]\" />\n </button>\n </div>\n </ViewStackContext.Provider>\n )\n}\n\ntype HomeCardProps = {\n item: MemberPopupItem\n onAction: (type: MemberPopupActionType, url?: string) => void\n rounded: boolean\n}\n\nfunction HomeCard({ item, onAction, rounded }: HomeCardProps) {\n const ACTION_ICON: Partial<Record<MemberPopupActionType, typeof IconCredit>> = {\n [MemberPopupActionType.OpenEarnCredits]: IconCredit,\n [MemberPopupActionType.OpenConsumeCredits]: IconBag,\n [MemberPopupActionType.OpenReferral]: IconReferral,\n [MemberPopupActionType.OpenSubscribe]: IconSubscription,\n }\n\n return (\n <div className={cn('flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <div className=\"flex flex-col gap-[4px]\">\n <h3 className=\"text-[20px] font-[700] leading-[1.2] text-[#1e2024]\">{item.title}</h3>\n {item.description && <p className=\"text-[14px] font-[700] leading-[1.43] text-[#1e2024]\">{item.description}</p>}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n {item.links.map((link, i) => {\n const IconComponent = ACTION_ICON[link.type]\n return (\n <div key={i}>\n {i > 0 && <div className=\"mb-[16px] h-px bg-[#dadce0]\" />}\n <button\n className=\"flex w-full cursor-pointer items-center gap-[12px]\"\n onClick={() => onAction(link.type, link.url)}\n >\n {IconComponent && <IconComponent className=\"size-[24px] shrink-0\" />}\n <span className=\"flex-1 text-left text-[14px] font-[700] text-[#1e2024]\">{link.label}</span>\n <IconArrow className=\"size-[16px] shrink-0\" />\n </button>\n </div>\n )\n })}\n </div>\n </div>\n )\n}\n"],
5
- "mappings": "aAqCM,OAkHU,YAAAA,GAlHV,OAAAC,EA6FM,QAAAC,MA7FN,oBAnCN,OAAS,QAAAC,EAAM,YAAAC,EAAU,YAAAC,EAAU,eAAAC,EAAa,WAAAC,MAAe,QAC/D,OAAS,WAAAC,MAAe,wBACxB,OAA8B,sBAAAC,EAAoB,cAAcC,MAAU,gBAC1E,OACE,yBAAAC,EACA,wBAAAC,EACA,wBAAAC,MAIK,SACP,OAAS,uBAAAC,MAA2B,qBACpC,OAAS,yBAAAC,MAA6B,qBACtC,OAAS,oBAAAC,MAA0C,sBACnD,OAAS,aAAAC,EAAW,aAAAC,EAAW,cAAAC,EAAY,WAAAC,EAAS,gBAAAC,EAAc,cAAAC,EAAY,oBAAAC,MAAwB,UACtG,OAAS,kBAAAC,OAAsB,kBAE/B,MAAMC,GAActB,EAAK,IAAM,OAAO,sBAAsB,CAAC,EACvDuB,GAAiBvB,EAAK,IAAM,OAAO,yBAAyB,CAAC,EAC7DwB,GAAWxB,EAAK,IAAM,OAAO,mBAAmB,CAAC,EACjDyB,GAAkBzB,EAAK,IAAM,OAAO,2CAA2C,CAAC,EAChF0B,GAAsB1B,EAAK,IAAM,OAAO,mCAAmC,CAAC,EAC5E2B,GAAiB3B,EAAK,IAAM,OAAO,0CAA0C,CAAC,EAC9E4B,GAAW5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AE1C,UAAAC,GAAiB7E,EAAC6E,EAAA,CAAc,UAAU,uBAAuB,EAClE7E,EAAC,QAAK,UAAU,yDAA0D,SAAA4E,EAAK,MAAM,EACrF5E,EAACiB,EAAA,CAAU,UAAU,uBAAuB,GAC9C,IATQuD,CAUV,CAEJ,CAAC,EACH,GACF,CAEJ",
6
- "names": ["Fragment", "jsx", "jsxs", "lazy", "Suspense", "useState", "useCallback", "useMemo", "Picture", "useHeadlessContext", "cn", "MemberPopupActionType", "MemberPopupPageScope", "MemberPopupPanelType", "MemberPopupProvider", "useMemberPopupContext", "ViewStackContext", "IconClose", "IconArrow", "IconCredit", "IconBag", "IconReferral", "IconSwitch", "IconSubscription", "ROUNDED_BRANDS", "EarnCredits", "ConsumeCredits", "Referral", "CompleteProfile", "ActivitiesSubscribe", "SubscribeEmail", "Activate", "RedeemCoupon", "MemberPopup", "copy", "bottomOffset", "providerProps", "MemberPopupContent", "profile", "openSignInPopup", "openSignUpPopup", "brand", "storeDomain", "rounded", "isLogin", "isOpen", "setIsOpen", "viewStack", "setViewStack", "isSubscribeSuccess", "setIsSubscribeSuccess", "isActivateSuccess", "setIsActivateSuccess", "isProfileCompleteSuccess", "setIsProfileCompleteSuccess", "isSubscribeFormHidden", "setIsSubscribeFormHidden", "currentView", "isVisible", "config", "pathname", "matches", "page", "pushView", "view", "prev", "popView", "handleAction", "type", "url", "handleClose", "e", "item", "i", "HomeCard", "onAction", "ACTION_ICON", "link", "IconComponent"]
4
+ "sourcesContent": ["'use client'\n\nimport { lazy, Suspense, useState, useCallback, useMemo, useEffect } from 'react'\nimport { Picture } from '@anker-in/headless-ui'\nimport { type HeadlessConfig, useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport {\n MemberPopupActionType,\n MemberPopupPageScope,\n MemberPopupPanelType,\n type MemberPopupCopy,\n type MemberPopupContextValue,\n type MemberPopupItem,\n} from './type'\nimport { MemberPopupProvider } from './context/provider'\nimport { useMemberPopupContext } from './context/provider'\nimport { ViewStackContext, type ViewPayload } from './context/viewStack'\nimport { IconClose, IconArrow, IconCredit, IconBag, IconReferral, IconSwitch, IconSubscription } from './icons'\nimport { ROUNDED_BRANDS } from '../../constants'\n\nconst EarnCredits = lazy(() => import('./panels/EarnCredits'))\nconst ConsumeCredits = lazy(() => import('./panels/ConsumeCredits'))\nconst Referral = lazy(() => import('./panels/Referral'))\nconst CompleteProfile = lazy(() => import('./panels/EarnCredits/CompleteProfilePanel'))\nconst ActivitiesSubscribe = lazy(() => import('./panels/ActivitiesSubscribePanel'))\nconst SubscribeEmail = lazy(() => import('./panels/EarnCredits/SubscribeEmailPanel'))\nconst Activate = lazy(() => import('./panels/EarnCredits/ActivatePanel'))\nconst RedeemCoupon = lazy(() => import('./panels/ConsumeCredits/RedeemCouponPanel'))\n\ntype MemberPopupProps = MemberPopupContextValue & {\n headlessConfig: HeadlessConfig\n copy: MemberPopupCopy\n bottomOffset?: string\n}\n\nexport function MemberPopup({ copy, bottomOffset = '24px', ...providerProps }: MemberPopupProps) {\n const isVisible = useMemo(() => {\n const config = copy.pageConfig\n if (!config) return true\n const pathname = typeof window !== 'undefined' ? window.location.pathname : ''\n const matches = config.pages.some(page => pathname === page || pathname.startsWith(page + '/'))\n switch (config.scope) {\n case MemberPopupPageScope.Include:\n return matches\n case MemberPopupPageScope.Exclude:\n return !matches\n default:\n return true\n }\n }, [copy.pageConfig])\n\n console.log('isVisible', isVisible)\n\n return isVisible ? (\n <MemberPopupProvider {...providerProps} earnCreditsCopy={copy.earnCredits}>\n <MemberPopupContent copy={copy} bottomOffset={bottomOffset} />\n </MemberPopupProvider>\n ) : null\n}\n\ntype MemberPopupContentProps = {\n copy: MemberPopupCopy\n bottomOffset: string\n}\n\nfunction MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {\n const { profile, openSignInPopup, openSignUpPopup } = useMemberPopupContext()\n const { brand, storeDomain } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n const isLogin = !!profile\n const [isOpen, setIsOpen] = useState(false)\n const [viewStack, setViewStack] = useState<ViewPayload[]>([])\n const [isSubscribeSuccess, setIsSubscribeSuccess] = useState(false)\n const [isActivateSuccess, setIsActivateSuccess] = useState(false)\n const [isProfileCompleteSuccess, setIsProfileCompleteSuccess] = useState(false)\n const [isSubscribeFormHidden, setIsSubscribeFormHidden] = useState(false)\n\n const currentView = viewStack[viewStack.length - 1] ?? null\n\n const pushView = useCallback((view: ViewPayload) => {\n setViewStack(prev => [...prev, view])\n }, [])\n\n const popView = useCallback(() => {\n setViewStack(prev => prev.slice(0, -1))\n }, [])\n\n function handleAction(type: MemberPopupActionType, url?: string) {\n switch (type) {\n case MemberPopupActionType.ExternalLink:\n if (url) window.open(url, '_blank', 'noopener,noreferrer')\n break\n case MemberPopupActionType.OpenEarnCredits:\n pushView({ type: MemberPopupPanelType.EarnCredits })\n break\n case MemberPopupActionType.OpenConsumeCredits:\n pushView({ type: MemberPopupPanelType.ConsumeCredits })\n break\n case MemberPopupActionType.OpenReferral:\n pushView({ type: MemberPopupPanelType.Referral })\n break\n case MemberPopupActionType.OpenSubscribe:\n pushView({ type: MemberPopupPanelType.Subscribe })\n break\n }\n }\n\n function handleClose() {\n setIsOpen(false)\n setViewStack([])\n setIsSubscribeFormHidden(false)\n }\n\n return (\n <ViewStackContext.Provider value={{ pushView, popView }}>\n {isOpen && <div className=\"fixed inset-0 z-[998]\" onClick={handleClose} />}\n <div\n className=\"fixed right-0 z-[999] flex flex-row items-end pr-[16px] md:flex-col md:items-end md:right-0 md:w-screen md:pr-0 md:pl-0\"\n style={{ bottom: bottomOffset }}\n >\n {isOpen && (\n <div\n className={cn(\n 'relative mr-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[500px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] md:mr-0 md:mb-[8px] md:mx-[16px] md:w-[calc(100vw-32px)] md:max-w-[400px]',\n rounded ? 'rounded-[12px]' : 'rounded-none'\n )}\n style={{ maxHeight: 'min(80vh, 606px)' }}\n onClick={e => e.stopPropagation()}\n >\n <div className=\"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white md:bottom-[-8px] md:left-auto md:right-[29px] md:top-auto md:border-x-8 md:border-b-transparent md:border-t-white\" />\n <div className=\"flex items-center justify-end pl-[10px] pr-[16px] pb-[8px] pt-[16px]\">\n {currentView !== null && (\n <button\n className=\"mr-auto flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={popView}\n aria-label=\"Back\"\n >\n <IconSwitch />\n </button>\n )}\n <button\n className=\"flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={handleClose}\n aria-label=\"Close\"\n >\n <IconClose />\n </button>\n </div>\n\n <div className=\"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]\">\n {currentView === null && (\n <>\n {(copy.title || copy.subtitle) && (\n <div className=\"flex flex-col gap-[4px]\">\n {copy.title && (\n <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>\n )}\n {copy.subtitle && (\n <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>\n )}\n </div>\n )}\n {copy.list.map((item, i) => (\n <HomeCard key={i} item={item} onAction={handleAction} rounded={rounded} />\n ))}\n </>\n )}\n\n {currentView !== null && (\n <Suspense\n fallback={\n <div className=\"flex items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n }\n >\n {currentView.type === MemberPopupPanelType.EarnCredits && copy.earnCredits && (\n <EarnCredits\n copy={copy.earnCredits}\n onClose={popView}\n isProfileCompleteSuccess={isProfileCompleteSuccess}\n isSubscribeSuccess={isSubscribeSuccess}\n isActivateSuccess={isActivateSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.ConsumeCredits && copy.consumeCredits && (\n <ConsumeCredits\n copy={copy.consumeCredits}\n onClose={popView}\n isActivateSuccess={isActivateSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Referral && copy.referral && (\n <Referral copy={copy.referral} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.CompleteProfile && copy.earnCredits && (\n <CompleteProfile\n copy={copy.earnCredits.completeProfile}\n shopifyStoreDomain={storeDomain}\n onClose={popView}\n onSuccess={() => setIsProfileCompleteSuccess(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.Subscribe && copy.activitiesSubscribe && (\n <ActivitiesSubscribe\n copy={copy.activitiesSubscribe}\n email={profile?.email}\n onSuccess={() => setIsSubscribeSuccess(true)}\n hideForm={isSubscribeFormHidden}\n onHideForm={() => setIsSubscribeFormHidden(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.SubscribeEmail && copy.earnCredits && (\n <SubscribeEmail\n copy={copy.earnCredits.subscribe}\n email={profile?.email}\n onClose={popView}\n onSuccess={() => setIsSubscribeSuccess(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.Activate && copy.earnCredits && (\n <Activate\n copy={copy.earnCredits.authCodeActivate}\n onClose={popView}\n onSuccess={() => {\n setIsActivateSuccess(true)\n }}\n />\n )}\n {currentView.type === MemberPopupPanelType.RedeemCoupon &&\n currentView.props &&\n copy.consumeCredits && (\n <RedeemCoupon\n itemTitle={currentView.props.itemTitle}\n itemCredits={currentView.props.itemCredits}\n itemImage={currentView.props.itemImage}\n itemValue={currentView.props.itemValue}\n itemOff={currentView.props.itemOff}\n itemRules={currentView.props.itemRules}\n redeemId={currentView.props.redeemId}\n userId={currentView.props.userId}\n alpcConfig={currentView.props.alpcConfig}\n copy={copy.consumeCredits.redeemModal}\n pointUnit={copy.consumeCredits.pointUnit}\n onClose={popView}\n />\n )}\n </Suspense>\n )}\n </div>\n\n {copy.footer && !isLogin && (\n <div className=\"border-t border-[#dadce0] p-[16px]\">\n <div className=\"flex items-center justify-between gap-[16px]\">\n <div className=\"flex items-center gap-[4px]\">\n <span className=\"text-[14px] font-[700] text-[#080a0f]\">{copy.footer.loginHint}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline\"\n onClick={openSignInPopup}\n >\n {copy.footer.loginLabel}\n </button>\n </div>\n <div className=\"flex shrink-0 items-center gap-[8px]\">\n <button\n className={cn(\n 'cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n onClick={openSignUpPopup}\n >\n {copy.footer.joinLabel}\n </button>\n </div>\n </div>\n </div>\n )}\n </div>\n )}\n\n <button\n className=\"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg md:ml-auto md:mr-[16px]\"\n onClick={() => setIsOpen(prev => !prev)}\n aria-label={copy.triggerImg.alt ?? 'Open member popup'}\n >\n <Picture source={copy.triggerImg.url} alt={copy.triggerImg.alt ?? ''} className=\"size-[58px]\" />\n </button>\n </div>\n </ViewStackContext.Provider>\n )\n}\n\ntype HomeCardProps = {\n item: MemberPopupItem\n onAction: (type: MemberPopupActionType, url?: string) => void\n rounded: boolean\n}\n\nfunction HomeCard({ item, onAction, rounded }: HomeCardProps) {\n const ACTION_ICON: Partial<Record<MemberPopupActionType, typeof IconCredit>> = {\n [MemberPopupActionType.OpenEarnCredits]: IconCredit,\n [MemberPopupActionType.OpenConsumeCredits]: IconBag,\n [MemberPopupActionType.OpenReferral]: IconReferral,\n [MemberPopupActionType.OpenSubscribe]: IconSubscription,\n }\n\n return (\n <div className={cn('flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <div className=\"flex flex-col gap-[4px]\">\n <h3 className=\"text-[20px] font-[700] leading-[1.2] text-[#1e2024]\">{item.title}</h3>\n {item.description && <p className=\"text-[14px] font-[700] leading-[1.43] text-[#1e2024]\">{item.description}</p>}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n {item.links.map((link, i) => {\n const IconComponent = ACTION_ICON[link.type]\n return (\n <div key={i}>\n {i > 0 && <div className=\"mb-[16px] h-px bg-[#dadce0]\" />}\n <button\n className=\"flex w-full cursor-pointer items-center gap-[12px]\"\n onClick={() => onAction(link.type, link.url)}\n >\n {IconComponent && <IconComponent className=\"size-[24px] shrink-0\" />}\n <span className=\"flex-1 text-left text-[14px] font-[700] text-[#1e2024]\">{link.label}</span>\n <IconArrow className=\"size-[16px] shrink-0\" />\n </button>\n </div>\n )\n })}\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": "aAsDM,OAgGU,YAAAA,GAhGV,OAAAC,EA2EM,QAAAC,MA3EN,oBApDN,OAAS,QAAAC,EAAM,YAAAC,EAAU,YAAAC,EAAU,eAAAC,EAAa,WAAAC,MAA0B,QAC1E,OAAS,WAAAC,MAAe,wBACxB,OAA8B,sBAAAC,EAAoB,cAAcC,MAAU,gBAC1E,OACE,yBAAAC,EACA,wBAAAC,EACA,wBAAAC,MAIK,SACP,OAAS,uBAAAC,MAA2B,qBACpC,OAAS,yBAAAC,MAA6B,qBACtC,OAAS,oBAAAC,MAA0C,sBACnD,OAAS,aAAAC,EAAW,aAAAC,EAAW,cAAAC,EAAY,WAAAC,EAAS,gBAAAC,EAAc,cAAAC,EAAY,oBAAAC,MAAwB,UACtG,OAAS,kBAAAC,MAAsB,kBAE/B,MAAMC,EAActB,EAAK,IAAM,OAAO,sBAAsB,CAAC,EACvDuB,EAAiBvB,EAAK,IAAM,OAAO,yBAAyB,CAAC,EAC7DwB,GAAWxB,EAAK,IAAM,OAAO,mBAAmB,CAAC,EACjDyB,GAAkBzB,EAAK,IAAM,OAAO,2CAA2C,CAAC,EAChF0B,GAAsB1B,EAAK,IAAM,OAAO,mCAAmC,CAAC,EAC5E2B,GAAiB3B,EAAK,IAAM,OAAO,0CAA0C,CAAC,EAC9E4B,GAAW5B,EAAK,IAAM,OAAO,oCAAoC,CAAC,EAClE6B,GAAe7B,EAAK,IAAM,OAAO,2CAA2C,CAAC,EAQ5E,SAAS8B,GAA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
+ "names": ["Fragment", "jsx", "jsxs", "lazy", "Suspense", "useState", "useCallback", "useMemo", "Picture", "useHeadlessContext", "cn", "MemberPopupActionType", "MemberPopupPageScope", "MemberPopupPanelType", "MemberPopupProvider", "useMemberPopupContext", "ViewStackContext", "IconClose", "IconArrow", "IconCredit", "IconBag", "IconReferral", "IconSwitch", "IconSubscription", "ROUNDED_BRANDS", "EarnCredits", "ConsumeCredits", "Referral", "CompleteProfile", "ActivitiesSubscribe", "SubscribeEmail", "Activate", "RedeemCoupon", "MemberPopup", "copy", "bottomOffset", "providerProps", "isVisible", "config", "pathname", "matches", "page", "MemberPopupContent", "profile", "openSignInPopup", "openSignUpPopup", "brand", "storeDomain", "rounded", "isLogin", "isOpen", "setIsOpen", "viewStack", "setViewStack", "isSubscribeSuccess", "setIsSubscribeSuccess", "isActivateSuccess", "setIsActivateSuccess", "isProfileCompleteSuccess", "setIsProfileCompleteSuccess", "isSubscribeFormHidden", "setIsSubscribeFormHidden", "currentView", "pushView", "view", "prev", "popView", "handleAction", "type", "url", "handleClose", "e", "item", "i", "HomeCard", "onAction", "ACTION_ICON", "link", "IconComponent"]
7
7
  }
@@ -5,9 +5,6 @@ type Props = {
5
5
  isSubscribeSuccess?: boolean;
6
6
  isActivateSuccess?: boolean;
7
7
  isProfileCompleteSuccess?: boolean;
8
- onSubscribeSuccess?: () => void;
9
- onActivateSuccess?: () => void;
10
- onProfileCompleteSuccess?: () => void;
11
8
  };
12
- declare function EarnCredits({ copy, onClose, isSubscribeSuccess, isActivateSuccess, isProfileCompleteSuccess, onSubscribeSuccess, onActivateSuccess, onProfileCompleteSuccess, }: Props): import("react/jsx-runtime").JSX.Element;
9
+ declare function EarnCredits({ copy, onClose, isSubscribeSuccess, isActivateSuccess, isProfileCompleteSuccess, }: Props): import("react/jsx-runtime").JSX.Element;
13
10
  export default EarnCredits;
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as n}from"react/jsx-runtime";import{useMemo as m}from"react";import{classNames as c,useHeadlessContext as A}from"@anker-in/lib";import{useMemberPopupContext as B}from"../../context/provider";import{useViewStack as U}from"../../context/viewStack";import{useSubscribed as D}from"./hooks/useSubscribed";import{EarnCreditsTaskType as i,MemberPopupPanelType as b}from"../../type";import{IconBag as M,IconLock as R,IconSubscription as y,IconOrders as F}from"../../icons";import{numberFormat as L}from"../../../credits/context/utils";import{ROUNDED_BRANDS as O}from"../../../../constants";function V({id:t,className:a}){switch(t){case i.Activate:return e(R,{className:a});case i.Subscribe:return e(y,{className:a});case i.Shop:return e(M,{className:a});case i.CompleteProfile:return e(F,{className:a})}}function z({copy:t,onClose:a,isSubscribeSuccess:v=!1,isActivateSuccess:g=!1,isProfileCompleteSuccess:f=!1,onSubscribeSuccess:w,onActivateSuccess:P,onProfileCompleteSuccess:E}){const{profile:o,openSignUpPopup:d,alpcConfig:N,creditInfo:x}=B(),{pushView:p}=U(),{locale:T}=N,{brand:h}=A(),u=O.includes(h);console.log("creditInfo",x);const l=!!o,C=D({userId:o?.user_id,brand:h,email:o?.email,locale:T,apiBaseUrl:N.apiBaseUrl}),k=m(()=>f||!!(o?.first_name||o?.last_name)&&!!o?.phone_number&&!!o?.dob,[o,f]),S=m(()=>({[i.Activate]:{finished:!!o?.activated||g,onClick:l?()=>p({type:b.Activate,props:{onSuccess:P}}):d},[i.CompleteProfile]:{finished:k,onClick:l?()=>p({type:b.CompleteProfile,props:{onSuccess:E}}):d},[i.Subscribe]:{finished:C||v,onClick:l?()=>p({type:b.SubscribeEmail,props:{onSuccess:w}}):d},[i.Shop]:{finished:!1,link:t.goShopLink,onClick:l?void 0:d}}),[o,l,g,f,k,C,v,d,p,t.goShopLink]),I=m(()=>t.list.map(s=>{const r=S[s.id];if(!r)return null;const _=r.finished?t.completed:l?H(s.id,t):t.joinNow;return{...s,...r,buttonLabel:_}}).filter(Boolean),[t,S,l]);return n("div",{className:"flex flex-col gap-[16px]",children:[n("div",{className:"flex flex-col gap-[16px]",children:[e("div",{className:"flex flex-col gap-[8px]",children:t.title&&e("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title})}),l&&n("div",{className:c("flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]",u?"rounded-[8px]":"rounded-none"),children:[n("div",{className:"flex flex-1 flex-col gap-[4px]",children:[e("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:t.balanceLabel??"AnkerCredits Balance"}),n("div",{className:"flex items-end gap-[4px]",children:[e("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:L(x?.available_credit??0)}),e("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:t.creditUnit??"ankercredits"})]})]}),e("div",{className:"h-full w-px bg-[#dadce0]"}),n("div",{className:"flex flex-1 flex-col gap-[4px]",children:[e("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:t.comingSoonLabel??"Coming Soon"}),n("div",{className:"flex items-end gap-[4px]",children:[e("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:L(x?.pending_credit??0)}),e("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:t.creditUnit??"ankercredits"})]})]})]})]}),n("div",{className:"flex flex-col gap-[16px]",children:[t.subtitle&&e("p",{className:"text-[16px] font-[700] text-[#1e2024]",children:t.subtitle}),e("div",{className:"flex flex-col",children:I.map((s,r)=>n("div",{className:"relative py-[16px]",children:[r>0&&e("div",{className:"absolute left-0 right-0 top-0 h-px bg-[#dadce0]"}),n("div",{className:c("flex items-center gap-[12px]",s.finished&&"opacity-60"),children:[e(V,{id:s.id,className:"size-[24px] shrink-0"}),n("div",{className:"flex-1",children:[e("div",{className:"text-[16px] font-[700] text-[#1e2024]",children:s.title}),s.description&&e("div",{className:"mt-[4px] text-[14px] font-[700] text-[#4a4c56]",children:s.description})]}),!s.finished&&s.link&&l?e("a",{href:s.link,target:"_blank",rel:"noopener noreferrer",className:c("cursor-pointer bg-[#080a0f] min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",u?"rounded-[4px]":"rounded-none"),children:s.buttonLabel}):e("button",{className:c("cursor-pointer min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",s.finished?"bg-[#767880]":"bg-[#080a0f]",u?"rounded-[4px]":"rounded-none"),disabled:s.finished,onClick:s.finished?void 0:s.onClick,children:s.buttonLabel})]})]},r))})]})]})}function H(t,a){switch(t){case i.Activate:return a.activate;case i.CompleteProfile:return a.completeProfileLabel;case i.Subscribe:return a.subscribeLabel;case i.Shop:return a.shopNow}}var Z=z;export{Z as default};
1
+ import{jsx as e,jsxs as a}from"react/jsx-runtime";import{useMemo as u}from"react";import{classNames as c,useHeadlessContext as T}from"@anker-in/lib";import{useMemberPopupContext as I}from"../../context/provider";import{useViewStack as _}from"../../context/viewStack";import{useSubscribed as A}from"./hooks/useSubscribed";import{EarnCreditsTaskType as n,MemberPopupPanelType as b}from"../../type";import{IconBag as B,IconLock as U,IconSubscription as D,IconOrders as M}from"../../icons";import{numberFormat as L}from"../../../credits/context/utils";import{ROUNDED_BRANDS as R}from"../../../../constants";function y({id:t,className:s}){switch(t){case n.Activate:return e(U,{className:s});case n.Subscribe:return e(D,{className:s});case n.Shop:return e(B,{className:s});case n.CompleteProfile:return e(M,{className:s})}}function F({copy:t,onClose:s,isSubscribeSuccess:v=!1,isActivateSuccess:g=!1,isProfileCompleteSuccess:f=!1}){const{profile:o,openSignUpPopup:d,alpcConfig:N,creditInfo:x}=I(),{pushView:p}=_(),{locale:w}=N,{brand:h}=T(),m=R.includes(h);console.log("creditInfo",x);const l=!!o,C=A({userId:o?.user_id,brand:h,email:o?.email,locale:w,apiBaseUrl:N.apiBaseUrl}),k=u(()=>f||!!(o?.first_name||o?.last_name)&&!!o?.phone_number&&!!o?.dob,[o,f]),S=u(()=>({[n.Activate]:{finished:!!o?.activated||g,onClick:l?()=>p({type:b.Activate}):d},[n.CompleteProfile]:{finished:k,onClick:l?()=>p({type:b.CompleteProfile}):d},[n.Subscribe]:{finished:C||v,onClick:l?()=>p({type:b.SubscribeEmail}):d},[n.Shop]:{finished:!1,link:t.goShopLink,onClick:l?void 0:d}}),[o,l,g,f,k,C,v,d,p,t.goShopLink]),E=u(()=>t.list.map(i=>{const r=S[i.id];if(!r)return null;const P=r.finished?t.completed:l?O(i.id,t):t.joinNow;return{...i,...r,buttonLabel:P}}).filter(Boolean),[t,S,l]);return a("div",{className:"flex flex-col gap-[16px]",children:[a("div",{className:"flex flex-col gap-[16px]",children:[e("div",{className:"flex flex-col gap-[8px]",children:t.title&&e("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title})}),l&&a("div",{className:c("flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]",m?"rounded-[8px]":"rounded-none"),children:[a("div",{className:"flex flex-1 flex-col gap-[4px]",children:[e("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:t.balanceLabel??"AnkerCredits Balance"}),a("div",{className:"flex items-end gap-[4px]",children:[e("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:L(x?.available_credit??0)}),e("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:t.creditUnit??"ankercredits"})]})]}),e("div",{className:"h-full w-px bg-[#dadce0]"}),a("div",{className:"flex flex-1 flex-col gap-[4px]",children:[e("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:t.comingSoonLabel??"Coming Soon"}),a("div",{className:"flex items-end gap-[4px]",children:[e("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:L(x?.pending_credit??0)}),e("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:t.creditUnit??"ankercredits"})]})]})]})]}),a("div",{className:"flex flex-col gap-[16px]",children:[t.subtitle&&e("p",{className:"text-[16px] font-[700] text-[#1e2024]",children:t.subtitle}),e("div",{className:"flex flex-col",children:E.map((i,r)=>a("div",{className:"relative py-[16px]",children:[r>0&&e("div",{className:"absolute left-0 right-0 top-0 h-px bg-[#dadce0]"}),a("div",{className:c("flex items-center gap-[12px]",i.finished&&"opacity-60"),children:[e(y,{id:i.id,className:"size-[24px] shrink-0"}),a("div",{className:"flex-1",children:[e("div",{className:"text-[16px] font-[700] text-[#1e2024]",children:i.title}),i.description&&e("div",{className:"mt-[4px] text-[14px] font-[700] text-[#4a4c56]",children:i.description})]}),!i.finished&&i.link&&l?e("a",{href:i.link,target:"_blank",rel:"noopener noreferrer",className:c("cursor-pointer bg-[#080a0f] min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",m?"rounded-[4px]":"rounded-none"),children:i.buttonLabel}):e("button",{className:c("cursor-pointer min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",i.finished?"bg-[#767880]":"bg-[#080a0f]",m?"rounded-[4px]":"rounded-none"),disabled:i.finished,onClick:i.finished?void 0:i.onClick,children:i.buttonLabel})]})]},r))})]})]})}function O(t,s){switch(t){case n.Activate:return s.activate;case n.CompleteProfile:return s.completeProfileLabel;case n.Subscribe:return s.subscribeLabel;case n.Shop:return s.shopNow}}var W=F;export{W as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/EarnCredits/index.tsx"],
4
- "sourcesContent": ["import { useMemo } from 'react'\nimport { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useSubscribed } from './hooks/useSubscribed'\nimport { EarnCreditsTaskType, MemberPopupPanelType, type EarnCreditsCopy } from '../../type'\nimport { IconBag, IconLock, IconSubscription, IconOrders } from '../../icons'\nimport { numberFormat } from '../../../credits/context/utils'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\nfunction TaskIcon({ id, className }: { id: EarnCreditsTaskType; className?: string }) {\n switch (id) {\n case EarnCreditsTaskType.Activate:\n return <IconLock className={className} />\n case EarnCreditsTaskType.Subscribe:\n return <IconSubscription className={className} />\n case EarnCreditsTaskType.Shop:\n return <IconBag className={className} />\n case EarnCreditsTaskType.CompleteProfile:\n return <IconOrders className={className} />\n }\n}\n\ntype Props = {\n copy: EarnCreditsCopy\n onClose: () => void\n isSubscribeSuccess?: boolean\n isActivateSuccess?: boolean\n isProfileCompleteSuccess?: boolean\n onSubscribeSuccess?: () => void\n onActivateSuccess?: () => void\n onProfileCompleteSuccess?: () => void\n}\n\nfunction EarnCredits({\n copy,\n onClose,\n isSubscribeSuccess = false,\n isActivateSuccess = false,\n isProfileCompleteSuccess = false,\n onSubscribeSuccess,\n onActivateSuccess,\n onProfileCompleteSuccess,\n}: Props) {\n const { profile, openSignUpPopup, alpcConfig, creditInfo } = useMemberPopupContext()\n const { pushView } = useViewStack()\n const { locale } = alpcConfig\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n console.log('creditInfo', creditInfo)\n\n const isLogin = !!profile\n\n const isSubscribed = useSubscribed({\n userId: profile?.user_id,\n brand: brand,\n email: profile?.email,\n locale,\n apiBaseUrl: alpcConfig.apiBaseUrl,\n })\n\n const profileCompleted = useMemo(() => {\n return (\n isProfileCompleteSuccess ||\n (!!(profile?.first_name || profile?.last_name) && !!profile?.phone_number && !!profile?.dob)\n )\n }, [profile, isProfileCompleteSuccess])\n\n const taskStates: Record<EarnCreditsTaskType, { finished: boolean; onClick?: () => void; link?: string }> = useMemo(\n () => ({\n [EarnCreditsTaskType.Activate]: {\n finished: !!profile?.activated || isActivateSuccess,\n onClick: isLogin\n ? () =>\n pushView({\n type: MemberPopupPanelType.Activate,\n props: { onSuccess: onActivateSuccess },\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.CompleteProfile]: {\n finished: profileCompleted,\n onClick: isLogin\n ? () =>\n pushView({\n type: MemberPopupPanelType.CompleteProfile,\n props: { onSuccess: onProfileCompleteSuccess },\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.Subscribe]: {\n finished: isSubscribed || isSubscribeSuccess,\n onClick: isLogin\n ? () =>\n pushView({\n type: MemberPopupPanelType.SubscribeEmail,\n props: { onSuccess: onSubscribeSuccess },\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.Shop]: {\n finished: false,\n link: copy.goShopLink,\n onClick: isLogin ? undefined : openSignUpPopup,\n },\n }),\n [\n profile,\n isLogin,\n isActivateSuccess,\n isProfileCompleteSuccess,\n profileCompleted,\n isSubscribed,\n isSubscribeSuccess,\n openSignUpPopup,\n pushView,\n copy.goShopLink,\n ]\n )\n\n const list = useMemo(() => {\n return copy.list\n .map(item => {\n const state = taskStates[item.id]\n if (!state) return null\n const buttonLabel = state.finished\n ? copy.completed\n : isLogin\n ? getNotFinishedLabel(item.id, copy)\n : copy.joinNow\n return { ...item, ...state, buttonLabel }\n })\n .filter(Boolean) as ((typeof copy.list)[number] & {\n finished: boolean\n onClick?: () => void\n link?: string\n buttonLabel: string\n })[]\n }, [copy, taskStates, isLogin])\n\n return (\n <div className=\"flex flex-col gap-[16px]\">\n <div className=\"flex flex-col gap-[16px]\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\n </div>\n\n {isLogin && (\n <div\n className={cn(\n 'flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]',\n rounded ? 'rounded-[8px]' : 'rounded-none'\n )}\n >\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.balanceLabel ?? 'AnkerCredits Balance'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.available_credit ?? 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n <div className=\"h-full w-px bg-[#dadce0]\" />\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.comingSoonLabel ?? 'Coming Soon'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.pending_credit ?? 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n </div>\n )}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n {copy.subtitle && <p className=\"text-[16px] font-[700] text-[#1e2024]\">{copy.subtitle}</p>}\n\n <div className=\"flex flex-col\">\n {list.map((item, idx) => (\n <div key={idx} className=\"relative py-[16px]\">\n {idx > 0 && <div className=\"absolute left-0 right-0 top-0 h-px bg-[#dadce0]\" />}\n <div className={cn('flex items-center gap-[12px]', item.finished && 'opacity-60')}>\n <TaskIcon id={item.id} className=\"size-[24px] shrink-0\" />\n <div className=\"flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024]\">{item.title}</div>\n {item.description && (\n <div className=\"mt-[4px] text-[14px] font-[700] text-[#4a4c56]\">{item.description}</div>\n )}\n </div>\n {!item.finished && item.link && isLogin ? (\n <a\n href={item.link}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={cn(\n 'cursor-pointer bg-[#080a0f] min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n >\n {item.buttonLabel}\n </a>\n ) : (\n <button\n className={cn(\n 'cursor-pointer min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n item.finished ? 'bg-[#767880]' : 'bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={item.finished}\n onClick={!item.finished ? item.onClick : undefined}\n >\n {item.buttonLabel}\n </button>\n )}\n </div>\n </div>\n ))}\n </div>\n </div>\n </div>\n )\n}\n\nfunction getNotFinishedLabel(id: EarnCreditsTaskType, copy: EarnCreditsCopy): string {\n switch (id) {\n case EarnCreditsTaskType.Activate:\n return copy.activate\n case EarnCreditsTaskType.CompleteProfile:\n return copy.completeProfileLabel\n case EarnCreditsTaskType.Subscribe:\n return copy.subscribeLabel\n case EarnCreditsTaskType.Shop:\n return copy.shopNow\n }\n}\n\nexport default EarnCredits\n"],
5
- "mappings": "AAaa,cAAAA,EAgJC,QAAAC,MAhJD,oBAbb,OAAS,WAAAC,MAAe,QACxB,OAAS,cAAcC,EAAI,sBAAAC,MAA0B,gBACrD,OAAS,yBAAAC,MAA6B,yBACtC,OAAS,gBAAAC,MAAoB,0BAC7B,OAAS,iBAAAC,MAAqB,wBAC9B,OAAS,uBAAAC,EAAqB,wBAAAC,MAAkD,aAChF,OAAS,WAAAC,EAAS,YAAAC,EAAU,oBAAAC,EAAkB,cAAAC,MAAkB,cAChE,OAAS,gBAAAC,MAAoB,iCAC7B,OAAS,kBAAAC,MAAsB,wBAE/B,SAASC,EAAS,CAAE,GAAAC,EAAI,UAAAC,CAAU,EAAoD,CACpF,OAAQD,EAAI,CACV,KAAKT,EAAoB,SACvB,OAAOR,EAACW,EAAA,CAAS,UAAWO,EAAW,EACzC,KAAKV,EAAoB,UACvB,OAAOR,EAACY,EAAA,CAAiB,UAAWM,EAAW,EACjD,KAAKV,EAAoB,KACvB,OAAOR,EAACU,EAAA,CAAQ,UAAWQ,EAAW,EACxC,KAAKV,EAAoB,gBACvB,OAAOR,EAACa,EAAA,CAAW,UAAWK,EAAW,CAC7C,CACF,CAaA,SAASC,EAAY,CACnB,KAAAC,EACA,QAAAC,EACA,mBAAAC,EAAqB,GACrB,kBAAAC,EAAoB,GACpB,yBAAAC,EAA2B,GAC3B,mBAAAC,EACA,kBAAAC,EACA,yBAAAC,CACF,EAAU,CACR,KA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adlessContext", "useMemberPopupContext", "useViewStack", "useSubscribed", "EarnCreditsTaskType", "MemberPopupPanelType", "IconBag", "IconLock", "IconSubscription", "IconOrders", "numberFormat", "ROUNDED_BRANDS", "TaskIcon", "id", "className", "EarnCredits", "copy", "onClose", "isSubscribeSuccess", "isActivateSuccess", "isProfileCompleteSuccess", "onSubscribeSuccess", "onActivateSuccess", "onProfileCompleteSuccess", "profile", "openSignUpPopup", "alpcConfig", "creditInfo", "pushView", "locale", "brand", "rounded", "isLogin", "isSubscribed", "profileCompleted", "taskStates", "list", "item", "state", "buttonLabel", "getNotFinishedLabel", "idx", "EarnCredits_default"]
4
+ "sourcesContent": ["import { useMemo } from 'react'\nimport { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useSubscribed } from './hooks/useSubscribed'\nimport { EarnCreditsTaskType, MemberPopupPanelType, type EarnCreditsCopy } from '../../type'\nimport { IconBag, IconLock, IconSubscription, IconOrders } from '../../icons'\nimport { numberFormat } from '../../../credits/context/utils'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\nfunction TaskIcon({ id, className }: { id: EarnCreditsTaskType; className?: string }) {\n switch (id) {\n case EarnCreditsTaskType.Activate:\n return <IconLock className={className} />\n case EarnCreditsTaskType.Subscribe:\n return <IconSubscription className={className} />\n case EarnCreditsTaskType.Shop:\n return <IconBag className={className} />\n case EarnCreditsTaskType.CompleteProfile:\n return <IconOrders className={className} />\n }\n}\n\ntype Props = {\n copy: EarnCreditsCopy\n onClose: () => void\n isSubscribeSuccess?: boolean\n isActivateSuccess?: boolean\n isProfileCompleteSuccess?: boolean\n}\n\nfunction EarnCredits({\n copy,\n onClose,\n isSubscribeSuccess = false,\n isActivateSuccess = false,\n isProfileCompleteSuccess = false,\n}: Props) {\n const { profile, openSignUpPopup, alpcConfig, creditInfo } = useMemberPopupContext()\n const { pushView } = useViewStack()\n const { locale } = alpcConfig\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n console.log('creditInfo', creditInfo)\n\n const isLogin = !!profile\n\n const isSubscribed = useSubscribed({\n userId: profile?.user_id,\n brand: brand,\n email: profile?.email,\n locale,\n apiBaseUrl: alpcConfig.apiBaseUrl,\n })\n\n const profileCompleted = useMemo(() => {\n return (\n isProfileCompleteSuccess ||\n (!!(profile?.first_name || profile?.last_name) && !!profile?.phone_number && !!profile?.dob)\n )\n }, [profile, isProfileCompleteSuccess])\n\n const taskStates: Record<EarnCreditsTaskType, { finished: boolean; onClick?: () => void; link?: string }> = useMemo(\n () => ({\n [EarnCreditsTaskType.Activate]: {\n finished: !!profile?.activated || isActivateSuccess,\n onClick: isLogin\n ? () =>\n pushView({\n type: MemberPopupPanelType.Activate,\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.CompleteProfile]: {\n finished: profileCompleted,\n onClick: isLogin\n ? () =>\n pushView({\n type: MemberPopupPanelType.CompleteProfile,\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.Subscribe]: {\n finished: isSubscribed || isSubscribeSuccess,\n onClick: isLogin\n ? () =>\n pushView({\n type: MemberPopupPanelType.SubscribeEmail,\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.Shop]: {\n finished: false,\n link: copy.goShopLink,\n onClick: isLogin ? undefined : openSignUpPopup,\n },\n }),\n [\n profile,\n isLogin,\n isActivateSuccess,\n isProfileCompleteSuccess,\n profileCompleted,\n isSubscribed,\n isSubscribeSuccess,\n openSignUpPopup,\n pushView,\n copy.goShopLink,\n ]\n )\n\n const list = useMemo(() => {\n return copy.list\n .map(item => {\n const state = taskStates[item.id]\n if (!state) return null\n const buttonLabel = state.finished\n ? copy.completed\n : isLogin\n ? getNotFinishedLabel(item.id, copy)\n : copy.joinNow\n return { ...item, ...state, buttonLabel }\n })\n .filter(Boolean) as ((typeof copy.list)[number] & {\n finished: boolean\n onClick?: () => void\n link?: string\n buttonLabel: string\n })[]\n }, [copy, taskStates, isLogin])\n\n return (\n <div className=\"flex flex-col gap-[16px]\">\n <div className=\"flex flex-col gap-[16px]\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\n </div>\n\n {isLogin && (\n <div\n className={cn(\n 'flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]',\n rounded ? 'rounded-[8px]' : 'rounded-none'\n )}\n >\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.balanceLabel ?? 'AnkerCredits Balance'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.available_credit ?? 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n <div className=\"h-full w-px bg-[#dadce0]\" />\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.comingSoonLabel ?? 'Coming Soon'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.pending_credit ?? 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n </div>\n )}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n {copy.subtitle && <p className=\"text-[16px] font-[700] text-[#1e2024]\">{copy.subtitle}</p>}\n\n <div className=\"flex flex-col\">\n {list.map((item, idx) => (\n <div key={idx} className=\"relative py-[16px]\">\n {idx > 0 && <div className=\"absolute left-0 right-0 top-0 h-px bg-[#dadce0]\" />}\n <div className={cn('flex items-center gap-[12px]', item.finished && 'opacity-60')}>\n <TaskIcon id={item.id} className=\"size-[24px] shrink-0\" />\n <div className=\"flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024]\">{item.title}</div>\n {item.description && (\n <div className=\"mt-[4px] text-[14px] font-[700] text-[#4a4c56]\">{item.description}</div>\n )}\n </div>\n {!item.finished && item.link && isLogin ? (\n <a\n href={item.link}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={cn(\n 'cursor-pointer bg-[#080a0f] min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n >\n {item.buttonLabel}\n </a>\n ) : (\n <button\n className={cn(\n 'cursor-pointer min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n item.finished ? 'bg-[#767880]' : 'bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={item.finished}\n onClick={!item.finished ? item.onClick : undefined}\n >\n {item.buttonLabel}\n </button>\n )}\n </div>\n </div>\n ))}\n </div>\n </div>\n </div>\n )\n}\n\nfunction getNotFinishedLabel(id: EarnCreditsTaskType, copy: EarnCreditsCopy): string {\n switch (id) {\n case EarnCreditsTaskType.Activate:\n return copy.activate\n case EarnCreditsTaskType.CompleteProfile:\n return copy.completeProfileLabel\n case EarnCreditsTaskType.Subscribe:\n return copy.subscribeLabel\n case EarnCreditsTaskType.Shop:\n return copy.shopNow\n }\n}\n\nexport default EarnCredits\n"],
5
+ "mappings": "AAaa,cAAAA,EAuIC,QAAAC,MAvID,oBAbb,OAAS,WAAAC,MAAe,QACxB,OAAS,cAAcC,EAAI,sBAAAC,MAA0B,gBACrD,OAAS,yBAAAC,MAA6B,yBACtC,OAAS,gBAAAC,MAAoB,0BAC7B,OAAS,iBAAAC,MAAqB,wBAC9B,OAAS,uBAAAC,EAAqB,wBAAAC,MAAkD,aAChF,OAAS,WAAAC,EAAS,YAAAC,EAAU,oBAAAC,EAAkB,cAAA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U,gBAAkB,cAC9B,EACA,SAAUM,EAAK,SACf,QAAUA,EAAK,SAA0B,OAAfA,EAAK,QAE9B,SAAAA,EAAK,YACR,GAEJ,IAnCQI,CAoCV,CACD,EACH,GACF,GACF,CAEJ,CAEA,SAASD,EAAoBxB,EAAyBG,EAA+B,CACnF,OAAQH,EAAI,CACV,KAAKT,EAAoB,SACvB,OAAOY,EAAK,SACd,KAAKZ,EAAoB,gBACvB,OAAOY,EAAK,qBACd,KAAKZ,EAAoB,UACvB,OAAOY,EAAK,eACd,KAAKZ,EAAoB,KACvB,OAAOY,EAAK,OAChB,CACF,CAEA,IAAOuB,EAAQxB",
6
+ "names": ["jsx", "jsxs", "useMemo", "cn", "useHeadlessContext", "useMemberPopupContext", "useViewStack", "useSubscribed", "EarnCreditsTaskType", "MemberPopupPanelType", "IconBag", "IconLock", "IconSubscription", "IconOrders", "numberFormat", "ROUNDED_BRANDS", "TaskIcon", "id", "className", "EarnCredits", "copy", "onClose", "isSubscribeSuccess", "isActivateSuccess", "isProfileCompleteSuccess", "profile", "openSignUpPopup", "alpcConfig", "creditInfo", "pushView", "locale", "brand", "rounded", "isLogin", "isSubscribed", "profileCompleted", "taskStates", "list", "item", "state", "buttonLabel", "getNotFinishedLabel", "idx", "EarnCredits_default"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anker-in/campaign-ui",
3
- "version": "0.5.0-beta.11",
3
+ "version": "0.5.0-beta.12",
4
4
  "description": "Campaign UI components and utilities for Anker projects",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
 
3
- import { lazy, Suspense, useState, useCallback, useMemo } from 'react'
3
+ import { lazy, Suspense, useState, useCallback, useMemo, useEffect } from 'react'
4
4
  import { Picture } from '@anker-in/headless-ui'
5
5
  import { type HeadlessConfig, useHeadlessContext, classNames as cn } from '@anker-in/lib'
6
6
  import {
@@ -33,11 +33,28 @@ type MemberPopupProps = MemberPopupContextValue & {
33
33
  }
34
34
 
35
35
  export function MemberPopup({ copy, bottomOffset = '24px', ...providerProps }: MemberPopupProps) {
36
- return (
36
+ const isVisible = useMemo(() => {
37
+ const config = copy.pageConfig
38
+ if (!config) return true
39
+ const pathname = typeof window !== 'undefined' ? window.location.pathname : ''
40
+ const matches = config.pages.some(page => pathname === page || pathname.startsWith(page + '/'))
41
+ switch (config.scope) {
42
+ case MemberPopupPageScope.Include:
43
+ return matches
44
+ case MemberPopupPageScope.Exclude:
45
+ return !matches
46
+ default:
47
+ return true
48
+ }
49
+ }, [copy.pageConfig])
50
+
51
+ console.log('isVisible', isVisible)
52
+
53
+ return isVisible ? (
37
54
  <MemberPopupProvider {...providerProps} earnCreditsCopy={copy.earnCredits}>
38
55
  <MemberPopupContent copy={copy} bottomOffset={bottomOffset} />
39
56
  </MemberPopupProvider>
40
- )
57
+ ) : null
41
58
  }
42
59
 
43
60
  type MemberPopupContentProps = {
@@ -59,21 +76,6 @@ function MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {
59
76
 
60
77
  const currentView = viewStack[viewStack.length - 1] ?? null
61
78
 
62
- const isVisible = useMemo(() => {
63
- const config = copy.pageConfig
64
- if (!config) return true
65
- const pathname = typeof window !== 'undefined' ? window.location.pathname : ''
66
- const matches = config.pages.some(page => pathname === page || pathname.startsWith(page + '/'))
67
- switch (config.scope) {
68
- case MemberPopupPageScope.Include:
69
- return matches
70
- case MemberPopupPageScope.Exclude:
71
- return !matches
72
- default:
73
- return true
74
- }
75
- }, [copy.pageConfig])
76
-
77
79
  const pushView = useCallback((view: ViewPayload) => {
78
80
  setViewStack(prev => [...prev, view])
79
81
  }, [])
@@ -82,9 +84,6 @@ function MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {
82
84
  setViewStack(prev => prev.slice(0, -1))
83
85
  }, [])
84
86
 
85
- console.log('isVisible', isVisible)
86
- if (!isVisible) return null
87
-
88
87
  function handleAction(type: MemberPopupActionType, url?: string) {
89
88
  switch (type) {
90
89
  case MemberPopupActionType.ExternalLink:
@@ -178,12 +177,9 @@ function MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {
178
177
  <EarnCredits
179
178
  copy={copy.earnCredits}
180
179
  onClose={popView}
180
+ isProfileCompleteSuccess={isProfileCompleteSuccess}
181
181
  isSubscribeSuccess={isSubscribeSuccess}
182
182
  isActivateSuccess={isActivateSuccess}
183
- isProfileCompleteSuccess={isProfileCompleteSuccess}
184
- onSubscribeSuccess={() => setIsSubscribeSuccess(true)}
185
- onActivateSuccess={() => setIsActivateSuccess(true)}
186
- onProfileCompleteSuccess={() => setIsProfileCompleteSuccess(true)}
187
183
  />
188
184
  )}
189
185
  {currentView.type === MemberPopupPanelType.ConsumeCredits && copy.consumeCredits && (
@@ -201,14 +197,14 @@ function MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {
201
197
  copy={copy.earnCredits.completeProfile}
202
198
  shopifyStoreDomain={storeDomain}
203
199
  onClose={popView}
204
- onSuccess={currentView.props?.onSuccess}
200
+ onSuccess={() => setIsProfileCompleteSuccess(true)}
205
201
  />
206
202
  )}
207
203
  {currentView.type === MemberPopupPanelType.Subscribe && copy.activitiesSubscribe && (
208
204
  <ActivitiesSubscribe
209
205
  copy={copy.activitiesSubscribe}
210
206
  email={profile?.email}
211
- onSuccess={currentView.props?.onSuccess}
207
+ onSuccess={() => setIsSubscribeSuccess(true)}
212
208
  hideForm={isSubscribeFormHidden}
213
209
  onHideForm={() => setIsSubscribeFormHidden(true)}
214
210
  />
@@ -218,14 +214,16 @@ function MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {
218
214
  copy={copy.earnCredits.subscribe}
219
215
  email={profile?.email}
220
216
  onClose={popView}
221
- onSuccess={currentView.props?.onSuccess}
217
+ onSuccess={() => setIsSubscribeSuccess(true)}
222
218
  />
223
219
  )}
224
220
  {currentView.type === MemberPopupPanelType.Activate && copy.earnCredits && (
225
221
  <Activate
226
222
  copy={copy.earnCredits.authCodeActivate}
227
223
  onClose={popView}
228
- onSuccess={currentView.props?.onSuccess}
224
+ onSuccess={() => {
225
+ setIsActivateSuccess(true)
226
+ }}
229
227
  />
230
228
  )}
231
229
  {currentView.type === MemberPopupPanelType.RedeemCoupon &&
@@ -27,9 +27,6 @@ type Props = {
27
27
  isSubscribeSuccess?: boolean
28
28
  isActivateSuccess?: boolean
29
29
  isProfileCompleteSuccess?: boolean
30
- onSubscribeSuccess?: () => void
31
- onActivateSuccess?: () => void
32
- onProfileCompleteSuccess?: () => void
33
30
  }
34
31
 
35
32
  function EarnCredits({
@@ -38,9 +35,6 @@ function EarnCredits({
38
35
  isSubscribeSuccess = false,
39
36
  isActivateSuccess = false,
40
37
  isProfileCompleteSuccess = false,
41
- onSubscribeSuccess,
42
- onActivateSuccess,
43
- onProfileCompleteSuccess,
44
38
  }: Props) {
45
39
  const { profile, openSignUpPopup, alpcConfig, creditInfo } = useMemberPopupContext()
46
40
  const { pushView } = useViewStack()
@@ -75,7 +69,6 @@ function EarnCredits({
75
69
  ? () =>
76
70
  pushView({
77
71
  type: MemberPopupPanelType.Activate,
78
- props: { onSuccess: onActivateSuccess },
79
72
  })
80
73
  : openSignUpPopup,
81
74
  },
@@ -85,7 +78,6 @@ function EarnCredits({
85
78
  ? () =>
86
79
  pushView({
87
80
  type: MemberPopupPanelType.CompleteProfile,
88
- props: { onSuccess: onProfileCompleteSuccess },
89
81
  })
90
82
  : openSignUpPopup,
91
83
  },
@@ -95,7 +87,6 @@ function EarnCredits({
95
87
  ? () =>
96
88
  pushView({
97
89
  type: MemberPopupPanelType.SubscribeEmail,
98
- props: { onSuccess: onSubscribeSuccess },
99
90
  })
100
91
  : openSignUpPopup,
101
92
  },