1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[40402],{96433:(e,r,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/super/referrals-metrics",function(){return t(60050)}])},69235:(e,r,t)=>{"use strict";t.d(r,{A:()=>c});var l=t(2445),n=t(27006),a=t(58156),i=t.n(a),o=t(58065),s=t(7817);let c=e=>{let{role:r,children:t}=e,a=(0,s.A)(),c=(Array.isArray(r)?r:[r]).some(e=>i()(a,e));return a?c?t:(0,l.Y)(n.Center,{children:(0,l.Y)(n.Text,{fontSize:"xl",fontWeight:"bold",color:"red.500",children:(0,l.Y)(o.A,{id:"admin.shared.æ¬éä¸è¶³",defaultMessage:"æ¬éä¸è¶³"})})}):(0,l.Y)(n.Center,{children:(0,l.Y)(n.Spinner,{})})}},66351:(e,r,t)=>{"use strict";t.d(r,{A:()=>i});var l=t(2445),n=t(27006);function a(e){let{getInputProps:r,getCheckboxProps:t}=(0,n.useRadio)(e),a=r(),i=t();return(0,l.FD)(n.Box,{as:"label",children:[(0,l.Y)("input",{...a}),(0,l.Y)(n.Box,{...i,cursor:"pointer",whiteSpace:"nowrap",borderLeft:"4px solid transparent",_checked:{borderLeftColor:"teal.500",color:"teal.500"},px:"3",py:"1",children:e.children})]})}let i=e=>{let{options:r,onChange:t,defaultValue:i}=e,{getRootProps:o,getRadioProps:s}=(0,n.useRadioGroup)({defaultValue:i,onChange:t}),c=o();return(0,l.FD)(l.FK,{children:[(0,l.Y)(n.Select,{display:{base:"block",lg:"none"},w:"full",defaultValue:i,onChange:e=>t(e.target.value),children:r.map(e=>{let{value:r,label:t}=e;return(0,l.Y)("option",{value:r,children:t},r)})}),(0,l.Y)(n.Stack,{display:{base:"none",lg:"flex"},...c,children:r.map(e=>{let{value:r,label:t}=e,n=s({value:r});return(0,l.Y)(a,{...n,children:t},r)})})]})}},95738:(e,r,t)=>{"use strict";t.d(r,{A:()=>i,m:()=>a});var l=t(2445),n=t(22061);let a=[{name:"analytics",label:"Metrics"},{name:"revenue",label:"çæ¶åæ"},{name:"subscriptions",label:"æå¡åæ"},{name:"payment",label:"Payment"},{name:"product-metrics",label:"ç¢åææ¨"},{name:"affiliates",label:"Rewards"},{name:"digital-products",label:"ååè´å©"},{name:"referrals-metrics",label:"æ¨è¦ææåæ"}],i=e=>{let{tabs:r}=e;return(0,l.Y)(n.A,{tabs:r,allTabs:a})}},22061:(e,r,t)=>{"use strict";t.d(r,{A:()=>u});var l=t(2445),n=t(27006),a=t(86715),i=t(38146),o=t(69235),s=t(66351),c=t(68296);let u=e=>{let{tabs:r=[],allTabs:t=[],requiredRole:u=!1,title:d=""}=e,h=(0,a.useRouter)(),p=h.asPath.split("?")[0],f=t.findIndex(e=>"/admin/super/".concat(e.name)===p),m=r.findIndex(e=>e.query===h.query.tab),Y=(0,l.FD)(n.Tabs,{variant:"soft-rounded",colorScheme:"teal",isLazy:!0,defaultIndex:m>=0?m:0,onChange:e=>{let t=r[e].query;window.history.pushState({},"","".concat(window.location.pathname).concat(t?"?tab=".concat(t):""))},children:[(0,l.Y)(n.TabList,{overflow:"auto",display:"block",whiteSpace:"nowrap",children:r.map((e,r)=>(0,l.Y)(n.Tab,{display:"inline-flex",children:e.label},r))}),(0,l.Y)(n.TabPanels,{children:r.map((e,r)=>(0,l.Y)(n.TabPanel,{children:(0,l.Y)(i.A,{children:e.comp})},r))})]});return(0,l.Y)(c.A,{children:(0,l.FD)(n.VStack,{children:[d&&(0,l.Y)(n.Heading,{as:"h1",size:"lg",mb:"4",textAlign:"left",w:"full",children:d}),(0,l.FD)(n.Stack,{direction:{base:"column",lg:"row"},alignItems:"flex-start",spacing:{base:4,lg:8},divider:(0,l.Y)(n.StackDivider,{}),w:"full",children:[t.length>1&&(0,l.Y)(n.Box,{flexShrink:0,minW:0,w:{base:"full",lg:"auto"},pos:{lg:"sticky"},top:"4",children:(0,l.Y)(s.A,{options:t.map((e,r)=>({label:e.label,value:"".concat(r)})),onChange:e=>{h.push("/admin/super/".concat(t[e].name))},defaultValue:"".concat(f)})}),(0,l.Y)(n.Box,{flex:"1",w:"full",minW:0,children:u?(0,l.Y)(o.A,{role:u,children:Y}):Y})]})]})})}},67555:(e,r,t)=>{"use strict";t.d(r,{A:()=>f});var l=t(2445),n=t(83450),a=t(38340),i=t(55939),o=t(98579);t(96540);var s=t(42371),c=t(58422),u=t(12913),d=t(54170);let h=Math.PI/180,p=e=>{let{cx:r,cy:t,midAngle:n,innerRadius:a,outerRadius:i,percent:o,value:s,label:c}=e,u=a+(i-a)*.5,d=r+u*Math.cos(-n*h),p=t+u*Math.sin(-n*h);return(0,l.FD)("text",{x:d,y:p,fill:"white",textAnchor:"middle",dominantBaseline:"central",transform:"translate(0, -10)",children:[(0,l.Y)("tspan",{children:c}),(0,l.FD)("tspan",{x:d,dy:"1.5em",children:[s," (","".concat((100*o).toFixed(0),"%"),")"]})]})},f=e=>{let{title:r,values:t}=e,h=(0,o.rd)("colors",["teal.500","purple.300","yellow.400","green.400","blue.400","red.400"]);return(0,l.FD)(n.B,{flex:"1",p:4,borderRadius:"xl",border:"1px solid",borderColor:"gray.100",ps:!0,children:[(0,l.Y)(a.D,{size:"md",children:r}),(0,l.Y)(i.g,{ratio:1,children:(0,l.Y)(s.u,{children:(0,l.Y)(c.r,{children:(0,l.Y)(u.F,{data:t,cx:"50%",cy:"50%",dataKey:"value",labelLine:!1,label:p,animationDuration:500,children:t.map((e,r)=>(0,l.Y)(d.f,{fill:h[r]},"cell-".concat(r)))})})})})]})}},10767:(e,r,t)=>{"use strict";t.d(r,{A:()=>i});
1var l=t(96540),n=t(99624),a=t(36795);let i=()=>{let{addSdk:e,activeSDK:r}=(0,l.useContext)(a.A);return(0,l.useEffect)(()=>{r.includes("auth")||setTimeout(()=>e("auth"))},[r]),r.includes("auth")&&(0,n.As)()}},11335:(e,r,t)=>{"use strict";t.d(r,{A:()=>u});var l=t(55364),n=t.n(l),a=t(96540),i=t(8519),o=t(10767);let s=new Map,c=["auth/id-token-expired","auth/id-token-revoked","auth/argument-error"],u=()=>{let e=(0,a.useRef)(0),r=(0,o.A)();return(0,a.useCallback)(async(t,l)=>{var a,o,u;let d="".concat("portaly:firebaseToken",":").concat(null===(a=r.currentUser)||void 0===a?void 0:a.uid),h=null!==(u=null===(o=(0,i.A)("session"))||void 0===o?void 0:o.getItem(d))&&void 0!==u?u:s.get(d),p=async()=>{h=await r.currentUser.getIdToken(!0),(0,i.F)(d,h,"session"),s.set(d,h)};h||await p();let f=async()=>{let r=await fetch(t,n()({},l,h&&{headers:{Authorization:"Bearer ".concat(h)}}));if(r.ok)return e.current=0,204===r.status?null:r.json();let a=await r.text();if(c.includes(a)&&e.current<3)return e.current+=1,await p(),f();let i=Error(a);return i.response=r,Promise.reject(i)};return f()},[r])}},60050:(e,r,t)=>{"use strict";t.r(r),t.d(r,{default:()=>A});var l=t(2445),n=t(13368),a=t.n(n),i=t(95738),o=t(27006),s=t(94394),c=t.n(s),u=t(96540),d=t(59324),h=t(58323),p=t(11335),f=t(84316),m=t(67555);let Y={MONTHLY_PRICE:249,YEARLY_PRICE:2190},b={MONTHS:10,YEARS:1.5},g=e=>{let{ltvResult:r}=e,t=e=>new Intl.NumberFormat("zh-TW",{style:"currency",currency:"TWD",minimumFractionDigits:0}).format(e);return(0,l.Y)(o.Box,{p:6,borderRadius:"xl",border:"1px solid",borderColor:"gray.100",bg:"white",children:(0,l.FD)(o.Stack,{spacing:6,children:[(0,l.Y)(o.HStack,{justify:"space-between",align:"center",children:(0,l.Y)(o.Heading,{size:"md",children:"LTV 試ç®ï¼éé¡ï¼"})}),(0,l.FD)(o.SimpleGrid,{columns:{base:1,md:3},spacing:4,children:[(0,l.FD)(o.Stat,{children:[(0,l.Y)(o.StatLabel,{children:"æè¨ç¨æ¶ LTV"}),(0,l.Y)(o.StatNumber,{color:"blue.500",children:t(r.monthlyUsersLTV)}),(0,l.FD)(o.StatHelpText,{children:[r.monthlyUsersCount," ä½ç¨æ¶ \xd7 æè²»ï¼",t(Y.MONTHLY_PRICE),"ï¼ \xd7 ææ¸"]})]}),(0,l.FD)(o.Stat,{children:[(0,l.Y)(o.StatLabel,{children:"å¹´è¨ç¨æ¶ LTV"}),(0,l.Y)(o.StatNumber,{color:"green.500",children:t(r.yearlyUsersLTV)}),(0,l.FD)(o.StatHelpText,{children:[r.yearlyUsersCount," ä½ç¨æ¶ \xd7 å¹´è²»ï¼",t(Y.YEARLY_PRICE),"ï¼ \xd7 ",b.YEARS]})]}),(0,l.FD)(o.Stat,{children:[(0,l.Y)(o.StatLabel,{children:"總 LTV"}),(0,l.Y)(o.StatNumber,{color:"purple.500",fontSize:"2xl",children:t(r.totalLTV)}),(0,l.Y)(o.StatHelpText,{children:"æè¨ LTV + å¹´è¨ LTV"})]})]}),(0,l.Y)(o.Divider,{}),(0,l.FD)(o.Box,{bg:"gray.50",p:4,borderRadius:"md",children:[(0,l.Y)(o.Text,{fontSize:"sm",fontWeight:"medium",mb:2,children:"LTV è¨ç®å
¬å¼ï¼"}),(0,l.FD)(o.Stack,{fontSize:"sm",spacing:1,color:"gray.700",children:[(0,l.FD)(o.Text,{children:["⢠æè¨ç¨æ¶ LTV = è§å¯çªå
§ææåå¹æè²»çç´¯è¨ï¼",t(Y.MONTHLY_PRICE),"/æï¼ï¼è¨é±ä¸ç¨æ¶ä»¥è¨é± ",b.MONTHS," åæè¨ç®"]}),(0,l.FD)(o.Text,{children:["⢠年è¨ç¨æ¶ LTV = å¹´è²»ï¼",t(Y.YEARLY_PRICE),"ï¼\xd7"," ",b.YEARS]}),(0,l.Y)(o.Text,{children:"⢠總 LTV = æè¨ LTV + å¹´è¨ LTV"})]})]})]})})},S=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.entries(e).map(e=>{let[t,l]=e;return{label:r[t],value:l.length}}).filter(e=>e.label).sort((e,r)=>r.value-e.value)},x=e=>{let{subscriptionStatus:r}=e;return r&&"normal"===r.status?"M"===r.period?"M":"Y":"unknown"},T=e=>{let{subscriptionStatus:r}=e;if(!r)return"unknown";if("normal"===r.status||"trial"===r.status||"error"===r.status)return r.status;if((null==r?void 0:r.subscriptionDuration)===void 0)return"unknown";let t=parseInt(r.subscriptionDuration,10);return t<=30?"cancelled_1month":t<=60?"cancelled_2months":t<=90?"cancelled_3months":t<=180?"cancelled_6months":"cancelled_long_term"},v=()=>{let e=(0,p.A)(),{data:r,isLoading:t,error:n}=(0,d.Ay)("/api/super/analytics/referral/firstTimeRewardResults",e),a=(0,u.useMemo)(()=>[{Header:"使ç¨è
å稱",accessor:"referredName",Cell:e=>{let{row:{original:r}}=e,t=(0,f.A)(r.referredSlug);return(0,l.Y)(o.Link,{href:t,isExternal:!0,target:"_blank",rel:"noopener noreferrer",children:r.referredName})}},{Header:"使ç¨è
Slug",accessor:"referredSlug",Cell:e=>{let{row:{original:r}}=e,t=(0,f.A)(r.referredSlug);return(0,l.Y)(o.Link,{href:t,isExternal:!0,target:"_blank",rel:"noopener noreferrer",children:r.referredSlug})}},{Header:"æ¨è¦äººå稱",accessor:"referralName",Cell:e=>{let{row:{original:r}}=e,t=(0,f.A)(r.referralSlug);return(0,l.Y)(o.Link,{href:t,isExternal:!0,target:"_blank",rel:"noopener noreferrer",children:r.referralName})}},{Header:"æ¨è¦äºº Slug",accessor:"referralSlug",Cell:e=>{let{row:{original:r}}=e,t=(0,f.A)(r.referralSlug);return(0,l.Y)(o.Link,{href:t,isExternal:!0,target:"_blank",rel:"noopener noreferrer",children:r.referralSlug})}},{Header:"è¨é±çæ
",Cell:e=>{var r;let{row:{original:t}}=e;return(0,l.Y)(o.Text,{children:(null===(r=t.subscriptionStatus)||void 0===r?void 0:r.status)==="normal"?"è¨é±ä¸":"已忶"})}},{Header:"è¨é±æ¹æ¡",Cell:e=>{let{row:{original:r}}=e;return(0,l.Y)(o.Text,{children:r.subscriptionStatus.period})}},{Header:"è¨é±å¤©æ¸",Cell:e=>{let{row:{original:r}}=e;return(0,l.Y)(o.Text,{children:r.subscriptionStatus.subscriptionDuration?Math.ceil(parseInt(r.subscriptionStatus.subscriptionDuration,10)/30):""})}},{Header:"åæ¶åå ",Cell:e=>{let{row:{original:r}}=e;return(0,l.Y)(o.Text,{children:r.subscriptionStatus.reason})}}],[]);if(t)return(0,l.Y)(o.Spinner,{});if(n)return(0,l.Y)("div",{children:"Failed to load"});if(!r)return(0,l.Y)(o.Spinner,{});if(!r.data)return(0,l.Y)("div",{children:"No data"});let i=null==r?void 0:r.data,s=c()(i,T),v=c()(i,x),w=i.filter(e=>{var r,t;return(null===(r=e.subscriptionStatus)||void 0===r?void 0:r.status)==="normal"||(null===(t=e.subscriptionStatus)||void 0===t?void 0:t.status)==="terminate"}),A=function(e){let r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=[],l=[],n=0,a=0;
1return e.forEach(e=>{let{subscriptionStatus:i,referredName:o,referredSlug:s,referralName:c,referralSlug:u}=e;if(i){if("M"===i.period){let r=function(e){let{subscriptionStatus:r}=e;return r?r.subscriptionDuration?Math.ceil(parseInt(r.subscriptionDuration,10)/30)*Y.MONTHLY_PRICE:b.MONTHS*Y.MONTHLY_PRICE:0}(e);r>0&&(n+=r,t.push({name:o,slug:s,referralName:c,referralSlug:u,subscriptionDuration:i.subscriptionDuration?Math.ceil(parseInt(i.subscriptionDuration,10)/30):b.MONTHS,ltv:r}))}else if("Y"===i.period){let t=function(e){let r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],{subscriptionStatus:t}=e;return t?r?Y.YEARLY_PRICE*(b.MONTHS/12):Y.YEARLY_PRICE*b.YEARS:0}(e,r);t>0&&(a+=t,l.push({name:o,slug:s,referralName:c,referralSlug:u,ltv:t}))}}}),{monthlyUsersLTV:n,yearlyUsersLTV:a,totalLTV:n+a,monthlyUsersCount:t.length,yearlyUsersCount:l.length,details:{monthlyUsers:t,yearlyUsers:l}}}(w);return(0,l.FD)(o.Stack,{spacing:6,children:[(0,l.FD)(o.Stack,{spacing:6,direction:"row",width:"100%",children:[(0,l.Y)(m.A,{title:"被æ¨è¦ç¨æ¶è¨é±çæ³",values:S(s,{normal:"è¨é±ä¸",trial:"å
費試ç¨ä¸",cancelled_1month:"è¨é±ä¸åæåæ¶",cancelled_2months:"è¨é±å
©åæåæ¶",cancelled_3months:"è¨é±ä¸åæåæ¶",cancelled_6months:"è¨é±å
åæåæ¶",cancelled_long_term:"è¨é±é·æåæ¶"})}),(0,l.Y)(m.A,{title:"被æ¨è¦ç¨æ¶è¨é±æé",values:S(v,{M:"æè¨é±",Y:"å¹´è¨é±"})})]}),(0,l.Y)(g,{ltvResult:A}),(0,l.Y)(o.Heading,{fontSize:"2xl",textAlign:"center",children:"è¨é±ç¨æ¶è©³ç´°è³æ"}),(0,l.Y)(h.A,{data:w,columns:a})]})},w=()=>{let e=(0,p.A)(),{data:r,isLoading:t,error:n}=(0,d.Ay)("/api/super/analytics/referral/referralResults",e),a=(0,u.useMemo)(()=>[{Header:"æ¨è¦äººå稱",accessor:"referralName",Cell:e=>{let{row:{original:r}}=e,t=(0,f.A)(r.referralSlug);return(0,l.Y)(o.Link,{href:t,isExternal:!0,target:"_blank",rel:"noopener noreferrer",children:r.referralName})}},{Header:"æ¨è¦äºº Slug",accessor:"referralSlug",Cell:e=>{let{row:{original:r}}=e,t=(0,f.A)(r.referralSlug);return(0,l.Y)(o.Link,{href:t,isExternal:!0,target:"_blank",rel:"noopener noreferrer",children:r.referralSlug})}},{Header:"æ¨è¦ç¨æ¶ç¸½æ¸",accessor:"referralCount"},{Header:"æ¨è¦ä»è²»ç¨æ¶ç¸½æ¸",accessor:"subscribeReferralCount"}],[]);if(t)return(0,l.Y)(o.Spinner,{});if(n)return(0,l.Y)("div",{children:"Failed to load"});if(!r)return(0,l.Y)(o.Spinner,{});if(!r.data)return(0,l.Y)("div",{children:"No data"});let i=null==r?void 0:r.data;return(0,l.Y)(l.FK,{children:(0,l.Y)(h.A,{data:i,columns:a,canExport:!0})})};function A(){return(0,l.FD)(l.FK,{children:[(0,l.Y)(a(),{children:(0,l.FD)("title",{children:["SuperAdmin | ","Portaly"]})}),(0,l.Y)(i.A,{tabs:[{label:"æ¨è¦è
ææç¸½è¦½è¡¨",comp:(0,l.Y)(w,{})},{label:"100 å
æç表è LTV 試ç®",comp:(0,l.Y)(v,{})}]})]})}}},e=>{var r=r=>e(e.s=r);e.O(0,[19883,28505,58247,67690,87551,81544,53958,80971,64065,99624,13404,77381,90585,47533,57716,59324,2524,31278,42020,75688,64190,45915,90636,46593,38792],()=>r(96433)),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.