1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/exceljs.min-C4dcVw1k.js","assets/index-Bfuskbvf.js","assets/index-DfsbQ129.css"])))=>i.map(i=>d[i]); 2import{R as $t,r as a,j as e,B as k,ab as oe,G as F,h as d,D as Nt,a as ft,b as xt,u as jt,c as _s,e as Hs,T as Lt,a1 as Ae,w as pe,ap as st,aJ as vs,l as ne,aC as kt,i as me,t as Xe,ao as Ke,a4 as Ue,ci as fs,L as Vs,aa as N,k as Ye,cC as Fs,cD as Ys,an as Rt,J as zs,aq as Ks,aj as Xs,ak as Js,ai as xs,P as Os,cE as qs,cF as Ms,cG as Qs,aE as gt,cH as Zs,cI as $s,bG as ea,cJ as es,cK as ta,b3 as sa,cL as aa,m as je,cM as na,bO as ia,cN as la,cO as As,at as ra,au as oa,ay as ca,az as da,bW as ua,cP as be,o as ze,H as pa,p as js,g as ma,bv as ts,S as ha}from"./index-Bfuskbvf.js";import{d as ga,c as fa,r as xa,e as ja,f as Sa,h as is,a as ba,b as ya,i as va,u as wa,j as Ca,k as Ta,l as Ma,m as Aa,g as Ea}from"./campaigns-DF_1YeRp.js";import{u as bs}from"./useQuery-qSjE5pux.js";import{a as Ia,D as Pa}from"./DateRangePicker-BUAnjXtW.js";import{W as ns}from"./WhatsAppTemplatePreview-DH5QdBtS.js";import{S as at}from"./InfoIcon.svg-ByI-v68A.js";import{C as Da}from"./Card-OPaZ3948.js";import{D as Bs}from"./DataTable-DpPVeQCz.js";import{c as ka}from"./analytics-DciYmsyc.js";import{S as Es}from"./StatValue-Dnbk1IAW.js";import{B as Na}from"./BalanceUpdate-BXFKgqmB.js";import{P as Ra}from"./index-CKfAl4vS.js";import{r as Is,a as Ps}from"./constants-CfTbxg26.js";import{H as La,G as _a}from"./TemplateSection-DlzzOa4-.js";import"./FileSaver.min-BxdFp20m.js";import{i as Fa,a as Oa}from"./utils-BJXZy9fU.js";import{D as ss,T as Ds}from"./Thumbnail-CPGu2m-l.js";import{S as ks}from"./NoteIcon.svg-BD9YhqVp.js";import{R as Ba}from"./RadioButton-uoiHGclV.js";import{B as Ua}from"./Banner-CA00zSsJ.js";import{C as Wa}from"./Checkbox-JrDf54NZ.js";import{S as Ga}from"./ExternalIcon.svg-oo2gJIS1.js";import{N as Ha}from"./NudgeScreen-eY4pKYIu.js";import{P as Va}from"./PaymentFailed-GmnRHMsh.js";import{P as Ya,e as za,T as Ka}from"./PageMarkup-Wdu19r-5.js";import{P as Xa}from"./PageHeader-B4MQwna_.js";/* empty css */import"./SupportEmailLink-cl4oV6sB.js";/* empty css */import"./pricing-BNegtuF_.js";import"./Filters-CP7-UWdS.js";import"./ChoiceList-lJgzmq9l.js";import"./CheckIcon.svg-CGbzQukX.js";import"./nudgeScreenNew-CzV1cdn_.js";import"./PlanModal-D0Rpsrp6.js";import"./payment-failed-CTJuC0at.js";var Us=function(u){return $t.createElement("svg",Object.assign({viewBox:"0 0 20 20"},u),$t.createElement("path",{fillRule:"evenodd",d:"M6 2.25c.414 0 .75.336.75.75v.528c.487-.028 1.07-.028 1.768-.028h2.482v-.5c0-.414.336-.75.75-.75s.75.336.75.75v.604c1.296.347 2.25 1.53 2.25 2.936 0 .835-.678 1.513-1.513 1.513h-8.733c-.004.288-.004.617-.004.997v2.468c0 1.233 1 2.232 2.232 2.232.414 0 .75.336.75.75s-.336.75-.75.75c-2.061 0-3.732-1.67-3.732-3.732v-2.5c0-.813 0-1.469.043-2 .045-.546.14-1.026.366-1.47.36-.706.933-1.28 1.639-1.64.066-.033.134-.064.202-.093v-.815c0-.414.336-.75.75-.75Zm7.237 4.303h-8.61c.033-.13.072-.234.118-.324.216-.424.56-.768.984-.984.197-.1.458-.17.912-.207.462-.037 1.057-.038 1.909-.038h3.16c.85 0 1.54.69 1.54 1.54v.005l-.004.004-.004.003h-.005Z"}),$t.createElement("path",{d:"M14.25 12c0-.414-.336-.75-.75-.75s-.75.336-.75.75v1.293c0 .331.132.65.366.884l.854.853c.293.293.767.293 1.06 0 .293-.293.293-.767 0-1.06l-.78-.78v-1.19Z"}),$t.createElement("path",{fillRule:"evenodd",d:"M13.5 18c2.485 0 4.5-2.015 4.5-4.5s-2.015-4.5-4.5-4.5-4.5 2.015-4.5 4.5 2.015 4.5 4.5 4.5Zm0-1.5c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3Z"}))};Us.displayName="CalendarTimeIcon";const Ja="/assets/whatsappScreen-G-kZ5qJ4.svg",Ss=(n,u)=>{const p=parseInt(n);return u==="AM"?p===12?0:p:p===12?12:p+12},qa=n=>{const[u,p]=(n||"").split(":").map(Number),S=isNaN(u)?12:u,R=isNaN(p)?0:p,b=S>=12,J=S===0?12:S>12?S-12:S,ce=Math.round(R/5)*5%60;return{hour:String(J).padStart(2,"0"),minute:String(ce).padStart(2,"0"),amPm:b?"PM":"AM"}},Ns=Array.from({length:12},(n,u)=>{const p=String(u+1).padStart(2,"0");return{label:p,value:p}}),as=Array.from({length:12},(n,u)=>{const p=String(u*5).padStart(2,"0");return{label:p,value:p}}),Rs=[{label:"AM",value:"AM"},{label:"PM",value:"PM"}],Ws=({dateTime:n,setDateTime:u})=>{const p=n.date?new Date(n.date+"T12:00:00"):new Date,{hour:S,minute:R,amPm:b}=qa(n.time),[{month:J,year:ce},$]=a.useState({month:p.getMonth(),year:p.getFullYear()}),[C,ie]=a.useState({start:p,end:p}),[V,T]=a.useState(S),[K,y]=a.useState(R),[Y,ee]=a.useState(b),q=j=>oe(j.start).isSame(oe(),"day"),Q=(j,E)=>{if(!q(j))return Ns;const w=new Date().getHours();return Ns.map(I=>({...I,disabled:Ss(I.value,E)<w}))},O=(j,E,w)=>{if(!q(j))return as;const I=new Date().getHours(),X=new Date().getMinutes(),P=Ss(E,w);if(P>I)return as;if(P<I)return as.map(B=>({...B,disabled:!0}));const o=Math.ceil(X/5)*5%60;return as.map(B=>({...B,disabled:parseInt(B.value)<o}))},ye=j=>{if(!q(j))return Rs;const E=new Date().getHours()>=12?"PM":"AM";return Rs.map(w=>({...w,disabled:w.value==="AM"&&E==="PM"}))},Ee=(j,E,w,I)=>
2{if(!q(j))return{h:E,m:w,ap:I};const X=new Date,P=Ss(E,I),o=parseInt(w);if(P>X.getHours())return{h:E,m:w,ap:I};if(P===X.getHours()&&o>=Math.ceil(X.getMinutes()/5)*5%60)return{h:E,m:w,ap:I};let B=X.getHours(),he=Math.ceil(X.getMinutes()/5)*5;he>=60&&(he=0,B+=1),B>=24&&(B=23);const le=B>=12?"PM":"AM",se=B===0?12:B>12?B-12:B;return{h:String(se).padStart(2,"0"),m:String(he).padStart(2,"0"),ap:le}},te=(j,E,w,I)=>{const X=oe(j.start).format("YYYY-MM-DD");let P=parseInt(E);I==="PM"&&P!==12&&(P+=12),I==="AM"&&P===12&&(P=0),u({date:X,time:`${P}:${w}`})},de=j=>{const{h:E,m:w,ap:I}=Ee(j,V,K,Y);ie(j),T(E),y(w),ee(I),te(j,E,w,I)};return e.jsxs(k,{gap:"400",children:[e.jsx(Ia,{month:J,year:ce,onChange:de,onMonthChange:(j,E)=>$({month:j,year:E}),selected:C,disableDatesBefore:oe().startOf("day").toDate(),disableDatesAfter:oe().add(1,"month").toDate()}),e.jsxs(F,{gap:"300",blockAlign:"center",children:[e.jsx(d,{as:"span",fontWeight:"semibold",children:"Time"}),e.jsx("div",{style:{width:"85px"},children:e.jsx(Nt,{label:"",labelHidden:!0,options:Q(C,Y),value:V,onChange:j=>{T(j),te(C,j,K,Y)}})}),e.jsx("div",{style:{width:"85px"},children:e.jsx(Nt,{label:"",labelHidden:!0,options:O(C,V,Y),value:K,onChange:j=>{y(j),te(C,V,j,Y)}})}),e.jsx("div",{style:{width:"80px"},children:e.jsx(Nt,{label:"",labelHidden:!0,options:ye(C),value:Y,onChange:j=>{ee(j),te(C,V,K,j)}})})]})]})},Qa=n=>{try{return new Intl.NumberFormat(void 0,{maximumFractionDigits:2}).format(n)}catch{return n.toLocaleString()}},Za=5*60*1e3,Gs=n=>n.status==="DRAFT"&&n.campaignType==="SHOPIFY_SEGMENT",ws=n=>Gs(n)&&Number(n.size??0)<=0,ys=n=>{if(!ws(n))return!1;const u=Number(n.modifiedOn??n.createdOn??0);return u>0&&Date.now()-u<=Za},$a=n=>ws(n)&&!ys(n),en="919901353494",tn=(n,u)=>{const p=["Hi, I need help with a campaign.",`Campaign ID: ${n.id}`,`Campaign name: ${n.name||"-"}`,`Store: ${u.url||"-"}`].join(` 3`);return`https://wa.me/${en}?text=${encodeURIComponent(p)}`};function sn(n){var Kt,At,Xt,Et,Jt,qt,Qt,It,Pt,Dt;const{shopDetailsData:u,agentPhone:p}=ft(xt(t=>({shopDetailsData:t.shopDetailsData,agentPhone:t.agentPhone}))),[S,R]=a.useState(null),[b,J]=a.useState(""),[ce,$]=a.useState(""),[C,ie]=a.useState(0),[V,T]=a.useState(!1),[K,y]=a.useState(0),[Y,ee]=a.useState(!1),[q,Q]=a.useState(null),O=a.useRef(null),[ye,Ee]=a.useState(null),te=a.useRef(null),de=a.useRef(null),j=jt(),E=_s();let{path:w}=Hs();const[I,X]=a.useState({id:"",url:"",planId:""}),[P,o]=a.useState({show:!1,message:"",error:!1}),[B,he]=a.useState(""),[le,se]=a.useState({open:!1,campaignId:"",name:""}),[ae,ge]=a.useState(!1),[ve,H]=a.useState(null),[re,Je]=a.useState(null),[We,Z]=a.useState(null),[U,Ge]=a.useState(null),[qe,nt]=a.useState(!1),[Qe,we]=a.useState(null),[Ce,Se]=a.useState(()=>!localStorage.getItem("campaigns_actions_hint_seen")),Ie=a.useRef(null),[Te,it]=a.useState(null);a.useEffect(()=>{if(Ce&&Ie.current){const t=Ie.current.getBoundingClientRect();it({top:t.bottom+10,left:t.left})}},[Ce]);const St=()=>{Ce&&(localStorage.setItem("campaigns_actions_hint_seen","1"),Se(!1))},[xe,Pe]=a.useState({open:!1,campaignId:"",mode:"schedule"}),[L,A]=a.useState({date:"",time:""}),[fe,Re]=a.useState({open:!1,campaign:null}),[Ze,bt]=a.useState({open:!1,campaign:null}),[M,_t]=a.useState(null),[ls,rs]=a.useState(!1),[Ft,$e]=a.useState(""),[He,Ot]=a.useState({}),[lt,Le]=a.useState([]),[Bt,os]=a.useState(!1);a.useEffect(()=>{const t=u;t!=null&&t.id&&(R(t.id),J(t.userId??"")),t!=null&&t.url&&$(t.url),t&&X({id:t.id??"",url:t.url??"",planId:t.planId??""})},[u]),a.useEffect(()=>{var h;const t=(h=E.state)==null?void 0:h.successMessage;t&&(o({show:!0,message:t,error:!1}),j.replace(E.pathname,{}))},[]),a.useEffect(()=>(document.body.className+="optin-number-page",()=>{document.body.className=""}),[]);const Cs=((Kt=n.privateWabaDetails)==null?void 0:Kt.pipeLineStage)??((At=n.privateWabaDetails)==null?void 0:At.pipelineStage),_e=!!(n.privateWabaDetails&&Cs==="FINALIZE"),{data:De,isFetching:Ut,isError:Ve,isFetched:Wt,refetch:rt}=bs({queryKey:["campaigns",b,K,C],queryFn:async()=>{const t=await ba(b),h=Array.isArray(t==null?void 0:t.campaigns)?[...t.campaigns]:[];h.length>0&&h.sort((i,r)=>(i.createdOn??0)>
3(r.createdOn??0)?-1:(i.createdOn??0)<(r.createdOn??0)?1:0);const s=await Promise.all(h.map(async i=>{var l,c;if(i.status!=="COMPLETED")return{...i,revenueRow:null};const r=await ya(b,i.id).catch(()=>null);return{...i,revenueRow:((c=(l=r==null?void 0:r.data)==null?void 0:l.rows)==null?void 0:c[0])??null}}));return{...t,campaigns:s}},enabled:!!b&&_e,retry:3,retryDelay:t=>Math.min(2e3*2**t,1e4),refetchInterval:t=>{var s;return(((s=t.state.data)==null?void 0:s.campaigns)??[]).some(ys)?1e4:!1}}),{data:yt}=bs({queryKey:["campaignTemplates",b],queryFn:async()=>{const t=await is(b);return(t==null?void 0:t.templates)||[]},enabled:!!b&&_e}),Gt=new Map((yt||[]).map(t=>[String(t.id),t])),ot=(De==null?void 0:De.campaigns)??[],et=()=>{O.current&&(clearTimeout(O.current),O.current=null)},vt=t=>{et(),Q(t)},ke=()=>{et(),O.current=setTimeout(()=>{Q(null)},200)},ct=()=>{te.current&&(clearTimeout(te.current),te.current=null)},Ht=t=>{ct(),Ee(t)},wt=()=>{ct(),te.current=setTimeout(()=>{Ee(null)},200)},tt=()=>{de.current&&(clearTimeout(de.current),de.current=null)},z=t=>{tt(),Ge(t)},Fe=()=>{tt(),de.current=setTimeout(()=>{Ge(null)},200)},ue=()=>{!b||Y||(ee(!0),Ks(b).then(t=>{(t==null?void 0:t.status)==="success"?setTimeout(()=>{rt().finally(()=>{ee(!1),Q(null)})},5e3):(ee(!1),o({show:!0,message:(t==null?void 0:t.message)||"Unable to sync templates.",error:!0}))},()=>{ee(!1),o({show:!0,message:"Unable to sync templates.",error:!0})}))};a.useEffect(()=>{if(!n.setEventTriggered||!Wt||Ve)return;const t=((De==null?void 0:De.campaigns)??[]).length;n.setEventTriggered({...n.eventTriggered.current,TT:n.eventTriggered.current.TT+1,length:t})},[Wt,Ve,De]),a.useEffect(()=>{!b||_e||n.setEventTriggered({...n.eventTriggered.current,TF:n.eventTriggered.current.TF+1,length:0})},[b,_e]);const cs=async()=>{try{if((await ga(b,B)).status==="success"){const h=ot.find(s=>String(s.id)===String(B));Ae("campaign_deleted",{campaign_id:B,campaign_name:h==null?void 0:h.name}),o({show:!0,message:"Scheduled campaign deleted successfully.",error:!1}),he(""),T(!1),y(parseInt(B))}else o({show:!0,message:"Unable to delete scheduled campaign.",error:!0})}catch(t){console.log(t)}},_=async()=>{var h,s;const t=le.campaignId;ge(!0);try{const i=await fa(b,t);if((i==null?void 0:i.status)==="success")Ae("campaign_draft_deleted",{campaign_id:t,campaign_name:le.name}),o({show:!0,message:"Campaign draft deleted.",error:!1}),se({open:!1,campaignId:"",name:""}),y(Date.now());else{const r=typeof(i==null?void 0:i.message)=="string"?i.message:"Unable to delete this draft.";o({show:!0,message:r,error:!0})}}catch(i){const r=(s=(h=i==null?void 0:i.response)==null?void 0:h.data)==null?void 0:s.message;o({show:!0,message:typeof r=="string"?r:"Unable to delete this draft.",error:!0})}finally{ge(!1)}},ds=P.show?e.jsx(Lt,{error:P.error,content:P.message,onDismiss:()=>{o({show:!1,message:"",error:!1})}}):null,Vt=async(t,h)=>{var s,i;Ae("campaign_audience_refresh_clicked",{campaign_id:String(t),trigger:h}),Je(String(t));try{const r=await xa(b,t);(r==null?void 0:r.status)==="success"?y(Date.now()):o({show:!0,message:(r==null?void 0:r.message)||"Unable to refresh audience.",error:!0})}catch(r){const l=((i=(s=r==null?void 0:r.response)==null?void 0:s.data)==null?void 0:i.message)||"Unable to refresh audience.";o({show:!0,message:l,error:!0})}finally{Je(null)}},Ct=async t=>{H(String(t));try{const h=await ja(b,t);if((h==null?void 0:h.status)==="success")Ae("campaign_sent",{campaign_id:String(t)}),o({show:!0,message:"Campaign sent successfully.",error:!1}),y(Date.now());else{const s=typeof(h==null?void 0:h.message)=="string"?h.message:"Failed to send campaign.";o({show:!0,message:s,error:!0})}}catch{o({show:!0,message:"Failed to send campaign.",error:!0})}finally{H(null)}},dt=async()=>{var i,r;if(!L.date||!L.time)return;const[t,h]=L.time.split(":"),s=new Date(`${L.date}T${String(t).padStart(2,"0")}:${String(h).padStart(2,"0")}:00`).getTime();if(isNaN(s)||s<=Date.now()){o({show:!0,message:"Please choose a future date and time.",error:!0});return}H(String(xe.campaignId));try{const l=await Sa(b,xe.campaignId,s);if((l==null?void 0:l.status)==="success"){const c=xe.mode==="reschedule"?"campaign_rescheduled":"campaign_scheduled";Ae(c,{campaign_id:String(xe.campaignId),scheduled_at:s});const f=xe.mode==="reschedule"?"Campaign rescheduled successfully.":"Campaign scheduled successfully.";Pe({open:!1,campaignId:"",mode:"schedule"}),A({date:"",time:""}),o({show:!0,message:f,error:!1}),y(Date.now())}
3else{const c=typeof(l==null?void 0:l.message)=="string"?l.message:"Failed to schedule campaign.";o({show:!0,message:c,error:!0})}}catch(l){const c=((r=(i=l==null?void 0:l.response)==null?void 0:i.data)==null?void 0:r.message)||"Failed to schedule campaign.";o({show:!0,message:c,error:!0})}finally{H(null)}},Ne=async t=>{_t(null),rs(!0);try{const h=await is(b),s=((h==null?void 0:h.templates)||[]).find(i=>String(i.id)===String(t.templateId));if(s!=null&&s.internalText){const i=[];let r;const l=/{{(.*?)}}/g;for(;r=l.exec(s.internalText);)i.push(r[1]);s.variables=[...new Set(i)]}_t(s??null)}catch{_t(null)}finally{rs(!1)}},Yt=async t=>{bt({open:!0,campaign:t}),$e(""),Ot({}),Le([]),Ne(t)},Tt=t=>t.replace(/\s*\|\s*\[.*?\]$/,""),us=()=>{if(!(M!=null&&M.internalText))return"";let t=Tt(M.internalText);return(M.variables||[]).forEach(h=>{t=t.replace(new RegExp(`\\{\\{${h}\\}\\}`,"g"),He[h]||`{{${h}}}`)}),t},ut=async()=>{var s,i,r,l,c,f,m;const t=Ft.split(",").map(x=>x.trim()).filter(Boolean);if(!t.length||!M)return;const h=(M.variables||[]).map(x=>He[x]||"");os(!0),Le(t.map(x=>({phone:x,status:"pending"})));for(let x=0;x<t.length;x++)try{const g=await Fs(p,b,{templateId:M.templateId,internalText:M.internalText,to:t[x],params:h,media:"",type:M.type});if(g!=null&&g.error){const v=((i=(s=g.error)==null?void 0:s.errors)==null?void 0:i[0])||((r=g.error)==null?void 0:r.message)||"Failed to send";Le(W=>W.map((D,G)=>G===x?{...D,status:"error",error:v}:D))}else Le(v=>v.map((W,D)=>D===x?{...W,status:"success"}:W))}catch(g){const v=((f=(c=(l=g==null?void 0:g.response)==null?void 0:l.data)==null?void 0:c.errors)==null?void 0:f[0])||(g==null?void 0:g.message)||"Failed to send";Le(W=>W.map((D,G)=>G===x?{...D,status:"error",error:v}:D))}os(!1),Ae("campaign_test_sent",{campaign_id:String(((m=fe.campaign)==null?void 0:m.id)??""),recipient_count:t.length})},ps=async()=>{var s;const t=n.balance,h=Number((t==null?void 0:t.cappedAmount)??0)+100;nt(!0);try{const i=await Ys(b,String(h));(i==null?void 0:i.status)==="success"&&((s=i==null?void 0:i.message)!=null&&s.update_capped_amount_url)?(window.open(i.message.update_capped_amount_url,"_blank"),Ge(null)):o({show:!0,message:"Unable to get Shopify billing link. Please try again.",error:!0})}catch{o({show:!0,message:"Unable to get Shopify billing link. Please try again.",error:!0})}finally{nt(!1)}},zt={DRAFT:"Draft",CREATED:"Queued",SCHEDULED:"Scheduled",PUBLISHED:"Sending",COMPLETED:"Completed"},pt={LOW_BALANCE:"Campaign paused â your account has insufficient balance.",TEMPLATE_NOT_APPROVED:"The message template was not approved at the time of sending. If the template is approved now, you can send or schedule the campaign again.",ERROR:"An unexpected error occurred while sending this campaign."},ms=t=>{if(t==="COMPLETED")return e.jsxs(F,{gap:"100",align:"start",blockAlign:"center",children:[e.jsx(kt,{tone:"success",children:"Completed"}),e.jsx(Rt,{content:"A campaign is marked Completed once Meta has reported a delivery status â sent, delivered, read, or failed â for at least 90% of recipients. Messages continue to be delivered beyond this point.",children:e.jsx(Ke,{source:at,tone:"subdued"})})]});if(t in pt&&t!=="LOW_BALANCE")return e.jsxs(F,{gap:"100",align:"start",blockAlign:"center",children:[e.jsx(kt,{tone:"critical",children:"Failed"}),e.jsx(Rt,{content:pt[t],children:e.jsx(Ke,{source:at,tone:"critical"})})]});const h={DRAFT:"attention",CREATED:"info",SCHEDULED:"info",PUBLISHED:"warning",COMPLETED:"success"};return e.jsx(kt,{tone:h[t]??"info",children:zt[t]??t})},hs=(t,h,s)=>{if(!t)return null;const i={PENDING:"warning",APPROVED:"success",REJECTED:"critical",DISABLED:"critical",MISSING:"warning"},r={PENDING:"In Review",APPROVED:"Approved",REJECTED:"Rejected",DISABLED:"Disabled",MISSING:"Template missing"},l=e.jsx(kt,{tone:i[t]??"info",children:r[t]??t});if(t==="PENDING"){const c=String(s);return e.jsxs(F,{gap:"100",align:"center",blockAlign:"center",children:[l,e.jsx(st,{active:q===c,activator:e.jsx("span",{style:{cursor:"pointer"},tabIndex:0,role:"button","aria-label":"Template review info",onMouseEnter:()=>vt(c),onMouseLeave:ke,onFocus:()=>vt(c),onBlur:ke,onClick:()=>Q(f=>f===c?null:c),children:e.jsx(Ke,{source:at,tone:"subdued"})}),onClose:()=>{Y||Q(null)},children:e.jsx(me,{padding:"400",maxWidth:"280px",onMouseEnter:et,onMouseLeave:ke,children:e.jsxs(k,{gap:"300",children:[e.jsx(d,{as:"p",variant:"bodySm",children:"Meta can take 24-48 hours to review a template, though approval sometimes comes sooner. If you think a template's status is out of date, you can manually sync it below."}),e.jsx(ne,{size:"slim",onClick:ue,loading:Y,disabled:Y,children:"Sync templates"})]})})})]})}return t==="REJECTED"&&h?e.jsx("span",{title:h,children:l}):l},Oe=ot.map((t,h)=>{const s=t.status==="DRAFT",i=t.status==="TEMPLATE_NOT_APPROVED",r=t.templateStatus==="APPROVED",l=t.status==="COMPLETED",c=t.status==="PUBLISHED",f=ws(t),m=[...l?[{content:"See Analytics",onAction:()=>{Z(null),Ae("campaign_analytics_viewed",{campaign_id:String(t.id)}),j.push(`/campaigns/${t.id}/analytics`)}}]:[],...s||i&&r?[{content:"Schedule Campaign",disabled:f,helpText:f?"Wait for the Shopify audience to finish building":void 0,onAction:()=>
3{Z(null),Pe({open:!0,campaignId:t.id,mode:"schedule"}),A({date:"",time:""})}},{content:"Send Now",disabled:s&&!r||f,helpText:s&&!r?"Template must be approved first":f?"Wait for the Shopify audience to finish building":void 0,onAction:()=>{Z(null),Re({open:!0,campaign:t}),Ne(t)}}]:[],...s?[{content:"Edit Campaign",onAction:()=>{Z(null),Ae("campaign_edit_draft_clicked",{campaign_id:String(t.id)});const g=new URLSearchParams({editCampaignId:String(t.id),name:t.name||"",templateId:t.templateId||"",mediaUrl:t.mediaUrl||""});j.push(`/campaigns/create/new?${g.toString()}`)}}]:[],...s?[{content:"Delete Campaign",destructive:!0,onAction:()=>{Z(null),se({open:!0,campaignId:String(t.id),name:t.name||""})}}]:[],...s?[{content:"Test Campaign",disabled:!r,helpText:r?void 0:"Template must be approved first",onAction:()=>{Z(null),Yt(t)}}]:r?[{content:"Test Campaign",onAction:()=>{Z(null),Yt(t)}}]:[],...s?[]:[{content:"Clone Campaign",onAction:()=>{Z(null);const g=new URLSearchParams({clone:t.id,name:t.name||"",templateId:t.templateId||"",mediaUrl:t.mediaUrl||"",skipRecent:String(!!t.skipRecent),skipDays:String(t.skipDays??7)});j.push(`/campaigns/create/new?${g.toString()}`)}}],...t.status==="SCHEDULED"?[{content:"Reschedule Campaign",onAction:()=>{Z(null);const g=t.scheduledAt?{date:oe(t.scheduledAt).format("YYYY-MM-DD"),time:oe(t.scheduledAt).format("HH:mm")}:{date:"",time:""};A(g),Pe({open:!0,campaignId:t.id,mode:"reschedule"})}},{content:"Delete Campaign",destructive:!0,onAction:()=>{Z(null),T(!0),he(t.id)}}]:[],{content:"Get Support",onAction:()=>{Z(null),Ae("campaign_get_support_clicked",{campaign_id:String(t.id)}),window.open(tn(t,I),"_blank","noopener,noreferrer")}}],x=Ce&&h===0;return[e.jsx(pe,{vertical:!0,spacing:"extraTight",children:e.jsxs("div",{ref:x?Ie:void 0,style:{position:"relative",display:"inline-block"},children:[e.jsx(st,{active:We===String(t.id),activator:e.jsx(ne,{variant:"plain",onClick:()=>{St(),Z(g=>g===String(t.id)?null:String(t.id))},children:"â¢â¢â¢"}),onClose:()=>Z(null),children:e.jsx(vs,{items:m,onActionAnyItem:()=>Z(null)})}),x&&Te&&e.jsxs("div",{className:"sl-coachmark",style:{position:"fixed",top:Te.top,left:Te.left},children:[e.jsx("div",{className:"sl-coachmark-arrow"}),e.jsxs("span",{children:["Click ",e.jsx("strong",{children:"â¢â¢â¢"})," to schedule, send, or view analytics for this campaign."]}),e.jsx("button",{className:"sl-coachmark-dismiss",onClick:St,children:"Got it"})]})]})}),e.jsx(pe,{vertical:!0,spacing:"extraTight",children:e.jsx("p",{className:"campaignNameCell",children:l||c?e.jsx("span",{style:{color:"#2c6ecb",cursor:"pointer",textDecoration:"underline"},onClick:()=>j.push(`/campaigns/${t.id}/analytics`),children:t.name}):e.jsx("span",{children:t.name})})}),e.jsxs(pe,{vertical:!0,spacing:"extraTight",alignment:"leading",children:[t.status==="LOW_BALANCE"?e.jsxs(F,{gap:"100",align:"start",blockAlign:"center",children:[e.jsx(kt,{tone:"critical",children:"Failed"}),e.jsx(st,{active:U===String(t.id),activator:e.jsx("div",{style:{cursor:"pointer"},onMouseEnter:()=>z(String(t.id)),onMouseLeave:Fe,children:e.jsx(Ke,{source:at,tone:"critical"})}),onClose:()=>Ge(null),children:e.jsx("div",{onMouseEnter:tt,onMouseLeave:Fe,children:e.jsx(me,{padding:"400",maxWidth:"280px",children:e.jsxs(k,{gap:"300",children:[e.jsx(d,{as:"p",variant:"bodySm",children:"This campaign stopped sending because your monthly messaging fee limit was reached on Shopify. You're only charged for messages actually delivered â increasing the limit lets sending resume."}),e.jsx(Xe,{onClick:()=>!qe&&ps(),children:qe?"Opening Shopify billingâ¦":"Increase limit on Shopify"})]})})})})]}):ms(t.status),t.status==="SCHEDULED"&&t.scheduledAt&&e.jsxs("p",{className:"cellSub cellTimestamp",children:["Sends ",oe(t.scheduledAt).format("MMM D 'YY, h:mm a")]}),t.status==="COMPLETED"&&t.publishedOn>0&&e.jsx("p",{className:"cellSub cellTimestamp",children:oe(t.publishedOn).format("MMM D 'YY, h:mm a")}),(t.status==="DRAFT"||t.status==="CREATED"||t.status in pt)&&t.createdOn>0&&e.jsx("p",{className:"cellSub cellTimestamp",children:oe(t.createdOn).format("MMM D 'YY, h:mm a")})]}),e.jsx(pe,{vertical:!0,spacing:"extraTight",children:(()=>{var D,G;const g=hs(t.templateStatus,t.templateStatusReason,t.id),v=Gt.get(String(t.templateId));if(!g||!(v!=null&&v.internalText))return g;const W=`preview-${t.id}`;return e.jsx(st,{active:ye===W,activator:e.jsx("div",{style:{display:"inline-block"},onMouseEnter:()=>Ht(W),onMouseLeave:wt,children:g}),onClose:()=>Ee(null),children:e.jsx("div",{onMouseEnter:ct,onMouseLeave:wt,style:{width:"280px",padding:"12px"},children:e.jsx(ns,{bare:!0,html:Tt(v.internalText),ctaLabel:(G=(D=v.buttons)==null?void 0:D[0])==null?void 0:G.name,mediaType:v.type,mediaUrl:t.mediaUrl,cards:v.type==="CAROUSEL"?v.cards||[]:void 0,footer:v.footer,previewLabel:"Template Preview"})})})})()}),e.jsx(pe,{vertical:!0,spacing:"extraTight",children:ys(t)?e.jsx(st,{active:Qe===String(t.id),activator:e.jsx("div",{onMouseEnter:()=>we(String(t.id)),onMouseLeave:()=>we(null),children:e.jsxs(F,{gap:"100",blockAlign:"center",align:"center",children:[e.jsx("div",{style:{transform:"scale(0.6)",transformOrigin:"center"},children:e.jsx(Ue,{size:"small"})}),e.jsx("span",{className:"cellSub",children:"Fetchingâ¦"})]})}),onClose:()=>we(null),children:e.jsx(me,{padding:"300",maxWidth:"240px",children:e.jsx(d,{as:"p",variant:"bodySm",children:"Depending on the size of the Shopify segment you've selected, it can take up to 5 minutes."})})}):$a(t)?e.jsxs(k,{gap:"0",inlineAlign:"center",children:[e.jsx("span",{className:"cellSub",style:{color:"var(--p-color-text-critical)",lineHeight:"14px"},children:"Couldn't fetch the"}),e.jsxs("span",{className:"cellSub",style:{lineHeight:"14px"},children:[e.jsx("span",{style:{color:"var(--p-color-text-critical)"},children:"audience."})," ",e.jsx("span",{style:{color:re===String(t.id)?"#6d7175":"#2c6ecb",curs
3or:re===String(t.id)?"default":"pointer",textDecoration:re===String(t.id)?"none":"underline"},onClick:()=>{re!==String(t.id)&&Vt(t.id,"retry")},children:re===String(t.id)?"Retryingâ¦":"Retry"})]})]}):Gs(t)?e.jsxs(k,{gap:"0",inlineAlign:"center",children:[e.jsx("p",{children:t.size??0}),e.jsx("span",{className:"cellSub",style:{color:re===String(t.id)?"#6d7175":"#2c6ecb",cursor:re===String(t.id)?"default":"pointer",textDecoration:re===String(t.id)?"none":"underline"},onClick:()=>{re!==String(t.id)&&Vt(t.id,"refetch")},children:re===String(t.id)?"Refetchingâ¦":"Refetch"})]}):e.jsx("p",{children:t.size??0})}),e.jsx(pe,{vertical:!0,spacing:"extraTight",children:t.status==="COMPLETED"?e.jsxs("p",{children:[(t.delivered??0)+(t.failed??0),e.jsx("br",{}),e.jsxs("span",{className:"cellSub",children:["(",t.size?(((t.delivered??0)+(t.failed??0))/t.size*100).toFixed(0):0,"%)"]})]}):e.jsx("p",{children:"â"})}),e.jsx(pe,{vertical:!0,spacing:"extraTight",children:t.status==="COMPLETED"?e.jsxs("p",{children:[t.delivered??0,e.jsx("br",{}),e.jsxs("span",{className:"cellSub",children:["(",t.size?((t.delivered??0)/t.size*100).toFixed(0):0,"%)"]})]}):e.jsx("p",{children:"â"})}),e.jsx(pe,{vertical:!0,spacing:"extraTight",children:t.status==="COMPLETED"?e.jsxs("p",{children:[t.read??0,e.jsx("br",{}),e.jsxs("span",{className:"cellSub",children:["(",t.size?((t.read??0)/t.size*100).toFixed(0):0,"%)"]})]}):e.jsx("p",{children:"â"})}),...Number((u==null?void 0:u.planId)??I.planId)===fs?[e.jsx(pe,{vertical:!0,spacing:"extraTight",children:e.jsx("p",{children:t.linksClicked??0})})]:[],e.jsx(pe,{vertical:!0,spacing:"extraTight",children:e.jsx("p",{children:t.revenueRow?(t.revenueRow.attributedOrderCount??0).toLocaleString():"â"})}),e.jsx(pe,{vertical:!0,spacing:"extraTight",children:e.jsx("p",{children:t.revenueRow?e.jsxs(e.Fragment,{children:[Qa(t.revenueRow.attributedGrossRevenue??0),t.revenueRow.currency&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsxs("span",{className:"cellSub",children:["(",t.revenueRow.currency,")"]})]})]}):"â"})})]}),Mt=Number((u==null?void 0:u.planId)??I.planId)>=Number(zs);let mt,ht;return Mt?_e?(mt="Create your first campaign",ht=n.handleClick):(mt="Start Onboarding",ht=()=>j.push("/whatsapp-onboarding")):(mt="Upgrade",ht=()=>j.push("/pricing")),e.jsxs("div",{className:"optin-number-page",style:{marginTop:"1%"},children:[e.jsx("style",{children:` 4 .sl-coachmark { 5 background: #202123; 6 color: #fff; 7 border-radius: 8px; 8 padding: 12px 14px; 9 width: 230px; 10 z-index: 500; 11 box-shadow: 0 4px 16px rgba(0,0,0,0.2); 12 font-size: 13px; 13 line-height: 1.5; 14 } 15 .sl-coachmark-arrow { 16 position: absolute; 17 top: -7px; 18 left: 16px; 19 width: 0; 20 height: 0; 21 border-left: 7px solid transparent; 22 border-right: 7px solid transparent; 23 border-bottom: 7px solid #202123; 24 } 25 .sl-coachmark-dismiss { 26 margin-top: 10px; 27 background: #fff; 28 color: #202123; 29 border: none; 30 border-radius: 4px; 31 padding: 4px 12px; 32 font-size: 12px; 33 font-weight: 600; 34 cursor: pointer; 35 display: block; 36 margin-left: auto; 37 } 38 .sl-coachmark-dismiss:hover { background: #e8e8e8; } 39 `}),ds,e.jsx("div",{style:{marginBottom:"1rem"},className:"optin-number-page"}),(_e&&!b||Ut)&&e.jsxs("div",{style:{padding:"24px 0",display:"flex",alignItems:"center",gap:12},children:[e.jsx(Ue,{accessibilityLabel:"Fetching campaigns",size:"small"}),e.jsx(d,{as:"span",tone:"subdued",children:"Fetching campaigns..."})]}),!(_e&&!b)&&!Ut&&(Ve?e.jsx(me,{background:"bg-surface",padding:"400",borderRadius:"200",children:e.jsx(Vs,{children:e.jsxs("div",{style:{padding:"45px 0"},children:[e.jsx("div",{className:"flexCenter helpText",children:"Failed to load campaigns. The request may have timed out."}),e.jsx("div",{className:"borderLine"}),e.jsx("div",{className:"flexCenter customButton",children:e.jsx(ne,{onClick:()=>rt(),children:"Retry"})})]})})}):(Oe==null?void 0:Oe.length)>
390?e.jsxs(e.Fragment,{children:[e.jsx(N,{open:V,onClose:()=>T(!1),title:"Delete scheduled campaign?",primaryAction:{content:"Delete",destructive:!0,onAction:cs},secondaryActions:[{content:"Cancel",onAction:()=>T(!1)}],children:e.jsx(N.Section,{children:e.jsx(d,{as:"p",children:"This will permanently delete this campaign and all saved information will be lost."})})}),e.jsx(N,{open:le.open,onClose:()=>se({open:!1,campaignId:"",name:""}),title:"Delete this draft?",primaryAction:{content:"Delete",destructive:!0,loading:ae,onAction:_},secondaryActions:[{content:"Cancel",onAction:()=>se({open:!1,campaignId:"",name:""})}],children:e.jsx(N.Section,{children:e.jsxs(d,{as:"p",children:[le.name?`"${le.name}" `:"This draft ","will be permanently deleted. This can't be undone and there's no way to restore it afterward."]})})}),e.jsx(Da,{children:e.jsx("div",{className:"campaignsTable",children:e.jsx(Bs,{columnContentTypes:["text","text","text","text","text","text","text","text",...Number((u==null?void 0:u.planId)??I.planId)===fs?["text"]:[],"text","text"],headings:["Actions","Campaign Name","Status","Template","Recipients","Sent","Delivered","Read",...Number((u==null?void 0:u.planId)??I.planId)===fs?["Links Clicked"]:[],"Orders","Revenue"],rows:Oe})})})]}):e.jsx(me,{background:"bg-surface",padding:"800",borderRadius:"200",children:e.jsxs("div",{style:{display:"flex",gap:"48px",alignItems:"center"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:e.jsxs(k,{gap:"500",children:[e.jsxs(k,{gap:"300",children:[e.jsx(d,{variant:"headingXl",as:"h2",children:"Send WhatsApp Broadcast Campaigns"}),e.jsxs(d,{as:"p",tone:"subdued",children:["Reach your customers where they are most active. WhatsApp messages achieve up to"," ",e.jsx("strong",{children:"98% open rates"})," â perfect for promotions, product launches, and re-engagement."]})]}),e.jsxs(k,{gap:"150",children:[e.jsx(d,{as:"p",children:"Target specific customer segments"}),e.jsx(d,{as:"p",children:"Personalize messages with customer and order data"}),e.jsx(d,{as:"p",children:"Schedule campaigns in advance"}),e.jsx(d,{as:"p",children:"Track opens, clicks, and delivery in real time"})]}),e.jsxs(k,{gap:"100",children:[e.jsx("div",{children:e.jsx(ne,{variant:"primary",onClick:ht,children:mt})}),!Mt&&e.jsx(d,{as:"p",tone:"subdued",variant:"bodySm",children:"Available with Scale plan"})]})]})}),e.jsx("div",{style:{flexShrink:0},children:e.jsx("img",{src:Ja,alt:"WhatsApp Campaigns",style:{width:"260px"}})})]})})),e.jsx(N,{open:fe.open,onClose:()=>Re({open:!1,campaign:null}),title:"Send campaign now?",size:"medium",primaryAction:{content:"Send now",onAction:async()=>{const t=fe.campaign;Re({open:!1,campaign:null}),await Ct(t.id)},loading:!!ve},secondaryActions:[{content:"Cancel",onAction:()=>Re({open:!1,campaign:null})}],children:e.jsx(N.Section,{children:e.jsxs("div",{style:{display:"flex",gap:"32px",alignItems:"flex-start"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:e.jsxs(d,{as:"p",children:["This will immediately send the campaign to"," ",e.jsxs("strong",{children:[((Xt=fe.campaign)==null?void 0:Xt.size)??0," recipients"]}),". This action cannot be undone."]})}),e.jsx("div",{style:{flexShrink:0,width:"260px"},children:ls?e.jsxs(F,{gap:"200",blockAlign:"center",children:[e.jsx(Ue,{size:"small"}),e.jsx(d,{as:"span",tone:"subdued",children:"Loading previewâ¦"})]}):M!=null&&M.internalText?e.jsx(ns,{bare:!0,html:Tt(M.internalText),ctaLabel:(Jt=(Et=M.buttons)==null?void 0:Et[0])==null?void 0:Jt.name,mediaType:M.type,mediaUrl:(qt=fe.campaign)==null?void 0:qt.mediaUrl,cards:M.type==="CAROUSEL"?M.cards||[]:void 0,footer:M.footer,previewLabel:"Message Preview"}):null})]})})}),e.jsxs(N,{open:Ze.open,onClose:()=>{bt({open:!1,campaign:null}),Le([])},title:`Test Campaign: ${((Qt=Ze.campaign)==null?void 0:Qt.name)||""}`,size:"medium",children:[e.jsx(N.Section,{children:ls?e.jsxs(F,{gap:"200",blockAlign:"center",children:[e.jsx(Ue,{size:"small"}),e.jsx(d,{as:"span",tone:"subdued",children:"Loading templateâ¦"})]}):M?e.jsxs("div",{style:{display:"flex",gap:"32px",alignItems:"flex-start"},children:[e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsx("div",{className:"sl-test-modal-fields",children:e.jsx(Ye,{label:"Phone numbers",helpText:e.jsx("span",{style:{fontSize:"11px"},children:"Comma-separated, include country code (e.g. 919876543210)"}),autoComplete:"off",value:Ft,onChange:$e,placeholder:"919876543210, 15551234567"})}),(M.variables||[]).length>0&&e.jsxs(k,{gap:"200",children:[e.jsx(d,{as:"p",fontWeight:"semibold",children:"Variables"}),(M.variables||[]).map(t=>e.jsx("div",{className:"sl-test-modal-fields",children:e.jsx(Ye,{label:`{{${t}}}`,autoComplete:"off",placeholder:"Enter a sample value",value:He[t]||"",onChange:h=>Ot(s=>({...s,[t]:h}
39))})},t))]}),lt.length>0&&e.jsx(k,{gap:"100",children:lt.map((t,h)=>e.jsxs(F,{gap:"200",blockAlign:"center",children:[e.jsx(d,{variant:"bodySm",as:"span",children:t.phone}),t.status==="pending"&&e.jsx(Ue,{size:"small"}),t.status==="success"&&e.jsx(d,{tone:"success",variant:"bodySm",as:"span",children:"Sent"}),t.status==="error"&&e.jsx(d,{tone:"critical",variant:"bodySm",as:"span",children:t.error||"Failed"})]},h))}),e.jsx(F,{align:"end",children:e.jsx(ne,{variant:"primary",loading:Bt,disabled:!Ft.trim()||Bt,onClick:ut,children:"Send Test"})})]}),e.jsx("div",{style:{flexShrink:0,width:"280px"},children:e.jsx(ns,{bare:!0,html:us(),ctaLabel:(Pt=(It=M.buttons)==null?void 0:It[0])==null?void 0:Pt.name,mediaType:M.type,mediaUrl:(Dt=Ze.campaign)==null?void 0:Dt.mediaUrl,cards:M.type==="CAROUSEL"?M.cards||[]:void 0,footer:M.footer,previewLabel:"Message Preview"})})]}):e.jsx(d,{as:"p",tone:"critical",children:"Could not load template details."})}),e.jsx(N.Section,{children:e.jsxs(d,{tone:"subdued",variant:"bodySm",as:"p",children:["Meta may limit delivery of test messages. To increase the chances,"," ",e.jsxs("a",{href:`https://wa.me/${p}?text=Hi`,target:"_blank",rel:"noreferrer",style:{color:"#2c6ecb",textDecoration:"none"},onMouseEnter:t=>t.currentTarget.style.textDecoration="underline",onMouseLeave:t=>t.currentTarget.style.textDecoration="none",children:['send a "Hi" from your test number to the Business API number (',p,")"]})," ","before sending the test."]})})]}),e.jsx(N,{open:xe.open,onClose:()=>Pe({open:!1,campaignId:"",mode:"schedule"}),title:xe.mode==="reschedule"?"Reschedule campaign":"Schedule campaign",primaryAction:{content:xe.mode==="reschedule"?"Reschedule":"Schedule",onAction:dt,loading:!!ve,disabled:!L.date},secondaryActions:[{content:"Cancel",onAction:()=>Pe({open:!1,campaignId:"",mode:"schedule"})}],children:e.jsx(N.Section,{children:e.jsx(Ws,{dateTime:L,setDateTime:A})})})]})}const an="_wrapper_j604i_1",nn="_topBar_j604i_8",ln="_summaryGrid_j604i_19",rn="_summaryCard_j604i_26",on="_infoIcon_j604i_42",Be={wrapper:an,topBar:nn,summaryGrid:ln,summaryCard:rn,infoIcon:on},cn=(n,u)=>{if(!u)return n.toLocaleString();try{return new Intl.NumberFormat(void 0,{style:"currency",currency:u,maximumFractionDigits:2}).format(n)}catch{return`${u} ${n.toLocaleString()}`}},dn=n=>{var S,R;if(!n)return"â";const u=n.match(/^(\d+(?:\.\d+)?)(K|M)?$/i);if(!u)return n;let p=parseFloat(u[1]);return((S=u[2])==null?void 0:S.toUpperCase())==="K"&&(p*=1e3),((R=u[2])==null?void 0:R.toUpperCase())==="M"&&(p*=1e6),p.toLocaleString()},un=({userId:n})=>{var ee,q,Q;const{shopWabaDetails:u,shopSetting:p}=ft(xt(O=>
39({shopWabaDetails:O.shopWabaDetails,shopSetting:O.shopSetting}))),S=((ee=Xs.find(O=>O.value===String((p==null?void 0:p.attributionWindowMillis)??Js)))==null?void 0:ee.label)??"",[R,b]=a.useState({startDate:oe().subtract(29,"days").format("YYYY-MM-DD"),endDate:oe().format("YYYY-MM-DD")}),{fromMillis:J,toMillis:ce}=a.useMemo(()=>({fromMillis:oe(R.startDate).startOf("day").valueOf(),toMillis:oe(R.endDate).endOf("day").valueOf()}),[R.startDate,R.endDate]),$=bs({queryKey:["campaigns-revenue-summary",n,J,ce],queryFn:()=>ka(n,J,ce),enabled:!!n}),C=(q=$.data)==null?void 0:q.data,ie=(Q=C==null?void 0:C.sources)==null?void 0:Q.find(O=>O.key==="campaigns"),V=$.isLoading,T=$.isError,K=!V&&!T,y=parseFloat((ie==null?void 0:ie.revenue)??"0"),Y=(ie==null?void 0:ie.orders)??0;return e.jsxs("div",{className:Be.wrapper,children:[e.jsxs("div",{className:Be.topBar,children:[e.jsx(d,{as:"h2",variant:"headingMd",children:"Campaign Performance"}),e.jsx(Pa,{startDate:R.startDate,endDate:R.endDate,onChange:(O,ye)=>{b({startDate:oe(O).format("YYYY-MM-DD"),endDate:oe(ye).format("YYYY-MM-DD")})}})]}),e.jsxs("div",{className:Be.summaryGrid,children:[e.jsx("div",{className:Be.summaryCard,children:e.jsxs(xs,{sectioned:!0,children:[e.jsxs(F,{gap:"100",blockAlign:"center",children:[e.jsx(d,{as:"p",tone:"subdued",children:"Revenue"}),e.jsx(Rt,{content:"Revenue from orders attributed to your marketing campaigns during the selected period.",children:e.jsx("span",{className:Be.infoIcon,children:e.jsx(Ke,{source:at,tone:"subdued"})})})]}),T||V?e.jsx(d,{as:"h3",variant:"headingLg",children:"â"}):e.jsx(Es,{value:cn(y,C==null?void 0:C.currency),isEmpty:K&&y===0,emptyCaption:"No revenue in this period"}),S&&e.jsx(me,{paddingBlockStart:"200",children:e.jsxs(d,{as:"p",variant:"bodySm",tone:"subdued",children:["Revenue attribution window is ",S,"."," ",e.jsx(Xe,{url:"/settings#revenue-attribution",children:"Change"})]})})]})}),e.jsx("div",{className:Be.summaryCard,children:e.jsxs(xs,{sectioned:!0,children:[e.jsxs(F,{gap:"100",blockAlign:"center",children:[e.jsx(d,{as:"p",tone:"subdued",children:"Orders"}),e.jsx(Rt,{content:"Number of orders attributed to your marketing campaigns during the selected period.",children:e.jsx("span",{className:Be.infoIcon,children:e.jsx(Ke,{source:at,tone:"subdued"})})})]}),T||V?e.jsx(d,{as:"h3",variant:"headingLg",children:"â"}):e.jsx(Es,{value:Y.toLocaleString(),isEmpty:K&&Y===0,emptyCaption:"No orders in this period"})]})}),e.jsx("div",{className:Be.summaryCard,children:e.jsxs(xs,{sectioned:!0,children:[e.jsxs(F,{gap:"100",blockAlign:"center",children:[e.jsx(d,{as:"p",tone:"subdued",children:"Daily Message Limit"}),e.jsx(Rt,{content:"The maximum number of WhatsApp messages you can send in a rolling 24-hour window, as set by Meta based on your account's messaging tier. This limit is shared across all your automations and campaigns.",children:e.jsx("span",{className:Be.infoIcon,children:e.jsx(Ke,{source:at,tone:"subdued"})})})]}),e.jsx(d,{as:"h3",variant:"headingLg",children:dn(u==null?void 0:u.messagingLimit)})]})})]})]})},pn="/assets/balanceMeter-CL-nEfsr.svg",mn=({isOpen:n,setIsOpen:u,value:p,src:S})=>e.jsx("div",{children:n&&e.jsx("div",{id:"overlay",onClick:()=>u(!1),children:e.jsxs("div",{className:"overLayText",children:[e.jsx("div",{children:e.jsx("img",{width:100,height:100,style:{display:"block",margin:"auto"},src:S,alt:"test"})}),e.jsx("div",{style:{width:"350px"},children:e.jsx("p",{style:{fontSize:"16px"},children:p})})]})})}),hn=({title:n,titleId:u,...p},S)=>a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",width:"800px",height:"800px",viewBox:"0 0 24 24",ref:S,"aria-labelledby":u,...p},n?a.createElement("title",{id:u},n):null,a.createElement("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})),gn=a.forwardRef(hn),fn=n=>{var u,p,S,R;return e.jsx(Os,{title:"",children:e.jsx(N,{open:n.showModal,sectioned:!0,title:"",onClose:()=>{n.setShowModal(!1)},children:e.jsx(N.Section,{children:e.jsxs("div",{className:"basic-error-modal",children:[e.jsxs("div",{className:"errorMod
39alHeading",children:[e.jsx(gn,{style:{color:"var(--sl-primary)"},"aria-hidden":"true"}),"Oops! Action Not Allowed"]}),((u=n==null?void 0:n.errorDetails)==null?void 0:u.limit)<=0?e.jsxs("div",{className:"errorModalContent",children:[e.jsx("p",{children:qs}),e.jsx("br",{}),e.jsxs("p",{children:[e.jsx(Xe,{url:Ms,external:!0,children:"Learn more"})," ","about how to increase your messaging limit."]}),e.jsx("br",{})]}):e.jsxs("div",{className:"errorModalContent",children:[e.jsxs("p",{children:[Qs.replace("{SIZE}",(p=n==null?void 0:n.errorDetails)==null?void 0:p.size).replace("{TIER}",(S=n==null?void 0:n.errorDetails)==null?void 0:S.tier).replace("{LIMIT}",(R=n==null?void 0:n.errorDetails)==null?void 0:R.limit)," "]}),e.jsx("br",{}),e.jsxs("p",{children:[e.jsx(Xe,{url:Ms,external:!0,children:"Learn more"})," ","about how to increase your messaging limit."]}),e.jsx("br",{}),e.jsx("p",{children:"Please go back & choose a different set of customers to continue with campaign."}),e.jsx("br",{})]}),e.jsx("div",{className:"errorModalFooter",children:e.jsx("button",{className:"errorModalButtonCss",type:"button",onClick:()=>{n.setShowModal(!1)},children:"Close"})})]})})})})},xn="data:image/svg+xml,%3csvg%20width='49'%20height='49'%20viewBox='0%200%2049%2049'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3crect%20width='49'%20height='49'%20fill='url(%23pattern0)'/%3e%3cdefs%3e%3cpattern%20id='pattern0'%20patternContentUnits='objectBoundingBox'%20width='1'%20height='1'%3e%3cuse%20xlink:href='%23image0_25_44'%20transform='scale(0.01)'/%3e%3c/pattern%3e%3cimage%20id='image0_25_44'%20width='100'%20height='100'%20xlink:href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAACXBIWXMAAAsTAAALEwEAmpwYAAAGyElEQVR4nO2dS4wVRRSGi+hCNyq+38T3W+IL344axOGe04OoGI0xUWPcEZjpqnuHFVGiLsSNUfe4xo2PRFkb34qijqCIgyjIQwSZufdUA7Y5fe88GOYy0/fe6qruqT85G4ak69TXp6a7+tQ/Qnh5eXl5eXl5eXklWhIvOU5F2CU1rFKEa6TGD5WGtUrDG2WNz6w4EJxV/59eRtUbLzlREpQl4S6lMW4WkuCw1PBeRcNcj8SQyhHMkxq2HgvE5GBwNVeUB9NJGASPKoJqGhhHgNGwbmncfZKH0iEYkvBgqzBGg/Cr3njBqR5KG5KEj3QExtgS9nV//NBpHkpLMGCxIow6BWOsUuAbDyWlQsKFipA6DmNs+VrfF+PpvlKmUxm1UrdRGKO/6HFg+dCD53gox4SBCyRhzTSMsYCf1HDPuR7KpDBgfrYwRioFNnooE6QiuFsRDmUNY1xs6h2G83ylcGVEwZ2S4IBFGHGjUn4La8FFMxpKOSrdIQn+tQ1DjcVgfw0uFjNRMsLbHYMRNyplq6x1XyJmkpTGGyXhXtuTr5oG/N5fCy4VM0F9uucGRfi3/UnHqWJHSD1XiyKLv09Igj0OTHY8zeXrr7IOrhFFlNTB9Ypgt+1JVumXr52hhmtFkdRHeCUvAfYnF1uGUtELrxNFkKKeK5TG7fYnFduK5CEkWnizKAAMY5UhCQ9KjS/zcpgsiRpe6eT3k6OvB3v4oUTkUYrgMqnhT6N3LmHvxOtKQmn2mvBPGJVuFXlSWC3N4bdew0vIwZVx1wkTr83/ZuTD1pHX3leOgttEHsT7QWm7Q1qMwWZjMH0zNKpzP+82CJfVV110gdT4a1abgaKJ+GdZjCHZoa6V7hMuqjzcfb7SuDmTidCOAKn/oh8Oa8H9wiVx62by9S2jSVAOARmBwh/YhEMwfsxyApRjQJIgqJZrwQPCpsIDi8+UBD9knrx2EEgCBSkkDIQNrYi7z1CE31tJXDsKpL58aUnBokxh9Mcwm7sAbSWtHAYyBgUWZwJjWbzoFEnwpc2EleNAkiCMylR62CiMSjz/ZEXwhfVkdQ6AJFDgkNLwpDEYkvBz60nqHAEZhYJPdRQGn62QBJ9aT07nEEgDCh+r6AiMlXHX8XzgxXpSOsdA6lCqYYS3tA1EaXjNejK6AEDqMTjZDvW0lXz4ITjsQCJxQYDwI3G5DSD4ge0EVMGA8Pf5lg6h8tkJRfif/QSwYEAwDqPSPamBKA3P2h64KigQpfHF9EAI33Jg4HEhgRCuSQ8ksapwYPC6gEA0fJQaSN0/xPbAsahA1qYGwmVlf+BYSCCS4M3UQBKnHQcGr4oIRAdPpwbC9ke2B64KCIRftFuyj+KXl6lskDwQbGEO4N3UMEbvNIKyu3ca7hWxmHXUoGMxi9s9Xa2Otjy8krbMLLoAW4xyBPMmjplbPG2Pq3nAq6Jd8ZZxO15VRu84jQPc1D0y1j5aeHnW/WHTHyus65iRWsNA7JALiamJwb4oBB/Xw7xHSkswCD7tuIFaqIPHTJ69KGwQ20HBbGFC9Uox2+qvihSE64272CkK0NWlQTkUkvDbzIzSFEHJhnOPyklIwg2ZG6Sx0ZiHgkfD0LBRDpXOzhSGW1BgiyR4OwnbLaQaB6y7anMLvo33FMkmyQTLxz/bN7Z7+iw1ZmxyxjKQTxBlbUAmNaxqNh6p8aWMx/KLcwZoiTl+VkZkhBE3fTcbCz/3Z/V4zmcq+WylcFGVCO/KyANr81RjyeLwaeJCVy3NES6LjwrzkWGzFQK7J93pHVEsZpl2HeKj37mxBGSnA+Nb4BF2Nbs+H1U2CwO35c51jo1aTLrGSY0Dk70J8wuZyR3fxC5k3A5zrsRGLYaXjkGl8Tm24+NQETzP9nwGr7eDDXVEnlWm0lX59srCemUQ7iqMu1zDwGx7nmFUimJgNiIudeN2TdqUHRPcJIqo+idW/CNPMFTeXeSmZ2yG23KwTO2brImikKobnMEWdysD9+fONa5dVap4YVbeWiodjKGWDtQUBUqWHltqWt5XcK+YyWq40P3sAgzlqjtc1uJPnjY8t9ToMgVV51zhnDBCo+ztnti5h5s2bOfvpMLEEA03ZAsjQNt5O60ViTEafJdRZfTYzjcX6k8+wRq0gSKMMnd9y7uWJUZpBuygCA6FGh63nV8uVUkM0/CzTsJQOnjCdl65VqXuYveJ0+5uM01L2UCtDc8ufunrmIGY17iuRI2r03YlJu2lRd9Ct6mKhrlK4/tTg4Gd/LdE2jIM80ptcc6ORa9Lje8kViCEa6SGF/hv63bsPJ+Xl5eXl5eXl5fIv/4HjD2zGQp7iYkAAAAASUVORK5CYII='/%3e%3c/defs%3e%3c/svg%3e",jn=n=>{var p;const u=jt();return e.jsx(Os,{children:e.jsx(N,{open:n.showModal,sectioned:!0,title:"",onClose:()=>{n.setShowModal(!1)},size:"small",children:e.jsx(N.Section,{children:e.jsxs("div",{className:"basic-insufficientBal-modal",children:[e.jsxs("div",{className:"insufficientBalModalHeading",children:[e.jsx("img",{src:xn,alt:"ErrorIcon"}),"Insufficient Balance"]}),e.jsxs("div",{className:"insufficientBalModalContent",children:[!(n!=null&&n.errorDetails)||(n==null?void 0:n.walletBalance)===0?e.jsxs("div",{children:[e.jsx("p",{children:"You do not have enough wallet balance."}),e.jsx("p",{children:"Please recharge."})]}):e.jsx("p",{children:`You are trying to send WhatsApp Campaign to ${(p=n==null?void 0:n.errorDetails)==null?void 0:p.size} customers. 40 However, you do not have enough wallet balance to trigger the 41 campaign.`}),e.jsx("br",{}),e.jsxs("p",{children:["Please note that charge per message ="," ",e.jsx(Xe,{url:"https://docs.google.com/spreadsheets/d/14Wc_J09VwCZ3LaIzVfsCs5bySHTVSITk2sk0JsEjzAE",external:!0,children:"WhatsApp cost"})," ","+ $ 0.004"]}),e.jsx("br",{}),e.jsx("br",{})]}),e.jsx("div",{className:"insufficientBalModalFooter",children:e.jsx("button",{className:"insufficientBalModalButtonCss",type:"button",onClick:()=>{n.setShowModal(!1),u.push({pathname:"/wallet",state:{page:1}})},children:"Recharge Wallet"})})]})})})})},Ls=/^[+-]?\d+\.?\d*[Ee][+-]?\d+$/,Sn=n=>{var It,Pt,Dt,t,h;const{shopDetailsData:u,agentPhone:p}=ft(xt(s=>({shopDetailsData:s.shopDetailsData,agentPhone:s.agentPhone}))),{setSelectedTemplateForPreview:S}=n,R=(It=n.currentSelectedTemplateId)==null?void 0:It.templateId,b=jt(),J=_s(),ce=[gt.TYPE[2].value,gt.TYPE[3].value,gt.TYPE[4].value],[$,C]=a.useState(!1),[ie,V]=a.useState(!1),[T,K]=a.useState({id:"",url:"",userId:"",platform:""}),[y,Y]=a.useState({name:"",body:"",file:"",recipientType:"file",consent:"false"}),[ee,q]=a.useState({show:!1,message:""}),[Q,O]=a.useState({show:!1,message:""}),[ye,Ee]=a.useState(!1),[te,de]=a.useState(!1),[j,E]=a.useState(!1),[w,I]=a.use
41State(R||""),[X,P]=a.useState([]),[o,B]=a.useState({}),[he,le]=a.useState(!1),[se,ae]=a.useState(!1),[ge,ve]=a.useState(),[H,re]=a.useState(),[Je,We]=a.useState(!1),[Z,U]=a.useState(!1),[Ge,qe]=a.useState({}),[nt,Qe]=a.useState(!1),[we,Ce]=a.useState(""),[Se,Ie]=a.useState(""),[Te,it]=a.useState(null),[St,xe]=a.useState(null),[Pe,L]=a.useState(null),[A,fe]=a.useState([]),[Re,Ze]=a.useState(!1),[bt,M]=a.useState(null),[_t,ls]=a.useState(!1),[rs,Ft]=a.useState(Zs.TEMPLATE_CATEGORY),[$e,He]=a.useState(!1),[Ot,lt]=a.useState(!1),[Le,Bt]=a.useState({date:new Date().toISOString().split("T")[0],time:new Date().getHours()+":"+new Date().getMinutes()}),[os,Cs]=a.useState(!1),[_e,De]=a.useState(!1),[Ut,Ve]=a.useState(!1),[Wt,rt]=a.useState(!1),[yt,Gt]=a.useState(""),[ot,et]=a.useState({}),[vt,ke]=a.useState([]),[ct,Ht]=a.useState(!1),[wt,tt]=a.useState([]),[z,Fe]=a.useState({phoneSource:"",variableMappings:{},fallbackMappings:{}}),[ue,cs]=a.useState("file"),[_,ds]=a.useState(null),[Vt,Ct]=a.useState(!1);let dt=JSON.parse(localStorage.getItem("walletRenewalStatus")||"{}");a.useEffect(()=>{let s=u||{};if(s&&s.id){K({...s,id:s.id,url:s.url,platform:s.platform}),is(s.userId).then(c=>{var f,m;((f=c==null?void 0:c.templates)==null?void 0:f.filter(x=>x.status==="APPROVED").length)>0&&P((m=c==null?void 0:c.templates)==null?void 0:m.filter(x=>x.status==="APPROVED"))});const i=new URLSearchParams(J.search),r=i.get("shop"),l=i.get("segmentId");r&&l&&(cs("shopify"),At(s.userId,r,l))}},[]),a.useEffect(()=>{T!=null&&T.id&&Oe(!1)},[T]),a.useEffect(()=>{w&&w!==""&&X.length>0&&zt(w)},[w,X]);const Ne=s=>{typeof s!="string"&&(s="Something went wrong"),O({show:!0,message:s})},Yt=()=>{if([je.WIX,je.NONE].includes(T.platform)&&dt.balance<=.09){U(!0);return}ae(!0);let s=ut();if(s){ae(!1),Ne(s);return}const i=l=>{l.status==="success"?(Ae("campaign_created",{template_name:o.name,template_type:o.type,has_media:!!Se,recipient_source:ue}),le(!0),ae(!1),setTimeout(()=>{Mt()},1e3)):(ae(!1),Ne(l))},r=l=>{var c,f,m,x,g,v,W,D;if(ae(!1),(f=(c=l==null?void 0:l.response)==null?void 0:c.data)!=null&&f.limit_issue)qe((x=(m=l==null?void 0:l.response)==null?void 0:m.data)==null?void 0:x.limit_issue),U(!0);else{let G=(v=(g=l==null?void 0:l.response)==null?void 0:g.data)!=null&&v.errors&&((D=(W=l==null?void 0:l.response)==null?void 0:W.data)!=null&&D.errors[0])?l.response.data.errors[0]:As;Ne(G)}};if(ue==="shopify"){const l=new URLSearchParams(J.search),c={shop:l.get("shop"),segmentId:l.get("segmentId"),templateId:w,name:y.name,media:Se||"",phoneSource:z.phoneSource,variableMappings:z.variableMappings,fallbackMappings:z.fallbackMappings};Ca(T.userId,c).then(i,r)}else{let l=new FormData;l.append("name",y.name),l.append("templateId",w),l.append("file",ge),l.append("consent",y.consent),l.append("media",Se),l.append("phoneSource",z.phoneSource),Object.keys(z.variableMappings).length>0&&l.append("variableMappings",JSON.stringify(z.variableMappings)),Object.keys(z.fallbackMappings).length>0&&l.append("fallbackMappings",JSON.stringify(z.fallbackMappings)),Ta(T.userId,l).then(i,r)}},Tt=s=>{let i=s.date+" "+s.time,r=Date.parse(i);if([je.WIX,je.NONE].includes(T.platform)&&dt.balance<=.09){U(!0);return}ae(!0);let l=ut();if(l){ae(!1),Ne(l);return}const c=m=>{m.status==="success"?(Ae("campaign_scheduled",{template_name:o.name,template_type:o.type,has_media:!!Se,recipient_source:ue,scheduled_at:r}),le(!0),ae(!1),setTimeout(()=>{Mt()},1e3)):(ae(!1),Ne(m))},f=m=>{var x,g,v,W,D,G,Me,Zt;if(ae(!1),(g=(x=m==null?void 0:m.response)==null?void 0:x.data)!=null&&g.limit_issue)qe((W=(v=m==null?void 0:m.response)==null?void 0:v.data)==null?void 0:W.limit_issue),U(!0);else{let gs=(G=(D=m==null?void 0:m.response)==null?void 0:D.data)!=null&&G.errors&&((Zt=(Me=m==null?void 0:m.response)==null?void 0:Me.data)!=null&&Zt.errors[0])?m.response.data.errors[0]:As;Ne(gs)}};if(ue==="shopify"){const m=new URLSearchParams(J.search),x={shop:m.get("shop"),segmentId:m.get("segmentId"),templateId:w,name:y.name,media:Se||"",scheduleTime:r,phoneSource:z.phoneSource,variableMappings:z.variableMappings,fallbackMappings:z.fallbackMappings};Ma(T.userId,x).then(c,f)}else{let m=new FormData;m.append("name",y.name),m.append("templateId",w),m.append("scheduleTime",r.toString()),m.append("file",ge),m.append("consent",y.consent),m.append("media",Se),m.append("phoneSource",z.phoneSource),Object.keys(z.variableMappings).length>0&&m.append("variableMappings",JSON.stringify(z.variableMappings)
41),Object.keys(z.fallbackMappings).length>0&&m.append("fallbackMappings",JSON.stringify(z.fallbackMappings)),Aa(T.userId,m).then(c,f)}},us=(s,i)=>(!$&&i==="name"&&C(!0),Y(r=>({...r,[i]:s}))),ut=()=>{if(y.name){if(pt()!==!1)return"Campaign name should be less than 50 characters";if(ue==="file"&&!ge)return"Receipients file is not found";if(ue==="shopify"&&!_)return"Shopify segment could not be loaded";if(w){if(ce.includes(o.type)&&!Se)return"Please select a media file for campaign";if(z.phoneSource){if(y.consent!=="true")return la}else return"Please map the Phone Number column before sending"}else return"Please select a template to proceed"}else return"Campaign name can not be empty";return!1},ps=(s,i)=>{var m;const r=[];let l="";const c=/{{(.*?)}}/g;for(;l=c.exec(s);)r.push(l[1]);let f=r.filter(x=>!Oa.includes(x)||Fa.includes(x));return f.length>0?We(!0):We(!1),r.length===1&&f.length&&f.length===1&&f[0]==="1"&&((m=i==null?void 0:i.buttons[0])==null?void 0:m.urlType)==="STATIC"&&(r.length=0,f.length=0),f.length>0?We(!0):We(!1),r},zt=s=>{var i=X.find(r=>r.id===s);if(i&&i.internalText&&(i.variables=ps(i.internalText,i)),B(i),S&&S(i),Ie(""),Ce(""),n.setMediaUrlForPreview&&n.setMediaUrlForPreview(void 0),Fe(r=>({...r,variableMappings:{},fallbackMappings:{}})),et({}),ue==="shopify"){const r=new URLSearchParams(J.search),l=r.get("shop"),c=r.get("segmentId");l&&c&&At(T.userId,l,c,s)}},pt=()=>{if($){let s=y;if(s.name&&s.name.trim()){if(s.name.length>50)return"Campaign name should be less than 50 characters";if(s.name.length<=0)return"Campaign name cannot be empty"}else return"Campaign name cannot be empty"}return!1},ms=ee.show?e.jsx(Lt,{content:ee.message,onDismiss:()=>{q({show:!1,message:""})}}):null,hs=Q.show?e.jsx(Lt,{error:!0,content:Q.message,onDismiss:()=>{O({show:!1,message:""})}}):null,Oe=s=>{He(!0),X.length?(E(s),He(!1)):is(T.userId).then(i=>{var r,l;((r=i==null?void 0:i.templates)==null?void 0:r.filter(c=>c.status==="APPROVED").length)>0?(P((l=i==null?void 0:i.templates)==null?void 0:l.filter(c=>c.status==="APPROVED")),E(s),He(!1)):(Ne("You don't have any approved templates"),He(!1))})};a.useEffect(()=>{console.log("Template Id: ",w)},[w]);const Ts=s=>{Y({...y,consent:s==="true"?"false":"true"})},Mt=()=>{n.updateCampaignsListViewFlag(),n.setCurrentSelectedTemplateId(""),b.push({pathname:"/campaigns"})},mt=s=>{var r;let i=s.target.files.length?na(o.type,s.target.files[0].type,s.target.files[0].size):{error:!0,message:es.file_size_error};if(((r=s.target)==null?void 0:r.files.length)<1||i!=null&&i.error)O({show:!0,message:i.message});else{let l=new FormData;l.append("file",s.target.files[0]),l.append("fileType",s.target.files[0].type),Qe(!0),wa(T.userId,l).then(c=>{c!=null&&c.message&&Ie(c==null?void 0:c.message),Ce(s.target.files[0].name),Qe(!1)}).catch(c=>{console.log(c),Ce(""),Ie(""),Qe(!1)})}},ht=()=>{Ie(""),Ce(""),n.setMediaUrlForPreview&&n.setMediaUrlForPreview(void 0)},Kt=async s=>{try{if(s.name.endsWith(".csv")){const i=new FileReader;i.onload=r=>{var f;const c=((f=r.target)==null?void 0:f.result).split(` 42`).filter(m=>m.trim()).map(m=>m.split(",").map(x=>x.trim().replace(/^"|"$/g,"")));Ze(c.slice(1).some(m=>m.some(x=>Ls.test(x)))),M(Math.max(0,c.length-1)),tt(c[0]||[]),fe(c.slice(0,4))},i.readAsText(s)}else if(s.name.endsWith(".xlsx")||s.name.endsWith(".xls")){const{default:i}=await ia(async()=>{const{default:c}=await import("./exceljs.min-C4dcVw1k.js").then(f=>f.e);return{default:c}},__vite__mapDeps([0,1,2])),r=new i.Workbook,l=new FileReader;l.onload=async c=>{var W;const f=(W=c.target)==null?void 0:W.result;await r.xlsx.load(f);const m=r.worksheets[0],x=[];let g=0;m&&m.eachRow({includeEmpty:!1},(D,G)=>{if(g=G,G<=4){const Me=[];D.eachCell({includeEmpty:!1},(Zt,gs)=>{for(;Me.length<gs-1;)Me.push("");Me.push(Zt.text??"")}),x.push(Me)}}),M(Math.max(0,g-1)),tt(x[0]||[]),fe(x);const v=x.slice(1).some(D=>D.some(G=>Ls.test(G)));Ze(v)},l.readAsArrayBuffer(s)}}catch(i){console.error("Error parsing file preview:",i)}},At=(s,i,r,l)=>{Ct(!0),va(s,i,r,l).then(c=>{Ct(!1),(c==null?void 0:c.status)==="success"&&c.segment&&(ds(c.segment),c.segment.recommendedMappings&&Fe(f=>({phoneSource:c.segment.recommendedMappings.phoneSource||f.phoneSource,variableMappings:c.segment.recommendedMappings.variableMappings||{},fallbackMappings:c.segment.recommendedMappings.fallbackMappings||{}})))},()=>{Ct(!1)})},Xt=()=>{var r;if(!((r=o==null?void 0:o.variables)!=null&&r.length))return[];const s=[];let i=!1;
42return o.variables.forEach(l=>{var c,f;l==="1"?((f=(c=o==null?void 0:o.buttons)==null?void 0:c[0])==null?void 0:f.urlType)==="DYNAMIC"&&(i=!0):s.push({key:l,label:`{{${l}}}`})}),i&&s.push({key:"buttonUrlSuffix",label:"Button URL Suffix"}),s},Et=()=>ue==="shopify"?((_==null?void 0:_.availableFields)||[]).map(s=>({label:s.label||s.key,value:s.key})):wt.map(s=>({label:s,value:s})),Jt=()=>{if(!(o!=null&&o.internalText))return"";let s=o.internalText;return(o.variables||[]).forEach(i=>{const r=ot[i];s=s.replace(new RegExp(`\\{\\{${i}\\}\\}`,"g"),r||`{{${i}}}`)}),s},qt=async()=>{var r,l,c,f,m,x;const s=yt.split(",").map(g=>g.trim()).filter(Boolean);if(!s.length)return;const i=(o.variables||[]).map(g=>ot[g]||"");Ht(!0),ke(s.map(g=>({phone:g,status:"pending"})));for(let g=0;g<s.length;g++)try{const v=await Fs(p,T.userId,{templateId:o.templateId,internalText:o.internalText,to:s[g],params:i,media:Se||"",type:o.type});if(v!=null&&v.error){const W=((l=(r=v.error)==null?void 0:r.errors)==null?void 0:l[0])||((c=v.error)==null?void 0:c.message)||"Failed to send";ke(D=>D.map((G,Me)=>Me===g?{...G,status:"error",error:W}:G))}else ke(W=>W.map((D,G)=>G===g?{...D,status:"success"}:D))}catch(v){const W=((x=(m=(f=v==null?void 0:v.response)==null?void 0:f.data)==null?void 0:m.errors)==null?void 0:x[0])||(v==null?void 0:v.message)||"Failed to send";ke(D=>D.map((G,Me)=>Me===g?{...G,status:"error",error:W}:G))}Ht(!1)},Qt=!!w&&(ue==="file"&&wt.length>0||ue==="shopify"&&!!_&&!_.reauthRequired&&!(((Pt=_.missingScopes)==null?void 0:Pt.length)>0));return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{background:"var(--p-color-bg-surface)",padding:"20px",borderRadius:"8px",boxShadow:"var(--p-shadow-200)"},children:e.jsx("div",{className:"createCampaignButtons",children:e.jsxs(k,{gap:"800",children:[e.jsx(Ye,{autoComplete:"off",label:e.jsx(d,{as:"span",fontWeight:"bold",children:"Campaign Name"}),placeholder:"Enter Campaign Name",value:y.name,onChange:s=>us(s,"name"),error:pt()}),e.jsxs(k,{gap:"100",children:[e.jsx(d,{as:"p",fontWeight:"bold",children:"Message"}),o!=null&&o.id?e.jsx("div",{onClick:()=>{Oe(!0)},children:e.jsxs(k,{gap:"200",children:[e.jsx(Ye,{className:"sl-readonly-field",autoComplete:"off",label:"",value:o.name,onChange:()=>{},readOnly:!0,disabled:$e,placeholder:"Template name",suffix:e.jsx(Xe,{onClick:s=>{s.stopPropagation(),Oe(!0)},children:"Change Template"})}),e.jsx(Ye,{className:"sl-readonly-field",autoComplete:"off",label:"",value:o.buttons.length?o.internalText.replace("https://i.gs.im/{{1}}",(Dt=o==null?void 0:o.buttons[0])==null?void 0:Dt.value):o.internalText,onChange:()=>{},readOnly:!0,disabled:$e,multiline:4,placeholder:"Message"})]})}):e.jsxs(F,{gap:"300",blockAlign:"center",children:[e.jsx(ne,{variant:"secondary",onClick:()=>{Oe(!0)},disabled:$e,children:"Select Template"}),$e&&e.jsxs(F,{gap:"100",blockAlign:"center",children:[e.jsx(Ue,{size:"small"}),e.jsx(d,{variant:"bodySm",tone:"subdued",children:"Fetching templates..."})]})]})]}),ce.includes(o.type)?e.jsxs(k,{gap:"100",children:[e.jsx(d,{as:"p",fontWeight:"bold",children:$s.label}),e.jsx("div",{className:"uploadMediaFile",children:e.jsxs(ss,{allowMultiple:!1,dropOnPage:!0,onDrop:(s,i,r)=>{i.length>0&&(it(i[0]),n.setMediaUrlForPreview&&n.setMediaUrlForPreview(URL.createObjectURL(i[0])),mt({target:{files:i}}))},accept:"image/png, image/jpeg, image/jpg, video/mp4, application/pdf",children:[!we&&e.jsx(ss.FileUpload,{}),we&&e.jsx("div",{style:{padding:"16px"},children:e.jsxs(pe,{alignment:"center",children:[e.jsx(Ds,{size:"small",alt:we,source:Te&&["image/gif","image/jpeg","image/png"].includes(Te.type)?window.URL.createObjectURL(Te):ks}),e.jsxs("div",{children:[e.jsx(d,{fontWeight:"bold",as:"span",children:we}),Te&&e.jsxs(d,{variant:"bodySm",as:"p",tone:"subdued",children:[(Te.size/1024).toFixed(2)," KB"]})]}),e.jsx(ne,{onClick:s=>{s.stopPropagation(),ht(),it(null)},icon:ea,variant:"plain"})]})})]})}),e.jsxs("div",{className:"fileTypeNote",children:[o.type===gt.TYPE[2].value&&e.jsx("span",{children:es.imageFileLimit}),o.type===gt.TYPE[3].value&&e.jsx("span",{children:es.videoFileLimit}),o.type===gt.TYPE[4].value&&e.jsx("span",{children:es.documentFileLimit})]})]}):null,e.jsxs(k,{gap:"200",children:[e.jsx(d,{as:"p",fontWeight:"bold",children:"Recipients"}),e.jsx("div",{style:{display:"none"},children:e.jsx(pe,{children:e.jsx(Ba,{label:"From file",id:"From file",name:"",checked:!0,onChange:()=>{}})})}),ue==="shopify"?e.jsx("div",{style:{border:"2px dashed #c9cccf",borderRadius:"8px",padding:"16px"},children:Vt?e.jsxs(F,{gap:"200",blockAlign:"center",children:[e.jsx(Ue,{size:"small"}),e.jsx(d,{tone:"subdued",children:"Loading Shopify segment..."})]}):_!=null&&_.reauthRequired?e.jsxs(k,{gap:"200",children:[e.jsxs(d,{tone:"critical",children:["Shopify reconnection required",_.reauthReason?`: ${_.reauthReason}`:"."]}),_.reauthUrl&&e.jsx(ne,{url:_.reauthUrl,external:!0,variant:"plain",children:"Reconnect Shopify"})]}):((t=_==null?void 0:_.missingScopes)==null?void 0:t.length)>
420?e.jsx(d,{tone:"critical",children:"Missing Shopify permissions. Please reinstall the Superlemon app."}):_?e.jsxs(k,{gap:"100",children:[e.jsx(d,{fontWeight:"bold",children:_.segmentName}),e.jsxs(d,{variant:"bodySm",tone:"subdued",children:["~",_.estimatedCount??_.currentCount," customers"]})]}):e.jsx(d,{tone:"critical",children:"Could not load Shopify segment."})}):e.jsxs("div",{children:[ge?e.jsx("div",{style:{border:"2px dashed #c9cccf",borderRadius:"8px",padding:"12px",overflow:"hidden"},children:e.jsxs(k,{gap:"300",children:[e.jsxs(F,{align:"space-between",blockAlign:"center",children:[e.jsxs(F,{gap:"200",blockAlign:"center",children:[e.jsx(Ds,{size:"small",alt:ge.name,source:ks}),e.jsx(d,{fontWeight:"bold",as:"span",children:ge.name})]}),e.jsx(ne,{variant:"plain",onClick:s=>{s.stopPropagation(),ve(null),xe(null),fe([]),tt([]),M(null),Ze(!1),Fe({phoneSource:"",variableMappings:{},fallbackMappings:{}})},children:"Change file"})]}),Re&&e.jsxs(Ua,{tone:"warning",children:["Your file has phone numbers in scientific notation (e.g. 9.18765E+11). The original digits are lost and cannot be recovered. Please open the file in Excel, format the phone number column as ",e.jsx("strong",{children:"Text"}),", and re-upload."]}),A.length>0?e.jsxs("div",{style:{border:"1px solid #e1e3e5",borderRadius:"8px",overflowX:"auto",backgroundColor:"#fff"},children:[e.jsx(Bs,{columnContentTypes:new Array(A[0].length).fill("text"),headings:A[0],rows:A.slice(1,4),increasedTableDensity:!0}),e.jsx(me,{padding:"200",background:"bg-surface-secondary-active",children:e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(d,{variant:"bodySm",tone:"subdued",children:"Showing first 3 rows from your sheet."})})})]}):e.jsx(me,{padding:"300",background:"bg-surface-secondary-active",borderRadius:"200",children:e.jsx(d,{variant:"bodySm",tone:"subdued",children:"Preview not available. Upload an MS Excel (.xlsx) or CSV file for a live preview."})})]})}):e.jsx(ss,{allowMultiple:!1,onDrop:(s,i,r)=>{i.length>0&&(xe(i[0]),ve(i[0]),Kt(i[0]))},children:e.jsx(ss.FileUpload,{})}),e.jsx(me,{paddingBlockStart:"200",paddingInlineStart:"300",children:e.jsx(d,{variant:"bodySm",tone:"subdued",children:"Upload any CSV or Excel file with a header row â you'll map the columns below."})})]}),Qt&&e.jsx(me,{paddingBlockStart:"600",children:e.jsxs(k,{gap:"300",children:[e.jsx(d,{as:"p",fontWeight:"semibold",children:"Map your columns"}),e.jsxs(d,{variant:"bodySm",tone:"subdued",children:["Match each required field to a column in your ",ue==="shopify"?"Shopify segment":"file","."]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"180px 1fr 1fr",gap:"12px",alignItems:"center"},children:[e.jsx(d,{variant:"bodySm",fontWeight:"semibold",tone:"subdued",children:"Field"}),e.jsx(d,{variant:"bodySm",fontWeight:"semibold",tone:"subdued",children:"Column"}),e.jsx(d,{variant:"bodySm",fontWeight:"semibold",tone:"subdued",children:"Fallback"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"180px 1fr 1fr",gap:"12px",alignItems:"center"},children:[e.jsxs(d,{as:"span",children:["Phone Number ",e.jsx("span",{style:{color:"var(--p-color-text-critical)"},children:"*"})]}),e.jsx(Nt,{label:"",labelHidden:!0,options:[{label:"Select column",value:""},...Et()],value:z.phoneSource,onChange:s=>Fe(i=>({...i,phoneSource:s}))}),e.jsx("div",{})]}),Xt().map(({key:s,label:i})=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"180px 1fr 1fr",gap:"12px",alignItems:"center"},children:[e.jsx(d,{as:"span",children:i}),e.jsx(Nt,{label:"",labelHidden:!0,options:[{label:"Select column",value:""},...Et()],value:z.variableMappings[s]||"",onChange:r=>Fe(l=>({...l,variableMappings:{...l.variableMappings,[s]:r}}))}),e.jsx(Ye,{label:"",labelHidden:!0,placeholder:"Fallback (optional)",autoComplete:"off",value:z.fallbackMappings[s]||"",onChange:r=>Fe(l=>{const c={...l.fallbackMappings};return r?c[s]=r:delete c[s],{...l,fallbackMappings:c}})})]},s))]})}),e.jsx(me,{paddingBlockStart:"800",children:e.jsx(F,{gap:"200",blockAlign:"center",wrap:!1,children:e.jsx(Wa,{label:e.jsxs(F,{gap:"100",blockAlign:"center",wrap:!1,children:[e.jsx(d,{as:"span",children:"I confirm that I have collected customer permission to send them campaigns."}),e.jsx(Xe,{url:ta,external:!0,children:e.jsxs(F,{gap:"100",blockAlign:"center",children:[e.jsx(d,{variant:"bodySm",children:"Learn More"}),e.jsx(Ke,{source:Ga,tone:"base"})]})})]}
42),checked:y.consent==="true",onChange:s=>Ts(y.consent)})})})]}),e.jsx(me,{paddingBlockStart:"400",children:e.jsxs(F,{align:"space-between",children:[e.jsx(ne,{variant:"plain",onClick:()=>n.setShowDiscardModal(!0),children:"Cancel"}),e.jsxs(F,{gap:"300",children:[e.jsx(ne,{disabled:!w,onClick:()=>{ke([]),De(!0)},children:"Test"}),e.jsxs(sa,{variant:"segmented",children:[e.jsx(ne,{variant:"primary",loading:se,disabled:!!ut(),onClick:()=>Ve(!0),children:"Send Now"}),e.jsx(st,{active:Wt,preferredAlignment:"right",activator:e.jsx(ne,{variant:"primary",onClick:()=>rt(s=>!s),icon:aa,accessibilityLabel:"More send options",disabled:!!ut()}),autofocusTarget:"first-node",onClose:()=>rt(!1),children:e.jsx(vs,{actionRole:"menuitem",items:[{content:"Schedule for later",icon:Us,onAction:()=>{rt(!1),lt(!0)}}]})})]})]})]})})]})})}),e.jsx(N,{open:Ut,onClose:()=>Ve(!1),title:"Send campaign now?",primaryAction:{content:"Send Now",onAction:()=>{Ve(!1),Yt()},loading:se,destructive:!1},secondaryActions:[{content:"Cancel",onAction:()=>Ve(!1)}],children:e.jsx(N.Section,{children:e.jsxs(k,{gap:"200",children:[e.jsxs(d,{as:"p",children:["You're about to send ",e.jsx(d,{as:"span",fontWeight:"bold",children:y.name})," to"," ",ue==="shopify"&&_?e.jsxs(d,{as:"span",fontWeight:"bold",children:[_.estimatedCount??_.currentCount," recipients"]}):bt!==null?e.jsxs(d,{as:"span",fontWeight:"bold",children:[bt," recipients"]}):"all recipients"," in your list."]}),e.jsx(d,{as:"p",tone:"subdued",children:"This action cannot be undone. Messages will be sent immediately."})]})})}),e.jsx(N,{open:_e,sectioned:!0,title:"Test Campaign",onClose:()=>{De(!1),Gt(""),et({}),ke([])},children:e.jsx(N.Section,{children:e.jsxs(k,{gap:"400",children:[e.jsxs(d,{tone:"subdued",variant:"bodySm",as:"p",children:["Please send a message (e.g. Hi) to your Business API number (",p,") to increase the chances of receiving the test campaign."]}),e.jsx(Ye,{label:"Phone numbers",helpText:"Comma-separated, include country code (e.g. 919876543210, 15551234567)",autoComplete:"off",value:yt,onChange:Gt,placeholder:"919876543210, 15551234567"}),e.jsxs(k,{gap:"100",children:[e.jsx(d,{as:"p",fontWeight:"semibold",children:"Preview"}),e.jsx(me,{background:"bg-surface-secondary-active",padding:"300",borderRadius:"200",children:e.jsx(d,{as:"p",variant:"bodySm",children:Jt()})})]}),((h=o==null?void 0:o.variables)==null?void 0:h.length)>0&&e.jsxs(k,{gap:"200",children:[e.jsx(d,{as:"p",fontWeight:"semibold",children:"Variables"}),o.variables.map(s=>e.jsx(Ye,{label:`{{${s}}}`,autoComplete:"off",value:ot[s]||"",onChange:i=>et(r=>({...r,[s]:i}))},s))]}),vt.length>0&&e.jsx(k,{gap:"100",children:vt.map((s,i)=>e.jsxs(F,{gap:"200",blockAlign:"center",children:[e.jsx(d,{variant:"bodySm",as:"span",children:s.phone}),s.status==="pending"&&e.jsx(Ue,{size:"small"}),s.status==="success"&&e.jsx(d,{tone:"success",variant:"bodySm",as:"span",children:"Sent"}),s.status==="error"&&e.jsx(d,{tone:"critical",variant:"bodySm",as:"span",children:s.error||"Failed"})]},i))}),e.jsx(F,{align:"end",children:e.jsx(ne,{variant:"primary",loading:ct,disabled:!yt.trim()||ct,onClick:qt,children:"Send Test"})})]})})}),e.jsx(N,{open:Ot,sectioned:!0,title:"Schedule your Campaign",onClose:()=>lt(!1),primaryAction:{content:"Schedule",onAction:()=>Tt(Le),loading:se,disabled:se},secondaryActions:[{content:"Cancel",onAction:()=>lt(!1)}],children:e.jsx(N.Section,{children:e.jsx(Ws,{dateTime:Le,setDateTime:Bt})})}),e.jsxs("div",{className:"",children:[e.jsx(N,{open:ye,sectioned:!0,title:"Tutorial video",onClose:()=>{de(!1)},children:e.jsx("iframe",{id:"ytplayer",width:"100%",height:"360",allow:"fullscreen",src:n.tutorialSrc,frameBorder:"0",title:"Tutorial Video"})}),j&&e.jsx(La,{fetchedTemplates:X,templateId:w,setTemplateId:I,selectTemplate:zt,setHsmTemplateModalOpen:E,isHsmTemplateModalOpen:j,from:"Campaign",showSuccess:he,setShowSuccess:le}),e.jsx(_a,{showSuccess:he,setShowSuccess:le,value:"Message triggered successfully"}),[je.WIX,je.NONE].includes(T.platform)&&dt.balance<=.09?e.jsx(jn,{showModal:Z,setShowModal:U,walletBalance:dt.balance}):e.jsx(fn,{showModal:Z,setShowModal:U,errorDetails:Ge})]}),ms,hs]})},bn=n=>
42{const u=jt(),{shopDetailsData:p,shopPrivateWabaDetails:S}=ft(xt(L=>({shopDetailsData:L.shopDetailsData,shopPrivateWabaDetails:L.shopPrivateWabaDetails}))),[R,b]=a.useState(!1),{showPricingBanner:J,privateWabaDetails:ce,currentSelectedTemplateId:$,createNewCampaignView:C,setCreateNewCampaignView:ie,setSelectedTemplateForPreview:V,setMediaUrlForPreview:T,isUpsell:K}=n,[y,Y]=a.useState(S),[ee,q]=a.useState(!S),[Q,O]=a.useState({show:!1,message:""}),[ye,Ee]=a.useState({show:!1,message:""}),[te,de]=a.useState({show:!1,message:""}),[j,E]=a.useState(!1),[w,I]=a.useState(!1),[X,P]=a.useState(!1),[o,B]=a.useState({}),he=ra(p).includes(oa.CAMPAIGNS),[le,se]=a.useState(75),[ae,ge]=a.useState(0);let ve=a.useRef({TF:0,TT:0,length:0});const[H,re]=a.useState(null),Je=L=>{ve.current=L,re(L.length>0),L.TT===1||L.TF},[We,Z]=a.useState(p==null?void 0:p.planId);let U=p||{};const Ge=L=>{Ea(L).then(A=>{var fe,Re;(fe=A==null?void 0:A.settings)!=null&&fe.threshold&&se(Number((Re=A==null?void 0:A.settings)==null?void 0:Re.threshold)*100)})};a.useEffect(()=>{U&&U.id&&(Ce(U.userId),Ge(U.userId))},[]),a.useEffect(()=>{qe()},[]),a.useEffect(()=>{n.currentSelectedTemplateId&&u.push("/campaigns/create",n.currentSelectedTemplateId)},[n.currentSelectedTemplateId]);const qe=()=>{U&&U.userId?ca(U.userId).then(L=>{L&&L.appId&&L.whatsappVerificationStatus?(Y(L),q(!1)):da(U.userId).then(A=>
42{A&&A.appId&&A.whatsappVerificationStatus&&Y(A),q(!1)})}).catch(()=>q(!1)):q(!1)},nt=()=>{if(K){u.push("/campaigns/create/new");return}if(we()){Pe();return}o&&(o==null?void 0:o.balanceUsed)>=(o==null?void 0:o.cappedAmount)?de({show:!0,message:be.EXHAUSTED_MONTHLY_LIMIT}):!y||y&&y.whatsappVerificationStatus!=="WHATSAPP_VERIFICATION_DONE"?de({show:!0,message:be.PRIVATE_WABA_NOT_ENABLED}):Pe()},Qe=()=>!y||y&&y.whatsappVerificationStatus!=="WHATSAPP_VERIFICATION_DONE",we=()=>{const L=(S==null?void 0:S.pipeLineStage)??(S==null?void 0:S.pipelineStage);return U.platform===je.NONE&&L==="FINALIZE"},Ce=L=>{ua(L).then(A=>{if(A.status==="success"){b(!1),B(A.message);let fe=100*(A.message.balanceUsed/A.message.cappedAmount);ge(fe),A.message.balanceUsed>=A.message.cappedAmount&&localStorage.getItem("overlay")==="0"?(P(!0),localStorage.setItem("overlay","1")):localStorage.setItem("overlay","0")}else b(!0)}).catch(A=>{console.log(A)})},Se=te.show?e.jsx(Lt,{error:!0,content:te.message,onDismiss:()=>{de({show:!1,message:""})}}):null,Ie=Q.show?e.jsx(Lt,{error:!0,content:Q.message,onDismiss:()=>{de({show:!1,message:""})}}):null,[Te,it]=a.useState([je.WIX,je.NONE].includes(U.platform)?Is[7][1].price:Ps[1].price),[St,xe]=a.useState([je.WIX,je.NONE].includes(U.platform)?Is[7][1].planName:Ps[1].planName),Pe=()=>{if(C){u.push("/campaigns");return}u.push("/campaigns/create/new")};return he||K?e.jsx(e.Fragment,{children:C?e.jsx(e.Fragment,{children:e.jsx(Sn,{updateCampaignsListViewFlag:Pe,currentSelectedTemplateId:$,setCurrentSelectedTemplateId:n.setCurrentSelectedTemplateId,setSelectedTemplateForPreview:V,setMediaUrlForPreview:T,setShowDiscardModal:n.setShowDiscardModal})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flexSpaceBetween",style:{marginBottom:"10px"},children:e.jsx(Na,{shop:U,balance:o})}),H&&e.jsx(un,{userId:p==null?void 0:p.userId}),e.jsxs("div",{className:"flexSpaceBetween createNewCampaign",style:{justifyContent:"space-between",gap:"8px",alignItems:"center",marginBottom:"12px"},children:[e.jsx(d,{as:"h2",variant:"headingMd",children:"Recent Campaigns"}),e.jsx("div",{className:"button-design-new",children:e.jsx(ne,{variant:"primary",disabled:!K&&!we()&&(Qe()||o&&(o==null?void 0:o.balanceUsed)>=(o==null?void 0:o.cappedAmount)||R),onClick:()=>nt(),children:be.CREATE_CAMPAIGN})})]}),ee?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"60px 0"},children:e.jsx(Ue,{accessibilityLabel:"Loading"})}):e.jsx(sn,{privateWabaDetails:y,setToast:O,setErrorToast:Ee,setShowErrorToast:E,setShowSuccessToast:I,handleClick:nt,balance:o,disabled:R,limitReached:Number(ae)>=Number(le),eventTriggered:ve,setEventTriggered:Je}),Se,Ie,e.jsx(mn,{isOpen:X,setIsOpen:P,value:be.EXCEEDED_MONTHLY_LIMIT,src:pn}),e.jsx("div",{style:{padding:"16px 0",textAlign:"center"},children:e.jsxs(ze,{children:["WhatsApp messages sent are chargeable based on the recipient's country. View"," ",e.jsx("a",{href:"https://docs.google.com/spreadsheets/d/1WBMcVKFxM41crj4cyaWHl47sVn5pqjXQRSGbuqFFSn0/edit?usp=sharing",target:"_blank",rel:"noreferrer",children:"rates by country"}),"."]})})]})}):e.jsx(e.Fragment,{children:e.jsxs("div",{children:[e.jsx("br",{}),e.jsx("br",{}),e.jsxs("div",{className:"nudgeScreen-singlebox",children:[e.jsxs("div",{children:[e.jsxs(ze,{children:[e.jsx(pa,{children:e.jsx(js,{variation:"strong",children:be.WHY_MARKETING_CAMPAIGNS})}),e.jsxs(js,{variation:"subdued",children:[e.jsx("br",{}),e.jsx("br",{}),be.WHY_MARKETING_CAMPAIGNS_DESCP]})]}),e.jsx(ze,{children:e.jsxs(js,{variation:"subdued",children:[e.jsx("br",{}),e.jsx("br",{}),be.EXAMPLE,e.jsx("br",{}),e.jsx("br",{}),be.UPGRADE_MSG.replace("{recommendedPlanName}",`${St}`).replace("{recommendedPlanPrice}",`${Te}`),e.jsx("br",{}),e.jsx("br",{}),be.LEARN_MORE_TXT," Â ",e.jsx(Xe,{onClick:()=>{window.location.href="/pricing"},children:be.LEARN_MORE_BUTTON})]})})]}),[je.WIX,je.NONE].includes(U.platform)?e.jsx(Ha,{}):e.jsx(Ra,{page:be.HEADER,planId:We,setPlanId:n.setPlanId,upgradePlanButton:!1,setShowUpgradePlanDiv:()=>{},shopId:U.id,setRecommendedPlanPrice:it,setRecommendedPlanName:xe,userId:U.userId})]})]})})},yn=n=>{const{shopDetailsData:u}=ft(xt(V=>
42({shopDetailsData:V.shopDetailsData}))),[p,S]=a.useState(0),[R,b]=a.useState({id:"",url:""}),J=jt();a.useEffect(()=>{let V=u||{};V&&V.id&&b(V)},[]),a.useEffect(()=>{n.setGuideStep(p)},[p]);const ce=()=>{switch(p){case 0:return e.jsxs(ze,{children:[e.jsx("b",{children:"What is a WhatsApp marketing campaign?"}),e.jsx("p",{children:"WhatsApp marketing campaigns are one of the most popular marketing strategies that allow sending of promotional messages, product releases, newsletters & much more to users via WhatsApp in bulk. Itâs a hassle-free way of delivering business updates to customers on a day-to-day basis."}),e.jsx("p",{children:"E.g. product-related insights, latest arrivals, delivery updates, newsletter subscriptions, and more."})]});case 1:return e.jsx("span",{children:e.jsxs(ze,{children:[e.jsx("p",{children:"You can view previously created campaigns and create new ones in the âCampaignsâ section in the left navigation drawer."}),e.jsx("br",{}),e.jsx("div",{style:{width:"100%",height:"100%"},children:e.jsx("img",{style:{marginLeft:"auto",marginRight:"auto",display:"block",width:"100%",height:"100%"},className:"",src:"https://cdn.shopify.com/s/files/1/0683/1371/0892/files/image5_a000036a-9d36-4d99-b39f-7afe1b70774a.png?v=1691494627",alt:""})})]})});case 2:return e.jsxs(ze,{children:[e.jsx("p",{children:"On the âMarketing Campaignsâ page click the âCreate New Campaignâ button to create a new campaign."}),e.jsx("div",{style:{width:"100%",height:"100%"},children:e.jsx("img",{style:{marginLeft:"auto",marginRight:"auto",display:"block",width:"100%",height:"100%"},src:"https://cdn.shopify.com/s/files/1/0683/1371/0892/files/Frame_26_1.png?v=1692132467",alt:"Checkout Page Checkbox"})}),e.jsx("p",{children:"Enter the âCampaign Nameâ and click the âSelect Templateâ button"}),e.jsx("img",{style:{marginLeft:"auto",marginRight:"auto",display:"block",width:"100%",height:"100%"},src:"https://cdn.shopify.com/s/files/1/0683/1371/0892/files/Frame_49.png?v=1692170588",alt:"Checkout Page Checkbox"}),e.jsxs("p",{children:["Choose an approved template"," ",e.jsx("span",{onClick:()=>{J.push({pathname:"/whatsapp-templates",state:{tab:"ct"}}),ie()},style:{color:"blue",cursor:"pointer"},children:"(You can create a new template here)"})]}),e.jsx("div",{style:{width:"100%",height:"100%"},children:e.jsx("img",{style:{marginLeft:"auto",marginRight:"auto",display:"block",width:"100%",height:"100%"},src:"https://cdn.shopify.com/s/files/1/0683/1371/0892/files/image3.png?v=1691471407",alt:""})})]});case 3:return e.jsxs(ze,{children:[e.jsx("p",{children:"You can use the file upload method to fill in the phone numbers of your customers via an Excel sheet or csv file. Or you can also select customers list by selecting customer groups."}),e.jsx("p",{style:{fontWeight:"600"},children:"A. Via file upload method:"}),e.jsx("p",{children:"You can download the sample sheet by clicking on MS Excel or CSV link."}),e.jsx("div",{style:{width:"100%",height:"100%"},children:e.jsx("img",{style:{marginLeft:"auto",marginRight:"auto",display:"block",width:"100%",height:"100%"},src:"https://cdn.shopify.com/s/files/1/0683/1371/0892/files/Frame_7_1.png?v=1692133063",alt:""})}),e.jsx("p",{children:"In the sheet youâll need to enter the customer phone number & the variable details that are present in template. Once you've filled in all the data in the sheet, you can upload the file and submit the campaign."}),e.jsx("p",{style:{fontWeight:"600"},children:"B. Via customer group:"}),e.jsx("p",{children:"You can also run a marketing campaign using customer segments, which has its own benefits. Youâll avoid the hassle of filling excel/csv files if you decide to run a campaign via customer group. As Superlemon has already integrated with Shopify. All the customer data is already Present with Supetrlemon. You can simply select the customer group & send the campaign."}),e.jsx("div",{style:{width:"100%",height:"100%"},children:e.jsx("img",{style:{marginLeft:"auto",marginRight:"auto",display:"block",width:"100%",height:"100%"},src:"https://cdn.shopify.com/s/files/1/0683/1371/0892/files/Frame_8_1.png?v=1692133135",alt:""})}),e.jsxs("p",{children:["To learn more about how to create customer groups"," ",e.jsx("span",{onClick:()=>{window.open("https://www.superlemon.xyz/help-center/campaigns/28/","_blank")},style:{color:"blue",cursor:"default"},children:" click here."})]}),e.jsxs("p",{children:["Please note that the customer group method can only be used if the selected templat only has standard variable. if the selected temple has a custom variable, campaign should be run via file upload method."," "]})]});case 4:return e.jsx("span",{children:e.jsxs(ze,{children:[e.jsx("p",{children:"To measure the success of your campaign, you need to track and analyze your campaign metrics. This may include metrics such as message delivery rates, open rates, click-through rates, and conversion rates. Simply click on the âDownload Reportâ
42 button to view the report."}),e.jsx("div",{style:{width:"100%",height:"100%"},children:e.jsx("img",{style:{marginLeft:"auto",marginRight:"auto",display:"block",width:"100%",height:"100%"},src:"https://cdn.shopify.com/s/files/1/0683/1371/0892/files/Frame_45.png?v=1692133269",alt:""})})]})})}},$=()=>{S(p+1)},C=()=>{S(p-1)},ie=()=>{n.stepsCompleted(),n.closeModal()};return e.jsx(N,{open:n.open,onClose:n.closeModal,title:"Marketing Campaign",primaryAction:{content:p===4?"Guide Completed":"Next step",onAction:p===4?ie:$},secondaryActions:p>=1?[{content:"Back",onAction:C}]:void 0,children:e.jsx(N.Section,{children:e.jsx(pe,{vertical:!0,children:e.jsx(pe.Item,{children:ce()})})})})},vn={heading:"WhatsApp Campaign",content:[{text:"A WhatsApp marketing campaign offers a powerful and direct way to engage with your target audience. By leveraging the popularity of WhatsApp, businesses can send personalized messages, updates, promotions, and even customer support directly to users' smartphones.",buttonActionText:"Start Guide"}]},wn={tooltip_card:vn},li=n=>{var ae,ge,ve;const u=jt(),{isUpsell:p}=n,{shopDetailsData:S,planPaymentInfo:R}=ft(xt(H=>({shopDetailsData:H.shopDetailsData,planPaymentInfo:H.planPaymentInfo}))),b=ma(R),J=(ae=n==null?void 0:n.location)==null?void 0:ae.state,[ce,$]=a.useState(typeof J=="string"||typeof J=="number"?J:""),[C,ie]=a.useState({}),[V,T]=a.useState(void 0),[K,y]=a.useState(n.location.pathname==="/campaigns/create"),[Y,ee]=a.useState(!1),[q,Q]=a.useState([]),[O,ye]=a.useState({open:!1,videoSrc:""}),[Ee,te]=a.useState(!1),[de]=a.useState(!1),[j,E]=a.useState(0),[w,I]=a.useState(!1),[X,P]=a.useState(!1),o=()=>{te(!1)},B=()=>{te(!1)},he=a.useCallback(()=>ee(H=>!H),[]);a.useEffect(()=>{let H=[];ts.MY_CAMPAIGNSPAGE.forEach(re=>{let Je={content:re.content,onAction:()=>le(re.videoSrc)};H.push(Je)}),Q(H)},[]);const le=H=>{ye({open:!0,videoSrc:H})};a.useEffect(()=>{const H=n.location.state;$(typeof H=="string"||typeof H=="number"?H:"")},[n.location.state]),a.useEffect(()=>{y(n.location.pathname==="/campaigns/create")},[n.location.pathname]);const se=()=>wn;return e.jsx(e.Fragment,{children:b.downgraded?e.jsx(Va,{failedOn:b.downgradedOn}):e.jsx(e.Fragment,{children:e.jsxs(Ya,{customHeader:e.jsxs("div",{children:[K&&e.jsx(me,{paddingBlockEnd:"200",children:e.jsx(ne,{variant:"plain",icon:ha,onClick:()=>P(!0),children:"Back to Campaigns"})}),e.jsx(Xa,{title:K?"Create Campaign":"Marketing Campaigns",subtitle:K?void 0:be.DESCRIPTION,style:{width:"100%",maxWidth:"100%"}})]}),rightSidePanel:K?e.jsxs(k,{gap:"400",children:[(C==null?void 0:C.body)&&e.jsx(ns,{html:C.body.replace(/\n/g,"<br>"),ctaLabel:(ve=(ge=C.buttons)==null?void 0:ge.find(H=>H.type==="URL"))==null?void 0:ve.name,mediaType:["IMAGE","VIDEO","DOCUMENT"].includes(C.type)?C.type:void 0,mediaUrl:V,previewLabel:"Template Preview"}),e.jsx(me,{padding:"400",background:"bg-surface",borderColor:"border",borderWidth:"1",borderRadius:"200",shadow:"200",children:e.jsxs(k,{gap:"300",children:[e.jsx(st,{active:Y,activator:e.jsx(ne,{icon:za,onClick:he,disclosure:!0,children:ts.TITLE}),onClose:he,children:e.jsx(vs,{actionRole:"tutorialVideo",items:q})}),se()&&e.jsx(Ka,{variant:"panel",className:"sl-templates-guide-panel",obj:se(),btn1Action:()=>te(!0)})]})})]}):null,children:[e.jsx(bn,{currentSelectedTemplateId:ce,setCurrentSelectedTemplateId:$,createNewCampaignView:K,setCreateNewCampaignView:y,setSelectedTemplateForPreview:ie,setMediaUrlForPreview:T,setShowDiscardModal:P,isUpsell:p}),e.jsx(N,{open:O.open,sectioned:!0,title:ts.TITLE,onClose:()=>{ye({open:!1,videoSrc:""})},children:e.jsx("iframe",{id:"ytplayer",width:"100%",height:"360",allow:"fullscreen",src:O.videoSrc,frameBorder:"0",title:ts.TITLE})}),Ee&&se()?e.jsx(yn,{open:!0,completed:de,closeModal:B,stepsCompleted:o,shopName:S,setGuideStep:E}):null,e.jsx(N,{open:X,onClose:()=>P(!1),title:"Discard unsaved changes?",primaryAction:{content:"Discard changes",onAction:()=>{u.push("/campaigns"),P(!1)},destructive:!0},secondaryActions:[{content:"Continue editing",onAction:()=>P(!1)}],children:e.jsx(N.Section,{children:e.jsx(d,{children:"If you leave this page, any unsaved progress on your campaign will be lost."})})})]})})})};export{li 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.