1import{a as E,b as I}from"./BEU6Iz9z.js";import{_ as M}from"./BJ7JBiyg.js";import{P as W,bj as H,ay as J,bz as K,y,bQ as d,aI as g,bw as O,aC as c,M as r,B as m,l as Q,A as f,F as R,aJ as q,x as n,aU as a,ar as G,_ as X,L as u,f as Y}from"./D_ziQEbF.js";import{_ as Z}from"./XQz1Z-F3.js";import{_ as j}from"./BIAxJt1l.js";import{_ as ee}from"./Dc3jPrLc.js";import{_ as te}from"./C8xzz0kp.js";import{_ as se}from"./BE9pUpIW.js";import{h as v}from"./QfiTXYh-.js";import"./BLT6YblJ.js";import"./CjVoiRKp.js";import"./heas-0XY.js";import"./BROlw15H.js";import"./BJ2ClxiI.js";import"./DW4zm3j7.js";import"./sBoEYB1r.js";const re={key:0,class:"flex justify-center py-8"},ae={key:2,class:"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3"},oe={class:"flex flex-wrap items-start justify-between gap-4"},ne={class:"flex-1"},ie={class:"mt-2 font-semibold text-gray-900 dark:text-white"},le={class:"mt-1 font-mono text-xs text-gray-500 dark:text-gray-400"},ce={class:"mt-1 space-y-1"},ue={class:"flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400"},me={class:"flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400"},de={class:"flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400"},_e={key:0,class:"mt-2 border-t border-gray-100 pt-2 dark:border-gray-800"},fe={class:"flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400"},pe={class:"capitalize"},xe={key:0,class:"flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400"},ge={class:"flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400"},be={key:3,class:"py-8 text-center text-gray-600 dark:text-gray-400"},ze=W({__name:"subscribers",setup(he){H({title:()=>"All Subscribers",titleTemplate:"%s | Wiredash Console"});const k=O();function $(e){k.push(e)}const _=g([]),p=g(!1),x=g(null);J(()=>{w()});async function w(){x.value=null,p.value=!0;try{const e=await K("/explorer/getSubscribersWithLifetimeValue",{method:"POST"});if(!e)throw new Error("Failed to load subscriber projects");const s=Array.isArray(e)?e:[];_.value=A(s)}catch(e){x.value=e instanceof Error?e.message:"An unexpected error occurred",_.value=[]}finally{p.value=!1}}function A(e){return[...e].sort((s,i)=>{const l=b(s.lifetimeValue||[]);return b(i.lifetimeValue||[])-l})}function b(e){return!e||e.length===0?0:e.reduce((s,i)=>s+parseFloat(i.total),0)}function C(e){return!e||e.length===0?"No revenue":e.map(({currencyCode:s,total:i})=>{const l=parseFloat(i).toFixed(2);return s==="usd"?`$${l}`:s==="eur"?`â¬${l}`:`${l} ${s.toUpperCase()}`}).join(" + ")}function h(e){return e?v(e).format("ll"):"N/A"}function U(e){return v(e).fromNow(!0)}function B(e,s){if(!e)return"Free";if(s.subscription&&s.subscription.amount&&s.subscription.currency){const i=s.subscription.amount/100,l=s.subscription.currency,o=Number.isInteger(i)?i.toString():i.toFixed(2);return l==="usd"?`$${o}`:l==="eur"?`â¬${o}`:`${o} ${l.toUpperCase()}`}return"Custom price"}function F(e){return e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(0)+"K":e.toString()}function N(e){if(!e)return"gray";switch(e.toLowerCase()){case"growth":return"purple";case"business":return"blue";case"pro":return"green";case"starter":return"yellow";default:return"gray"}}return(e,s)=>{const i=I,l=M,o=X,V=Z,P=Y,S=j,L=ee,D=te,T=E,z=se;return c(),y(z,null,{default:d(()=>[r(T,{grow:""},{default:d(()=>[r(i,{title:"All Subscribers"}),r(D,{class:"pb-24"},{default:d(()=>[r(L,{title:"Subscriber Projects",description:"All projects with a paid subscription plan, sorted by lifetime value."},{default:d(()=>[p.value?(c(),m("div",re,[r(Q,{loading:!0,class:"h-6 w-6"})])):f("",!0),x.value?(c(),y(l,{key:1,color:"red",variant:"soft",title:"Error",description:x.value,class:"mb-4"},null,8,["description"])):f("",!0),_.value.length>0?(c(),m("div",ae,[(c(!0),m(R,null,q(_.value,t=>(c(),m("div",{key:t._id,class:"flex flex-col"},[r(S,{class:"flex-1"},{default:d(()=>[n("div",oe,[n("div",ne,[n("p",ie,a(t.name),1),n("p",le,a(t._id),1),n("div",ce,[n("div",{class:G(["flex items-center gap-2 text-sm font-medium",t.lifetimeValue&&t.lifetimeValue.length>0?"text-emerald-600 dark:text-emerald-400":"text-gray-500 dark:text-gray-400"])},[r(o,{name:"i-heroicons-currency-dollar",class:"flex-shrink-0"}),u(" "+a(C(t.lifetimeValue)),1)],2),n("div",ue,[r(o,{name:"i-heroicons-calendar",class:"flex-shrink-0"}),u(" "+a(h(t.createdAt))+" · "+a(U(t.createdAt)),1)]),n("div",me,[r(o,{name:"i-heroicons-user-group",class:"flex-shrink-0"}),u(" "+a(t.memberCount)+" members ",1)]),n("div",de,[r(o,{name:"i-heroicons-clock",class:"flex-shrink-0"}),u(" "+a(t.timezone),1)]),t.subscription?(c(),m("div",_e,[n("div",fe,[r(o,{name:"i-heroicons-credit-card",class:"flex-shrink-0"}),n("span",pe,a(t.subscription.plan),1),u(" ("+a(B(t.subscription.priceId,t))+"/"+a(t.subscription.interval)+") ",1)]),t.subscription.previouslyBilledAt?(c(),m("div",xe,[r(o,{name:"i-heroicons-calendar-days",class:"flex-shrink-0"}),u(" Last billing: "+a(h(t.subscription.previouslyBilledAt)),1)])):f("",!0),n("div",ge,[r(o,{name:"i-heroicons-device-phone-mobile",class:"flex-shrink-0"}),u(" "+a(F(t.subscription.deviceCount))+" devices ",1)])])):f("",!0),r(V,{color:N(t.plan),variant:"subtle",size:"sm",class:"mt-2"},{default:d(()=>[u(a(t.plan),1)]),_:2},1032,["color"])])]),r(P,{label:"View",color:"gray","trailing-icon":"i-heroicons-arrow-right-20-solid",onClick:ye=>$(`/explorer/${t._id}`)},null,8,["onClick"])])]),_:2},1024)]))),128))])):!p.value&&_.value.length===0?(c(),m("div",be," No subscriber projects found. ")):f("",!0)]),_:1})]),_:1})]),_:1})]),_:1})}}});
1export{ze as default};
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.