vendor: 7,407 bytes, lines 1-2
1import{a as D,r as v,j as e}from"./vendor-react-CSQ4l2Qt.js";import{A as st}from"./AdminLayout-ZxLqBONy.js";import{R as ye,g as oe}from"./react-country-flag.esm-us5bmqfA.js";import{g as se,a as Ae,E as at}from"./EmailComposerModal-B9I87HyW.js";import{T as nt,a as rt,b as Ce,c as U,d as it,e as I}from"./table-BSmngJLi.js";import{ai as _e,B as X,C as S,k,l as A,n as C,aj as M,m as Ue,v as lt}from"./index-BAoGeGy8.js";import{u as ot}from"./useAdminAPI-CeHyujfP.js";import{a5 as Re,a6 as ct,i as Be,a7 as dt,a8 as Me,N as ze,a9 as Fe,aa as Ge,a4 as mt,a as xt}from"./vendor-icons-BzYMg0rX.js";import{i as pt,D as ht,f as ut,E as ft,L as De,a as Ne,C as gt,A as jt,b as ce,c as yt,d as Ee,h as Nt,e as vt,g as Xe,u as bt,G as wt,j as Ke,k as St,X as V,Y,l as kt,R as J,m as At,T as Q,B as ae,n as de}from"./generateCategoricalChart-BJ6BJGje.js";import{B as ne}from"./BarChart-DbZZ0W6L.js";import"./vendor-common-Cpj98o6Y.js";import"./vendor-router-CCuRhTj0.js";import"./vendor-radix-ZWey7SXZ.js";import"./input-BMXZwAiI.js";import"./label-BanYa52H.js";import"./checkbox-B08dUMiD.js";import"./alert-dialog-DEH67UsE.js";import"./outreach-email-template-DTu9Ovz1.js";import"./vendor-query-DKDaiBxq.js";import"./vendor-helmet-D0NSfYc1.js";import"./vendor-markdown-Cz07tREc.js";var Ct=["type","layout","connectNulls","ref"],Dt=["key"];function le(s){"@babel/helpers - typeof";return le=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},le(s)}function We(s,a){if(s==null)return{};var r=Pt(s,a),n,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(s);for(i=0;i<o.length;i++)n=o[i],!(a.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(s,n)&&(r[n]=s[n])}return r}function Pt(s,a){if(s==null)return{};var r={};for(var n in s)if(Object.prototype.hasOwnProperty.call(s,n)){if(a.indexOf(n)>=0)continue;r[n]=s[n]}return r}function me(){return me=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var r=arguments[a];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(s[n]=r[n])}return s},me.apply(this,arguments)}function Ve(s,a){var r=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);a&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(s,i).enumerable})),r.push.apply(r,n)}return r}function E(s){for(var a=1;a<arguments.length;a++){var r=arguments[a]!=null?arguments[a]:{};a%2?Ve(Object(r),!0).forEach(function(n){$(s,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(r)):Ve(Object(r)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(r,n))})}return s}function re(s){return Tt(s)||Ot(s)||Lt(s)||Et()}function Et(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 2In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Lt(s,a){if(s){if(typeof s=="string")return Le(s,a);var r=Object.prototype.toString.call(s).slice(8,-1);if(r==="Object"&&s.constructor&&(r=s.constructor.name),r==="Map"||r==="Set")return Array.from(s);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Le(s,a)}}function Ot(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function Tt(s){if(Array.isArray(s))return Le(s)}function Le(s,a){(a==null||a>s.length)&&(a=s.length);for(var r=0,n=new Array(a);r<a;r++)n[r]=s[r];return n}function It(s,a){if(!(s instanceof a))throw new TypeError("Cannot call a class as a function")}function Ye(s,a){for(var r=0;r<a.length;r++){var n=a[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(s,Qe(n.key),n)}}function $t(s,a,r){return a&&Ye(s.prototype,a),r&&Ye(s,r),Object.defineProperty(s,"prototype",{writable:!1}),s}function _t(s,a,r){return a=be(a),Ut(s,Je()?Reflect.construct(a,r||[],be(s).constructor):a.apply(s,r))}function Ut(s,a){if(a&&(le(a)==="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Rt(s)}function Rt(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Je(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Je=function(){return!!s})()}function be(s){return be=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},be(s)}function Bt(s,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(a&&a.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),a&&Oe(s,a)}function Oe(s,a){return Oe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Oe(s,a)}function $(s,a,r){return a=Qe(a),a in s?Object.defineProperty(s,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):s[a]=r,s}function Qe(s){var a=Mt(s,"string");return le(a)=="symbol"?a:a+""}function Mt(s,a){if(le(s)!="object"||!s)return s;var r=s[Symbol.toPrimitive];if(r!==void 0){var n=r.call(s,a);if(le(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var pe=function(s){function a(){var r;It(this,a);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return r=_t(this,a,[].concat(i)),$(r,"state",{isAnimationFinished:!0,totalLength:0}),$(r,"generateSimpleStrokeDasharray",function(c,m){return"".concat(m,"px ").concat(c-m,"px")}),$(r,"getStrokeDasharray",function(c,m,p){var g=p.reduce(function(L,O){return L+O});if(!g)return r.generateSimpleStrokeDasharray(m,c);for(var h=Math.floor(c/g),u=c%g,x=m-c,j=[],f=0,N=0;f<p.length;N+=p[f],++f)if(N+p[f]>u){j=[].concat(re(p.slice(0,f)),[u-N]);break}var P=j.length%2===0?[0,x]:[x];return[].concat(re(a.repeat(p,h)),re(j),P).map(function(L){return"".concat(L,"px")}).join(", ")}),$(r,"id",bt("recharts-line-")),$(r,"pathRef",function(c){r.mainCurve=c}),$(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),$(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return Bt(a,s),$t(a,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();this.setState({totalLength:n})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();n!==this.state.totalLength&&this.setState({totalLength:n})}}},{key:"getTotalLength",value:function(){var n=this.mainCurve;try{return n&&n.getTotalLength&&n.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(n,i){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,c=o.points,m=o.xAxis,p=o.yAxis,g=o.layout,h=o.children,u=ut(h,ft);if(!u)return null;var x=function(N,P){return{x:N.x,y:N.y,value:N.value,errorVal:Xe(N.payload,P)}},j={clipPath:n?"url(#clipPath-".concat(i,")"):null};return D.createElement(De,j,u.map(function(f){return D.cloneElement(f,{key:"bar-".concat(f.props.dataKey),data:c,xAxis:m,yAxis:
2p,layout:g,dataPointFormatter:x})}))}},{key:"renderDots",value:function(n,i,o){var c=this.props.isAnimationActive;if(c&&!this.state.isAnimationFinished)return null;var m=this.props,p=m.dot,g=m.points,h=m.dataKey,u=Ne(this.props,!1),x=Ne(p,!0),j=g.map(function(N,P){var L=E(E(E({key:"dot-".concat(P),r:3},u),x),{},{index:P,cx:N.x,cy:N.y,value:N.value,dataKey:h,payload:N.payload,points:g});return a.renderDotItem(p,L)}),f={clipPath:n?"url(#clipPath-".concat(i?"":"dots-").concat(o,")"):null};return D.createElement(De,me({className:"recharts-line-dots",key:"dots"},f),j)}},{key:"renderCurveStatically",value:function(n,i,o,c){var m=this.props,p=m.type,g=m.layout,h=m.connectNulls;m.ref;var u=We(m,Ct),x=E(E(E({},Ne(u,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:i?"url(#clipPath-".concat(o,")"):null,points:n},c),{},{type:p,layout:g,connectNulls:h});return D.createElement(gt,me({},x,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(n,i){var o=this,c=this.props,m=c.points,p=c.strokeDasharray,g=c.isAnimationActive,h=c.animationBegin,u=c.animationDuration,x=c.animationEasing,j=c.animationId,f=c.animateNewValues,N=c.width,P=c.height,L=this.state,O=L.prevPoints,H=L.totalLength;return D.createElement(jt,{begin:h,duration:u,isActive:g,easing:x,from:{t:0},to:{t:1},key:"line-".concat(j),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(T){var w=T.t;if(O){var R=O.length/m.length,_=m.map(function(b,te){var K=Math.floor(te*R);if(O[K]){var W=O[K],B=ce(W.x,b.x),Se=ce(W.y,b.y);return E(E({},b),{},{x:B(w),y:Se(w)})}if(f){var he=ce(N*2,b.x),ue=ce(P/2,b.y);return E(E({},b),{},{x:he(w),y:ue(w)})}return E(E({},b),{},{x:b.x,y:b.y})});return o.renderCurveStatically(_,n,i)}var q=ce(0,H),F=q(w),G;if(p){var ee="".concat(p).split(/[,\s]+/gim).map(function(b){return parseFloat(b)});G=o.getStrokeDasharray(F,H,ee)}else G=o.generateSimpleStrokeDasharray(H,F);return o.renderCurveStatically(m,n,i,{strokeDasharray:G})})}},{key:"renderCurve",value:function(n,i){var o=this.props,c=o.points,m=o.isAnimationActive,p=this.state,g=p.prevPoints,h=p.totalLength;return m&&c&&c.length&&(!g&&h>0||!yt(g,c))?this.renderCurveWithAnimation(n,i):this.renderCurveStatically(c,n,i)}},{key:"render",value:function(){var n,i=this.props,o=i.hide,c=i.dot,m=i.points,p=i.className,g=i.xAxis,h=i.yAxis,u=i.top,x=i.left,j=i.width,f=i.height,N=i.isAnimationActive,P=i.id;if(o||!m||!m.length)return null;var L=this.state.isAnimationFinished,O=m.length===1,H=_e("recharts-line",p),T=g&&g.allowDataOverflow,w=h&&h.allowDataOverflow,R=T||w,_=Ee(P)?this.id:P,q=(n=Ne(c,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},F=q.r,G=F===void 0?3:F,ee=q.strokeWidth,b=ee===void 0?2:ee,te=Nt(c)?c:{},K=te.clipDot,W=K===void 0?!0:K,B=G*2+b;return D.createElement(De,{className:H},T||w?D.createElement("defs",null,D.createElement("clipPath",{id:"clipPath-".concat(_)},D.createElement("rect",{x:T?x:x-j/2,y:w?u:u-f/2,width:T?j:j*2,height:w?f:f*2})),!W&&D.createElement("clipPath",{id:"clipPath-dots-".concat(_)},D.createElement("rect",{x:x-B/2,y:u-B/2,width:j+B,height:f+B}))):null,!O&&this.renderCurve(R,_),this.renderErrorBar(R,_),(O||c)&&this.renderDots(R,W,_),(!N||L)&&vt.renderCallByParent(this.props,m))}}],[{key:"getDerivedStateFromProps",value:function(n,i){return n.animationId!==i.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,prevPoints:i.curPoints}:n.points!==i.curPoints?{curPoints:n.points}:null}},{key:"repeat",value:function(n,i){for(var o=n.length%2!==0?[].concat(re(n),[0]):n,c=[],m=0;m<i;++m)c=[].concat(re(c),re(o));return c}},{key:"renderDotItem",value:function(n,i){var o;if(D.isValidElement(n))o=D.cloneElement(n,i);else if(pt(n))o=n(i);else{var c=i.key,m=We(i,Dt),p=_e("recharts-line-dot",typeof n!="boolean"?n.className:"");o=D.createElement(ht,me({key:c},m,{className:p}))}return o}}])}(v.PureComponent);$(pe,"displayName","Line");$(pe,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!wt.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});$(pe,"getComposedData",function(s){var a=s.props,r=s.xAxis,n=s.yAxis,i=s.xAxisTicks,o=s.yAxisTicks,c=s.dataKey,m=s.bandSize,p=s.displayedData,g=s.offset,h=a.layout,u=p.map(function(x,j){var f=Xe(x,c);return h==="horizontal"?{x:Ke({axis:r,ticks:i,bandSize:m,entry:x,index:j}),y:Ee(f)?null:n.scale(f),value:f,payload:x}:{x:Ee(f)?null:r.scale(f),y:Ke({axis:n,ticks:o,bandSize:m,entry:x,index:j}),value:f,payload:x}});return E({points:u,layout:h},g)});var zt=St({chartName:"LineChart",GraphicalChild:pe,axisComponents:[{axisType:"xAxis",AxisComp:V},{axisType:"yAxis",AxisComp:Y}],formatAxisMap:kt});const z=s=>{let a=0;for(let o=0;o<s.length;o++)a=s.charCodeAt(o)+((a<<5)-a);const r=Math.abs(a%360),n=65+Math.abs(a>>8)%20,i=45+Math.abs(a>>16)%15;return`hsl(${r}, ${n}%, ${i}%)`},ve=s=>{const a=s.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(!a)return"#ffffff";const r=parseInt(a[1])/360,n=parseInt(a[2])/100,i=parseInt(a[3])/100,o=(h,u,x)=>(x<0&&(x+=1),x>1&&(x-=1),x<1/6?h+(u-h)*6*x:x<1/2?u:x<2/3?h+(u-h)*(2/3-x)*6:h);let c,m,p;if(n===0)c=m=p=i;else{const h=i<.5?i*(1+n):i+n-i*n,u=2*i-h;c=o(u,h,r+1/3),m=o(u,h,r),p=o(u,h,r-1/3)}return .2126*c+.7152*m+.0722*p>.5?"#000000":"#ffffff"},Ft=["free","starter","pro"],Gt=new Set(Ft),Kt=s=>s&&Gt.has(s)?s:"free",ie=s=>s?s.replace(/[._-]/g," ").replace(/\b\w/g,a=>a.toUpperCase()):"",xe=(s,a=!1)=>
2{if(!s)return"-";const r=new Date(s);return Number.isNaN(r.getTime())?"-":a?r.toLocaleString():r.toLocaleDateString()},Pe=s=>{const a=Number(s||0);return a.toLocaleString(void 0,{style:"currency",currency:"USD",minimumFractionDigits:a>0&&a<.01?4:2,maximumFractionDigits:a>0&&a<.01?6:2})},Wt=(s,a)=>{if(s==null)return"";const r=(a||"EUR").toUpperCase();try{return new Intl.NumberFormat(void 0,{style:"currency",currency:r}).format(s/100)}catch{return`${(s/100).toFixed(2)} ${r}`}},Z=s=>s.billing??null,we=s=>{const a=Z(s);return a?.effectivePlan||a?.plan||s.planType||"free"},He=s=>Kt(Z(s)?.plan||s.planType),Ze=s=>s==="pro"?"bg-purple-500/10 text-purple-600":s==="starter"?"bg-blue-500/10 text-blue-600":"bg-muted text-muted-foreground",Vt=s=>s==="good"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":s==="warning"?"bg-amber-500/10 text-amber-700 dark:text-amber-400":s==="danger"?"bg-red-500/10 text-red-600 dark:text-red-400":s==="info"?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"bg-muted text-muted-foreground",Te=s=>[s.entitlementStatus,s.paymentStatus,s.stripeSubscriptionStatus,s.billingStatus,s.packageStatus,s.status].filter(a=>typeof a=="string"&&a.trim().length>0),Yt=(s,a)=>Te(s).some(r=>{const n=r.toLowerCase();return a.some(i=>n.includes(i))}),Ht=s=>!!s&&s.toLowerCase()!=="free",qe=s=>{const a=Z(s);if(!a)return!1;const r=(a.effectivePlan||we(s)||"").toLowerCase(),n=a.plan||s.planType,i=!!a.paymentGraceEndsAt||!!a.paymentFailedAt||Ht(n),o=Yt(a,["unpaid_disabled","disabled","downgraded","expired"]);return a.paidFeaturesActive===!1||o||r==="free"&&i},Xt=s=>{const a=Te(s).map(i=>i.toLowerCase()),r=s.paymentGraceEndsAt?new Date(s.paymentGraceEndsAt):null,n=!!r&&!Number.isNaN(r.getTime())&&r.getTime()<=Date.now();return a.some(i=>i.includes("downgraded"))||n?"Downgraded after grace":a.some(i=>i.includes("unpaid_disabled"))?"Unpaid disabled":a.some(i=>i.includes("expired"))?"Expired":"Features disabled"},Jt=s=>{const a=Z(s);if(!a?.paymentGraceEndsAt||!qe(s))return"Grace ends";const r=new Date(a.paymentGraceEndsAt);return!Number.isNaN(r.getTime())&&r.getTime()<=Date.now()?"Grace ended":"Grace recorded"},Qt=s=>{const a=Z(s),r=we(s);if(!a)return{label:"Billing pending",tone:"muted"};const n=Te(a)[0],i=(n||"").toLowerCase();return qe(s)?{label:Xt(a),tone:"danger"}:i.includes("unpaid")||i.includes("expired")||i.includes("past_due")?{label:ie(n),tone:"danger"}:i.includes("grace")||a.paymentGraceEndsAt?{label:n?ie(n):"Grace period",tone:"warning"}:a.scheduledDowngradePlan&&a.scheduledDowngradeDate?{label:"Scheduled change",tone:"warning"}:n?{label:ie(n),tone:i.includes("active")||i.includes("current")?"good":"info"}:r==="free"?{label:"Free",tone:"muted"}:{label:a.hasStripeSubscription?"Current":"Manual plan",tone:a.hasStripeSubscription?"good":"info"}},Zt=s=>{const a=Qt(s),r=we(s);return e.jsx("div",{className:"min-w-[150px] space-y-1",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold uppercase ${Ze(r)}`,children:r}),e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-medium ${Vt(a.tone)}`,children:a.label})]})})},qt=s=>{const a=Z(s),r=a?.purchasedAt||s.planStartedAt;return e.jsxs("div",{className:"min-w-[120px] space-y-1 text-[10px] text-muted-foreground",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-foreground",children:"Purchase:"})," ",xe(r)]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-foreground",children:"Cycle:"})," ",xe(a?.billingCycleStart)]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-foreground",children:"Expires:"})," ",xe(a?.planExpiresAt)]})]})},es=s=>{const a=Z(s);if(!a)return e.jsx("span",{className:"text-xs text-muted-foreground",children:"-"});const r=[a.scheduledDowngradePlan&&a.scheduledDowngradeDate?{label:`Scheduled to ${a.scheduledDowngradePlan}`,date:a.scheduledDowngradeDate,tone:"text-amber-700 dark:text-amber-400"}:null,a.paymentGraceEndsAt?{label:Jt(s),date:a.paymentGraceEndsAt,tone:"text-red-600 dark:text-red-400"}:null,a.paymentFailedAt?{label:"Payment failed",date:a.paymentFailedAt,tone:"text-red-600 dark:text-red-400"}
2:null].filter(Boolean);return r.length===0?e.jsx("span",{className:"text-xs text-muted-foreground",children:"-"}):e.jsx("div",{className:"min-w-[130px] space-y-1",children:r.map(n=>e.jsxs("div",{className:"text-[10px] leading-tight",children:[e.jsx("span",{className:`font-medium ${n.tone}`,children:n.label}),e.jsx("div",{className:"text-muted-foreground",children:xe(n.date,!0)})]},`${n.label}-${n.date}`))})},ts=s=>{if(!s||s.length===0)return e.jsx("span",{className:"block w-[170px] text-[10px] text-muted-foreground",children:"No recent payments"});const a=s.slice(0,3),r=a.slice(0,2),n=a.length-r.length;return e.jsxs("div",{className:"w-[170px] max-w-[170px] space-y-0.5 text-[10px] leading-tight",children:[r.map(i=>{const o=i.description||ie(i.eventType)||"Billing event",c=Wt(i.amount,i.currency),m=ie(i.status)||ie(i.eventType)||"-";return e.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-1.5",children:[e.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",title:o,children:o}),e.jsx("span",{className:"shrink-0 text-muted-foreground",children:xe(i.createdAt)}),e.jsx("span",{className:"min-w-0 truncate text-muted-foreground",title:m,children:m}),c&&e.jsx("span",{className:"shrink-0 font-mono text-muted-foreground",children:c})]},i.id)}),n>0&&e.jsxs("div",{className:"truncate text-muted-foreground",children:["+",n," more"]})]})},ss=(s,a,r)=>{const n=a.user,i=a.billing||n?.billing||a.subscription||null,o=i?{...s.billing??{},...i,plan:i.plan||n?.planType||r,effectivePlan:i.effectivePlan||i.plan||n?.planType||r}:s.billing?{...s.billing,plan:r,effectivePlan:s.billing.effectivePlan||r}:null;return{...s,...n,id:s.id,email:n?.email??s.email,name:n?.name??s.name,planType:n?.planType||o?.plan||r||s.planType,oauthProvider:n?.oauthProvider??s.oauthProvider,country:n?.country??s.country,lastLoginIp:n?.lastLoginIp??s.lastLoginIp,source:n?.source??s.source,registrationPage:n?.registrationPage??s.registrationPage,crawlDomain:n?.crawlDomain??s.crawlDomain,creditsUsed:n?.creditsUsed??s.creditsUsed,planStartedAt:n?.planStartedAt??s.planStartedAt,createdAt:n?.createdAt??s.createdAt,billing:o}},Ss=()=>{const[s,a]=v.useState([]),[r,n]=v.useState([]),[i,o]=v.useState(1),[c,m]=v.useState(!1),[p,g]=v.useState([]),[h,u]=v.useState(null),x=v.useRef(!1),j=50,{fetchWaitlist:f,fetchUsers:N,deleteWaitlistSubscriber:P,updateUserPlan:L,resetUserCredits:O,impersonateUser:H,loading:T}=ot(),w=async()=>{const t=await f();a(t.map(l=>({...l,timestamp:new Date(l.createdAt||Date.now()).getTime().toString()})))},R=async()=>{const t=await N();n(t)};v.useEffect(()=>{w(),R();const t=setInterval(()=>{w(),R()},3e4);return()=>clearInterval(t)},[]);const _=async(t,l)=>{confirm(`Are you sure you want to delete ${l}?`)&&(await P(t)?(M({title:"Subscriber deleted",description:`${l} has been removed from the waitlist.`}),w()):M({title:"Error",description:"Failed to delete subscriber.",variant:"destructive"}))},q=async t=>{if(x.current||!window.confirm(`Sign in as ${t.email}? This changes the user session for every Namiru tab in this browser.`))return;x.current=!0,u(t.id);const d=window.open("","_blank");d&&(d.opener=null);try{const y=await H(t.id);if(!y?.sessionEstablished||!y.isImpersonated){d?.close(),M({title:"Failed to impersonate user",variant:"destructive"});return}lt({...y.user,isImpersonated:!0}),d?d.location.replace("/agent-builder"):window.location.assign("/agent-builder"),M({title:"Impersonation started",description:`Opened new tab as ${t.email}`})}catch(y){d?.close(),M({title:"Failed to impersonate user",description:y instanceof Error?y.message:"Request failed",variant:"destructive"})}finally{x.current=!1,u(null)}},F=s.reduce((t,l)=>(t[l.country]=(t[l.country]||0)+1,t),{}),G=s.reduce((t,l)=>{const d=l.affiliateLink||"Direct";return t[d]=(t[d]||0)+1,t},{}),ee=s.reduce((t,l)=>t+Number(l.timeSpent||0),0);s.length>0&&ee/s.length;const b=v.useMemo(()=>{const t=new Map;return s.forEach(l=>{const d=new Date(parseInt(l.timestamp)),y=`${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,"0")}-${String(d.getDate()).padStart(2,"0")}`;t.set(y,(t.get(y)||0)+1)}),Array.from(t.entries()).map(([l,d])=>({date:l,signups:d})).sort((l,d)=>l.date.localeCompare(d.date)).slice(-30)},[s]),te=v.useMemo(()=>{const t=new Map;
2return s.forEach(l=>{const d=l.package||"No Package";t.set(d,(t.get(d)||0)+1)}),Array.from(t.entries()).map(([l,d])=>({package:l,count:d})).sort((l,d)=>d.count-l.count)},[s]),K=v.useMemo(()=>{const t=new Map;return s.forEach(l=>{const d=l.earlyAccessChoice==="yes"?"Yes":l.earlyAccessChoice==="no"?"No":"Not Clicked";t.set(d,(t.get(d)||0)+1)}),["Not Clicked","No","Yes"].map(l=>({choice:l,count:t.get(l)||0}))},[s]),W=v.useMemo(()=>{const t=new Map;return s.forEach(l=>{l.theme==="dark"?t.set("Dark",(t.get("Dark")||0)+1):l.theme==="light"&&t.set("Light",(t.get("Light")||0)+1)}),["Dark","Light"].map(l=>({theme:l,count:t.get(l)||0}))},[s]),B=v.useMemo(()=>{const t=new Map;return s.forEach(l=>{const d=l.buttonClicked==="stripe"?"Stripe":l.buttonClicked==="confirm"?"Confirm":"Not Clicked";t.set(d,(t.get(d)||0)+1)}),["Not Clicked","Confirm","Stripe"].map(l=>({button:l,count:t.get(l)||0}))},[s]),Se=v.useMemo(()=>{const t=new Map;return s.forEach(l=>{l.blogSlug&&t.set(l.blogSlug,(t.get(l.blogSlug)||0)+1)}),Array.from(t.entries()).map(([l,d])=>({blog:l,count:d})).sort((l,d)=>d.count-l.count).slice(0,5)},[s]),he=v.useMemo(()=>{const t=new Map;return s.forEach(l=>{const d=l.affiliateLink||"Direct";t.set(d,(t.get(d)||0)+1)}),Array.from(t.entries()).map(([l,d])=>({affiliate:l,count:d})).sort((l,d)=>d.count-l.count).slice(0,5)},[s]),ue=s.filter(t=>t.earlyAccess).length,et=s.length>0?(ue/s.length*100).toFixed(1):0,fe=v.useMemo(()=>[...s].sort((t,l)=>parseInt(l.timestamp)-parseInt(t.timestamp)),[s]),ge=Math.ceil(fe.length/j),je=fe.slice((i-1)*j,i*j);return e.jsxs(st,{children:[e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold mb-1 sm:mb-2",children:"Users & Subscribers"}),e.jsxs("p",{className:"text-sm sm:text-base text-muted-foreground",children:[r.length," registered users · ",s.length," waitlist subscribers"]}
2)]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(X,{variant:"outline",onClick:()=>{w(),R()},disabled:T,size:"sm",className:"gap-2 flex-1 sm:flex-none",children:[e.jsx(Re,{className:`w-4 h-4 ${T?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),e.jsxs(X,{variant:"outline",size:"sm",onClick:()=>{const t=JSON.stringify(s,null,2),l=new Blob([t],{type:"application/json"}),d=URL.createObjectURL(l),y=document.createElement("a");y.href=d,y.download=`waitlist-export-${Date.now()}.json`,y.click(),URL.revokeObjectURL(d)},className:"gap-2 flex-1 sm:flex-none",children:[e.jsx(ct,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Export Data"})]})]})]}),e.jsxs(S,{children:[e.jsxs(k,{className:"pb-3 flex flex-row items-center justify-between",children:[e.jsxs(A,{className:"text-lg",children:["Registered Users (",r.length,")"]}),e.jsxs(X,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>{g([]),m(!0)},children:[e.jsx(Be,{className:"w-4 h-4"}),"Send Email"]})]}),e.jsx(C,{children:e.jsxs("div",{className:"overflow-x-auto",children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"pb-2 pr-4 font-medium",children:"Name"}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:"Email"}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:"Plan"}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:"Billing Status"}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:"Billing Dates"}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:"Grace / Scheduled"}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:"Recent Payments"}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:"Country"}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:"AI Spend"}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:"Credits"}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:"IP"}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:"Auth"}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:"Source"}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:"Entry Page"}),e.jsx("th",{className:"pb-2 pr-4 font-medium",children:"Crawled URL"}),e.jsx("th",{className:"pb-2 font-medium",children:"Registered"})]})}),e.jsx("tbody",{children:r.map(t=>e.jsxs("tr",{className:"border-b border-border/30",children:[e.jsx("td",{className:"py-2 pr-4",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"block max-w-[200px] truncate",title:t.name||void 0,children:t.name||"-"}),e.jsx("button",{title:`Send email to ${t.email}`,className:"text-primary/70 hover:text-primary hover:bg-primary/10 p-1 rounded transition-colors",onClick:()=>{g([t.id]),m(!0)},children:e.jsx(Be,{className:"w-4 h-4"})}),e.jsx("button",{title:`Sign in as ${t.email}`,"aria-label":`Sign in as ${t.email}`,type:"button",disabled:h!==null,className:"text-orange-500/70 hover:text-orange-600 hover:bg-orange-500/10 p-1 rounded transition-colors disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>void q(t),children:h===t.id?e.jsx(Re,{className:"w-4 h-4 animate-spin motion-reduce:animate-none"}):e.jsx(dt,{className:"w-4 h-4"})}),e.jsx("button",{title:`View funnel for ${t.email}`,className:"text-green-500/70 hover:text-green-600 hover:bg-green-500/10 p-1 rounded transition-colors",onClick:()=>window.open(`/admin/funnel?userId=${t.id}`,"_blank"),children:e.jsx(Me,{className:"w-4 h-4"})})]})}),e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:e.jsx("span",{className:"block max-w-[200px] truncate",title:t.email,children:t.email})}),e.jsx("td",{className:"py-2 pr-4",children:e.jsxs("select",{value:He(t),onChange:async l=>{const d=l.target.value,y=await L(t.id,d);if(y){let Ie=d;n(tt=>tt.map(ke=>{if(ke.id!==t.id)return ke;const $e=ss(ke,y,d);return Ie=we($e),$e})),M({title:`Plan updated to ${Ie}`,description:t.email})}else M({title:"Failed to update plan",variant:"destructive"})},className:`px-2 py-0.5 rounded text-xs font-medium border-none cursor-pointer ${Ze(He(t))}`,children:[e.jsx("option",{value:"free",children:"free"}),e.jsx("option",{value:"starter",children:"starter"}),e.jsx("option",{value:"pro",children:"pro"})]})}),e.jsx("td",{className:"py-2 pr-4",children:Zt(t)}),e.jsx("td",{className:"py-2 pr-4",children:qt(t)}),e.jsx("td",{className:"py-2 pr-4",children:es(t)}),e.jsx("td",{className:"py-2 pr-4 max-w-[190px]",children:ts(t.billing?.payments)}),e.jsx("td",{className:"py-2 pr-4 text-xs",children:t.country?e.jsxs("span",{className:"inline-flex items-center gap-1.5",title:oe(t.country),children:[e.jsx(ye,{countryCode:t.country.toUpperCase(),svg:!0,style:{width:"1.15em",height:"1.15em"},"aria-label":oe(t.country)}),e.jsx("span",{children:t.country})]}):"-"}),e.jsx("td",{className:"py-2 pr-4 text-xs font-mono",children:e.jsx("a",{href:`/admin/spending?search=${encodeURIComponent(t.email)}`,className:"font-semibold text-foreground hover:text-primary hover:underline",title:`Exact: ${Pe(t.aiSpend?.providerReportedCostUsd)} | Estimated: ${Pe(t.aiSpend?.estimatedCostUsd)} | ${t.aiSpend?.totalTokens||0} tokens`,children:Pe(t.aiSpend?.totalCostUsd)})}),e.jsxs("td",{className:"py-2 pr-4 text-xs font-mono",children:[e.jsx("span",{children:t.creditsUsed}),t.creditsUsed>0&&e.jsx("button",{className:"ml-2 text-[10px] text-red-500 hover:text-red-700 underline",onClick:async()=>
2{if(!confirm(`Reset credits for ${t.email}?`))return;await O(t.id)?(n(d=>d.map(y=>y.id===t.id?{...y,creditsUsed:0}:y)),M({title:"Credits reset",description:t.email})):M({title:"Failed to reset credits",variant:"destructive"})},children:"reset"})]}),e.jsx("td",{className:"py-2 pr-4 text-xs font-mono text-muted-foreground",children:t.lastLoginIp||"-"}),e.jsx("td",{className:"py-2 pr-4 text-xs text-muted-foreground",children:t.oauthProvider||"email"}),e.jsx("td",{className:"py-2 pr-4 text-xs text-muted-foreground",children:t.source||"-"}),e.jsx("td",{className:"py-2 pr-4 text-xs text-muted-foreground",children:t.registrationPage||"-"}),e.jsx("td",{className:"py-2 pr-4 text-xs font-mono text-muted-foreground",children:t.crawlDomain?(()=>{try{const l=new URL(t.crawlDomain).hostname;return e.jsx("a",{href:t.crawlDomain,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:l})}catch{return e.jsx("span",{children:t.crawlDomain})}})():"-"}),e.jsx("td",{className:"py-2 text-xs text-muted-foreground",children:new Date(t.createdAt).toLocaleDateString()})]},t.id))})]}),r.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4 text-sm",children:"No registered users yet"})]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:gap-4 md:grid-cols-4",children:[e.jsxs(S,{children:[e.jsx(k,{className:"pb-2",children:e.jsx(A,{className:"text-xs sm:text-sm font-medium",children:"Total Subscribers"})}),e.jsxs(C,{className:"pt-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-xl sm:text-2xl font-bold",children:s.length}),e.jsx(Me,{className:"w-3 h-3 sm:w-4 sm:h-4 text-green-500"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[b.slice(-7).reduce((t,l)=>t+l.signups,0)," last 7 days"]})]})]}),e.jsxs(S,{children:[e.jsx(k,{className:"pb-2",children:e.jsx(A,{className:"text-xs sm:text-sm font-medium",children:"Affiliates"})}),e.jsxs(C,{className:"pt-0",children:[e.jsx("div",{className:"text-xl sm:text-2xl font-bold",children:Object.keys(G).length}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Traffic sources"})]})]}),e.jsxs(S,{children:[e.jsx(k,{className:"pb-2",children:e.jsx(A,{className:"text-xs sm:text-sm font-medium",children:"Early Access"})}),e.jsxs(C,{className:"pt-0",children:[e.jsxs("div",{className:"text-xl sm:text-2xl font-bold",children:[et,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[ue," opted in"]})]})]}),e.jsxs(S,{children:[e.jsx(k,{className:"pb-2",children:e.jsx(A,{className:"text-xs sm:text-sm font-medium",children:"Countries"})}),e.jsxs(C,{className:"pt-0",children:[e.jsx("div",{className:"text-xl sm:text-2xl font-bold",children:Object.keys(F).length}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Global reach"})]})]})]}),e.jsxs("div",{className:"grid gap-3 sm:gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsxs(S,{children:[e.jsxs(k,{className:"pb-2 sm:pb-4",children:[e.jsx(A,{className:"text-sm sm:text-base",children:"Signups Over Time"}),e.jsx(Ue,{className:"text-xs sm:text-sm",children:"Daily subscriber trend (last 30 days)"})]}),e.jsx(C,{className:"p-2 sm:p-6 pt-0",children:e.jsx(J,{width:"100%",height:100,className:"sm:!h-[130px]",children:e.jsxs(zt,{data:b,margin:{top:15,right:5,left:-25,bottom:0},children:[e.jsx(At,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),e.jsx(V,{dataKey:"date",tick:{fontSize:7},tickFormatter:t=>{const l=t.split("-");return l.length===3?`${parseInt(l[1])}/${parseInt(l[2])}`:t},interval:"preserveStartEnd"}),e.jsx(Y,{tick:{fontSize:8}}),e.jsx(Q,{contentStyle:{fontSize:11},labelFormatter:t=>{const l=String(t).split("-");return l.length===3?new Date(parseInt(l[0]),parseInt(l[1])-1,parseInt(l[2])).toLocaleDateString():t}}),e.jsx(pe,{type:"monotone",dataKey:"signups",stroke:"#8884d8",strokeWidth:2,dot:{fill:"#8884d8",r:3},activeDot:{r:5},label:{position:"top",fontSize:8}})]})})})]}),e.jsxs("div",{className:"grid gap-3 sm:gap-4 grid-cols-2",children:[e.jsxs(S,{children:[e.jsx(k,{className:"pb-2",children:e.jsx(A,{className:"text-xs sm:text-sm",children:"Blog Sources"})}),e.jsx(C,{className:"p-2 sm:p-6 pt-0",children:e.jsx(J,{width:"100%",height:100,className:"sm:!h-[130px]",children:e.jsxs(ne,{data:Se,margin:{top:15,right:2,left:2,bottom:5},children:[e.jsx(V,{dataKey:"blog",tick:{fontSize:7},angle:-45,textAnchor:"end",height:40}),e.jsx(Y,{tick:{fontSize:7}}),e.jsx(Q,{}),e.jsx(ae,{dataKey:"count",fill:"#10b981",label:{position:"top",fontSize:8}})]})})})]}),e.jsxs(S,{children:[e.jsx(k,{className:"pb-2",children:e.jsx(A,{className:"text-xs sm:text-sm",children:"Affiliate Sources"})}),e.jsx(C,{className:"p-2 sm:p-6 pt-0",children:e.jsx(J,{width:"100%",height:100,className:"sm:!h-[130px]",children:e.jsxs(ne,{data:he,margin:{top:15,right:2,left:2,bottom:5},children:[e.jsx(V,{dataKey:"affiliate",tick:{fontSize:7},angle:-45,textAnchor:"end",height:40}),e.jsx(Y,{tick:{fontSize:7}}),e.jsx(Q,{}),e.jsx(ae,{dataKey:"count",label:{position:"top",fontSize:8},children:he.map(t=>e.jsx(de,{fill:z(t.affiliate)},t.affiliate))})]})})})]})]})]}),e.jsxs("div",{className:"grid gap-3 sm:gap-4 grid-cols-2",children:[e.jsxs(S,{children:[e.jsx(k,{className:"pb-2",children:e.jsx(A,{className:"text-xs sm:text-sm",children:"Package Distribution"})}),e.jsx(C,{className:"p-2 sm:p-6 pt-0",children:e.jsx(J,{width:"100%",height:100,className:"sm:!h-[130px]",children:e.jsxs(ne,{data:te,margin:{top:15,right:2,left:2,bottom:5},children:[e.jsx(V,{dataKey:"package",tick:{fontSize:7}}),e.jsx(Y,{tick:{fontSize:7}}),e.jsx(Q,{}),e.jsx(ae,{dataKey:"count",label:{position:"top",fontSize:8},children:te.map((t,l)=>e.jsx(de,{fill:t.package==="professional"?"#f59e0b":t.package==="basic"?"#61a6fa":"#6b7280"},`cell-${l}`))})]})})})]}),e.jsxs(S,{children:[e.jsx(k,{className:"pb-2",children:e.jsx(A,{className:"text-xs sm:text-sm",children:"Early Access"})}),e.jsx(C,{className:"p-2 sm:p-6 pt-0",children:e.jsx(J,{width:"100%",height:100,className:"sm:!h-[130px]",children:e.jsxs(ne,{data:K,margin:{top:15,right:2,left:2,bottom:5},children:[e.jsx(V,{dataKey:"choice",tick:{fontSize:7}}),e.jsx(Y,{tick:{fontSize:7}}),e.jsx(Q,{}),e.jsx(ae,{dataKey:"count",label:{position:"top",fontSize:8},children:K.map((t,l)=>e.jsx(de,{fill:t.choice==="Yes"?"#10b981":t.choice==="No"?"#ef4444":"#6b7280"},`cell-${l}`))})]})})})]}),e.jsxs(S,{children:[e.jsx(k,{className:"pb-2",children:e.jsx(A,{className:"text-xs sm:text-sm",children:"Theme"})}),e.jsx(C,{className:"p-2 sm:p-6 pt-0",children:e.jsx(J,{width:"100%",height:100,className:"sm:!h-[130px]",children:e.jsxs(ne,{data:W,margin:{top:15,right:2,left:2,bottom:5},children:[e.jsx(V,{dataKey:"theme",tick:{fontSize:7}}),e.jsx(Y,{tick:{fontSize:7}}),e.jsx(Q,{}),e.jsx(ae,{dataKey:"count",label:{position:"top",fontSize:8},children:W.map((t,l)=>e.jsx(de,{fill:t.theme==="Dark"?"#3b82f6":"#f59e0b"},`cell-${l}`))})]})})})]}),e.jsxs(S,{children:[e.jsx(k,{className:"pb-2",children:e.jsx(A,{className:"text-xs sm:text-sm",children:"Button Clicked"})}),e.jsx(C,{className:"p-2 sm:p-6 pt-0",children:e.jsx(J,{width:"100%",height:100,className:"sm:!h-[130px]",children:e.jsxs(ne,{data:B,margin:{top:15,right:2,left:2,bottom:5},children:[e.jsx(V,{dataKey:"button",tick:{fontSize:7}}),e.jsx(Y,{tick:{fontSize:7}}),e.jsx(Q,{}),e.jsx(ae,{dataKey:"count",label:{position:"top",fontSize:8},children:B.map((t,l)=>e.jsx(de,{fill:t.button==="Stripe"?"#8b5cf6":t.button==="Confirm"?"#3b82f6":"#6b7280"},`cell-${l}`))})]})})})]})]})]}),e.jsxs(S,{children:[e.jsxs(k,{className:"pb-3 sm:pb-6",children:[e.jsx(A,{className:"text-base sm:text-lg",children:"Subscribers"}),e.jsx(Ue,{className:"text-xs sm:text-sm",children:"All waitlist subscribers with their details"})]}),e.jsxs(C,{className:"p-3 md:p-6 md:pt-0",children:[e.jsx("div",{className:"md:hidden space-y-3",children:je.length===0?e.jsx("div",{className:"text-center text-muted-foreground text-sm py-8",children:"No subscribers yet"}):je.map(t=>e.jsxs("div",{className:"bg-card border border-border rounded-lg p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",title:t.email,children:t.email}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[new Date(parseInt(t.timestamp)).toLocaleDateString()," at ",new Date(parseInt(t.timestamp)).toLocaleTimeString()]})]}),e.jsx(X,{variant:"ghost",size:"sm",onClick:()=>_(t.id,t.email),disabled:T,className:"h-8 w-8 p-0 flex-shrink-0","aria-label":`Delete ${t.email}`,children:e.jsx(ze,{className:"w-4 h-4 text-destructive"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Country"}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.country!=="Unknown"&&t.country!=="GEO_ERROR"&&e.jsx(ye,{countryCode:t.country,svg:!0,style:{width:"1.1em",height:"1.1em"}}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs",title:t.country,children:oe(t.country)}),se(t.country)&&e.jsx("span",{className:`text-[10px] ${Ae(t.country)}`,children:se(t.country)})]})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Package"}),e.jsx("p",{className:`text-xs mt-0.5 ${t.package==="professional"?"text-amber-500 dark:text-amber-400 font-semibold":t.package==="basic"?"font-semibold":"text-gray-500 dark:text-gray-400"}`,style:t.package==="basic"?{color:"#61a6fa"}:{},children:t.package||"-"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Early Access"}),e.jsx("p",{className:`text-xs mt-0.5 ${t.earlyAccessChoice==="yes"?"text-emerald-500 dark:text-emerald-400 font-semibold":t.earlyAccessChoice==="no"?"text-rose-500 dark:text-rose-400 font-semibold":"text-gray-500 dark:text-gray-400"}`,children:t.earlyAccessChoice==="yes"?"Yes":t.earlyAccessChoice==="no"?"No":t.earlyAccessChoice?String(t.earlyAccessChoice):"-"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Theme / Button"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.theme==="light"?e.jsx(Fe,{className:"w-3.5 h-3.5 text-amber-500"}):t.theme==="dark"?e.jsx(Ge,{className:"w-3.5 h-3.5 text-blue-400"}):e.jsx("span",{className:"text-gray-400 text-xs",children:"-"}),e.jsx("span",{className:"text-gray-400",children:"/"}),t.buttonClicked==="stripe"?e.jsx("span",{className:"text-xs font-semibold text-purple-600 dar
2k:text-purple-400",children:"Stripe"}):t.buttonClicked==="confirm"?e.jsx("span",{className:"text-xs font-semibold text-blue-600 dark:text-blue-400",children:"Confirm"}):e.jsx("span",{className:"text-gray-400 text-xs",children:"-"})]})]})]}),(t.blogSlug||t.affiliateLink)&&e.jsxs("div",{className:"pt-1 border-t border-border/50",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Source"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1",children:[t.blogSlug&&e.jsxs("span",{className:"text-xs font-semibold text-blue-600 dark:text-blue-400",children:["Blog: ",t.blogSlug]}),t.affiliateLink&&e.jsx("span",{className:"text-xs font-mono px-1.5 py-0.5 rounded",style:{backgroundColor:z(t.affiliateLink),color:ve(z(t.affiliateLink))},children:t.affiliateLink})]})]}),t.useCase&&e.jsxs("div",{className:"pt-1 border-t border-border/50",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Use Case"}),e.jsx("p",{className:"text-xs mt-0.5 line-clamp-2",title:t.useCase,children:t.useCase})]})]},t.id))}),e.jsx("div",{className:"hidden md:block",children:e.jsxs(nt,{children:[e.jsx(rt,{children:e.jsxs(Ce,{children:[e.jsx(U,{className:"text-xs sm:text-sm whitespace-nowrap",children:"Email"}),e.jsx(U,{className:"text-xs sm:text-sm whitespace-nowrap",children:"Country"}),e.jsx(U,{className:"text-xs sm:text-sm whitespace-nowrap",children:"Package"}),e.jsx(U,{className:"text-xs sm:text-sm whitespace-nowrap",children:"Early Access"}),e.jsx(U,{className:"text-xs sm:text-sm whitespace-nowrap",children:"Theme"}),e.jsx(U,{className:"text-xs sm:text-sm whitespace-nowrap",children:"Button"}),e.jsx(U,{className:"text-xs sm:text-sm whitespace-nowrap",children:"Use Case"}),e.jsx(U,{className:"text-xs sm:text-sm whitespace-nowrap",children:"Source"}),e.jsx(U,{className:"text-xs sm:text-sm whitespace-nowrap",children:"Date"}),e.jsx(U,{className:"text-xs sm:text-sm whitespace-nowrap",children:"Actions"})]})}),e.jsx(it,{children:je.length===0?e.jsx(Ce,{children:e.jsx(I,{colSpan:10,className:"text-center text-muted-foreground text-sm",children:"No subscribers yet"})}):je.map(t=>e.jsxs(Ce,{children:[e.jsx(I,{className:"font-medium text-xs sm:text-sm max-w-[150px] truncate",children:t.email}),e.jsx(I,{children:e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[t.country!=="Unknown"&&t.country!=="GEO_ERROR"&&e.jsx(ye,{countryCode:t.country,svg:!0,style:{width:"1.2em",height:"1.2em"}}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs sm:text-sm",title:t.country,children:oe(t.country)}),se(t.country)&&e.jsx("span",{className:`text-[10px] sm:text-xs ${Ae(t.country)}`,children:se(t.country)})]})]})}),e.jsx(I,{children:e.jsx("span",{className:`text-xs sm:text-sm ${t.package==="professional"?"text-amber-500 dark:text-amber-400 font-semibold":t.package==="basic"?"font-semibold":"text-gray-500 dark:text-gray-400"}`,style:t.package==="basic"?{color:"#61a6fa"}:{},children:t.package||"-"})}),e.jsx(I,{children:e.jsx("span",{className:`text-xs sm:text-sm ${t.earlyAccessChoice==="yes"?"text-emerald-500 dark:text-emerald-400 font-semibold":t.earlyAccessChoice==="no"?"text-rose-500 dark:text-rose-400 font-semibold":"text-gray-500 dark:text-gray-400"}`,children:t.earlyAccessChoice==="yes"?"Yes":t.earlyAccessChoice==="no"?"No":t.earlyAccessChoice?String(t.earlyAccessChoice):"-"})}),e.jsx(I,{children:t.theme==="light"?e.jsx(Fe,{className:"w-3 h-3 sm:w-4 sm:h-4 text-amber-500"}):t.theme==="dark"?e.jsx(Ge,{className:"w-3 h-3 sm:w-4 sm:h-4 text-blue-400"}):e.jsx("span",{className:"text-gray-400 text-xs",children:"-"})}),e.jsx(I,{children:t.buttonClicked==="stripe"?e.jsx("span",{className:"text-[10px] sm:text-xs font-semibold text-purple-600 dark:text-purple-400",children:"Stripe"}):t.buttonClicked==="confirm"?e.jsx("span",{className:"text-[10px] sm:text-xs font-semibold text-blue-600 dark:text-blue-400",children:"Confirm"}):e.jsx("span",{className:"text-gray-400 text-xs",children:"-"})}),e.jsx(I,{children:t.useCase?e.jsx("span",{className:"text-[10px] sm:text-xs max-w-[120px] sm:max-w-[200px] truncate block",title:t.useCase,children:t.useCase}):e.jsx("span",{className:"text-xs",children:"-"})}),e.jsx(I,{children:t.blogSlug?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"text-[10px] sm:text-xs font-semibold text-blue-600 dar
2k:text-blue-400",children:["Blog: ",t.blogSlug]}),t.affiliateLink&&e.jsx("span",{className:"text-[10px] sm:text-xs font-mono px-1.5 sm:px-2 py-0.5 sm:py-1 rounded",style:{backgroundColor:z(t.affiliateLink),color:ve(z(t.affiliateLink))},children:t.affiliateLink})]}):t.affiliateLink?e.jsx("span",{className:"text-[10px] sm:text-xs font-mono px-1.5 sm:px-2 py-0.5 sm:py-1 rounded",style:{backgroundColor:z(t.affiliateLink),color:ve(z(t.affiliateLink))},children:t.affiliateLink}):e.jsx("span",{className:"text-[10px] sm:text-xs text-muted-foreground",children:"Direct"})}),e.jsx(I,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs sm:text-sm whitespace-nowrap",children:new Date(parseInt(t.timestamp)).toLocaleDateString()}),e.jsx("span",{className:"text-[10px] sm:text-xs text-muted-foreground whitespace-nowrap",children:new Date(parseInt(t.timestamp)).toLocaleTimeString()})]})}),e.jsx(I,{children:e.jsx(X,{variant:"ghost",size:"sm",onClick:()=>_(t.id,t.email),disabled:T,className:"h-8 w-8 p-0","aria-label":`Delete ${t.email}`,children:e.jsx(ze,{className:"w-3 h-3 sm:w-4 sm:h-4 text-destructive"})})})]},t.id))})]})}),ge>1&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-3 px-3 sm:px-4 py-3 sm:py-4 border-t mt-4",children:[e.jsxs("div",{className:"text-xs sm:text-sm text-muted-foreground text-center sm:text-left",children:["Showing ",(i-1)*j+1," to ",Math.min(i*j,fe.length)," of ",fe.length]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(X,{variant:"outline",size:"sm",onClick:()=>o(t=>Math.max(1,t-1)),disabled:i===1,className:"h-8 px-2 sm:px-3",children:[e.jsx(mt,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline ml-1",children:"Previous"})]}),e.jsxs("div",{className:"text-xs sm:text-sm whitespace-nowrap",children:[i," / ",ge]}),e.jsxs(X,{variant:"outline",size:"sm",onClick:()=>o(t=>Math.min(ge,t+1)),disabled:i===ge,className:"h-8 px-2 sm:px-3",children:[e.jsx("span",{className:"hidden sm:inline mr-1",children:"Next"}),e.jsx(xt,{className:"w-4 h-4"})]})]})]})]})]}),e.jsxs("div",{className:"grid gap-3 sm:gap-4 md:grid-cols-2",children:[e.jsxs(S,{children:[e.jsx(k,{className:"pb-3 sm:pb-6",children:e.jsx(A,{className:"text-sm sm:text-base",children:"Top Countries"})}),e.jsx(C,{className:"pt-0",children:e.jsx("div",{className:"space-y-2",children:Object.entries(F).sort(([,t],[,l])=>l-t).slice(0,10).map(([t,l])=>e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[t!=="Unknown"&&t!=="GEO_ERROR"&&e.jsx(ye,{countryCode:t,svg:!0,style:{width:"1.1em",height:"1.1em"}}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs sm:text-sm",title:t,children:oe(t)}),se(t)&&e.jsx("span",{className:`text-[10px] sm:text-xs ${Ae(t)}`,children:se(t)})]})]}),e.jsx("span",{className:"font-medium text-xs sm:text-sm",children:l})]},t))})})]}),e.jsxs(S,{children:[e.jsx(k,{className:"pb-3 sm:pb-6",children:e.jsx(A,{className:"text-sm sm:text-base",children:"Top Affiliate Links"})}),e.jsx(C,{className:"pt-0",children:e.jsx("div",{className:"space-y-2",children:Object.entries(G).sort(([,t],[,l])=>l-t).slice(0,10).map(([t,l])=>e.jsxs("div",{className:"flex items-center justify-between gap-2 py-1",children:[e.jsx("span",{className:"text-[10px] sm:text-xs font-mono px-1.5 sm:px-2 py-0.5 sm:py-1 rounded truncate max-w-[140px] sm:max-w-[200px]",style:{backgroundColor:z(t),color:ve(z(t))},children:t}),e.jsx("span",{className:"font-medium text-xs sm:text-sm flex-shrink-0",children:l})]},t))})})]})]})]}),e.jsx(at,{open:c,onOpenChange:m,users:r.map(t=>({id:t.id,email:t.email,name:t.name})),preSelectedUserIds:p})]})};export{Ss as WaitlistSubscribers};
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.