PageSourceSearch

https://app.campaignhq.co/_next/static/chunks/pages/campaigns/[campaignId]/edit-0766b3db30fc9dff.js

js campaignhq.co collected 2026-09-24 09:43:06 UTC 114,186 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4038],{79242:function(e,s,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/campaigns/[campaignId]/edit",function(){return t(18496)}])},17105:function(e,s,t){"use strict";t.d(s,{Z:function(){return Example}});var a=t(85893),i=t(67294),l=t(11355),n=t(80100),r=t(82911),d=t(11163);function Example(e){let{open:s,setOpen:t,subHeading:o}=e,c=(0,i.useRef)(null),m=(0,d.useRouter)(),gotoSelectPlan=()=>{t(!1),m.push("/settings/billing")};return(0,a.jsx)(l.u.Root,{show:s,as:i.Fragment,children:(0,a.jsxs)(n.V,{as:"div",className:"relative z-10",initialFocus:c,onClose:t,children:[(0,a.jsx)(l.u.Child,{as:i.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"})}),(0,a.jsx)("div",{className:"fixed inset-0 z-10 overflow-y-auto",children:(0,a.jsx)("div",{className:"flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0",children:(0,a.jsx)(l.u.Child,{as:i.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",children:(0,a.jsxs)(n.V.Panel,{className:"relative transform overflow-hidden rounded-lg bg-white px-4 pb-4 pt-5 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg sm:p-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-green-100",children:(0,a.jsx)(r.Z,{className:"h-6 w-6 text-green-600","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-5",children:[(0,a.jsx)(n.V.Title,{as:"h3",className:"text-base font-semibold leading-6 text-gray-900",children:"Upgrade to premium"}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm text-gray-500",children:o||"You have reached the limit of 5 steps in your automation."})})]})]}),(0,a.jsxs)("div",{className:"mt-5 sm:mt-6 sm:grid sm:grid-flow-row-dense sm:grid-cols-2 sm:gap-3",children:[(0,a.jsx)("button",{type:"button",className:"inline-flex w-full justify-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 sm:col-start-2",onClick:()=>gotoSelectPlan(),children:"Upgrade Today"}),(0,a.jsx)("button",{type:"button",className:"mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:col-start-1 sm:mt-0",onClick:()=>t(!1),ref:c,children:"Cancel"})]})]})})})})]})})}},38397:function(e,s,t){"use strict";var a=t(85893),i=t(11163),l=t(67294),n=t(94892),r=t(88894),d=t(87536),o=t(47953),c=t(39029),m=t(70178),x=t(72173);t(22424),t(18357),t(11097);var u=t(9473);s.Z=e=>{let{prompt:s,campaign:t,onTemplateChange:o,onDiscardTemplate:c,setEditorType:m}=e,[h,g]=(0,l.useState)(!1),[p,f]=(0,l.useState)(s.customFields),[j,y]=(0,l.useState)(!1);(0,i.useRouter)(),(0,u.I0)();let onSelect=(e,s)=>{w(fieldNameToKey(e),s.value)},{register:b,handleSubmit:v,watch:N,setValue:w,formState:{errors:C,isValid:k}}=(0,d.cI)();(0,l.useEffect)(()=>{s.customFields.forEach(e=>{e.example&&w(""==e.key?"custom_field":e.key,e.example)})},[]);let save=async e=>{y(!0);let a={},i="";Object.keys(e).forEach(s=>{"custom_field"==s?i=e[s]:a[fieldNameToKey(s)]=e[s]});let l={prompt_template_id:s.id,prompt_type:"campaign",extra_details:a,details:i};t?.id&&(l.campaign_id=t?.id);let[d,c]=await (0,r.W)(n.Z.prompts.create(l));c&&(o(c.data),m(c.data.editorType)),y(!1)},fieldName=e=>"Target persona's concerns"==e?"target_persona_concerns":""==e?"custom_field":e.split(" ").join("_"),fieldNameToKey=e=>"target_persona_concerns"==e?"Target persona's concerns":e.split("_").join(" "),discard=e=>{e.preventDefault(),c()};return(0,a.jsxs)("div",{className:"w-full  p-[30px]",children:[(0,a.jsx)("h2",{className:"font-semibold mb-3 text-indigo-500",children:s.name}),(0,a.jsxs)("form",{id:"prompt-form",onSubmit:v(save),className:"rounded  ",children:[p.map((e,s)=>(0,a.jsx)("div",{className:"mb-3",children:(0,a.jsx)(Field,{errors:C,field:e,fieldName:fieldName(e.key),register:b,onSelect:onSelect},s)})),(0,a.jsxs)("div",{className:"flex justify-end mt-10 space-x-3",children:[(0,a.jsx)("button",{onClick:e=>discard(e),className:"inline-flex items-center justify-center px-4 py-2 text-sm font-bold text-indigo-600 underline decoration-dashed underline-offset-4 focus:outline-none sm:w-auto",children:"Discard"}),(0,a.jsx)(x.zx,{loading:j,disabled:j||!k,text:"Generate",type:"submit"})]})]},"prompt-form")]})};let Field=e=>{let{field:s,register:t,onSelect:i,fieldName:l,errors:n}=e,{type:r}=s;switch(r){case"text":return(0,a.jsx)(o.Z,{name:l,register:t,placeholder:s.placeholder,label:s.name,validations:{required:s.required},error:n[l]});case"select":return(0,a.jsx)(m.Z,{name:l,placeholder:s.placeholder,label:s.name,error:n[l],onSelect:e=>i(l,e),validations:{required:s.required},options:s.options.map(e=>({name:e,value:e}))});case"textarea":return(0,a.jsx)(c.Z,{name:l,register:t,error:n[l],placeholder:s.placeholder,validations:{required:s.required},label:s.name});
1case"custom":return(0,a.jsx)(c.Z,{name:l,register:t,placeholder:s.placeholder,error:n[l],validations:{required:s.required},label:s.name})}}},85384:function(e,s,t){"use strict";t.d(s,{Z:function(){return PromptList}});var a=t(85893),i=t(65350),l=t(29668),n=t(43451),r=t(20445),d=t(43312),o=t(7543),c=t(12435),m=t(93559),x=t(8662);let u={"multipurpose-email":{icon:i.Z,iconForeground:"text-teal-700",iconBackground:"bg-teal-50",description:"Custom email to send to your customers"},"product-update-announcement-email":{icon:l.Z,iconForeground:"text-purple-700",iconBackground:"bg-purple-50",description:"Announce a new product or feature"},"abandoned-cart-email":{icon:n.Z,iconForeground:"text-rose-700",iconBackground:"bg-rose-50",description:"Send a reminder to customers who left items in their cart"}};function classNames(){for(var e=arguments.length,s=Array(e),t=0;t<e;t++)s[t]=arguments[t];return s.filter(Boolean).join(" ")}function PromptList(e){let{prompts:s,onSelect:t}=e,handleClick=e=>{t(e)};return(0,a.jsx)("div",{className:"divide-y divide-gray-200 overflow-hidden rounded-lg sm:grid sm:grid-cols-2 sm:gap-px sm:divide-y-0",children:s.map((e,t)=>(0,a.jsx)("div",{onClick:()=>handleClick(e),className:classNames(0===t?"rounded-tl-lg rounded-tr-lg sm:rounded-tr-none":"",1===t?"sm:rounded-tr-lg":"",t===s.length-2?"sm:rounded-bl-lg":"",t===s.length-1?"rounded-bl-lg rounded-br-lg sm:rounded-bl-none":"","group relative bg-white p-1 focus-within:ring-2 focus-within:ring-inset focus-within:ring-indigo-500"),children:(0,a.jsxs)("div",{className:"bg-50 h-full rounded border p-3 cursor-pointer",children:[(0,a.jsx)("div",{className:"",children:(0,a.jsx)("span",{className:classNames(u[e.slug].iconForeground,u[e.slug].iconBackground,"inline-flex rounded-lg p-3 ring-4 ring-white"),children:(()=>{let s=u[e.slug].icon;return(0,a.jsx)(s,{className:"h-6 w-6","aria-hidden":"true"})})()})}),(0,a.jsxs)("div",{className:"mt-8",children:[(0,a.jsx)("h3",{className:"text-base font-semibold leading-6 text-gray-900",children:(0,a.jsxs)("a",{className:"focus:outline-none",children:[(0,a.jsx)("span",{className:"absolute inset-0","aria-hidden":"true"}),e.name]})}),(0,a.jsx)("p",{className:"mt-2 text-sm text-gray-500",children:u[e.slug].description})]}),(0,a.jsx)("span",{className:"pointer-events-none absolute right-6 top-6 text-gray-300 group-hover:text-gray-400","aria-hidden":"true",children:(0,a.jsx)("svg",{className:"h-6 w-6",fill:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M20 4h1a1 1 0 00-1-1v1zm-1 12a1 1 0 102 0h-2zM8 3a1 1 0 000 2V3zM3.293 19.293a1 1 0 101.414 1.414l-1.414-1.414zM19 4v12h2V4h-2zm1-1H8v2h12V3zm-.707.293l-16 16 1.414 1.414 16-16-1.414-1.414z"})})})]})},e.name))})}r.Z,d.Z,o.Z,c.Z,m.Z,x.Z},34110:function(e,s,t){"use strict";t.d(s,{Z:function(){return Empty}});var a=t(85893),i=t(77e3);function Empty(e){let{heading:s,subHeading:t,onCtaClick:l,ctaLable:n,className:r}=e;return(0,a.jsxs)("div",{className:`text-center ${r}`,children:[(0,a.jsx)("svg",{className:"mx-auto h-12 w-12 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:(0,a.jsx)("path",{vectorEffect:"non-scaling-stroke",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 13h6m-3-3v6m-9 1V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2z"})}),(0,a.jsx)("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:s}),t?(0,a.jsx)("p",{className:"mt-1 text-sm text-gray-500",children:t}):"",n?(0,a.jsx)("div",{className:"mt-6",children:(0,a.jsxs)("button",{type:"button",className:"inline-flex items-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",onClick:l,children:[(0,a.jsx)(i.Z,{className:"-ml-1 mr-2 h-5 w-5","aria-hidden":"true"}),n]})}):""]})}},39029:function(e,s,t){"use strict";t.d(s,{Z:function(){return TextArea}});var a=t(85893);function TextArea(e){let{name:s,type:t="text",error:i,register:l,validations:n,value:r,onChange:d,onBlur:o,className:c,label:m,placeholder:x,disabled:u,helpComponent:h}=e;return(0,a.jsxs)("div",{className:c,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("label",{htmlFor:"email",className:"block text-sm font-medium text-gray-700",children:m}),h?h():""]}),(0,a.jsxs)("div",{className:"mt-1",children:[(0,a.jsx)("textarea",{rows:4,onChange:e=>d?d(e.target.value):"",onBlur:e=>o?o(e.target.value):"",type:t,name:s,value:r,id:s,autoComplete:"new-password",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false","data-form-type":"other","data-lpignore":"true","data-1p-ignore":"true","data-bwignore":"true",disabled:u,...l?{...l(s,{...n,onChange:e=>d?d(e.target.value):"",onBlur:e=>o?o(e.target.value):""})}:{},className:`  block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6 ${i?.message?"text-red-900 border-red-300 focus:border-red-500 focus:ring-red-500 focus:outline-none placeholder-red-300":u?"disabled:cursor-not-allowed disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 sm:text-sm":"border-gray-300 focus:border-indigo-500 focus:ring-indigo-500"}`,placeholder:x}),i?.message?(0,a.jsx)("p",{className:"mt-2 text-sm text-red-600",children:i?.message}):""]})]})}t(67294)},97454:function(e,s,t){"use strict";t.d(s,{Z:function(){return ToneRephraseModal}});var a=t(85893),i=t(72173),l=t(70178),n=t(47953),r=[{name:"Appreciative",value:"appreciative"},{name:"Assertive",value:"assertive"},{name:"Awestruck",value:"awestruck"},{name:"Candid",value:"candid"},{name:"Casual",value:"casual"},{name:"Cautionary",value:"cautionary"},{name:"Compassionate",value:"compassionate"},{name:"Convincing",value:"convincing"},{name:"Curious",value:"curious"},{name:"Earnest",value:"earnest"},{name:"Encouraging",value:"encouraging"},{name:"Enthusiastic",value:"enthusiastic"},{name:"Formal",value:"formal"},{name:"Friendly",value:"friendly"},{name:"Funny",value:"funny"},{name:"Humble",value:"humble"},{name:"Humorous",value:"humorous"},{name:"Informative",value:"informative"},{name:"Inspirational",value:"inspirational"},{name:"Joyful",value:"joyful"},{name:"Optimistic",value:"optimistic"},{name:"Passionate",value:"passionate"},{name:"Romantic",value:"romantic"},{name:"Thoughtful",value:"thoughtful"},{name:"Urgent",value:"urgent"},{name:"Warm",value:"warm"},{name:"Witty",value:"witty"}],d=t(11355),o=t(80100),c=t(67294),m=t(87536),x=t(9473),u=t(94892),h=t(88894),g=t(7658),p=t(11163);function ToneRephraseModal(e){let{open:s=!1,setOpen:t,subject:f,setSubjectValue:j}=e,{handleSubmit:y,formState:{errors:b,isSubmitting:v,isValid:N},register:w,setValue:C}=(0,m.cI)({mode:"onChange"});(0,x.I0)(),(0,p.useRouter)(),(0,c.useRef)(null);let closeModal=()=>{t(!1)};(0,c.useEffect)(()=>{C("subject",f),C("tone",r[0].value)},[f]);let submit=async function(e){let s={subject:e.subject,tone:e.tone},[t,a]=await (0,h.W)(u.Z.integrations.rephraseSubject(s));a&&(j("subject",a.data.subject),(0,g.C)("success","Subject updated","Subject rephrased and updated successfully")),closeModal()};return(0,a.jsx)(d.u.Root,{show:s,as:c.Fragment,children:(0,a.jsxs)(o.V,{as:"div",className:"relative z-10",onClose:closeModal,children:[(0,a.jsx)(d.u.Child,{as:c.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"})}),(0,a.jsx)("div",{className:"fixed inset-0 z-10 overflow-y-auto",children:(0,a.jsx)("div",{className:"flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0",children:(0,a.jsx)(d.u.Child,{as:c.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",children:(0,a.jsx)(o.V.Panel,{className:"relative w-1/3 transform rounded-lg bg-white text-left shadow-xl transition-all",children:(0,a.jsxs)("div",{className:"bg-white shadow sm:rounded-lg",children:[(0,a.jsxs)("div",{className:"px-4 py-5 sm:px-6",children:[(0,a.jsx)("h3",{className:"text-base font-semibold leading-6 text-gray-900",children:"Rephrase Subject Line"}),(0,a.jsx)("p",{className:"mt-1 max-w-2xl text-sm text-gray-500",children:"You can rephrase the subject line in any tone using our AI assistant."})]}),(0,a.jsx)("div",{className:"border-t border-gray-200 px-4 py-5 sm:px-6",children:(0,a.jsxs)("form",{onSubmit:y(submit),children:[(0,a.jsx)(n.Z,{name:"subject",register:w,validations:{required:"Subject is required"},error:b?.subject,className:"mb-1",label:"Subject",placeholder:"Personalise subject line with contact fields"}),(0,a.jsx)(l.Z,{name:"tone",label:"Select a tone",options:r,onSelect:function(e){C("tone",e.value)}}),(0,a.jsx)("div",{className:"mt-5 flex justify-end",children:(0,a.jsx)(i.zx,{type:"submit",loading:v,disabled:v||!N,text:"Rephrase"})})]})})]})})})})})]})})}},35443:function(e,s){"use strict";s.Z=[{name:"0%",value:0},{name:"5%",value:5},{name:"10%",value:10},{name:"15%",value:15},{name:"20%",value:20},{name:"25%",value:25},{name:"30%",value:30},{name:"35%",value:35},{name:"40%",value:40},{name:"45%",value:45},{name:"50%",value:50}]},84118:function(e,s,t){"use strict";t.d(s,{N:function(){return useDebounce}});var a=t(67294);function useDebounce(e,s){let[t,i]=(0,a.useState)(e);return(0,a.useEffect)(()=>{let t=setTimeout(()=>{i(e)},s);return()=>{clearTimeout(t)}},[e,s]),t}},18496:function(e,s,t){"use strict";t.r(s),t.d(s,{default:function(){return CampaignEdit}});var a=t(85893),i=t(5447),l=t(67294),n=t(11163);t(52133);var r=t(9473),d=t(39377);t(34110);var o=t(9008),c=t.n(o);t(11097);
1var m=t(94892),x=t(88894),u=t(87536),h=t(47953),g=t(41664),p=t.n(g),f=t(79659),j=t(72173),y=t(79719),b=t(97454),v=t(20445),N=t(74131),w=t(7105),C=t(50882),k=t(21809),S=t(43312),A=t(54510),T=t(71922),E=t(11355),Z=t(80100),_=t(52913),F=t(31038),M=t(5152),P=t.n(M),L=t(15016),I=t(58533),B=t(98523),D=t(31415),z=t(29227),R=t(13245),$=t(7266),O=t(84118);let V=[{name:"Prebuilt",value:"default"},{name:"Saved",value:"yours"}],TemplateCardSkeleton=()=>(0,a.jsx)("div",{className:"group relative bg-white rounded-lg border border-gray-200 overflow-hidden",children:(0,a.jsxs)("div",{className:"animate-pulse",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 bg-gray-50 border-b border-gray-200",children:[(0,a.jsx)("div",{className:"h-5 bg-gray-200 rounded w-48"}),(0,a.jsx)("div",{className:"h-4 bg-gray-200 rounded w-20"})]}),(0,a.jsx)("div",{className:"h-48 bg-gray-200"})]})}),EmptyState=e=>{let{searchQuery:s,selectedTab:t}=e;return(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center px-4",children:[(0,a.jsx)("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-gradient-to-br from-indigo-50 to-purple-50",children:(0,a.jsx)(B.Z,{className:"h-6 w-6 text-indigo-600"})}),(0,a.jsx)("h3",{className:"mt-3 text-base font-semibold text-gray-900",children:s?`No templates found for "${s}"`:`No ${t.name.toLowerCase()} templates`}),(0,a.jsx)("p",{className:"mt-1.5 text-sm text-gray-500 max-w-md",children:s?"Try searching with different keywords.":`Get started by exploring our ${"Prebuilt"===t.name?"prebuilt templates":"saved templates"}.`})]})};function CampaignTemplateList(e){let{editorType:s,onTemplateChange:t,goBack:i}=e,[n,d]=(0,l.useState)(V[0]),[o,c]=(0,l.useState)(""),u=(0,O.N)(o,500),[h,g]=(0,l.useState)([]),[p,f]=(0,l.useState)(!1),[j,y]=(0,l.useState)([]),[b,v]=(0,l.useState)(!1),N=(0,r.I0)(),w=(0,r.v9)(e=>e.templates.templatesData),C=(0,r.v9)(e=>e.templates.loading);async function loadCategories(){f(!0);let[e,s]=await (0,x.W)(m.Z.companies.categoryTags());s&&g(s.data||[]),f(!1)}async function loadTemplates(e){let{refresh:t}=e,a={per_page:20,page:1};t||(a={page:w.page+1,per_page:w.perPage||20});let i=n.value;"yours"==i&&(a.is_public=!1),i&&"default"!=i||(a.is_public=!0),a.editor_type=s,u&&(a.search=u),j.length>0&&(a.categories=j),N((0,L.pK)(a))}(0,r.v9)(e=>e.sessions.currentUser);let handleCategoryToggle=e=>{let s=j.includes(e)?j.filter(s=>s!==e):[...j,e];y(s)},clearFilters=()=>{y([])},handleTemplateSelect=e=>{t(e)};return(0,l.useEffect)(()=>{loadCategories()},[]),(0,l.useEffect)(()=>{loadTemplates({refresh:!0})},[n]),(0,l.useEffect)(()=>{(u||""===u)&&loadTemplates({refresh:!0})},[u]),(0,l.useEffect)(()=>{loadTemplates({refresh:!0})},[j]),(0,a.jsxs)("div",{className:"flex flex-col h-screen bg-white",children:[(0,a.jsxs)("div",{className:"bg-white border-b border-gray-200 sticky top-0 z-10 shadow-sm",children:[(0,a.jsx)("div",{className:"px-4 py-2.5 flex items-center justify-between",children:(0,a.jsxs)("button",{onClick:i,className:"flex items-center space-x-2 text-sm font-medium text-gray-600 hover:text-indigo-600 transition-colors duration-200 group",children:[(0,a.jsx)(_.Z,{className:"h-4 w-4"}),(0,a.jsx)("span",{children:"Back"})]})}),(0,a.jsx)("nav",{className:"flex border-t border-gray-200",children:V.map(e=>(0,a.jsx)("button",{type:"button",onClick:s=>{s.preventDefault(),d(e),c("")},className:function(){for(var e=arguments.length,s=Array(e),t=0;t<e;t++)s[t]=arguments[t];return s.filter(Boolean).join(" ")}(e.name===n.name?"border-indigo-500 text-indigo-600 bg-indigo-50":"border-transparent text-gray-600 hover:text-gray-800 hover:bg-gray-50","flex-1 border-b-2 py-3 px-4 text-center text-sm font-semibold transition-all duration-200"),children:e.name},e.name))})]}),(0,a.jsxs)("div",{className:"bg-white border-b border-gray-200",children:[(0,a.jsxs)("div",{className:"px-4 py-3",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:(0,a.jsx)($.Z,{className:"h-4 w-4 text-gray-400"})}),(0,a.jsx)("input",{type:"text",className:"block w-full pl-10 pr-10 py-2.5 border border-gray-300 rounded-lg leading-5 bg-white placeholder-gray-400 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition-all duration-200",placeholder:"Search templates...",value:o,onChange:e=>c(e.target.value)}),o&&(0,a.jsx)("button",{onClick:()=>{c("")},className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:(0,a.jsx)(D.Z,{className:"h-4 w-4 text-gray-400 hover:text-gray-600 transition-colors duration-200"})})]}),h&&h.length>0&&(0,a.jsxs)("button",{onClick:()=>v(!b),className:`mt-2.5 w-full flex items-center justify-between gap-1.5 px-3 py-2 rounded-lg border text-sm font-medium transition-all duration-200 ${j.length>0?"bg-indigo-50 text-indigo-700 border-indigo-200":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(z.Z,{className:"w-4 h-4"}),(0,a.jsx)("span",{children:"Filter by category"}),j.length>0&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 rounded-full bg-indigo-600 text-white text-xs font-semibold",children:j.length})]}),(0,a.jsx)(R.Z,{className:`w-4 h-4 transition-transform duration-200 ${b?"rotate-180":""}`})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between mt-2.5",children:[w.data.length>0&&!C&&(0,a.jsxs)("div",{className:"text-xs text-gray-500 font-medium",children:[w.total," ",1===w.total?"template":"templates"]}),j.length>0&&(0,a.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[j.map(e=>(0,a.jsxs)("button",{onClick:s=>{s.stopPropagation(),handleCategoryToggle(e)},className:"group inline-flex items-center gap-1 px-2 py-1 rounded-md bg-indigo-50 hover:bg-indigo-100 border border-indigo-200 text-xs font-medium text-indigo-700 transition-all duration-200","aria-label":`Remove ${e} filter`,children:[(0,a.jsx)("span",{className:"truncate max-w-[100px]",children:e}),(0,a.jsx)(D.Z,{className:"w-3 h-3 text-indigo-600 group-hover:text-indigo-700 flex-shrink-0"})]},e)),j.length>0&&(0,a.jsx)("button",{onClick:clearFilters,className:"text-xs text-gray-500 hover:text-gray-700 font-medium px-2 py-1",children:"Clear all"})]})]})]}),b&&h&&h.length>0&&(0,a.jsx)("div",{className:"px-4 pb-3 border-t border-gray-100 bg-gray-50",children:(0,a.jsxs)("div",{className:"pt-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsx)("h3",{className:"text-xs font-semibold text-gray-900 uppercase tracking-wider",children:"Filter by category"}),j.length>0&&(0,a.jsx)("button",{onClick:clearFilters,className:"text-xs text-gray-500 hover:text-gray-700 font-medium transition-colors duration-150",children:"Clear"})]}),(0,a.jsx)("div",{className:"space-y-3",children:(0,a.jsx)("div",{className:"space-y-1",children:h.map(e=>{let s=j.includes(e.name);return(0,a.jsxs)("button",{onClick:()=>handleCategoryToggle(e.name),className:`w-full group flex items-center justify-between px-2.5 py-2 rounded-md text-sm transition-all duration-200 ${s?"bg-indigo-50 text-indigo-700 font-medium":"text-gray-700 hover:bg-gray-50 hover:text-gray-900"}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 flex-1 min-w-0",children:[(0,a.jsx)("span",{className:`inline-flex items-center justify-center w-3.5 h-3.5 rounded border-2 transition-all duration-200 flex-shrink-0 ${s?"bg-indigo-600 border-indigo-600":"bg-white border-gray-300 group-hover:border-indigo-400"}
1`,children:s&&(0,a.jsx)("svg",{className:"w-2 h-2 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}),(0,a.jsx)("span",{className:"truncate font-normal text-sm",children:e.name})]}),(0,a.jsx)("span",{className:`ml-2 px-1.5 py-0.5 rounded text-xs font-medium transition-all duration-200 flex-shrink-0 ${s?"bg-indigo-100 text-indigo-700":"text-gray-500 group-hover:text-gray-700"}`,children:e.count})]},e.id)})})})]})})]}),(0,a.jsx)("div",{className:"flex-1 overflow-hidden",children:C&&0===w.data.length?(0,a.jsx)("div",{className:"p-4",children:(0,a.jsx)("div",{className:"flex flex-col gap-3",children:[...Array(8)].map((e,s)=>(0,a.jsx)(TemplateCardSkeleton,{},s))})}):0!==w.data.length||C?(0,a.jsx)("div",{id:"scrollableContainer",className:"h-full overflow-y-auto px-4 py-4",children:(0,a.jsx)(I.Z,{next:()=>loadTemplates({refresh:!1}),dataLength:w.data.length,scrollableTarget:"scrollableContainer",hasMore:!C&&w.data.length!=w.total,loader:(0,a.jsx)("div",{className:"flex flex-col gap-3 my-4",children:[void 0,void 0,void 0].map((e,s)=>(0,a.jsx)(TemplateCardSkeleton,{},`loading-${s}`))}),children:(0,a.jsx)("ul",{className:"flex flex-col gap-4",children:w.data.map(e=>(0,a.jsxs)("li",{className:"group relative bg-white rounded-lg border border-gray-200 overflow-hidden transition-all duration-200 hover:border-indigo-500 hover:shadow-lg cursor-pointer",onClick:()=>handleTemplateSelect(e),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 bg-gray-50 border-b border-gray-200",children:[(0,a.jsx)("h3",{className:"text-base font-semibold text-gray-900 group-hover:text-indigo-600 transition-colors duration-200",children:e.name}),(0,a.jsx)("span",{className:"text-indigo-600 opacity-0 group-hover:opacity-100 transition-opacity duration-200 text-sm font-medium whitespace-nowrap",children:"Select →"})]}),(0,a.jsx)("div",{className:"relative bg-gray-100 flex items-center justify-center overflow-hidden",style:{height:"200px"},children:e.pictureUrl?(0,a.jsx)("img",{src:e.pictureUrl,alt:e.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):(0,a.jsx)(B.Z,{className:"h-16 w-16 text-gray-300"})})]},e.id))})})}):(0,a.jsx)(EmptyState,{searchQuery:o,selectedTab:n})})]})}var U=t(74855),W=t(18357),H=t(29921),Q=t(7658);function CancelEditTemplateConfirmModal_CreateCampaignModal(e){let{open:s=!1,setOpen:t,onClose:i}=e,closeModal=()=>{t(!1)},handleLeave=()=>{i(),closeModal()};return(0,a.jsx)(E.u.Root,{show:s,as:l.Fragment,children:(0,a.jsxs)(Z.V,{as:"div",className:"relative z-10",onClose:closeModal,children:[(0,a.jsx)(E.u.Child,{as:l.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"})}),(0,a.jsx)("div",{className:"fixed inset-0 z-10 overflow-y-auto",children:(0,a.jsx)("div",{className:"flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0",children:(0,a.jsx)(E.u.Child,{as:l.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",children:(0,a.jsxs)(Z.V.Panel,{className:"relative w-1/3 transform rounded-lg bg-white text-left shadow-xl transition-all",children:[(0,a.jsx)("div",{className:"absolute right-0 top-0 hidden pr-4 pt-4 sm:block",children:(0,a.jsxs)("button",{type:"button",className:"rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",onClick:()=>t(!1),children:[(0,a.jsx)("span",{className:"sr-only",children:"Close"}),(0,a.jsx)(D.Z,{className:"h-6 w-6","aria-hidden":"true"})]})}),(0,a.jsxs)("div",{className:"bg-white shadow sm:rounded-lg",children:[(0,a.jsxs)("div",{className:"px-4 py-5 sm:px-6",children:[(0,a.jsx)("h3",{className:"mb-5 flex space-x-2 text-lg font-semibold leading-6 text-gray-900",children:"Are you sure you want to leave?"}),(0,a.jsx)("p",{className:"mt-1 max-w-2xl text-sm text-gray-500",children:"You have some unsaved changes. You will lose them if you leave."})]}),(0,a.jsx)("div",{className:"border-t border-gray-200 px-4 py-5 sm:px-6",children:(0,a.jsxs)("div",{className:"flex justify-end",children:[(0,a.jsx)(j.zx,{onClick:()=>t(!1),className:"mr-2",variant:"outline",children:"Cancel"}),(0,a.jsx)(j.zx,{onClick:()=>handleLeave(),className:"ml-2",variant:"primary",children:"Yes, leave"})]})})]})]})})})})]})})}var q=t(17105),G=t(85384),Y=t(38397);let J=P()(()=>Promise.all([t.e(4607),t.e(2220)]).then(t.bind(t,62220)),{loadableGenerated:{webpack:()=>[62220]},ssr:!1}),K=P()(()=>Promise.all([t.e(6235),t.e(2589)]).then(t.bind(t,82589)),{loadableGenerated:{webpack:()=>[82589]},ssr:!1});function CampaignEditorModal(e){let{open:s=!1,setOpen:t,campaign:i,editorType:r,setEditorType:d,setHtmlBody:o,isSaving:c}=e,[u,h]=(0,l.useState)([]);(0,l.useEffect)(()=>{let fetchCompanyCustomFields=async()=>{let[e,s]=await (0,x.W)(m.Z.customFields.companyCustomFields());if(s?.data){let e=s.data.filter(e=>e?.mergeTag).map(e=>({label:e.mergeTag,tag:e.mergeTag}));h(e)}};fetchCompanyCustomFields()},[]);let g=u.length>0?u:i.customFields||[],p=[{label:"Title",tag:"title"},{label:"First Name",tag:"first_name"},{label:"Last Name",tag:"last_name"},{label:"Email",tag:"email"},{label:"Designation",tag:"designation"},{label:"Phone number",tag:"phone_number"},...g,{label:"Company",tag:"company"},{label:"Company address",tag:"company_address"},{label:"Company address in one line",tag:"company_address_line"},{label:"Unsubscribe link",tag:"unsubscribe_link"}],[f,j]=(0,l.useState)(i.htmlBody),[y,b]=(0,l.useState)(i.designJson),[v,N]=(0,l.useState)(0),[w,C]=(0,l.useState)(-1),[k,S]=(0,l.useState)(!1),[A,T]=(0,l.useState)(!1),[_,F]=(0,l.useState)(!1);function onEditorChange(e,s){b(s),j(e),T(!0)}async function saveBodyAndDesign(){await o(f,y),T(!1),leaveModal()}let closeModal=()=>{if(A){F(!0);return}leaveModal()},leaveModal=()=>{T(!1),N(0),t(!1)},M=(0,n.useRouter)();return(0,a.jsx)(E.u.Root,{show:s,as:l.Fragment,children:(0,a.jsxs)(Z.V,{as:"div",className:"relative z-10",onClose:closeModal,children:[(0,a.jsx)(CancelEditTemplateConfirmModal_CreateCampaignModal,{open:_,setOpen:F,onClose:leaveModal}),(0,a.jsx)(E.u.Child,{as:l.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"})}),(0,a.jsx)("div",{className:"fixed inset-0 z-10 overflow-y-auto",children:(0,a.jsx)("div",{className:"flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0",children:(0,a.jsx)(E.u.Child,{as:l.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",children:(0,a.jsxs)(Z.V.Panel,{className:"relative h-screen transform overflow-hidden rounded-lg bg-white pb-4 pt-5 text-left shadow-xl transition-all sm:w-full",children:[(0,a.jsxs)("div",{className:"absolute right-0 top-0 flex space-x-2 pr-4 pt-4",children:[(0,a.jsx)("button",{href:"#",onClick:()=>closeModal(),className:"inline-flex items-center justify-center px-4 py-2 text-sm font-bold text-indigo-600 underline decoration-dashed underline-offset-4 focus:outline-none sm:w-auto",children:"Cancel"}),(0,a.jsx)("button",{type:"button",onClick:()=>S(!k),className:"inline-flex items-center justify-center rounded-md border border-indigo-600 bg-white px-4 py-2 text-sm font-medium text-indigo-600 hover:bg-indigo-700 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:w-auto",children:k?"Exit preview":"Preview"}),(0,a.jsx)("button",{type:"button",onClick:saveBodyAndDesign,disabled:c,
1className:"inline-flex items-center justify-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:w-auto",children:c?(0,a.jsx)(H.g4,{height:"24",width:"30",color:"#ffffff"}):"Save & Continue ->"})]}),(0,a.jsx)("div",{className:"border-b pb-5",children:(0,a.jsx)("div",{className:"px-6 sm:flex sm:items-start",children:(0,a.jsxs)("div",{className:"mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left",children:[(0,a.jsx)(Z.V.Title,{as:"h3",className:"text-base font-semibold leading-none text-gray-900",children:i?.name}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)("p",{className:"text-sm leading-none text-gray-500",children:i?.subject})})]})})}),(0,a.jsxs)("div",{className:"sm:grid sm:grid-cols-12",children:[(0,a.jsx)(LeftPanel,{editorType:r,onTemplateChange:function(e){j(e.htmlBody),b(e.designJson),d(e.editorType),N(e=>e+1),T(!0)},DefaultFields:p,copiedIndex:w,handleCopy:function(e){C(e),setTimeout(()=>{C(-1)},1e3)},campaign:i,onDiscardTemplate:function(){j(i.htmlBody),b(i.designJson)},setEditorType:d}),(0,a.jsx)("div",{className:`h-screen overflow-scroll ${"ai_editor"==M.query.currentNav?"sm:col-span-8":"sm:col-span-10"}`,children:(0,a.jsx)("div",{className:"mt-5 pb-[100px]",children:k?(0,a.jsx)(W.Z,{body:f}):"html"==r?(0,a.jsx)("div",{className:"px-6",children:(0,a.jsx)(K,{onChange:onEditorChange,data:f,count:v})}):(0,a.jsx)(J,{onChange:onEditorChange,data:f,design:y,count:v,customFields:g})},v)})]})]})})})})]})})}let MergeTags=e=>{let{editorType:s,copiedIndex:t,DefaultFields:i,goBack:l,handleCopy:n}=e;return(0,a.jsxs)("div",{className:"",children:[(0,a.jsxs)("div",{className:"flex cursor-pointer space-x-3 bg-indigo-50 p-[15px]",onClick:l,children:[(0,a.jsx)(_.Z,{className:"h-6 w-6 text-indigo-500"}),(0,a.jsxs)("span",{className:"text-sm font-semibold text-indigo-500",children:["Main Menu"," "]})]}),(0,a.jsxs)("div",{className:"px-4 pt-6 pb-3 text-xs",children:["Personalize with merge tags"," ",(0,a.jsx)("span",{className:"text-gray-400",children:"(click to copy)"})]}),i.map((e,s)=>(0,a.jsx)("div",{className:`${s%2!=0?"bg-gray-50":""}`,children:(0,a.jsxs)("div",{className:"px-4 py-3",children:[(0,a.jsxs)("div",{className:"mt-1 text-sm text-indigo-600 transition delay-300 ease-in-out hover:cursor-pointer  hover:font-semibold sm:col-span-2 sm:mt-0",children:[(0,a.jsx)(U.CopyToClipboard,{text:`{{{${e.tag}}}}`,onCopy:()=>n(s),children:(0,a.jsxs)("span",{children:[`{{{${e.tag}}}}`," "]})})," ",t==s&&(0,a.jsx)("span",{className:"text-gray-400",children:"copied!"})]}),(0,a.jsx)("div",{className:"text-xs font-medium text-gray-500",children:e.label})]})},e.tag))]})},X=[{name:"Templates",href:"#",current:!1,label:"Templates",beta:!1},{name:"ai_editor",href:"#",current:!1,label:"AI Editor",beta:!0},{name:"Merge Tags",href:"#",current:!1,label:"Merge Tags",beta:!1}];function LeftPanel(e){let{editorType:s,onTemplateChange:t,DefaultFields:i,copiedIndex:d,handleCopy:o,campaign:c,onDiscardTemplate:m,setEditorType:x}=e,[u,h]=(0,l.useState)("Main"),g=(0,r.v9)(e=>e.sessions.currentUser.company),[p,f]=(0,l.useState)(!1),goBack=()=>{h("Main")},j=(0,n.useRouter)(),setCurrentNav=e=>{if("ai_editor"==e&&("free"==g.plan.slug||"free-regular"==g.plan.slug)){f(!0);return}h(e),j.push({query:{...j.query,currentNav:e}})};return(0,a.jsxs)("div",{className:`h-screen overflow-scroll border pb-[100px] ${"ai_editor"==u?"sm:col-span-4 ":"sm:col-span-2"}`,children:[(0,a.jsx)(q.Z,{open:p,setOpen:f,subHeading:"Upgrade your plan to use AI editor"}),"Templates"==u?(0,a.jsx)(CampaignTemplateList,{goBack:goBack,onTemplateChange:t}):null,"Merge Tags"==u?(0,a.jsx)(MergeTags,{goBack:goBack,handleCopy:o,editorType:s,DefaultFields:i,copiedIndex:d}):null,"ai_editor"==u?(0,a.jsx)(AiFormPane,{onDiscardTemplate:m,goBack:goBack,campaign:c,onTemplateChange:t,setEditorType:x}):null,"Main"==u?(0,a.jsxs)("nav",{className:"flex w-full flex-col","aria-label":"Sidebar",children:[(0,a.jsx)("div",{className:"flex cursor-pointer space-x-3 bg-indigo-50 p-[15px]",children:(0,a.jsxs)("span",{className:"text-sm font-semibold text-indigo-500",children:["Main Menu"," "]})}),(0,a.jsx)("ul",{role:"list",className:"w-full space-y-1 ",children:X.map(e=>(0,a.jsx)("li",{children:(0,a.jsxs)("a",{onClick:()=>setCurrentNav(e.name),href:e.href,className:function(){for(var e=arguments.length,s=Array(e),t=0;t<e;t++)s[t]=arguments[t];
1return s.filter(Boolean).join(" ")}(e.current?"bg-gray-50 text-indigo-600":"text-gray-700 hover:bg-gray-50 hover:text-indigo-600","group flex items-center gap-x-3 rounded-md p-2 pl-3 text-sm font-semibold leading-6"),children:[e.label," ",e.beta&&(0,a.jsx)("span",{className:"inline-flex items-center rounded-md bg-yellow-100 px-2 py-1 text-xs font-medium text-yellow-800",children:"Beta"}),(0,a.jsx)(F.Z,{className:"ml-auto h-5 w-5 text-gray-400 group-hover:text-gray-500","aria-hidden":"true"})]})},e.name))})]}):null]})}let AiFormPane=e=>{let{goBack:s,campaign:t,onTemplateChange:i,onDiscardTemplate:r,setEditorType:d}=e,[o,c]=(0,l.useState)([]),[u,h]=(0,l.useState)(!1),[g,p]=(0,l.useState)(null),[f,j]=(0,l.useState)("promptList"),y=(0,n.useRouter)(),fetchPrompts=async()=>{let[e,s]=await (0,x.W)(m.Z.promptTemplates.index());s&&(c(s.data),h(!0))};return(0,l.useEffect)(()=>{fetchPrompts()},[]),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex cursor-pointer space-x-3 bg-indigo-50 p-[15px]",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-3 bg-indigo-50",onClick:s,children:[(0,a.jsx)(_.Z,{className:"h-3 w-3 text-indigo-500"}),(0,a.jsxs)("span",{className:"text-sm font-semibold text-indigo-500",children:["Main Menu"," "]})]}),"promptForm"==f||"promptList"==f?(0,a.jsxs)("div",{className:"flex space-x-3 bg-indigo-50",onClick:()=>{"promptForm"==f&&(j("promptList"),p(null))},children:[(0,a.jsx)(F.Z,{className:"h-6 w-6 text-indigo-500"}),(0,a.jsx)("span",{className:`text-sm font-semibold ${"promptForm"==f?"text-indigo-500":"text-gray-600"}`,children:"Select Prompt"})]}):null,"promptForm"==f?(0,a.jsxs)("div",{className:"flex space-x-3 bg-indigo-50",children:[(0,a.jsx)(F.Z,{className:"h-6 w-6 text-indigo-500"}),(0,a.jsx)("span",{className:"text-sm font-semibold text-gray-500",children:"Edit Prompt"})]}):null]}),"promptList"==f?(0,a.jsx)(G.Z,{prompts:o,onSelect:e=>{p(e),j("promptForm"),y.push({query:{...y.query,prompt:e.id}})}}):null,"promptForm"==f?(0,a.jsx)(Y.Z,{prompt:g,campaign:t,onTemplateChange:i,onDiscardTemplate:r,setEditorType:d}):null]})};var ee=t(42574),es=t(77015);function EditorTypeModal(e){let{open:s=!1,setOpen:t,setEditorTypeAndOpenEditor:i}=e;(0,r.I0)(),(0,n.useRouter)();let closeModal=()=>{t(!1)},openEditor=e=>{closeModal(),i(e)};return(0,l.useEffect)(()=>{},[]),(0,a.jsx)(E.u.Root,{show:s,as:l.Fragment,children:(0,a.jsxs)(Z.V,{as:"div",className:"relative z-10",onClose:closeModal,children:[(0,a.jsx)(E.u.Child,{as:l.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"})}),(0,a.jsx)("div",{className:"fixed inset-0 z-10 overflow-y-auto",children:(0,a.jsx)("div",{className:"flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0",children:(0,a.jsx)(E.u.Child,{as:l.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",children:(0,a.jsxs)(Z.V.Panel,{className:"relative w-1/3 transform rounded-lg bg-white text-left shadow-xl transition-all",children:[(0,a.jsx)("div",{className:"absolute right-0 top-0 hidden pr-4 pt-4 sm:block",children:(0,a.jsxs)("button",{type:"button",className:"rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",onClick:()=>t(!1),children:[(0,a.jsx)("span",{className:"sr-only",children:"Close"}),(0,a.jsx)(D.Z,{className:"h-6 w-6","aria-hidden":"true"})]})}),(0,a.jsxs)("div",{className:"bg-white shadow sm:rounded-lg",children:[(0,a.jsxs)("div",{className:"px-4 py-5 sm:px-6",children:[(0,a.jsx)("h3",{className:"flex space-x-2 text-lg font-semibold leading-6 text-gray-900",children:(0,a.jsx)("div",{children:"Choose your editor"})}),(0,a.jsx)("p",{className:"mt-1 max-w-2xl text-sm text-gray-500",children:"Choose the editor you want to use to create your email design with."})]}),(0,a.jsx)("div",{className:"border-t border-gray-200 px-4 py-5 sm:px-6",children:(0,a.jsxs)("div",{className:"flex justify-center space-x-4",children:[(0,a.jsxs)("div",{onClick:()=>openEditor("dragndrop"),className:"flex cursor-pointer flex-col items-center rounded-md border px-6 py-8 hover:border-indigo-600",children:[(0,a.jsx)("div",{className:"mb-2",children:(0,a.jsx)(ee.Z,{className:"h-10 w-10 text-indigo-600"})}),(0,a.jsx)("div",{className:"font-semibold text-gray-600",children:"Drag n Drop"})]}),(0,a.jsxs)("div",{onClick:()=>openEditor("html"),className:"flex cursor-pointer flex-col items-center rounded-md border px-6 py-8 hover:border-indigo-600",children:[(0,a.jsx)("div",{className:"mb-2",children:(0,a.jsx)(es.Z,{className:"h-10 w-10 text-indigo-600"})}),(0,a.jsx)("div",{className:"font-semibold text-gray-600",children:"HTML editor"})]})]})})]})]})})})})]})})}var et=t(28368),ea=t(93496),ei=t(86083),el=t(35443),en=t(70178),er=t(31676),ed=t(82975),eo=t(39145),ec=t(43863),em=t(76878),ex=t(73268);function SendModal(e){let{open:s=!1,setOpen:t,campaign:i,deliverNow:d,setCampaign:o}
1=e,[c,u]=(0,l.useState)({startDate:new Date,endDate:new Date}),[g,p]=(0,l.useState)(!1),[y,b]=(0,l.useState)(!1);(0,r.I0)();let[v,N]=(0,l.useState)(!0),[k,S]=(0,l.useState)(!0),[A,T]=(0,l.useState)(!0),[_,F]=(0,l.useState)(!0),[M,P]=(0,l.useState)(i.utmParams?.utm_source),[L,I]=(0,l.useState)(i.utmParams?.utm_medium),[B,z]=(0,l.useState)(i.utmParams?.utm_campaign),[R,$]=(0,l.useState)(i.utmParams?.utm_content),[O,V]=(0,l.useState)(i.utmParams?.utm_term),U=(0,r.v9)(e=>e.sessions.currentUser),[W,H]=(0,l.useState)(ei.Z.find(e=>e.name==Intl.DateTimeFormat().resolvedOptions().timeZone)),[Q,q]=(0,l.useState)(null),G=(0,n.useRouter)(),handleDateChange=e=>{u(e)},[Y,J]=(0,l.useState)(el.Z[0]),[K,X]=(0,l.useState)(null),[ee,es]=(0,l.useState)(!1),eu=[0,15,30,45],minTime=function(){let e=new Date,s=e.getHours(),t=e.getMinutes(),a="00";for(let e=0;e<eu.length;e++)if(t<eu[e]){a=eu[e];break}return{hour:s,minute:a,str:`${s}:${a}`}};async function saveCampaign(){b(!0);let e={schedule_time:null,schedule_date:null,sending_limit:K,limit_increase:Y?.value,track_open:k,track_click:A,track_ganalytics_link:_,exclude_weekends:ee};_&&(e.utm_params={utm_source:M||null,utm_medium:L||null,utm_campaign:B||null,utm_content:R||null,utm_term:O||null}),"later"==d&&(e.schedule_time=`${Q}:00`,e.schedule_date=(0,ea._3)(c.startDate,"yyyy-MM-dd"),e.timezone=W?.value);let s=null;s=m.Z.campaigns.start(i.id,e);let[t,a]=await (0,x.W)(s);b(!1),a&&G.push(`/campaigns/${a.data.id}`),closeModal()}function handleLimitChange(e){J(e)}(0,l.useEffect)(()=>{u({startDate:new Date,endDate:new Date}),q(minTime().str),J(el.Z[0]),es(!1),X(null),S(!0),T(!0),F(i?.trackGanalyticsLink!==!1),P(i?.utmParams?.utm_source||U?.company?.name||""),I(i?.utmParams?.utm_medium||"email"),z(i?.utmParams?.utm_campaign||i?.name||""),$(i?.utmParams?.utm_content||""),V(i?.utmParams?.utm_term||""),H(ei.Z.find(e=>e.name==Intl.DateTimeFormat().resolvedOptions().timeZone))},[d]),(0,l.useEffect)(()=>{i?.utmParams?(i.utmParams.utm_campaign?z(i.utmParams.utm_campaign):i?.name&&z(i.name),i.utmParams.utm_source?P(i.utmParams.utm_source):U?.company?.name&&P(U.company.name),i.utmParams.utm_medium&&I(i.utmParams.utm_medium),i.utmParams.utm_content&&$(i.utmParams.utm_content),i.utmParams.utm_term&&V(i.utmParams.utm_term)):(i?.name&&z(i.name),U?.company?.name&&P(U.company.name))},[i?.utmParams,i?.name,U?.company?.name]),(0,l.useEffect)(()=>{N(function(){let e={timezone:W?.name},s=(t=(0,ea._3)(c.startDate,"yyyy-MM-dd")+"T"+`${Q}:00`+W?.value,new Date(t).toString());var t,a=new Date(s);let i=new Date(new Date().toLocaleString("en-US",e));return a.getTime()>=i.getTime()}())},[Q,W,c]);let closeModal=()=>{t(!1)};return(0,a.jsx)(E.u.Root,{show:s,as:l.Fragment,children:(0,a.jsxs)(Z.V,{as:"div",className:"relative z-10",onClose:closeModal,children:[(0,a.jsx)(E.u.Child,{as:l.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"})}),(0,a.jsx)("div",{className:"fixed inset-0 z-10 overflow-y-auto",children:(0,a.jsx)("div",{className:"flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0",children:(0,a.jsx)(E.u.Child,{as:l.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",children:(0,a.jsxs)(Z.V.Panel,{className:"relative w-full max-w-2xl transform rounded-lg bg-white text-left shadow-xl transition-all max-h-[90vh] flex flex-col",children:[(0,a.jsx)("div",{className:"absolute right-0 top-0 z-10 pr-4 pt-4",children:(0,a.jsxs)("button",{type:"button",className:"rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",onClick:()=>t(!1),children:[(0,a.jsx)("span",{className:"sr-only",children:"Close"}),(0,a.jsx)(D.Z,{className:"h-6 w-6","aria-hidden":"true"})]})}),(0,a.jsxs)("div",{className:"bg-white shadow sm:rounded-lg flex flex-col max-h-[90vh]",children:[(0,a.jsxs)("div",{className:"px-4 py-5 sm:px-6 flex-shrink-0",children:[(0,a.jsx)("h3",{className:"mb-2 flex space-x-2 text-lg font-semibold leading-6 text-gray-900",children:"later"==d?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(w.Z,{className:"h-6 w-6 text-indigo-600","aria-hidden":"true"})," ",(0,a.jsx)("div",{children:"Send later"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(C.Z,{className:"h-6 w-6 text-indigo-600","aria-hidden":"true"})," ",(0,a.jsx)("div",{children:"Send now"})]})}),(0,a.jsx)("p",{className:"max-w-2xl text-sm text-gray-500",children:"later"==d?"Schedule your campaign to be sent at a later date and time.":"Send your campaign now."})]}),(0,a.jsxs)("div",{className:"border-t border-gray-200 flex flex-col flex-1 min-h-0",children:[(0,a.jsx)("div",{className:"px-4 py-5 sm:px-6 overflow-y-auto flex-1",children:(0,a.jsxs)("div",{className:"mb-6",children:["later"==d?(0,a.jsxs)("div",{className:"mb-8",children:[(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsxs)("div",{className:"mr-5",children:[(0,a.jsx)("label",{htmlFor:"deliveryDate",className:"block text-sm font-medium text-gray-500",children:"Delivery date"}),(0,a.jsx)(er.ZP,{id:"deliveryDate",value:c,displayFormat:"DD-MM-YYYY",onChange:e=>handleDateChange(e),asSingle:!0,useRange:!1,name:"deliveryDate",placeholder:"Select a delivery  date",inputClassName:"dark:bg-white dark:text-gray-800 dark:border-gray-300 border-white-300 py-2 px-4 roun
1ded-lg w-full"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(ed.Z,{hour:Q?Q.split(":")[0]:"00",minute:Q?Q.split(":")[1]:"00",onInput:e=>{q(e)}}),v?"":(0,a.jsxs)("p",{className:"mt-2 text-sm text-red-600",children:[" ","Please set a time in future"," "]})]})]}),(0,a.jsx)("div",{className:"mt-5",children:(0,a.jsx)(en.Z,{label:"Timezone",value:W,options:ei.Z,onSelect:function(e){H(e)}})})]}):"",(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.jsx)("div",{className:"divide-y divide-gray-900/10",children:(0,a.jsx)("dl",{className:"space-y-6 divide-y divide-gray-900/10",children:(0,a.jsx)(et.p,{as:"div",children:e=>{let{open:s}=e;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("dt",{children:(0,a.jsxs)(et.p.Button,{className:"flex w-full items-start justify-between text-left text-gray-900",children:[(0,a.jsxs)("span",{className:"text-xs font-semibold leading-7",children:["Advanced settings"," ",(0,a.jsx)("span",{className:"text-xs text-gray-400",children:"(optional)"})]}),(0,a.jsx)("span",{className:"ml-6 flex h-7 items-center",children:s?(0,a.jsx)(ec.Z,{className:"h-6 w-6","aria-hidden":"true"}):(0,a.jsx)(em.Z,{className:"h-6 w-6","aria-hidden":"true"})})]})}),(0,a.jsx)(et.p.Panel,{as:"dd",className:"mt-2",children:(0,a.jsx)("div",{className:"text-base leading-7 text-gray-600",children:(0,a.jsxs)("div",{className:"p-6",children:[(0,a.jsx)(f.B,{enabled:k,setEnabled:S,className:"mb-7",label:"Open tracking",subLabel:"Track who opened your email  and at what time."}),(0,a.jsx)(f.B,{enabled:A,setEnabled:T,className:"mb-7",label:"Click tracking",subLabel:"Track which links were clicked and at what time."}),(0,a.jsx)(f.B,{enabled:_,setEnabled:F,className:"mb-7",label:"Google analytics link tracking",subLabel:"Add google analytics link in your mails"})]})})})]})}})})}),_&&(0,a.jsx)("div",{className:"divide-y divide-gray-900/10 mt-6",children:(0,a.jsx)("dl",{className:"space-y-6 divide-y divide-gray-900/10",children:(0,a.jsx)(et.p,{as:"div",children:e=>{let{open:s}=e;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("dt",{children:(0,a.jsxs)(et.p.Button,{className:"flex w-full items-start justify-between text-left text-gray-900",children:[(0,a.jsxs)("span",{className:"text-xs font-semibold leading-7",children:["UTM Parameters"," ",(0,a.jsx)("span",{className:"text-xs text-gray-400",children:"(for Google Analytics tracking)"})]}),(0,a.jsx)("span",{className:"ml-6 flex h-7 items-center",children:s?(0,a.jsx)(ec.Z,{className:"h-6 w-6","aria-hidden":"true"}):(0,a.jsx)(em.Z,{className:"h-6 w-6","aria-hidden":"true"})})]})}),(0,a.jsx)(et.p.Panel,{as:"dd",className:"mt-2",children:(0,a.jsx)("div",{className:"text-base leading-7 text-gray-600",children:(0,a.jsxs)("div",{className:"p-6",children:[(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-indigo-200 bg-indigo-50 p-3",children:(0,a.jsxs)("p",{className:"text-xs text-indigo-800",children:[(0,a.jsx)("strong",{children:"Google Analytics tracking is enabled."})," Configure UTM parameters to track campaign performance in Google Analytics."]})}),(0,a.jsx)("div",{className:"mt-4 space-y-4",children:(0,a.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:["UTM Source ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-2",children:"Identifies which site sent the traffic (e.g., company name, newsletter)"}),(0,a.jsx)(h.Z,{name:"utmSource",type:"text",placeholder:"e.g., CampaignHQ",value:M,onChange:e=>{P(e)}})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:["UTM Medium ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-2",children:"Identifies what type of link was used (e.g., email, cpc, banner)"}),(0,a.jsx)(h.Z,{name:"utmMedium",type:"text",placeholder:"e.g., email",value:L,onChange:e=>{I(e)}})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:["UTM Campaign ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-2",children:"Identifies a specific product promotion or strategic campaign"}),(0,a.jsx)(h.Z,{name:"utmCampaign",type:"text",placeholder:"e.g., spring-sale",value:B,onChange:e=>{z(e)}})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:["UTM Content ",(0,a.jsx)("span",{className:"text-gray-400 text-xs",children:"(optional)"})]}),(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-2",children:"Identifies what specifically was clicked (e.g., logo link, text link)"}),(0,a.jsx)(h.Z,{name:"utmContent",type:"text",placeholder:"e.g., newsletter-link",value:R,onChange:e=>{$(e)}})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:["UTM Term ",(0,a.jsx)("span",{className:"text-gray-400 text-xs",children:"(optional)"})]}),(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-2",children:"Identifies search keywords (typically used for paid search)"}),(0,a.jsx)(h.Z,{name:"utmTerm",type:"text",placeholder:"e.g., running shoes",value:O,onChange:e=>{V(e)}})]})]})})]})})})]})}})})}),(0,a.jsx)("div",{className:"divide-y divide-gray-900/10 mt-6",children:(0,a.jsx)("dl",{className:"space-y-6 divide-y divide-gray-900/10",children:(0,a.jsx)(et.p,{as:"div",children:e=>{let{open:s}=e;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("dt",{children:(0,a.jsxs)(et.p.Button,{className:"flex w-full items-center justify-between text-left text-gray-900",children:[(0,a.jsxs)("div",{className:"flex items-center text-xs font-semibold leading-7",children:[U?.company?.plan?.freePlan?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("a",{"data-tooltip-id":"warmup-lock",className:"mr-1.5 inline-block cursor-pointer",children:(0,a.jsx)(ex.Z,{className:"h-5 w-5 text-red-600"})}),(0,a.jsx)(eo.u,{id:"warmup-lock",place:"left",children:"Not available in free plan"})]}):null,"Domain / IP warm-up settings",U?.company?.plan?.freePlan?null:(0,a.jsx)("span",{className:"ml-2 text-xs text-gray-400",children:"(optional)"})]}),(0,a.jsx)("span",{className:"ml-6 flex h-7 items-center",children:s?(0,a.jsx)(ec.Z,{className:"h-6 w-6","aria-hidden":"true"}):(0,a.jsx)(em.Z,{className:"h-6 w-6","aria-hidden":"true"})})]})}),(0,a.jsx)(et.p.Panel,{as:"dd",className:"mt-2",children:(0,a.jsx)("div",{className:"text-base leading-7 text-gray-600",children:(0,a.jsx)("div",{className:"mb-10 p-6",children:(0,a.jsxs)("div",{className:"mb-2",children:[(0,a.jsx)("div",{className:"mb-2",children:"Start with"}),(0,a.jsx)(h.Z,{name:"sendingLimit",type:"number",placeholder:"Ex: Start with small number of emails and increase",value:K,onChange:e=>{X(e)},disabled:U?.company?.plan?.freePlan}),(0,a.jsx)("div",{className:"my-2",children:"emails and increase"}),(0,a.jsx)(en.Z,{name:"list",options:el.Z,value:Y,onSelect:handleLimitChange,disabled:U?.company?.plan?.freePlan}),(0,a.jsx)("div",{className:"my-2",children:"daily."}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("input",{id:"excludeWeekends",name:"excludeWeekends",type:"checkbox",className:"h-4 w-4 roun
1ded border-gray-300 text-indigo-600 focus:ring-indigo-600",checked:ee,onChange:e=>{es(e.target.checked)}}),(0,a.jsx)("label",{htmlFor:"excludeWeekends",className:"ml-2 block text-sm text-gray-900",children:"Exclude weekends"})]})]})})})})]})}})})})]})]})}),(0,a.jsx)("div",{className:"px-4 py-4 sm:px-6 flex justify-end flex-shrink-0 border-t border-gray-200 bg-white",children:(0,a.jsx)(j.zx,{loading:y,disabled:i.scheduleDate&&!v,onClick:saveCampaign,children:"later"==d?"Schedule":"Send ->"})})]})]})]})})})})]})})}var eu=t(75131),eh=t(23),eg=t(78916),ep=t(45350);let ContactOption=e=>(0,a.jsx)(ep.c.Option,{...e,children:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"block truncate",children:(0,a.jsx)("span",{children:e.data.label})}),(0,a.jsx)("div",{className:"text-xs text-gray-500",children:e.data.email})]})}),ContactMultiValueLabel=e=>(0,a.jsx)(ep.c.MultiValueLabel,{...e,children:(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("span",{className:"text-sm",children:e.data.label}),e.data.email&&(0,a.jsx)("span",{className:"text-xs text-gray-600",children:e.data.email})]})});function TestCampaignModal(e){let{open:s=!1,setOpen:t,campaignId:i}=e,[n,r]=(0,l.useState)(!1),[d,o]=(0,l.useState)(null),[c,u]=(0,l.useState)("list"),[h,g]=(0,l.useState)([]),[f,y]=(0,l.useState)(null),[b,v]=(0,l.useState)(!1);(0,l.useEffect)(()=>{s&&fetchTestList()},[s]);let fetchTestList=async()=>{v(!0);let[e,s]=await (0,x.W)(m.Z.lists.all({list_type:"test"}));s&&s.data&&s.data.length>0?y(s.data[0]):y(null),v(!1)},searchContacts=async e=>{if(!e||e.length<2)return[];try{let[s,t]=await (0,x.W)(m.Z.contacts.index({search:e,per_page:20}));if(t&&t.data){let e=t.data.data||[];return e.map(e=>({value:e.id,label:e.full_name||e.name||`${e.first_name||""} ${e.last_name||""}`.trim()||"Unknown",email:e.email}))}return[]}catch(e){return console.error("Error searching contacts:",e),[]}};async function sendTestCampaign(){if(o(null),"contacts"===c){if(!h||0===h.length){o("Please select at least one contact");return}if(h.length>10){o("Maximum 10 contacts allowed");return}}r(!0);let e={};"list"===c?e.is_test_list=!0:e.contact_ids=h.map(e=>e.value);let[s,t]=await (0,x.W)(m.Z.campaigns.test(i,e));r(!1),t?((0,Q.C)("success","Success","Test campaign sent successfully"),closeModal()):s&&o(s.response?.data?.message||"Failed to send test campaign")}let closeModal=()=>{t(!1),g([]),o(null),u("list"),y(null)};return(0,a.jsx)(E.u.Root,{show:s,as:l.Fragment,children:(0,a.jsxs)(Z.V,{as:"div",className:"relative z-10",onClose:closeModal,children:[(0,a.jsx)(E.u.Child,{as:l.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"})}),(0,a.jsx)("div",{className:"fixed inset-0 z-10 overflow-y-auto",children:(0,a.jsx)("div",{className:"flex min-h-full items-end justify-center p-4 sm:items-center sm:p-0",children:(0,a.jsx)(E.u.Child,{as:l.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",children:(0,a.jsxs)(Z.V.Panel,{className:"relative transform overflow-hidden rounded-lg bg-white px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg sm:p-6",children:[(0,a.jsx)("div",{className:"absolute right-0 top-0 hidden pr-4 pt-4 sm:block",children:(0,a.jsxs)("button",{type:"button",className:"rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",onClick:closeModal,children:[(0,a.jsx)("span",{className:"sr-only",children:"Close"}),(0,a.jsx)(D.Z,{className:"h-6 w-6","aria-hidden":"true"})]})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-indigo-100",children:(0,a.jsx)(C.Z,{className:"h-6 w-6 text-indigo-600","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"mt-3 text-center sm:mt-5",children:[(0,a.jsx)(Z.V.Title,{as:"h3",className:"text-base font-semibold leading-6 text-gray-900",children:"Test Campaign"}),(0,a.jsx)("p",{className:"mt-2 text-sm text-gray-500",children:"Choose a test list or select contacts to send a test campaign."}),d&&(0,a.jsx)("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2",children:(0,a.jsx)("p",{className:"text-sm text-red-600",children:d})}),(0,a.jsxs)("div",{className:"mt-5 text-left",children:[(0,a.jsx)(eu.E,{value:c,onChange:u,children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(eu.E.Option,{value:"list",children:e=>{let{checked:s}=e;return(0,a.jsx)("div",{className:`relative flex cursor-pointer rounded-lg border p-4 focus:outline-none ${s?"border-indigo-600 bg-indigo-50":"border-gray-300 bg-white"}`,children:(0,a.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,a.jsx)("div",{className:"flex items-center",children:(0,a.jsx)(eu.E.Label,{as:"p",className:`text-sm font-medium ${s?"text-indigo-900":"text-gray-900"}`,children:"Test List"})}),s&&(0,a.jsx)("div",{className:"shrink-0 text-indigo-600",children:(0,a.jsx)("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a1 1 0 00-1.414-1.414L9 10.586 7.557 9.143a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})})]})})}}),(0,a.jsx)(eu.E.Option,{value:"contacts",children:e=>{let{checked:s}=e;return(0,a.jsx)("div",{className:`relative flex cursor-pointer rounded-lg border p-4 focus:outline-none ${s?"border-indigo-600 bg-indigo-50":"border-gray-300 bg-white"}`,children:(0,a.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,a.jsx)("div",{className:"flex items-center",children:(0,a.jsx)(eu.E.Label,{as:"p",className:`text-sm font-medium ${s?"text-indigo-900":"text-gray-900"}`,children:"Select Contacts"})}),s&&(0,a.jsx)("div",{className:"shrink-0 text-indigo-600",children:(0,a.jsx)("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a1 1 0 00-1.414-1.414L9 10.586 7.557 9.143a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})})]})})}})]})}),"list"===c&&(0,a.jsx)("div",{className:"mt-4",children:(0,a.jsx)("div",{className:"rounded-md bg-indigo-50 border border-indigo-200 p-4",children:b?(0,a.jsx)("p",{className:"text-sm text-indigo-900",children:"Loading test list information..."}):f?(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("p",{className:"text-sm text-indigo-900",children:[(0,a.jsx)("span",{className:"font-medium",children:"Test List:"})," A test list is where you can maintain your test user details for easy testing. This makes it convenient to test campaigns without manually selecting contacts each time."]}),(0,a.jsxs)("div",{className:"mt-3 pt-3 border-t border-indigo-200",children:[(0,a.jsxs)("p",{className:"text-sm font-medium text-indigo-900 mb-2",children:["You already have a test list: ",(0,a.jsx)("span",{className:"font-semibold",children:f.name}),void 0!==f.contacts_count&&(0,a.jsxs)("span",{className:"text-indigo-700 font-normal",children:[" ","(",f.contacts_count," ",1===f.contacts_count?"contact":"contacts",")"]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 mt-2",children:[(0,a.jsxs)(p(),{href:`/contacts?listId=${f.id}`,className:"inline-flex items-center gap-1.5 text-xs font-medium text-indigo-700 hover:text-indigo-900 underline decoration-dotted underline-offset-2",children:[(0,a.jsx)(eh.Z,{className:"h-3.5 w-3.5"}),"View test list"]}),(0,a.jsxs)(p(),{href:`/data-management/user-imports/new-import?listId=${f.id}`,className:"inline-flex items-center gap-1.5 text-xs font-medium text-indigo-700 hover:text-indigo-900 underline decoration-dotted underline-offset-2",children:[(0,a.jsx)(eh.Z,{className:"h-3.5 w-3.5"}),"Add contacts to test list"]})]})]})]}):(0,a.jsxs)("p",{className:"text-sm text-indigo-900",children:[(0,a.jsx)("span",{className:"font-medium",children:"Test List:"})," A test list is where you can maintain your test user details for easy testing. This makes it convenient to test campaigns without manually selecting contacts each time."]})})}),"contacts"===c&&(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Search and Select Contacts"}),(0,a.jsx)(eg.Z,{isMulti:!0,loadOptions:searchContacts,value:h,onChange:e=>{if(e&&e.length>10){o("Maximum 10 contacts allowed");return}o(null),g(e||[])},components:{Option:ContactOption,MultiValueLabel:ContactMultiValueLabel},placeholder:"Search contacts by name or email...",isClearable:!0,isSearchable:!0,cacheOptions:!1,noOptionsMessage:e=>{let{inputValue:s}=e;return s.length<2?"Type at least 2 characters to search":"No contacts found"},styles:{option:(e,s)=>({...e,backgroundColor:s.isFocused?"#c7d2fe":e.backgroundColor}),multiValue:e=>({...e,backgroundColor:"#c7d2fe",padding:"4px 8px"}),multiValueLabel:e=>({...e,color:"#4f46e5",padding:0}),multiValueRemove:e=>({...e,color:"#4f46e5",":hover":{backgroundColor:"#4f46e5",color:"white"}}),control:(e,s)=>({...e,borderColor:s.isFocused?"#4f46e5":e.borderColor,":hover":{...e[":hover"],borderColor:s.isFocused?"#4f46e5":void 0}})}}),(0,a.jsxs)("p",{className:"mt-2 text-xs text-gray-500",children:["Maximum 10 contacts allowed (",h.length,"/10)"]})]})]})]})]}),(0,a.jsxs)("div",{className:"mt-5 flex justify-end space-x-3 sm:mt-6",children:[(0,a.jsx)(j.PL,{onClick:closeModal,children:"Cancel"}),(0,a.jsx)(j.zx,{loading:n,onClick:sendTestCampaign,disabled:n,children:"Send Test"})]})]})})})})]})})}var ef=t(16839),ej={src:"/_next/static/media/placeholder.27d7d8e0.jpg",height:400,width:300,blurDataURL:"data:image/jpeg;
1base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoKCgoKCgsMDAsPEA4QDxYUExMUFiIYGhgaGCIzICUgICUgMy03LCksNy1RQDg4QFFeT0pPXnFlZXGPiI+7u/sBCgoKCgoKCwwMCw8QDhAPFhQTExQWIhgaGBoYIjMgJSAgJSAzLTcsKSw3LVFAODhAUV5PSk9ecWVlcY+Ij7u7+//CABEIAAgABgMBIgACEQEDEQH/xAAoAAEBAAAAAAAAAAAAAAAAAAAABwEBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAKuF/8QAGBAAAwEBAAAAAAAAAAAAAAAAARESAEH/2gAIAQEAAT8AFUWp5v/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Af//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Af//Z",blurWidth:6,blurHeight:8},ey=t(25675),eb=t.n(ey),ev=t(23157);t(9151);var eN=t(68841),SpamReportNotification=e=>{let{spamReport:s}=e,[t,i]=(0,l.useState)(!1);return(0,a.jsxs)("div",{className:"mx-auto rounded-lg bg-white shadow-lg",children:[(0,a.jsxs)("div",{className:`cursor-pointer border-l-4 border-yellow-500 bg-yellow-100 p-4  text-yellow-700 ${t?"rounded-t-lg":"rounded-lg"}`,onClick:()=>i(!t),children:[(0,a.jsxs)("p",{className:"font-bold",children:["Spam Score: ",s.score]}),(0,a.jsxs)("p",{children:["Click to ",t?"hide":"view"," more details."]})]}),t&&(0,a.jsxs)("div",{className:"mt-6 p-8",children:[(0,a.jsx)("h2",{className:"mb-4 text-xl font-bold text-gray-800",children:"Spam Report Details"}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"min-w-full divide-y divide-gray-200 rounded rounded-lg border border-gray-200 bg-white shadow-md",children:[(0,a.jsx)("thead",{className:"bg-gray-100",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"border-b border-gray-300 px-6 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-600",children:"Score"}),(0,a.jsx)("th",{className:"border-b border-gray-300 px-6 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-600",children:"Description"})]})}),(0,a.jsx)("tbody",{className:"divide-y divide-gray-200",children:s.rules.map((e,s)=>(0,a.jsxs)("tr",{className:`${s%2==0?"bg-gray-50":"bg-white"}`,children:[(0,a.jsx)("td",{className:"whitespace-nowrap px-6 py-4 text-sm font-semibold text-gray-900",children:e.score}),(0,a.jsxs)("td",{className:"px-6 py-4 text-sm text-gray-800",children:[e.description,e.description.includes("See")&&(0,a.jsx)("a",{href:e.description.match(/https?:\/\/[^\s]+/g),target:"_blank",rel:"noopener noreferrer",className:"ml-2 text-blue-500 hover:underline",children:"Learn more"})]})]},s))})]})})]})]})},FromEmailInput=e=>{let{register:s,setValue:t,trigger:i,getValues:n,verifiedSenders:r,errors:d}=e,[o,c]=(0,l.useState)(""),[m,x]=(0,l.useState)(""),[u,h]=(0,l.useState)(null);return(0,l.useEffect)(()=>{if(n("fromEmail")){let[e,s]=n("fromEmail").split("@");c(e),x(s),t("localFromEmail",e),t("domain",s),i("localFromEmail"),i("domain")}},[n("fromEmail")]),(0,l.useEffect)(()=>{if(m&&r.length>0){let e=r.find(e=>e.name===m);h(e||null)}else m||h(null)},[r,m]),(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("label",{htmlFor:"local",className:"text-sm font-medium text-gray-700 mb-1",children:"From Email Address"}),(0,a.jsxs)("div",{className:"flex items-end",children:[(0,a.jsx)("div",{className:"relative flex-1",children:(0,a.jsx)("input",{name:"fromEmail",type:"text",className:"w-full border-l-1 border-gray-300 p-2 pr-4 text-sm border-r-0 rounded-l-md focus:ring-0 focus:border-gray-300",placeholder:"Enter your email",...s("localFromEmail",{required:"Email address"}),onChange:e=>{let s=e.target.value;if(!s.match(/^[a-zA-Z0-9.]+$/))return;let a=n("domain");t("fromEmail",`${s}@${a}`),i("fromEmail")}})}),(0,a.jsx)("div",{className:"border h-[42px] flex items-center px-2 bg-slate-100 border-gray-300 border-r-0 border-l-0",children:"@"}),(0,a.jsx)("select",{...s("domain"),onChange:e=>{let s=e.target.value;x(s);let a=n("localFromEmail");t("fromEmail",`${a}@${s}`),t("domain",s),i("fromEmail")},className:"border-l-1 border-gray-300 rounded-r-md border-l-0 focus:ring-0 focus:border-gray-300",children:r.map((e,s)=>(0,a.jsx)("option",{value:e.name,children:e.name},s))})]}),(()=>{if(!u||!u.healthStatus)return null;let e=String(u?.healthStatus).toLowerCase(),s=u?.healthStatusMessage,t="",i="",l="";return"healthy"===e||"good"===e||"ok"===e?(t="bg-green-100 text-green-700 border-green-200",i="Healthy",l="bg-green-400"):"unhealthy"===e||"poor"===e||"bad"===e||"critical"===e?(t="bg-red-100 text-red-700 border-red-200",i="Unhealthy",l="bg-red-400"):"warning"===e||"degraded"===e||"at_risk"===e?(t="bg-yellow-100 text-yellow-700 border-yellow-200",i="Warning",l="bg-yellow-400"):(t="bg-gray-100 text-gray-700 border-gray-200",i=String(u?.healthStatus),l="bg-gray-400"),(0,a.jsxs)("div",{className:"mt-2 flex items-center space-x-2 flex-wrap",children:[(0,a.jsxs)("span",{className:`inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium border ${t}`,children:[(0,a.jsx)("span",{className:`w-2 h-2 mr-1.5 rounded-full ${l}`}),i]}),s&&(0,a.jsx)("span",{className:"text-xs text-gray-600",children:s})]})})(),d?.localFromEmail||d?.domain?(0,a.jsxs)("div",{className:"text-red-500",children:[d?.localFromEmail?.message," ",d?.domain?.message]}):null]})},ew=t(35013);function getCampaignSubscriptionCategoryId(e){let s=e?.subscriptionCategory?.id??e?.subscriptionCategoryId??e?.subscription_category_id??"";return s?String(s):""}let Option=e=>(0,a.jsx)(ep.c.Option,{...e,children:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"block truncate",children:(0,a.jsx)("span",{children:e?.data?.name})}),(0,a.jsxs)("div",{className:"text-xs text-gray-500",children:[e?.data?.subscriberCount," subscribed contacts"]})]})}),EmailServiceOption=e=>(0,a.jsx)(ep.c.Option,{...e,children:(0,a.jsx)("div",{children:e?.data?.name})});function CampaignEdit(){let e=(0,n.useRouter)(),s=(0,r.I0)(),[t,i]=(0,l.useState)(!1),[o,g]=(0,l.useState)(null),[y,E]=(0,l.useState)(!1),[Z,_]=(0,l.useState)(!1),[F,M]=(0,l.useState)(!1),[P,L]=(0,l.useState)(!1),[I,B]=(0,l.useState)(!1),[D,z]=(0,l.useState)(!1),[R,$]=(0,l.useState)(!1),[O,V]=(0,l.useState)(!1),[U,W]=(0,l.useState)(!1),[H,q]=(0,l.useState)([]),[G,Y]=(0,l.useState)(null),[J,K]=(0,l.useState)(!0),[X,ee]=(0,l.useState)(""),[es,et]=(0,l.useState)(!0),[ea,ei]=(0,l.useState)(""),[el,en]=(0,l.useState)("email"),[er,ed]=(0,l.useState)(""),[ec,em]=(0,l.useState)(""),[eu,eh]=(0,l.useState)(""),[eg,ep]=(0,l.useState)(!1),[ey,eC]=(0,l.useState)(null),[ek,eS]=(0,l.useState)(null),[eA,eT]=(0,l.useState)(!1),[eE,eZ]=(0,l.useState)(null),[e_,eF]=(0,l.useState)(!1),[eM,eP]=(0,l.useState)(!1),[eL,eI]=(0,l.useState)(!1),eB=(0,r.v9)(e=>e.dashboard.getStarted),[eD,ez]=(0,l.useState)([]),[eR,e$]=(0,l.useState)([]),[eO,eV]=(0,l.useState)(!0),[eU,eW]=(0,l.useState)(null),fetchEmailServices=async()=>{eV(!0);let[e,s]=await (0,x.W)(m.Z.service.index({marketing_email:!0}));s&&e$(s.data),eV(!1)};(0,l.useEffect)(()=>{o&&(eW(eR.find(e=>e.id==o.serviceId)),se("serviceId",o.serviceId))},[eR,o]);let[eH,eQ]=(0,l.useState)(!1),fetchVerifiedSenders=async()=>
1{if(eQ(!0),eU){let[e,s]=await (0,x.W)(m.Z.service.verifiedSenders(eU.id));s&&ez(s.data.filter(e=>"verified"==e.status).map(e=>({...e,name:e.name,value:e.name})))}eQ(!1)};async function checkDomains(){(eB?.setupService||eB?.verifiedSender)&&eI(!0)}(0,l.useEffect)(()=>{checkDomains(),fetchEmailServices()},[eB]),(0,l.useEffect)(()=>{eU&&fetchVerifiedSenders()},[eU]),(0,l.useEffect)(()=>{0==eD.length&&se("fromEmail",null)},[eD]);let eq=(0,r.v9)(e=>e.sessions.currentUser),eG=eq?.company?.subscriptionCategoriesEnabled??eq?.company?.subscription_categories_enabled??!1,[eY,eJ]=(0,l.useState)([]),[eK,eX]=(0,l.useState)(!1),[e0,e1]=(0,l.useState)(""),[e2,e5]=(0,l.useState)(!1),e4=(0,u.cI)({mode:"onChange"}),{handleSubmit:e6,formState:{errors:e3,isSubmitting:e9,isValid:e7},register:e8,setValue:se,trigger:ss,getValues:st}=e4,[sa,si]=(0,l.useState)("static"),[sl,sn]=(0,l.useState)("list"),[sr,sd]=(0,l.useState)([]),[so,sc]=(0,l.useState)(0),initializePage=async function(){if(await fetchEmailServices(),e.query.campaignId){let[s,t]=await (0,x.W)(m.Z.campaigns.show(e.query.campaignId));t&&t.data&&("draft"!==t.data.aasmState&&await e.push(`/campaigns/${t.data.id}`),g(t.data),e1(getCampaignSubscriptionCategoryId(t.data)),eS(t.data.pictureUrl),sd(t.data.lists||[]),t.data.lists.length>0&&(q(t.data.lists),"segmented"===t.data.lists[0].listType?(sn("segment"),si("segmented")):(sn("list"),si("static"))),Y(t.data.segment),K(t.data.personalisedTo),se("fromName",t.data.fromName),se("fromEmail",t.data.fromEmail),se("subject",t.data.subject),se("previewText",t.data.previewText),se("htmlBody",t.data.htmlBody),se("designJson",t.data.designJson),se("replyTo",t.data.replyTo),eW(eR.find(e=>e.id==t.data.serviceId)),se("serviceId",t.data.serviceId),t.data.utmParams?(ei(t.data.utmParams.utm_source||eq?.company?.name||""),en(t.data.utmParams.utm_medium||"email"),ed(t.data.utmParams.utm_campaign||t.data.name||""),em(t.data.utmParams.utm_content||""),eh(t.data.utmParams.utm_term||"")):(ei(eq?.company?.name||""),en("email"),ed(t.data.name||""),em(""),eh("")),et(!1!==t.data.trackGanalyticsLink))}},submit=async function(e){let s=o.campaignLists.map(e=>({id:e.id,list_id:e.listId,campaign_id:e.campaignId})),t=H.map(e=>({list_id:e.id,campaign_id:o.id})),a=[],i=new Map;for(let e of s)i.set(e.list_id,e);for(let e of t){let s=i.get(e.list_id);s?(a.push(s),i.delete(e.list_id)):a.push(e)}for(let[e,s]of i.entries())a.push({...s,_destroy:!0});let l={list_id:H?.length>0?H[0]?.id:null,campaign_lists_attributes:a,segment_id:G?G.id:null,personalised_to:J,from_name:e.fromName,from_email:e.fromEmail,subject:e.subject,preview_text:e.previewText,reply_to:e.replyTo,service_id:e.serviceId,track_ganalytics_link:es};es&&(l.utm_params={utm_source:ea||null,utm_medium:el||null,utm_campaign:er||null,utm_content:ec||null,utm_term:eu||null});let n=null;o&&o.id&&(n=m.Z.campaigns.update(o.id,l));let[r,d]=await (0,x.W)(n);d&&(g(d.data),sd(d.data.lists||[]),closeAllForms())},fetchSubscriptionCategories=async()=>{if(!eG)return;eX(!0);let[e,s]=await (0,x.W)(m.Z.subscriptionCategories.index());if(s?.data){let e=Array.isArray(s.data)?s.data:s.data?.subscription_categories??s.data?.data??[];eJ(e.filter(e=>e?.isActive!==!1))}eX(!1)};(0,l.useEffect)(()=>{fetchSubscriptionCategories()},[eG]),(0,l.useEffect)(()=>{o&&e1(getCampaignSubscriptionCategoryId(o))},[o]);let updateSubscriptionCategory=async e=>{if(!o?.id||e2)return;e5(!0);let[s,t]=await (0,x.W)(m.Z.campaigns.update(o.id,{subscription_category_id:e||null}));return e5(!1),!s&&(t?.data&&g(t.data),(0,Q.C)("success","Updated","Subscription category updated"),!0)},openSendModal=e=>{eZ(e),eT(!0)},closeAllForms=()=>{L(!1),z(!1),$(!1),V(!1),B(!1);let e=document.getElementsByTagName("html");e[0].style.overflow="auto"},setEditorTypeAndOpenEditor=e=>{M(!1),eC(e),_(!0)},closeAllModals=()=>{_(!1),M(!1),E(!1),ep(!1)},setHtmlBody=async(e,s)=>{eP(!0),se("htmlBody",e),se("designJson",s),se("editorType",ey);let t=null;o&&o.id&&(t=m.Z.campaigns.update(o.id,{html_body:e,design_json:s,editor_type:ey}));let[a,i]=await (0,x.W)(t);i&&(g(i.data),eS(i.data.pictureUrl),sd(i.data.lists||[]),closeAllForms()),eP(!1)},updateEditorType=async e=>{eP(!0),se("editorType",e);let s=null;o&&o.id&&(s=m.Z.campaigns.update(o.id,{editor_type:e}));
1let[t,a]=await (0,x.W)(s);a&&(g(a.data),eS(a.data.pictureUrl),sd(a.data.lists||[])),eC(e),eP(!1)};if((0,l.useEffect)(()=>{s((0,eN.Pm)()),async function(){await initializePage(),i(!0)}()},[]),!t||!o||eO)return(0,a.jsx)(d.Z,{});let sm=!!(o?.serviceId&&o?.subject&&o?.htmlBody&&o?.fromName&&o?.fromEmail),sx=(()=>{let e=[];return(o?.serviceId||e.push("Email Service"),o?.subject||e.push("Subject"),o?.htmlBody||e.push("Content"),o?.fromName&&o?.fromEmail||e.push("From details"),0===e.length)?"":`Please complete: ${e.join(", ")}`})();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c(),{children:(0,a.jsx)("title",{children:"Campaigns - CampaignHQ"})}),(0,a.jsx)(EditorTypeModal,{setOpen:M,open:F,setEditorTypeAndOpenEditor:setEditorTypeAndOpenEditor}),(0,a.jsx)(SendModal,{setOpen:eT,open:eA,campaign:o,deliverNow:eE,setCampaign:g}),(0,a.jsx)(TestCampaignModal,{setOpen:eF,open:e_,campaignId:o?.id}),(0,a.jsx)(ef.Z,{campaign:o,isOpen:U,onClose:()=>W(!1),onUpdate:e=>{g(e)}}),(0,a.jsx)(T.Z,{setOpen:E,open:y,name:o?.name,campaignId:o?.id,updateCampaingName:function(e){g({...o,name:e})}}),(0,a.jsx)(CampaignEditorModal,{setOpen:e=>{_(e),!1==e&&(closeAllModals(),eC(null))},open:Z,campaign:o,editorType:ey,setEditorType:updateEditorType,setHtmlBody:setHtmlBody,isSaving:eM}),(0,a.jsx)(b.Z,{setOpen:ep,open:eg,subject:X,setSubjectValue:se}),(0,a.jsxs)("form",{onSubmit:e6(submit),children:[(0,a.jsxs)("div",{className:"border-b px-4 py-4 sm:flex sm:items-center sm:justify-between sm:px-6 lg:px-8",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("h1",{className:"text-md font-medium leading-6 text-gray-900 sm:truncate",children:"Let's get started!"}),(0,a.jsx)("p",{className:"text-xs text-gray-700",children:"Draft campaign"})]}),(0,a.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-2 sm:mt-0 sm:ml-4",children:[(0,a.jsxs)(p(),{href:"/campaigns",className:"inline-flex items-center justify-center gap-1.5 px-3 py-2 text-sm font-medium text-gray-600 hover:text-gray-900 focus:outline-none sm:w-auto transition-colors",children:[(0,a.jsx)(v.Z,{className:"h-4 w-4"}),"Finish later"]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[sm?(0,a.jsxs)("button",{type:"button",onClick:()=>eF(!0),className:"inline-flex items-center justify-center gap-1.5 rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 hover:border-gray-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:w-auto transition-colors",children:[(0,a.jsx)(N.Z,{className:"h-4 w-4"}),"Test Campaign"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{type:"button","data-tooltip-id":"test-campaign-disabled",disabled:!0,className:"inline-flex items-center justify-center gap-1.5 rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-400 shadow-sm cursor-not-allowed sm:w-auto",children:[(0,a.jsx)(N.Z,{className:"h-4 w-4 text-gray-400"}),"Test Campaign"]}),(0,a.jsx)(eo.u,{id:"test-campaign-disabled",place:"bottom",children:sx})]}),eq?.company?.plan?.freePlan?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{type:"button","data-tooltip-id":"warmup-lock",disabled:!0,className:"inline-flex items-center justify-center gap-1.5 rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-400 shadow-sm cursor-not-allowed sm:w-auto",children:[(0,a.jsx)(ex.Z,{className:"h-4 w-4 text-gray-400"}),"Schedule"]}),(0,a.jsx)(eo.u,{id:"warmup-lock",place:"bottom",children:"Upgrade to premium plan to schedule"})]}):(0,a.jsxs)("button",{type:"button",onClick:()=>openSendModal("later"),className:"inline-flex items-center justify-center gap-1.5 rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 hover:border-gray-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:w-auto transition-colors",children:[(0,a.jsx)(w.Z,{className:"h-4 w-4"}),"Schedule"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>openSendModal("now"),className:"inline-flex items-center justify-center gap-1.5 rounded-md border border-transparent bg-indigo-600 px-5 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:w-auto transition-colors",children:[(0,a.jsx)(C.Z,{className:"h-4 w-4"}),"Send"]})]})]})]}),(0,a.jsx)("div",{className:"px-4 py-4 pb-12 sm:px-6 lg:px-8",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("h1",{className:"text-2xl font-semibold text-gray-900 sm:truncate",children:o?.name}),(0,a.jsx)("a",{className:"inline-flex items-center text-xs text-indigo-600 hover:text-indigo-700 font-medium transition-colors cursor-pointer flex-shrink-0",onClick:()=>E(!0),children:"Edit name"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[o?.categories&&o.categories.length>0&&(0,a.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap",children:o.categories.map((e,s)=>(0,a.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium bg-indigo-50 text-indigo-700 border border-indigo-200",children:e},s))}),(0,a.jsxs)("button",{onClick:()=>W(!0),className:"inline-flex items-center gap-1 text-xs text-indigo-600 hover:text-indigo-700 font-medium transition-colors",children:[(0,a.jsx)(k.Z,{className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{children:o?.categories&&o.categories.length>0?"Edit tags":"Add tags"})]})]})]})}),o?.spamReport?.rules&&(0,a.jsx)("div",{className:"mb-5 px-8",children:(0,a.jsx)(SpamReportNotification,{spamReport:o?.spamReport})}),(0,a.jsx)("div",{className:"px-8",children:eL?null:(0,a.jsxs)("div",{className:"flex items-center justify-between space-x-2 rounded-lg border border-orange-600 bg-orange-50 p-4 text-sm text-orange-900 shadow-md",children:[(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsxs)("span",{className:"mb-1 block",children:["Hey there! It seems like you haven't verified any"," ",(0,a.jsx)("span",{className:"font-bold underline",children:"from email address"})," ","or ",(0,a.jsx)("span",{className:"font-bold underline",children:"sender domain"})," ","yet."]}),(0,a.jsx)("span",{className:"block",children:"To kick off your campaigns, it's essential to verify at least one of them."})]}),(0,a.jsx)(p(),{href:"/channels/email/",className:"inline-flex items-center font-semibold text-orange-600 hover:text-orange-800",children:"Verify email or domain now ->"})]})}),(0,a.jsx)("div",{className:"mt-4 px-4 sm:flex sm:items-center sm:justify-between sm:px-6 lg:px-8",children:(0,a.jsxs)("div",{className:"min-w-0 flex-1 border rounded-md",children:[(0,a.jsxs)("div",{children:[eG?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 border-b py-4 px-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:e0?(0,a.jsx)(S.Z,{className:"h-5 w-5 text-green-500","aria-hidden":"true"}):(0,a.jsx)(S.Z,{className:"h-5 w-5 text-gray-500","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"text-md mb-1 font-semibold leading-none text-gray-600",children:"Category"}),e0?(0,a.jsx)("p",{className:"text-sm leading-normal text-gray-600",children:eY.find(e=>String(e.id)===String(e0))?.name||o?.subscriptionCategory?.name||"Selected category"}):(0,a.jsx)("p",{className:"text-sm leading-normal text-gray-400",children:"No subscription category selected for this campaign."}),(0,a.jsxs)("p",{className:"mt-1 text-xs leading-normal text-gray-500",children:["Selecting a category sends this campaign only to contacts subscribed to that category in",(0,a.jsx)("span",{className:"font-medium text-gray-700",children:" Manage preferences"}),"."]}),(0,a.jsxs)("p",{className:"mt-1 text-xs leading-normal text-indigo-600",children:["Manage available categories in"," ",(0,a.jsx)(p(),{href:"/settings/email-preference-center",className:"font-semibold underline decoration-dotted underline-offset-4",children:"Email Preference Center settings"}),"."]})]}),(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[e2?(0,a.jsx)("span",{className:"text-xs text-gray-500",children:"Saving..."}):null,(0,a.jsxs)("select",{value:e0,onChange:async e=>{let s=e.target.value;e1(s),await updateSubscriptionCategory(s)},disabled:eK||e2,className:"min-w-[220px] rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/40 disabled:cursor-not-allowed disabled:opacity-60",children:[(0,a.jsx)("option",{value:"",children:"No category"}),eY.map(e=>(0,a.jsx)("option",{value:String(e.id),children:e.name},e.id))]})]})})]})}):(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 py-4 px-4 border-b bg-gray-50/60",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)(ex.Z,{className:"h-5 w-5 text-gray-400","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"text-md mb-1 font-semibold leading-none text-gray-700",children:"Subscription Category (Optional)"}),(0,a.jsx)("p",{className:"text-sm leading-normal text-gray-600",children:"Email Preference Center is currently disabled."}),(0,a.jsx)("p",{className:"mt-1 text-xs leading-normal text-gray-500",children:"Enable it to let contacts manage subscription topics, reduce unsubscribes, and improve relevance."})]}),(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)(p(),{href:"/settings/email-preference-center",className:"inline-flex items-center rounded-md bg-white px-3 py-2 text-sm font-medium text-indigo-600 border border-indigo-200 hover:bg-indigo-50 focus:outline-none",children:"Enable in settings"})})]}),(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 py-4 px-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:o.lists.length>0?(0,a.jsx)(S.Z,{className:"h-5 w-5 text-green-500","aria-hidden":"true"}):(0,a.jsx)(S.Z,{className:"h-5 w-5 text-gray-500","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"text-md mb-1 font-semibold leading-none text-gray-600",children:"Email Service"}),o.serviceId&&!I?(0,a.jsxs)("p",{className:"text-sm leading-normal text-gray-600",children:[eU?.n
1ame," Service"]}):(0,a.jsx)("p",{className:"text-sm leading-normal text-gray-400",children:"Pick an email service to send this campaign from."})]}),(0,a.jsx)("div",{className:"flex-shrink-0",children:!I&&(0,a.jsx)("button",{className:"inline-flex w-40 justify-center cursor-pointer rounded-md bg-gray-200 px-4 py-2 text-sm font-medium text-black focus:outline-none hover:bg-gray-300",onClick:()=>B(!0),children:"Edit email service"})})]}),I&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 px-4 pb-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)(S.Z,{className:"h-5 w-5 text-white","aria-hidden":"true"})}),(0,a.jsx)("div",{className:"min-w-0 flex-1",children:(0,a.jsx)("div",{className:"flex space-x-6",children:(0,a.jsx)("div",{className:"flex-1",children:eR.length>0?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"block text-sm font-medium leading-6 text-gray-900",children:"Email Service"}),(0,a.jsx)(ev.ZP,{isMulti:!1,options:eR,getOptionLabel:e=>e?.name,getOptionValue:e=>e?.id,hideSelectedOptions:!0,defaultValue:eU,onChange:e=>{eW(e),se("serviceId",e.id),g({...o,serviceId:e.id})},components:{Option:EmailServiceOption},placeholder:"Select email service",className:"mt-2",styles:{option:(e,s)=>({...e,backgroundColor:s.isFocused?"#c7d2fe":e.backgroundColor}),control:(e,s)=>({...e,borderColor:s.isFocused?"#4f46e5":e.borderColor,":hover":{...e[":hover"],borderColor:s.isFocused?"#4f46e5":void 0}})}})]}):""})})})]}),(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 px-4 pb-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)(S.Z,{className:"h-5 w-5 text-white","aria-hidden":"true"})}),(0,a.jsx)("div",{className:"min-w-0 flex-1",children:(0,a.jsxs)("div",{className:"mt-4 flex space-x-2",children:[(0,a.jsx)(j.zx,{type:"submit",loading:e9,disabled:e9,className:"sm:w-auto",children:"Save"}),(0,a.jsx)("button",{onClick:()=>B(!1),className:"inline-flex items-center justify-center px-4 py-2 text-sm font-bold text-gray-600 underline decoration-dashed underline-offset-4 focus:outline-none sm:w-auto",children:"Cancel"})]})})]})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 py-4 px-4 border-t",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:o.lists.length>0?(0,a.jsx)(S.Z,{className:"h-5 w-5 text-green-500","aria-hidden":"true"}):(0,a.jsx)(S.Z,{className:"h-5 w-5 text-gray-500","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"text-md mb-1 font-semibold leading-none text-gray-600",children:"To"}),o.lists.length>0&&!P?o.segment?(0,a.jsxs)("p",{className:"text-sm leading-normal text-gray-600",children:[(0,a.jsx)("span",{className:"font-semibold text-black",children:o.segment?.name})," ","in the audience"," ",(0,a.jsx)("span",{className:"font-semibold text-black",children:o.lists[0].name}),"."," ",(0,a.jsxs)(p(),{href:"#",className:"font-semibold text-indigo-600 underline decoration-dotted underline-offset-4",children:[o.segment.contactsCount," recipients."]})," "]}):(0,a.jsxs)("p",{className:"text-sm leading-normal text-gray-600",children:["segment"===sl?"Segment":"Audience"," ",(0,a.jsxs)("span",{className:"font-semibold text-black",children:[o.lists[0].name," ",o.totalLists-1>0&&(0,a.jsxs)("span",{className:"text-xs text-gray-600",children:["+",o.totalLists-1," more ","segment"===sl?"segment(s)":"list(s)"]})]}),"."," ",(0,a.jsxs)("span",{className:"inline-block font-semibold text-indigo-600 underline decoration-dotted underline-offset-4",children:[o?.contactsCount," recipients."]})," "]}):(0,a.jsx)("p",{className:"text-sm leading-normal text-gray-400",children:"Who are you sending this campaign to?"}),o?.list&&!P&&o?.personalisedTo&&(0,a.jsx)("p",{className:"text-xs leading-normal text-gray-600",children:"Your 'To' field is personalized."})]}),(0,a.jsx)("div",{className:"flex-shrink-0",children:!P&&(0,a.jsx)("button",{className:"inline-flex w-40 justify-center cursor-pointer rounded-md bg-gray-200 px-4 py-2 text-sm font-medium text-black focus:outline-none hover:bg-gray-300",onClick:()=>L(!0),children:"Edit recipients"})})]}),P&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 px-4 pb-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)(S.Z,{className:"h-5 w-5 text-white","aria-hidden":"true"})}),(0,a.jsx)("div",{className:"min-w-0 flex-1",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"block text-sm font-medium leading-6 text-gray-900 mb-2",children:"Audience Type"}),(0,a.jsx)(ew.Wo,{audienceType:sl,onSelect:e=>{let s="list"===e?"static":"segmented";if(Y(null),sn(e),si(s),sr&&sr.length>0){let s=sr.filter(s=>"list"===e&&"static"===s.listType||"segment"===e&&"segmented"===s.listType);s.length>0?q(s):q([])}else q([])}}),(0,a.jsx)(ew.ZP,{audienceType:sl,listType:sa,isMulti:!0,listSelected:H,onListSelect:e=>{q(e),Y(null)},listOptionComponent:Option,onOptionsLoaded:sc}),(o?.lists?.length>0||H?.length>0||so>0)&&(0,a.jsx)("div",{className:"mt-4 max-w-md",children:(0,a.jsx)(f.B,{enabled:J,setEnabled:K,label:"Personalize the 'To' field",subLabel:"Show recipient name in email client with email address"})})]})})]}),(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 px-4 pb-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)(S.Z,{className:"h-5 w-5 text-white","aria-hidden":"true"})}),(0,a.jsx)("div",{className:"min-w-0 flex-1",children:(0,a.jsxs)("div",{className:"mt-4 flex space-x-2",children:[H?.length>0?(0,a.jsx)(j.zx,{type:"submit",loading:e9,disabled:e9,className:"sm:w-auto",children:"Save"}):null,(0,a.jsx)("button",{onClick:()=>L(!1),className:"inline-flex items-center justify-center px-4 py-2 text-sm font-bold text-gray-600 underline decoration-dashed underline-offset-4 focus:outline-none sm:w-auto",children:"Cancel"})]})})]})]})]}),(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 border-t py-4 px-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:o?.fromName&&o?.fromEmail?(0,a.jsx)(S.Z,{className:"h-5 w-5 text-green-500","aria-hidden":"true"}):(0,a.jsx)(S.Z,{className:"h-5 w-5 text-gray-500","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"text-md mb-1 font-semibold leading-none text-gray-600",children:"From"}),o?.fromEmail&&!D?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{className:"text-sm leading-normal text-gray-600",children:[o?.fromName," <",o?.fromEmail,">"]}),(()=>{let e=o?.fromEmail?.split("@")[1],s=eD.find(s=>s.name===e);if(s&&s.healthStatus){let e=String(s?.healthStatus).toLowerCase(),t="",i="",l="";return"healthy"===e||"good"===e||"ok"===e?(t="bg-green-100 text-green-700 border-green-200",i="Healthy",l="bg-green-400"):"unhealthy"===e||"poor"===e||"bad"===e||"critical"===e?(t="bg-red-100 text-red-700 border-red-200",i="Unhealthy",l="bg-red-400"):"warning"===e||"degraded"===e||"at_risk"===e?(t="bg-yellow-100 text-yellow-700 border-yellow-200",i="Warning",l="bg-yellow-400"):(t="bg-gray-100 text-gray-700 border-gray-200",i=String(s?.healthStatus),l="bg-gray-400"),(0,a.jsxs)("div",{className:"mt-2 flex items-center space-x-2 flex-wrap",children:[(0,a.jsxs)("span",{className:`inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium border ${t}`,children:[(0,a.jsx)("span",{className:`w-2 h-2 mr-1.5 rounded-full ${l}`}),i]}),s?.healthStatusMessage&&(0,a.jsx)("span",{className:"text-xs text-gray-600",children:s?.healthStatusMessage})]})}return null})(),o?.replyTo&&(0,a.jsxs)("p",{className:"text-xs leading-normal text-gray-500 mt-1",children:["Reply-to: ",o?.replyTo]})]}):(0,a.jsx)("p",{className:"text-sm leading-normal text-gray-400",children:"Who is sending this campaign?"})]}),(0,a.jsx)("div",{className:"flex-shrink-0",children:!D&&(0,a.jsx)("button",{className:"inline-flex w-40 justify-center cursor-pointer rounded-md bg-gray-200 px-4 py-2 text-sm font-medium text-black focus:outline-none hover:bg-gray-300",onClick:()=>z(!0),children:"Add from"})})]}),D&&(0,a.jsxs)(a.Fragment,{children:[!eU||0===eD.length||eH?eH?(0,a.jsx)("div",{className:"group relative flex items-start space-x-3 px-4 pb-4 w-full",children:(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)(S.Z,{className:"h-5 w-5 text-white","aria-hidden":"true"}),(0,a.jsx)("div",{className:"min-w-0 flex-1 w-full",children:(0,a.jsxs)("div",{className:"text-sm leading-normal text-gray-400 text-center",children:["Fetching verified domains for ",eU.name,"..."]})})]})}):(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 px-4 pb-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)(S.Z,{className:"h-5 w-5 text-white","aria-hidden":"true"})}),(0,a.jsx)("div",{className:"min-w-0 flex-1",children:eU?(0,a.jsxs)("div",{className:"relative overflow-hidden bg-white border border-gray-200 rounded-xl shadow-sm",children:[(0,a.jsx)("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-50/30 to-white pointer-events-none"}),(0,a.jsx)("div",{className:"relative p-6",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:"mx-auto w-12 h-12 bg-gradient-to-br from-blue-50 to-indigo-50 rounded-xl flex items-center justify-center mb-4 shadow-sm border border-blue-100/50",children:(0,a.jsx)("svg",{className:"w-6 h-6 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 8l7.89 4.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}),(0,a.jsxs)("div",{className:"w-full",children:[(0,a.jsxs)("h3",{className:"text-lg font-medium text-gray-900 mb-2 tracking-tight",children:[(0,a.jsxs)("span",{className:"font-medium",children:["[",eU.name,"] Email Service"]})," does not have any verified domains"]}),(0,a.jsxs)("p",{className:"text-gray-600 mb-6 leading-relaxed text-sm",children:["To send emails from ",(0,a.jsx)("strong",{children:eU.name}),", you need to verify a domain first. This ensures your emails reach inboxes and builds trust with your recipients."]}),(0,a.jsx)("div",{className:"flex justify-center",children:(0,a.jsxs)(p(),{href:`/settings/email-services/${eU.id}`,className:"group relative inline-flex items-center justify-center px-6 py-2.5 bg-gradient-to-r from-blue-600 to-indigo-600 text-white font-medium rounded-lg shadow-sm hover:shadow-md transition-all duration-200 transform hover:-translate-y-0.5 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[(0,a.jsx)("svg",{className:"w-4 h-4 mr-2 transition-transform group-hover:scale-110",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"Add Domain to ",eU.name]})})]})]})})]}):(0,a.jsxs)("div",{className:"relative overflow-hidden bg-white border border-gray-200 rounded-xl shadow-sm",children:[(0,a.jsx)("div",{className:"absolute inset-0 bg-gradient-to-br from-yellow-50/30 to-white pointer-events-none"}),(0,a.jsx)("div",{className:"relative p-6",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:"mx-auto w-12 h-12 bg-gradient-to-br from-yellow-50 to-orange-50 rounded-xl flex items-center justify-center mb-4 shadow-sm border border-yellow-100/50",children:(0,a.jsx)("svg",{className:"w-6 h-6 text-yellow-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"})})}),(0,a.jsxs)("div",{className:"w-full",children:[(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-2 tracking-tight",children:"Email service required"}),(0,a.jsx)("p",{className:"text-gray-600 mb-4 leading-relaxed text-sm",children:"Before you can set up your from email address, you need to select an email service provider."}),(0,a.jsx)("div",{className:"p-3 bg-gradient-to-r from-yellow-50 to-orange-50 rounded-lg border border-yellow-200/50 w-full",children:(0,a.jsxs)("div",{className:"flex items-center justify-center space-x-2",children:[(0,a.jsx)("div",{className:"w-6 h-6 bg-yellow-100 rounded-full flex items-center justify-center",children:(0,a.jsx)("svg",{className:"w-3 h-3 text-yellow-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),(0,a.jsx)("p",{className:"text-xs text-yellow-800 font-medium",children:'Go back to the "Email Service" section above and select a service to continue'})]})}),(0,a.jsx)("div",{className:"mt-4 flex justify-center",children:(0,a.jsx)(p(),{href:"/channels/email",className:"inline-flex items-center font-semibold text-indigo-600 hover:text-indigo-700 text-sm",children:"Set up email service →"})})]})]})})]})})]}):(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 px-4 pb-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)(S.Z,{className:"h-5 w-5 text-white","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex space-x-6 mb-4",children:[(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsx)(h.Z,{name:"fromN
1ame",register:e8,validations:{required:"Name is required"},error:e3?.fromName,label:"Name"})}),(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsx)(FromEmailInput,{name:"fromEmail",register:e8,setValue:se,trigger:ss,getValues:st,verifiedSenders:eD,errors:e3})})]}),(0,a.jsxs)("div",{className:"flex space-x-6",children:[(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsx)(h.Z,{name:"replyTo",register:e8,validations:{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid reply-to email address"}},error:e3?.replyTo,label:"Reply to email (optional)"})}),(0,a.jsx)("div",{className:"flex-1"})]})]})]})}),(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 px-4 pb-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)(S.Z,{className:"h-5 w-5 text-white","aria-hidden":"true"})}),(0,a.jsx)("div",{className:"min-w-0 flex-1",children:(0,a.jsxs)("div",{className:"mt-4 flex space-x-2",children:[(0,a.jsx)(j.zx,{type:"submit",loading:e9,disabled:!eU||0===eD.length||e9,className:"sm:w-auto",children:"Save"}),(0,a.jsx)("button",{onClick:()=>z(!1),className:"inline-flex items-center justify-center px-4 py-2 text-sm font-bold text-gray-600 underline decoration-dashed underline-offset-4 focus:outline-none sm:w-auto",children:"Cancel"})]})})]})]}),(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 border-t py-4 px-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:o?.subject?(0,a.jsx)(S.Z,{className:"h-5 w-5 text-green-500","aria-hidden":"true"}):(0,a.jsx)(S.Z,{className:"h-5 w-5 text-gray-500","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"text-md mb-1 font-semibold leading-none text-gray-600",children:"Subject"}),o?.subject&&!R?(0,a.jsx)("p",{className:"text-sm leading-normal text-gray-600",children:o?.subject}):(0,a.jsx)("p",{className:"text-sm leading-normal text-gray-400",children:"What's the subject line for this campaign?"}),o?.previewText&&!R&&(0,a.jsxs)("p",{className:"text-xs leading-normal text-gray-600",children:["Preview text: ",o?.previewText]})]}),(0,a.jsx)("div",{className:"flex-shrink-0",children:!R&&(0,a.jsx)("button",{className:"inline-flex w-40 justify-center cursor-pointer rounded-md bg-gray-200 px-4 py-2 text-sm font-medium text-black focus:outline-none hover:bg-gray-300",onClick:()=>$(!0),children:"Edit subject"})})]}),R&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 px-4 pb-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)(S.Z,{className:"h-5 w-5 text-white","aria-hidden":"true"})}),(0,a.jsx)("div",{className:"min-w-0 flex-1",children:(0,a.jsx)("div",{className:"flex space-x-6",children:(0,a.jsxs)("div",{className:"w-1/2",children:[(0,a.jsx)(h.Z,{name:"subject",register:e8,validations:{required:"Subject is required"},error:e3?.subject,className:"mb-1",label:"Subject line",helpComponent:MergeTag,placeholder:"Personalise subject line with contact fields",onChange:e=>{ee(e)}}),(0,a.jsxs)("div",{className:"mb-5 flex items-center space-x-1 text-sm",children:[(0,a.jsx)(A.Z,{height:"20px",width:"20px",className:"font-medium text-yellow-500"}),(0,a.jsx)("a",{className:"text-sm font-semibold text-indigo-500 hover:cursor-pointer",onClick:()=>ep(!eg),children:"Rephrase your subject line using our AI assistant"})]}),(0,a.jsx)(h.Z,{name:"previewText",register:e8,label:"Preview text",helpComponent:MergeTag,placeholder:"Personalise preview text with contact fields"})]})})})]}),(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 px-4 pb-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)(S.Z,{className:"h-5 w-5 text-white","aria-hidden":"true"})}),(0,a.jsx)("div",{className:"min-w-0 flex-1",children:(0,a.jsxs)("div",{className:"mt-4 flex space-x-2",children:[(0,a.jsx)(j.zx,{type:"submit",loading:e9,disabled:e9,className:"sm:w-auto",children:"Save"}),(0,a.jsx)("button",{onClick:()=>$(!1),className:"inline-flex items-center justify-center px-4 py-2 text-sm font-bold text-gray-600 underline decoration-dashed underline-offset-4 focus:outline-none sm:w-auto",children:"Cancel"})]})})]})]}),(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 border-t py-4 px-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:o?.htmlBody?(0,a.jsx)(S.Z,{className:"h-5 w-5 text-green-500","aria-hidden":"true"}):(0,a.jsx)(S.Z,{className:"h-5 w-5 text-gray-500","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"text-md mb-1 font-semibold leading-none text-gray-600",children:"Content"}),o.htmlBody?(0,a.jsx)("p",{className:"text-sm leading-normal text-gray-600",children:o?.subject}):(0,a.jsx)("p",{className:"text-sm leading-normal text-gray-400",children:"Design the content of your email"})]}),(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)("button",{className:"inline-flex w-40 justify-center cursor-pointer rounded-md bg-gray-200 px-4 py-2 text-sm font-medium text-black focus:outline-none hover:bg-gray-300",onClick:()=>{o.designJson||o.htmlBody?setEditorTypeAndOpenEditor(o.editorType):M(!0)},children:"Edit design"})})]}),(0,a.jsxs)("div",{className:"group relative flex items-start space-x-3 px-4 pb-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)(S.Z,{className:"h-5 w-5 text-white","aria-hidden":"true"})}),(0,a.jsx)("div",{className:"min-w-0 flex-1",children:(0,a.jsx)("div",{className:"flex space-x-6",children:(0,a.jsx)("div",{className:"w-1/2",children:ek?(0,a.jsx)("img",{src:ek,alt:"Create blank template",width:200}):(0,a.jsx)(eb(),{src:ej,alt:"Create blank template",width:200})})})})]}),(0,a.jsxs)("div",{className:"group relative flex items-start space-x-4 border-t py-5 px-6 pb-8",children:[(0,a.jsx)("div",{className:"flex-shrink-0 pt-0.5",children:es&&(ea||el||er)?(0,a.jsx)(S.Z,{className:"h-5 w-5 text-green-500","aria-hidden":"true"}):(0,a.jsx)(S.Z,{className:"h-5 w-5 text-gray-500","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"text-md mb-3 font-semibold leading-none text-gray-900",children:"Google Analytics"}),es&&(ea||el||er)&&!O?(0,a.jsx)("div",{className:"mt-3",children:(0,a.jsxs)("div",{className:"flex flex-wrap gap-2.5",children:[(0,a.jsxs)("div",{className:"inline-flex items-center px-3 py-1.5 rounded-lg bg-indigo-50 border border-indigo-200 shadow-sm",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-indigo-700 mr-2",children:"Source:"}),(0,a.jsx)("span",{className:"text-xs text-indigo-900 font-semibold truncate max-w-[200px]",title:ea,children:ea||"Not set"})]}),(0,a.jsxs)("div",{className:"inline-flex items-center px-3 py-1.5 rounded-lg bg-indigo-50 border border-indigo-200 shadow-sm",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-indigo-700 mr-2",children:"Medium:"}),(0,a.jsx)("span",{className:"text-xs text-indigo-900 font-semibold",children:el||"Not set"})]}),(0,a.jsxs)("div",{className:"inline-flex items-center px-3 py-1.5 rounded-lg bg-indigo-50 border border-indigo-200 shadow-sm",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-indigo-700 mr-2",children:"Campaign:"}),(0,a.jsx)("span",{className:"text-xs text-indigo-900 font-semibold truncate max-w-[200px]",title:er,children:er||"Not set"})]}),ec&&(0,a.jsxs)("div",{className:"inline-flex items-center px-3 py-1.5 rounded-lg bg-gray-50 border border-gray-200 shadow-sm",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-gray-700 mr-2",children:"Content:"}),(0,a.jsx)("span",{className:"text-xs text-gray-900 font-semibold truncate max-w-[150px]",title:ec,children:ec})]}),eu&&(0,a.jsxs)("div",{className:"inline-flex items-center px-3 py-1.5 rounded-lg bg-gray-50 border border-gray-200 shadow-sm",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-gray-700 mr-2",children:"Term:"}),(0,a.jsx)("span",{className:"text-xs text-gray-900 font-semibold truncate max-w-[150px]",title:eu,children:eu})]})]})}):(0,a.jsx)("p",{className:"text-sm leading-relaxed text-gray-500 mt-2",children:"Configure Google Analytics tracking and UTM parameters"})]}),(0,a.jsx)("div",{className:"flex-shrink-0",children:!O&&(0,a.jsxs)("button",{className:"cursor-pointer rounded-lg bg-gray-200 px-5 py-2.5 text-sm font-medium text-black hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:w-auto transition-all duration-200 shadow-sm hover:shadow",onClick:()=>V(!0),children:[es&&(ea||el||er)?"Edit":"Configure"," Google Analytics"]})})]}),O&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"group relative flex items-start space-x-4 px-6 py-6",children:[(0,a.jsx)("div",{className:"flex-shrink-0 pt-0.5",children:(0,a.jsx)(S.Z,{className:"h-5 w-5 text-white","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"mb-6 rounded-xl border border-indigo-200 bg-gradient-to-r from-indigo-50 via-blue-50 to-indigo-50 p-5 shadow-sm",children:(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)("div",{className:"flex-shrink-0 mt-0.5",children:(0,a.jsx)("svg",{className:"h-5 w-5 text-indigo-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),(0,a.jsxs)("div",{className:"ml-3.5",children:[(0,a.jsx)("p",{className:"text-sm font-semibold text-indigo-900 mb-1.5",children:"Google Analytics Tracking"}),(0,a.jsx)("p",{className:"text-xs text-indigo-700 leading-relaxed",children:"Measure campaign performance and track conversions in Google Analytics with UTM parameters."})]})]})}),(0,a.jsx)("div",{className:"mb-6",children:(0,a.jsx)(f.B,{enabled:es,setEnabled:et,label:"Enable Google Analytics link tracking",subLabel:"Add Google Analytics tracking links to your emails"})}),es&&(0,a.jsxs)("div",{className:"mt-6 rounded-xl border border-gray-200 bg-white p-6 shadow-sm",children:[(0,a.jsxs)("div",{className:"mb-5 flex items-center pb-2 border-b border-gray-100",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)("svg",{className:"h-5 w-5 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),(0,a.jsx)("h3",{className:"ml-2.5 text-sm font-semibold text-gray-900",children:"UTM Parameters"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"block text-sm font-semibold text-gray-900 mb-2.5",children:["UTM Source ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("p",{className:"text-xs text-gray-600 mb-3 leading-relaxed",children:"Identifies which site sent the traffic (e.g., company name, newsletter)"}),(0,a.jsx)(h.Z,{name:"utmSource",type:"text",placeholder:"e.g., CampaignHQ",value:ea,onChange:e=>{ei(e)}})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"block text-sm font-semibold text-gray-900 mb-2.5",children:["UTM Medium ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("p",{className:"text-xs text-gray-600 mb-3 leading-relaxed",children:"Identifies what type of link was used (e.g., email, cpc, banner)"}),(0,a.jsx)(h.Z,{name:"utmMedium",type:"text",placeholder:"e.g., email",value:el,onChange:e=>{en(e)}})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"block text-sm font-semibold text-gray-900 mb-2.5",children:["UTM Campaign ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("p",{className:"text-xs text-gray-600 mb-3 leading-relaxed",children:"Identifies a specific product promotion or strategic campaign"}),(0,a.jsx)(h.Z,{name:"utmCampaign",type:"text",placeholder:"e.g., spring-sale",value:er,onCh
1ange:e=>{ed(e)}})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"block text-sm font-semibold text-gray-900 mb-2.5",children:["UTM Content ",(0,a.jsx)("span",{className:"text-gray-500 text-xs font-normal",children:"(optional)"})]}),(0,a.jsx)("p",{className:"text-xs text-gray-600 mb-3 leading-relaxed",children:"Identifies what specifically was clicked (e.g., logo link, text link)"}),(0,a.jsx)(h.Z,{name:"utmContent",type:"text",placeholder:"e.g., newsletter-link",value:ec,onChange:e=>{em(e)}})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"block text-sm font-semibold text-gray-900 mb-2.5",children:["UTM Term ",(0,a.jsx)("span",{className:"text-gray-500 text-xs font-normal",children:"(optional)"})]}),(0,a.jsx)("p",{className:"text-xs text-gray-600 mb-3 leading-relaxed",children:"Identifies search keywords (typically used for paid search)"}),(0,a.jsx)(h.Z,{name:"utmTerm",type:"text",placeholder:"e.g., running shoes",value:eu,onChange:e=>{eh(e)}})]})]})]})]})]}),(0,a.jsxs)("div",{className:"group relative flex items-start space-x-4 px-6 py-5 pb-8 border-t border-gray-200 bg-gray-50",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)(S.Z,{className:"h-5 w-5 text-white","aria-hidden":"true"})}),(0,a.jsx)("div",{className:"min-w-0 flex-1",children:(0,a.jsxs)("div",{className:"flex space-x-3",children:[(0,a.jsx)(j.zx,{type:"submit",loading:e9,disabled:e9,className:"sm:w-auto",children:"Save"}),(0,a.jsx)("button",{onClick:()=>V(!1),className:"inline-flex items-center justify-center px-5 py-2.5 text-sm font-medium text-gray-700 hover:text-gray-900 focus:outline-none sm:w-auto transition-colors",children:"Cancel"})]})})]})]})]})})]})]})}function MergeTag(){let[e,s]=(0,l.useState)(!1);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("a",{className:"text-xs font-semibold text-indigo-500 hover:cursor-pointer",onClick:()=>s(!e),children:"Contact Field"}),(0,a.jsx)(y.Z,{setOpen:s,open:e})]})}CampaignEdit.Layout=i.c}},function(e){e.O(0,[1739,9921,5675,2814,7536,7811,445,4135,9145,9135,4881,7917,8050,3410,1796,5447,4193,3708,6142,9774,2888,179],function(){return e(e.s=79242)}),_N_E=e.O()}]);

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.