1import{d as ue,eT as pe,f as ce,c,i as D,a as l,j as e,b as o,t as T,e as y,l as v,F as V,bN as j,w as d,af as R,o as a,k as ve,ge as p,bC as H,bD as _,p as k,m as x,bE as z,C as we,ca as q,s as O,G as Y,H as Ce,bR as Se,aI as ke,r as ne,g as _e,gf as De,B as he,gg as Ee,E as $e,bT as Te,_ as Ne}from"./index-V_hZsPnK.js";import{_ as be}from"./CardLoader.vue_vue_type_style_index_0_lang-BIzBdiv7.js";import{_ as Ae}from"./CampaignBlueprintMetrics.vue_vue_type_script_setup_true_lang-BFSHztan.js";import{V as Ie}from"./vue-draggable-next.esm-bundler-WlB9Fpfh.js";import{E as re}from"./index-CkdYP7CD.js";import"./icon-segments-zCfp1aJ4.js";import"./icon-offers--zZnXRTP.js";import"./min-CDqligTH.js";(function(){try{var C=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};C.SENTRY_RELEASE={id:"[email protected]"}}catch{}})();try{(function(){var C=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},A=new C.Error().stack;A&&(C._sentryDebugIds=C._sentryDebugIds||{},C._sentryDebugIds[A]="042d39aa-1dfd-42ef-9706-05aa3b0b7046",C._sentryDebugIdIdentifier="sentry-dbid-042d39aa-1dfd-42ef-9706-05aa3b0b7046")})()}catch{}const Le={key:1},Be={class:"divide-brand-sand border-t border-brand-sand"},Re={class:"px-10 pt-10 pb-4 flex items-center justify-between"},Ve={class:"text-xl font-bold text-brand-black"},Oe={class:"flex items-center space-x-3 shrink-0"},Pe={key:0,class:"bg-fuchsia-200 text-fuchsia-800 font-semibold px-4 py-1 text-xs rounded-xl flex items-center space-x-2"},Ge={key:1,class:"bg-indigo-200 text-indigo-800 font-semibold px-4 py-1 text-xs rounded-xl"},Ue={key:2,class:"bg-green-200 text-green-800 font-semibold px-4 py-1 text-xs rounded-xl"},Fe={key:3,class:"bg-fuchsia-200 text-fuchsia-800 font-semibold px-4 py-1 text-xs rounded-xl"},Me={key:4,class:"bg-indigo-200 text-indigo-800 font-semibold px-4 py-1 text-xs rounded-xl"},je={key:5,class:"bg-brand-sand text-brand-brown font-semibold px-4 py-1 text-xs rounded-xl"},He={key:6,class:"bg-brand-sand text-brand-brown font-semibold px-4 py-1 text-xs rounded-xl"},ze={key:7,class:"bg-brand-green-light text-brand-green-dark font-semibold px-4 py-1 text-xs rounded-xl"},Ye={key:8,class:"bg-brand-purple-light text-brand-purple-dark font-semibold px-4 py-1 text-xs rounded-xl"},We={key:9,class:"bg-brand-yellow-light text-brand-yellow-dark font-semibold px-4 py-1 text-xs rounded-xl"},qe={key:10,class:"brand-input"},Je={key:1,class:"relative"},Ke={class:"mx-10 mt-2 mb-10"},Qe={class:"space-y-6"},Xe={key:0,class:"subtitle -mt-4 text-brand-brown text-base font-semibold"},Ze={key:0},et={key:1,class:"text-base font-semibold"},tt={key:2,class:"text-base font-semibold"},W=ue({__name:"CampaignBlueprintCard",props:{campaignBlueprintId:{}},emits:["view","enable","disable","edit","clone","publish","delete"],setup(C,{emit:A}){const h=C,r=pe(),S=ce();async function J(){h.campaignBlueprintId&&!r.campaignBlueprints[h.campaignBlueprintId]&&await r.fetchCampaignBlueprint(h.campaignBlueprintId)}J();const N=c(()=>r.campaignCounts[h.campaignBlueprintId]??0),b=c(()=>
1{if(h.campaignBlueprintId)return r.campaignBlueprints[h.campaignBlueprintId]}),E=c(()=>b.value?.campaignSchedule===q.Schedule.ONE_TIME),P=c(()=>E.value?u.value===p.State.SENT:!0),u=c(()=>b.value?.state??p.State.DRAFT),I=c(()=>b.value?b.value.updatedAt!==b.value.publishedAt:!1),L=c(()=>!$.value&&!S.org?.reactivation?.activeCampaign),$=c(()=>b.value?.audience),K=c(()=>h.campaignBlueprintId?b.value?.loadState??R.UNLOADED:R.LOADED),Q=c(()=>K.value===R.LOADED?R.LOADED:R.LOADING),f=A;function G(){k.confirm({message:"Are you sure you want to schedule this campaign?",cancelText:"Back",confirmText:"Schedule campaign",type:"warning",onConfirm:()=>f("enable")})}return(X,t)=>Q.value===e(R).LOADING?(a(),D(be,{key:0})):(a(),l("div",Le,[o("div",Be,[o("div",Re,[o("p",Ve,T($.value?$.value.name||"Segmented Reactivation Campaign":"Primary Reactivation Campaign"),1),o("div",Oe,[L.value?(a(),l("p",Pe,[v(e(ve),{icon:["fas","exclamation-triangle"]}),t[15]||(t[15]=o("span",null,"Needs to be Published",-1))])):u.value===e(p).State.ACTIVE&&I.value?(a(),l("p",Ge," Unpublished Changes ")):y("",!0),u.value===e(p).State.ACTIVE?(a(),l("p",Ue," Active ")):u.value===e(p).State.COLLECTING?(a(),l("p",Fe," Collecting Data ")):u.value===e(p).State.SETUP?(a(),l("p",Me," Setup Pending ")):u.value===e(p).State.DISABLED?(a(),l("p",je," Inactive ")):u.value===e(p).State.DRAFT?(a(),l("p",He," Draft ")):u.value===e(p).State.SCHEDULED?(a(),l("p",ze," Scheduled ")):u.value===e(p).State.SENDING?(a(),l("p",Ye," Sending Now ")):u.value===e(p).State.SENT?(a(),l("p",We," Sent ")):y("",!0),b.value?(a(),l("div",qe,[!e(S).isAdmin&&u.value===e(p).State.SENDING?(a(),l(V,{key:0},[],64)):e(S).isAdmin&&u.value===e(p).State.SENDING?(a(),l("div",Je,[v(e(z),{"split-button":"",class:"secondary brand-input",onClick:t[1]||(t[1]=m=>f("view"))},j({default:d(()=>[t[17]||(t[17]=x(" View ",-1))]),_:2},[e(S).permissions.reactivation.write?{name:"dropdown",fn:d(()=>[v(e(H),null,{default:d(()=>[v(e(_),{class:"w-full text-brand-blue font-medium cursor-pointer",onClick:t[0]||(t[0]=m=>e(k).disable("campaign",()=>f("disable")))},{default:d(()=>[...t[16]||(t[16]=[x(" Disable ",-1)])]),_:1})]),_:1})]),key:"0"}:void 0]),1024),t[18]||(t[18]=o("span",{class:"absolute -bottom-6 right-0 text-red-500 text-xs border-t-2 border-red-500 w-24 text-center"},"admin only",-1))])):u.value===e(p).State.SENT?(a(),D(e(z),{key:2,"split-button":"",class:"secondary brand-input",onClick:t[4]||(t[4]=m=>f("view"))},j({default:d(()=>[t[21]||(t[21]=x(" View ",-1))]),_:2},[e(S).permissions.reactivation.write?{name:"dropdown",fn:d(()=>[v(e(H),null,{default:d(()=>[v(e(_),{class:"w-full text-brand-blue font-medium cursor-pointer",onClick:t[2]||(t[2]=m=>e(k).clone("campaign",()=>f("clone")))},{default:d(()=>[...t[19]||(t[19]=[x(" Clone ",-1)])]),_:1}),v(e(_),{class:"w-full text-brand-blue font-medium cursor-pointer",onClick:t[3]||(t[3]=m=>e(k).delete("campaign",()=>f("delete")))},{default:d(()=>[...t[20]||(t[20]=[x(" Delete ",-1)])]),_:1})]),_:1})]),key:"0"}:void 0]),1024)):$.value?(a(),D(e(z),{key:3,"split-button":"",class:"secondary brand-input",onClick:t[11]||(t[11]=m=>f("edit"))},j({default:d(()=>[x(T(e(S).permissions.reactivation.write?"Edit":"View")+" ",1)]),_:2},[e(S).permissions.reactivation.write?{name:"dropdown",fn:d(()=>[v(e(H),null,{default:d(()=>[$.value?(a(),l(V,{key:0},[b.value.enabled?(a(),D(e(_),{key:0,class:"w-full text-brand-blue font-medium cursor-pointer",onClick:t[5]||(t[5]=m=>e(k).disable("campaign",()=>f("disable")))},{default:d(()=>[...t[22]||(t[22]=[x(" Disable ",-1)])]),_:1})):y("",!0),b.value.enabled?y("",!0):(a(),D(e(_),{key:1,class:"text-brand-blue font-medium cursor-pointer",onClick:t[6]||(t[6]=m=>E.value?G():e(k).enable("campaign",()=>f("enable")))},{default:d(()=>[x(T(E.value?"Schedule":"Activate"),1)]),_:1})),b.value.enabled?(a(),D(e(_),{key:2,class:"w-full text-brand-blue font-medium cursor-pointer",onClick:t[7]||(t[7]=m=>e(k).clone("campaign",()=>f("clone")))},{default:d(()=>[...t[23]||(t[23]=[x(" Clone ",-1)])]),_:1})):y("",!0),b.value.enabled?y("",!0):(a(),D(e(_),{key:3,class:"w-full text-brand-blue font-medium cursor-pointer",onClick:t[8]||(t[8]=m=>e(k).delete("campaign",()=>f("delete")))},{default:d(()=>[...t[24]||(t[24]=[x(" Delete ",-1)])]),_:1}))],64)):b.value.publishedAt?y("",!0):(a(),l(V,{key:1},[v(e(_),{class:"w-full text-brand-blue font-medium cursor-pointer",onClick:t[9]||(t[9]=m=>e(k).publish("campaign",()=>f("publish")))},{default:d(()=>[...t[25]||(t[25]=[x(" Publish ",-1)])]),_:1}),v(e(_),{class:"w-full text-brand-blue font-medium cursor-pointer",onClick:t[10
1]||(t[10]=m=>e(k).delete("campaign",()=>f("delete")))},{default:d(()=>[...t[26]||(t[26]=[x(" Delete ",-1)])]),_:1})],64))]),_:1})]),key:"0"}:void 0]),1024)):(a(),D(e(z),{key:4,"split-button":"",class:"secondary brand-input",onClick:t[14]||(t[14]=m=>f("edit"))},j({default:d(()=>[x(T(e(S).permissions.reactivation.write?"Edit":"View")+" ",1)]),_:2},[e(S).permissions.reactivation.write?{name:"dropdown",fn:d(()=>[v(e(H),null,{default:d(()=>[b.value.enabled?(a(),D(e(_),{key:0,class:"w-full text-brand-blue font-medium cursor-pointer",onClick:t[12]||(t[12]=m=>e(k).disable("campaign",()=>f("disable")))},{default:d(()=>[...t[27]||(t[27]=[x(" Disable ",-1)])]),_:1})):y("",!0),b.value.enabled?y("",!0):(a(),D(e(_),{key:1,class:"text-brand-blue font-medium cursor-pointer",onClick:t[13]||(t[13]=m=>e(k).enable("campaign",()=>f("enable")))},{default:d(()=>[...t[28]||(t[28]=[x(" Activate ",-1)])]),_:1}))]),_:1})]),key:"0"}:void 0]),1024))])):y("",!0)])]),o("div",null,[o("div",Ke,[o("div",Qe,[b.value?.enabled?(a(),l("p",Xe,[N.value===void 0?(a(),l("span",Ze,[v(e(we),{width:"800",height:"200",class:"inline-block w-16 h-4 mx-1"})])):u.value===e(p).State.SENDING?(a(),l("span",et,T(N.value)+" Campaigns Currently in Progress ",1)):u.value===e(p).State.SCHEDULED?(a(),l("span",tt,T(N.value)+" Campaigns Scheduled ",1)):y("",!0)])):y("",!0),v(Ae,{"campaign-blueprint-id":X.campaignBlueprintId,"show-details":P.value,borders:!0},null,8,["campaign-blueprint-id","show-details"])])])])])]))}}),nt={class:"space-y-2"},at={class:"brand-card-lg no-padding"},st={class:"flex justify-between px-10 py-10"},it={class:"title"},lt={class:"subtitle mt-2 text-lg font-medium text-brand-brown"},ot={class:"pl-12"},dt={class:"font-bold"},rt={key:0,class:"space-y-10"},ut={key:1,class:"space-y-10"},pt={key:0,class:"grabber w-6 h-6 absolute hidden top-3 left-3 cursor-move z-10"},ct={key:0,class:"brand-card-lg no-padding"},vt={class:"space-y-12"},bt={key:1,class:"brand-card-lg no-padding"},mt={class:"space-y-12"},ft=ue({__name:"index",props:{campaignSchedule:{}},setup(C){const A=C;function h(n){switch(n){case p.State.SENT:return 3;case p.State.SCHEDULED:return 2;case p.State.SENDING:return 1;default:return 0}}const r=pe(),S=_e(),J=ce(),N=O(!1),b=O({}),E=O(!1),P=O(!1),u=O(!1),I=c(()=>A.campaignSchedule),L=c(()=>I.value===q.Schedule.ONE_TIME),$=c(()=>Ee(I.value)),K=c(()=>$.value.title),Q=c(()=>$.value.description),f=c(()=>$.value.addButtonText),G=c(()=>!!r.primaryCampaignBlueprintId),X=c(()=>I.value===q.Schedule.RECURRING&&G.value),t=c(()=>({animation:200,group:"description",disabled:!1,ghostClass:"ghost"})),m=c(()=>r.campaignBlueprintsArray.filter(({audience:n,deleted:s,campaignSchedule:w=q.Schedule.RECURRING})=>n&&!s&&w===I.value)??[]),U=c(()=>L.value?m.value.filter(({state:s})=>s!==p.State.SENT).sort((s,w)=>{const i=h(s.state)-h(w.state);return i!==0?i:s.state===p.State.DRAFT&&w.state===p.State.DRAFT&&s.updatedAt&&w.updatedAt?new Date(w.updatedAt).getTime()-new Date(s.updatedAt).getTime():0}):m.value.filter(({enabled:n})=>n)),ae=c(()=>L.value?[]:m.value.filter(({enabled:n})=>!n)),se=c(()=>m.value.filter(({state:n})=>n===p.State.SENT));async function me(){E.value=!0,P.value=!0;let n=!0;!G.value&&!L.value&&(n=!1);const s=await r.createCampaignBlueprint(I.value,n);await r.sync(),F(s._id)}function Z(n){n&&S.push({name:"reactivationcampaignview",params:{id:n}})}function F(n){n&&S.push({name:"reactivationcampaign",params:{id:n}})}async function fe(n){if(n.newIndex!==n.oldIndex){const s=U.value.map(({_id:w})=>w);u.value=!0,await r.updateCampaignBlueprintsOrder(s),u.value=!1}N.value=!1}function ee(n){n&&(r.storeCampaignBlueprintData(n,{deleted:!0}),r.scheduleSaveCampaignBlueprint(n,0))}async function M(n,s=!1){try{if(n){const w=r.campaignBlueprintsArray?.find(({_id:B})=>B===n),i=new Date,g=new Date(i.getTime()+1440*60*1e3),oe=w?.emails.filter(B=>B.enabled),ge=oe?.filter(B=>{const de=new Date(B.sendOnDate??new Date),[ye=0,xe=0]=(B.timeToSend??De).split(":").map(Number);return de.setHours(ye,xe),de>g});if(!s&&ge?.length!==oe?.length){he.error("Error","Please ensure all emails are scheduled to send at least 24 hours from now.");return}u.value=!0,b.value[n]=!0,await r.publishCampaignBlueprint(n),b.value[n]=!1,s||re.success("It's live! Reactivation campaign successfully published."),u.value=!1}}catch{re.error("Failed to publish reactivation campaign. Please refresh and try again or c
1ontact us through chat"),b.value[n]=!1}}async function ie(n){n&&(r.storeCampaignBlueprintData(n,{enabled:!1}),r.scheduleSaveCampaignBlueprint(n,0),await M(n,!0))}async function te(n){n&&(r.storeCampaignBlueprintData(n,{enabled:!0}),r.scheduleSaveCampaignBlueprint(n,0),await M(n))}function le(n){n&&r.cloneCampaignBlueprint(n,!1)}return(n,s)=>{const w=Ce("loading");return a(),l("div",null,[o("div",nt,[o("div",at,[o("div",st,[o("div",null,[o("p",it,T(K.value),1),o("p",lt,T(Q.value),1),s[6]||(s[6]=o("p",{class:"subtitle text-brand-blue font-semibold text-md mt-2"},[o("a",{href:"https://docs.churnkey.co/campaign-customization-guide",target:"_blank"}," Learn more about Reactivation Campaigns â ")],-1))]),o("div",null,[o("div",ot,[v(e($e),{disabled:!e(J).permissions.reactivation.write||E.value||P.value,type:"primary",class:"py-4 px-6",onClick:me},{default:d(()=>[o("span",dt,T(f.value)+" â",1)]),_:1},8,["disabled"])])])]),E.value?(a(),l("div",rt,[v(be)])):Y((a(),l("div",ut,[X.value?(a(),D(W,{key:0,class:"mt-2","campaign-blueprint-id":e(r).primaryCampaignBlueprintId||"",onEdit:s[0]||(s[0]=i=>F(e(r).primaryCampaignBlueprintId||"")),onView:s[1]||(s[1]=i=>Z(e(r).primaryCampaignBlueprintId||"")),onDisable:s[2]||(s[2]=i=>ie(e(r).primaryCampaignBlueprintId||"")),onEnable:s[3]||(s[3]=i=>te(e(r).primaryCampaignBlueprintId||""))},null,8,["campaign-blueprint-id"])):y("",!0),Y(v(e(Ie),Se({class:"list-group",tag:"ul",list:U.value},t.value,{handle:".grabber",onDisabled:s[4]||(s[4]=i=>!N.value),onStart:s[5]||(s[5]=i=>N.value=!0),onEnd:fe}),{default:d(()=>[v(Te,{type:"transition",name:N.value?void 0:"flip-list"},{default:d(()=>[(a(!0),l(V,null,ne(U.value,i=>(a(),l("li",{key:i._id,class:"relative grabber-parent mb-6"},[L.value?y("",!0):(a(),l("div",pt,[v(e(ve),{icon:["fas","grip-vertical"],class:"text-brand-dark-sand text-2xl"})])),v(W,{"campaign-blueprint-id":i._id,onView:g=>Z(i._id),onEdit:g=>F(i._id),onDisable:g=>ie(i._id),onEnable:g=>te(i._id),onDelete:g=>ee(i._id),onPublish:g=>M(i._id),onClone:g=>le(i._id)},null,8,["campaign-blueprint-id","onView","onEdit","onDisable","onEnable","onDelete","onPublish","onClone"])]))),128))]),_:1},8,["name"])]),_:1},16,["list"]),[[ke,U.value.length>0]])])),[[w,u.value]])]),!E.value&&se.value.length?Y((a(),l("div",ct,[s[7]||(s[7]=o("div",{class:"flex justify-between px-10 py-10"},[o("div",null,[o("p",{class:"title"},"Sent Reactivation Campaigns"),o("p",{class:"subtitle mt-2 text-lg font-medium text-brand-brown"}," You can clone sent campaigns to get a head start on creating new ones. ")])],-1)),o("div",vt,[(a(!0),l(V,null,ne(se.value,i=>(a(),l("div",{key:i._id},[v(W,{"campaign-blueprint-id":i._id,onView:g=>Z(i._id),onClone:g=>le(i._id),onDelete:g=>ee(i._id)},null,8,["campaign-blueprint-id","onView","onClone","onDelete"])]))),128))])])),[[w,u.value]]):y("",!0),!E.value&&ae.value.length?Y((a(),l("div",bt,[s[8]||(s[8]=o("div",{class:"flex justify-between px-10 py-10"},[o("div",null,[o("p",{class:"title"},"Inactive Reactivation Campaigns"),o("p",{class:"subtitle mt-2 text-lg font-medium text-brand-brown"}," When you enable these inactive campaigns, theyâll immediately go live. ")])],-1)),o("div",mt,[(a(!0),l(V,null,ne(ae.value,i=>(a(),l("div",{key:i._id},[v(W,{"campaign-blueprint-id":i._id,onEdit:g=>F(i._id),onEnable:g=>te(i._id),onDelete:g=>ee(i._id),onPublish:g=>M(i._id)},null,8,["campaign-blueprint-id","onEdit","onEnable","onDelete","onPublish"])]))),128))])])),[[w,u.value]]):y("",!0)])])}}}),Dt=Ne(ft,[["__scopeId","data-v-397fcc5c"]]);export{Dt as default}; 2//# sourceMappingURL=index-CGH4UGxK.js.map
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.