1import{u as O,r as c,t as S,j as e,y as xe,B as pe,z as he,X as ge,Y as je,E as ye,F as ve}from"./vendor-react-zwv87yMD.js";import{u as fe,a as M,b as k}from"./vendor-query-DYq8g7OI.js";import{m as P,s as I}from"./marketing-Hc2N7K1u.js";import{u as _}from"./authStore-Bv6p2Ne2.js";import{B as ie}from"./badge-QivbhJml.js";import{C as be,E as $,a as Ne}from"./EmailPreviewDialog-Di5ci-TT.js";import{E as Se}from"./EmailStyleToggle-DgmlEgb4.js";import{B as j}from"./button-DlBDuKbo.js";import{I as U}from"./input-C9cRIRX4.js";import{L as z}from"./label-CSUA9GMO.js";import{T as le}from"./textarea-CfTUtQow.js";import{C as Z}from"./checkbox-Ka5qdjOo.js";import{b as q,c as J,d as oe}from"./dialog-CCoQRIQ_.js";import{S as Ee,a as we,b as Ce,c as Te,d as ke}from"./select-D2pLZtG9.js";import{T as Ie,a as Le,b as ee,c as Q,d as De,e as G}from"./table-BLRYsg93.js";import{n as de,v as A,ah as se,au as Fe,ao as Pe,ap as X,d as ce}from"./vendor-icons-bLSWzydc.js";import"./vendor-charts-CtrTLS4K.js";import"./vendor-i18n-BdYkS11p.js";import"./vendor-ui-CfDMlrKu.js";import"./vendor-pdf-DQuePnfN.js";import"./vendor-state-ByI9XJey.js";import"./vendor-editor-C_dhmuey.js";import"./api-client-wl3SCNAO.js";import"./i18n-CwjSIy0a.js";import"./utils-BXSzAfFa.js";const Ae=["all","new","regulars","lapsed"],ze=["RATING","NPS","SINGLE_CHOICE","MULTIPLE_CHOICE","FREE_TEXT"],V=15,W=s=>s==="SINGLE_CHOICE"||s==="MULTIPLE_CHOICE",Oe=2,Re=10,Ue=100,te=s=>{if(!W(s.type))return!0;const t=ue(s.optionsText);return t.length>=Oe&&t.length<=Re&&t.every(n=>n.length<=Ue)},Me={DRAFT:"bg-gray-100 text-gray-700",SCHEDULED:"bg-purple-100 text-purple-700",QUEUED:"bg-yellow-100 text-yellow-800",SENDING:"bg-orange-100 text-orange-800",SENT:"bg-green-100 text-green-700",FAILED:"bg-red-100 text-red-700",ACTIVE:"bg-sky-100 text-sky-700"},ae=()=>({type:"RATING",prompt:"",optionsText:"",required:!1}),re=s=>({id:s.id,type:s.type,prompt:s.prompt,optionsText:(s.options??[]).join(", "),required:s.required??!1}),ue=s=>Array.from(new Set(s.split(",").map(t=>t.trim()).filter(Boolean))),Qe=(s,t)=>({type:s.type,prompt:s.prompt.trim(),options:W(s.type)?ue(s.optionsText):void 0,required:s.required,order:t});function Ge({segmentCounts:s}){const{t}=O("marketing"),n=fe(),d=_(a=>a.currentOrganizationId),[i,l]=c.useState(!1),[y,x]=c.useState(null),[p,m]=c.useState(null),[L,b]=c.useState(null),w=c.useRef(new Map),{data:f,isLoading:D}=M({queryKey:["surveys",d],queryFn:()=>I.list(),enabled:!!d}),{data:E}=M({queryKey:["marketing-campaigns","SURVEY",d],queryFn:()=>P.campaigns.list({type:"SURVEY"}),enabled:!!d,refetchInterval:a=>{var r;return(r=a.state.data)!=null&&r.some(u=>u.status==="SCHEDULED"||u.status==="QUEUED"||u.status==="SENDING")?15e3:!1}}),C=()=>{n.invalidateQueries({queryKey:["surveys"]}),n.invalidateQueries({queryKey:["survey"]})},[v,h]=c.useState(null),T=k({mutationFn:a=>P.campaigns.send(a),onSuccess:()=>{S.success(t("surveys.toast.queued")),n.invalidateQueries({queryKey:["marketing-campaigns"]})},onError:()=>S.error(t("surveys.toast.error")),onSettled:()=>h(null)}),o=k({mutationFn:a=>P.campaigns.cancel(a),onSuccess:()=>n.invalidateQueries({queryKey:["marketing-campaigns"]}),onError:()=>S.error(t("surveys.toast.error"))}),N=k({mutationFn:a=>P.campaigns.remove(a),onSuccess:()=>n.invalidateQueries({queryKey:["marketing-campaigns"]}),onError:()=>S.error(t("surveys.toast.error"))}),R=k({mutationFn:a=>I.remove(a),onSuccess:()=>{S.success(t("surveys.toast.deleted")),C()},onError:()=>S.error(t("surveys.toast.error"))}),B=a=>{window.confirm(t("surveys.actions.confirmDelete",{title:a.title}))&&R.mutate(a.id)},H=()=>{x(null),l(!0)},K=a=>{x(a),l(!0)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:t("surveys.title")}),e.jsxs(j,{size:"sm",onClick:H,children:[e.jsx(de,{className:"w-4 h-4 mr-1"}),t("surveys.newSurvey")]})]}),D?e.jsx(A,{className:"w-6 h-6 animate-spin text-muted-foreground"}):!f||f.length===0?e.jsx("p",{className:"text-sm text-muted-foreground border rounded-lg p-6 text-center",children:t("surveys.empty")}):e.jsx("div",{className:"border rounded-lg overflow-x-auto",children:e.jsxs(Ie,{children:[e.jsx(Le,{children:e.jsxs(ee,{children:[e.jsx(Q,{children:t("surveys.th.title")}),e.jsx(Q,{children:t("surveys.th.questions")}),e.jsx(Q,{children:t("surveys.th.responses")}),e.jsx(Q,{className:"text-right",children:t("surveys.th.actions")})]})}),e.jsx(De,{children:f.map(a=>{var r,u;return e.jsxs(ee,{children:[e.jsxs(G,{children:[e.jsx("p",{className:"font-medium text-sm",children:a.title}),a.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:a.description})]}),e.jsx(G,{className:"text-sm tabular-nums",children:((r=a._count)==null?void 0:r.questions)??0}),e.jsx(G,{className:"text-sm tabular-nums",children:((u=a._count)==null?void 0:u.responses)??0}),e.jsxs(G,{className:"text-right space-x-1 whitespace-nowrap",children:[e.jsxs(j,{size:"sm",variant:"outline",onClick:()=>m(a),children:[e.jsx(se,{className:"w-3.5 h-3.5 mr-1"}),t("surveys.actions.send")]}),e.jsxs(j,{size:"sm",variant:"ghost",onClick:()=>b(a),children:[e.jsx(Fe,{className:"w-3.5 h-3.5 mr-1"}),t("surveys.actions.results")]}),e.jsx(j,{size:"sm",variant:"ghost",title:t("surveys.actions.edit"),onClick:()=>K(a),children:e.jsx(Pe,{className:"w-3.5 h-3.5"})}),e.jsx(j,{size:"sm",variant:"ghost",title:t("surveys.actions.delete"),disabled:R.isPending,onClick:()=>B(a),children:e.jsx(X,{className:"w-3.5 h-3.5"})})]})]},a.id)})})]})}),E&&E.length>0&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-medium text-muted-foreground mb-2",children:t("followups.listTitle")}),e.jsx("div",{className:"border rounded-lg divide-y",children:E.map(a=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:a.name}),e.jsx(ie,{variant:"secondary",className:Me[a.status],children:t(`followups.status.${a.status}`)}),e.jsxs("div",{className:"ml-auto space-x-1 whitespace-nowrap",children:[(a.status==="DRAFT"||a.status==="FAILED")&&e.jsxs(j,{size:"sm",variant:"outline",disabled:T.isPending,onClick:()=>h({campaign:a,mode:"send"}),children:[e.jsx(se,{className:"w-3.5 h-3.5 mr-1"}),a.status==="FAILED"?t("followups.actions.retry"):t("followups.actions.send")]}),(a.status==="QUEUED"||a.status==="SENDING"||a.status==="SCHEDULED")&&e.jsx(j,{size:"sm",variant:"ghost",disabled:o.isPending,onClick:()=>o.mutate(a.id),children:t("followups.actions.cancel")}),a.status!=="QUEUED"&&a.status!=="SENDING"&&e.jsx(j,{size:"sm",variant:"ghost",disabled:N.isPending,onClick:()=>{window.confirm(t("followups.confirmDelete",{name:a.name}))&&N.mutate(a.id)},children:e.jsx(X,{className:"w-3.5 h-3.5"})})]})]},a.id))})]}),e.jsx(be,{request:v,onClose:()=>h(null),pending:T.isPending,onConfirm:a=>T.mutate(a.campaign.id)}),e.jsx(_e,{open:i,survey:y,onClose:()=>l(!1),onSaved:C}),e.jsx(Be,{survey:p,segmentCounts:s,createdCampaignIds:w,onClose:()=>m(null),onSent:()=>{n.invalidateQueries({queryKey:["marketing-campaigns"]}),C()}}),e.jsx(He,{survey:L,onClose:()=>b(null)})]})}function _e({open:s,survey:t,onClose:n,onSaved:d}){var a;const{t:i}=O("marketing"),l=_(r=>r.currentOrganizationId),[y,x]=c.useState(""),[p,m]=c.useState(""),[L,b]=c.useState(!0),[w,f]=c.useState([]),[D,E]=c.useState(""),C=c.useRef(!1),v=(((a=t==null?void 0:t._count)==null?void 0:a.responses)??0)>0,h=M({queryKey:["survey",t==null?void 0:t.id,l],queryFn:()=>I.get(t.id),enabled:s&&!!t});c.useEffect(()=>{if(!s){C.current=!1;return}C.current||(t?h.data&&h.data.id===t.id&&(C.current=!0,x(h.data.title),m(h.data.description??""),b(h.data.isActive),E(""),f((h.data.questions??[]).map(re))):(C.current=!0,x(""),m(""),b(!0),E(""),f([ae()])))},[s,t,h.data]);const T=k({mutationFn:()=>I.aiGenerate(D.trim()),onSuccess:r=>{x(r.title),f(r.questions.slice(0,V).map(re))},onError:r=>{var g,F;const u=(F=(g=r==null?void 0:r.response)==null?void 0:g.data)==null?void 0:F.message;S.error(u||i("surveys.builder.aiError"))}}),o=k({mutationFn:()=>{const r=w.map(Qe);return t?I.update(t.id,{title:y.trim(),description:p.trim(),isActive:L,...v?{}:{questions:r}}):I.create({title:y.trim(),description:p.trim()||void 0,questions:r})},onSuccess:()=>{S.success(i(t?"surveys.toast.updated":"surveys.toast.created")),d(),n()},onError:()=>S.error(i("surveys.toast.error"))}),N=(r,u)=>{f(g=>g.map((F,me)=>me===r?{...F,...u}:F))},R=r=>{f(u=>u.filter((g,F)=>F!==r))},B=()=>{f(r=>r.length>=V?r:[...r,ae()])},H=w.length>0&&w.every(r=>r.prompt.trim()&&te(r)),K=!!y.trim()&&(v||H)&&!o.isPending&&!h.isFetching;return e.jsxs($,{open:s,onClose:n,children:[e.jsx(q,{children:e.jsx(J,{children:i(t?"surveys.builder.editTitle":"surveys.builder.createTitle")})}),e.jsxs("div",{className:"space-y-4",children:[!v&&e.jsxs("div",{className:"border rounded-lg p-3 bg-muted/40",children:[e.jsx(z,{className:"text-sm",children:i("surveys.builder.aiGoalLabel")}),e.jsxs("div",{className:"flex gap-2 mt-1.5",children:[e.jsx(U,{value:D,onChange:r=>E(r.target.value),placeholder:i("surveys.builder.aiGoalPh"),maxLength:300}),e.jsxs(j,{type:"button",variant:"outline",className:"shrink-0",disabled:!D.trim()||T.isPending,onClick:()=>T.mutate(),children:[T.isPending?e.jsx(A,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):e.jsx(ce,{className:"w-3.5 h-3.5 mr-1"}),i("surveys.builder.aiGenerate")]})]})]}),e.jsxs("div",{children:[e.jsx(z,{children:i("surveys.builder.title")}),e.jsx(U,{value:y,onChange:r=>x(r.target.value),placeholder:i("surveys.builder.titlePh"),maxLength:200,className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(z,{children:i("surveys.builder.description")}),e.jsx(le,{value:p,onChange:r=>m(r.target.value),rows:2,maxLength:1e3,className:"mt-1"})]}),t&&e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx(Z,{checked:L,onCheckedChange:b}),i("surveys.builder.active")]}),v&&e.jsx("p",{className:"text-xs text-amber-600",children:i("surveys.builder.locked")}),t&&h.isLoading?e.jsx(A,{className:"w-5 h-5 animate-spin text-muted-foreground"}):e.jsxs("div",{className:"space-y-3",children:[w.map((r,u)=>e.jsxs("div",{className:"border rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ee,{value:r.type,onValueChange:g=>N(u,{type:g}),disabled:v,children:[e.jsx(we,{className:"h-8 text-xs w-[170px]","aria-label":i("surveys.builder.typeLabel"),children:e.jsx(Ce,{})}),e.jsx(Te,{children:ze.map(g=>e.jsx(ke,{value:g,children:i(`surveys.builder.types.${g}`)},g))})]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer ml-auto",children:[e.jsx(Z,{checked:r.required,disabled:v,onCheckedChange:g=>N(u,{required:g})}),i("surveys.builder.required")]}),e.jsx(j,{size:"sm",variant:"ghost",title:i("surveys.builder.remove"),disabled:v,onClick:()=>R(u),children:e.jsx(X,{className:"w-3.5 h-3.5"})})]}),e.jsx(U,{value:r.prompt,onChange:g=>N(u,{prompt:g.target.value}),placeholder:i("surveys.builder.questionPrompt"),maxLength:300,disabled:v}),W(r.type)&&e.jsxs("div",{children:[e.jsx(U,{value:r.optionsText,onChange:g=>N(u,{optionsText:g.target.value}),placeholder:i("surveys.builder.optionsLabel"),disabled:v}),e.jsx("p",{className:`text-xs mt-1 ${te(r)?"text-muted-foreground":"text-red-600"}`,children:i("surveys.builder.optionsHint")})]})]},u)),e.jsxs(j,{type:"button",size:"sm",variant:"outline",disabled:v||w.length>=V,onClick:B,children:[e.jsx(de,{className:"w-3.5 h-3.5 mr-1"}),i("surveys.builder.addQuestion")]})]})]}),e.jsxs(oe,{className:"gap-2",children:[e.jsx(j,{variant:"outline",onClick:n,children:i("surveys.builder.cancel")}),e.jsxs(j,{disabled:!K,onClick:()=>o.mutate(),children:[o.isPending&&e.jsx(A,{className:"w-4 h-4 mr-1 animate-spin"}),i("surveys.builder.save")]})]})]})}function Be({survey:s,segmentCounts:t,createdCampaignIds:n,onClose:d,onSent:i}){const{t:l,ready:y}=O("marketing"),[x,p]=c.useState("all"),[m,L]=c.useState(""),[b,w]=c.useState(""),[f,D]=c.useState("PLAIN");c.useEffect(()=>{s&&y&&(p("all"),L(l("surveys.send.defaultSubject")),w(l("surveys.send.defaultBody")))},[s,y]);const E=k({mutationFn:async()=>{const o=s.id;let N=n.current.get(o);return N||(N=(await P.campaigns.create({type:"SURVEY",name:s.title,channel:"EMAIL",subject:m,body:b,emailStyle:f,surveyId:o,targetAudience:x==="all"?"all":"filtered",audie
1nceFilter:x==="all"?void 0:{segment:x}})).id,n.current.set(o,N)),await P.campaigns.send(N),o},onSuccess:o=>{n.current.delete(o),S.success(l("surveys.toast.queued")),i(),d()},onError:()=>S.error(l("surveys.toast.error"))}),[C,v]=c.useState(null),h=t==null?void 0:t[x],T=y&&!!m&&!!b&&!E.isPending&&h!==0;return e.jsxs($,{open:!!s,onClose:d,children:[e.jsx(q,{children:e.jsxs(J,{children:[l("surveys.send.title")," â ",s==null?void 0:s.title]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(z,{className:"text-sm",children:l("surveys.send.audience")}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-1.5",children:Ae.map(o=>e.jsxs("button",{type:"button",onClick:()=>p(o),className:`px-3 py-1.5 rounded-full text-xs border transition-colors ${x===o?"bg-primary text-primary-foreground border-primary":"bg-background hover:bg-muted"}`,children:[l(`followups.segments.${o}`),(t==null?void 0:t[o])!==void 0&&e.jsxs("span",{className:"ml-1 opacity-75",children:["· ",t[o]]})]},o))})]}),e.jsxs("div",{children:[e.jsx(z,{children:l("surveys.send.subject")}),e.jsx(U,{value:m,onChange:o=>L(o.target.value),maxLength:200,className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(z,{children:l("surveys.send.body")}),e.jsx(le,{value:b,onChange:o=>w(o.target.value),rows:6,maxLength:5e3,className:"mt-1"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:l("surveys.send.buttonNote")})]}),e.jsx(Se,{value:f,onChange:D})]}),e.jsxs(oe,{className:"gap-2",children:[e.jsx(j,{variant:"outline",onClick:d,children:l("surveys.send.cancel")}),e.jsx(j,{variant:"outline",disabled:!b,onClick:()=>v({type:"SURVEY",subject:m,body:b,emailStyle:f}),children:l("followups.preview.button")}),e.jsxs(j,{disabled:!T,onClick:()=>E.mutate(),children:[E.isPending&&e.jsx(A,{className:"w-4 h-4 mr-1 animate-spin"}),h!==void 0?l("surveys.send.sendNow",{count:h}):l("surveys.send.sendNowUnknown")]})]}),e.jsx(Ne,{request:C,onClose:()=>v(null)})]})}function He({survey:s,onClose:t}){const{t:n}=O("marketing"),d=_(m=>m.currentOrganizationId),[i,l]=c.useState(null),y=M({queryKey:["survey-results",s==null?void 0:s.id,d],queryFn:()=>I.results(s.id),enabled:!!s});c.useEffect(()=>{l(null)},[s==null?void 0:s.id]);const x=k({mutationFn:()=>I.summarize(s.id),onSuccess:m=>l(m.summary),onError:()=>S.error(n("surveys.toast.error"))}),p=y.data;return e.jsxs($,{open:!!s,onClose:t,children:[e.jsx(q,{children:e.jsxs(J,{children:[n("surveys.results.title")," â ",s==null?void 0:s.title]})}),y.isLoading?e.jsx(A,{className:"w-6 h-6 animate-spin text-muted-foreground"}):y.isError?e.jsx("p",{className:"text-sm text-red-600",children:n("surveys.toast.error")}):p&&p.totalResponses===0?e.jsx("p",{className:"text-sm text-muted-foreground border rounded-lg p-6 text-center",children:n("surveys.results.noResponses")}):p?e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(Y,{label:n("surveys.results.responses"),value:p.totalResponses}),e.jsx(Y,{label:n("surveys.results.sent"),value:p.sentCount}),e.jsx(Y,{label:n("surveys.results.rate"),value:p.responseRate!=null?`${p.responseRate}%`:"â"})]}),e.jsxs("div",{children:[e.jsx(j,{type:"button",size:"sm",variant:"outline",disabled:x.isPending,onClick:()=>x.mutate(),children:x.isPending?e.jsxs(e.Fragment,{children:[e.jsx(A,{className:"w-3.5 h-3.5 mr-1 animate-spin"}),n("surveys.results.summarizing")]}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3.5 h-3.5 mr-1"}),n("surveys.results.summarize")]})}),i&&e.jsxs("div",{className:"border rounded-lg p-3 mt-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:n("surveys.results.aiSummary")}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:i})]})]}),p.questions.map(m=>e.jsx(Ke,{question:m},m.id))]}):null]})}function Y({label:s,value:t}){return e.jsxs("div",{className:"border rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e.jsx("p",{className:"text-xl font-semibold tabular-nums",children:t})]})}function Ke({question:s}){const{t}=O("marketing");return e.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[e.jsx("p",{className:"font-medium text-sm",children:s.prompt}),s.type==="RATING"&&e.jsxs(e.Fragment,{children:[s.average!=null&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t("surveys.results.average"),":"," ",e.jsx("span",{className:"tabular-nums",children:s.average.toFixed(1)})]}),e.jsx(ne,{seriesName:t("surveys.results.responses"),data:["1","2","3","4","5"].map(n=>{var d;return{label:n,count:((d=s.distribution)==null?void 0:d[n])??0}})})]}),s.type==="NPS"&&s.nps&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"px-3 py-1.5 rounded-full text-xs bg-green-100 text-green-700",children:[t("surveys.results.promoters"),": ",s.nps.promoters]}),e.jsxs("span",{className:"px-3 py-1.5 rounded-full text-xs bg-gray-100 text-gray-700",children:[t("surveys.results.passives"),": ",s.nps.passives]}),e.jsxs("span",{className:"px-3 py-1.5 rounded-full text-xs bg-red-100 text-red-700",children:[t("surveys.results.detractors"),": ",s.nps.detractors]}),e.jsxs("span",{className:"text-sm font-semibold ml-auto tabular-nums",children:[t("surveys.results.nps"),": ",s.nps.score??"â"]})]}),(s.type==="SINGLE_CHOICE"||s.type==="MULTIPLE_CHOICE")&&e.jsx(ne,{seriesName:t("surveys.results.responses"),data:Object.entries(s.choices??{}).map(([n,d])=>({label:n,count:d}))}),s.type==="FREE_TEXT"&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1.5",children:t("surveys.results.texts")}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1.5",children:(s.texts??[]).map((n,d)=>e.jsx("p",{className:"text-sm border rounded-md px-3 py-2 bg-muted/40",children:n},d))})]})]})}function ne({data:s,seriesName:t}){return e.jsx("div",{className:"h-44 w-full",children:e.jsx(xe,{width:"100%",height:"100%",children:e.jsxs(pe,{data:s,margin:{top:4,right:8,left:-24,bottom:0},children:[e.jsx(he,{strokeDasharray:"3 3",vertical:!1,className:"stroke-muted"}),e.jsx(ge,{dataKey:"label",tick:{fontSize:12}
1,tickLine:!1,axisLine:!1,interval:0}),e.jsx(je,{tick:{fontSize:12},tickLine:!1,axisLine:!1,allowDecimals:!1}),e.jsx(ye,{cursor:{fill:"hsl(var(--muted))",opacity:.4},contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),e.jsx(ve,{dataKey:"count",name:t,fill:"hsl(var(--primary))",radius:[4,4,0,0],maxBarSize:40})]})})})}const Ve=["all","new","regulars","lapsed"];function Ye(s){return s==="all"?{targetAudience:"all"}:{targetAudience:"filtered",audienceFilter:{segment:s}}}function vs(){const{t:s}=O("marketing"),t=_(d=>d.currentOrganizationId),n=M({queryKey:["followup-segment-counts",t],queryFn:async()=>{const i=(await Promise.allSettled(Ve.map(async l=>{const{count:y}=await P.campaigns.audienceCount({type:"SURVEY",channel:"EMAIL",...Ye(l)});return[l,y]}))).filter(l=>l.status==="fulfilled").map(l=>l.value);return Object.fromEntries(i)},enabled:!!t,staleTime:6e4});return e.jsxs("div",{className:"p-4 md:p-6 space-y-6 max-w-5xl",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[s("surveys.title"),e.jsx(ie,{variant:"secondary",className:"bg-amber-100 text-amber-800 text-xs font-medium",children:s("followups.betaBadge")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("surveys.pageSubtitle")})]}),e.jsx(Ge,{segmentCounts:n.data})]})}export{vs 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.