PageSourceSearch

https://www.aiads.aisensy.com/357.03bdfd50a5692e3c654c.js

js aisensy.com collected 2026-09-24 18:21:44 UTC 1,829,282 bytes, 1 lines download raw bytes

1(self.webpackChunkwhatsapp_dashboard=self.webpackChunkwhatsapp_dashboard||[]).push([[357],{70176:(e,t,a)=>{"use strict";a.d(t,{A:()=>r});var n=a(23441),s=a(23664),o=a(18526);class i extends n.Component{state={hasError:!1};static getDerivedStateFromError(e){return{hasError:!0}}componentDidCatch(e,t){console.error(e,t),this.setState({errorInfo:t})}render(){return this.state.hasError?(0,o.jsx)(s.Grid,{container:!0,justify:"center",children:(0,o.jsx)(s.Grid,{item:!0,xs:11,md:8,children:(0,o.jsx)(s.Typography,{variant:"h2",align:"center",children:"Something doesn't feel right. Kindly, refresh."})})}):this.props.children}}const r=i},47766:(e,t,a)=>{"use strict";a.d(t,{Ay:()=>j,Dg:()=>s,fz:()=>o});a(71301),a(44665);const n={media:{AUDIO:[],VIDEO:[],IMAGE:[],FILE:[],PRODUCT:[]},loading:{AUDIO:!1,VIDEO:!1,IMAGE:!1,FILE:!1,PRODUCT:!1},loadingMore:{AUDIO:!1,VIDEO:!1,IMAGE:!1,FILE:!1,PRODUCT:!1},hasMore:{AUDIO:!1,VIDEO:!1,IMAGE:!1,FILE:!1},recent:{AUDIO:[],VIDEO:[],IMAGE:[],FILE:[],PRODUCT:[]},total:{AUDIO:0,VIDEO:0,IMAGE:0,FILE:0,PRODUCT:0},uploading:{AUDIO:{},VIDEO:{},IMAGE:{},FILE:{}},totalSize:0,mediaCount:{}}
1,s={IMAGE:"rgb(250, 173, 32, 0.15)",VIDEO:"rgb(95, 102, 205, 0.15)",FILE:"rgb(236, 64, 122, 0.15)",LOCATION:"rgb(255 5 5 / 17%)"},o={IMAGE:"rgb(250, 173, 32)",VIDEO:"rgb(95, 102, 205)",FILE:"rgb(236, 64, 122)",LOCATION:"rgb(239 0 0)"},i="MEDIA/IMAGE",r="MEDIA/AUDIO",l="MEDIA/VIDEO",d="MEDIA/FILE",c="MEDIA/RECENT_IMAGE",p="MEDIA/RECENT_AUDIO",u="MEDIA/RECENT_VIDEO",m="MEDIA/RECENT_FILE",h="MEDIA/MORE_IMAGE",g="MEDIA/MORE_AUDIO",b="MEDIA/MORE_VIDEO",y="MEDIA/MORE_FILE",x="MEDIA/IMAGE_STATUS",f="MEDIA/AUDIO_STATUS",A="MEDIA/VIDEO_STATUS",I="MEDIA/FILE_STATUS",C="MEDIA/MORE_IMAGE_STATUS",_="MEDIA/MORE_AUDIO_STATUS",S="MEDIA/MORE_VIDEO_STATUS",v="MEDIA/MORE_FILE_STATUS",E="MEDIA/ADD_UPLOADING_MEDIA",T="MEDIA/UPDATE_UPLOADING_MEDIA",D="MEDIA/REMOVE_UPLOADING_MEDIA",w="MEDIA/MEDIA_UPLOAD_COMPLETED",N="MEDIA/REMOVE_MEDIA";function j(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:n,{type:t,payload:a}=arguments.length>1?arguments[1]:void 0;switch(t){case i:return{...e,media:{...e.media,IMAGE:[...a.media]},hasMore:{...e.hasMore,IMAGE:20===a.media.length},total:{...e.total,IMAGE:a.totalMediaCount?a.totalMediaCount:e.total.IMAGE}};case l:return{...e,media:{...e.media,VIDEO:[...a.media]},hasMore:{...e.hasMore,VIDEO:20===a.media.length},total:{...e.total,VIDEO:a.totalMediaCount?a.totalMediaCount:e.total.VIDEO}};case r:return{...e,media:{...e.media,AUDIO:[...a.media]},hasMore:{...e.hasMore,AUDIO:20===a.media.length},total:{...e.total,AUDIO:a.totalMediaCount?a.totalMediaCount:e.total.AUDIO}};case d:return{...e,media:{...e.media,FILE:[...a.media]},hasMore:{...e.hasMore,FILE:20===a.media.length},total:{...e.total,FILE:a.totalMediaCount?a.totalMediaCount:e.total.FILE}};case c:return{...e,recent:{...e.recent,IMAGE:[...a.media]}};case u:return{...e,recent:{...e.recent,VIDEO:[...a.media]}};case p:return{...e,recent:{...e.recent,AUDIO:[...a.media]}};case m:return{...e,recent:{...e.recent,FILE:[...a.media]}};case x:return{...e,loading:{...e.loading,IMAGE:a.loading}};case A:return{...e,loading:{...e.loading,VIDEO:a.loading}};case f:return{...e,loading:{...e.loading,AUDIO:a.loading}};case I:return{...e,loading:{...e.loading,FILE:a.loading}};case h:return{...e,media:{...e.media,IMAGE:[...e.media.IMAGE,...a.media]},hasMore:{...e.hasMore,IMAGE:20===a.media.length}};case b:return{...e,media:{...e.media,VIDEO:[...e.media.VIDEO,...a.media]},hasMore:{...e.hasMore,VIDEO:20===a.media.length}};case g:return{...e,media:{...e.media,AUDIO:[...e.media.AUDIO,...a.media]},hasMore:{...e.hasMore,AUDIO:20===a.media.length}};case y:return{...e,media:{...e.media,FILE:[...e.media.FILE,...a.media]},hasMore:{...e.hasMore,FILE:20===a.media.length}};case C:return{...e,loadingMore:{...e.loadingMore,IMAGE:a.loading}};case S:return{...e,loadingMore:{...e.loadingMore,VIDEO:a.loading}};case _:return{...e,loadingMore:{...e.loadingMore,AUDIO:a.loading}};case v:return{...e,loadingMore:{...e.loadingMore,FILE:a.loading}};case E:return{...e,uploading:{...e.uploading,[a.fileType]:{...e.uploading[a.fileType],[a.id]:{...a}}}};case T:return{...e,uploading:{...e.uploading,[a.fileType]:{...e.uploading[a.fileType],[a.id]:{...e.uploading[a.fileType][a.id],...a}}}};case D:const t={...e.uploading[a.fileType]};return delete t[a.id],{...e,uploading:{...e.uploading,[a.fileType]:t}};case w:return{...e,recent:{...e.recent,[a.fileType]:[a,...e.recent[a.fileType]]}};case N:return{...e,recent:{...e.recent,[a.fileType]:[...e.recent[a.fileType].filter((e=>e._id!==a._id))]},media:{...e.media,[a.fileType]:[...e.media[a.fileType].filter((e=>e._id!==a._id))]}};default:return e}}},55457:(e,t,a)=>{"use strict";a.d(t,{$t:()=>l,dh:()=>d,n:()=>c});var n=a(23441),s=a(23664),o=a(53682),i=a(73546),r=a(18526);const l=(0,n.createContext)(null),d=()=>(0,n.useContext)(l),c=e=>{let{children:t}=e;const[a,d]=(0,n.useState)({open:!1,message:"",severity:"info",backgroundColor:"",customIcon:null,showUndoButton:!1,buttontext:""}),c=(0,n.useCallback)((function(e){d({open:!0,message:e,severity:arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",backgroundColor:arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",customIcon:arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,showUndoButton:arguments.length>4&&void 0!==arguments[4]&&arguments[4],buttontext:arguments.length>5&&void 0!==arguments[5]?arguments[5]:""})}),[]),p=()=>{d((e=>({...e,open:!1})))};return(0,r.jsxs)(l.Provider,{value:{showSnackbar:c},children:[t,(0,r.jsx)(s.Snackbar,{anchorOrigin:{vertical:"top",horizontal:"center"},open:a.open,autoHideDuration:5e3,onClose:p,style:{zIndex:3600},children:(0,r.jsx)(o.Alert,{severity:a.severity,style:a.backgroundColor?{backgroundColor:a.backgroundColor}:void 0,action:(0,r.jsxs)(r.Fragment,{children:[a.showUndoButton&&(0,r.jsx)(s.Button,{color:"inherit",size:"small",onClick:p,children:a.buttontext}),(0,r.jsx)(s.IconButton,{size:"small","aria-label":"close",color:"inherit",onClick:p,children:(0,r.jsx)(i.A,{fontSize:"small"})})]}),children:"string"==typeof a.message?a.message:JSON.stringify(a.message)})})]})}},44466:(e,t,a)=>{"use strict";a.d(t,{A:()=>kb});
1var n=a(23441),s=a.n(n),o=a(23664),i=a(42625),r=a(44258),l=a(49012),d=a(52305),c=a(14379),p=a(44431),u=a(19458);const m=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{agent:a,assistantDetails:n}=t;return!(e.aisensyOnly&&!(0,u.x)().isAiSensy)&&((!e.power||a?.power>=e.power)&&!!((e,t)=>{if(!t)return!0;const a=e?.specialAccess?.[t];return!0===a||"true"===a||Boolean(a&&"object"==typeof a&&(!0===a.value||"true"===a.value))})(n,e.specialAccess))};var h=a(18526);const g=e=>(0,h.jsx)("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",...e,children:(0,h.jsx)("path",{d:"M6 18V14M6 14H8L13 17V7L8 10H5C3.89543 10 3 10.8954 3 12V12C3 13.1046 3.89543 14 5 14H6ZM17 7L19 5M17 17L19 19M19 12H21"})}),b={fontSize:"20px"},y=[{id:"adsManagerMainPage",name:"Ads Manager",to:"/ads-manager",icon:(0,h.jsx)(g,{}),power:1},{id:"adTemplates",name:"Ads Agent",to:"/ads-agent",icon:(0,h.jsx)(c.A,{size:20}),power:1,isAi:!0,aisensyOnly:!0},{id:"leadGenPreview",name:"Leads",to:"/lead-gen-preview",icon:(0,h.jsx)(d.RecentActorsRounded,{style:b}),power:1},{id:"leadForms",name:"Forms",to:"/lead-forms",icon:(0,h.jsx)(d.DescriptionOutlined,{style:b}),power:1},{id:"audiences",name:"Audiences",to:"/audiences",icon:(0,h.jsx)(d.PeopleAlt,{style:b}),power:1},{id:"Event",name:"Events",to:"/events",icon:(0,h.jsx)(p.A,{style:b}),power:1},{id:"setup",name:"Setup",to:"/setup",icon:(0,h.jsx)(l.A,{style:b}),power:1},{id:"EventDetails",name:"Event Details",to:"/events/:eventId",icon:(0,h.jsx)(p.A,{style:b}),power:1,isNotShow:!0},{id:"leads",name:"Leads",to:"/leads",icon:(0,h.jsx)(d.RecentActorsRounded,{style:b}),power:1,isNotShow:!0},{id:"createAds",name:"Create Ads",to:"/create",icon:(0,h.jsx)(l.A,{style:b}),power:1,isNotShow:!0},{id:"editAds",name:"Edit Ads",to:"/edit/:adId",icon:(0,h.jsx)(l.A,{style:b}),power:1,isNotShow:!0},{id:"duplicateAds",name:"Duplicate Ads",to:"/duplicate/:adId",icon:(0,h.jsx)(l.A,{style:b}),power:1,isNotShow:!0},{id:"analytics",name:"Analiytics",to:"/:id/personal-analytics",icon:(0,h.jsx)(l.A,{style:b}),power:1,isNotShow:!0}],x=(e,t)=>y.filter((a=>m(a,{agent:e,assistantDetails:t}))),f=(e,t)=>x("object"==typeof e&&null!==e?e:{power:e},t).filter((e=>!e.isNotShow)),A=["/create","/edit/","/duplicate/","/personal-analytics"],I=/\/advertisement(-mfe)?\/datasets\/[^/]+/,C=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return A.some((t=>e.includes(t)))||I.test(e)},_="@media (max-width:958.95px)";var S=a(46110);const v=(0,o.makeStyles)((e=>({"@keyframes aiTwinkle":{"0%, 100%":{transform:"scale(1) rotate(0deg)",opacity:.8},"45%":{transform:"scale(1.3) rotate(70deg)",opacity:1},"70%":{transform:"scale(1.05) rotate(90deg)",opacity:.9}},"@keyframes aiShine":{"0%":{transform:"translateX(-130%)"},"45%, 100%":{transform:"translateX(130%)"}},root:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"2px 8px",borderRadius:10,fontSize:10,fontWeight:600,lineHeight:1,backgroundColor:"#D3FF6B",color:"black",textTransform:"uppercase",letterSpacing:"0.5px",height:"18px"},default:{width:"40px"},ai:{backgroundColor:"#14AE54",color:"#fff",gap:3,padding:"2px 7px",letterSpacing:"0.3px",position:"relative",overflow:"hidden","&::after":{content:'""',position:"absolute",top:0,left:0,width:"100%",height:"100%",background:"linear-gradient(100deg, transparent 25%, rgba(255,255,255,0.5) 50%, transparent 75%)",animation:"$aiShine 3.4s ease-in-out infinite",pointerEvents:"none"},"@media (prefers-reduced-motion: reduce)":{"&::after":{animation:"none",background:"none"}}},aiLabel:{position:"relative",zIndex:1},aiIcon:{display:"inline-flex",flexShrink:0,position:"relative",zIndex:1,transformOrigin:"center",animation:"$aiTwinkle 2.6s ease-in-out infinite","@media (prefers-reduced-motion: reduce)":{animation:"none"}}}))),E=e=>{let{label:t="NEW",variant:a="default",className:n,style:s}=e;const i=v();return"ai"===a?(0,h.jsxs)(o.Box,{className:`${i.root} ${i.ai} ${n||""}`,style:s,children:[(0,h.jsx)("span",{className:i.aiLabel,children:t}),(0,h.jsx)("span",{className:i.aiIcon,children:(0,h.jsx)(S.A,{size:10,
1color:"#FFD54A",fill:"#FFD54A"})})]}):(0,h.jsx)(o.Box,{className:`${i.root} ${i.default} ${n||""}`,style:s,children:t})};const T=(0,i.connect)((e=>({agent:e.login.user,assistantDetails:e.assistantDetails.data})))((function(e){let{classes:t,agent:a,basename:n,isCollapse:s,assistantDetails:i}=e;const l=(0,r.useLocation)(),d=(0,r.useHistory)();return C(l.pathname)?null:(0,h.jsx)("div",{className:t.root,style:{width:s?"48px":"280px"},children:(0,h.jsxs)(o.Box,{mx:2,children:[(0,h.jsx)(o.Box,{my:2,mb:3,style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:!s&&(0,h.jsx)(o.Box,{color:"#000000",display:"flex",alignItems:"center",justifyContent:"start",children:(0,h.jsx)(o.Typography,{variant:"h3",children:"Ads Manager"})})}),!s&&f(a,i).map((e=>{const a=l.pathname.includes(e.to)?"active":"inactive";return(0,h.jsx)(o.ButtonBase,{className:`${t.linkButton} ${t[a]}`,onClick:()=>d.push(n+e.to),children:(0,h.jsxs)(o.Grid,{container:!0,spacing:2,alignItems:"center",children:[(0,h.jsx)(o.Grid,{item:!0,children:(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",className:t["icon_"+a],children:e.icon})}),(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",children:[(0,h.jsx)(o.Typography,{variant:"body2",align:"left",style:{fontSize:14,transition:"1s ease-out"},className:t["name_"+a],children:e.name}),e.isAi?(0,h.jsx)(E,{style:{marginLeft:6},label:"AI",variant:"ai"}):e.isNew?(0,h.jsx)(E,{style:{marginLeft:6},label:"NEW"}):null]})})]})},e.id)}))]})})})),D=(0,o.withStyles)((e=>({root:{width:"280px",height:"100vh",background:"rgb(255, 255, 255)",borderRight:"1px solid rgb(240,240,240)",display:"flex",flexDirection:"column",transition:"0.5s ease-out",justifyContent:"space-between",color:"gray",[e.breakpoints.down("md")]:{width:"260px !important"},[_]:{display:"none"}},icon_active:{color:e.palette.primary.main},icon_inactive:{color:"rgb(20,20,20)"},name_active:{color:e.palette.primary.main},name_inactive:{color:"rgb(20,20,20)"},linkButton:{margin:"3px 0em",width:"100%",borderRadius:"5px",padding:"10px"},active:{backgroundColor:e.palette.primary.light},inactive:{backgroundColor:"transparent"}})))(T);const w=(0,i.connect)((e=>({agent:e.login.user,assistantDetails:e.assistantDetails.data})))((function(e){let{classes:t,agent:a,assistantDetails:n,basename:s}=e;const i=(0,r.useLocation)(),l=(0,r.useHistory)();if(C(i.pathname))return null;const d=f(a,n);return(0,h.jsxs)("div",{className:t.root,children:[(0,h.jsx)(o.Typography,{variant:"h3",className:t.title,children:"Ads Manager"}),(0,h.jsx)("div",{role:"tablist",className:t.tabs,children:d.map((e=>{const a=i.pathname.includes(e.to);return(0,h.jsxs)(o.ButtonBase,{role:"tab","aria-selected":a?"true":"false",className:`${t.tab} ${a?t.active:t.inactive}`,onClick:()=>l.push(s+e.to),children:[(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",className:t.icon,children:e.icon}),(0,h.jsx)(o.Typography,{variant:"body2",className:t.label,children:e.name}),e.isNew&&(0,h.jsx)(E,{style:{marginLeft:6},label:"NEW"})]},e.id)}))})]})})),N=(0,o.withStyles)((e=>({root:{height:56,boxSizing:"border-box",display:"flex",alignItems:"center",padding:"0 16px",background:"rgb(255, 255, 255)",borderBottom:"1px solid rgb(240,240,240)",color:"gray"},title:{marginRight:24,whiteSpace:"nowrap"},tabs:{display:"flex",alignItems:"center",height:"100%",overflowX:"auto"},tab:{height:"100%",padding:"0 14px",borderRadius:0,borderBottom:"3px solid transparent",display:"flex",alignItems:"center",gap:8,whiteSpace:"nowrap"},active:{borderBottomColor:e.palette.primary.main,"& $icon, & $label":{color:e.palette.primary.main}},inactive:{"& $icon, & $label":{color:"rgb(20,20,20)"}},icon:{},label:{fontSize:14}})))(w);var j=a(1842);const k=()=>"standalone"===(0,j._E)()?.hostInfo?.surface?"standalone":"console",L=()=>"standalone"===k();var R=a(36412);function B(e){let{name:t,fallback:a=null,...n}=e;const s=(0,j._E)()?.integrations?.[t];if(!("function"==typeof s||s&&s.$$typeof))return a;const o=s;return(0,h.jsx)(o,{...n})}var O=a(53682);function P(e){let{open:t,message:a,severity:s,onClose:i,autoHideDuration:r=3e3,anchorOrigin:l={vertical:"top",horizontal:"center"},alertProps:d,...c}=e;const p=(0,n.useRef)({message:"",severity:"error"});t&&(p.current={message:a,severity:s||"error"});const u=t?{message:a,severity:s||"error"}:p.current;return(0,h.jsx)(o.Snackbar,{open:!!t,autoHideDuration:r,anchorOrigin:l,onClose:i,...c,children:(0,h.jsx)(O.Alert,{severity:u.severity,onClose:i,...d,children:u.message})})}var M=a(18880),U=a(38221),F=a.n(U),W=a(82542),z=a(20345),G=a(15994);const H=(0,G.withStyles)((e=>({sectionTitle:{fontSize:16,fontWeight:500,color:"#1f2937",marginBottom:16},ratioCard:{marginBottom:16,borderRadius:8,boxShadow:"none",backgroundColor:"#ffffff"},optionCard:{marginBottom:16,borderRadius:8,backgroundColor:"#ffffff"},ratioDisplay:{fontSize:24,fontWeight:600,color:e?.palette?.primary?.main||"#3b82f6",textAlign:"center",marginBottom:8},ratioLabel:{fontSize:14,color:"#6b7280",textAlign:"center",marginBottom:16},explanationBox:{marginTop:12,padding:12,backgroundColor:"#f9fafb",borderRadius:8},warningBox:{padding:12,backgroundColor:e.palette.primary.light,borderRadius:8,marginBottom:16,textAlign:"center"}})))((e=>{let{classes:t,theme:a,lookalikeRatio:n,setLookalikeRatio:s,selectedCustomAudience:i}=e;return(0,h.jsxs)(o.Box,{style:{marginTop:16},children:[(0,h.jsx)(o.Box,{style:{display:"flex",alignItems:"center",marginBottom:16}
1,children:(0,h.jsx)(o.Typography,{className:t.sectionTitle,children:"Lookalike Configuration"})}),(0,h.jsx)(o.Card,{className:t.ratioCard,style:{opacity:i?1:.6},children:(0,h.jsxs)(o.CardContent,{style:{padding:16},children:[(0,h.jsxs)(o.Box,{style:{textAlign:"center",marginBottom:16},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",marginBottom:8},children:[(0,h.jsx)(d.TrendingUp,{style:{marginRight:8,color:a?.palette?.primary?.main||"#3b82f6"}}),(0,h.jsx)(o.Typography,{style:{fontSize:16,fontWeight:600,color:"#374151"},children:"Audience Size"})]}),(0,h.jsxs)(o.Typography,{className:t.ratioDisplay,children:[n,"%"]}),(0,h.jsx)(o.Typography,{className:t.ratioLabel,children:(e=>e<=1?"Very similar users, smaller audience":e<=2?"Balanced similarity and reach (recommended)":e<=5?"Broader reach, less similar users":"Maximum reach, least similar users")(n)})]}),(0,h.jsx)(o.Box,{style:{marginBottom:16},children:(0,h.jsx)(o.Slider,{value:n,onChange:(e,t)=>s(t),min:1,max:10,step:1,disabled:!i,marks:Array.from({length:10},((e,t)=>{const a=t+1;return{value:a,label:`${a}%`}})),style:{color:i?a?.palette?.primary?.main||"#3b82f6":"#d1d5db",height:8}})}),(0,h.jsxs)(o.Box,{className:t.explanationBox,children:[(0,h.jsx)(o.Typography,{style:{fontSize:14,color:"#374151",fontWeight:600,marginBottom:12},children:"How it works:"}),(0,h.jsxs)(o.Box,{style:{display:"flex",flexWrap:"wrap",gap:8},children:[(0,h.jsx)(o.Chip,{label:"1% - Very Similar",size:"small",onClick:()=>i&&s(1),style:{backgroundColor:1===n?a?.palette?.primary?.light||"#e0f2fe":"#f3f4f6",color:1===n?a?.palette?.primary?.main||"#3b82f6":"#374151",border:`1px solid ${1===n?a?.palette?.primary?.main||"#3b82f6":"#d1d5db"}`,cursor:i?"pointer":"not-allowed",opacity:i?1:.6}}),(0,h.jsx)(o.Chip,{label:"2% - Balanced (Recommended)",size:"small",onClick:()=>i&&s(2),style:{backgroundColor:2===n?a?.palette?.primary?.light||"#e0f2fe":"#f3f4f6",color:2===n?a?.palette?.primary?.main||"#3b82f6":"#374151",border:`1px solid ${2===n?a?.palette?.primary?.main||"#3b82f6":"#d1d5db"}`,cursor:i?"pointer":"not-allowed",opacity:i?1:.6}}),(0,h.jsx)(o.Chip,{label:"5% - Broader Reach",size:"small",onClick:()=>i&&s(5),style:{backgroundColor:5===n?a?.palette?.primary?.light||"#e0f2fe":"#f3f4f6",color:5===n?a?.palette?.primary?.main||"#3b82f6":"#374151",border:`1px solid ${5===n?a?.palette?.primary?.main||"#3b82f6":"#d1d5db"}`,cursor:i?"pointer":"not-allowed",opacity:i?1:.6}}),(0,h.jsx)(o.Chip,{label:"10% - Maximum Reach",size:"small",onClick:()=>i&&s(10),style:{backgroundColor:10===n?a?.palette?.primary?.light||"#e0f2fe":"#f3f4f6",color:10===n?a?.palette?.primary?.main||"#3b82f6":"#374151",border:`1px solid ${10===n?a?.palette?.primary?.main||"#3b82f6":"#d1d5db"}`,cursor:i?"pointer":"not-allowed",opacity:i?1:.6}})]})]})]})})]})})),V=[{key:"userNumber",label:"Phone",required:!0},{key:"userName",label:"Full Name",required:!0},{key:"email",label:"Email"}],Y=[{key:"firstName",label:"First Name"},{key:"lastName",label:"Last Name"},{key:"dob",label:"Date of Birth"},{key:"city",label:"City"},{key:"state",label:"State / Province"},{key:"zip",label:"Zip / Postal Code"},{key:"country",label:"Country"},{key:"gender",label:"Gender"},{key:"externId",label:"External ID"}],Z="__none__",K=e=>{let{csvHeaders:t,csvRowCount:a,csvMapping:s,dragActive:i,uploadedFileName:r,onFileSelect:l,onMappingChange:c,onClearFile:p,onDragActiveChange:u,sampleCsvUrl:m}=e;const g=(0,n.useRef)(null),b=(e,t)=>{const a={...s};t===Z?delete a[e]:(Object.entries(a).forEach((n=>{let[s,o]=n;s!==e&&o===t&&delete a[s]})),a[e]=t),c(a)},y=!!r,x=[...V,...Y],f=e=>{const a=(n=e.key,new Set(Object.entries(s).filter((e=>{let[t,a]=e;return t!==n&&a})).map((e=>{let[,t]=e;return t}))));var n;const i=s[e.key]||Z,r=i!==Z;return(0,h.jsxs)(o.Grid,{container:!0,spacing:1,alignItems:"center",style:{marginBottom:8},children:[(0,h.jsx)(o.Grid,{item:!0,xs:5,children:(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",gap:6},children:[(0,h.jsx)(o.Typography,{style:{fontSize:14,color:"#374151"},children:e.label}),e.required&&(0,h.jsx)(o.Chip,{label:"required",size:"small",style:{fontSize:10,height:18,backgroundColor:"#fee2e2",color:"#dc2626"}})]})}),(0,h.jsx)(o.Grid,{item:!0,xs:6,children:(0,h.jsx)(o.FormControl,{variant:"outlined",size:"small",fullWidth:!0,children:(0,h.jsxs)(o.Select,{value:i,onChange:t=>b(e.key,t.target.value),style:{backgroundColor:r?"#f0fdf4":"#fff",borderRadius:6,fontSize:14},children:[(0,h.jsx)(o.MenuItem,{value:Z,style:{color:"#9ca3af",fontSize:14},children:"— Not mapped —"}),t.map((e=>{const t=a.has(e);return(0,h.jsxs)(o.MenuItem,{value:e,style:{fontSize:14,color:t?"#9ca3af":"#111827"},children:[e,t&&(0,h.jsx)(o.Typography,{component:"span",style:{fontSize:11,color:"#9ca3af",marginLeft:6},children:"(in use — will reassign)"})]},e)}))]})})}),(0,h.jsx)(o.Grid,{item:!0,xs:1,style:{paddingLeft:0},children:r&&(0,h.jsx)(o.Tooltip,{title:"Remove mapping",placement:"top",children:(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>b(e.key,Z),style:{color:"#9ca3af",padding:4},children:(0,h.jsx)(d.Close,{style:{fontSize:16}})})})})]},e.key)};return(0,h.jsxs)(o.Box,{children:[y?(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",justifyContent:"space-between",backgroundColor:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:"12px 16px"},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",gap:10},children:[(0,h.jsx)(d.CheckCircle,{style:{color:"#16a34a",fontSize:20}}),(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{style:{fontSize:14,fontWeight:500,color:"#15803d"},children:r}),(0,h.jsxs)(o.Typography,{style:{fontSize:12,color:"#16a34a"}
1,children:[a.toLocaleString()," rows detected"]})]})]}),(0,h.jsx)(o.Button,{size:"small",onClick:p,style:{color:"#6b7280",minWidth:0,padding:4},children:(0,h.jsx)(d.Close,{fontSize:"small"})})]}):(0,h.jsxs)(o.Box,{onDragOver:e=>{e.preventDefault(),u(!0)},onDragLeave:()=>u(!1),onDrop:e=>{e.preventDefault(),u(!1);const t=e.dataTransfer.files[0];t&&t.name.endsWith(".csv")&&l(t)},onClick:()=>g.current?.click(),style:{border:"2px dashed "+(i?"#0a474c":"#D1D5DB"),borderRadius:8,padding:"40px 24px",textAlign:"center",cursor:"pointer",backgroundColor:i?"#f0fafa":"#FAFAFA",transition:"all 0.2s"},children:[(0,h.jsx)(d.CloudUpload,{style:{fontSize:40,color:i?"#0a474c":"#9ca3af",marginBottom:8}}),(0,h.jsx)(o.Typography,{style:{fontSize:15,color:"#374151",fontWeight:500},children:"Drag & drop your CSV file here"}),(0,h.jsx)(o.Typography,{style:{fontSize:13,color:"#9ca3af",marginTop:4},children:"or"}),(0,h.jsx)(o.Button,{variant:"outlined",size:"small",style:{marginTop:12,borderColor:"#0a474c",color:"#0a474c",textTransform:"none",borderRadius:6,pointerEvents:"none"},children:"Browse File"}),(0,h.jsx)("input",{ref:g,type:"file",accept:".csv",style:{display:"none"},onChange:e=>{const t=e.target.files[0];t&&(l(t),e.target.value="")}})]}),!y&&m&&(0,h.jsx)(o.Box,{style:{marginTop:8,textAlign:"center"},children:(0,h.jsx)("a",{href:m,download:!0,style:{fontSize:13,color:"#0a474c",textDecoration:"underline"},onClick:e=>e.stopPropagation(),children:"Download sample CSV"})}),y&&t.length>0&&(0,h.jsxs)(o.Box,{style:{marginTop:20},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",gap:6,marginBottom:12},children:[(0,h.jsx)(o.Typography,{style:{fontSize:15,fontWeight:500,color:"#111827"},children:"Map Your Columns to Meta Fields"}),(0,h.jsx)(o.Tooltip,{title:"All values are hashed with SHA-256 before being sent to Meta.",placement:"top",arrow:!0,children:(0,h.jsx)(d.Info,{style:{fontSize:16,color:"#9ca3af",cursor:"pointer"}})})]}),(0,h.jsxs)(o.Grid,{container:!0,spacing:0,style:{marginBottom:6},children:[(0,h.jsx)(o.Grid,{item:!0,xs:5,children:(0,h.jsx)(o.Typography,{style:{fontSize:11,color:"#9ca3af",fontWeight:600,paddingLeft:4,letterSpacing:"0.05em"},children:"META FIELD"})}),(0,h.jsx)(o.Grid,{item:!0,xs:6,children:(0,h.jsx)(o.Typography,{style:{fontSize:11,color:"#9ca3af",fontWeight:600,paddingLeft:4,letterSpacing:"0.05em"},children:"YOUR CSV COLUMN"})})]}),x.map((e=>f(e))),(0,h.jsx)(o.Box,{style:{marginTop:16,padding:"10px 14px",backgroundColor:"#f0fdf4",borderRadius:6,display:"flex",alignItems:"center",gap:8},children:(0,h.jsxs)(o.Typography,{style:{fontSize:14,color:"#15803d"},children:["👥 ",(0,h.jsx)("strong",{children:a.toLocaleString()})," contacts will be uploaded to this audience"]})})]})]})};var J=a(2915),$=a(66289),q=a(62231);const X=e=>{let{id:t,options:a,value:n,onChange:s,placeholder:i,classes:r,showTooltip:l=!1,showDescription:c=!1,label:p,description:u,marginBottom:m,width:g,optionWidth:b,showEventType:y=!1,button:x,isDisabled:f=!1,isFetching:A=!1,showHeader:I=!1,getOptionDisabled:C,getOptionTooltip:_,hasError:S=!1,errorTooltip:v}=e;return(0,h.jsxs)(o.Box,{style:{marginBottom:m||"0px"},children:[(p||u||x)&&(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",style:{marginBottom:"8px"},children:[(0,h.jsxs)(o.Box,{children:[p&&(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:p}),u&&(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:u})]}),x&&(0,h.jsx)(o.Box,{children:x})]}),A?(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,style:{borderRadius:"10px"}}):(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"flex-start",style:{gap:"8px"},children:[(0,h.jsx)(o.Box,{flexGrow:S?0:1,minWidth:0,children:(0,h.jsx)(O.Autocomplete,{id:t,disableClearable:!0,options:a,getOptionLabel:e=>e.label,getOptionDisabled:C,style:{marginTop:"8px",width:g||"100%"},onChange:s,groupBy:I?e=>e.header:void 0,value:n,disabled:f,renderOption:e=>{const t=!!C&&C(e),a=t&&_?_(e):null,n=l?(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",width:"100%",children:[(0,h.jsx)(o.Typography,{style:{width:b||"3
10px"},children:e.label}),e.tooltip&&(0,h.jsx)(o.Tooltip,{title:(0,h.jsx)(o.Typography,{style:{whiteSpace:"pre-line"},children:e.tooltip}),arrow:!0,placement:"right",children:(0,h.jsx)(d.Info,{style:{fontSize:"18px",cursor:"pointer",marginLeft:"8px"}})})]}):c?(0,h.jsxs)(o.Box,{width:"100%",children:[(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",gap:"8px",children:(0,h.jsx)(o.Typography,{children:e.label})}),e.description&&(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:e.description})]}):(0,h.jsx)(o.Typography,{children:e.label});if(t&&a){const e=(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",children:[(0,h.jsx)(o.Box,{flexGrow:1,children:n}),(0,h.jsx)(d.Error,{style:{color:"#ef4444",fontSize:"18px",marginLeft:"8px",flexShrink:0}})]});return(0,h.jsx)(o.Tooltip,{title:a,placement:"bottom",arrow:!0,enterDelay:0,leaveDelay:0,children:(0,h.jsx)(o.Box,{style:{width:"100%",pointerEvents:"auto",cursor:"not-allowed"},children:(0,h.jsx)("div",{style:{pointerEvents:"none",width:"100%"},children:e})})})}return n},renderInput:e=>(0,h.jsx)(o.TextField,{id:`${t}-field`,...e,className:r?.textField,InputProps:{...e.InputProps},placeholder:i})})}),S&&(0,h.jsx)(o.Tooltip,{title:v||"One or more options here have an issue.",placement:"top",arrow:!0,children:(0,h.jsx)(d.Error,{style:{color:"#ef4444",fontSize:"22px",marginTop:"8px",flexShrink:0,cursor:"not-allowed"}})})]})]})},Q=[{label:"ALL",tooltip:"Capture Accounts Centre accounts who completed any one of these actions.\nExample 1: People who have searched for an item on your website, OR people who added an item to their basket, OR people who added an item to their wishlist.\nExample 2: People who purchased on your website, OR people who purchased in your mobile app, OR people who are in your customer list."},{label:"ANY",tooltip:"Capture Accounts Centre accounts who MUST complete all of these actions.\nExample 1: People who searched for an item on your website in the last 14 days AND made a purchase on your website in the last 180 days.\nExample 2: People who watched your video AND people who are in your customer list.\n\nRequiring your audience to meet the All criteria may cause the audience size to be very small."}],ee=[{id:"ALL_VISITORS",label:"All website visitors",description:"Includes people who have visited any of your websites."},{id:"VISITORS_BY_URL",label:"People who visited specific web pages",description:"Includes people who have visited specific websites or web pages."},{id:"TOP_TIME_SPENDERS",label:"Visitors by time spent"}],te=[{label:"All"},{label:"All mobile devices",description:"This includes smartphones and tablets."},{label:"iOS"},{label:"Android"},{label:"Desktop"}],ae=[{label:"contains"},{label:"doesn't contain"},{label:"equals"}],ne=[{specialCase:!0,label:"URL/Parameter",tooltip:"Specify a URL or parameter for your event (e.g. purchases that total a certain amount)."},{label:"Aggregated Value",tooltip:"Aggregated value allows you to specify the frequency of an event (e.g. purchased five times), or to refine by the sum, average, maximum or minimum value of a parameter (e.g. purchases of more than £50)."},{label:"Device"}],se=[{label:"Frequency"},{label:"Sum of"},{label:"Average of"},{label:"Maximum of"},{label:"Minimum of"}],oe=[{id:"gte",label:"is greater than or equal to (≥)"},{id:"gt",label:"is greater than (>)"},{id:"eq",label:"equals"},{id:"neq",label:"doesn't equal"},{id:"lte",label:"is less than or equal to (≤)"},{id:"lt",label:"is less than (<)"}],ie=[{id:"url",label:"URL"}],re=[{id:"i_contains",label:"contains"},{id:"i_not_contains",label:"doesn't contain"},{id:"i_equals",label:"equals"},{id:"i_not_equals",label:"doesn't equal"},{id:"i_starts_with",label:"starts with"},{id:"i_ends_with",label:"ends with"},{id:"gte",label:"is greater than or equal to (≥)"},{id:"gt",label:"is greater than (>)"},{id:"lte",label:"is less than or equal to (≤)"},{id:"lt",label:"is less than (<)"}],le=e=>{let{label:t,onClick:a,variant:n="outlined",disabled:s=!1,...i}=e;return(0,h.jsx)(o.Button,{variant:n,onClick:a,disabled:s,...i,children:t})},de=e=>{let{children:t,marginTop:a="0px"}=e;return(0,h.jsx)(o.Box,{style:{borderRadius:"8px",padding:"12px",background:"white",border:"12px solid #f3f5f5",marginTop:a},children:(0,h.jsx)(o.Box,{style:{background:"white",borderRadius:"8px",padding:"16px"},children:t})})},ce=e=>{let{onClick:t,withBorder:a=!1}=e;return(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",...a&&{marginBottom:"20px",paddingBottom:"20px",borderBottom:"1px solid black"}},onClick:t,children:[(0,h.jsx)(d.DeleteOutline,{}),(0,h.jsx)(o.Typography,{children:"Remove"})]})},pe=e=>{let{title:t}=e;return(0,h.jsx)(o.Box,{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:(0,h.jsxs)(o.Typography,{children:[t,(0,h.jsx)("span",{style:{color:"gray"},children:" ∙ Optional"})]})})},ue=e=>{let{label:t,tooltipText:a,children:n}=e;return(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",width:"100%",marginBottom:"8px",children:[(0,h.jsx)(o.Typography,{children:t}),a&&(0,h.jsx)(o.Tooltip,{title:(0,h.jsx)(o.Typography,{style:{whiteSpace:"pre-line"},children:a}),arrow:!0,placement:"right",children:(0,h.jsx)(d.Info,{style:{fontSize:"18px",cursor:"pointer",marginLeft:"8px"}})}),n]})},me=e=>{let{criteriaType:t,onRemove:a,showRemove:n=!1}=e;return n?(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",style:{marginBottom:"16
1px"},children:[(0,h.jsx)(o.Typography,{variant:"h5",style:{fontWeight:"600"},children:"ANY"===t?"Or":"And"}),(0,h.jsx)(o.IconButton,{style:{padding:"0px"},onClick:a,children:(0,h.jsx)(d.Close,{})})]}):null},he=e=>{let{children:t,onClick:a,color:n="#0a78be"}=e;return(0,h.jsx)(o.Typography,{style:{color:n,cursor:"pointer"},onClick:a,children:t})},ge=e=>{let{rule:t,originalIndex:a,rules:n,setRules:s,classes:i,config:r,pixelEventsCustomFields:l}=e;const{showFieldSelector:c=!1,fieldOptions:p=[],operatorOptions:u=[],dataKey:m,valueKey:g,title:b,removeButtonStyle:y="RemoveButton",showConnectorText:x=!1,addButtonConfig:f={},defaultItem:A={}}=r,I=t[m]||[],C=()=>{const e=[...n];e[a][m]||(e[a][m]=[]),e[a][m].push({...A}),s(e)},_=e=>{try{const t=[...n];t[a][m].splice(e,1),0===t[a][m]?.length&&(delete t[a][m],"urlParameterFilters"===m&&(t[a].furtherRefineBy={})),s(t)}catch(e){console.log("Error removing item:",e)}};if(0===I?.length)return null;const S=e=>"IconButton"===y?(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>{try{_(e)}catch(e){console.log("Error removing item:",e)}},style:{padding:"4px",color:"#666"},children:(0,h.jsx)(d.Close,{fontSize:"small"})}):0==e?null:(0,h.jsx)(ce,{withBorder:!0,onClick:()=>{try{_(e)}catch(e){console.log("Error removing item:",e)}}}),v=(e,a)=>{const{type:n,label:s,showOnLastOnly:o,disabledCondition:i,additionalCondition:r}=f;if(!s)return null;if("link"===n)return null;if(o&&!a)return null;if(r&&!r(t))return null;const l=!!i&&i(I);return(0,h.jsx)(le,{label:s,disabled:l,onClick:C})},E=()=>{if(t.events?.id){const e=t.events?.id,a=l?.[e]||[];return[...ie,...a]}return[]};return(0,h.jsxs)(de,{marginTop:"20px",children:[I.map(((e,t)=>{const r=t===I.length-1,l=e[g]||[];return(0,h.jsxs)(o.Box,{children:[t>0&&x&&(0,h.jsx)(o.Typography,{variant:"body2",style:{marginBottom:"16px",marginTop:"16px",color:"#666"},children:"And the same URL/parameter must ALSO match"}),(0,h.jsxs)(o.Box,{style:{borderRadius:"8px",marginBottom:"16px",position:"relative",backgroundColor:"#fff"},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"16px"},children:[(0,h.jsx)(o.Typography,{variant:"h6",style:{fontWeight:"600"},children:b}),"IconButton"===y&&S(t)]}),(0,h.jsxs)(o.Box,{style:{display:"flex",gap:"16px",marginBottom:"16px",flexWrap:"wrap",alignItems:"flex-start"},children:[c&&(0,h.jsx)(X,{id:`${m}-field-${a}-${t}`,options:E(),value:e.field,onChange:(e,o)=>((e,t)=>{const o=[...n];o[a][m][e].field=t,s(o)})(t,o),placeholder:"Select field",classes:i,width:"200px",marginBottom:"0px"}),(0,h.jsx)(X,{id:`${m}-operator-${a}-${t}`,options:u,value:e.operator,onChange:(e,o)=>((e,t)=>{const o=[...n];o[a][m][e].operator=t,s(o)})(t,o),placeholder:"Select operator",classes:i,width:c?"200px":"250px",marginBottom:"0px"})]}),(0,h.jsx)(o.Box,{style:{border:"1px solid #c4c4c4",borderRadius:"8px",padding:"8px 12px",backgroundColor:"#fff",marginBottom:"16px",overflow:"hidden"},children:(0,h.jsx)(q.u,{value:l,classNames:{input:"rti--container"},onChange:e=>((e,t)=>{const o=[...n];o[a][m][e][g]=t,s(o)})(t,e),placeHolder:"At least one of these values"})}),"RemoveButton"===y&&S(t),v(0,r)]})]},t)})),(()=>{const{type:e,label:t}=f;return"link"===e&&t?(0,h.jsx)(he,{onClick:C,children:t}):null})()]})},be=e=>{let{rule:t,index:a,originalIndex:n,rules:s,setRules:i,classes:r,pixels:l,criteriaType:d,pixelEvents:c,pixelEventsCustomFields:p,fetchPixelDetails:u,assistantDetails:m}=e;const g=(e,t)=>{const a=[...s];a[n][e]=t,i(a)};return(0,h.jsxs)(o.Box,{style:{border:"1px solid black",borderRadius:"8px",minHeight:"100px",margin:"20px 0px",padding:"16px"},children:[(0,h.jsx)(me,{criteriaType:d.label,showRemove:a>0,onRemove:()=>{const e=[...s];e.splice(n,1),i(e)}}),(0,h.jsx)(X,{id:`data-source-text-${n}`,options:l.filter((e=>"ACTIVE"===e.status)).map((e=>({label:`${e.name} (${e.pixelId})`,value:e.pixelId}))),value:t.dataSource,onChange:async(e,t)=>{if(g("dataSource",t),t?.value&&m?.assistantId)try{await u({assistantId:m.assistantId,pixelId:t.value})}catch(e){console.log("Error fetching pixel details:",e)}},placeholder:"Select data source",classes:r,label:"Data Source",marginBottom:"16
1px"}),(0,h.jsx)(X,{id:`events-text-${n}`,isDisabled:!t.dataSource?.value,options:(()=>{const e=ee.map((e=>({...e,isBaseOption:!0})));if(t.dataSource?.value){const a=t.dataSource.value;(c?.[a]||[]).forEach((t=>{e.find((e=>e.id===t.id))||e.push({...t,isFetchedEvent:!0})}))}return e})(),value:t.events,onChange:async(e,a)=>{const o=[...s];if(o[n].events=a,"TOP_TIME_SPENDERS"===a.id&&(o[n].aggregationMethod="percentile",o[n].percentileValue=25),ee.find((e=>e.id===a.id))&&(o[n].urlParameterFilters=[]),!ee.find((e=>e.id===a.id))&&a?.id&&m?.assistantId)try{await u({assistantId:m.assistantId,pixelId:t.dataSource.value,event:a.id})}catch(e){console.log("Error fetching pixel details:",e)}o[n].urlAction=[],o[n].furtherRefineBy={},o[n].filters=[],o[n].deviceAction=null,o[n].aggregatedValueAction=null,o[n].percentileValue=null,o[n].retentionDays=30,i(o),"VISITORS_BY_URL"==a.id&&(o[n].urlAction=[{field:"url",operator:{label:"contains"},value:""}])},placeholder:"Select events",classes:r,showDescription:!0,showEventType:!0,label:"Events",marginBottom:"16px"}),"TOP_TIME_SPENDERS"===t.events?.id&&(0,h.jsx)(o.Box,{style:{marginBottom:"16px"},children:"percentile"===t.aggregationMethod&&(0,h.jsxs)(o.Box,{style:{marginBottom:"16px"},children:[(0,h.jsx)(ue,{label:"Percentile",tooltipText:"Select the top percentage of time spenders to include in the audience"}),(0,h.jsx)(X,{id:`percentile-text-${n}`,options:[{label:"Top 25%",value:25},{label:"Top 10%",value:10},{label:"Top 5%",value:5}],value:t.percentileValue?{label:`Top ${t.percentileValue}%`,value:t.percentileValue}:{label:"Top 25%",value:25},onChange:(e,t)=>
1{const a=[...s];a[n].percentileValue=t.value,i(a)},placeholder:"Select percentile",classes:r,label:"",marginBottom:"16px"})]})}),(0,h.jsxs)(o.Box,{style:{marginBottom:"16px"},children:[(0,h.jsx)(ue,{label:"Audience retention",tooltipText:"Enter the number of days that you want Accounts Centre\naccounts to remain in your audience after meeting the\nwebsite traffic criteria that you've specified. People\nwill be removed from your audience after this time\nunless they meet the criteria again.\n\nMaximum time: 180 days"}),(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",width:"100%",children:[(0,h.jsx)(o.TextField,{id:`retention-days-text-${n}`,type:"number",value:t.retentionDays,onChange:e=>{g("retentionDays",e.target.value)},classes:r,marginBottom:"16px"}),(0,h.jsx)(o.Typography,{style:{marginLeft:"8px"},children:"days"})]})]}),null!=t.aggregatedValueAction&&(0,h.jsxs)(de,{marginTop:"20px",children:[(0,h.jsx)(pe,{title:"Aggregated value"}),(0,h.jsxs)(o.Box,{style:{display:"flex",margin:"16px 0px",background:"#f9f9fb",borderRadius:"8px"},children:[(0,h.jsx)(X,{id:`aggregated-value-field-text-${n}`,options:se,value:t.aggregatedValueAction.field,onChange:(e,t)=>
1{const a=[...s];a[n].aggregatedValueAction.field=t,i(a)},classes:r,width:"150px"}),"Frequency"!==t.aggregatedValueAction.field?.label&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(X,{id:`aggregated-value-custom-data-${n}`,options:[{label:"Custom Data"}],value:t.aggregatedValueAction.customData,onChange:(e,t)=>{const a=[...s];a[n].aggregatedValueAction.customData=t,a[n].aggregatedValueAction.customDataValue="custom data",i(a)},classes:r,width:"120px"}),(0,h.jsx)(o.TextField,{id:`aggregated-value-custom-data-value-${n}`,placeholder:"custom data",value:t.aggregatedValueAction.customDataValue,onChange:e=>{const t=[...s];t[n].aggregatedValueAction.customDataValue=e.target.value,i(t)},className:r.textField,inputProps:{style:{height:"30px"}}})]}),(0,h.jsx)(X,{id:`aggregated-value-operator-text-${n}`,options:oe,value:t.aggregatedValueAction.operator,onChange:(e,t)=>{const a=[...s];a[n].aggregatedValueAction.operator=t,i(a)},classes:r,width:"200px"})," ",!("TOP_TIME_SPENDERS"===t.events.id&&"percentile"===t.aggregationMethod)&&(0,h.jsx)(o.TextField,{id:`aggregated-value-value-text-${n}`,type:"number",placeholder:"TOP_TIME_SPENDERS"===t.events.id?"Time in seconds":"Add a value",value:t.aggregatedValueAction.value,onChange:e=>{const t=[...s];t[n].aggregatedValueAction.value=e.target.value,i(t)},className:r.textField,inputProps:{style:{height:"30px"}}})]}),(0,h.jsx)(ce,{onClick:()=>{try{const e=[...s];e[n].aggregatedValueAction=null,i(e)}catch(e){console.log("Error removing aggregated value action:",e)}}})]}),null!=t.deviceAction&&(0,h.jsxs)(de,{marginTop:"20px",children:[(0,h.jsx)(pe,{title:"Device"}),(0,h.jsx)(X,{id:`device-action-text-${n}`,options:te,value:t.deviceAction,onChange:(e,t)=>
1{const a=[...s];a[n].deviceAction=t,i(a)},classes:r,marginBottom:"16px"}),(0,h.jsx)(ce,{onClick:()=>{try{const e=[...s];e[n].deviceAction={},i(e)}catch(e){console.log("Error removing device action:",e)}}})]}),t.urlAction.length>0&&(0,h.jsx)(ge,{rule:t,originalIndex:n,rules:s,setRules:i,classes:r,config:{showFieldSelector:!1,operatorOptions:ae,dataKey:"urlAction",valueKey:"value",title:"URL",removeButtonStyle:"RemoveButton",showConnectorText:!1,addButtonConfig:{type:"button",label:"Add another rule",showOnLastOnly:!0,disabledCondition:e=>e.length>=5||e.find((e=>!e.value)),additionalCondition:e=>"TOP_TIME_SPENDERS"!==e.events.id},defaultItem:{field:"url",operator:{label:"contains"},value:""}}}),t.urlParameterFilters&&t.urlParameterFilters.length>0&&(0,h.jsx)(ge,{rule:t,originalIndex:n,rules:s,setRules:i,classes:r,config:{showFieldSelector:!0,fieldOptions:ie,operatorOptions:re,dataKey:"urlParameterFilters",valueKey:"values",title:"URL or parameter",removeButtonStyle:"IconButton",showConnectorText:!0,addButtonConfig:{type:"link",label:"+ And also",showOnLastOnly:!1},defaultItem:{field:ie[0],operator:re[0],values:[]}},pixelEventsCustomFields:p}),0===t.urlAction.length&&"TOP_TIME_SPENDERS"===t.events.id&&(0,h.jsx)(he,{onClick:()=>{const e=[...s];e[n]={...e[n],urlAction:[{field:"url",operator:{label:"contains"},value:""}]},i(e)},children:"+ Select specific web page(s)"}),!["ALL_VISITORS","TOP_TIME_SPENDERS"].includes(t.events.id)&&(null==t.deviceAction||null==t.aggregatedValueAction)&&(0,h.jsx)(o.Box,{children:(0,h.jsx)(X,{id:`further-refine-by-text-${n}`,options:ne.filter((e=>!(e.specialCase&&ee.find((e=>e.id===t.events.id))||"Aggregated Value"===e.label&&null!=t.aggregatedValueAction||"Device"===e.label&&null!=t.deviceAction||"URL/Parameter"===e.label&&t.urlParameterFilters?.length>0))),value:t.furtherRefineBy,onChange:(e,t)=>
1{const a=[...s];a[n].furtherRefineBy=t,"Aggregated Value"===t.label?a[n].aggregatedValueAction={field:se[0],operator:oe[0],value:""}:"Device"===t.label?a[n].deviceAction={label:"Desktop"}:"URL/Parameter"===t.label&&(a[n].urlParameterFilters=[{field:ie[0],operator:re[0],values:[]}]),i(a)},placeholder:"Select further refine by",classes:r,showTooltip:!0,optionWidth:"210px",width:"210px"})})]})},ye=(0,i.connect)((e=>({assistantDetails:e.assistantDetails.data,pixels:e.audience.pixels,pixelsLoading:e.audience.pixelsLoading,pixelsError:e.audience.pixelsError,pixelsPagination:e.audience.pixelsPagination,pixelEvents:e.audience.pixelEvents,pixelEventsCustomFields:e.audience.pixelEventsCustomFields})),{fetchAssistantDetails:$.lq,fetchPixels:z.aR,fetchPixelDetails:z.X3})((e=>{let{classes:t,assistantDetails:a,pixels:s,pixelDetails:i,pixelEvents:r,pixelsLoading:l,onRuleDefinitionChange:c,pixelId:p,...u}=e;const m={ruleType:"include",dataSource:[],events:ee[0],retentionDays:30,furtherRefineBy:{},urlAction:[],urlParameterFilters:[],aggregatedValueAction:null,filters:[],deviceAction:null,urlParameterFilters:[]},[g,b]=(0,n.useState)(Q[0]),[y,x]=(0,n.useState)([m]);return(0,n.useEffect)((()=>{const e=a?.assistantId;!e||l||s&&0!==s.length||u.fetchPixels({assistantId:e,page:1,limit:100,search:""})}),[a?.assistantId,a?.adSetupDetails?.isAdsSetupCompleted,u.fetchPixels,s,l]),(0,n.useEffect)((()=>{y.length>0&&g.label&&c({rules:y,criteriaType:g})}),[y]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("style",{children:"\n          .rti--container:hover {\n            border: none !important;\n            outline: none !important;\n            box-shadow: none !important;\n          }\n          .rti--container:focus {\n            border: none !important;\n            outline: none !important;\n            box-shadow: none !important;\n          }\n          .rti--container {\n            padding: 4px !important;\n            font-size: 14px !important;\n            border: none !important;\n            box-shadow: none !important;\n          }\n          .rti--tag {\n            max-width: 100%;\n            word-break: break-all;\n          }\n          .rti--tag span {\n            max-width: 100%;\n            overflow: hidden;\n            text-overflow: ellipsis;\n            word-break: break-all;\n          }\n          .rti--input {\n            width: 100% !important;\n          }\n        "}),(0,h.jsx)(o.Grid,{children:(0,h.jsxs)(o.Grid,{container:!0,spacing:3,xs:12,children:[(0,h.jsx)(X,{id:"criteria-type-text",options:Q,value:g,onChange:(e,t)=>
1{b(t)},placeholder:"Select criteria type",classes:t,showTooltip:!0,label:"Select Criteria",description:"Include people who meet one or more of the following criteria:"}),(0,h.jsx)(o.Grid,{xs:12,children:y.filter((e=>"exclude"!=e.ruleType)).map(((e,n)=>{const o=y.findIndex((t=>t===e));return(0,h.jsx)(be,{rule:e,index:n,originalIndex:o,rules:y,setRules:x,classes:t,pixels:s,criteriaType:g,pixelEvents:r,pixelEventsCustomFields:u.pixelEventsCustomFields,fetchPixelDetails:u.fetchPixelDetails,assistantDetails:a,usePixelsForDataSource:!0},`include-${o}`)}))}),y?.length<5&&(0,h.jsxs)(o.Grid,{display:"flex",style:{gap:"8px"},container:!0,xs:12,children:["ANY"==g.label?(0,h.jsx)(le,{label:"Include more people",onClick:()=>x([...y,m])}):(0,h.jsx)(le,{label:"Narrow Further",onClick:()=>x([...y,{...m,ruleType:"include"}])}),(0,h.jsx)(le,{label:"Exclude people",onClick:()=>x([...y,{...m,ruleType:"exclude"}])})]}),y?.find((e=>"exclude"==e.ruleType))&&(0,h.jsxs)(o.Grid,{xs:12,style:{marginTop:"20px"},children:[(0,h.jsxs)(o.Typography,{variant:"h5",style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,h.jsx)(d.RemoveCircle,{}),"Exclude people who meet any of the following criteria:"]}),y.filter((e=>"exclude"===e.ruleType)).map(((e,n)=>{const o=y.findIndex((t=>t===e));return(0,h.jsx)(be,{rule:e,index:n,originalIndex:o,rules:y,setRules:x,classes:t,pixels:s,criteriaType:g,pixelEvents:r,fetchPixelDetails:z.X3,assistantDetails:a,usePixelsForDataSource:!1},`exclude-${o}`)})),y?.length<5&&(0,h.jsx)(o.Grid,{display:"flex",style:{gap:"8px"},container:!0,xs:12,children:(0,h.jsx)(le,{label:"Exclude people",onClick:()=>x([...y,{...m,ruleType:"exclude"}])})})]})]})})]})})),xe=(0,o.withStyles)((e=>({textField:{width:"100%",'& .MuiAutocomplete-input, & [class*="MuiAutocomplete-input-"]':{},[e.breakpoints.down("sm")]:{width:"100%"}}})))((0,r.withRouter)(ye)),fe=e=>({gte:">=",gt:">",eq:"=",neq:"!=",lte:"<=",lt:"<"}[e]||">="),Ae=e=>{const t=(e=>{if(!e)throw new Error("Data source is required for rule conversion");if("string"==typeof e)return e;if(Array.isArray(e))throw new Error("Data source cannot be an empty array. Please select a pixel.");if(e.value)return e.value;if(e.pixelId)return e.pixelId;throw new Error("Unable to extract pixel ID from data source")})(e.dataSource),a=86400*(e.retentionDays||30),n=(e=>{const t=e.events?.id;return"ALL_VISITORS"===t?"ALL_VISITORS":"TOP_TIME_SPENDERS"===t?"TOP_TIME_SPENDERS":"VISITORS_BY_URL"===t||e.urlAction&&e.urlAction.length>0?"VISITORS_BY_URL":"ALL_VISITORS"})(e),s=(e=>{const t=e.events?.id,a=e.aggregatedValueAction,n=e.aggregationMethod,s=e.percentileValue;if("TOP_TIME_SPENDERS"===t)return n?"percentile"===n?{type:"time_spent",method:"percentile",operator:"in_range",value:{from:100-(s||25),to:100}}:{type:"time_spent",method:"absolute",operator:a?.operator?fe(a.operator.id||a.operator):">",value:parseFloat(a?.value||0)||0}:{type:"time_spent",method:"absolute",operator:">",value:a?.value||0};if("Frequency"===a?.field?.label){const e=a.operator?fe(a.operator.id||a.operator):">=",t=a.value||0;return{type:"count",method:"absolute",operator:e,value:parseFloat(t)||0}}if(a?.field){const e={"Sum of":"sum","Average of":"avg","Maximum of":"max","Minimum of":"min"}[a.field.label||a.field];if(e){const t=a.operator?fe(a.operator.id||a.operator):">=",n=a.value||0,s=a.customDataValue||"value";return{type:e,method:"absolute",operator:t,value:parseFloat(n)||0,field:s}}}return null})(e),o="TOP_TIME_SPENDERS"===n||"Frequency"===e.aggregatedValueAction?.field?.label,i=(e=>{if(!e||0===e.length)return[];const t=[];return e.forEach((e=>{if(!e||!e.operator)return;const a={contains:"i_contains","doesn't contain":"i_not_contains",equals:"i_equals"}[e.operator.label||e.operator]||"i_contains";let n=[];if(!e.value)throw new Error("Invalid URL value");Array.isArray(e.value)?n=e.value:e.value&&"string"==typeof e.value&&(n=e.value.split(",").map((e=>e.trim()))),n.forEach((e=>{e&&e.trim()&&t.push({field:"url",operator:a,value:e.trim()})}))})),t})(e.urlAction||[]),r=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const a=[];if(t&&Array.isArray(t)&&t.forEach((e=>
1{"event"===e.field&&a.push({field:"event",operator:(e.operator,"i_equals"),value:e.value})})),e&&e.id){const t=e.id;if("ALL_VISITORS"===t||"VISITORS_BY_URL"===t||"TOP_TIME_SPENDERS"===t)return a;(e.label||e.name)&&a.push({field:"event",operator:"i_equals",value:e.label||e.name})}return a}(e.events,e.filters),l=(e=>{if(!e||0===e.length)return[];const t=[];return e.forEach((e=>{if(!e||!e.field||!e.operator)return;const a=e.field.id||e.field,n={i_contains:"i_contains",i_not_contains:"i_not_contains",i_equals:"i_equals",i_not_equals:"i_neq",i_starts_with:"i_starts_with",i_ends_with:"i_ends_with",gte:"i_gte",gt:"i_gt",lte:"i_lte",lt:"i_lt"}[e.operator.id||e.operator]||"i_contains";(e.values||[]).forEach((e=>{(e&&e.trim&&""!==e.trim()||e&&"string"==typeof e&&""!==e.trim())&&t.push({field:a,operator:n,value:e.trim()})}))})),t})(e.urlParameterFilters||[]);let d=[];o||(d=(e=>{if(!e)return[];const t=[],a=e.field?.label||e.field,n=e.operator,s=e.value;if(!n||null==s||""===s)return[];const o={gte:"i_gte",gt:"i_gt",eq:"i_eq",neq:"i_neq",lte:"i_lte",lt:"i_lt"}[n.id||n]||"i_eq",i=parseFloat(s);if(isNaN(i))return[];if(e.customData&&e.customDataValue&&"custom data"!==e.customDataValue.trim()){const a=e.customDataValue.trim();a&&t.push({field:a,operator:o,value:i})}else"Frequency"!==a&&t.push({field:"value",operator:o,value:i});return t})(e.aggregatedValueAction,e.events));const c=(e.deviceAction,[]),p=[...i,...r,...l,...d,...c];"ALL_VISITORS"!==n&&"TOP_TIME_SPENDERS"!==n||0!==p.length||p.push({field:"url",operator:"i_contains",value:""});let u=null;if(p.length>0){let e="and";e=1===p.length?"and":i.length>1&&0===r.length&&0===d.length&&0===c.length?"or":"and",u={operator:e,filters:p}}else"ALL_VISITORS"===n&&(u={operator:"and",filters:[{field:"url",operator:"i_contains",value:""}]});return{eventSources:[{id:t,type:"pixel"}],retentionSeconds:a,template:n,...u&&{filter:u},...s&&{aggregation:s}}},Ie=(e,t)=>{if(!e||!Array.isArray(e)||0===e.length)throw new Error("Rules array is required and cannot be empty");const a=e.filter((e=>"exclude"!==e.ruleType)),n=e.filter((e=>"exclude"===e.ruleType)),s="ALL"===(t?.label||t||"ALL")?"or":"and";const o=a.map((e=>Ae(e))),i=n.map((e=>Ae(e))),r={};if(o.length>0&&(r.inclusions={operator:s,rules:o}),i.length>0&&(r.exclusions={operator:s,rules:i}),!r.inclusions&&!r.exclusions)throw new Error("No valid rules found for conversion");return r};var Ce=a(44809),_e=a(87100),Se=a(95093),ve=a.n(Se);const Ee=()=>null;var Te=a(29390),De=a(95454),we=a(6379),Ne=a(9928),je=a(83560);const ke=["NEW","CONTACTED","QUALIFIED","PROPOSAL","NEGOTIATION","CLOSED_WON","CLOSED_LOST"],Le=[{key:"tags",name:"Tags",type:"List",icon:d.LabelOutlined,group:"quick"},{key:"createdAt",name:"Created Date",type:"Date",icon:d.DateRangeOutlined,group:"quick"},{key:"lastActive",name:"Last Seen",type:"Date",icon:d.DateRangeOutlined,group:"quick"},{key:"optedIn",name:"Opted In",type:"Radio",icon:d.PhoneAndroidOutlined,group:"quick",options:["Yes","No"]},{key:"blocked",name:"Blocked",type:"Radio",icon:d.BlockOutlined,group:"quick",options:["Yes","No"]},{key:"segment",name:"Segment",type:"Segment",icon:d.BookmarkBorderOutlined,group:"quick"},{key:"list",name:"List",type:"ContactList",icon:d.BookmarksOutlined,group:"quick"},{key:"userName",name:"Name",type:"String",icon:d.PersonOutlined,group:"attributes"},{key:"userNumber",name:"Mobile Number",type:"String",icon:d.PhoneAndroidOutlined,group:"attributes"},{key:"source",name:"Source",type:"String",icon:d.ListAltOutlined,group:"attributes"},{key:"firstMessage",name:"First Message",type:"Boolean",icon:d.ChatBubbleOutlineOutlined,group:"attributes"},{key:"campaigns",name:"Campaigns",type:"List",icon:d.SendOutlined,group:"attributes"},{key:"isIntervened",name:"Intervened",type:"Boolean",icon:d.AssignmentIndOutlined,group:"attributes"},{key:"isClosed",name:"Closed",type:"Boolean",icon:d.AssignmentIndOutlined,group:"attributes"},{key:"isRequesting",name:"Requested",type:"Boolean",icon:d.AssignmentIndOutlined,group:"attributes"},{key:"agentOwners",name:"Intervened By Agent",type:"List",icon:d.AssignmentIndOutlined,group:"attributes"}],Re={String:["is","is not","contains","not contains"],Boolean:["is"],List:["has","not has"],Date:["between"],Radio:["is"],Status:["is"],Segment:["is","is not"],ContactList:["is","is not"]},Be=(e,t)=>{const a=Re[t]||["is"];return"userNumber"===e?a.filter((e=>
1"contains"!==e&&"not contains"!==e)):a},Oe=()=>[{key:"optedIn",name:"Opted In",type:"Radio",listType:"String",operator:"is",value:"Yes",icon:d.PhoneAndroidOutlined,options:["Yes","No"]},{key:"blocked",name:"Blocked",type:"Radio",listType:"String",operator:"is",value:"No",icon:d.BlockOutlined,options:["Yes","No"]}],Pe=(0,_e.makeStyles)((e=>({filtersSection:{marginBottom:12,backgroundColor:"#fff",borderRadius:8,padding:"12px 16px",border:"1px solid #E5E7EB"},filtersSectionMuted:{marginBottom:12,backgroundColor:"#F7F7F7",borderRadius:8,padding:"12px 16px"},filterGroupsScroll:{maxHeight:160,overflowY:"auto",scrollbarWidth:"thin","&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-thumb":{backgroundColor:"#D1D5DB",borderRadius:999}},emptyFiltersRow:{display:"flex",alignItems:"center",gap:12,minHeight:32},groupCard:{display:"flex",alignItems:"stretch",border:"1px solid #E5E7EB",borderRadius:6,backgroundColor:"#fff",overflowX:"auto",overflowY:"hidden",width:"fit-content",maxWidth:"100%",minWidth:0,flex:"0 1 auto",scrollbarWidth:"thin","&::-webkit-scrollbar":{height:6},"&::-webkit-scrollbar-thumb":{backgroundColor:"#D1D5DB",borderRadius:999},"&:hover $deleteGroupBtn":{opacity:1,maxWidth:28,padding:"0 6px",borderLeft:"1px solid #E5E7EB"}},filterSegment:{display:"inline-flex",alignItems:"center",gap:4,padding:"8px 8px",fontSize:12,color:"#374151",cursor:"pointer",userSelect:"none",whiteSpace:"nowrap",minWidth:0,maxWidth:"100%","&:hover":{backgroundColor:"#F5F9FF"},"&:hover $filterSegmentClose":{opacity:1}},filterSegmentHighlighted:{backgroundColor:"#F5F9FF"},filterSegmentActive:{display:"inline-flex",alignItems:"center",gap:4,padding:"8px 8px",fontSize:12,color:e.palette.primary.main,cursor:"pointer",userSelect:"none",whiteSpace:"nowrap",minWidth:0,maxWidth:"100%",backgroundColor:e.palette.primary.light,"&:hover $filterSegmentClose":{opacity:1}},filterSegmentClose:{opacity:0,transition:"opacity 0.15s",flexShrink:0},filterSegmentIncomplete:{display:"inline-flex",alignItems:"center",gap:4,padding:"8px 8px",fontSize:12,color:"#374151",cursor:"pointer",userSelect:"none",whiteSpace:"nowrap",minWidth:0,maxWidth:"100%",backgroundColor:"#FEE2E2","&:hover":{backgroundColor:"#FECACA"},"&:hover $filterSegmentClose":{opacity:1}},filterSegmentStale:{display:"inline-flex",alignItems:"center",gap:4,padding:"8px 8px",fontSize:12,color:"#92400E",cursor:"pointer",userSelect:"none",whiteSpace:"nowrap",minWidth:0,maxWidth:"100%",backgroundColor:"#FEF3C7","&:hover":{backgroundColor:"#FDE7A8"},"&:hover $filterSegmentClose":{opacity:1}},filterSegmentLabel:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:260,[e.breakpoints.down("sm")]:{maxWidth:180}},filterChip:{backgroundColor:"#fff",border:"1px solid #D1D5DB",borderRadius:4,height:24,fontSize:12,'& .MuiChip-label, & [class*="MuiChip-label-"]':{paddingLeft:8,paddingRight:6}},filterChipEditing:{backgroundColor:e.palette.primary.light,border:`1.5px solid ${e.palette.primary.main}`,borderRadius:4,height:24,fontSize:12,'& .MuiChip-label, & [class*="MuiChip-label-"]':{paddingLeft:8,paddingRight:6}},filterOpBadgeAnd:{display:"inline-flex",alignItems:"center",padding:"0 6px",fontSize:10,fontWeight:500,cursor:"pointer",userSelect:"none",color:"#9CA3AF",borderLeft:"1px solid #E5E7EB",borderRight:"1px solid #E5E7EB","&:hover":{color:e.palette.primary.main,backgroundColor:"#F5F9FF"}},filterOpBadgeAndHighlighted:{color:e.palette.primary.main,backgroundColor:"#F5F9FF"},filterOpBadgeOr:{display:"inline-flex",alignItems:"center",padding:"0 6px",fontSize:10,fontWeight:500,cursor:"pointer",userSelect:"none",color:"#9CA3AF",borderLeft:"1px solid #E5E7EB",borderRight:"1px solid #E5E7EB","&:hover":{color:e.palette.primary.main,backgroundColor:"#F5F9FF"}},filterOpBadgeOrHighlighted:{color:e.palette.primary.main,backgroundColor:"#F5F9FF"},addFilterInGroupBtn:{display:"inline-flex",alignItems:"center",padding:"0 7px",cursor:"pointer",color:"#9CA3AF",borderLeft:"1px solid #E5E7EB",background:"none",border:"none",borderLeft:"1px solid #E5E7EB",fontFamily:"inherit",flexShrink:0,"&:hover":{color:e.palette.primary.main,backgroundColor:"#F5F9FF"}},deleteGroupBtn:{display:"inline-flex",alignItems:"center",padding:0,maxWidth:0,overflow:"hidden",cursor:"pointer",color:"#C4C9D4",background:"none",border:"none",borderLeft:"none",fontFamily:"inherit",flexShrink:0,opacity:0,transition:"opacity 0.15s, max-width 0.15s, padding 0.15s","&:hover":{color:"#EF4444",backgroundColor:"#FEF2F2"}},groupConnectorBadge:{display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:600,padding:"1px 7px",borderRadius:20,cursor:"pointer",userSelect:"none",border:"1px solid #E5E7EB",color:"#6B7280",backgroundColor:"#F3F4F6",alignSelf:"center","&:hover":{borderColor:"#D1D5DB",backgroundColor:"#E5E7EB"}},groupConnectorBadgeAndHighlighted:{color:e.palette.primary.main,borderColor:"#BFDBFE",backgroundColor:"#F5F9FF"},groupConnectorBadgeOrHighlighted:{color:e.palette.primary.main,borderColor:"#BFDBFE",backgroundColor:"#F5F9FF"}
1,segmentInfoBanner:{display:"flex",alignItems:"flex-start",gap:6,fontSize:11,color:"#1D4ED8",backgroundColor:"#EFF6FF",border:"1px solid #BFDBFE",borderRadius:6,padding:"6px 10px",marginBottom:6},saveAsSegmentBtn:{fontSize:12,textTransform:"none",color:e.palette.primary.main,padding:"2px 8px",borderRadius:6,border:`1px solid ${e.palette.primary.main}`,background:"none",fontFamily:"inherit",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,"&:hover":{backgroundColor:e.palette.primary.light}},segmentSavedChip:{fontSize:11,height:20,backgroundColor:"#D1FAE5",color:"#065F46",borderRadius:20},addGroupBtnWrap:{marginTop:8},addGroupBtn:{fontSize:12,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,padding:"4px 10px 4px 0",borderRadius:6,border:"none",background:"none",fontFamily:"inherit",color:e.palette.primary.main,"&:hover":{backgroundColor:"transparent"}},actionsRow:{display:"flex",alignItems:"center",gap:12,marginTop:10},actionLink:{fontSize:13,textTransform:"none",color:"#6B7280",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,padding:0,background:"none",border:"none",fontFamily:"inherit","&:hover":{color:e.palette.primary.main}},resultsBar:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 0",marginBottom:6},resultsCount:{display:"flex",alignItems:"center",gap:8},tableContainer:{border:"1px solid #E5E7EB",borderRadius:8,height:400,overflow:"auto"},paginationToolbar:{justifyContent:"center",paddingLeft:0},paginationSpacer:{flex:"none"},tableHeadCell:{fontWeight:600,fontSize:12,color:"#6B7280",backgroundColor:"#F9FAFB",borderBottom:"1px solid #E5E7EB",padding:"8px 12px",whiteSpace:"nowrap",textTransform:"uppercase",letterSpacing:.5},tableBodyCell:{fontSize:13,color:"#374151",padding:"8px 12px",borderBottom:"1px solid #F3F4F6"},emptyState:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:e.spacing(4),color:"#6B7280",height:400,border:"1px solid #E5E7EB",borderRadius:8},popoverPaper:{borderRadius:6,boxShadow:"0 4px 20px rgba(0,0,0,0.12)",maxHeight:400,minWidth:240,overflowX:"hidden",overflowY:"auto"},popoverSearchWrap:{padding:"12px 16px",borderBottom:"1px solid #F3F4F6"},popoverSearchFieldRoot:{width:"100%",padding:"0 !important",backgroundColor:"transparent !important",borderRadius:"0 !important"},popoverSearchInputRoot:{width:"100%",minHeight:40,borderRadius:"6px !important",backgroundColor:"#F7F9FB !important",alignItems:"center",padding:"0 !important","& fieldset":{borderColor:"#D7DEE7"},"&:hover fieldset":{borderColor:"#C6D0DB"},"&.Mui-focused fieldset":{borderColor:e.palette.primary.main}},popoverSearchInput:{fontSize:13,padding:"10px 14px !important"},popoverGroupLabel:{fontSize:11,fontWeight:600,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:.8,padding:"8px 16px 4px"},popoverItem:{fontSize:13,padding:"6px 16px",gap:8,'& .MuiListItemIcon-root, & [class*="MuiListItemIcon-root-"]':{minWidth:28}},filterTooltip:{fontSize:12,padding:"8px 10px",color:"#334155",backgroundColor:"#FFFFFF",border:"1px solid #D7DEE7",boxShadow:"0 8px 24px rgba(15, 23, 42, 0.12)"},filterTooltipArrow:{color:"#FFFFFF","&::before":{border:"1px solid #D7DEE7",boxSizing:"border-box"}},editPopoverHeader:{fontSize:12,fontWeight:600,color:"#6B7280",padding:"12px 16px 8px"},operatorItem:{display:"flex",alignItems:"center",padding:"6px 16px",cursor:"pointer",fontSize:13,color:"#374151","&:hover":{backgroundColor:"#F3F4F6"}},operatorItemActive:{display:"flex",alignItems:"center",padding:"6px 16px",cursor:"pointer",fontSize:13,color:e.palette.primary.main,fontWeight:500,backgroundColor:e.palette.primary.light,"&:hover":{backgroundColor:e.palette.primary.light}},editValueSection:{padding:"8px 16px 12px"},connectorPopoverItem:{display:"flex",alignItems:"center",padding:"6px 16px",cursor:"pointer",fontSize:13,color:"#374151",minWidth:100,"&:hover":{backgroundColor:"#F3F4F6"}},connectorPopoverItemActive:{display:"flex",alignItems:"center",padding:"6px 16px",cursor:"pointer",fontSize:13,color:e.palette.primary.main,fontWeight:500,minWidth:100,backgroundColor:e.palette.primary.light,"&:hover":{backgroundColor:e.palette.primary.light}},intercomOpRow:{display:"flex",alignItems:"center",gap:10,padding:"7px 14px",cursor:"pointer",fontSize:13,color:"#374151",userSelect:"none"},intercomDoneBtn:{color:e.palette.primary.main,textTransform:"none",fontSize:13,fontWeight:500,minWidth:80,width:"100%",borderRadius:0,padding:"8px 0","&:hover":{backgroundColor:"#F5F9FF"}}}))),Me=(0,n.forwardRef)(((e,t)=>{let{assistantId:a,onFiltersChange:r,onHasFiltersChange:l,filterOnly:c=!1,hideAddFilterTrigger:p=!1,includeReadStatus:m=!1,allFilters:g=null,showSaveAsSegment:b=!0,muted:y=!1,showSegmentInfoBanner:x=!1,initialActiveSegmentId:f=null,initialActiveSegmentName:A=null,onDiscard:I,onSegmentSaved:C}
1=e;const _=Pe(),S=(0,_e.useTheme)(),v=(0,i.useDispatch)(),{isAiSensy:E}=(0,u.x)(),[T,D]=(0,n.useState)(!1),[w,N]=(0,n.useState)(!1),[j,k]=(0,n.useState)(!1),[L,R]=(0,n.useState)(f),[P,M]=(0,n.useState)(A);(0,n.useEffect)((()=>{R(f||null),M(A||null),Ye(!1)}),[f,A]);const U=(0,n.useRef)(null),[W,z]=(0,n.useState)([]),[G,H]=(0,n.useState)([]),[V,Y]=(0,n.useState)("and"),[Z,K]=(0,n.useState)(null),[J,$]=(0,n.useState)(""),[q,X]=(0,n.useState)(null),[Q,ee]=(0,n.useState)(null),[te,ae]=(0,n.useState)(null),[ne,se]=(0,n.useState)(null),[oe,ie]=(0,n.useState)(null),[re,le]=(0,n.useState)(!1),de=(0,n.useRef)(null),ce=(0,n.useRef)(!1),pe=(0,n.useRef)(null),ue=(0,n.useRef)(null),me=(0,n.useRef)(0),[he,ge]=(0,n.useState)([]),[be,ye]=(0,n.useState)(!1),[xe,fe]=(0,n.useState)(0),[Ae,Ie]=(0,n.useState)(!1),[Ce,Se]=(0,n.useState)(0),[Re,Me]=(0,n.useState)(10),[Ue,Fe]=(0,n.useState)(null),[We,ze]=(0,n.useState)(!1),[Ge,He]=(0,n.useState)(!1),[Ve,Ye]=(0,n.useState)(!1),Ze=(0,i.useSelector)((e=>e.tags?.tags||{})),Ke=(0,i.useSelector)((e=>e.campaignsList?.campaignsList||{})),Je=(0,i.useSelector)((e=>e.tags?.attributes||[])),$e=(e=>(e||[]).filter((e=>e?.disabled)).map((e=>e.action?`${e.action}_${e.name}`:e.name)))((0,i.useSelector)((e=>e.tags?.rawAttributes||[]))),qe=(0,i.useSelector)((e=>e.segments?.list||[])),Xe=(0,i.useSelector)((e=>e.segments?.listLoading||!1)),Qe=(0,i.useSelector)((e=>e.lists?.list||[])),et=(0,i.useSelector)((e=>e.lists?.listLoading||!1)),tt=(0,i.useSelector)((e=>e.segments?.segmentCap)),at=(0,i.useSelector)((e=>e.segments?.segmentCount)),nt=(0,i.useSelector)((e=>e.lists?.listCap)),st=(0,i.useSelector)((e=>e.assistantDetails?.data)),ot=(0,i.useSelector)((e=>e.agents?.agents||{})),it=(0,i.useSelector)((e=>e.tags?.isLoading||!1)),rt=(0,i.useSelector)((e=>e.agents?.isLoading||!1)),lt=(0,i.useSelector)((e=>e.campaignsList?.isLoading||!1)),dt=E,ct=E,pt=null!=tt&&at>=tt,ut=b&&dt,mt=(0,n.useRef)(r);mt.current=r,(0,n.useEffect)((()=>{Ge&&Ye(!0)}),[Ge]),(0,n.useEffect)((()=>{ce.current&&(ce.current=!1,pe.current&&(X("new"),K(pe.current)))}),[W]),(0,n.useEffect)((()=>{if(!de.current)return;const{gi:e,fi:t}=de.current;de.current=null,setTimeout((()=>{const a=document.querySelector(`[data-filter-chip="${e}-${t}"]`);a&&(ae(e),se(t),ee(a))}),50)}),[G]);const ht=e=>"Date"===e.type?Boolean(e.value?.startDate&&e.value?.endDate):"Radio"===e.type?Boolean(e.value)&&"All"!==e.value:"Segment"===e.type?Boolean(e.value?._id):"ContactList"===e.type?Boolean(e.value?._id||e.value?.listId):""!==e.value&&null!==e.value&&void 0!==e.value,gt=e=>"Date"===e.type?{startDate:e.value?.startDate?ve()(e.value.startDate).startOf("day").toISOString():null,endDate:e.value?.endDate?ve()(e.value.endDate).endOf("day").toISOString():null}:"agentOwners"===e.key?"object"==typeof e.value?e.value?.name||"":e.value||"":"Segment"===e.type?{segmentId:e.value?._id||e.value?.segmentId||null,segmentName:e.value?.name||e.value?.segmentName||""}:"ContactList"===e.type?{listId:e.value?._id||e.value?.listId||null,listName:e.value?.name||e.value?.listName||""}:e.value&&"object"==typeof e.value?{...e.value,label:e.value.tagName||e.value.displayName||e.value.name||""}:e.value,bt=()=>{const e={filterExpressionVersion:2,topLevelFiltersVersion:1,filterGroups:[],groupsOperator:V,filters:[],dateFilters:{lastActive:{startDate:null,toDate:null,focusedInput:null},createdAt:{startDate:null,toDate:null,focusedInput:null}},optedIn:"all",blocked:"all",readStatus:"all",leadStage:"all"},t=[];return W.forEach((a=>{ht(a)&&("optedIn"===a.key&&(e.optedIn=a.value?.toLowerCase()||"all"),"blocked"===a.key&&(e.blocked=a.value?.toLowerCase()||"all"),"readStatus"===a.key&&(e.readStatus=a.value?.toLowerCase()||"all"),t.push({attributeKey:a.key,attributeName:a.name,attributeType:a.listType||a.type,inputType:a.type,operator:a.operator,value:gt(a)}))})),G.forEach(((t,a)=>{const n=a===G.length-1,s=[];t.filters.forEach(((a,o)=>{if(!ht(a))return;const i=o===t.filters.length-1,r={attributeKey:a.key,attributeName:a.name,attributeType:a.listType||a.type,inputType:a.type,operator:a.operator,value:gt(a)};if(s.push(r),"Date"===a.type){const t="createdAt"===a.key?"createdAt":"lastActive";a.value?.startDate&&(e.dateFilters[t].startDate=ve()(a.value.startDate).startOf("day")),a.value?.endDate&&(e.dateFilters[t].endDate=ve()(a.value.endDate).endOf("day"))}else if("Radio"===a.type)"optedIn"===a.key&&(e.optedIn=a.value?.toLowerCase()||"all"),"blocked"===a.key&&(e.blocked=a.value?.toLowerCase()||"all"),"readStatus"===a.key&&(e.readStatus=a.value?.toLowerCase()||"all"),"leadStage"===a.key&&(e.leadStage=a.value||"all");else{const s=i&&!n?V:t.filterOperator;e.filters.push({attributeKey:a.key,attributeName:{key:a.key,name:a.name,type:a.listType||a.type},attributeType:a.listType||a.type,operator:a.operator,value:"agentOwners"===a.key?gt(a):a.value,condition:s})}})),s.length>0&&e.filterGroups.push({id:t.id,operator:t.filterOperator,conditionsOperator:t.filterOperator,conditions:s})})),t.length>0&&e.filterGroups.unshift({id:"top-level-quick-filters",isTopLevel:!0,operator:"and",conditionsOperator:"and",conditions:t}),e},yt=(0,n.useRef)(F()((async(e,t)=>{if(e){ze(!0);try{const a=await v((0,je.TD)(e,t));Fe(a?.data?.count??a?.count??a?.data??0)}catch{Fe(null)}finally{ze(!1)}}}),600)),xt=async(e,t,a,n)=>{if(e){ye(!0);try{const s=await v((0,je.mM)(e,t,a*n,n));ge(s?.contacts||[])}catch{ge([])}finally{ye(!1)}}},ft=async(e,t)=>{if(e){Ie(!0);try{const a=await v((0,je.F1)(e,t));fe(a?.totalContacts||0)}catch{fe(0)}finally{Ie(!1)}}};(0,n.useEffect)((()=>{l&&l(W.length>0||G.length>0||T)}),[G,T,W]),(0,n.useEffect)((()=>{a&&(0!==Object.keys(Ze).length||it||v((0,De.u)(a,!0)),0!==Object.keys(ot).length||rt||v((0,we.pQ)(a,!0)),0!==Object.keys(Ke).length||lt||v((0,Ne.ge)(a)))}),[a]);const At=(0,n.useRef)(null),It=()=>{a&&At.current!==a&&(Qe.length>0||(At.current=a,Promise.resolve(v((0,Te.Ep)({assistantId:a}))).catch((()=>{}))))};(0,n.useEffect)((()=>{G.some((e=>e.filters.some((e=>"ContactList"===e.type))))&&It()}),[G,a,Qe.length]),(0,n.useEffect)((()=>{G.length>me.current&&ue.current&&(ue.current.scrollTop=ue.current.scrollHeight),me.current=G.length}),[G.length]);
1const[Ct,_t]=(0,n.useState)(0),St=(0,n.useRef)(null),vt=(0,n.useRef)(!1),Et=W.some((e=>e.value))||G.some((e=>e.filters.some((e=>e.value)))),Tt=W.some((e=>!ht(e)))||G.some((e=>e.filters.some((e=>!ht(e))))),Dt="One of your filters is missing a value. Finish editing it before adding another.",wt=()=>{I?I():(H([]),z([]),D(!1),Se(0),He(!1),Fe(null),St.current=null,mt.current&&mt.current(null),_t((e=>e+1)))};(0,n.useEffect)((()=>{!c&&vt.current&&xt(a,St.current,Ce,Re)}),[Ce,Re]),(0,n.useEffect)((()=>{if(c||!vt.current)return;const e=St.current;yt.current(a,e),xt(a,e,0,Re),ft(a,e)}),[Ct,a]),(0,n.useEffect)((()=>{c||(xt(a,null,0,Re),ft(a,null),vt.current=!0)}),[a]);const Nt=(e,t)=>{const a=Be(t.key,t.type),n={key:t.key,name:t.name,type:t.type,listType:"List"===t.type?"List":"Boolean"===t.type?"Boolean":"Status"===t.type?"Status":"String",operator:a[0],value:"Date"===t.type?{startDate:"",endDate:""}:"",icon:t.icon,options:t.options||null,_isNew:!0};H("new"===e?e=>(de.current={gi:e.length,fi:0},[...e,{id:Date.now(),filterOperator:"and",filters:[n]}]):t=>t.map(((t,a)=>a!==e?t:(de.current={gi:e,fi:t.filters.length},{...t,filters:[...t.filters,n]})))),K(null),$(""),He(!0)},jt=(e,t,a,n)=>{-1===e?z((e=>e.map(((e,s)=>s===t?{...e,[a]:n}:e)))):H((s=>s.map(((s,o)=>o!==e?s:{...s,filters:s.filters.map(((e,s)=>s===t?{...e,[a]:n}:e))})))),He(!0)},kt=()=>{Y((e=>"and"===e?"or":"and")),He(!0)};(0,n.useImperativeHandle)(t,(()=>({openAddFilter(e){0===W.length&&0===G.length?(ce.current=!0,z(Oe()),He(!0)):(X("new"),K(e))},getCurrentFilterConfig:()=>bt()})));const Lt=e=>{if("Date"===e.type){const t=e.value?.startDate?ve()(e.value.startDate).format("MMM D"):"...",a=e.value?.endDate?ve()(e.value.endDate).format("MMM D"):"...";return`${e.name}: ${t} – ${a}`}if("Segment"===e.type){const t=e.value?.name||e.value?.segmentName||"",a=e.operator||"is";return t?`${e.name} ${a} ${t}`:`${e.name} ${a} ...`}if("ContactList"===e.type){const t=e.value?.name||e.value?.listName||"",a=e.operator||"is";return t?`${e.name} ${a} ${t}`:`${e.name} ${a} ...`}const t="object"==typeof e.value?e.value?.tagName||e.value?.displayName||e.value?.name||"":e.value;return t?`${e.name} ${e.operator} ${t}`:`${e.name} ${e.operator} ...`},Rt=e=>!!e&&((e,t)=>{let{tags:a,attributeKeys:n,disabledAttributeKeys:s,segments:o}=t;const i=[];return(e?.referencedTagIds||[]).forEach((e=>{const t=String(e),n=a?.[t];n?n.disabled&&i.push({type:"tag",field:t,message:`Tag "${n.tagName}" referenced by this segment is disabled.`}):i.push({type:"tag",field:t,message:"A tag referenced by this segment was deleted."})})),(e?.referencedAttributeKeys||[]).forEach((e=>{const t="string"==typeof e&&e.startsWith("params.")?e.slice(7):e;n?.includes(t)?s?.includes(t)&&i.push({type:"attribute",field:t,message:`Attribute "${t}" referenced by this segment is disabled.`}):i.push({type:"attribute",field:t,message:`Attribute "${t}" referenced by this segment was removed.`})})),(e?.referencedSegmentIds||[]).forEach((e=>{const t=String(e);(o||[]).some((e=>String(e._id)===t))||i.push({type:"segment",field:t,message:"A segment referenced by this segment was deleted."})})),i})(e,{tags:Ze,attributeKeys:Je,disabledAttributeKeys:$e,segments:qe,lists:Qe}).length>0,Bt=e=>!!e?.disabled,Ot=0===tt,Pt=e=>Rt(e)||Bt(e)||Ot,Mt=e=>!!e?.disabled,Ut=0===nt,Ft=e=>Mt(e)||Ut,Wt=e=>{if("tags"===e.key){const t=e.value?._id;if(!t)return null;const a=Ze[t];return a?a.disabled?{type:"tag",message:"This tag is disabled and can't be used as a filter."}:null:{type:"tag",message:"This tag has been deleted."}}if("string"==typeof e.key&&e.key.startsWith("params.")){const t=e.key.slice(7);return Je.includes(t)?$e.includes(t)?{type:"attribute",message:"This attribute is disabled and can't be used as a filter."}:null:{type:"attribute",message:"This attribute has been deleted."}}if("Segment"===e.type){if(!!(!e.value?._id&&!e.value?.segmentId))return null;const t=(e=>{const t=e?._id||e?.segmentId;return t&&qe.find((e=>String(e._id)===String(t)))||null})(e.value);return t?Ot?{type:"segment",message:"Segments aren't available on your current plan. Upgrade to use segments."}:Bt(t)?{type:"segment",message:"This segment is disabled because it exceeds your plan's segment limit. Enable it from the Segments page or upgrade your plan."}:Rt(t)?{type:"segment",message:"This segment references a deleted tag, attribute, or segment. Edit the segment to fix it."}:null:{type:"segment",message:"This segment has been deleted."}}if("ContactList"===e.type){if(!!(!e.value?._id&&!e.value?.listId))return null;const t=(e=>{const t=e?._id||e?.listId;return t&&Qe.find((e=>String(e._id)===String(t)))||null})(e.value);return t?Ut?{type:"list",message:"Lists aren't available on your current plan. Upgrade to use lists."}:Mt(t)?{type:"list",message:"This list is disabled because it exceeds your plan's list limit. Enable it from the Lists page or upgrade your plan."}:null:{type:"list",message:"This list has been deleted."}}return null},zt=G.some((e=>e.filters.some((e=>!!Wt(e))))),Gt="One of your filters references a deleted tag or attribute. Remove or fix it before applying.",Ht=(Je||[]).filter((e=>e&&"string"==typeof e)).map((e=>({key:`params.${e}`,name:e.includes("_")?e.split("_").slice(1).join("_"):e,type:"String",icon:d.ListAltOutlined,group:"custom",disabled:$e.includes(e)}))),Vt=m?[...Le,{key:"readStatus",name:"Read Status",type:"Radio",icon:d.ChatBubbleOutlineOutlined,group:"quick",options:["Read","Unread"]}]:Le,Yt=E&&st?.specialAccess?.enableLeadStage?[{key:"leadStage",name:"Lead Stage",type:"Radio",icon:d.TrendingUpOutlined,group:"attributes",options:ke}]:[],Zt=[...!("v2"!==st?.providerType&&"v3"!==st?.providerType||"v3"!==st?.type&&"v4"!==st?.type)&&st?.planActivatedOn?[{key:"sessionPeriod",name:"MAU Status",type:"Status",icon:d.PeopleOutlined,group:"attributes",options:["Active","Inactive"]}]:[],...st?.cbpType?[{key:"whatsappConvoExpTime",name:"WhatsApp Conversation Status",type:"Status",icon:d.ChatBubbleOutlineOutlined,group:"attributes",options:["Active","Inactive"]}]:[]],Kt=[...Vt.filter((e=>(dt||"Segment"!==e.type)&&(ct||"ContactList"!==e.type))),...Yt,...Zt,...Ht],Jt=Kt.reduce(((e,t)=>(e[t.key]=t,e)),{}),$t=e=>{if(!e)return"";const t=ve().isMoment(e)?e:ve()(e);return t.isValid()?t.format("YYYY-MM-DD"):""},qt=e=>{switch((e||"").toLowerCase()){case"yes":return"Yes";case"no":return"No";case"all":return"All";case"read":return"Read";case"unread":return"Unread";default:return e||""}},Xt=e=>{const t=e?.attributeKey||e?.attributeName?.key,a=Jt[t]||{},n=e?.inputType||a.type||e?.attributeType||"String",s=Be(t,n)[0];let o=e?.value;if("Date"===n)o={startDate:$t(e?.value?.startDate||e?.value?.fromDate),endDate:$t(e?.value?.endDate||e?.value?.toDate)};else if("Segment"===n){if(!dt)return{key:null};const t=e?.value;o=t?._id?t:{_id:t?.segmentId||null,name:t?.segmentName||""}}else if("ContactList"===n){if(!ct)return{key:null};const t=e?.value;o=t?._id?t:{_id:t?.listId||null,name:t?.listName||""}}else if("Radio"===n)o=qt(e?.value);else if("agentOwners"===t){const t=e?.value?.name||e?.value;o=Object.values(ot).find((e=>e.name===t))||t||""}else null==o&&(o="");return{key:t,name:a.name||e?.attributeName?.name||e?.attributeName||t,type:n,listType:"List"===n?"List":"Boolean"===n?"Boolean":"Status"===n?"Status":"String",operator:e?.operator||s,value:o,icon:a.icon,options:a.options||null}},Qt=Kt.filter((e=>e.name?.toLowerCase().includes(J.toLowerCase()))),ea=Qt.filter((e=>"quick"===e.group)),ta=Qt.filter((e=>"attributes"===e.group)),aa=Qt.filter((e=>"custom"===e.group));(0,n.useEffect)((()=>
1{if(ee(null),ae(null),se(null),K(null),$(""),X(null),He(!1),Ye(!1),!g)return D(!1),H([]),z([]),Y("and"),void(St.current=null);if(g.selectAll)return D(!0),H([]),z([]),Y("and"),void(St.current=g);const e=[],t=new Set,a=[];if(Array.isArray(g.filterGroups)&&g.filterGroups.length){const n=!!g.topLevelFiltersVersion;g.filterGroups.forEach(((s,o)=>{if(s.isTopLevel)(s.conditions||[]).forEach((a=>{const n=a?.attributeKey||a?.attributeName?.key;if(!t.has(n)){const s=Xt(a);"blocked"===s.key&&(s.name="Blocked"),e.push(s),t.add(n)}}));else{const i=(s.conditions||[]).filter((a=>{const s=a?.attributeKey||a?.attributeName?.key;if(!(n||"optedIn"!==s&&"blocked"!==s||t.has(s))){const n=Xt(a);return"blocked"===n.key&&(n.name="Blocked"),e.push(n),t.add(s),!1}return!0})).map((e=>Xt(e))).filter((e=>e.key));i.length&&a.push({id:s.id||`${Date.now()}-${o}`,filterOperator:s.conditionsOperator||s.operator||"and",filters:i})}})),n||!g.optedIn||"all"===g.optedIn||t.has("optedIn")||(e.unshift({key:"optedIn",name:"Opted In",type:"Radio",listType:"String",operator:"is",value:qt(g.optedIn),icon:d.PhoneAndroidOutlined,options:["Yes","No"]}),t.add("optedIn")),n||!g.blocked||"all"===g.blocked||t.has("blocked")||(e.push({key:"blocked",name:"Blocked",type:"Radio",listType:"String",operator:"is",value:qt(g.blocked),icon:d.BlockOutlined,options:["Yes","No"]}),t.add("blocked"))}else{const n=(g.filters||[]).map((e=>Xt(e))).filter((e=>e.key));n.length&&a.push({id:"legacy-filters",filterOperator:g.filters?.[0]?.condition||"and",filters:n});const s=[],o=$t(g.dateFilters?.lastActive?.startDate),i=$t(g.dateFilters?.lastActive?.toDate||g.dateFilters?.lastActive?.endDate);(o||i)&&s.push(Xt({attributeKey:"lastActive",inputType:"Date",operator:"between",value:{startDate:o,endDate:i}}));const r=$t(g.dateFilters?.createdAt?.startDate),l=$t(g.dateFilters?.createdAt?.toDate||g.dateFilters?.createdAt?.endDate);(r||l)&&s.push(Xt({attributeKey:"createdAt",inputType:"Date",operator:"between",value:{startDate:r,endDate:l}})),m&&g.readStatus&&"all"!==g.readStatus&&s.push(Xt({attributeKey:"readStatus",inputType:"Radio",operator:"is",value:g.readStatus})),s.forEach(((e,t)=>{a.push({id:`legacy-quick-${t}`,filterOperator:"and",filters:[e]})})),g.optedIn&&"all"!==g.optedIn&&!t.has("optedIn")&&(e.push({key:"optedIn",name:"Opted In",type:"Radio",listType:"String",operator:"is",value:qt(g.optedIn),icon:d.PhoneAndroidOutlined,options:["Yes","No"]}),t.add("optedIn")),g.blocked&&"all"!==g.blocked&&!t.has("blocked")&&(e.push({key:"blocked",name:"Blocked",type:"Radio",listType:"String",operator:"is",value:qt(g.blocked),icon:d.BlockOutlined,options:["Yes","No"]}),t.add("blocked"))}D(!1),z(e),H(a),Y(g.groupsOperator||"and"),St.current=g}),[g,m,dt,ct]);const na=(null!==St.current?Ue??xe:xe)??0,sa=null!==te&&null!==ne?-1===te?W[ne]??null:G[te]?.filters[ne]??null:null;return(0,h.jsxs)(o.Box,{children:[(0,h.jsxs)(o.Box,{className:W.length>0||G.length>0||T?y?_.filtersSectionMuted:_.filtersSection:void 0,children:[0===W.length&&0===G.length&&!T&&!p&&(0,h.jsx)(o.Box,{className:_.emptyFiltersRow,children:(0,h.jsxs)(o.Box,{component:"span",className:_.actionLink,onClick:()=>{ce.current=!0,z(Oe()),He(!0)},children:[(0,h.jsx)(d.Add,{style:{fontSize:16}}),"Add filter"]})}),T&&(0,h.jsx)(o.Box,{className:_.emptyFiltersRow,children:(0,h.jsx)(o.Chip,{className:_.filterChipEditing,label:`All ${na.toLocaleString()} contacts selected`,onDelete:wt,icon:(0,h.jsx)(d.PeopleOutlined,{style:{fontSize:16,color:S.palette.primary.main}})})}),x&&G.some((e=>e.filters.some((e=>"Segment"===e.type&&ht(e)))))&&(0,h.jsxs)(o.Box,{className:_.segmentInfoBanner,children:[(0,h.jsx)(d.BookmarkBorderOutlined,{style:{fontSize:13,flexShrink:0,marginTop:1}}),(0,h.jsx)("span",{children:"Changes to a referenced segment apply automatically the next time this segment is evaluated."})]}),W.length>0&&(0,h.jsx)(o.Box,{style:{marginBottom:G.length>0?16:8},children:(0,h.jsx)(o.Box,{className:_.groupCard,children:W.map(((e,t)=>{const a=-1===te&&ne===t,n=a?_.filterSegmentActive:_.filterSegment,i=Lt(e);return(0,h.jsxs)(s().Fragment,{children:[t>0&&(0,h.jsx)(o.Box,{className:_.filterOpBadgeAnd,style:{cursor:"default",pointerEvents:"none"},children:"and"}),(0,h.jsx)(o.Tooltip,{title:i,arrow:!0,placement:"top",classes:{tooltip:_.filterTooltip,arrow:_.filterTooltipArrow},children:(0,h.jsxs)(o.Box,{"data-filter-chip":`-1-${t}`,className:n,onClick:e=>{ae(-1),se(t),ee(e.currentTarget)},children:[e.icon&&(0,h.jsx)(e.icon,{style:{fontSize:13,color:a?S.palette.primary.main:"#6B7280",flexShrink:0}}),(0,h.jsx)("span",{className:_.filterSegmentLabel,children:i}),(0,h.jsx)(d.Close,{className:_.filterSegmentClose,style:{fontSize:12,color:"#000"},onClick:e=>{e.stopPropagation(),(e=>{const t=W.filter(((t,a)=>a!==e));z(t),-1===te&&ne===e&&(ee(null),ae(null),se(null)),0===t.length&&0===G.length?(St.current=null,Fe(null),He(!1),mt.current&&mt.current(null),_t((e=>e+1))):He(!0)})(t)}})]})})]},e.key)}))})}),W.length>0&&0===G.length&&(0,h.jsx)(o.Box,{style:{marginBottom:8},children:(0,h.jsxs)(o.Box,{ref:pe,component:"span",className:_.actionLink,onClick:e=>{X("new"),K(e.currentTarget)},style:{fontSize:12},children:[(0,h.jsx)(d.Add,{style:{fontSize:14}}
1),"Add filter"]})}),G.length>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Box,{className:_.filterGroupsScroll,ref:ue,children:(0,h.jsx)(o.Box,{style:{display:"flex",flexDirection:"column",gap:4,width:"100%"},children:G.map(((e,t)=>(0,h.jsxs)(s().Fragment,{children:[t>0&&(0,h.jsx)(o.Box,{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 0",width:"100%"},children:(0,h.jsx)(o.Box,{className:`${_.groupConnectorBadge} ${re?"and"===V?_.groupConnectorBadgeAndHighlighted:_.groupConnectorBadgeOrHighlighted:""}`,onClick:kt,onMouseEnter:()=>le(!0),onMouseLeave:()=>le(!1),onFocus:()=>le(!0),onBlur:()=>le(!1),title:"Click to toggle AND / OR",children:V.toUpperCase()})}),(0,h.jsxs)(o.Box,{className:_.groupCard,children:[e.filters.map(((a,n)=>{const i=te===t&&ne===n,r=oe===t;return(0,h.jsxs)(s().Fragment,{children:[n>0&&(0,h.jsx)(o.Box,{className:"and"===e.filterOperator?`${_.filterOpBadgeAnd} ${r?_.filterOpBadgeAndHighlighted:""}`:`${_.filterOpBadgeOr} ${r?_.filterOpBadgeOrHighlighted:""}`,onClick:()=>(e=>{H((t=>t.map(((t,a)=>a!==e?t:{...t,filterOperator:"and"===t.filterOperator?"or":"and"})))),He(!0)})(t),onMouseEnter:()=>ie(t),onMouseLeave:()=>ie(null),title:"Click to toggle AND / OR",children:e.filterOperator}),(()=>{const e=!ht(a)&&!i&&!a._isNew,s=i||a._isNew?null:Wt(a),r=i?_.filterSegmentActive:e?_.filterSegmentIncomplete:s?_.filterSegmentStale:_.filterSegment,l=e?`${a.name} is missing value`:Lt(a),c=s?`${l} — ${s.message}`:l;return(0,h.jsx)(o.Tooltip,{title:c,arrow:!0,placement:"top",classes:{tooltip:_.filterTooltip,arrow:_.filterTooltipArrow},children:(0,h.jsxs)(o.Box,{"data-filter-chip":`${t}-${n}`,className:r,onClick:e=>{ae(t),se(n),ee(e.currentTarget)},children:[a.icon&&(0,h.jsx)(a.icon,{style:{fontSize:13,color:i?S.palette.primary.main:e?"#EF4444":s?"#92400E":"#6B7280",flexShrink:0}}),(0,h.jsx)("span",{className:_.filterSegmentLabel,children:l}),s&&(0,h.jsx)(o.Tooltip,{title:s.message,children:(0,h.jsx)(d.Warning,{style:{fontSize:11,color:"#D97706",flexShrink:0}})}),(0,h.jsx)(d.Close,{className:_.filterSegmentClose,style:{fontSize:12,color:"#000"},onClick:e=>{e.stopPropagation(),((e,t)=>{const a=G.map(((a,n)=>n!==e?a:{...a,filters:a.filters.filter(((e,a)=>a!==t))})).filter((e=>e.filters.length>0));H(a),te===e&&ne===t&&(ee(null),ae(null),se(null)),0===a.length&&0===W.length?(St.current=null,Fe(null),He(!1),mt.current&&mt.current(null),_t((e=>e+1))):He(!0)})(t,n)}})]})})})()]},n)})),(0,h.jsx)(o.Tooltip,{title:Tt?Dt:"",placement:"top",arrow:!0,classes:{tooltip:_.filterTooltip,arrow:_.filterTooltipArrow},children:(0,h.jsx)(o.Box,{component:"span",className:_.addFilterInGroupBtn,onClick:Tt?void 0:e=>((e,t)=>{X(e),K(t),dt&&a&&0===qe.length&&!Xe&&v((()=>{})),ct&&It()})(t,e.currentTarget),style:Tt?{opacity:.35,cursor:"not-allowed"}:{},children:(0,h.jsx)(d.Add,{style:{fontSize:13}})})})]})]},e.id)))})}),(0,h.jsxs)(o.Box,{style:{marginTop:8,display:"flex",alignItems:"center",gap:16},children:[(0,h.jsx)(o.Tooltip,{title:Tt?Dt:"",placement:"top",arrow:!0,classes:{tooltip:_.filterTooltip,arrow:_.filterTooltipArrow},children:(0,h.jsxs)(o.Box,{component:"span",className:_.addGroupBtn,onClick:Tt?void 0:e=>{X("new"),K(e.currentTarget)},style:Tt?{opacity:.35,cursor:"not-allowed"}:{},children:[(0,h.jsx)(d.Add,{style:{fontSize:13}}),"Add filter group"]})}),ut&&(0,h.jsx)(o.Tooltip,{title:Tt?Dt:zt?Gt:"Save these filters as a reusable segment",placement:"top",arrow:!0,classes:{tooltip:_.filterTooltip,arrow:_.filterTooltipArrow},children:(0,h.jsxs)(o.Box,{component:"span",className:_.addGroupBtn,onClick:Tt||zt?void 0:()=>{L||!pt?N(!0):k(!0)},style:Tt||zt?{opacity:.35,cursor:"not-allowed"}:{},children:[(0,h.jsx)(d.BookmarkBorderOutlined,{style:{fontSize:14}}),P?Ve?"Save as New":`Saved: ${P}`:"Save as Segment"]})})]})]}),Ge&&(W.length>0||G.length>0)&&(0,h.jsxs)(o.Box,{className:_.actionsRow,children:[(0,h.jsx)(o.Tooltip,{title:Tt?Dt:zt?Gt:"",placement:"top",arrow:!0,classes:{tooltip:_.filterTooltip,arrow:_.filterTooltipArrow},children:(0,h.jsx)("span",{children:(0,h.jsx)(o.Button,{size:"small",disableElevation:!0,variant:"contained",disabled:Tt||zt,onClick:()=>{const e=bt();St.current=Et?e:null,U.current=St.current,mt.current&&mt.current(St.current),Se(0),He(!1),_t((e=>e+1))},style:{backgroundColor:Tt||zt?"#D1D5DB":S.palette.primary.main,color:"#fff",textTransform:"none",fontSize:12,borderRadius:6,padding:"3px 14px",height:28,minWidth:0},children:"Apply Filters"})})}),(0,h.jsx)(o.Box,{component:"span",className:_.actionLink,onClick:wt,style:{color:"#EF4444"},children:"Discard"})]})]}),!c&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Box,{className:_.resultsBar,children:(0,h.jsxs)(o.Box,{className:_.resultsCount,children:[(0,h.jsx)(d.PeopleOutlined,{style:{fontSize:18,color:S.palette.primary.main}}),(0,h.jsxs)(o.Typography,{style:{fontSize:15,fontWeight:600,color:"#111827",display:"inline-flex",alignItems:"center",gap:6},children:[We||Ae?(0,h.jsx)(o.CircularProgress,{size:14}
1):na.toLocaleString()," ","contact",1!==na?"s":""]})]})}),be?(0,h.jsx)(o.Box,{className:_.emptyState,children:(0,h.jsx)(o.CircularProgress,{size:24})}):0===he.length?(0,h.jsxs)(o.Box,{className:_.emptyState,children:[(0,h.jsx)(d.PeopleOutlined,{style:{fontSize:40,color:"#D1D5DB",marginBottom:8}}),(0,h.jsx)(o.Typography,{style:{fontSize:14,color:"#6B7280"},children:"No contacts found"})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.TableContainer,{className:_.tableContainer,children:(0,h.jsxs)(o.Table,{size:"small",stickyHeader:!0,children:[(0,h.jsx)(o.TableHead,{children:(0,h.jsxs)(o.TableRow,{children:[(0,h.jsx)(o.TableCell,{className:_.tableHeadCell,children:"Name"}),(0,h.jsx)(o.TableCell,{className:_.tableHeadCell,children:"Mobile Number"}),(0,h.jsx)(o.TableCell,{className:_.tableHeadCell,children:"Created At"})]})}),(0,h.jsx)(o.TableBody,{children:he.map(((e,t)=>(0,h.jsxs)(o.TableRow,{hover:!0,children:[(0,h.jsx)(o.TableCell,{className:_.tableBodyCell,children:e.userName||"Unknown User"}),(0,h.jsx)(o.TableCell,{className:_.tableBodyCell,children:e.userNumber||"-"}),(0,h.jsx)(o.TableCell,{className:_.tableBodyCell,children:e.createdAt||e.createdOn?ve()(e.createdAt||e.createdOn).format("MMM D, YYYY HH:mm"):"-"})]},e._id||t)))})]})}),(0,h.jsx)(o.TablePagination,{component:"div",classes:{toolbar:_.paginationToolbar,spacer:_.paginationSpacer},count:Ae?-1:xe,page:Ce,onChangePage:(e,t)=>Se(t),rowsPerPage:Re,onChangeRowsPerPage:e=>{Me(parseInt(e.target.value,10)),Se(0)},rowsPerPageOptions:[10,25,50],labelDisplayedRows:e=>{let{from:t,to:a}=e;return(0,h.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[t,"–",a," of"," ",Ae?(0,h.jsx)(o.CircularProgress,{size:12,style:{verticalAlign:"middle"}}):xe.toLocaleString()]})}})]})]}),(0,h.jsxs)(o.Popover,{style:{zIndex:3500},open:Boolean(Z),anchorEl:Z,onClose:()=>{K(null),$(""),X(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{className:_.popoverPaper},children:[(0,h.jsx)(o.Box,{className:_.popoverSearchWrap,children:(0,h.jsx)(o.TextField,{autoFocus:!0,fullWidth:!0,autoFocus:!0,variant:"outlined",size:"small",placeholder:"Search filters...",value:J,onChange:e=>$(e.target.value),classes:{root:_.popoverSearchFieldRoot},InputProps:{classes:{root:_.popoverSearchInputRoot,input:_.popoverSearchInput}}})}),ea.length>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Typography,{className:_.popoverGroupLabel,children:"Quick Filters"}),(0,h.jsx)(o.MenuList,{dense:!0,children:ea.map((e=>(0,h.jsxs)(o.MenuItem,{className:_.popoverItem,onClick:()=>Nt(q,e),children:[(0,h.jsx)(o.ListItemIcon,{children:(0,h.jsx)(e.icon,{style:{fontSize:18,color:"#6B7280"}})}),(0,h.jsx)(o.ListItemText,{primary:e.name,primaryTypographyProps:{style:{fontSize:13}}})]},e.key)))})]}),ta.length>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Divider,{}),(0,h.jsx)(o.Typography,{className:_.popoverGroupLabel,children:"Attributes"}),(0,h.jsx)(o.MenuList,{dense:!0,children:ta.map((e=>(0,h.jsxs)(o.MenuItem,{className:_.popoverItem,onClick:()=>Nt(q,e),children:[(0,h.jsx)(o.ListItemIcon,{children:(0,h.jsx)(e.icon,{style:{fontSize:18,color:"#6B7280"}})}),(0,h.jsx)(o.ListItemText,{primary:e.name,primaryTypographyProps:{style:{fontSize:13}}})]},e.key)))})]}),aa.length>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Divider,{}),(0,h.jsx)(o.Typography,{className:_.popoverGroupLabel,children:"Custom Attributes"}),(0,h.jsx)(o.MenuList,{dense:!0,children:aa.map((e=>(0,h.jsx)(o.Tooltip,{title:e.disabled?"This attribute is disabled and can't be used as a filter. Enable it from the Attributes page.":"",placement:"right",children:(0,h.jsx)("span",{children:(0,h.jsxs)(o.MenuItem,{className:_.popoverItem,disabled:e.disabled,onClick:()=>Nt(q,e),children:[(0,h.jsx)(o.ListItemIcon,{children:(0,h.jsx)(e.icon,{style:{fontSize:18,color:"#6B7280"}})}),(0,h.jsx)(o.ListItemText,{primary:e.name,primaryTypographyProps:{style:{fontSize:13}}})]})})},e.key)))})]})]}),(0,h.jsx)(o.Popover,{style:{zIndex:3500},open:Boolean(Q)&&null!==sa,anchorEl:Q,onClose:()=>{if(null!==te&&null!==ne){const e=-1===te?W[ne]:G[te]?.filters[ne];e?._isNew&&jt(te,ne,"_isNew",!1)}ee(null),ae(null),se(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{style:{borderRadius:8,minWidth:260,boxShadow:"0 4px 20px rgba(0,0,0,0.12)"}},children:sa&&(()=>{const e=sa,t=te,a=ne,n=Be(e.key,e.type),i=(e=>{if(e.options)return e.options;if("tags"===e.key)return Object.values(Ze);
1if("campaigns"===e.key)return Object.keys(Ke);if("agentOwners"===e.key)return Object.values(ot).filter((e=>!e.disabled&&!e.businessArchived));if("firstMessage"===e.key)return["SET","NOT SET",...Object.values(Ze).filter((e=>e.isFirstMessage&&!e.disabled))];return"Segment"===e.type?dt?qe:[]:"ContactList"===e.type?ct?Qe:[]:"Boolean"===e.type?["Yes","No"]:[]})(e),r=0===i.length&&"String"===e.type,l=()=>{e._isNew&&jt(t,a,"_isNew",!1),ee(null),ae(null),se(null)};return n.length>1?(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Box,{style:{padding:"6px 0"},children:n.map((n=>{const l=e.operator===n;return(0,h.jsxs)(s().Fragment,{children:[(0,h.jsxs)(o.Box,{className:_.intercomOpRow,onClick:()=>jt(t,a,"operator",n),children:[l?(0,h.jsx)(d.RadioButtonChecked,{style:{fontSize:16,color:S.palette.primary.main,flexShrink:0}}):(0,h.jsx)(d.RadioButtonUnchecked,{style:{fontSize:16,color:"#D1D5DB",flexShrink:0}}),(0,h.jsx)("span",{children:n})]}),l&&("ContactList"===e.type?(0,h.jsx)(o.Box,{style:{padding:"2px 8px 8px 38px"},children:(0,h.jsx)(O.Autocomplete,{options:Qe,loading:et,value:Qe.find((t=>t._id===(e.value?._id||e.value?.listId)))||null,getOptionLabel:e=>e?.name||"",getOptionSelected:(e,t)=>e._id===t?._id,getOptionDisabled:e=>Ft(e),onChange:(e,n)=>jt(t,a,"value",n),ListboxProps:{style:{maxHeight:200,fontSize:13}},renderOption:e=>{const t=(0,h.jsx)("span",{style:{fontSize:13},children:e.name});if(!Ft(e))return t;const a=Ut?"Lists aren't available on your current plan. Upgrade to use lists.":"This list is disabled because it exceeds your plan's list limit. Enable it from the Lists page or upgrade your plan.";return(0,h.jsx)(o.Tooltip,{title:a,placement:"right",children:(0,h.jsx)("span",{style:{width:"100%",pointerEvents:"auto"},children:t})})},renderInput:e=>(0,h.jsx)(o.TextField,{...e,autoFocus:!0,variant:"outlined",size:"small",placeholder:"Select list…",inputProps:{...e.inputProps,style:{...e.inputProps?.style,padding:"5px 8px",fontSize:13}}})})}):"Segment"===e.type?(0,h.jsx)(o.Box,{style:{padding:"2px 8px 8px 38px"},children:(0,h.jsx)(O.Autocomplete,{options:qe,loading:Xe,value:qe.find((t=>t._id===(e.value?._id||e.value?.segmentId)))||null,getOptionLabel:e=>e?.name||"",getOptionSelected:(e,t)=>e._id===t?._id,getOptionDisabled:e=>Pt(e),onChange:(e,n)=>jt(t,a,"value",n),ListboxProps:{style:{maxHeight:200,fontSize:13}},renderOption:e=>{const t=(0,h.jsxs)(o.Box,{style:{display:"flex",flexDirection:"column"},children:[(0,h.jsx)("span",{style:{fontSize:13},children:e.name}),Rt(e)&&(0,h.jsxs)("span",{style:{fontSize:11,color:"#D97706",display:"flex",alignItems:"center",gap:3},children:[(0,h.jsx)(d.Warning,{style:{fontSize:11}})," Broken conditions"]})]});if(!Pt(e))return t;const a=Ot?"Segments aren't available on your current plan. Upgrade to use segments.":Rt(e)?"This segment references a deleted tag or attribute. Edit the segment to fix it.":"This segment is disabled because it exceeds your plan's segment limit. Enable it from the Segments page or upgrade your plan.";return(0,h.jsx)(o.Tooltip,{title:a,placement:"right",children:(0,h.jsx)("span",{style:{width:"100%",pointerEvents:"auto"},children:t})})},renderInput:e=>(0,h.jsx)(o.TextField,{...e,autoFocus:!0,variant:"outlined",size:"small",placeholder:"Select segment…",inputProps:{...e.inputProps,style:{...e.inputProps?.style,padding:"5px 8px",fontSize:13}}})})}):"tags"===e.key?(0,h.jsx)(o.Box,{style:{padding:"2px 8px 8px 38px"},children:(0,h.jsx)(O.Autocomplete,{options:i,value:e.value||null,getOptionLabel:e=>e?.tagName||"",getOptionSelected:(e,t)=>e._id===t?._id,getOptionDisabled:e=>!!e.disabled,onChange:(e,n)=>jt(t,a,"value",n),ListboxProps:{style:{maxHeight:180,overflowX:"hidden",scrollbarWidth:"thin",scrollbarColor:"#D1D5DB transparent"}},renderOption:e=>{const t=(0,h.jsx)("span",{style:{fontSize:13},children:e.tagName});return e.disabled?(0,h.jsx)(o.Tooltip,{title:"This tag is disabled and can't be used as a filter. Enable it from the Tags page.",placement:"right",children:(0,h.jsx)("span",{style:{width:"100%",pointerEvents:"auto"},children:t})}):t},renderInput:e=>
1(0,h.jsx)(o.TextField,{...e,autoFocus:!0,variant:"outlined",size:"small",placeholder:"Select value...",inputProps:{...e.inputProps,style:{...e.inputProps?.style,padding:"5px 8px",fontSize:13}}})})}):i.length>0?(0,h.jsx)(o.Box,{style:{padding:"2px 8px 8px 38px"},children:(0,h.jsx)(O.Autocomplete,{freeSolo:r,disableClearable:!0,options:i,value:e.value||"",getOptionLabel:e=>e?.tagName||e?.displayName||e?.name||("string"==typeof e?e:""),onChange:(e,n)=>jt(t,a,"value",n),onInputChange:(e,n,s)=>{r&&"input"===s&&jt(t,a,"value",n)},ListboxProps:{style:{maxHeight:180,overflowX:"hidden",scrollbarWidth:"thin",scrollbarColor:"#D1D5DB transparent"}},renderInput:e=>(0,h.jsx)(o.TextField,{...e,autoFocus:!0,variant:"outlined",size:"small",placeholder:"Select value...",inputProps:{...e.inputProps,style:{...e.inputProps?.style,padding:"5px 8px",fontSize:13}}})})}):(0,h.jsx)(o.Box,{style:{padding:"2px 14px 8px 38px"},children:(0,h.jsx)(o.TextField,{fullWidth:!0,autoFocus:!0,variant:"outlined",size:"small",placeholder:"Enter value...",value:e.value||"",onChange:e=>jt(t,a,"value",e.target.value),inputProps:{style:{padding:"5px 8px",fontSize:13}}})}))]},n)}))}),(0,h.jsx)(o.Divider,{}),(0,h.jsx)(o.Button,{className:_.intercomDoneBtn,onClick:l,children:"Done"})]}):(0,h.jsxs)(o.Box,{children:["Segment"===e.type?(0,h.jsx)(o.Box,{className:_.editValueSection,children:(0,h.jsx)(O.Autocomplete,{options:qe,loading:Xe,value:qe.find((t=>t._id===(e.value?._id||e.value?.segmentId)))||null,getOptionLabel:e=>e?.name||"",getOptionSelected:(e,t)=>e._id===t?._id,getOptionDisabled:e=>Pt(e),onChange:(e,n)=>jt(t,a,"value",n),ListboxProps:{style:{maxHeight:200,fontSize:13}},renderOption:e=>{const t=(0,h.jsxs)(o.Box,{style:{display:"flex",flexDirection:"column"},children:[(0,h.jsx)("span",{style:{fontSize:13},children:e.name}),Rt(e)&&(0,h.jsxs)("span",{style:{fontSize:11,color:"#D97706",display:"flex",alignItems:"center",gap:3},children:[(0,h.jsx)(d.Warning,{style:{fontSize:11}})," Broken conditions"]})]});if(!Pt(e))return t;const a=Ot?"Segments aren't available on your current plan. Upgrade to use segments.":Rt(e)?"This segment references a deleted tag or attribute. Edit the segment to fix it.":"This segment is disabled because it exceeds your plan's segment limit. Enable it from the Segments page or upgrade your plan.";return(0,h.jsx)(o.Tooltip,{title:a,placement:"right",children:(0,h.jsx)("span",{style:{width:"100%",pointerEvents:"auto"},children:t})})},renderInput:e=>(0,h.jsx)(o.TextField,{...e,autoFocus:!0,variant:"outlined",size:"small",placeholder:"Select segment…",inputProps:{...e.inputProps,style:{...e.inputProps?.style,fontSize:13}}})})}):"Date"===e.type?(0,h.jsxs)(o.Box,{className:_.editValueSection,children:[(0,h.jsx)(o.Typography,{style:{fontSize:11,fontWeight:600,color:"#9CA3AF",marginBottom:4,textTransform:"uppercase"},children:"From"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"standard",type:"date",value:e.value?.startDate||"",onChange:n=>jt(t,a,"value",{...e.value,startDate:n.target.value}),InputLabelProps:{shrink:!0},InputProps:{style:{fontSize:13}}}),(0,h.jsx)(o.Typography,{style:{fontSize:11,fontWeight:600,color:"#9CA3AF",marginBottom:4,marginTop:12,textTransform:"uppercase"},children:"To"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"standard",type:"date",value:e.value?.endDate||"",onChange:n=>jt(t,a,"value",{...e.value,endDate:n.target.value}),InputLabelProps:{shrink:!0},InputProps:{style:{fontSize:13}}})]}):i.length>0?(0,h.jsx)(o.Box,{style:{padding:"6px 0"},children:i.map((n=>{const s="string"==typeof n?n:n?.tagName||n?.name||"",i=("string"==typeof e.value?e.value:e.value?.tagName||e.value?.name||"")===s;return(0,h.jsxs)(o.Box,{className:_.intercomOpRow,onClick:()=>jt(t,a,"value",n),children:[i?(0,h.jsx)(d.RadioButtonChecked,{style:{fontSize:16,color:S.palette.primary.main,flexShrink:0}}):(0,h.jsx)(d.RadioButtonUnchecked,{style:{fontSize:16,color:"#D1D5DB",flexShrink:0}}),(0,h.jsx)("span",{children:s})]},s)}))}):(0,h.jsx)(o.Box,{className:_.editValueSection,children:(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"standard",placeholder:"Enter value...",value:e.value||"",onChange:e=>jt(t,a,"value",e.target.value),InputProps:{style:{fontSize:13}}})}),(0,h.jsx)(o.Divider,{}),(0,h.jsx)(o.Button,{className:_.intercomDoneBtn,onClick:l,children:"Done"})]})})()}),ut&&(0,h.jsx)(Ee,{open:w,onClose:()=>N(!1),assistantId:a,filterConfig:Ge?bt():U.current||bt(),activeSegmentId:L,activeSegmentName:P,preferCreate:Ve,onUpgradeNeeded:()=>{N(!1),k(!0)},onSaveSuccess:e=>{let{segmentId:t,segmentName:a}=e;R(t),M(a),Ye(!1),C&&C({segmentId:t,segmentName:a})}}),ut&&(0,h.jsx)(B,{name:"upgradePlanDialog",purchaseNew:!1,dialogOpen:j,toggleUpgradeDialog:()=>k(!1)})]})})),Ue=Me,Fe=(0,G.withStyles)((e=>({dialog:{'& .MuiDialog-paper, & [class*="MuiDialog-paper-"]':{borderRadius:8,maxWidth:"900px",width:"100%",backgroundColor:"white",margin:"16px",display:"flex",flexDirection:"column","@media (max-width: 600px)":{margin:"8px",borderRadius:4}}},dialogTitle:{padding:"16px 24px 12px 24px",borderBottom:"none",position:"relative","@media (max-width: 600px)":{padding:"12px 16px 8px 16px"}},titleContainer:{display:"flex",alignItems:"center",gap:8},closeButton:{color:"#6b7280",padding:8,"&:hover":{backgroundColor:"#f3f4f6"}},dialogContent:{padding:"0 24px 0px 24px","@media (max-width: 600px)":{padding:"0 16px 12px 16px"}},subtitle:{color:"#6b7280",fontSize:14,marginBottom:12},sectionTitle:{fontSize:16,fontWeight:500,color:"#111827",marginBottom:10},textField:{backgroundColor:"#F9F9FB",borderRadius:8,'& .MuiInputLabel-root, & [class*="MuiInputLabel-root-"]':{fontSize:14,fontWeight:500,color:"#9593AE"}
1,"& input::placeholder":{color:"#9ca3af",opacity:1}},dataSourceContainer:{paddingTop:20},radioGroup:{gap:24,cursor:"pointer",color:"#0a474c"},radioOption:{'& .MuiFormControlLabel-label, & [class*="MuiFormControlLabel-label-"]':{width:"100%"}},optionContent:{width:"100%"},optionTitle:{fontSize:16,fontWeight:500,color:"#111827",marginBottom:4},optionDescription:{fontSize:14,color:"#6b7280"},optionIcon:{fontSize:24,color:"primary"}})),{withTheme:!0})((e=>{let{open:t,onClose:a,classes:r,assistantDetails:l,theme:c,audienceType:p="custom",onError:u,onSuccess:m}=e;const g=(0,i.useDispatch)(),[b,y]=(0,n.useState)(""),[x,f]=(0,n.useState)(""),[A,I]=(0,n.useState)(["importFile"]),[C,_]=(0,n.useState)(""),[S,v]=(0,n.useState)(!1),[E,T]=(0,n.useState)([]),[D,w]=(0,n.useState)(0),[N,j]=(0,n.useState)({}),[k,L]=(0,n.useState)(""),[R,B]=(0,n.useState)(""),[O,P]=(0,n.useState)(!1),[M,U]=(0,n.useState)([]),[F,W]=(0,n.useState)(null),[G,V]=(0,n.useState)({}),[Y,Z]=(0,n.useState)({}),[$,q]=(0,n.useState)([]),[X,Q]=(s().useRef(null),(0,n.useState)(null)),[ee,te]=(0,n.useState)(1),[ae,ne]=(0,n.useState)(""),[se,oe]=(0,n.useState)("All website visitors"),[ie,re]=(0,n.useState)(30),[le,de]=(0,n.useState)(!1),[ce,pe]=(0,n.useState)(null),[ue,me]=(0,n.use
1State)(""),he=s().useCallback((e=>{e&&pe(e)}),[]),[ge,be]=(0,n.useState)(1),[ye,fe]=(0,n.useState)(!1),[Ae,_e]=(0,n.useState)(!0),Se=(0,i.useSelector)((e=>e.audience?.audiences||[])),ve=(0,i.useSelector)((e=>e.audience?.loading||!1)),Ee=((0,i.useSelector)((e=>e.audience?.conversationCount||null)),(0,i.useSelector)((e=>e.audience?.conversationCountLoading||!1)),"lookalike"===p?Se.filter((e=>"CUSTOM"===e.type)):Se);(0,n.useEffect)((()=>{(async()=>{if("custom"===p&&A.length>0&&!A.includes("importFile")){let e={};if(A.includes("attributes")&&M.length>0&&(e.attributes=M.filter((e=>e.attribute&&e.operator&&e.value))),A.includes("contacts")&&F&&(e.contacts=F),A.includes("createdAt")&&Object.keys(G).length>0&&(e.createdAt=G),A.includes("optedIn")&&Object.keys(Y).length>0&&(e.optedIn=Y),A.includes("campaign")&&$.length>0&&(e.campaigns=$.filter((e=>e.campaign))),Object.keys(e).length>0&&l?.assistantId)try{await g((0,z.Nn)({assistantId:l.assistantId,allFilters:e}))}catch(e){console.error("Error fetching conversation count:",e)}}})()}),[p,A,M,F,G,Y,$,l?.assistantId,g]),s().useEffect((()=>{t||(te(1),Q(null),ne(""),oe("All website visitors"),re(30),de(!1),pe(null),me(""),I(["importFile"]),T([]),w(0),j({}),B(""),L(""),v(!1))}),[t]),s().useEffect((()=>{if(t&&"lookalike"===p&&l?.assistantId){const e=l?.selectedMetaAdAccountId||l?.metaAdAccountId||l?.accountId;if(!e)return;g((0,z._L)({assistantId:l.assistantId,adAccountId:e,type:"ALL",status:"",limit:50})).then((e=>{})).catch((e=>{}))}}),[t,p,l?.assistantId,l?.selectedMetaAdAccountId,g]);const Te=(()=>{if(!b||""===b.trim())return!0;if("lookalike"===p)return!C;if("custom"===p){if(!X)return!0;if("csv"===X)return!(D>0&&N&&N.userNumber);if("pixel"===X)try{return Ie(ce.rules,ce.criteriaType),!1}catch(e){return!0}else if("contacts"===X)return!ce?.allFilters}return!1})(),De=(()=>{const e=[];if(b&&""!==b.trim()||e.push("Enter audience name"),"lookalike"===p)C||e.push("Select a custom audience");else if(X)if("csv"===X)D&&0!==D||e.push("Upload a CSV with at least one row"),N&&N.userNumber||e.push("Map the Phone column");else if("pixel"===X)try{Ie(ce.rules,ce.criteriaType)}catch(t){e.push(t.message||"Complete the pixel rule configuration")}else"contacts"===X&&(ce?.allFilters||e.push("Apply a filter or select all contacts"));else e.push("Select a data source type (CSV Upload or Pixel)");return e.join(" • ")})();return(0,h.jsxs)(o.Dialog,{open:t,onClose:a,maxWidth:"md",fullWidth:!0,className:r.dialog,PaperProps:{style:{height:"lookalike"===p||"custom"===p&&2===ee&&"contacts"===X?"80vh":"auto"}},children:[(0,h.jsx)(o.DialogTitle,{className:r.dialogTitle,children:(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center",width:"100%",minHeight:"40px",position:"relative"},children:[(0,h.jsx)("div",{className:r.titleContainer,style:{display:"flex",alignItems:"center",gap:"8px",flex:1,minWidth:0,paddingRight:window.innerWidth<600?"56px":"60px"},children:(0,h.jsx)(o.Typography,{variant:"h6",style:{fontSize:window.innerWidth<600?"18px":"20px",lineHeight:1.2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:"lookalike"===p?"Create Lookalike Audience":"Create Custom Audience"})}),(0,h.jsx)(o.IconButton,{onClick:a,className:r.closeButton,style:{padding:"8px",minWidth:"40px",minHeight:"40px"},children:(0,h.jsx)(d.Close,{})})]})}),(0,h.jsx)(o.DialogContent,{className:r.dialogContent,style:"custom"===p&&2===ee&&"contacts"===X?{display:"flex",flexDirection:"column",flex:1}:{},children:(0,h.jsxs)(o.Box,{style:{borderRadius:"8px",background:"white",padding:"16px 20px"},children:[("custom"!==p||1===ee)&&(0,h.jsxs)(o.Box,{className:r.audienceDetailsContainer,children:[(0,h.jsx)(o.Typography,{className:r.sectionTitle,children:"Audience Details"}),(0,h.jsxs)(o.Grid,{container:!0,spacing:3,children:[(0,h.jsx)(o.Grid,{item:!0,xs:12,md:6,children:(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:r.textFieldRoot},placeholder:"Enter audience name",value:b,onChange:e=>{e.target.value.length<=50&&y(e.target.value)},InputProps:{classes:{input:r.inputPadding}
1,endAdornment:(0,h.jsxs)("span",{style:{fontSize:11,color:"#9CA3AF",whiteSpace:"nowrap"},children:[b.length,"/50"]})}})}),(0,h.jsx)(o.Grid,{item:!0,xs:12,md:6,children:(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:r.textFieldRoot},placeholder:"custom"===p&&"pixel"===X?"Description • Optional":"Description",value:x,onChange:e=>{e.target.value.length<=100&&f(e.target.value)},InputProps:{classes:{input:r.inputPadding},endAdornment:(0,h.jsxs)("span",{style:{fontSize:11,color:"#9CA3AF",whiteSpace:"nowrap"},children:[x.length,"/100"]})}})})]})]}),"lookalike"===p&&(0,h.jsxs)(o.Box,{className:r.dataSourceContainer,children:[(0,h.jsx)(o.Typography,{className:r.sectionTitle,style:{marginBottom:20},children:"Select Custom Audience"}),(0,h.jsx)(o.FormControl,{variant:"outlined",size:"small",fullWidth:!0,style:{backgroundColor:"#F9F9FB"},children:(0,h.jsxs)(o.Select,{value:C,onChange:e=>_(e.target.value),displayEmpty:!0,style:{borderRadius:8,backgroundColor:"#F9F9FB"},children:[(0,h.jsx)(o.MenuItem,{value:"",disabled:!0,children:(0,h.jsx)("span",{style:{color:"#9ca3af"},children:ve?"Loading audiences...":"Choose a custom audience..."})}),ve?(0,h.jsx)(o.MenuItem,{disabled:!0,children:(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",gap:8},children:[(0,h.jsx)(o.CircularProgress,{size:16}),(0,h.jsx)(o.Typography,{style:{fontSize:14,color:"#6b7280"},children:"Loading custom audiences..."})]})}):Ee.length>0?Ee.map((e=>(0,h.jsx)(o.MenuItem,{value:e.id||e.audienceId||e._id,children:(0,h.jsxs)(o.Box,{style:{display:"flex",flexDirection:"column",width:"100%"},children:[(0,h.jsxs)(o.Typography,{style:{fontSize:14,fontWeight:500},children:[e.name," (",e.audienceId,")"]}),e.description&&(0,h.jsx)(o.Typography,{style:{fontSize:12,color:"#6b7280"},children:e.description})]})},e._id))):(0,h.jsx)(o.MenuItem,{disabled:!0,children:(0,h.jsx)(o.Typography,{style:{fontSize:14,color:"#9ca3af"},children:"No custom audiences found"})})]})}),"lookalike"===p&&(0,h.jsx)(H,{classes:r,theme:c,lookalikeRatio:ge,setLookalikeRatio:be,isFinancialService:ye,setIsFinancialService:fe,allowInternationalSeeds:Ae,setAllowInternationalSeeds:_e,selectedCustomAudience:C})]}),"custom"===p&&1===ee&&(0,h.jsx)(o.Box,{className:r.dataSourceContainer,children:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{className:r.sectionTitle,style:{marginBottom:16},children:"How do you want to build this audience?"}),(0,h.jsx)(o.Grid,{container:!0,spacing:2,children:[{key:"csv",icon:d.CloudUploadOutlined,title:"Customer List",description:"Upload contacts from a CSV file. Contacts will be hashed and matched by Meta."},{key:"pixel",icon:d.LanguageOutlined,title:"Website / Pixel",description:"Retarget people who visited your website using your Meta Pixel."},{key:"contacts",icon:d.PeopleOutlined,title:"From Contacts",description:"Filter and select contacts from your database to build this audience."}].map((e=>{const t=X===e.key,a=e.icon;return(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:6,children:(0,h.jsxs)(o.Box,{onClick:()=>Q(e.key),style:{border:`1.5px solid ${t?c.palette.primary.main:"#E5E7EB"}`,borderRadius:8,padding:"14px 16px",cursor:"pointer",backgroundColor:t?c.palette.primary.light:"#fff",transition:"all 0.2s ease"},onMouseEnter:e=>{t||(e.currentTarget.style.borderColor="#D1D5DB",e.currentTarget.style.backgroundColor="#F9FAFB")},onMouseLeave:e=>{t||(e.currentTarget.style.borderColor="#E5E7EB",e.currentTarget.style.backgroundColor="#fff")},children:[(0,h.jsx)(o.Box,{style:{width:36,height:36,borderRadius:8,backgroundColor:c.palette.primary.light,display:"flex",alignItems:"center",justifyContent:"center",marginBottom:8},children:(0,h.jsx)(a,{style:{fontSize:22,color:c.palette.primary.main}})}),(0,h.jsx)(o.Typography,{style:{fontSize:14,fontWeight:600,color:"#111827",marginBottom:4},children:e.title}),(0,h.jsx)(o.Typography,{style:{fontSize:13,color:"#6b7280",lineHeight:1.5},children:e.description})]})},e.key)}))})]})}),"custom"===p&&2===ee&&(0,h.jsxs)(o.Box,{className:r.dataSourceContainer,style:"contacts"===X?{flex:1,display:"flex",flexDirection:"column"}:{},children:["csv"===X&&(0,h.jsx)(K,{csvHeaders:E,csvRowCount:D,csvMapping:N,dragActive:S,uploadedFileName:k,onFileSelect:e=>{L(e.name),T([]),w(0),j({});const t=new FileReader;t.onload=e=>{const t=e.target.result;B(t),(0,Ce.parse)(t,{skipEmptyLines:!0,complete:e=>{const[t,...a]=e.data;T(t||[]),w(a.length)}})},t.readAsText(e)},onMappingChange:j,onClearFile:()=>{T([]),w(0),j({}),B(""),L("")},onDragActiveChange:v,sampleCsvUrl:J.NT}),"contacts"===X&&(0,h.jsx)(Ue,{assistantId:l?.assistantId,onFiltersChange:e=>{pe(e?{type:"contacts",allFilters:e}:null)}}),"pixel"===X&&(0,h.jsx)(xe,{classes:r,theme:c,assistantDetails:l,pixelId:ae,eventName:se,retentionDays:ie,prefill:le,ruleDefinition:ce,onPi
1xelIdChange:ne,onEventNameChange:e=>{oe(e);"Custom Event"===e||["All website visitors","People who visited specific web pages","Visitors by time spent","PageView","Purchase","AddToCart","InitiateCheckout","Lead","CompleteRegistration"].includes(e)?me(""):me(e)},onRetentionDaysChange:re,onPrefillChange:de,onRuleDefinitionChange:he})]})]})}),(0,h.jsxs)(o.DialogActions,{style:{padding:window.innerWidth<600?"10px 16px 12px 16px":"12px 24px 16px 24px",display:"flex",justifyContent:"custom"===p&&2===ee?"space-between":"flex-end"},children:["custom"===p&&2===ee&&(0,h.jsx)(o.Button,{onClick:()=>te(1),variant:"outlined",style:{color:"#6B7280",borderColor:"#D1D5DB",textTransform:"none",borderRadius:6,padding:"8px 16px"},children:"Back"}),"custom"===p&&1===ee&&(0,h.jsx)(o.Tooltip,{title:b?.trim()?X?"":"Select a data source type":"Enter audience name",placement:"top",arrow:!0,children:(0,h.jsx)("span",{children:(0,h.jsx)(o.Button,{onClick:()=>te(2),variant:"contained",color:"primary",disabled:!b?.trim()||!X,style:{backgroundColor:b?.trim()&&X?c.palette.primary.main:"#9ca3af",color:"#fff",textTransform:"none",borderRadius:6},children:"Next"})})}),("lookalike"===p||"custom"===p&&2===ee)&&(0,h.jsx)(o.Tooltip,{title:Te?De:"",placement:"top",arrow:!0,children:(0,h.jsx)("span",{children:(0,h.jsx)(o.Button,{onClick:async()=>{if(b&&""!==b.trim())if("lookalike"!==p||C){if("custom"===p){if(!X)return void(u&&u("Please select a data source type (CSV Upload or Pixel)."));if("csv"===X){if(A.includes("importFile")){if(!R||0===D)return void(u&&u("No data found in CSV. Please upload a valid file."));if(!N||!N.userNumber||""===N.userNumber)return void(u&&u("Please map the UserNumber column before proceeding."))}}else if("pixel"===X&&!ce)return void(u&&u("Please define the rule for the audience."))}try{P(!0);let e=null;if("lookalike"===p){const t={assistantId:l?.assistantId,name:b,description:x,type:"LOOKALIKE",origin_audience_id:C,lookalike_spec:{is_financial_service:ye,allow_international_seeds:Ae,ratio:ge/100,type:"custom_ratio"}};console.log("Creating lookalike audience with payload:",t);const a=await g((0,z.s7)(t));e=a?.data?._id||a?._id,console.log("Lookalike audience created successfully:",a)}else if("custom"===p){const t=l?.selectedMetaAdAccountId||l?.metaAdAccountId||l?.accountId;if("pixel"===X){let a=null;if(ce?.rules&&ce?.criteriaType)try{a=Ie(ce.rules,ce.criteriaType)}catch(e){console.error("Error converting rules to API format:",e)}const n=await g((0,z.Os)({assistantId:l?.assistantId,accountId:t,name:b,description:x,subtype:"WEBSITE",rule:a}));e=n?.data?._id||""}else if("csv"===X){const a=await g((0,z.Eu)({assistantId:l?.assistantId,fileName:`audience_${Date.now()}.csv`,csvText:R})),n=Object.entries(N).filter((e=>{let[,t]=e;return t})).reduce(((e,t)=>{let[a,n]=t;return{...e,[a]:n}}),{}),s=await g((0,z.Os)({assistantId:l?.assistantId,accountId:t,name:b,description:x,subtype:"CUSTOMER_LIST",fileUrl:a,headers:n}));e=s?.data?._id||""}else if("contacts"===X){const a=await g((0,z.Os)({assistantId:l?.assistantId,accountId:t,name:b,description:x,subtype:"CUSTOMER_LIST",dbQuery:ce?.allFilters}));e=a?.data?._id||""}}m&&m("lookalike"===p?"Lookalike audience created successfully!":"Custom audience created successfully!"),a()}catch(e){console.error("Error creating audience:",e),u&&u(e?.response?.data?.message||e?.message||"Failed to create audience. Please try again.")}finally{P(!1)}}else u&&u("Please select a custom audience to create a lookalike from.");else u&&u("Please enter an audience name.")},variant:"contained",color:"primary",disabled:Te||O,style:{backgroundColor:Te||O?"#9ca3af":c.palette.primary.main,color:"#fff",textTransform:"none",borderRadius:6},children:O?"Creating...":"lookalike"===p?"Create Lookalike Audience":"csv"===X?"Create & Upload Audience":"Create Custom Audience"})})})]})]})})),We=e=>{let{open:t,onClose:a,audience:s,assistantDetails:r,onSuccess:l,onError:c}=e;const p=(0,i.useDispatch)(),u=(0,_e.useTheme)(),[m,g]=(0,n.useState)(!1),[b,y]=(0,n.useState)(null),[x,f]=(0,n.useState)([]),[A,I]=(0,n.useState)(0),[C,_]=(0,n.use
1State)({}),[S,v]=(0,n.useState)(""),[E,T]=(0,n.useState)(""),[D,w]=(0,n.useState)(!1),[N,j]=(0,n.useState)(null);(0,n.useEffect)((()=>{t||(g(!1),y(null),f([]),I(0),_({}),v(""),T(""),w(!1),j(null))}),[t]);const k=!(b&&("csv"===b?A>0&&C?.userNumber:"contacts"===b&&N)),L=(()=>{if(!b)return"Select a source type";if("csv"===b){if(!A)return"Upload a CSV with at least one row";if(!C?.userNumber)return"Map the Phone column"}return"contacts"!==b||N?"":"Apply filters or select all contacts"})(),R=[{key:"csv",icon:d.CloudUploadOutlined,title:"Customer List",description:"Upload contacts from a CSV file."},{key:"contacts",icon:d.PeopleOutlined,title:"From Contacts",description:"Filter and select contacts from your database."}];return(0,h.jsxs)(o.Dialog,{open:t,onClose:a,maxWidth:"contacts"===b?"md":"sm",fullWidth:!0,PaperProps:{style:{borderRadius:8,backgroundColor:"#F9F9FB",height:"contacts"===b?"80vh":"auto",display:"flex",flexDirection:"column"}},children:[(0,h.jsx)(o.DialogTitle,{style:{padding:"16px 24px 12px",borderBottom:"none"},children:(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"h6",style:{fontSize:18,fontWeight:600},children:"Upload Contacts"}),s?.name&&(0,h.jsxs)(o.Typography,{style:{fontSize:13,color:"#6b7280",marginTop:2},children:["→ ",s.name]})]}),(0,h.jsx)(o.IconButton,{onClick:a,size:"small",style:{color:"#6b7280"},children:(0,h.jsx)(d.Close,{})})]})}),(0,h.jsxs)(o.DialogContent,{style:{padding:"0 24px 16px",..."contacts"===b?{display:"flex",flexDirection:"column",flex:1}:{}},children:[null===b&&(0,h.jsxs)(o.Box,{style:{backgroundColor:"#fff",borderRadius:8,padding:20,marginTop:8},children:[(0,h.jsx)(o.Typography,{style:{fontSize:15,fontWeight:500,marginBottom:12},children:"How do you want to add contacts?"}),(0,h.jsx)(o.Grid,{container:!0,spacing:2,children:R.map((e=>{const t=e.icon;return(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:6,children:(0,h.jsxs)(o.Box,{onClick:()=>y(e.key),style:{border:"1.5px solid #E5E7EB",borderRadius:8,padding:"14px 16px",cursor:"pointer",backgroundColor:"#fff",transition:"all 0.2s ease"},onMouseEnter:e=>{e.currentTarget.style.borderColor="#D1D5DB",e.currentTarget.style.backgroundColor="#F9FAFB"},onMouseLeave:e=>{e.currentTarget.style.borderColor="#E5E7EB",e.currentTarget.style.backgroundColor="#fff"},children:[(0,h.jsx)(o.Box,{style:{width:36,height:36,borderRadius:8,backgroundColor:u.palette.primary.light,display:"flex",alignItems:"center",justifyContent:"center",marginBottom:8},children:(0,h.jsx)(t,{style:{fontSize:20,color:u.palette.primary.main}})}),(0,h.jsx)(o.Typography,{style:{fontSize:14,fontWeight:600,color:"#111827",marginBottom:4},children:e.title}),(0,h.jsx)(o.Typography,{style:{fontSize:13,color:"#6b7280",lineHeight:1.5},children:e.description})]})},e.key)}))})]}),"csv"===b&&(0,h.jsx)(o.Box,{style:{backgroundColor:"#fff",borderRadius:8,padding:20,marginTop:8},children:(0,h.jsx)(K,{csvHeaders:x,csvRowCount:A,csvMapping:C,dragActive:D,uploadedFileName:E,onFileSelect:e=>{T(e.name),f([]),I(0),_({});const t=new FileReader;t.onload=e=>{const t=e.target.result;v(t),(0,Ce.parse)(t,{skipEmptyLines:!0,complete:e=>{const[t,...a]=e.data;f(t||[]),I(a.length)}})},t.readAsText(e)},onMappingChange:_,onClearFile:()=>{f([]),I(0),_({}),v(""),T("")},onDragActiveChange:w,sampleCsvUrl:J.NT})}),"contacts"===b&&(0,h.jsx)(o.Box,{style:{backgroundColor:"#fff",borderRadius:8,padding:20,marginTop:8,flex:1,display:"flex",flexDirection:"column"},children:(0,h.jsx)(Ue,{assistantId:r?.assistantId,onFiltersChange:e=>{j(e||null)}})})]}),(0,h.jsxs)(o.DialogActions,{style:{padding:"12px 24px 16px",display:"flex",justifyContent:b?"space-between":"flex-end"},children:[b&&(0,h.jsx)(o.Button,{onClick:()=>y(null),variant:"outlined",style:{color:"#6B7280",borderColor:"#D1D5DB",textTransform:"none",borderRadius:6,padding:"8px 16px"},children:"Back"}),b&&(0,h.jsx)(o.Tooltip,{title:k&&!m?L:"",placement:"top",arrow:!0,children:(0,h.jsx)("span",{children:(0,h.jsx)(o.Button,{onClick:async()=>{try{if(g(!0),"csv"===b){const e=await p((0,z.Eu)({assistantId:r?.assistantId,fileName:`audience_upload_${Date.now()}.csv`,csvText:S})),t=Object.entries(C).filter((e=>{let[,t]=e;return t})).reduce(((e,t)=>{let[a,n]=t;return{...e,[a]:n}}),{});await p((0,z.zq)({assistantId:r?.assistantId,audienceId:s?._id,headers:t,fileUrl:e}))}else"contacts"===b&&await p((0,z.zq)({assistantId:r?.assistantId,audienceId:s?._id,dbQuery:N}));l&&l("Contacts are being uploaded to the audience in the background."),a()}catch(e){c&&c(e?.response?.data?.message||e?.message||"Upload failed. Please try again.")}finally{g(!1)}},variant:"contained",color:"primary",disabled:k||m,style:{textTransform:"none",borderRadius:6,padding:"8px 20px",backgroundColor:k||m?"#9ca3af":u.palette.primary.main,color:"#fff"},children:m?"Uploading...":"Upload Contacts"})})})]})]})};const ze=function(e){const{open:t,onClose:a,taskMessage:n,onConfirm:s,body:i,zIndex:r}=e,l=e.finalQuestion||"Are you sure?";return(0,h.jsx)(o.Dialog,{open:t,disableBackdropClick:!0,onClose:a,style:{zIndex:r||3002},children:(0,h.jsx)(o.Box,{p:3,children:(0,h.jsxs)(o.Grid,{container:!0,children:[(0,h.jsxs)(o.Typography,{variant:"h3",gutterBottom:!0,style:{width:"100%"},children:[n,"string"==typeof n&&". "]}),!!i&&(0,h.jsx)(o.Typography,{variant:"body 2",gutterBottom:!0,style:{width:"100%"},children:i}),(0,h.jsx)(o.Typography,{variant:"h5",paragraph:!0,style:{width:"100%"},children:l}),(0,h.jsxs)(o.Grid,{container:!0,justify:"flex-end",children:[(0,h.jsx)(o.Button,{variant:"contained",color:"primary",onClick:s,style:{marginRight:"0.75em"},children:"Confirm"}),(0,h.jsx)(o.Button,{variant:"outlined",color:"primary",onClick:a,children:"Cancel"})]})]})})})};var Ge=a(5556),He=a.n(Ge);const Ve=(0,o.makeStyles)((e=>({drawer:{'& .MuiDrawer-paper, & [class*="MuiDrawer-paper-"]':{width:e=>{let{width:t}=e;return t||"400px"},[e.breakpoints.down("sm")]:{width:"calc(100vw - 32px)"},height:"100%",overflowX:"hidden",overflowY:"auto"}},header:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:e.spacing(2),borderBottom:"1px solid #E8E8E8",backgroundColor:e.palette.background.paper,position:"sticky",top:0,zIndex:1},title:{color:e.palette.text.primary,fontWeight:500,fontSize:"1.25rem"}
1,closeButton:{cursor:"pointer",color:e.palette.text.secondary,"&:hover":{color:e.palette.text.primary}},content:{padding:e.spacing(2),height:"calc(100% - 80px)",overflowY:"auto"},backdrop:{backgroundColor:"rgba(0, 0, 0, 0.5)"}}))),Ye=e=>{let{open:t,onClose:a,title:s,children:i,width:r,showHeader:l=!0,showCloseButton:c=!0,anchor:p="right",disableBackdropClick:u=!1,disableEscapeKeyDown:m=!1,keepMounted:g=!1,variant:b="temporary",elevation:y=16,className:x,headerProps:f={},contentProps:A={},...I}=e;const C=(0,o.useTheme)(),_=(0,o.useMediaQuery)(C.breakpoints.down("sm")),S=Ve({width:_?"calc(100vw - 32px)":r}),v=(0,n.useCallback)(((e,t)=>{"backdropClick"===t&&u||"escapeKeyDown"===t&&m||a&&a(e,t)}),[a,u,m]),E=(0,n.useCallback)((e=>{a&&a(e,"closeButton")}),[a]);return(0,h.jsx)(o.Drawer,{anchor:p,open:t,onClose:v,className:`${S.drawer} ${x||""}`,keepMounted:g,variant:b,elevation:y,BackdropProps:{className:S.backdrop},...I,children:(0,h.jsxs)(o.Box,{display:"flex",flexDirection:"column",height:"100%",children:[l&&(0,h.jsxs)(o.Box,{className:S.header,...f,children:[(0,h.jsx)(o.Typography,{variant:"h4",className:S.title,children:s}),c&&(0,h.jsx)(o.IconButton,{onClick:E,className:S.closeButton,size:"small","aria-label":"close drawer",children:(0,h.jsx)(d.Close,{})})]}),(0,h.jsx)(o.Box,{className:S.content,...A,children:i})]})})};Ye.propTypes={open:He().bool.isRequired,onClose:He().func,title:He().node,children:He().node,width:He().oneOfType([He().string,He().number]),showHeader:He().bool,showCloseButton:He().bool,anchor:He().oneOf(["left","top","right","bottom"]),disableBackdropClick:He().bool,disableEscapeKeyDown:He().bool,keepMounted:He().bool,variant:He().oneOf(["permanent","persistent","temporary"]),elevation:He().number,className:He().string,headerProps:He().object,contentProps:He().object};const Ze=Ye;var Ke=a(21047);const Je=(0,_e.makeStyles)((e=>({drawerContent:{padding:e.spacing(0)},title:{fontWeight:600,fontSize:20,marginBottom:e.spacing(2)},emptyState:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:e.spacing(6,3),textAlign:"center",minHeight:"300px",margin:e.spacing(4)},emptyStateIcon:{fontSize:48,color:"#9CA3AF",marginBottom:e.spacing(2)},emptyStateTitle:{fontSize:18,fontWeight:600,color:"#374151",marginBottom:e.spacing(1)},emptyStateText:{fontSize:14,color:"#6B7280",fontWeight:400,lineHeight:1.6,maxWidth:"320px"},logsTableContainer:{overflowX:"auto"},logsTable:{minWidth:500},tableHeadCell:{fontWeight:600,fontSize:13,color:"#6B7280",backgroundColor:"#F9FAFB",borderBottom:"1px solid #E5E7EB",padding:e.spacing(1.2,1.5),whiteSpace:"nowrap"},tableBodyCell:{fontSize:13,color:"#374151",padding:e.spacing(1.2,1.5),borderBottom:"1px solid #F3F4F6"},statusSuccess:{backgroundColor:"#E8F5E8",color:"#2E7D32",fontWeight:500,fontSize:11},statusFailed:{backgroundColor:"#FDECEA",color:"#F44336",fontWeight:500,fontSize:11},statusProcessing:{backgroundColor:"#FFF3E0",color:"#EC8600",fontWeight:500,fontSize:11},loaderContainer:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"200px"},errorText:{color:"#F44336",fontSize:14,textAlign:"center",padding:e.spacing(3)}}))),$e=(e,t)=>{const a=(t||"").toLowerCase();return"completed"===a||"success"===a?e.statusSuccess:"failed"===a||"error"===a?e.statusFailed:e.statusProcessing},qe=e=>{let{open:t,onClose:a,audienceData:s,assistantId:r}=e;
1const l=Je(),c=(0,i.useDispatch)(),[p,u]=(0,n.useState)([]),[m,g]=(0,n.useState)(!1),[b,y]=(0,n.useState)(null),[x,f]=(0,n.useState)(0),[A,I]=(0,n.useState)(0),[C,_]=(0,n.useState)(10),S=e=>{if(!e)return"Unknown";try{return ve()(e).format("MMM D, YYYY, h:mm A")}catch(t){return e}},v=s?._id||s?.id,E=(0,n.useCallback)((async()=>{if(r&&v){g(!0),y(null);try{const e=await c((0,Ke.$L)({assistantId:r,audienceId:v,page:x+1,limit:C}));u(e?.data||[]),I(e?.pagination?.totalItems||e?.total||0)}catch(e){y(e?.response?.data?.message||"Failed to fetch upload logs"),u([])}finally{g(!1)}}}),[r,v,x,C]);(0,n.useEffect)((()=>{t&&E()}),[t,E]),(0,n.useEffect)((()=>{t||(u([]),f(0),I(0),y(null))}),[t]);const T=(e,t)=>{f(t)},D=e=>{_(parseInt(e.target.value,10)),f(0)};return(0,h.jsx)(Ze,{open:t,onClose:a,width:"520px",title:s?.name||s?.audienceName||"Audience Details",children:(0,h.jsx)("div",{className:l.drawerContent,children:m?(0,h.jsx)(o.Box,{className:l.loaderContainer,children:(0,h.jsx)(o.CircularProgress,{size:32})}):b?(0,h.jsx)(o.Typography,{className:l.errorText,children:b}):p.length?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.TableContainer,{className:l.logsTableContainer,children:(0,h.jsxs)(o.Table,{className:l.logsTable,size:"small",children:[(0,h.jsx)(o.TableHead,{children:(0,h.jsxs)(o.TableRow,{children:[(0,h.jsx)(o.TableCell,{className:l.tableHeadCell,children:"Date"}),(0,h.jsx)(o.TableCell,{className:l.tableHeadCell,children:"Source"}),(0,h.jsx)(o.TableCell,{className:l.tableHeadCell,children:"Records"}),(0,h.jsx)(o.TableCell,{className:l.tableHeadCell,children:"Status"})]})}),(0,h.jsx)(o.TableBody,{children:p.map(((e,t)=>(0,h.jsxs)(o.TableRow,{children:[(0,h.jsx)(o.TableCell,{className:l.tableBodyCell,children:S(e.createdAt||e.uploadedAt)}),(0,h.jsx)(o.TableCell,{className:l.tableBodyCell,children:(()=>{const t=e.source||e.uploadType||"";return"audienceResponse"===t?"Campaign":"numbers"===t?"Contacts":t?t.charAt(0).toUpperCase()+t.slice(1):"-"})()}),(0,h.jsx)(o.TableCell,{className:l.tableBodyCell,children:null!=e.contactCount?e.contactCount.toLocaleString():null!=e.totalRecords?e.totalRecords.toLocaleString():"-"}),(0,h.jsx)(o.TableCell,{className:l.tableBodyCell,children:(0,h.jsx)(o.Chip,{label:e.status||"Processing",className:$e(l,e.status),size:"small"})})]},e._id||t)))})]})}),(0,h.jsx)(o.TablePagination,{component:"div",count:A,page:x,onChangePage:T,rowsPerPage:C,onChangeRowsPerPage:D,rowsPerPageOptions:[5,10,25],labelDisplayedRows:e=>{let{from:t,to:a,count:n}=e;return`${t}-${a} of ${-1!==n?n:`more than ${a}`}`}})]}):(0,h.jsxs)(o.Box,{className:l.emptyState,children:[(0,h.jsx)(d.InfoOutlined,{className:l.emptyStateIcon}),(0,h.jsx)(o.Typography,{className:l.emptyStateTitle,children:"No Upload Logs"}),(0,h.jsx)(o.Typography,{className:l.emptyStateText,children:"No upload history found for this audience. Logs will appear here after you upload contacts."})]})})})},Xe=e=>{const t=(0,j._E)()?.basename;return t||"/projects/"+e+"/advertisement"};var Qe=a(80697),et=a(73546);const tt=a.p+"3810c66cc59c3cf47fed1398e45bdaa0.svg",at=(0,o.makeStyles)((e=>({tableContainer:{borderRadius:14,border:"1px solid #F4F3F6",boxShadow:"none",minHeight:400},table:{minWidth:650,boxShadow:"none"},headerRow:{backgroundColor:"#ffffff"},headerCell:{fontSize:14,fontWeight:600,color:"#9593AE",padding:"18px 22px"},bodyRow:{backgroundColor:"#ffffff"},audienceName:{fontWeight:600},subLabel:{fontSize:13,color:"#9e9e9e"},sourceText:{fontSize:14,color:"#5f6368"},sizeText:{fontWeight:500},updatedText:{fontSize:13,color:"#9e9e9e"},statusChip:{padding:"2px 8px",borderRadius:16,fontSize:10,fontWeight:600,display:"inline-flex",alignItems:"center",textTransform:"capitalize",border:"1px solid #E8E8ED"},statusDot:{display:"inline-block",borderRadius:"50%",width:8,height:8,marginRight:8},statusReady:{backgroundColor:"#00B164"},statusBuilding:{backgroundColor:"#EC8600"},statusInactive:{backgroundColor:"#F44336"},circleIcon:{borderRadius:"50%",border:"1px solid #DAD9E2",width:18,height:18,display:"inline-block"},circleCheckedIcon:{borderRadius:"50%",backgroundColor:e.palette.primary.main,border:"1.5px solid #DAD9E2",width:18,height:18,dis
1play:"flex",alignItems:"center",justifyContent:"center",color:"#fff"},menuPaper:{borderRadius:8,width:200,boxShadow:"none"},menuItem:{fontSize:14,color:"#212121","&:hover":{backgroundColor:"#EBF5F3"},"&.Mui-selected":{backgroundColor:"#EBF5F3"},"&.Mui-focusVisible":{backgroundColor:"#EBF5F3"}},noDataContainer:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:"#ffffff",minHeight:500,borderRadius:12,padding:40,textAlign:"center"},noDataTitle:{fontSize:18,fontWeight:600,color:"#212121",marginBottom:8},noDataSubtitle:{fontSize:14,color:"#9593AE",marginBottom:20,maxWidth:400,lineHeight:1.5},createButton:{marginTop:10},noDataImage:{width:200,height:200,marginBottom:20,borderRadius:12}}))),nt=e=>{let{audienceMenuItems:t,onMenuAction:a,rowData:s,selectedAudience:i,selectedRowIndex:r,currentRowIndex:l}=e;const c=at(),[p,u]=(0,n.useState)(null),m=Boolean(p),g=()=>{u(null)},b=r===l,y="CUSTOM"===s?.type||"CUSTOM"===s?.audienceType,x="USER_PROVIDED_ONLY"===s?.customerFileSource,f="ACTIVE"===s?.status||"Ready"===s?.status,A=t.filter((e=>!("add-contacts"===e.action&&!x||"view-details"===e.action&&!x))).map((e=>{let t=!1,a="";return"create-campaign"!==e.action&&"create-lookalike"!==e.action||(b?y?f||(t=!0,a="Audience must be active to create ads or broadcasts"):(t=!0,a="Only custom audiences can be used for ads and broadcasts"):(t=!0,a="Select this custom audience to create ads or broadcasts")),{...e,disabled:t,tooltipText:a}}));return A.length?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.IconButton,{size:"small",onClick:e=>{u(e.currentTarget)},children:(0,h.jsx)(d.MoreVert,{fontSize:"small"})}),(0,h.jsx)(o.Menu,{anchorEl:p,open:m,onClose:g,children:A.map((e=>(0,h.jsx)(o.Tooltip,{title:e.disabled?e.tooltipText:"",placement:"left",arrow:!0,children:(0,h.jsx)("span",{children:(0,h.jsxs)(o.MenuItem,{onClick:()=>!e.disabled&&(e=>{a&&a(e.action,e,s),g()})(e),className:c.menuItem,disabled:e.disabled,style:{opacity:e.disabled?.5:1,cursor:e.disabled?"not-allowed":"pointer"},children:[(0,h.jsx)(o.ListItemIcon,{className:c.menuIcon,children:e.icon}),(0,h.jsx)(o.ListItemText,{primary:e.label})]})})},e.label)))})]}):null},st=e=>{let{audienceMenuItems:t,rows:a,onMenuAction:s,currentType:i,onCreateCustomAudience:r,onCreateLookalikeAudience:l,disabled:c=!1,onSelectionChange:p,selectedAudience:u,selectedRowIndex:m}=e;const g=at(),[b,y]=((0,o.useMediaQuery)("(max-width:600px)"),(0,n.useState)(null)),x=(()=>{switch(i){case"CUSTOM":return{title:"You haven't created any custom audiences yet",subtitle:"Build custom audiences from your customer data to target specific groups.",buttonText:"Create Custom Audience",buttonAction:r};case"LOOKALIKE":return{title:"You haven't created any lookalike audiences yet",subtitle:"Create lookalike audiences to reach people similar to your existing customers.",buttonText:"Create Lookalike Audience",buttonAction:l};default:return{title:"You haven't created any audiences yet",subtitle:"Build custom or lookalike audiences to use them in your future ad campaigns.",buttonText:"Create Audience",buttonAction:r}}})();return(0,h.jsx)(o.Box,{children:a.length<=0?(0,h.jsxs)(o.Box,{className:g.noDataContainer,children:[(0,h.jsx)("img",{src:tt,alt:"No data",className:g.noDataImage}),(0,h.jsx)(o.Typography,{variant:"h5",className:g.noDataTitle,children:x.title}),(0,h.jsx)(o.Typography,{variant:"h6",className:g.noDataSubtitle,children:x.subtitle}),(0,h.jsx)(o.Button,{variant:"contained",color:"primary",className:g.createButton,onClick:x.buttonAction,disabled:c,children:x.buttonText})]}):(0,h.jsx)(o.TableContainer,{component:o.Paper,className:g.tableContainer,children:(0,h.jsxs)(o.Table,{className:g.table,children:[(0,h.jsx)(o.TableHead,{children:(0,h.jsxs)(o.TableRow,{className:g.headerRow,children:[(0,h.jsx)(o.TableCell,{padding:"checkbox"}),(0,h.jsx)(o.TableCell,{className:g.headerCell,children:"Name"}),(0,h.jsx)(o.TableCell,{className:g.headerCell,children:"Audience ID"}),(0,h.jsx)(o.TableCell,{className:g.headerCell,children:"Type"}),(0,h.jsx)(o.TableCell,{className:g.headerCell,children:"Estimated Audience Size"}),(0,h.jsx)(o.TableCell,{className:g.headerCell,children:"Last Updated"}),(0,h.jsx)(o.TableCell,{className:g.headerCell,children:"Account ID"}),(0,h.jsx)(o.TableCell,{className:g.headerCell})]})}),(0,h.jsx)(o.TableBody,{children:a.map(((e,a)=>(0,h.jsxs)(o.TableRow,{className:g.bodyRow,children:[(0,h.jsx)(o.TableCell,{padding:"checkbox",children:(0,h.jsx)(o.Checkbox,{color:"primary",checked:b===a,onChange:()=>((e,t)=>{const a=b===t?null:t;y(a),p&&p(null!==a?e:null,a)})(e,a),icon:(0,h.jsx)("span",{className:g.circleIcon}),checkedIcon:(0,h.jsx)("span",{className:g.circleCheckedIcon,children:(0,h.jsx)(d.Check,{style:{fontSize:14}})})})}),(0,h.jsxs)(o.TableCell,{style:{width:"30%"}
1,children:[(0,h.jsx)(o.Typography,{className:g.audienceName,children:e.title}),(0,h.jsx)(o.Typography,{className:g.subLabel,children:e.subLabel})]}),(0,h.jsx)(o.TableCell,{children:(0,h.jsx)(o.Typography,{className:g.audienceName,children:e.audienceId})}),(0,h.jsx)(o.TableCell,{children:(0,h.jsx)(o.Typography,{className:g.audienceName,children:e.subtype})}),(0,h.jsx)(o.TableCell,{children:(0,h.jsx)(o.Typography,{className:g.audienceName,style:{textAlign:"center"},children:e.approximateCount>0?e.approximateCount:"N/A"})}),(0,h.jsx)(o.TableCell,{children:(0,h.jsx)(o.Typography,{className:g.audienceName,children:ve()(e.timeUpdated).format("MMM D, YYYY")})}),(0,h.jsx)(o.TableCell,{children:(0,h.jsx)(o.Typography,{className:g.audienceName,children:`act_${e.ownerMetaAdAccountId}`})}),(0,h.jsx)(o.TableCell,{align:"right",style:{whiteSpace:"nowrap"},children:t?.length>0&&(0,h.jsx)(nt,{audienceMenuItems:t,onMenuAction:s,rowData:e,selectedAudience:u,selectedRowIndex:m,currentRowIndex:a})})]},a)))})]})})})},ot=e=>{let{children:t,value:a,index:n,...s}=e;return(0,h.jsx)("div",{role:"tabpanel",hidden:a!==n,id:`tabpanel-${n}`,"aria-labelledby":`tab-${n}`,children:a===n&&(0,h.jsx)("div",{children:t})})},it=(0,o.makeStyles)((e=>({toggleContainer:{backgroundColor:"#f0f0f0",display:"flex",borderRadius:"8px",padding:"5.5px",width:"fit-content",minWidth:"40vw",[e.breakpoints.down("sm")]:{width:"97%",padding:"4px",minWidth:"auto"}},toggleButton:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:e.spacing(.2),padding:e.spacing(.65,.65),borderRadius:"6px",border:"none",backgroundColor:"transparent",color:e.palette.text.secondary,fontSize:"0.7rem",fontWeight:600,cursor:"pointer",transition:"all 0.2s ease",[e.breakpoints.down("sm")]:{padding:e.spacing(.75,.5),fontSize:"0.75rem",minHeight:"36px"},"&:focus":{outline:"none",boxShadow:"none"}},toggleButtonActive:{backgroundColor:"white",color:"black",borderRadius:"6px",transition:"all 0.2s ease"}}))),rt=e=>{let{tabs:t,value:a,onChange:n}=e;const i=it();return(0,h.jsxs)("div",{children:[(0,h.jsx)("div",{className:i.toggleContainer,children:t.map(((e,t)=>{const r=e.disabled||!1,l=e.disabledTooltip||"",d=(0,h.jsxs)("button",{className:`${i.toggleButton} ${a===t?i.toggleButtonActive:""}`,onClick:()=>(e=>{if(n&&"function"==typeof n)try{n({},e)}catch(t){n(e)}})(t),"aria-label":e.label,role:"tab","aria-selected":a===t,"aria-controls":`tabpanel-${t}`,id:`tab-${t}`,disabled:r,style:{opacity:r?.5:1,cursor:r?"not-allowed":"pointer"},children:[e.icon&&(0,h.jsx)("span",{style:{display:"flex",alignItems:"center"},children:e.icon}),(0,h.jsx)(o.Typography,{children:e.label})]});return l&&r?(0,h.jsx)(o.Tooltip,{title:l,placement:"top",children:(0,h.jsx)("span",{children:d})},t):(0,h.jsx)(s().Fragment,{children:d},t)}))}),t.map(((e,t)=>(0,h.jsx)(ot,{value:a,index:t,children:e.content},t)))]})};var lt=a(85731),dt=a(18931);const ct=(0,o.withStyles)((e=>({row:{display:"flex",alignItems:"stretch",width:"100%",boxSizing:"border-box",borderRadius:16,border:"1px solid #ececec",background:"#fff",overflow:"hidden",[e.breakpoints.down("sm")]:{flexDirection:"column"}},eyebrow:{fontSize:11,fontWeight:700,letterSpacing:"0.6px",textTransform:"uppercase",color:e.palette.primary.main,margin:0},leftCard:{width:300,flexShrink:0,boxSizing:"border-box",padding:e.spacing(3),background:"linear-gradient(180deg, rgba(37,211,102,0.08) 0%, rgba(37,211,102,0.02) 100%)",borderRight:"1px solid #ececec",[e.breakpoints.down("sm")]:{width:"100%",borderRight:"none",borderBottom:"1px solid #ececec"}},leftCardFull:{width:"100%",borderRight:"none",[e.breakpoints.down("sm")]:{borderBottom:"none"}},leftCardTitle:{fontSize:20,fontWeight:600,marginTop:e.spacing(1),marginBottom:e.spacing(2),color:e.palette.text.primary},leftCardBody:{fontSize:13,lineHeight:1.5,color:e.palette.text.secondary,marginBottom:e.spacing(2)},videoThumb:{position:"relative",display:"block",width:"100%",boxSizing:"border-box",border:"none",borderRadius:12,overflow:"hidden",cursor:"pointer",padding:0,paddingTop:"56.25%",marginBottom:e.spacing(2),background:"linear-gradient(135deg, rgba(16,157,89,0.24) 0%, rgba(16,157,89,0.06) 100%)","&:focus-visible":{outline:`2px solid ${e.palette.primary.main}`,outlineOffset:2}},videoThumbContent:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:e.spacing(1)},playButton:{width:44,height:44,borderRadius:"50%",background:"#fff",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 6px 16px rgba(0,0,0,0.18)"},watchTutorialLabel:{fontSize:12,fontWeight:600,color:"#0a474c",background:"rgba(255,255,255,0.9)",padding:"3px 10px",borderRadius:20},guideLinksList:{display:"flex",flexDirection:"column",gap:e.spacing(1)},guideLink:{display:"inline-flex",alignItems:"center",gap:6,fontSize:13,fontWeight:600,color:e.palette.primary.main,textDecoration:"none","&:hover":{textDecoration:"underline"}},rightPanel:{flex:1,minWidth:0,boxSizing:"border-box",padding:e.spacing(3)},rightEyebrowRow:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:e.spacing(1),flexWrap:"wrap",gap:e.spacing(1)},rightEyebrowLeft:{display:"flex",alignItems:"center",gap:6},startInMinutes:{fontSize:12,color:e.palette.text.secondary,marginLeft:"auto"},rightHeading:{fontSize:20,fontWeight:700,marginBottom:e.spacing(2.5),color:e.palette.text.primary},shortcutGrid:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:e.spacing(2),"html.ginger-panel-open &":{[e.breakpoints.down(1600)]:{"& > *:nth-child(n+5)":{display:"none"}},[e.breakpoints.down(1200)]:{gridTemplateColumns:"minmax(0, 1fr)","& > *:nth-child(n+3)":{display:"none"}}},[e.breakpoints.down("sm")]:{gridTemplateColumns:"minmax(0, 1fr)"}}
1,shortcutCard:{display:"flex",alignItems:"flex-start",gap:12,width:"100%",height:"100%",boxSizing:"border-box",textAlign:"left",padding:e.spacing(2),borderRadius:12,border:"1px solid #e6e6e6",background:"#fff",cursor:"pointer",transition:"all 0.2s",fontFamily:e.typography.fontFamily,"&:hover:not(:disabled)":{borderColor:e.palette.primary.main,boxShadow:`0 0 0 1px ${e.palette.primary.main}`,transform:"translateY(-2px)"},"&:focus-visible":{outline:`2px solid ${e.palette.primary.main}`,outlineOffset:2}},shortcutCardDisabled:{opacity:.5,cursor:"not-allowed"},shortcutCardHighlighted:{border:"1px solid rgba(16, 157, 89, 0.45)",background:"linear-gradient(180deg, rgba(37, 211, 102, 0.06) 0%, rgba(37, 211, 102, 0.02) 100%)"},shortcutBody:{minWidth:0,flex:1,alignSelf:"stretch",display:"flex",flexDirection:"column"},shortcutTitleRow:{display:"flex",alignItems:"center",gap:8,flexWrap:"nowrap",minWidth:0},shortcutTitle:{fontSize:15,fontWeight:600,color:e.palette.text.primary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},shortcutDescription:{fontSize:13,lineHeight:1.4,color:e.palette.text.secondary,marginTop:4},tagBase:{fontSize:10,fontWeight:700,letterSpacing:"0.3px",textTransform:"uppercase",padding:"2px 8px",borderRadius:10,lineHeight:1.6,whiteSpace:"nowrap",flexShrink:0},tagAi:{backgroundColor:"rgba(124, 58, 237, 0.12)",color:"#7C3AED"},tagGreen:{backgroundColor:"rgba(37, 211, 102, 0.15)",color:"#0a7c43"},tagAmber:{backgroundColor:"rgba(245, 158, 11, 0.14)",color:"#B45309"},tagGray:{backgroundColor:"rgba(0, 0, 0, 0.06)",color:e.palette.text.secondary}})))((e=>{let{classes:t,guide:a,heading:n,shortcuts:s=[]}=e;const i=Array.isArray(s)&&s.length>0,r=a?.guideLinks?.length?a.guideLinks:a?.guideLink?[a.guideLink]:[],l=e=>{switch(e){case"ai":return t.tagAi;case"popular":case"new":return t.tagGreen;case"amber":return t.tagAmber;default:return t.tagGray}};return(0,h.jsxs)(o.Box,{className:t.row,children:[a&&(0,h.jsxs)(o.Box,{className:`${t.leftCard} ${i?"":t.leftCardFull}`,children:[(0,h.jsx)(o.Typography,{className:t.eyebrow,children:a.eyebrow}),(0,h.jsx)(o.Typography,{variant:"h5",className:t.leftCardTitle,children:a.title}),a.showGuideLinks&&a.onWatchTutorial&&(0,h.jsx)(o.Box,{component:"button",type:"button",className:t.videoThumb,onClick:()=>{const e=a?.onWatchTutorial;"function"==typeof e?e():"string"==typeof e&&e&&window.open(e,"_blank","noopener,noreferrer")},"aria-label":`Watch tutorial video for ${a.title} (opens in a new tab)`,children:(0,h.jsxs)(o.Box,{className:t.videoThumbContent,children:[(0,h.jsx)(o.Box,{className:t.playButton,children:(0,h.jsx)(lt.A,{size:18,color:"#0a474c",fill:"#0a474c"})}),(0,h.jsx)(o.Typography,{className:t.watchTutorialLabel,children:"Watch tutorial"})]})}),a.description&&(0,h.jsx)(o.Typography,{className:t.leftCardBody,children:a.description}),a.showGuideLinks&&r.length>0&&(0,h.jsx)(o.Box,{className:t.guideLinksList,children:r.map(((e,a)=>(0,h.jsxs)(o.Link,{href:e.url,target:"_blank",rel:"noopener noreferrer",className:t.guideLink,onClick:e.onClick,children:[(0,h.jsx)("span",{children:e.label}),(0,h.jsx)(dt.A,{size:14})]},e.url||a)))})]}),i&&(0,h.jsxs)(o.Box,{className:t.rightPanel,children:[(n?.icon||n?.eyebrow||n?.rightNote)&&(0,h.jsxs)(o.Box,{className:t.rightEyebrowRow,children:[(n?.icon||n?.eyebrow)&&(0,h.jsxs)(o.Box,{className:t.rightEyebrowLeft,children:[n?.icon,n?.eyebrow&&(0,h.jsx)(o.Typography,{className:t.eyebrow,children:n.eyebrow})]}),n?.rightNote&&(0,h.jsx)(o.Typography,{className:t.startInMinutes,children:n.rightNote})]}),(0,h.jsx)(o.Typography,{variant:"h5",className:t.rightHeading,children:n?.title}),(0,h.jsx)(o.Box,{className:t.shortcutGrid,children:s.map((e=>(0,h.jsxs)(o.Box,{component:"button",type:"button",disabled:!!e.disabled,onClick:e.disabled?void 0:e.onClick,className:`${t.shortcutCard} ${e.disabled?t.shortcutCardDisabled:""} ${e.highlighted?t.shortcutCardHighlighted:""}`,children:[e.icon,(0,h.jsxs)(o.Box,{className:t.shortcutBody,children:[(0,h.jsxs)(o.Box,{className:t.shortcutTitleRow,children:[(0,h.jsx)(o.Typography,{className:t.shortcutTitle,children:e.title}),e.tag&&(0,h.jsx)(o.Box,{component:"span",className:`${t.tagBase} ${l(e.tagVariant)}`,children:e.tag})]}
1),(0,h.jsx)(o.Typography,{className:t.shortcutDescription,children:e.description})]})]},e.key)))})]})]})})),pt={template:{sectionDisplayName:"Template Message",section:"template",docLinks:[{url:"https://faq.aisensy.com/how-to-create-whatsapp-template-messages-in-aisensy/",title:"How to Create WhatsApp Template Message?",triggerEvent:"explore_template_page_tutorial"},{url:"https://m.aisensy.com/how-to-use-parameters-in-whatsapp-template-message",title:"Use chatbot parameters for leads",triggerEvent:"explore_template_page_tutorial"},{url:"https://m.aisensy.com/how-to-add-quick-reply-to-whatsapp-template-message",title:"Add Quick Reply to WhatsApp Template Message",triggerEvent:"explore_template_page_tutorial"},{url:"https://faq.aisensy.com/whatsapp-template-message-guidelines/",title:"Message formatting guideline (Bold, Italic & more)",triggerEvent:"explore_template_page_tutorial"}]},tag:{sectionDisplayName:"Tag",section:"tag",docLinks:[{url:"https://faq.aisensy.com/chat-profile/",title:"Chat Profile & First Message Tag",triggerEvent:"explore_tags_page_tutorial"},{url:"https://wiki.aisensy.com/en/articles/11501925-how-to-add-and-manage-tags-in-aisensy",title:"How to create & add tags to contacts",triggerEvent:"explore_tags_page_tutorial"}]},liveChat:{sectionDisplayName:"Live Chat",section:"liveChat",docLinks:[{url:"https://m.aisensy.com/how-to-add-user-attributes-manually",title:"Add user attributes manually",triggerEvent:"explore_live_page_tutorial"},{url:"https://m.aisensy.com/how-to-set-tags-and-attributes-from-user-profile",title:"Add/Remove Tag & update attribute",triggerEvent:"explore_live_page_tutorial"},{url:"https://m.aisensy.com/how-to-create-media-link-whatsapp-template-message",title:"Send & Generate media link",triggerEvent:"explore_live_page_tutorial"}]},attribute:{sectionDisplayName:"Attribute",section:"attribute",docLinks:[{url:"https://m.aisensy.com/how-to-add-user-attributes-manually",title:"Add user attributes manually",triggerEvent:"add_user_attributes_manually"},{url:"https://wiki.aisensy.com/en/articles/11502709-attributes-in-aisensy",title:"Attributes in AiSensy",triggerEvent:"attributes_in_aisensy"}]},globalVariable:{sectionDisplayName:"GlobalAttribute",section:"globalAttribute",docLinks:[{url:"https://help.aisensy.com/en/articles/9267658-how-to-use-global-attributes-in-aisensy",title:"Global attributes in AiSensy",triggerEvent:"attributes_in_aisensy"}]},campaign:{sectionDisplayName:"Campaign",section:"campaign",docLinks:[{url:"https://m.aisensy.com/how-to-use-filters-to-refine-whatsapp-broadcast",title:"Audience segregation for WhatsApp Broadcast",triggerEvent:"explore_campaigns_page_tutorial"},{url:"https://m.aisensy.com/how-to-upgrade-whatsapp-tier-limit",title:"Upgrade WhatsApp Tier Limit",triggerEvent:"explore_campaigns_page_tutorial"}]},contact:{sectionDisplayName:"Contacts",section:"contact",docLinks:[{url:"https://faq.aisensy.com/how-to-import-export-contacts-in-aisensy/",title:"Import upto 2 lakh contacts in one go",triggerEvent:"explore_contacts_page_tutorial"},{isVideo:!0,url:"wistia_embed wistia_async_cg750v82cx popover=true popoverContent=link wistia_embed_initialize playerColor=04454D",title:"Watch Tutorial",triggerEvent:"explore_contacts_page_tutorial"}]},chatbot:{sectionDisplayName:"Chatbot",section:"chatbot",docLinks:[{url:"https://faq.aisensy.com/how-to-create-drag-drop-chatbot-in-just-10-minutes-chatbot-flow-builder/",title:"Setup Welcome WhatsApp Chatbot",triggerEvent:"explore_chatbot_page_tutorial"}]},integration:{sectionDisplayName:"Integration",section:"integration",docLinks:[{url:"https://faq.aisensy.com/how-to-create-free-whatsapp-button-for-your-website/",title:"Create WhatsApp Button for Free",triggerEvent:"explore_integration_tutorial"},{url:"https://m.aisensy.com/blog/how-to-create-whatsapp-link",title:"Create WhatsApp Link for Free",triggerEvent:"explore_integration_tutorial"}]},migration:{sectionDisplayName:"Dashboard",section:"migration",docLinks:[{url:"https://m.aisensy.com/how-to-add-agents-and-managers-in-aisensy-app",title:"2fa disabled",triggerEvent:"explore_migraton_page_tutorial"}]},agent:{sectionDisplayName:"Agent",section:"agent",docLinks:[{url:"https://m.aisensy.com/how-to-add-agents-and-managers-in-aisensy-app",title:"Learn how to manage team members & managers",triggerEvent:"explore_agents_page_tutorial"}]},facebook:{sectionDisplayName:"Facebook Verification",section:"facebook",docLinks:[{url:"https://m.aisensy.com/how-to-ver
1ify-facebook-business-manager-account",title:"How to apply for FB Verification?",triggerEvent:"explore_facebook_tutorial"},{url:"https://m.aisensy.com/what-if-the-facebook-verification-start-button-is-greyed",title:"FB Verification button greyed out?",triggerEvent:"explore_facebook_tutorial"}]},display_and_phone:{sectionDisplayName:"Display Name & Phone Number",section:"display_and_phone",docLinks:[{url:"https://help.aisensy.com/en/articles/5348553-phone-number-rules",title:"Phone Number Rules",triggerEvent:"explore_display_name_tutorial"},{url:"https://help.aisensy.com/en/articles/5348554-display-name-rules",title:"Display Name Rules",triggerEvent:"explore_display_name_tutorial"}]},waba:{sectionDisplayName:"WABA",section:"waba",docLinks:[{url:"https://faq.aisensy.com/steps-to-apply-for-whatsapp-business-api/",title:"How to apply for WhatsApp Business API?",triggerEvent:"explore_waba_tutorial"}]},greenTick:{sectionDisplayName:"Green Tick",section:"greenTick",docLinks:[{url:"https://faq.aisensy.com/how-to-apply-for-whatsapp-green-tick/",title:"WhatsApp Blue Tick",triggerEvent:"explore_green_tick_tutorial"}]},profileEdit:{sectionDisplayName:"Customize WhatsApp Profile",section:"profileEdit",docLinks:[{url:"https://m.aisensy.com/how-to-edit-whatsapp-business-profile-in-aisensy",title:"How to Edit Business Profile?",triggerEvent:"explore_profile_edit_tutorial"}]},canned:{sectionDisplayName:"Canned Message",section:"canned",docLinks:[{url:"https://faq.aisensy.com/what-are-canned-messages-how-to-add-them-in-aisensy/",title:"How to create Canned Message?",triggerEvent:"explore_canned_message_tutorial"}]},billingAndUsage:{sectionDisplayName:"Billing and Usage",section:"billingAndUsage",docLinks:[{url:"https://faq.aisensy.com/aisensy-billing-cycle-whatsapp-pricing-details/",title:"How does AiSensy billing works?",triggerEvent:"explore_billing_and_usage_tutorial"}]},catalogue:{sectionDisplayName:"Catalogue",section:"catalogue",docLinks:[{url:"https://m.aisensy.com/how-to-create-canned-messages-in-aisensy",title:"How to create Cart Catalogue ?",triggerEvent:"explore_catalogue_tutorial"}]},opt:{sectionDisplayName:"Opt-out/Opt-in User",section:"opt",docLinks:[{url:"https://faq.aisensy.com/how-to-opt-in-opt-out-users-from-your-whatsapp-broadcasts-in-aisensy/",title:"How to create Opt-out/Opt-in User?",triggerEvent:"explore_canned_message_tutorial"}]},liveChatSettings:{sectionDisplayName:"Live Chat Settings",section:"liveChatSettings",docLinks:[{url:"https://faq.aisensy.com/how-to-set-up-welcome-off-hours-auto-replies-in-aisensy-app/",title:"How to enable Auto Resolve Chats?",triggerEvent:"explore_live_chat_tutorial"}]},notification:{sectionDisplayName:"Notification",section:"notification",docLinks:[{url:"https://wiki.aisensy.com/en/articles/11502615-notification-preferences-customize-sound-push-notifications-for-requesting-chats",title:"How to enable Sound & Push Notifications?",triggerEvent:"explore_notification_preference_tutorial"}]},shopify:{sectionDisplayName:"Ecomm",section:"ecomm",docLinks:[{url:"https://wiki.aisensy.com/en/articles/11484725-how-to-setup-messages-for-your-shopify-store-aisensy-x-shopify-2",title:"How to setup automated shopify messages",triggerEvent:"explore_shopify_in_ecomm"}]},shopifySetup:{sectionDisplayName:"Ecomm",section:"ecomm",docLinks:[{url:"https://help.aisensy.com/en/articles/7029056-how-to-create-access-token-api-secret-key-from-shopify-aisensy-x-shopify-1",title:"How to get Access Token and API Secret Key",triggerEvent:"explore_shopify_in_ecomm"}]},woocommerce:{sectionDisplayName:"Ecomm",section:"ecomm",docLinks:[{url:"https://help.aisensy.com/en/articles/7040525-woocommerce-x-aisensy-how-to-integrate-woocommerce-with-aisensy",title:"How to setup automated woocommerce messages",triggerEvent:"explore_woocommerce_in_ecomm"}]},woocommerceSetup:{sectionDisplayName:"Ecomm",section:"ecomm",docLinks:[{url:"https://help.aisensy.com/en/articles/7034328-how-to-create-woocommerce-secret-api-keys",title:"How to get Consumer Key and Secret Key",triggerEvent:"explore_woocommerce_in_ecomm"}]},metaAds:{sectionDisplayName:"Meta Ads",section:"metaAds",docLinks:[{url:"https://wiki.aisensy.com/en/?q=meta%20ads",title:"How to run Ads",triggerEvent:"explore_meta_ads"},{isYTVideo:!0,url:"https://youtube.com/embed/Q3H_Qmd0cys",title:"Click to WhatsApp Ads setup tutorial",triggerEvent:"explore_meta_ad"}]},metaAudiences:{sectionDisplayName:"Meta Audiences",section:"metaAudiences",docLinks:[{url:"https://www.facebook.com/business/help/610516375684216?id=2469097953376494",title:"How to create Website Audiences",triggerEvent:"explore_meta_audie
1nces"}]},shopifyAccessScopesEdit:{sectionDisplayName:"Chat",section:"chat",docLinks:[{url:"https://help.aisensy.com/en/articles/7628493-how-to-give-read-customer-permission-in-an-existing-shopify-app",title:"Read docs",triggerEvent:"add_customer_access_scopes_for_shopify"}]},whatsappPaySettings:{sectionDisplayName:"Whatsapp Pay Settings",section:"whatsappPaySettings",docLinks:[{url:"https://help.aisensy.com/en/articles/8300048-how-to-connect-whatsapp-pay-with-aisensy",title:"Read User Guide",triggerEvent:"explore_whatsapp_pay_settings_doc"},{isYTVideo:!0,url:"https://www.youtube.com/embed/k_MzrqOoZK4",title:"WhatsApp Payment Journey",triggerEvent:"explore_whatsapp_pay_journey_doc"},{isVideo:!0,url:"wistia_embed wistia_async_lstj0e9045 popover=true popoverContent=link wistia_embed_initialize playerColor=04454D",title:"WhatsApp Payment Setup Video",triggerEvent:"explore_whatsapp_pay_journey_doc"},{isVideo:!0,url:"wistia_embed wistia_async_2lpyv64wag popover=true popoverContent=link wistia_embed_initialize playerColor=04454D",title:"How to use WhatsApp Payment",triggerEvent:"explore_whatsapp_pay_journey_doc"}]}};var ut=a(72505),mt=a.n(ut);const ht=async e=>{let{triggerEvent:t,triggerNote:a,relatedProspectId:n,activityCode:s}=e;try{const e={triggerEvent:t,triggerNote:a,relatedProspectId:n,activityCode:s};if(!n)throw new Error("Prospect ID not found");await mt().post(`${J.k}/api/push-front-end-events-to-leadSquared`,e)}catch(e){return console.error("Error pushing activity to LeadSquared:",e),e}},gt=e=>{const t=(a=e?.url,a?.match(/wistia_async_([a-zA-Z0-9]+)/i)?.[1]);var a;return t?`https://fast.wistia.net/embed/iframe/${t}`:void 0},bt=function(){let e=arguments.length>1?arguments[1]:void 0;const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map((t=>({label:t.title,url:t.isVideo?gt(t):t.url,onClick:()=>((e,t)=>{e?.triggerEvent&&ht({triggerEvent:e.triggerEvent,triggerNote:e.title,relatedProspectId:t,activityCode:220})})(t,e)}))).filter((e=>!!e.url));return{guideLinks:t,onWatchTutorial:void 0}};var yt,xt,ft=a(27775),At=a(66220),It=a(81999),Ct=a(86589),_t=a(1834),St=a(42640);function vt(){return vt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},vt.apply(null,arguments)}function Et(e){return n.createElement("svg",vt({stroke:"currentColor",fill:"none",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",color:"currentColor","aria-hidden":"true",height:24,width:24,xmlns:"http://www.w3.org/2000/svg"},e),yt||(yt=n.createElement("path",{d:"M3 21l1.65-3.8a9 9 0 113.4 2.9L3 21"})),xt||(xt=n.createElement("path",{d:"M9 10a.5.5 0 001 0V9a.5.5 0 00-1 0v1a5 5 0 005 5h1a.5.5 0 000-1h-1a.5.5 0 000 1"})))}a.p;var Tt,Dt;function wt(){return wt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},wt.apply(null,arguments)}function Nt(e){return n.createElement("svg",wt({stroke:"currentColor",fill:"none",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",color:"currentColor","aria-hidden":"true",height:24,width:24,xmlns:"http://www.w3.org/2000/svg"},e),Tt||(Tt=n.createElement("path",{d:"M8.56 3.69a9 9 0 00-2.92 1.95M3.69 8.56A9 9 0 003 12M3.69 15.44a9 9 0 001.95 2.92M8.56 20.31A9 9 0 0012 21M15.44 20.31a9 9 0 002.92-1.95M20.31 15.44A9 9 0 0021 12M20.31 8.56a9 9 0 00-1.95-2.92M15.44 3.69A9 9 0 0012 3"})),Dt||(Dt=n.createElement("circle",{cx:12,cy:12,r:2.25,fill:"currentColor",stroke:"none"})))}a.p;var jt;function kt(){return kt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},kt.apply(null,arguments)}function Lt(e){return n.createElement("svg",kt({stroke:"currentColor",fill:"none",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",color:"currentColor","aria-hidden":"true",height:24,width:24,xmlns:"http://www.w3.org/2000/svg"},e),jt||(jt=n.createElement("path",{d:"M3 12a9 9 0 1018 0 9 9 0 00-18 0M3.6 9h16.8M3.6 15h16.8M11.5 3a17 17 0 000 18M12.5 3a17 17 0 010 18"})))}a.p;var Rt;function Bt(){return Bt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},Bt.apply(null,arguments)}function Ot(e){return n.createElement("svg",Bt({stroke:"currentColor",fill:"none",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",color:"currentColor","aria-hidden":"true",height:24,width:24,xmlns:"http://www.w3.org/2000/svg"},e),Rt||(Rt=n.createElement("path",{d:"M12 3a3 3 0 00-3 3v12a3 3 0 003 3M6 3a3 3 0 013 3v12a3 3 0 01-3 3M13 7h7a1 1 0 011 1v8a1 1 0 01-1 1h-7M5 7H4a1 1 0 00-1 1v8a1 1 0 001 1h1M17 12h.01M13 12h.01"})))}a.p;const Pt={width:"22px",height:"22px"},Mt=e=>(0,h.jsx)(o.Box,{style:{width:"36px",height:"36px",borderRadius:"10px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e}),Ut={ctwa:Mt((0,h.jsx)(Et,{style:{...Pt,color:"#109d59"}}
1)),whatsapp_status:Mt((0,h.jsx)(Nt,{style:{...Pt,color:"#109d59"}})),website_traffic:Mt((0,h.jsx)(Lt,{style:{...Pt,color:"#1877F2"}})),website_to_whatsapp:Mt((0,h.jsx)(Lt,{style:{...Pt,color:"#109d59"}})),lead_form:Mt((0,h.jsx)(Ot,{style:{...Pt,color:"#7C3AED"}}))},Ft=(e,t)=>(0,h.jsx)(o.Box,{style:{width:"36px",height:"36px",borderRadius:"10px",backgroundColor:e,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t}),Wt=e=>{let{history:t,projectId:a}=e;return{key:"broadcast",icon:Ft("rgba(37, 211, 102, 0.12)",(0,h.jsx)(ft.A,{size:20,color:"#109d59"})),title:"Launch Broadcast Campaign",description:"Reach your WhatsApp audience with offers, updates and alerts.",onClick:()=>t.push(`/projects/${a}/campaigns/create`)}},zt=e=>{let{history:t,projectId:a}=e;return{key:"status-ad",icon:Ut.whatsapp_status,title:"Launch WhatsApp Status Ad",tag:"NEW",tagVariant:"new",description:"Publish scroll-stopping offers directly to WhatsApp Status.",onClick:()=>t.push(`${Xe(a)}/create?selectedAdType=whatsapp_status`)}},Gt=e=>{let{history:t,projectId:a}=e;return{key:"ads-agent",icon:Ft("rgba(10, 71, 76, 0.12)",(0,h.jsx)(c.A,{size:20,color:"#0a474c"})),title:"Generate Ads with AI",tag:"AI",tagVariant:"ai",description:"Describe your business and Ads Agent writes, designs and targets the ads for you.",onClick:()=>t.push(`${Xe(a)}/ads-agent`)}},Ht=e=>{let{history:t,projectId:a}=e;return{key:"lead-form",icon:Ft("rgba(245, 158, 11, 0.14)",(0,h.jsx)(It.A,{size:20,color:"#B45309"})),title:"Launch Lead Form Ads",description:"Capture high-intent leads and follow up instantly on WhatsApp.",onClick:()=>t.push(`${Xe(a)}/create?selectedAdType=lead_form`)}},Vt={USD:{starter:100,growth:200,symbol:"$",Icon:Ct.A},INR:{starter:5e3,growth:1e4,symbol:"₹",Icon:_t.A}},Yt=e=>"USD"===e?Vt.USD:Vt.INR,Zt=(e,t)=>"USD"===e?`$${t}`:`₹${t.toLocaleString("en-IN")}`,Kt=e=>{let{onSelect:t,currency:a}=e;const{starter:n,Icon:s}=Yt(a),o=Zt(a,n);return{key:"starter-pack",icon:Ft("rgba(37, 211, 102, 0.12)",(0,h.jsx)(s,{size:20,color:"#109d59"})),title:`${o} Ads Starter Pack`,tag:"FREE SETUP",tagVariant:"new",description:`Get ${o} ad balance plus free expert campaign setup.`,onClick:()=>t(n)}},Jt=e=>{let{onSelect:t,currency:a}=e;const{growth:n,Icon:s}=Yt(a),o=Zt(a,n);return{key:"growth-pack",icon:Ft("rgba(37, 211, 102, 0.12)",(0,h.jsx)(s,{size:20,color:"#109d59"})),title:`${o} Ads Growth Pack`,tag:"RECOMMENDED",tagVariant:"new",description:`Get ${o} ad balance, expert setup and 30-day optimisation support.`,onClick:()=>t(n),highlighted:!0}},$t=e=>{let{history:t,projectId:a,disabled:n=!1}=e;return{key:"ai-agent",icon:Ft("rgba(124, 58, 237, 0.12)",(0,h.jsx)(St.A,{size:20,color:"#7C3AED"})),title:"Create AI Agent",tag:"AI",tagVariant:"ai",description:"Qualify leads, answer questions and close sales automatically.",onClick:()=>t.push(`/projects/${a}/agent-studio`),disabled:n}},qt=(0,r.withRouter)((e=>{let{history:t,match:a,title:n="Quick Guide",description:s,section:r,includeSection:l,guideLinks:d,prospectId:c,showTutorial:p=!0,shortcuts:u,heading:m,...g}=e;const b=a?.params?.projectId,y=!((0,i.useSelector)((e=>e.login?.user?.power))>=1),x=[...r&&pt[r]?.docLinks||[],...l&&pt[l]?.docLinks||[]],{guideLinks:f,onWatchTutorial:A}=bt(x,c),I=pt[r]?.sectionDisplayName,C={eyebrow:I?`${I} quick guide`:"Quick guide",title:n,description:s,showGuideLinks:p,onWatchTutorial:A,guideLinks:d||f},_=m||{title:"What would you like to launch?"},S=!p,v={history:t,projectId:b},E=[Wt(v),!S&&zt(v),!S&&Ht(v),$t({...v,disabled:y})].filter(Boolean),T=S?[]:u||E;return(0,h.jsx)(o.Box,{mt:3,mb:3,width:"100%",...g,children:(0,h.jsx)(ct,{guide:C,heading:_,shortcuts:T})})})),Xt=(e,t)=>{const a=(0,j._E)()?.integrations?.[e];return"function"==typeof a?a:"function"==typeof t?t:()=>{}},Qt=(0,r.withRouter)((0,i.connect)((e=>({assistantDetails:e.assistantDetails.data,login:e.login.user})))((e=>{let{assistantDetails:t,login:a,history:s,match:i,dispatch:r,...l}=e;
1const[d,c]=(0,n.useState)(!1),[p,m]=(0,n.useState)({}),g={history:s,projectId:i?.params?.projectId},b=e=>{const n=Xt("purchaseMetaAdsCredit")({amount:e,assistantDetails:t,login:a,updateAssistantStore:e=>r((0,$.nt)(e)),showSnackbar:m});n?.needsBillingAddress&&c(!0)};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(qt,{title:"Launch your Ads on Whatsapp, Facebook & Instagram",description:"Learn how to add ad credit, choose an objective and launch your first ad.",section:"metaAds",prospectId:t?.prospectId,showTutorial:(0,u.x)().isAiSensy&&!t?.partnerId,heading:{title:"Fund your ads or launch a campaign"},shortcuts:[Kt({onSelect:b,currency:t?.currency}),Jt({onSelect:b,currency:t?.currency}),zt(g),Ht(g),Gt(g),{key:"book-demo-call",icon:Ft("rgba(59, 130, 246, 0.12)",(0,h.jsx)(At.A,{size:20,color:"#2563EB"})),title:"Book a Demo Call",description:"Talk to an ads expert to set up, launch and troubleshoot your campaigns.",onClick:()=>window.open("https://calendly.com/ads-aisensy/ads-troubleshoot","_blank","noopener,noreferrer")}],...l}),(0,h.jsx)(B,{name:"metaAdsCreditDialog",dialogOpen:d,toggleTemplateCreditDialog:()=>c(!d),assistantDetails:t}),(0,h.jsx)(o.Snackbar,{open:!!p.alertOpen,autoHideDuration:6e3,onClose:()=>m({}),anchorOrigin:{vertical:"top",horizontal:"center"},children:(0,h.jsx)(O.Alert,{severity:p.severity||"info",onClose:()=>m({}),children:p.alertMsg})})]})})));var ea=a(14507);function ta(e){let{classes:t,accountValue:a,anchorEl:n,assistantDetails:s,handleCreateAdsNavigation:i,handleMenuClose:r,handleMenuOpen:l,handleOptionClick:c,isMobile:p,parentTab:u,selectedFetchedAdAccount:m}=e;return(0,h.jsxs)(o.Grid,{container:!0,alignItems:"center",justify:"space-between",className:`${t.pageTitleContainer} ${t.fullWidth} ginger-page-header`,children:[(0,h.jsx)(o.Grid,{item:!0,children:(0,h.jsx)(o.Typography,{variant:"h3",children:"Audiences"})}),(0,h.jsx)(o.Box,{ml:2,mr:4,display:"flex",alignItems:"center",children:(0,h.jsx)(B,{name:"gingerLauncher"})}),(0,h.jsx)(o.Grid,{item:!0,children:(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",gap:16,style:{marginLeft:p?0:12},children:[!p&&(0,h.jsx)(o.Tooltip,{title:s?.fbConnected?"Click on Create Ad to run click to WhatsApp Ads using your custom and lookalike audiences to target specific users":"Connect your Facebook Account",children:(0,h.jsx)(o.Button,{startIcon:(0,h.jsx)(d.AddOutlined,{}),variant:"contained",color:"primary",disabled:!(s?.fbConnected&&("aisensy_audiences"===u?a?.accountId||s?.selectedMetaAdAccountId:m?.accountId)),onClick:()=>i(!0),className:t.launchButton,children:"Create Ad"})}),(0,h.jsx)(o.Tooltip,{title:s?.fbConnected?"Create a custom or lookalike audience to target specific users with your ads":"Connect your Facebook Account",children:(0,h.jsxs)(o.Button,{variant:"contained",color:"primary",className:t.createAudienceButton,onClick:l,disabled:!s?.fbConnected||"aisensy_audiences"!=u||"aisensy_audiences"===u&&!a?.accountId&&!s?.selectedMetaAdAccountId,style:{marginLeft:p?0:12,marginRight:p?0:8},children:[(0,h.jsx)(Qe.A,{})," Create Audience"]})}),(0,h.jsxs)(o.Menu,{anchorEl:n,open:Boolean(n),onClose:r,className:t.menu,children:[(0,h.jsx)(o.Tooltip,{title:"Create a custom website audience from your pixel",placement:"right",children:(0,h.jsx)("div",{style:{width:"100%"},children:(0,h.jsx)(o.MenuItem,{onClick:()=>c("Custom Audience"),style:{width:"100%"},children:"Custom Audience"})})}),(0,h.jsx)(o.Tooltip,{title:"Create a lookalike audience that finds users similar to your existing custom audience to expand your reach",placement:"right",children:(0,h.jsx)("div",{style:{width:"100%"},children:(0,h.jsx)(o.MenuItem,{onClick:()=>c("Lookalike Audience"),style:{width:"100%"},children:"Lookalike Audience"})})})]})]})})]})}function aa(e){let{audienceMenuItems:t,storeSearchString:a,audiences:n,currentType:s,loading:i,classes:r,accountValue:l,agent:c,assistantDetails:p,debouncedSearch:u,dispatch:m,fbaccount:g,handleAudienceDelete:b,handleAudienceSelection:y,handleParentTabChange:x,handleSearchChange:f,handleTabChange:A,handleTableMenuAction:I,isLoading:C,isSyncing:_,parentTab:S,selectFetchedAdAccount:v,selectedAudience:E,selectedFetchedAdAccount:T,setAudienceType:D,setCreateAudienceOpen:w,syncAudiences:N,tabs:j,value:k}=e;return(0,h.jsx)(o.Grid,{container:!0,justify:"center",children:(0,h.jsx)(o.Grid,{item:!0,xs:12,md:11,lg:11,children:(0,h.jsxs)(o.Box,{className:r.innerContainer,children:[(0,h.jsx)(Qt,{}),(0,h.jsx)(o.Box,{style:{display:"flex",width:"100%",justifyContent:"space-between"},children:(0,h.jsx)(o.Box,{mt:3,mb:3,children:(0,h.jsxs)(o.Tabs,{value:S,onChange:x,indicatorColor:"primary",textColor:"primary",scrollButtons:"auto",children:[(0,h.jsx)(o.Tab,{style:{textTransform:"none"},label:(p?.partner?.brandName||"AiSensy")+" Audiences",value:"aisensy_audie
1nces"}),(0,h.jsx)(o.Tab,{style:{textTransform:"none"},label:"Fetched Audiences",value:"fetched_audiences"})]})})}),(0,h.jsxs)(o.Box,{style:{display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%"},children:[(0,h.jsx)(rt,{tabs:j,value:k,onChange:A}),(0,h.jsx)(o.Box,{style:{display:"flex",alignItems:"center",gap:"8px"},children:(0,h.jsxs)(o.Box,{className:r.toolbarLeft,children:["fetched_audiences"===S&&(0,h.jsx)(o.Box,{style:{width:"300px",flex:"0 1 auto",borderRadius:"6px"},children:(0,h.jsx)(o.Tooltip,{title:p?.fbConnectedBy!==c?.id&&p?.freezedMetaAdAccountId?"You don't have permission to change Ad Account":"",children:(0,h.jsx)(O.Autocomplete,{disableClearable:!0,disabled:!p?.fbConnected||p?.fbConnectedBy!==c?.id&&p?.freezedMetaAdAccountId,options:g.filter((e=>!e?.isChildBMAdAccount)),onChange:(e,t)=>v(t),value:T||null,groupBy:e=>e.metaBusinessName||"Other Ad Accounts",getOptionLabel:e=>{const{accountName:t,accountId:a}=e;return t&&a?`${t} - ${a.split("_")[1]}`:""},renderOption:(e,t)=>(0,ea.Oi)(e,t,r),renderInput:e=>(0,h.jsx)(o.TextField,{placeholder:"Choose ad account",...e,classes:{root:r.textFieldRoot},InputProps:{...e.InputProps}})})})}),(0,h.jsx)(o.Tooltip,{title:"Sync Audiences Insights & details",children:(0,h.jsx)(o.Button,{variant:"contained",color:"primary",size:"medium",startIcon:(0,h.jsx)(d.Sync,{}),onClick:N,disabled:_||i||!p?.fbConnected||("aisensy_audiences"===S?!l?.accountId&&!p?.selectedMetaAdAccountId:!T?.accountId),children:_?"Syncing...":"Sync"})})]})})]}),(0,h.jsx)(o.Box,{className:r.toolbarRow,children:(0,h.jsx)(o.Box,{className:r.searchContainer,children:(0,h.jsx)(o.TextField,{id:"searchAudienceTextField",placeholder:"Search audiences",value:a,classes:{root:r.textFieldRoot},color:"primary",style:{backgroundColor:"white",width:"100%"},onChange:f,disabled:!(p?.fbConnected&&("aisensy_audiences"===S?l?.accountId||p?.selectedMetaAdAccountId:T?.accountId)),InputProps:{startAdornment:(0,h.jsx)(o.InputAdornment,{position:"start",children:(0,h.jsx)(d.Search,{})}),endAdornment:a?(0,h.jsx)(o.InputAdornment,{position:"end",children:(0,h.jsx)(et.A,{style:{fontSize:20,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>{m((0,z.GF)("")),u&&u("")}})}):""}})})}),(0,h.jsx)(o.Box,{className:r.tableContainer,children:i||C?(0,h.jsx)(o.Box,{className:r.loadingContainer,children:(0,h.jsx)(o.CircularProgress,{})}):(0,h.jsx)(st,{audienceMenuItems:"aisensy_audiences"===S?t:t.filter((e=>"add-contacts"!==e.action&&"view-details"!==e.action)),deleteAudience:b,rows:n.map((e=>({title:e.name||e.audienceName||"Unnamed Audience",subLabel:e.description||e.subLabel||"",source:e.source||"Custom Audience",totalCustomAudiences:e.size?e.size.toLocaleString():"0",status:e.status||"Ready",lastUseDate:e.lastUpdated||e.updatedAt||new Date,...e}))),data:n,onMenuAction:I,onSelectionChange:y,currentType:s,disabled:!(p?.fbConnected&&("aisensy_audiences"===S?l?.accountId||p?.selectedMetaAdAccountId:T?.accountId)),selectedAudience:E,selectedRowIndex:E?n.findIndex((e=>(e._id||e.id)===(E._id||E.id))):null,onCreateCustomAudience:()=>{D("custom"),w(!0)},onCreateLookalikeAudience:()=>{D("lookalike"),w(!0)}})})]})})})}const na=[{label:"Upload Audience",icon:(0,h.jsx)(d.AddOutlined,{fontSize:"small"}),action:"add-contacts"},{label:"View Details",icon:(0,h.jsx)(d.Visibility,{fontSize:"small"}),action:"view-details"}],sa=(0,o.withStyles)((e=>({root:{height:"100%",background:"rgb(247, 247, 247)",boxSizing:"border-box",overflowX:"hidden",position:"relative",paddingBottom:0,[e.breakpoints.down("sm")]:{paddingBottom:e.spacing(6)}},overlay:{alignItems:"centre",background:"#fff",display:"flex",height:"100%",justifyContent:"centre",opacity:"0.6",width:"100%",position:"absolute",top:0,left:0,zIndex:20},higherzIndex:{zIndex:21},message:{cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",justifyContent:"center",width:"100%",[e.breakpoints.down("sm")]:{flexDirection:"column",gap:"16px",textAlign:"center"}},bottomBar:{position:"absolute",width:"100%",bottom:0,left:0,background:"white",boxSizing:"border-box",height:60,display:"flex",alignItems:"center"},pageTitleContainer:{position:"sticky",top:0,zIndex:100,background:"#fff",boxShadow:"0 0 11px rgb(230 230 230)",height:60,display:"flex",alignItems:"center",justifyContent:"space-between",padding:e.spacing(0,2.7),boxSizing:"border-box"},innerContainer:{paddingLeft:0,paddingRight:0,paddingTop:10,width:"100%",boxSizing:"border-box",[e.breakpoints.down("sm")]:{paddingLeft:16,paddingRight:16,paddingTop:8},[e.breakpoints.down("xs")]:{paddingLeft:12,paddingRight:12,paddingTop:6}},flexBetween:{display:"flex",justifyContent:"space-between",width:"100%",alignItems:"center",[e.breakpoints.down("sm")]:{flexDirection:"column",alignItems:"flex-start",ga
1p:"16px"},[e.breakpoints.down("xs")]:{gap:"12px"}},menu:{marginTop:44,marginLeft:6,[e.breakpoints.down("sm")]:{marginTop:8,marginLeft:0}},cardContainer:{flexWrap:"nowrap",gap:"8px",width:"100%",display:"flex",[e.breakpoints.down("sm")]:{flexDirection:"column",gap:"16px"},[e.breakpoints.down("xs")]:{gap:"12px"}},textFieldRoot:{background:"#f0f0f0",borderRadius:6,height:40,'& .MuiInputBase-root, & [class*="MuiInputBase-root-"]':{height:40}},toolbarRow:{display:"flex",alignItems:"center",justifyContent:"flex-start",marginTop:32,width:"100%",[e.breakpoints.down("sm")]:{flexDirection:"column",alignItems:"stretch",gap:"16px",marginTop:24},[e.breakpoints.down("xs")]:{gap:"12px",marginTop:20}},searchContainer:{flex:1,marginRight:24,maxWidth:"400px",[e.breakpoints.down("sm")]:{marginLeft:0,marginRight:0,order:2}},toolbarButton:{marginLeft:16,height:40,minWidth:120,color:"white",[e.breakpoints.down("sm")]:{marginLeft:0,marginTop:0,flex:1,width:"100%",minWidth:"auto"},[e.breakpoints.down("xs")]:{height:44,fontSize:"12px",paddingTop:"4px",paddingBottom:"4px"}},toolbarButtonsContainer:{display:"flex",[e.breakpoints.down("sm")]:{flexDirection:"row",justifyContent:"space-between",width:"100%",order:3,gap:0},[e.breakpoints.down("xs")]:{gap:"98px"}},tableContainer:{paddingLeft:0,paddingRight:0,marginTop:20,marginBottom:20,width:"100%",[e.breakpoints.down("sm")]:{marginTop:16,marginBottom:16}},description:{color:"#48465D",fontWeight:400,fontSize:16,lineHeight:"140%",letterSpacing:"0.15px",marginTop:8,[e.breakpoints.down("sm")]:{fontSize:14,lineHeight:"130%"}},tabsStyle:{marginTop:12,[e.breakpoints.down("sm")]:{order:1,width:"100%"}},mainToolbar:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,width:"100%",marginBottom:24,[e.breakpoints.down("md")]:{flexDirection:"column",alignItems:"stretch",gap:16},[e.breakpoints.down("sm")]:{gap:12,marginBottom:20}},toolbarLeft:{display:"flex",alignItems:"center",gap:16,[e.breakpoints.down("md")]:{width:"100%",justifyContent:"flex-start"}},toolbarCenter:{flex:"1 1 auto",minWidth:300,maxWidth:600,[e.breakpoints.down("md")]:{width:"100%",maxWidth:"100%"}},toolbarRight:{display:"flex",alignItems:"center",gap:16,flexWrap:"wrap",[e.breakpoints.down("md")]:{width:"100%",flexDirection:"column",gap:12}},toolbarSearchBox:{minWidth:"200px",maxWidth:"400px",flex:"1 1 auto",[e.breakpoints.down("md")]:{width:"100%",maxWidth:"100%"}},paginationContainer:{display:"flex",justifyContent:"center",backgroundColor:"white",marginTop:24,position:"sticky",bottom:0,padding:"0",border:"1px solid #F4F3F6",overflow:"hidden",[e.breakpoints.down("sm")]:{marginTop:16}},tablePagination:{'& .MuiTablePagination-toolbar, & [class*="MuiTablePagination-toolbar-"]':{paddingLeft:24,paddingRight:24,minHeight:64,[e.breakpoints.down("sm")]:{paddingLeft:12,paddingRight:12}},'& .MuiTablePagination-selectLabel, & [class*="MuiTablePagination-selectLabel-"]':{fontSize:14,color:"#6B7280",fontWeight:500},'& .MuiTablePagination-displayedRows, & [class*="MuiTablePagination-displayedRows-"]':{fontSize:14,color:"#6B7280",fontWeight:500},'& .MuiTablePagination-select, & [class*="MuiTablePagination-select-"]':{fontSize:14,color:"#374151",fontWeight:500},'& .MuiTablePagination-actions, & [class*="MuiTablePagination-actions-"]':{'& .MuiIconButton-root, & [class*="MuiIconButton-root-"]':{color:"#6B7280","&:hover":{backgroundColor:"#F3F4F6"},"&.Mui-disabled":{color:"#D1D5DB"}}}},loadingContainer:{display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"#ffffff",minHeight:500,borderRadius:12,padding:20,[e.breakpoints.down("sm")]:{minHeight:300,padding:16}},errorContainer:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",minHeight:500,backgroundColor:"#ffffff",borderRadius:12,padding:20,[e.breakpoints.down("sm")]:{minHeight:300,padding:16}},createAudienceButton:{[e.breakpoints.down("sm")]:{width:"100%",marginTop:8}},titleSection:{[e.breakpoints.down("sm")]:{width:"100%"}},titleDescription:{[e.breakpoints.down("sm")]:{marginBottom:16}},fullWidth:{width:"100%",background:"white"}})))((e=>{let{classes:t}=e;const a=(0,o.useTheme)(),s=(0,o.useMediaQuery)(a.breakpoints.down("sm")),r=(0,i.useDispatch)(),l=(0,i.useSelector)((e=>e.assistantDetails.data)),c=(0,i.useSelector)((e=>e.login.user)),p=(0,W.W6)(),{audiences:u,loading:m,error:g,totalPages:b,totalAudiences:y,totalReach:x,activeCampaigns:f,currentPage:A,searchString:I,currentType:C,createLoading:_,createError:S,deleteLoading:v,deleteError:E,syncLoading:T,syncError:D}=(0,i.useSelector)((e=>
1e.audience)),[w,N]=(0,n.useState)(null),[j,k]=(0,n.useState)(0),[L,R]=(0,n.useState)(!1),[B,P]=(0,n.useState)(l?.assistantId||null),[U,G]=(0,n.useState)({show:!1,severity:"success",msg:""}),[H,V]=(0,n.useState)(!1),[Y,Z]=(0,n.useState)("custom"),[K,J]=(0,n.useState)(!1),[q,X]=(0,n.useState)(null),[Q,ee]=(0,n.useState)(10),[te,ae]=(0,n.useState)(!1),[ne,se]=(0,n.useState)(null),[oe,ie]=(0,n.useState)(!1),[re,le]=(0,n.useState)(null),[de,ce]=(0,n.useState)({}),[pe,ue]=(0,n.useState)(!1),[me,he]=(0,n.useState)([]),[ge,be]=(0,n.useState)(null),ye=l?.assistantId,[xe,fe]=(0,n.useState)(localStorage.getItem(`${ye}aisensySelectedTabForAudiences`)||"aisensy_audiences"),[Ae,Ie]=(0,n.useState)(JSON.parse(localStorage.getItem(`${ye}aisensySelectedAdAccountForFetchedAudiences`)||"null")||null),Ce=T,_e=(0,n.useRef)(null),Se=(0,n.useCallback)((async e=>{if(e)try{const{isValid:t,pageId:a,adAccountId:n}=await r((0,M.cg)(e));r((0,$.nt)({fbConnected:t,selectedMetaPageId:t?a:"",selectedMetaAdAccountId:t?n:""})),t&&await Ee(e)}catch(e){console.log("Error fetching meta ad account:",e)}}),[r]),ve=(0,n.useCallback)(((e,t)=>{const{freezedMetaPageId:a,freezedMetaAdAccountId:n}=l||{};return e&&0!==e.length?e.map((e=>{const{metaBusinessId:s,isAssigned:o,pageId:i,accountId:r}=e||{};let l=!1;i&&""!==t?l=i===(t=t||a):r&&""!==t&&(l=r===(t=t||n));let d="Limited";return o?d="Assigned":s||(d="Personal"),{...e,tag:d,freezed:l}})):[]}),[l]),Ee=(0,n.useCallback)((async e=>{if(e)try{ue(!0);const t={data:await r((0,M.ae)(e))},{selectedMetaAdAccountId:a,freezedMetaAdAccountId:n,fbConnectedBy:s}=l||{},{id:o}=c||{},i=ve(t.data);if(he(i),ce({}),s&&s!==o&&n){const e=t.data?.find((e=>{let{isChildBMAdAccount:t}=e;return t}));ce(e||{})}else if(a){const e=t.data?.find((e=>{let{accountId:t}=e;return t===a}));ce(e||{})}if(Ae?.accountId){const e=t.data?.find((e=>{let{accountId:t}=e;return t===Ae.accountId}));e&&Ie(e)}}catch(e){console.log("Error fetching ad accounts:",e)}finally{ue(!1)}}),[l,c,ve]),Te=async function(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"ALL",o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:10,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"aisensy";if(l?.fbConnected){if("fetched"===i){if(e=Ae?.accountId,!e)return}else if(e=de?.accountId||l?.selectedMetaAdAccountId,!e)return;m||(r((0,z.dS)(i)),r((0,z._L)({assistantId:B,adAccountId:e,page:t,searchTerm:a,status:n,type:s,limit:o,source:i})))}};(0,n.useEffect)((()=>{l?.assistantId&&l?.fbConnected&&(P(l.assistantId),de?.accountId||Se(l.assistantId))}),[l?.assistantId,l?.fbConnected,de?.accountId]),(0,n.useEffect)((()=>{if(l?.assistantId&&l?.fbConnected&&!m)if("aisensy_audiences"===xe){const e=de?.accountId||l?.selectedMetaAdAccountId;if(e){const t=`aisensy_${e}_${C}_${I}`;_e.current!==t&&(_e.current=t,Te(1,I,"",C,10,"aisensy"))}}else if("fetched_audiences"===xe)if(Ae?.accountId){const e=`fetched_${Ae.accountId}_${C}_${I}`;_e.current!==e&&(_e.current=e,Te(1,I,"",C,10,"fetched"))}else _e.current=null}),[l?.assistantId,l?.fbConnected,de?.accountId,l?.selectedMetaAdAccountId,Ae?.accountId,xe,I,C,m]),(0,n.useEffect)((()=>{g&&(G({show:!0,severity:"error",msg:g}),r((0,z.ET)()))}),[g,r]),(0,n.useEffect)((()=>{S&&(G({show:!0,severity:"error",msg:S}),r((0,z.ET)()))}),[S,r]),(0,n.useEffect)((()=>{E&&(G({show:!0,severity:"error",msg:E}),r((0,z.ET)()))}),[E,r]),(0,n.useEffect)((()=>{D&&(G({show:!0,severity:"error",msg:D}),r((0,z.ET)()))}),[D,r]);const De=()=>{G({show:!1,severity:"success",msg:""})},we=(0,n.useMemo)((()=>F()((e=>{if(m)return;const t="aisensy_audiences"===xe?"aisensy":"fetched";if("fetched"===t&&!Ae?.accountId)return;const a=0===j?"ALL":1===j?"WEBSITE":2===j?"CUSTOM":"LOOKALIKE";e.trim()?Te(1,e,"",a,10,t):Te(1,"","",a,10,t)}),500)),[xe,j,m,Te,Ae?.accountId]);(0,n.useEffect)((()=>()=>{we.cancel()}),[we]);const Ne=()=>{N(null)},je=e=>{if(!e?._id)return void G({show:!0,severity:"error",msg:"Invalid audience data provided"});de?.accountId||l?.selectedMetaAdAccountId?(le(e),ie(!0)):G({show:!0,severity:"error",msg:"No ad account selected. Please set up your Meta Ad account first."})};return(0,h.jsxs)("div",{className:`${t.root} ginger-page-root`,children:[!l?.fbConnected&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("div",{className:t.overlay}),(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",justifyContent:"center",className:t.higherzIndex,style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"100%",padding:s?"16px":"0"},children:(0,h.jsx)("div",{onClick:()=>p.push(Xe(l?.assistantId)+"/setup"),style:{cursor:"pointer"},children:(0,h.jsxs)(o.Typography,{variant:s?"h5":"h4",color:"primary",align:"center",className:t.message,children:["Connect and Setup Meta Ad Account to continue!",(0,h.jsx)(o.IconButton,{children:(0,h.jsx)(d.ArrowForward,{})})]})})})]}),(0,h.jsx)(ta,{classes:t,accountValue:de,anchorEl:w,assistantDetails:l,handleCreateAdsNavigation:function(){p.push({pathname:`${Xe(l?.assistantId)}/create`,state:{...ge?{selectedAudience:ge}:{}}})},handleMenuClose:Ne,handleMenuOpen:e=>{N(e.currentTarget)},handleOptionClick:e=>{"Custom Audience"===e?(Z("custom"),V(!0)):"Lookalike Audience"===e?(Z("lookalike"),V(!0)):U(`Selected: ${e}`),Ne()},isMobile:s,parentTab:xe,selectedFetchedAdAccount:Ae}),(0,h.jsx)(aa,{audienceMenuItems:na,storeSearchString:I,audiences:u,currentType:C,loading:m,classes:t,accountValue:de,agent:c,assistantDetails:l,debouncedSearch:we,dispatch:r,fbaccount:me,handleAudienceDelete:je,handleAudienceSelection:(e,t)=>{be(null!==t?e:null)},handleParentTabChange:(e,t)=>
1{if(localStorage.setItem(`${ye}aisensySelectedTabForAudiences`,t),fe(t),k(0),r((0,z.w5)("ALL")),r((0,z.dS)("aisensy_audiences"===t?"aisensy":"fetched")),"fetched_audiences"===t)return r((0,z.VU)()),void(_e.current=null);_e.current=null,Te(1,I,"","ALL",10,"aisensy")},handleSearchChange:e=>{const t=e.target.value;r((0,z.GF)(t)),we(t)},handleTabChange:(e,t)=>{k(t);const a=0===t?"ALL":1===t?"WEBSITE":2===t?"CUSTOM":"LOOKALIKE";r((0,z.w5)(a));Te(1,I,"",a,10,"aisensy_audiences"===xe?"aisensy":"fetched")},handleTableMenuAction:(e,t,a)=>{switch(console.log("Table menu action:",e,t,a),e){case"create-campaign":if(!l?.assistantId)return void G({show:!0,severity:"error",msg:"Assistant ID not found. Please refresh the page."});if(!l?.isWhatsappVerified)return void G({show:!0,severity:"error",msg:"WhatsApp verification required to create broadcasts."});if(a?._id){const e=`/projects/${l.assistantId}/campaigns/create/broadcast`;p.push({pathname:e,state:{selectedAudience:a,audienceType:"audience-based",allFilter:{audienceId:a._id,audienceName:a.name||a.audienceName,audienceType:a.type||"CUSTOM",filters:Array.isArray(a.filters)?a.filters:[],dateFilters:a.dateFilters||{},optedIn:a.optedIn||"yes",blocked:a.blocked||"no",readStatus:a.readStatus||"all",totalReach:a.totalReach||0}}})}else console.error("No audience ID found in item:",t),G({show:!0,severity:"error",msg:"Could not identify audience for broadcast"});break;case"create-custom":V(!0),Z("custom");break;case"create-lookalike":V(!0),Z("lookalike");break;case"view-details":se(a),ae(!0);break;case"edit":U("Edit clicked");break;case"duplicate":U("Duplicate clicked");break;case"add-contacts":a?._id?(X(a),J(!0)):G({show:!0,severity:"error",msg:"Could not identify audience to upload contacts"});break;case"delete":a?._id?je(a):(console.error("No audience ID found in item:",t),G({show:!0,severity:"error",msg:"Could not identify audience to delete"}));break;default:console.log("Unknown action:",e)}},isLoading:pe,isSyncing:Ce,parentTab:xe,selectFetchedAdAccount:e=>{const t=JSON.stringify(e);localStorage.setItem(`${ye}aisensySelectedAdAccountForFetchedAudiences`,t),Ie(e)},selectedAudience:ge,selectedFetchedAdAccount:Ae,setAudienceType:Z,setCreateAudienceOpen:V,syncAudiences:async()=>{const{fbConnected:e,assistantId:t}=l||{};let a;if(a="aisensy_audiences"===xe?de?.accountId||l?.selectedMetaAdAccountId:Ae?.accountId,e&&a&&t)try{const e=await r((0,z.zJ)({assistantId:t,adAccountId:a}));G({show:!0,severity:"success",msg:e?.message||e?.data?.message||"Audiences synced successfully"});Te(1,I,"",C,10,"aisensy_audiences"===xe?"aisensy":"fetched")}catch(e){console.error("Error syncing audiences:",e);const t=e?.response||e,{action:a,message:n,assistant:s}=t?.data||{};if("reconnect"===a&&s){const{fbConnected:e,fbUserId:t,fbGrantedScopes:a,selectedMetaPageId:o,selectedMetaAdAccountId:i,freezedMetaAdAccountId:l,freezedMetaPageId:d}=s||{};r((0,$.nt)({fbConnected:e,fbUserId:t,fbGrantedScopes:a,selectedMetaPageId:o,selectedMetaAdAccountId:i,freezedMetaAdAccountId:l,freezedMetaPageId:d})),G({show:!0,severity:"error",msg:n||"Session expired, Please re-connect Facebook"})}else{G({show:!0,severity:"error",msg:D||t?.data?.message||e?.message||"Failed to sync audiences"})}}else G({show:!0,severity:"error",msg:"Please select an ad account to sync audiences."})},tabs:[{label:"All",value:0},{label:"Website",value:1},{label:"Custom",value:2},{label:"Lookalike",value:3}],value:j}),(0,h.jsx)(o.Box,{className:t.paginationContainer,children:(0,h.jsx)(o.TablePagination,{component:"div",count:y,page:A,onChangePage:(e,t)=>{const a=0===j?"ALL":1===j?"WEBSITE":2===j?"CUSTOM":"LOOKALIKE";r((0,z.Tm)(t));Te(t+1,I,"",a,Q,"aisensy_audiences"===xe?"aisensy":"fetched")},rowsPerPage:Q,onChangeRowsPerPage:e=>{const t=parseInt(e.target.value,10);ee(t);const a=0===j?"ALL":1===j?"WEBSITE":2===j?"CUSTOM":"LOOKALIKE";r((0,z.Tm)(0));Te(1,I,"",a,t,"aisensy_audiences"===xe?"aisensy":"fetched")},rowsPerPageOptions:[5,10,25,50],labelRowsPerPage:"Rows per page:",labelDisplayedRows:e=>{let{from:t,to:a,count:n}=e;return`${t}-${a} of ${-1!==n?n:`more than ${a}`}`},className:t.tablePagination})}),(0,h.jsx)(o.Snackbar,{open:U.show,anchorOrigin:{vertical:"top",horizontal:"center"},onClose:De,autoHideDuration:3e3,style:{[a.breakpoints.down("sm")]:{width:"90%",left:"5%",right:"5%"}},children:(0,h.jsx)(O.Alert,{severity:U.severity,onClose:De,children:U.msg})}),H&&(0,h.jsx)(Fe,{open:H,onClose:()=>{V(!1),Z("custom")},audienceType:Y,assistantDetails:l,onSuccess:e=>{G({show:!0,severity:"success",msg:e});const t=de?.accountId||l?.selectedMetaAdAccountId,a=0===j?"ALL":1===j?"WEBSITE":2===j?"CUSTOM":"LOOKALIKE",n="aisensy_audie
1nces"===xe?"aisensy":"fetched";r((0,z._L)({assistantId:l?.assistantId,adAccountId:t,page:1,searchTerm:I,status:"",type:a,source:n}))},onError:e=>{G({show:!0,severity:"error",msg:e})}}),(0,h.jsx)(We,{open:K,onClose:()=>{J(!1),X(null)},audience:q,assistantDetails:l,onSuccess:e=>{G({show:!0,severity:"success",msg:e})},onError:e=>{G({show:!0,severity:"error",msg:e})}}),(0,h.jsx)(qe,{open:te,onClose:()=>{ae(!1),se(null)},audienceData:ne,assistantId:l?.assistantId}),(0,h.jsx)(ze,{open:oe,onClose:()=>{ie(!1),le(null)},onConfirm:async()=>{if(!re?._id)return void G({show:!0,severity:"error",msg:"Invalid audience ID provided"});const e=de?.accountId||l?.selectedMetaAdAccountId;try{await r((0,z.WO)({audienceId:re._id,assistantId:B,adAccountId:e})),G({show:!0,severity:"success",msg:"Audience deleted successfully"}),ie(!1),le(null)}catch(e){console.error("Error deleting audience:",e),G({show:!0,severity:"error",msg:e||"Failed to delete audience"})}},taskMessage:"Delete Audience",finalQuestion:"Are you sure you want to delete this audience? This action cannot be undone.",body:re?(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"body2",style:{marginBottom:16,fontWeight:500},children:"You are about to delete the following audience:"}),(0,h.jsxs)(o.Box,{style:{backgroundColor:"#F8F9FA",padding:16,borderRadius:8,border:"1px solid #E9ECEF",marginBottom:16},children:[(0,h.jsx)(o.Typography,{variant:"h6",style:{fontWeight:600,marginBottom:8},children:re.title||"Unnamed Audience"}),(0,h.jsxs)(o.Typography,{variant:"body2",style:{marginBottom:4},children:[(0,h.jsx)("strong",{children:"Type:"})," ",re.source||"Custom Audience"]}),(0,h.jsxs)(o.Typography,{variant:"body2",style:{marginBottom:4},children:[(0,h.jsx)("strong",{children:"Size:"})," ",re.size?re.size.toLocaleString():"0"," ","people"]}),(0,h.jsxs)(o.Typography,{variant:"body2",style:{marginBottom:4},children:[(0,h.jsx)("strong",{children:"Status:"})," ",re.status||"Ready"]}),re.description&&(0,h.jsxs)(o.Typography,{variant:"body2",children:[(0,h.jsx)("strong",{children:"Description:"})," ",re.description]})]})]}):null,zIndex:3003})]})}));var oa=a(60427),ia=a(36896),ra=a(27606),la=a(54392),da=a(96746),ca=a(72572),pa=a(64054),ua=a(37098),ma=a(67264),ha=a(19371),ga=a(96232),ba=a(83182),ya=a(39870);const xa=[{value:10,label:"10 per page"},{value:25,label:"25 per page"},{value:50,label:"50 per page"},{value:100,label:"100 per page"}];const fa=(0,o.withStyles)((e=>({root:{color:e.palette.primary,marginLeft:e.spacing(1)}})))((function(e){const{classes:t,limit:a,setLimit:n,loadNext:i,loadPrev:r,total:l,page:c,isCountLoading:p,loadedContactsCount:u}=e,m=c*a+1,g=p?(c+1)*a:Math.min(l??0,(c+1)*a),b=p?u-c*a<a:g>=(l??0);return(0,h.jsxs)(s().Fragment,{children:[(0,h.jsx)(o.IconButton,{onClick:r,disabled:m<=1,children:(0,h.jsx)(d.NavigateBefore,{})}),(0,h.jsx)(o.Box,{mx:1,children:(0,h.jsxs)(o.Typography,{variant:"body1",style:{display:"flex",alignItems:"center",gap:4},children:[m,"-",g," of"," ",p?(0,h.jsx)(o.CircularProgress,{size:12,style:{verticalAlign:"middle"}}):l]})}),(0,h.jsx)(o.IconButton,{onClick:i,disabled:b,children:(0,h.jsx)(d.NavigateNext,{})}),(0,h.jsx)(o.Select,{labelId:"demo-simple-select-label",id:"demo-simple-select",value:a,onChange:n,style:{outline:"none"},className:t.root,disableUnderline:!0,children:xa.map((e=>(0,h.jsx)(o.MenuItem,{value:e.value,disableRipple:!0,children:e.label})))})]})}));var Aa=a(13118),Ia=a(3280),Ca=a(54107),_a=a(37419),Sa=a(91574);const va=e=>{const t=(0,j._E)()?.integrations?.[e];return"function"==typeof t||Boolean(t&&t.$$typeof)};a(24684),a(10145);var Ea=a(85072),Ta=a.n(Ea),Da=a(97825),wa=a.n(Da),Na=a(77659),ja=a.n(Na),ka=a(55056),La=a.n(ka),Ra=a(10540),Ba=a.n(Ra),Oa=a(41113),Pa=a.n(Oa),Ma=a(49181),Ua={};Ua.styleTagTransform=Pa(),Ua.setAttributes=La(),Ua.insert=ja().bind(null,"head"),Ua.domAPI=wa(),Ua.insertStyleElement=Ba();Ta()(Ma.A,Ua);Ma.A&&Ma.A.locals&&Ma.A.locals;var Fa=a(13292);const Wa=(e,t,a,n)=>{if(!e||!t)return"Select date range";const s=t.diff(e,"days");let o="";if(0===s){const t=ve()().endOf("day"),a=ve()().subtract(1,"day").endOf("day");o=e.isSame(t,"day")?"today":e.isSame(a,"day")?"yesterday":"singleday"}else if(6===s)o="7days";else if(29===s)o="30days";else if(89===s)o="90days";else{const s=n?ve()(n):a?ve()(a):ve()().subtract(36,"months").startOf("day");o=e.isSameOrBefore(s,"day")&&t.isSameOrAfter(ve()().endOf("day"),"day")?"maximum":"custom"}return o},za=(0,o.makeStyles)((e=>({dateRangeButton:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",backgroundColor:"#f0f0f0",borderRadius:"8px",cursor:"pointer",minWidth:"280px"},dateRangeIcon:{fontSize:"18px",color:"#666"},dateRangeText:{flex:1,color:"#333",fontSize:"14px"},dateRangeArrow:{fontSize:"20px",color:"#666"},dateRangePopover:{padding:0,minWidth:"700px",borderRadius:"8px",maxHeight:"90vh",overflow:"hidden"},dateRangeSidebar:{borderRight:"1px solid #e0e0e0",padding:"16px",overflowY:"auto",backgroundColor:"#fafafa",scrollbarWidth:"thin","&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{backgroundColor:"#c1c1c1",borderRadius:"3px","&:hover":{backgroundColor:"#a8a8a8"}}},dateRangeRadioLabel:{marginLeft:0,marginRight:0,'& .MuiFormControl
1Label-label, & [class*="MuiFormControlLabel-label-"]':{fontSize:"14px",paddingLeft:"8px"}},dateRangeCalendarContainer:{flex:1,padding:"16px",paddingLeft:"24px",display:"flex",flexDirection:"column",backgroundColor:"#ffffff",alignItems:"flex-start",justifyContent:"flex-start","& .DateRangePicker":{width:"100%"},"& .DateRangePickerInput":{width:"100%",display:"flex",justifyContent:"flex-start",marginBottom:"8px"},"& .DateInput":{display:"none"},"& .DateRangePicker_picker":{left:"0 !important",top:"auto !important",position:"relative !important",marginTop:"8px"}},dateRangePickerWrapper:{width:"100%",maxWidth:"100%"},dateRangeSectionTitle:{fontWeight:"bold",marginBottom:"12px",fontSize:"14px",color:"#333"}}))),Ga=e=>{let{startDate:t,endDate:a,onDatesChange:s,onFocusChange:i,focusedInput:r,minDate:l,constraintStartDate:c,placeholder:p="Select date range",customStyles:u,maxDays:m}=e;const g=za(),b=u?{...g,...u}:g,[y,x]=(0,n.useState)(null),[f,A]=(0,n.useState)(Wa(t,a,l,c)),I=(0,n.useRef)(f);(0,n.useEffect)((()=>{I.current=f}),[f]),(0,n.useEffect)((()=>{if(!t&&!a)return void A("custom");const e=Wa(t,a,l,c);e!==f&&"Select date range"!==e&&A(e)}),[t,a,l,c]);const C=(0,n.useMemo)((()=>((e,t,a,n)=>{if(!e||!t)return"Select date range";const s=t.diff(e,"days");let o="";if(0===s){const t=ve()().endOf("day"),a=ve()().subtract(1,"day").endOf("day");o=e.isSame(t,"day")?"Today":e.isSame(a,"day")?"Yesterday":"Day wise"}else if(6===s)o="Last 7 days";else if(29===s)o="Last 30 days";else if(89===s)o="Last 90 days";else{const s=n?ve()(n):a?ve()(a):ve()().subtract(36,"months").startOf("day");o=e.isSameOrBefore(s,"day")&&t.isSameOrAfter(ve()().endOf("day"),"day")?"Maximum":"Custom range"}const i=e.format("DD MMM YYYY"),r=t.format("DD MMM YYYY");return 0===s?`${o}: ${i}`:`${o}: ${i} - ${r}`})(t,a,l,c)),[t,a,l,c]),_=(0,n.useCallback)((e=>{x(e.currentTarget),i&&i("startDate")}),[i]),S=(0,n.useCallback)((()=>{x(null),i&&i(null)}),[i]),v=(0,n.useCallback)((e=>{let{startDate:t,endDate:a}=e,n=t,o=a,i=!1;const d=I.current,p="startDate"===r;"singleday"===d&&t&&!a&&(o=t.clone().endOf("day"),n=t.clone().startOf("day"),i=!0),"singleday"===d&&t&&a&&(t.isSame(a,"day")?(n=t.clone().startOf("day"),o=t.clone().endOf("day"),i=!0):(n=t,o=a)),s&&s({startDate:n,endDate:o});let u=null;if(n&&o){const e=o.diff(n,"days"),t=ve()().endOf("day"),a=c?ve()(c):l?ve()(l):ve()().subtract(36,"months").startOf("day");if(n.isSameOrBefore(a,"day")&&o.isSameOrAfter(t,"day"))u="maximum";else if(0===e){const e=ve()().endOf("day"),t=ve()().subtract(1,"day").endOf("day");n.isSame(e,"day")?u="today":n.isSame(t,"day")?u="yesterday":"singleday"===d&&(u="singleday"),i&&setTimeout((()=>{S()}),100)}else u=6===e?"7days":29===e?"30days":89===e?"90days":"custom"}else n&&"singleday"===d&&(u="singleday");u&&u!==d&&A(u),n&&o&&!p&&setTimeout((()=>S()),150)}),[s,l,c,S,r]),E=(0,n.useCallback)((e=>{if(e===f&&"singleday"!==e&&"custom"!==e)return;const t=ve()().endOf("day");let a,n;switch(e){case"today":a=t.clone().startOf("day"),n=t.clone().endOf("day");break;case"yesterday":a=t.clone().subtract(1,"day").startOf("day"),n=t.clone().subtract(1,"day").endOf("day");break;case"7days":a=t.clone().subtract(6,"days").startOf("day"),n=t.clone().endOf("day");break;case"30days":a=t.clone().subtract(29,"days").startOf("day"),n=t.clone().endOf("day");break;case"90days":a=t.clone().subtract(89,"days").startOf("day"),n=t.clone().endOf("day");break;case"maximum":a=c?ve()(c).startOf("day"):l?ve()(l).startOf("day"):ve()().subtract(36,"months").startOf("day"),n=t.clone().endOf("day");break;case"singleday":return"singleday"!==f&&A("singleday"),void(i&&i("startDate"));case"custom":return"custom"!==f&&A("custom"),void(i&&i("startDate"));default:return}e!==f&&A(e),s&&s({startDate:a,endDate:n})}),[s,i,l,c,f]),T=c||t&&a?C:p;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.Box,{onClick:_,className:b.dateRangeButton,children:[(0,h.jsx)(d.CalendarToday,{className:b.dateRangeIcon}),(0,h.jsx)(o.Typography,{variant:"h3",className:b.dateRangeText,children:T}),(0,h.jsx)(d.ArrowDropDown,{className:b.dateRangeArrow})]}),(0,h.jsx)(o.Popover,{open:Boolean(y),anchorEl:y,onClose:S,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{className:b.dateRangePopover},children:(0,h.jsxs)(o.Box,{display:"flex",style:{minHeight:"400px"},children:[(0,h.jsxs)(o.Box,{className:b.dateRangeSidebar,children:[(0,h.jsx)(o.Typography,{variant:"body2",className:b.dateRangeSectionTitle,style:{marginBottom:"16
1px",fontWeight:"600"},children:"Recently used"}),(0,h.jsxs)(o.RadioGroup,{value:f,onChange:e=>{E(e.target.value),"custom"!==e.target.value&&"singleday"!==e.target.value&&S()},style:{margin:0},children:[(0,h.jsx)(o.FormControlLabel,{value:"today",control:(0,h.jsx)(o.Radio,{size:"small",color:"primary"}),label:"Today",className:b.dateRangeRadioLabel}),(0,h.jsx)(o.FormControlLabel,{value:"yesterday",control:(0,h.jsx)(o.Radio,{size:"small",color:"primary"}),label:"Yesterday",className:b.dateRangeRadioLabel}),(!m||m>=7)&&(0,h.jsx)(o.FormControlLabel,{value:"7days",control:(0,h.jsx)(o.Radio,{size:"small",color:"primary"}),label:"7 days",className:b.dateRangeRadioLabel}),(!m||m>=30)&&(0,h.jsx)(o.FormControlLabel,{value:"30days",control:(0,h.jsx)(o.Radio,{size:"small",color:"primary"}),label:"30 days",className:b.dateRangeRadioLabel}),(!m||m>=90)&&(0,h.jsx)(o.FormControlLabel,{value:"90days",control:(0,h.jsx)(o.Radio,{size:"small",color:"primary"}),label:"90 days",className:b.dateRangeRadioLabel}),!m&&(0,h.jsx)(o.FormControlLabel,{value:"maximum",control:(0,h.jsx)(o.Radio,{size:"small",color:"primary"}),label:"Maximum",className:b.dateRangeRadioLabel}),(0,h.jsx)(o.FormControlLabel,{value:"singleday",control:(0,h.jsx)(o.Radio,{size:"small",color:"primary"}),label:"Day wise",className:b.dateRangeRadioLabel}),(0,h.jsx)(o.FormControlLabel,{value:"custom",control:(0,h.jsx)(o.Radio,{size:"small",color:"primary"}),label:"Custom range",className:b.dateRangeRadioLabel})]})]}),(0,h.jsx)(o.Box,{className:b.dateRangeCalendarContainer,children:(0,h.jsx)(o.Box,{className:b.dateRangePickerWrapper,children:(0,h.jsx)(Fa.DateRangePicker,{startDatePlaceholderText:"Start date",endDatePlaceholderText:"End date",startDateId:"dateRangePickerStartDate",endDateId:"dateRangePickerEndDate",startDate:t,endDate:a,onDatesChange:v,focusedInput:r||"startDate",onFocusChange:e=>{i&&i(e),e&&"singleday"!==f&&"custom"!==f&&A("custom")},numberOfMonths:2,navPosition:"navPositionTop",hideKeyboardShortcutsPanel:!0,small:!0,readOnly:!0,displayFormat:"DD MMM YYYY",minDate:c?ve()(c):l?ve()(l):ve()().subtract(36,"months").startOf("day"),maximumDate:ve()().endOf("day"),minimumNights:0,isOutsideRange:e=>{const t=ve()().endOf("day"),a=c?ve()(c):l?ve()(l):ve()().subtract(36,"months").startOf("day");return e.isAfter(t)||e.isBefore(a)},customArrowIcon:null,screenReaderInputMessage:" "})})})]})})]})},Ha=["FULL_NAME","FIRST_NAME","LAST_NAME","PHONE_NUMBER","PHONE","EMAIL","STREET_ADDRESS","CITY","STATE","ZIP_CODE","COUNTRY"],Va=["FULL_NAME","FIRST_NAME","LAST_NAME","PHONE","PHONE_OTP","PHONE_NUMBER","EMAIL"],Ya=["full_name","first_name","last_name","phone","phone_number","phone_otp","email"],Za=e=>"ctwa"===e?.leadType,Ka=e=>e&&(e.name||e.userName||e.mappedParams?.FULL_NAME||[e.mappedParams?.FIRST_NAME,e.mappedParams?.LAST_NAME].filter(Boolean).join(" "))||"",Ja=e=>e&&(e.phoneNumber||e.userNumber)||"",$a=e=>{if(!e)return null;if(e._id)return String(e._id);if(e.id)return String(e.id);if(e.leadgenId)return String(e.leadgenId);return Ja(e)||null},qa=e=>{if(!e)return"";const t=String(e);if(/[*•Xx]/.test(t))return t;const a=t.replace(/\D/g,"");return a?12===a.length&&a.startsWith("91")?`+91 ${a.slice(2,7)} ${a.slice(7)}`:`+${a}`:t},Xa=e=>e?.lastSubmissionAt||e?.createdTime||e?.sentAt||e?.createdAt||e?.created_time,Qa=e=>!(Za(e)||!e?.campaignError&&Ja(e)),en=e=>Ha.includes(e?.mappedParameter)||Va.includes(e?.type),tn=e=>Ha.includes(e?.parameterKey)||Ya.includes((e?.key||"").toLowerCase()),an=e=>/^custom_\d+$/i.test(e||"")?"Custom question":(e||"").replace(/_/g," ").toUpperCase(),nn=e=>"string"==typeof e?e.trim():e,sn=e=>Array.isArray(e)?e.map(nn).join(", "):nn(e),on=e=>(e||"").toLowerCase().replace(/[^a-z0-9]+/g," ").trim(),rn=(e,t)=>{const a={contact:[],qualifying:[],additional:[]},n=t?.questionAnswers||[];if(e?.questions?.length){const t={},s={};n.forEach((e=>{const a=(e.key||"").toLowerCase();a&&(t[a]=e);const n=on(e.question);n&&!s[n]&&(s[n]=e)}));const o=new Set;e.questions.forEach((e=>{const n=t[(e.key||"").toLowerCase()]||s[on(e.label||e.question)];n&&o.add(n);const i=n?.answer,r={key:e.key,label:e.label||e.question||n?.question||e.key,value:sn(i),answered:null!=i&&""!==i,isConditional:!!e.parentId};en(e)||n&&tn(n)?r.answered&&a.contact.push(r):a.qualifying.push(r)}
1)),n.forEach((e=>{o.has(e)||a.additional.push({key:e.key,label:e.question||an(e.key),value:sn(e.answer)})}))}else n.length&&n.forEach((e=>{const t={key:e.key,label:e.question||an(e.key),value:sn(e.answer),answered:void 0!==e.answer&&null!==e.answer&&""!==e.answer,isConditional:!1};tn(e)?t.answered&&a.contact.push(t):a.qualifying.push(t)}));return!n.length&&(t?.fieldData||[]).length&&t.fieldData.forEach((t=>{const n=e?.questions?.find((e=>(e.key||"").toLowerCase()===(t.name||"").toLowerCase())),s=sn(((e,t)=>{if(!e?.options?.length)return t;const a=t=>{const a=e.options.find((e=>e.key===t||e.value===t));return a?a.value:t};return Array.isArray(t)?t.map(a):a(t)})(n,t.values||[])),o={key:t.name,label:n?.label||n?.question||an(t.name),value:s,answered:!!s,isConditional:!!n?.parentId};Ya.includes((t.name||"").toLowerCase())?o.answered&&a.contact.push(o):a.qualifying.push(o)})),a},ln=(0,_e.makeStyles)((e=>({tr:{cursor:"pointer",transition:"0.3s",background:"white","&:hover":{backgroundColor:"#EBF5F3"},"& > td":{padding:e.spacing(2),verticalAlign:"middle",height:50,boxSizing:"border-box",fontSize:14,color:e.palette.text.primary}},striped:{background:"rgb(245,245,245)"},selected:{background:"rgba(10,71,76,0.08)","&:hover":{backgroundColor:"rgba(10,71,76,0.08)"}},checkboxCell:{width:60,padding:"8px 16px !important"},name:{fontFamily:"Inter",fontSize:14,color:e.palette.text.primary,maxWidth:240,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},subtle:{fontSize:12,color:e.palette.text.secondary,marginTop:2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:220},phone:{fontSize:13,color:e.palette.text.primary,whiteSpace:"nowrap"},source:{fontSize:13,color:e.palette.text.primary},answers:{fontSize:13,color:e.palette.text.primary,maxWidth:260,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},syncing:{fontStyle:"italic",color:e.palette.text.hint},ctwaActivity:{color:e.palette.text.secondary},statusCell:{whiteSpace:"nowrap"},time:{fontSize:12,color:e.palette.text.secondary,whiteSpace:"nowrap"}}))),dn=[{key:"checkbox",label:"",width:48},{key:"leadSource",label:"Lead Source",width:130},{key:"name",label:"Name",width:220},{key:"phone",label:"Phone Number",width:150},{key:"lastAd",label:"Last Ad Name",width:220},{key:"interactions",label:"Interaction Count",width:150},{key:"created",label:"Created At",width:170}],cn=e=>{let{lead:t,selected:a,onSelect:n,onClick:s,index:o=0,selectable:i=!0,hideInteractions:r=!1,busy:l=!1}=e;const d=ln(),c=Za(t),p=o%2==0,u=Ka(t)||"(Unknown)",m=Ja(t),g=Xa(t),b=c?"CTWA":"FORM",y=t.adName||t.lastAdName||t.adId||t.lastAdId||"—",x=t.submissionCount||"—",f=[d.tr,p?d.striped:"",a?d.selected:""].filter(Boolean).join(" ");return(0,h.jsxs)("tr",{className:f,style:l?{opacity:.55,cursor:"progress"}:void 0,onClick:()=>s&&s(t),children:[i&&(0,h.jsx)("td",{className:d.checkboxCell,children:(0,h.jsx)(ha.A,{size:"small",color:"primary",checked:!!a,onClick:e=>e.stopPropagation(),onChange:e=>n&&n(t,e.target.checked)})}),(0,h.jsx)("td",{children:(0,h.jsx)("span",{className:d.source,children:b})}),(0,h.jsxs)("td",{children:[(0,h.jsx)(ia.A,{className:d.name,title:u,children:u}),!c&&t.email&&(0,h.jsx)(la.A,{className:d.subtle,children:t.email})]}),(0,h.jsx)("td",{children:(0,h.jsx)("span",{className:d.phone,children:m?qa(m):"—"})}),(0,h.jsx)("td",{children:(0,h.jsx)("span",{className:d.source,children:y})}),!r&&(0,h.jsx)("td",{children:(0,h.jsx)("span",{className:d.source,children:x})}),(0,h.jsx)("td",{children:(0,h.jsx)("span",{className:d.time,children:g?ve()(g).format("MMM DD, YYYY HH:mm"):"—"})})]})};var pn=a(42460),un=a(85264),mn=a(51059),hn=a(75437),gn=a(20053);const bn=(0,_e.makeStyles)((e=>({chip:{display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:4,fontSize:12,fontFamily:"Roboto",fontWeight:500,lineHeight:"16px",whiteSpace:"nowrap",marginLeft:6},error:{color:e.palette.error.main,backgroundColor:"rgba(244, 67, 54, 0.08)"},success:{color:e.palette.success.main,backgroundColor:"rgba(76, 175, 80, 0.10)"},info:{color:e.palette.text.secondary,backgroundColor:"rgba(0, 0, 0, 0.05)"},ctwa:{color:e.palette.info.main,backgroundColor:"rgba(144, 19, 254, 0.08)",fontSize:10,letterSpacing:.5}}))),yn=()=>{const e=bn();return(0,h.jsx)("span",{className:(0,gn.A)(e.chip,e.ctwa),children:"CTWA"})},xn=e=>{let{signals:t=[],max:a}=e;const n=bn(),s=a?t.slice(0,a):t;return(0,h.jsx)(h.Fragment,{children:s.map((e=>{const t=(0,h.jsx)("span",{className:(0,gn.A)(n.chip,n[e.severity]||n.info),children:e.label},e.key);return e.title?(0,h.jsx)(o.Tooltip,{title:e.title,children:t},e.key):t}))})},fn=(0,_e.makeStyles)((e=>({sectionTitle:{fontFamily:"Inter",fontSize:12,fontWeight:600,letterSpacing:.8,textTransform:"uppercase",color:e.palette.text.hint,marginBottom:e.spacing(1)},section:{marginBottom:e.spacing(3)}
1,contactGrid:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:e.spacing(1.5)},contactLabel:{fontSize:11,color:e.palette.text.secondary,marginBottom:2},contactValue:{fontSize:14,color:e.palette.text.primary,wordBreak:"break-word"},qaRow:{padding:e.spacing(1.25,0),borderBottom:"1px solid #F0F0F0","&:last-child":{borderBottom:"none"}},qaConditional:{marginLeft:e.spacing(2),paddingLeft:e.spacing(1.5),borderLeft:`2px solid ${e.palette.primary.light}`},question:{fontSize:12,color:e.palette.text.secondary,marginBottom:2},answer:{fontSize:14,fontWeight:500,color:e.palette.text.primary},notAnswered:{fontSize:13,fontStyle:"italic",color:e.palette.text.hint},collapseToggle:{display:"flex",alignItems:"center",cursor:"pointer",color:e.palette.text.secondary,fontSize:13,"&:hover":{color:e.palette.primary.main}},syncingState:{display:"flex",flexDirection:"column",alignItems:"center",padding:e.spacing(5,2),color:e.palette.text.secondary,textAlign:"center"}}))),An=e=>{let{form:t,lead:a}=e;const s=fn(),[i,r]=(0,n.useState)(!1);if((e=>!(!e?.leadgenId||(e?.questionAnswers||[]).length||(e?.fieldData||[]).length||Object.keys(e?.mappedParams||{}).length))(a))return(0,h.jsxs)(o.Box,{className:s.syncingState,children:[(0,h.jsx)(d.CloudDownloadOutlined,{style:{fontSize:36,marginBottom:8}}),(0,h.jsx)(o.Typography,{variant:"body1",children:"Details syncing from Meta…"}),(0,h.jsx)(o.Typography,{variant:"body2",style:{marginTop:4},children:"This lead was recovered recently. Its answers will appear once the sync completes."})]});const{contact:l,qualifying:c,additional:p}=rn(t,a);return(0,h.jsxs)(o.Box,{children:[l.length>0&&(0,h.jsxs)(o.Box,{className:s.section,children:[(0,h.jsx)(o.Typography,{className:s.sectionTitle,children:"Contact"}),(0,h.jsx)(o.Box,{className:s.contactGrid,children:l.map((e=>(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{className:s.contactLabel,children:e.label}),(0,h.jsx)(o.Typography,{className:s.contactValue,children:e.value})]},e.key)))})]}),c.length>0&&(0,h.jsxs)(o.Box,{className:s.section,children:[(0,h.jsx)(o.Typography,{className:s.sectionTitle,children:"Qualifying answers"}),c.map((e=>(0,h.jsxs)(o.Box,{className:(0,gn.A)(s.qaRow,e.isConditional&&s.qaConditional),children:[(0,h.jsx)(o.Typography,{className:s.question,children:e.label}),e.answered?(0,h.jsx)(o.Typography,{className:s.answer,children:e.value}):(0,h.jsx)(o.Typography,{className:s.notAnswered,children:"— not answered"})]},e.key)))]}),p.length>0&&(0,h.jsxs)(o.Box,{className:s.section,children:[(0,h.jsxs)(o.Box,{className:s.collapseToggle,onClick:()=>r((e=>!e)),children:[i?(0,h.jsx)(d.ExpandLess,{fontSize:"small"}):(0,h.jsx)(d.ExpandMore,{fontSize:"small"}),(0,h.jsxs)("span",{style:{marginLeft:4},children:["Additional fields (",p.length,")"]})]}),(0,h.jsx)(o.Collapse,{in:i,children:p.map((e=>(0,h.jsxs)(o.Box,{className:s.qaRow,children:[(0,h.jsx)(o.Typography,{className:s.question,children:e.label}),(0,h.jsx)(o.Typography,{className:s.answer,children:e.value})]},e.key)))})]})]})},In=(0,_e.makeStyles)((e=>({sectionTitle:{fontFamily:"Inter",fontSize:12,fontWeight:600,letterSpacing:.8,textTransform:"uppercase",color:e.palette.text.hint,marginBottom:e.spacing(1)},row:{display:"flex",justifyContent:"space-between",alignItems:"baseline",padding:e.spacing(1.25,0),borderBottom:"1px solid #F0F0F0","&:last-child":{borderBottom:"none"}},label:{fontSize:12,color:e.palette.text.secondary},value:{fontSize:14,fontWeight:500,color:e.palette.text.primary,textAlign:"right"},note:{marginTop:e.spacing(2),fontSize:12,color:e.palette.text.hint,fontStyle:"italic"}}))),Cn=e=>{let{lead:t}=e;const a=In();if(!t)return null;const n=[{label:"Started chat",value:t.sentAt?ve()(t.sentAt).format("MMM DD, YYYY HH:mm"):"-"},{label:"Messages",value:null!=t.messages?t.messages:"-"},{label:"Source ad",value:t.adName||t.adId||"-"}];return(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{className:a.sectionTitle,children:"Activity"}),n.map((e=>(0,h.jsxs)(o.Box,{className:a.row,children:[(0,h.jsx)(o.Typography,{className:a.label,children:e.label}),(0,h.jsx)(o.Typography,{className:a.value,children:e.value})]},e.label))),t.adUrl&&(0,h.jsxs)(o.Box,{className:a.row,children:[(0,h.jsx)(o.Typography,{className:a.label,children:"Ad link"}),(0,h.jsxs)(o.Link,{href:t.adUrl,target:"_blank",rel:"noopener noreferrer",className:a.value,children:[t.adUrl," ↗"]})]}),(0,h.jsx)(o.Typography,{className:a.note,children:"CTWA leads start a WhatsApp chat from an ad — they don't submit a form, so there are no question answers."})]})};var _n=a(5795);const Sn=e=>(0,_n.mO)(e),vn=e=>(0,_n.am)(e),En=(e,t,a,n,s,o,i)=>(0,_n.WW)(e,t,a,n,s,o,i),Tn=(0,_e.makeStyles)((e=>({navBar:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:e.spacing(1)},name:{fontFamily:"Inter",fontSize:20,fontWeight:600,color:e.palette.text.primary},contactLine:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:4,marginTop:4,color:e.palette.text.secondary,fontSize:13},sourceLine:{marginTop:e.spacing(1),fontSize:12,color:e.palette.text.secondary},chipsRow:{marginTop:e.spacing(1),marginLeft:-6},header:{paddingBottom:e.spacing(2),borderBottom:"1px solid #ECECEC",marginBottom:e.spacing(1)},tabs:{minHeight:36,marginBottom:e.spacing(2),borderBottom:"1px solid #ECECEC"},tab:{minHeight:36,minWidth:100,textTransform:"none",fontSize:13},copyIcon:{padding:2,marginLeft:2},loading:{display:"flex",justifyContent:"center",padding:e.spacing(5)},historyRow:{padding:e.spacing(1.5),border:"1px solid #ECECEC",borderRadius:6,marginBottom:e.spacing(1),cursor:"pointer",transition:"0.2s","&:hover":{backgroundColor:"#EBF5F3"}},historyActive:{borderColor:e.palette.primary.main,backgroundColor:"#EBF5F3"},historyTitle:{fontSize:13,fontWeight:600,color:e.palette.text.primary},historyMeta:{fontSize:12,color:e.palette.text.secondary,marginTop:2},emptyState:{padding:e.spacing(4),textAlign:"center",color:e.palette.text.secondary}}))),Dn=new Map,wn=e=>{let{lead:t,assistantId:a,index:s=0,total:o=0,onPrev:i,onNext:r}=e;const l=Tn(),d=Za(t),c=(e=>
1!!e&&!Za(e)&&!e.leadgenId)(t),[p,u]=(0,n.useState)(d?"activity":"responses"),[m,g]=(0,n.useState)(c||d?[]:[t]),[b,y]=(0,n.useState)(0),[x,f]=(0,n.useState)(c&&!d),[A,I]=(0,n.useState)(null),C=c?t?._id:t?.leadContactId;(0,n.useEffect)((()=>{let e=!1;if(!d&&C&&(c||"history"===p)&&(c?0===m.length:m.length<=1)&&a)return f(!0),((e,t,a)=>(0,_n.e7)(e,t,a))(C,a,{limit:50}).then((a=>{if(e)return;const n=a?.data||[];n.length&&(g(c?n:[t,...n.filter((e=>e.leadgenId!==t.leadgenId))]),y(0))})).catch((()=>{})).finally((()=>!e&&f(!1))),()=>{e=!0}}),[C,a,p]);const _=m[b]||null;(0,n.useEffect)((()=>{const e=_?.formId;if(d||!e||!a)return;if(Dn.has(e))return void I(Dn.get(e));let t=!1;return((e,t)=>(0,_n._Z)(e,t))(e,a).then((a=>{const n=a?.data||null;n&&Dn.set(e,n),t||I(n)})).catch((()=>!t&&I(null))),()=>{t=!0}}),[_?.formId,a,d]);const S=(0,n.useMemo)((()=>(e=>{const t=[];return e?Za(e)?(t.push({key:"in-inbox",label:`In inbox · ${e.messages||0} msg${1===e.messages?"":"s"}`,severity:"info"}),t):(e.campaignError&&t.push({key:"failed",label:"Failed",severity:"error",title:e.campaignError}),Ja(e)||t.push({key:"no-phone",label:"No phone",severity:"error"}),e.campaignSent&&!e.campaignError&&t.push({key:"sent",label:"Sent",severity:"success"}),(e.submissionCount||0)>1&&t.push({key:"repeat",label:`${e.submissionCount} submissions`,severity:"info"}),t):t})(t)),[t]);if(!t)return null;const v=Ka(t)||"(Unknown)",E=Ja(t),T=Xa(t),D=t.formName||t.lastLeadFormName||_?.formName,w=t.adName||t.lastAdName||t.adId||t.lastAdId,N=d?[{key:"activity",label:"Activity"}]:[{key:"responses",label:"Responses"},{key:"history",label:"History",disabled:!(!d&&!!C)}];return(0,h.jsxs)(ia.A,{children:[(0,h.jsxs)(ia.A,{className:l.navBar,children:[(0,h.jsx)(pn.A,{size:"small",onClick:i,disabled:s<=0,children:(0,h.jsx)(un.A,{})}),(0,h.jsxs)(la.A,{variant:"body2",color:"textSecondary",children:[s+1," of ",o]}),(0,h.jsx)(pn.A,{size:"small",onClick:r,disabled:s>=o-1,children:(0,h.jsx)(mn.A,{})})]}),(0,h.jsxs)(ia.A,{className:l.header,children:[(0,h.jsxs)(ia.A,{display:"flex",alignItems:"center",children:[(0,h.jsx)(la.A,{className:l.name,children:v}),d&&(0,h.jsx)(yn,{})]}),(0,h.jsxs)(ia.A,{className:l.contactLine,children:[E?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("span",{children:["📞 ",qa(E)]}),(0,h.jsx)(ga.Ay,{title:"Copy phone",children:(0,h.jsx)(pn.A,{className:l.copyIcon,size:"small",onClick:()=>{return e=qa(E),void(navigator?.clipboard?.writeText&&navigator.clipboard.writeText(e));var e},children:(0,h.jsx)(hn.A,{style:{fontSize:14}})})})]}):(0,h.jsx)("span",{children:"📞 No phone captured"}),(t.email||_?.email)&&(0,h.jsxs)("span",{style:{marginLeft:8},children:["✉ ",t.email||_?.email]})]}),(0,h.jsxs)(la.A,{className:l.sourceLine,children:[d?`Ad: ${w||"-"}`:`${D||"Form"} · Ad: ${w||"-"}`,T?` · ${ve()(T).format("MMM DD, HH:mm")}`:""]}),(0,h.jsx)(ia.A,{className:l.chipsRow,children:(0,h.jsx)(xn,{signals:S})})]}),(0,h.jsx)(ua.A,{value:p,onChange:(e,t)=>
1u(t),indicatorColor:"primary",textColor:"primary",className:l.tabs,children:N.map((e=>(0,h.jsx)(ma.A,{value:e.key,label:e.label,disabled:e.disabled,className:l.tab},e.key)))}),d?(0,h.jsx)(Cn,{lead:t}):x&&!_?(0,h.jsx)(ia.A,{className:l.loading,children:(0,h.jsx)(ba.A,{size:28})}):"responses"===p?_?(0,h.jsx)(An,{form:A,lead:_}):(0,h.jsxs)(ia.A,{className:l.emptyState,children:[(0,h.jsx)(la.A,{variant:"body1",children:"No submission data found"}),(0,h.jsx)(la.A,{variant:"body2",style:{marginTop:4},children:"This contact has no stored form submissions."})]}):(0,h.jsx)(ia.A,{children:x?(0,h.jsx)(ia.A,{className:l.loading,children:(0,h.jsx)(ba.A,{size:28})}):m.length?m.map(((e,t)=>(0,h.jsxs)(ia.A,{className:`${l.historyRow} ${t===b?l.historyActive:""}`,onClick:()=>{y(t),u("responses")},children:[(0,h.jsx)(la.A,{className:l.historyTitle,children:e.formName||"Form submission"}),(0,h.jsxs)(la.A,{className:l.historyMeta,children:[e.createdTime?ve()(e.createdTime).format("MMM DD, YYYY HH:mm"):"-",e.adName?` · Ad: ${e.adName}`:"",e.campaignError?" · ⚠ Message failed":e.campaignSent?" · ✓ Message sent":""]})]},e.leadgenId||e._id||t))):(0,h.jsx)(ia.A,{className:l.emptyState,children:(0,h.jsx)(la.A,{variant:"body1",children:"No submission history"})})})]})};function Nn(e){const t=(0,j._E)()?.integrations?.LeadChatDialog;return t?(0,h.jsx)(t,{...e}):null}var jn=a(98448),kn=a(84630),Ln=a(77430),Rn=a(77920);const Bn=e=>(0,h.jsx)(Rn.A,{...e}),On=(0,_e.makeStyles)((e=>({controlsItem:{padding:0,cursor:"default",backgroundColor:"transparent !important","&:hover":{backgroundColor:"transparent"},"&.Mui-selected":{backgroundColor:"transparent"},"&.Mui-focusVisible":{backgroundColor:"transparent"}},controlsBox:{width:"100%",padding:e.spacing(1,1.5),boxSizing:"border-box"},searchField:{width:"100%",background:"rgb(240,240,240)",borderRadius:8,paddingLeft:e.spacing(1)},searchInput:{fontSize:13,padding:"7px 8px 7px 4px"},clearAll:{marginTop:e.spacing(.75),fontSize:13,fontWeight:600,color:e.palette.error.main,cursor:"pointer",display:"inline-block"},option:{minHeight:34,paddingTop:2,paddingBottom:2,paddingLeft:e.spacing(1)},optionCheckbox:{padding:6},optionLabel:{fontSize:13,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:220},noOptions:{padding:e.spacing(1,2),fontSize:13,color:e.palette.text.secondary,cursor:"default"}}))),Pn=e=>{let{label:t,allLabel:a,value:s=[],onChange:o,options:i=[],pageSize:r=25,className:l,iconClassName:d}=e;
1const c=On(),[p,u]=(0,n.useState)(r),[m,g]=(0,n.useState)(""),b=Array.isArray(s)?s:s?[s]:[],y=(0,n.useMemo)((()=>{const e=m.trim().toLowerCase();return e?i.filter((t=>String(t.label||"").toLowerCase().includes(e))):i}),[i,m]);return(0,h.jsxs)(jn.A,{multiple:!0,displayEmpty:!0,disableUnderline:!0,className:l,classes:{icon:d},value:b,onChange:e=>o(e.target.value),onClose:()=>{u(r),g("")},renderValue:e=>e&&0!==e.length?1===e.length?`${t}: ${i.find((t=>t.value===e[0]))?.label||e[0]}`:`${t}: ${e.length} selected`:`${t}: ${a}`,IconComponent:Bn,MenuProps:{getContentAnchorEl:null,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},style:{marginTop:5},PaperProps:{style:{maxHeight:320,width:320},onScroll:e=>{const t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<48&&u((e=>Math.min(e+r,y.length)))}}},children:[(0,h.jsx)(kn.A,{value:"__filter_select_controls__",disableRipple:!0,disableTouchRipple:!0,className:c.controlsItem,children:(0,h.jsxs)(ia.A,{className:c.controlsBox,onClick:e=>e.stopPropagation(),children:[(0,h.jsx)(ca.A,{autoFocus:!0,fullWidth:!0,placeholder:`Search ${(t||"options").toLowerCase()}...`,value:m,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),onChange:e=>{g(e.target.value),u(r)},InputProps:{disableUnderline:!0,className:c.searchField,classes:{input:c.searchInput},startAdornment:(0,h.jsx)(pa.A,{position:"start",style:{margin:0},children:(0,h.jsx)(Ia.A,{style:{fontSize:18,color:"#888"}})})}}),b.length>0&&(0,h.jsx)(la.A,{className:c.clearAll,onClick:e=>{e.stopPropagation(),o([])},children:"Clear all"})]})}),0===y.length&&(0,h.jsx)(kn.A,{value:"__filter_select_no_options__",disabled:!0,className:c.noOptions,children:"No matches"}),y.slice(0,p).map((e=>(0,h.jsxs)(kn.A,{value:e.value,title:e.label,className:c.option,children:[(0,h.jsx)(ha.A,{size:"small",color:"primary",className:c.optionCheckbox,checked:b.indexOf(e.value)>-1}),(0,h.jsx)(Ln.A,{primary:e.label,classes:{primary:c.optionLabel}})]},e.value)))]})};var Mn=a(98695),Un=a(87270);const Fn="#0a474c",Wn={groups:"groups",description:"description",ads_click:"ads_click",fact_check:"fact_check",check_circle:"check_circle"},zn=e=>{let{label:t,value:a,delta:n,icon:s,color:o,sub:i}=e;const r=null!=n&&n>=0;return(0,h.jsxs)(ia.A,{style:{flex:"1 1 0",minWidth:150,minHeight:92,padding:"14px 16px",background:"#fff",border:"1px solid rgba(0,0,0,0.08)",borderRadius:12,display:"flex",flexDirection:"column",justifyContent:"center",gap:4},children:[(0,h.jsxs)(ia.A,{style:{display:"flex",alignItems:"center",gap:6},children:[(0,h.jsx)(ia.A,{style:{width:24,height:24,borderRadius:6,display:"grid",placeItems:"center",background:(o||Fn)+"14"},children:(0,h.jsx)("span",{className:"material-icons",style:{fontSize:15,color:o||Fn},children:Wn[s]||s})}),(0,h.jsx)(la.A,{variant:"caption",style:{color:"#6E6E6E",fontWeight:600},children:t})]}),(0,h.jsxs)(ia.A,{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,h.jsx)(la.A,{style:{fontSize:"1.6rem",fontWeight:700,color:"#4A4A4A",lineHeight:1.1},children:a}),null!=n&&(0,h.jsxs)(ia.A,{style:{display:"inline-flex",alignItems:"center",color:r?"#357a38":"#aa2e25"},children:[r?(0,h.jsx)(Mn.A,{style:{fontSize:18}}):(0,h.jsx)(Un.A,{style:{fontSize:18}}),(0,h.jsxs)("span",{style:{fontSize:11.5,fontWeight:700},children:[Math.abs(n),"%"]})]})]}),i&&(0,h.jsx)(la.A,{variant:"caption",style:{color:"#B9B9B9"},children:i})]})},Gn=e=>{let{cards:t}=e;return(0,h.jsx)(ia.A,{style:{display:"flex",gap:16,flexWrap:"wrap",marginBottom:18},children:t.map((e=>(0,h.jsx)(zn,{...e},e.key)))})},Hn=e=>{let{metrics:t=[]}=e;return(0,h.jsx)(Gn,{cards:t})},Vn=e=>{let{forms:t=[],totalForms:a,activeForms:n,totalResponses:s=0}=e;const o=null!=a?a:t.length,i=null!=n?n:t.filter((e=>"ACTIVE"===e.status)).length,r=[{key:"f",label:"Total forms",value:o,icon:"fact_check",color:Fn},{key:"a",label:"Active forms",value:i,sub:o-i+" archived",icon:"check_circle",color:"#357a38"},{key:"s",label:"Total responses",value:Number(s).toLocaleString(),icon:"description",color:"#9013FE"}];return(0,h.jsx)(Gn,{cards:r})},Yn=new Map,Zn=(e,t)=>`${e}:${JSON.stringify(t||{})}`,Kn=e=>Yn.get(e),Jn=(e,t)=>{Yn.set(e,t)},$n=e=>{const t=`${e}:`;
1Array.from(Yn.keys()).forEach((e=>{e.startsWith(t)&&Yn.delete(e)}))},qn=(0,_e.makeStyles)((e=>({pageRoot:{height:"100%",width:"100%",background:"rgb(247, 247, 247)",boxSizing:"border-box",overflowX:"hidden",overflowY:"auto",scrollbarGutter:"stable",position:"relative",minHeight:"100vh"},pageTitleContainer:{position:"sticky",top:0,zIndex:100,background:"#fff",boxShadow:"0 0 11px rgb(230 230 230)",minHeight:60,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 24px",boxSizing:"border-box",width:"100%",[e.breakpoints.down("sm")]:{padding:"0 16px"}},previewTag:{marginLeft:12,fontSize:11,padding:"2px 8px",borderRadius:4,backgroundColor:"rgba(254, 192, 0, 0.18)",color:"#8a6d00",fontWeight:600,letterSpacing:.5},innerContainer:{padding:"24px 40px",width:"100%",boxSizing:"border-box",[e.breakpoints.down("md")]:{padding:"20px 24px"},[e.breakpoints.down("sm")]:{padding:"16px"}},alert:{marginBottom:16,borderRadius:8},statsContainer:{marginBottom:24,display:"flex",gap:20,flexWrap:"nowrap",width:"100%",[e.breakpoints.down("sm")]:{flexDirection:"column",gap:16}},statCard:{padding:"20px 24px",textAlign:"center",borderRadius:8,flex:1,boxShadow:"0 1px 3px rgba(0,0,0,0.08)",minHeight:80,display:"flex",flexDirection:"column",justifyContent:"center",background:"white"},headerBar:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"1em",flexWrap:"wrap",gap:8},searchField:{width:"35%",padding:"2px",background:"rgb(240,240,240)",[e.breakpoints.down("sm")]:{width:"100%"}},searchInputPadding:{padding:"12px 10px 12px 8px"},headerActions:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},pillSelect:{width:185,fontSize:"0.8125rem",color:"black",backgroundColor:"rgb(240,240,240)",borderRadius:8,padding:"4px 10px",[e.breakpoints.down("sm")]:{width:"auto",flex:1}},pillSelectIcon:{width:20,height:20,marginRight:6},datePillButton:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 10px",backgroundColor:"rgb(240,240,240)",borderRadius:8,cursor:"pointer",minWidth:0},datePillText:{flex:1,color:"black",fontSize:"0.8125rem",whiteSpace:"nowrap"},sourceTabs:{minHeight:40,marginBottom:12,'& .MuiTab-root, & [class*="MuiTab-root-"]':{textTransform:"none",fontSize:"14px",fontWeight:500,minHeight:40,minWidth:80}},sourceRow:{display:"flex",justifyContent:"space-between",alignItems:"flex-end"},tabs:{fontSize:"14px",textTransform:"none",borderBottom:"2px solid #f0f0f0",display:"flex"},count:{fontSize:13,color:e.palette.text.secondary,paddingBottom:12},listRoot:{border:"1px solid lightgrey",borderRadius:10,background:"white",overflow:"hidden",marginTop:"16px"},scrollContainer:{width:"100%",overflowX:"auto",overflowY:"hidden"},table:{width:"100%",minWidth:1100,borderCollapse:"collapse",borderSpacing:0},headRow:{"& th":{position:"sticky",top:0,zIndex:2,textAlign:"left",height:50,boxSizing:"border-box",color:e.palette.text.secondary,backgroundColor:"rgb(252,252,252)",padding:e.spacing(2),whiteSpace:"nowrap"}},loadingState:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:240},emptyState:{padding:"48px 24px",textAlign:"center",color:e.palette.text.secondary},footer:{position:"fixed",bottom:0,left:70,right:0,height:60,zIndex:100,background:"white",borderTop:"1px solid lightgrey",display:"flex",alignItems:"center",justifyContent:"center",[e.breakpoints.down("sm")]:{left:0}},connectMessage:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"60vh",padding:24,textAlign:"center"}}))),Xn=[{key:"all",label:"All Leads"},{key:"form",label:"Lead Form Submissions"},{key:"ctwa",label:"CTWA Leads"}],Qn=e=>e?ve()(e).format("YYYY-MM-DDTHH:mm:ss.SSS"):void 0,es=()=>{const e=qn(),t=(0,r.useHistory)(),a=(0,i.useDispatch)(),s=!1,o=(0,i.useSelector)((e=>e.assistantDetails.data)),l=(0,i.useSelector)((e=>e.ads?.pageDetails)),d=o?.assistantId,[c,p]=(0,n.useState)(null),[u,m]=(0,n.useState)({dailyTemplateLimit:null,consumedQuota:null});(0,n.useEffect)((()=>{if(!d)return;let e=!1;return(0,_n.QO)(d).then((t=>{!e&&t&&m({dailyTemplateLimit:t.dailyTemplateLimit,consumedQuota:t.consumedTemplateLimitQuota})}
1)).catch((()=>{})),()=>{e=!0}}),[d]);const g=(0,n.useCallback)((async()=>{if(!d)return;const e=Zn("meta-ad-setup-page",{assistantId:d}),t=Kn(e);t&&p(t);try{const{isValid:t,pageId:n}=await a((0,M.cg)(d));t&&n&&(Jn(e,n),p(n))}catch(e){console.error("Error fetching meta ad setup:",e)}}),[d]);(0,n.useEffect)((()=>{l?.pageId?p(l.pageId):o?.selectedMetaPageId?p(o.selectedMetaPageId):g()}),[s,l?.pageId,o?.selectedMetaPageId,g]);const[b,y]=(0,n.useState)("all"),[x,f]=(0,n.useState)(!1),[A,I]=(0,n.useState)(""),[C,_]=(0,n.useState)(""),[S,v]=(0,n.useState)([]),[E,T]=(0,n.useState)((()=>{const e=new URLSearchParams(window.location.search).get("adId");return e?[e]:[]})),[D,w]=(0,n.useState)({start:null,end:null}),[N,j]=(0,n.useState)(null),[k,L]=(0,n.useState)([]),[R,O]=(0,n.useState)(0),[P,U]=(0,n.useState)(0),[F,W]=(0,n.useState)(25),[z,G]=(0,n.useState)(!1),[H,V]=(0,n.useState)(null),[Y,Z]=(0,n.useState)([]),[K,J]=(0,n.useState)([]),[$,q]=(0,n.useState)(0),[X,Q]=(0,n.useState)(0),[ee,te]=(0,n.useState)(0),[ae,ne]=(0,n.useState)(null),[se,oe]=(0,n.useState)(-1),[ie,re]=(0,n.useState)(!1),[le,de]=(0,n.useState)(null),[ce,pe]=(0,n.useState)(!1),[ue,me]=(0,n.use
1State)([]),[he,ge]=(0,n.useState)([]),be=(0,n.useRef)(new Map),[ye,xe]=(0,n.useState)(!1),[fe,Ae]=(0,n.useState)(!1),[Ie,Ce]=(0,n.useState)(!1),[_e,Se]=(0,n.useState)(0),[ve,Ee]=(0,n.useState)(0),Te=(0,n.useMemo)((()=>Y.map((e=>({value:e.formId,label:e.name})))),[Y]),De=(0,n.useMemo)((()=>K.filter(((e,t,a)=>e.adId&&a.findIndex((t=>t.adId===e.adId))===t)).map((e=>({value:e.adId,label:e.adName||e.adId})))),[K]);(0,n.useEffect)((()=>{const e=setTimeout((()=>{_(A.trim()),U(0)}),500);return()=>clearTimeout(e)}),[A]);const we=(0,n.useCallback)((async()=>{if(!d||!c)return;const e=Zn("lead-forms-all",{assistantId:d,pageId:c}),t=Kn(e);t&&Z(t);try{const t=[],a=50;let n=1;for(let e=0;e<100;e+=1){const e=await En(d,c,void 0,void 0,n,a),s=e?.data||[];t.push(...s);const o=e?.pagination?.total??t.length;if(0===s.length||t.length>=o)break;n+=1}Jn(e,t),Z(t)}catch{}}),[d,c,s]),Ne=(0,n.useCallback)((async()=>{if(!d)return;const e=Zn("lead-gen-stats",{assistantId:d}),t=Kn(e);t&&(q(t.totalLeads||0),Q(t.formSubmissions||0),te(t.ctwaLeads||0));try{const t=await vn(d),a=t?.data||{};Jn(e,a),q(a.totalLeads||0),Q(a.formSubmissions||0),te(a.ctwaLeads||0)}catch{}}),[d,s]);(0,n.useEffect)((()=>{if(!d||!c)return;we(),Ne();const e=Zn("ads-list",{assistantId:d}),t=Kn(e);t&&J(t),a((0,oa.Tu)(d)).then((t=>{const a=t?.data||[];Jn(e,a),J(a)})).catch((()=>{}))}),[d,c,s]);const je=(0,n.useRef)(0),ke=(0,n.useCallback)((async()=>{if(!d)return;const e={assistantId:d,type:b,search:C||void 0,formId:S.length?S.join(","):void 0,adId:E.length?E.join(","):void 0,startDate:Qn(D.start),endDate:Qn(D.end),page:P+1,limit:F},t=Zn("lead-contacts",e),a=Kn(t);a?((a.leads||[]).forEach((e=>{const t=$a(e);t&&be.current.set(t,e)})),L(a.leads),O(a.total),G(!1)):G(!0),V(null);const n=++je.current;try{const s=await Sn(e);if(s?.status){const e={leads:s.data||[],total:s.pagination?.total||0};if(Jn(t,e),e.leads.forEach((e=>{const t=$a(e);t&&be.current.set(t,e)})),n!==je.current)return;L(e.leads),O(e.total)}else n!==je.current||a||V(s?.message||"Failed to fetch leads")}catch(e){n!==je.current||a||V(e?.response?.data?.message||"Failed to fetch leads")}finally{n===je.current&&G(!1)}}),[s,d,b,C,S,E,D,P,F]);(0,n.useEffect)((()=>{ke()}),[ke]),(0,n.useEffect)((()=>{if(!d)return;let e=!1;const t={assistantId:d,formId:S.length?S.join(","):void 0,adId:E.length?E.join(","):void 0,startDate:Qn(D.start),endDate:Qn(D.end)},a=Zn("lead-analytics",t),n=Kn(a);var s;return void 0!==n&&ne(n),(s=t,(0,_n.bk)(s)).then((t=>{const n=t?.data?.totals||null;Jn(a,n),e||ne(n)})).catch((()=>{e||void 0!==n||ne(null)})),()=>{e=!0}}),[s,d,S,E,D]);const Le=(0,n.useMemo)((()=>x?k.filter((e=>Qa(e))):k),[k,x]),Re=x?Le.length:R,Be=e=>{const t=Ja(e);return t&&t.startsWith("+")?t.slice(1):t},Oe=e=>{const t=$a(e);return!!t&&(ce?!he.includes(t):ue.includes(t))},Pe=async(e,t)=>{const n=Be(e);if(!n||window.innerWidth<=900)oe(t);else{de(e._id||e.leadgenId);try{const e=await a(function(e,t){let a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return()=>Xt("loadLeadConversation",(()=>null))(e,t,a)}(n,d,!0));null===e?oe(t):re(!0)}catch{oe(t)}finally{de(null)}}},Me=ce?Math.max(0,R-he.length):ue.length,Ue=Me>0,Fe=Le.length>0&&Le.every(Oe),We=!Fe&&Le.some(Oe),ze=()=>{pe(!1),me([]),ge([])},Ge=e=>{me([]),ge([]),pe(e)},He=()=>{We?ze():Ge(!Fe)},Ve=(e,t)=>{const a=$a(e);a&&(be.current.set(a,e),ce?ge((e=>t?e.filter((e=>e!==a)):e.includes(a)?e:[...e,a])):me((e=>t?e.includes(a)?e:[...e,a]:e.filter((e=>e!==a)))))},Ye=e=>e.map((e=>Be(be.current.get(e)))).filter(Boolean),Ke=ce?[]:Ye(ue),Je=ce?Ye(he):[];(0,n.useEffect)((()=>{pe(!1),me([]),ge([])}),[b,C,S,E,D]);const $e=(0,n.useMemo)((()=>k.filter((e=>Qa(e))).length),[k]),qe=(0,n.useMemo)((()=>{const e=[{key:"t",label:"Total leads",value:$.toLocaleString(),icon:"groups",color:"#0a474c"},{key:"f",label:"Form submissions",value:X.toLocaleString(),icon:"description",color:"#9013FE"},{key:"c",label:"CTWA leads",value:ee.toLocaleString(),icon:"ads_click",color:"#0098a6"}];return ae&&e.push({key:"n",label:"New contacts",value:(ae.newContacts||0).toLocaleString(),sub:`${(ae.returningContacts||0).toLocaleStr
1ing()} returning`,icon:"person_add",color:"#1769d4"},{key:"s",label:"Broadcast sent",value:(ae.broadcastSent||0).toLocaleString(),sub:`${(ae.broadcastFailed||0).toLocaleString()} failed`,icon:"send",color:"#b07b00"},{key:"a",label:"Needs attention",value:(ae.needsAttention||0).toLocaleString(),icon:"error_outline",color:"#aa2e25"}),e}),[$,X,ee,ae]),Qe=se>=0?Le[se]:null,et={all:"No leads found",form:"No form submissions found",ctwa:"No CTWA leads found"};return o&&!o.fbConnected?(0,h.jsx)("div",{className:`${e.pageRoot} ginger-page-root`,children:(0,h.jsx)(ia.A,{className:e.connectMessage,children:(0,h.jsx)(la.A,{variant:"h4",color:"primary",style:{cursor:"pointer"},onClick:()=>t.push(`${Xe(d)}/setup`),children:"Connect and Setup Meta Ad Account to view leads! →"})})}):(0,h.jsxs)("div",{className:e.pageRoot,children:[(0,h.jsxs)(ra.A,{container:!0,className:`${e.pageTitleContainer} ginger-page-header`,children:[(0,h.jsx)(ra.A,{item:!0,children:(0,h.jsxs)(ia.A,{display:"flex",alignItems:"center",children:[(0,h.jsx)(la.A,{variant:"h3",children:"Lead Gen"}),(0,h.jsx)("span",{className:e.previewTag,children:"NEW"})]})}),(0,h.jsx)(ia.A,{display:"flex",alignItems:"center",ml:"auto",pr:2,children:(0,h.jsx)(B,{name:"gingerLauncher"})})]}),(0,h.jsxs)(ia.A,{className:e.innerContainer,children:[H&&(0,h.jsx)(Aa.A,{severity:"error",className:e.alert,onClose:()=>V(null),children:H}),!x&&$e>0&&(0,h.jsxs)(Aa.A,{severity:"error",className:e.alert,action:(0,h.jsx)(da.A,{color:"inherit",size:"small",style:{textTransform:"none"},onClick:()=>f(!0),children:"View"}),children:[$e," lead",1===$e?"":"s"," on this page need attention (message failed or phone missing)"]}),(0,h.jsx)(Hn,{metrics:qe}),(0,h.jsxs)(ia.A,{className:e.headerBar,children:[(0,h.jsx)(ca.A,{classes:{root:e.searchField},variant:"outlined",size:"small",placeholder:"ctwa"===b?"Search by name or phone number":"Search by name, email, phone...",value:A,onChange:e=>I(e.target.value),InputProps:{classes:{input:e.searchInputPadding},startAdornment:(0,h.jsx)(pa.A,{position:"start",style:{margin:0},children:(0,h.jsx)(Ia.A,{})})}}),(0,h.jsxs)(ia.A,{className:e.headerActions,children:["ctwa"!==b&&(0,h.jsx)(Pn,{label:"Form",allLabel:"All Forms",value:S,onChange:e=>{v(e),U(0)},options:Te,className:e.pillSelect,iconClassName:e.pillSelectIcon}),(0,h.jsx)(Pn,{label:"Ad",allLabel:"All Ads",value:E,onChange:e=>{T(e),U(0)},options:De,className:e.pillSelect,iconClassName:e.pillSelectIcon}),(0,h.jsx)(Ga,{customStyles:{dateRangeButton:e.datePillButton,dateRangeText:e.datePillText},startDate:D.start,endDate:D.end,focusedInput:N,onDatesChange:e=>{let{startDate:t,endDate:a}=e;w({start:t,end:a}),U(0)},onFocusChange:j})]})]}),(0,h.jsxs)(ia.A,{className:e.sourceRow,children:[(0,h.jsx)(ua.A,{value:b,onChange:(e,t)=>
1(e=>{y(e),U(0),oe(-1),f(!1),v([]),T([]),I(""),_(""),G(!0)})(t),indicatorColor:"primary",textColor:"primary",className:e.sourceTabs,children:Xn.map((t=>(0,h.jsx)(ma.A,{value:t.key,label:t.label,className:e.tabs},t.key)))}),(0,h.jsxs)(ia.A,{display:"flex",alignItems:"center",style:{gap:12,marginBottom:12},children:[va("broadcastCampaign")&&(0,h.jsx)(ga.Ay,{title:0===Me?"Select at least one lead to broadcast":"",children:(0,h.jsx)("span",{children:(0,h.jsxs)(da.A,{variant:"contained",color:"primary",size:"small",startIcon:(0,h.jsx)(Sa.A,{style:{fontSize:16}}),disabled:0===Me,onClick:async()=>{if(0===Me)return;const e=async e=>{try{const t=await a((0,oa.az)({assistantId:d,userNumberArray:e}));return t?.optedoutLenght||0}catch(e){return 0}};!ce&&Ke.length>0?(Se(await e(Ke)),Ee(0)):ce&&Je.length>0?(Ee(await e(Je)),Se(0)):(Se(0),Ee(0)),Ce(!0)},style:{textTransform:"none"},children:["Broadcast",Me>0?` (${Me})`:""]})})}),(0,h.jsx)(ga.Ay,{title:0===k.length?"No leads to export":"",children:(0,h.jsx)("span",{children:(0,h.jsx)(da.A,{variant:"outlined",size:"small",startIcon:fe?(0,h.jsx)(ba.A,{size:14}):(0,h.jsx)(_a.A,{style:{fontSize:16}}),disabled:fe||0===k.length,onClick:async()=>{if(d&&!fe){Ae(!0);try{await(0,_n.ie)(d,{type:b,formId:S.length?S.join(","):void 0,adId:E.length?E.join(","):void 0,startDate:D.start,endDate:D.end,search:C,hasSelection:ce||ue.length>0,selectAll:ce,selectedNums:Ke,unselectedNums:Je})}catch(e){V(e?.message||"Failed to export CSV")}finally{Ae(!1)}}},style:{textTransform:"none"},children:fe?"Exporting…":"Export CSV"})})}),(0,h.jsx)(ga.Ay,{title:c?"Fetch any leads missed by the webhook from Meta":"Connect a page to sync leads",children:(0,h.jsx)("span",{children:(0,h.jsx)(da.A,{variant:"outlined",size:"small",startIcon:ye?(0,h.jsx)(ba.A,{size:14}):(0,h.jsx)(Ca.A,{}),disabled:ye||!c,onClick:async()=>{if(d&&c&&!ye){xe(!0);try{const e=await(0,_n.kR)(d,c,1===S.length?S[0]:void 0);if(!1===e?.status)return void V(e?.message||"Nothing to sync");$n("lead-contacts"),$n("lead-gen-stats"),$n("lead-analytics"),ke(),Ne()}catch(e){V(e?.response?.data?.message||"Failed to start lead sync")}finally{xe(!1)}}},style:{textTransform:"none"},children:ye?"Syncing…":"Sync from Meta"})})})]})]}),Ue&&(0,h.jsxs)(ia.A,{style:{marginBottom:12,padding:"8px 12px",borderRadius:8,background:"rgba(23,105,212,0.08)",display:"flex",alignItems:"center",justifyContent:"center",gap:8,fontSize:13},children:[(0,h.jsx)(la.A,{variant:"body2",color:"textSecondary",children:ce?`All ${Me.toLocaleString()} lead${1===Me?"":"s"} matching the current filters are selected.`:`${Me.toLocaleString()} lead${1===Me?"":"s"} selected.`}),!ce&&R>Me&&(0,h.jsxs)(da.A,{color:"primary",size:"small",style:{textTransform:"none"},onClick:()=>Ge(!0),children:["Select all ",R.toLocaleString()]}),(0,h.jsx)(da.A,{color:"inherit",size:"small",style:{textTransform:"none"},onClick:ze,children:"Clear"})]}),(0,h.jsx)(ia.A,{className:e.listRoot,children:z?(0,h.jsx)(ia.A,{className:e.loadingState,children:(0,h.jsx)(ba.A,{})}):0===Le.length?(0,h.jsxs)(ia.A,{className:e.emptyState,children:[(0,h.jsx)(la.A,{variant:"body1",children:et[b]||et.all}),(0,h.jsx)(la.A,{variant:"body2",style:{marginTop:4},children:"Try clearing the filters, or sync from Meta to recover missed leads."})]}):(0,h.jsx)(ia.A,{className:e.scrollContainer,children:(0,h.jsxs)("table",{className:e.table,children:[(0,h.jsx)("thead",{children:(0,h.jsx)("tr",{className:e.headRow,children:dn.filter((e=>!("form"===b&&"interactions"===e.key))).map((e=>(0,h.jsx)("th",{style:{width:e.width},children:"checkbox"===e.key?(0,h.jsx)(ha.A,{size:"small",color:"primary",checked:Fe,indeterminate:We,disabled:0===Le.length,onChange:He}):e.label?(0,h.jsx)(la.A,{variant:"h5",color:"primary",children:e.label}):null},e.key)))})}),(0,h.jsx)("tbody",{children:Le.map(((e,t)=>(0,h.jsx)(cn,{lead:e,index:t,selected:Oe(e),onSelect:Ve,onClick:()=>Pe(e,t),busy:le===(e._id||e.leadgenId),hideInteractions:"form"===b},e._id||e.leadgenId||t)))})]})})}),!z&&Le.length>0&&(0,h.jsx)(ia.A,{className:e.footer,children:(0,h.jsx)(fa,{limit:F,page:P,total:Re,loadPrev:()=>U((e=>Math.max(0,e-1))),loadNext:()=>U((e=>e+1)),setLimit:e=>{W(parseInt(e.target.value,10)),U(0)}})}),!z&&Le.length>0&&(0,h.jsx)(ia.A,{style:{height:72}})]}),(0,h.jsx)(ya.A,{open:Ie,onClose:()=>Ce(!1),"aria-labelledby":"lead-broadcast-dialog",maxWidth:"md",fullWidth:!0,disableBackdropClick:!0,children:Ie&&(0,h.jsx)(B,{name:"broadcastCampaign",closeDialog:()=>Ce(!1),totalSelected:Me,selectAll:ce,unSelected:Je,selected:Ke,dailyTemplateLimit:u.dailyTemplateLimit,consumedQuota:u.consumedQuota,allFilters:void 0,optedCount:0,selectedOptNo:_e,unSelectedOptNo:ve,groupedContacts:[],scheduledCampaigns:[],leadAudienceCampaign:!0,leadSourceType:b,leadSearch:C,leadStartDate:D.start,leadEndDate:D.end,leadAdId:E.join(","),leadFormId:S.join(",")})}),(0,h.jsx)(Nn,{open:ie,onClose:()=>re(!1),assistantId:d}),(0,h.jsx)(Ze,{open:!!Qe,onClose:()=>oe(-1),title:"Lead detail",width:"600px",children:Qe&&(0,h.jsx)(wn,{lead:Qe,assistantId:d,index:se,total:Le.length,onPrev:()=>
1oe((e=>Math.max(0,e-1))),onNext:()=>oe((e=>Math.min(Le.length-1,e+1)))},Qe._id||Qe.leadgenId)})]})};var ts=a(2543),as=a.n(ts),ns=a(97213),ss=a(85301);class os extends n.Component{constructor(e){super(e),this.state={amount:this.props.defaultCredits,error:null,isMACLoading:!1}}componentDidMount(){const e=document.createElement("script");return e.src="https://checkout.razorpay.com/v1/checkout.js",e.async=!0,document.body.appendChild(e),()=>{document.body.removeChild(e)}}componentDidUpdate(e){e.defaultCredits!==this.props.defaultCredits&&this.setState({amount:this.props.defaultCredits,error:null})}componentWillUnmount(){window.removeEventListener("beforeunload",this.alertSiteLeave)}handleAmountClick=e=>{let t="674de8270c6de80c169481b8"===this.props.assistantDetails.partnerId?"Minimum purchase of ₹500 is required to proceed.":"Minimum purchase of ₹100 is required to proceed.",a=Number(this.state.amount)+e<("674de8270c6de80c169481b8"===this.props.assistantDetails.partnerId?500:100);this.setState({amount:Number(this.state.amount)+e,error:a?t:Number(this.state.amount)+e>1e5?"You can buy credits up to a maximum of ₹1,00,000 only.":null})};alertSiteLeave=e=>{if(this.state.isMACLoading){const t="Payment will fail if you close this site!";return e.preventDefault(),e.returnValue=t,t}};onFailure=e=>{e.orderId=this.state.orderId,console.log("error response",e),this.props.updateFailedRazorpayOrder({...e,assistantId:this.props.assistantDetails.assistantId}).then((e=>{this.props.showSnackbar({alertOpen:!0,alertMsg:"Payment failed. Please try again!",severity:"error"}),this.setState({isMACLoading:!1})})).catch((e=>{this.props.showSnackbar({alertOpen:!0,alertMsg:"Unable to update failed payment from razorpay!",severity:"error"}),this.setState({isMACLoading:!1})})),window.removeEventListener("beforeunload",this.alertSiteLeave),this.props.onClose()};onSuccess=e=>{e.orderId=this.state.orderId,console.log("response",e),this.props.verifyRazorpayPayment({...e,assistantId:this.props.assistantDetails.assistantId}).then((e=>{this.props.showSnackbar({alertOpen:!0,alertMsg:"Payment successful! Please wait...",severity:"success",isMACLoading:!1}),window.removeEventListener("beforeunload",this.alertSiteLeave),this.props.fetchAssistantDetails(this.props.assistantDetails.assistantId,!0)})).catch((e=>{this.props.showSnackbar({alertOpen:!0,alertMsg:"Unable to verify payment from razorpay!",severity:"error"}),this.setState({isMACLoading:!1})}))};razorpay=()=>{const{assistantDetails:e,partnerName:t,colorObj:a}=this.props,{partner:n,assistantName:s,assistantId:o,partnerId:i}=e,{orderId:r,amountToPay:l}=this.state,{name:d,email:c,contact:p,id:u}=this.props.agent,m={key:J.HN,amount:l,currency:"INR",name:t||"Vyapar",description:`Purchase ${l/100} Meta ads credits for ${s}`,order_id:r,prefill:{name:d,email:c,contact:p},notes:{assistantId:o,partnerId:i},theme:{color:a?.primary||"#ED1A3B"},redirect:!1,remember_customer:!0,modal:{backdropclose:!1,escape:!1,handleback:!0,animation:!0,confirm_close:!0,ondismiss:()=>{this.setState({isMACLoading:!1})}},retry:{enabled:!0},handler:e=>{this.onSuccess(e)}},h=new window.Razorpay(m);h.on("payment.failed",(e=>{this.onFailure(e)})),window.addEventListener("beforeunload",this.alertSiteLeave),h.open()};createOrderOnRazorpay=async()=>{this.setState({isMACLoading:!0});const{assistantId:e,currency:t,assistantName:a,billingAddress:n,partnerId:s}=this.props.assistantDetails,{name:o,email:i,contact:r,id:l,clientId:d}=this.props.agent,c={partnerId:s,assistantId:e,currency:t,clientId:d,name:n?.firstName+(n?.lastName?` ${n?.lastName}`:o),email:n?.email||i,contact:n?.phone||r,amount:this.state.amount,assistantName:a,purpose:"META_AD_CREDIT_UPDATE"};this.props.createRazorpayOrder(c).then((e=>{const{order:t}=e,{id:a,amount_due:n}=t;this.setState({orderId:a,amountToPay:n},(()=>{this.props.onClose(),setTimeout((()=>{this.razorpay()}),200)}))})).catch((e=>{this.setState({isMACLoading:!1});const t=e?.response?.data?.message||"Unable to create order, please try again!";this.props.showSnackbar({alertOpen:!0,alertMsg:t,severity:"error"})}))};handleAmountChange=e=>{const t=e.target.value.replace(/[^0-9]/g,""),a=parseInt(t)||0;let n="674de8270c6de80c169481b8"===this.props.assistantDetails.partnerId?"Minimum purchase of ₹500 is required to proceed.":"Minimum purchase of ₹100 is required to proceed.",s=a<("674de8270c6de80c169481b8"===this.props.assistantDetails.partnerId?500:100);this.setState({amount:a,error:s?n:a>1e5?"You can buy credits up to a maximum of ₹1,00,000 only.":null})};render(){const{classes:e,open:t,onClose:a}=this.props,{amount:n,error:s}=this.state,i="674de8270c6de80c169481b8"===this.props.assistantDetails.partnerId?"Minimum purchase of ₹500 is required to proceed. You can buy credits up to a maximum of ₹1,00,000 only.":"Minimum purchase of ₹100 is required to proceed. You can buy credits up to a maximum of ₹1,00,000 only.";return(0,h.jsxs)(o.Dialog,{open:t,onClose:a,fullWidth:!0,className:e.dialog,children:[(0,h.jsxs)(o.Box,{className:e.dialogTitle,children:[(0,h.jsx)(o.Typography,{variant:"h2",className:e.title,children:"Buy Credits"}),(0,h.jsx)(o.IconButton,{className:e.closeButton,onClick:a,children:(0,h.jsx)(d.Close,{})})]}),(0,h.jsx)(o.Divider,{}),(0,h.jsxs)(o.DialogContent,{className:e.dialogContent,children:[(0,h.jsxs)(o.Typography,{variant:"body2",className:e.amountLabel,children:["Enter Amount",(0,h.jsx)("span",{style:{color:"#f45972"},children:"*"}),(0,h.jsx)(o.Tooltip,{placement:"right",title:i,children:(0,h.jsx)(ns.A,{size:12,style:{marginLeft:4,color:"#71748E"}})})]}
1),(0,h.jsx)(o.TextField,{fullWidth:!0,value:n.toLocaleString("en-IN"),min:100,max:1e5,error:!!s,onChange:this.handleAmountChange,style:{border:s?"1px solid #f45972":"1px solid #f0f0f0",boxShadow:s?"0px 0px 7px 0px rgba(244, 89, 114, 0.8)":"none"},className:e.amountInput,InputProps:{startAdornment:"₹"}}),(0,h.jsxs)(o.Box,{className:e.infoContainer,children:[(0,h.jsx)(ns.A,{size:14,color:s?"#f45972":"#71748E",style:{transform:s?"rotate(180deg)":"none"}}),(0,h.jsx)(o.Typography,{style:{color:s?"#f45972":"#71748E"},className:e.infoText,children:s||"The amount used to buy credits is non-refundable."})]}),(0,h.jsx)(o.Box,{className:e.amountChipContainer,children:[500,1e3,2500,5e3].map((t=>(0,h.jsxs)("button",{className:e.amountChip,onClick:()=>this.handleAmountClick(t),children:["+₹",t]},t)))}),(0,h.jsx)(o.Box,{display:"flex",justifyContent:"flex-end",mt:2,children:(0,h.jsx)(o.Button,{variant:"contained",disabled:!!s,className:e.payButton,color:"primary",onClick:this.createOrderOnRazorpay,children:"Pay Now"})})]})]})}}const is=(0,i.connect)(null,{createRazorpayOrder:ss.$L,verifyRazorpayPayment:ss.GE,updateFailedRazorpayOrder:ss.$N})(os),rs=(0,o.withStyles)((e=>({dialog:{maxWidth:"450px",margin:"0 auto"},dialogContent:{padding:"12px 16px"},dialogTitle:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:"4px 16px"},title:{fontSize:"20px",color:"#3F4155"},closeButton:{marginRight:"-8px"},amountChipContainer:{marginBottom:e.spacing(10),display:"flex",justifyContent:"flex-start",flexWrap:"wrap",gap:"8px"},amountChip:{padding:"7px 16px",borderRadius:"20px",backgroundColor:"#f0f7ff",cursor:"pointer",border:"none","&:hover":{backgroundColor:"#e3f0ff"}},amountLabel:{color:"#71748E",marginBottom:e.spacing(1),display:"flex",alignItems:"center"},amountInput:{marginBottom:e.spacing(1)},infoContainer:{display:"flex",alignItems:"center",gap:"4px",marginBottom:e.spacing(1)},infoText:{fontSize:"12px"},payButton:{borderRadius:"24px",padding:"8px 16px",color:"white",marginTop:e.spacing(2)}})))(is);var ls=a(55457);const ds=(0,i.connect)((e=>({assistantDetails:e.assistantDetails.data,agent:e.login.user})),{fetchAssistantDetails:$.lq})((function(e){let{dialogOpen:t,toggleTemplateCreditDialog:a,assistantDetails:n,agent:s,fetchAssistantDetails:o}=e;const i=(0,ls.dh)();if(!t)return null;const r=(0,j._E)()?.branding||{},l=i&&i.showSnackbar?i.showSnackbar:()=>{};return(0,h.jsx)(rs,{open:Boolean(t),onClose:a,assistantDetails:n,agent:s,fetchAssistantDetails:o,showSnackbar:l,partnerName:r.brandName||"",colorObj:r.colorObj||{},defaultCredits:500})})),cs=(0,o.withStyles)((e=>({bannerContainer:{borderRadius:"12px",padding:"16px 24px",marginTop:"8px",position:"relative",overflow:"hidden",[e.breakpoints.down("sm")]:{padding:"12px 16px"}},backgroundPattern:{pointerEvents:"none"},sparkle:{pointerEvents:"none"},flexContainer:{display:"flex",alignItems:"center",gap:"16px",[e.breakpoints.down("sm")]:{flexDirection:"column",alignItems:"stretch",gap:"12px"}},contentSection:{flex:1,minWidth:0},ctaSection:{flexShrink:0,[e.breakpoints.down("sm")]:{width:"100%"}},contentContainer:{color:"white"},badge:{display:"inline-flex",alignItems:"center",backgroundColor:"rgba(255, 255, 255, 0.2)",padding:"4px 8px",borderRadius:"12px",marginBottom:"8px",backdropFilter:"blur(10px)"},badgeText:{color:"white",fontWeight:600,fontSize:"10px",letterSpacing:"0.5px"},mainHeading:{color:"white",fontWeight:600,marginBottom:"4px",fontSize:"16px",lineHeight:"1.3",textWrap:"wrap",[e.breakpoints.down("sm")]:{fontSize:"14px"}},subText:{color:"white",opacity:.9,fontSize:"13px",lineHeight:"1.2",[e.breakpoints.down("sm")]:{fontSize:"12px"}},ctaContainer:{display:"flex",alignItems:"center",justifyContent:"flex-end",[e.breakpoints.down("sm")]:{justifyContent:"center"}},ctaButton:{backgroundColor:"#FFD700",color:"#333",fontWeight:500,fontSize:"14px",padding:"8px 16px",borderRadius:"24px",textTransform:"none",minHeight:"36px",width:"fit-content","&:hover":{backgroundColor:"#FFC107"}},"@keyframes twinkle":{"0%, 100%":{opacity:.3,transform:"translateY(-50%) scale(1)"},"50%":{opacity:1,transform:"translateY(-50%) scale(1.2)"}}})))((e=>{let{classes:t,onBuyCredits:a}=e;return(0,h.jsxs)(o.Paper,{elevation:3,className:t.bannerContainer,style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",position:"relative",overflow:"hidden"},children:[(0,h.jsx)(o.Box,{className:t.backgroundPattern,style:{position:"absolute",top:0,left:0,right:0,bottom:0,opacity:.1,backgroundImage:"radial-gradient(circle at 25% 25%, white 2px, transparent 2px)",backgroundSize:"20px 20px"}}),(0,h.jsxs)(o.Box,{className:t.flexContainer,style:{position:"relative",zIndex:1},children:[(0,h.jsx)(o.Box,{className:t.contentSection,children:(0,h.jsxs)(o.Box,{className:t.contentContainer,children:[(0,h.jsxs)(o.Box,{className:t.badge,children:[(0,h.jsx)(d.CardGiftcard,{style:{fontSize:"14px",marginRight:"4px"}}),(0,h.jsx)(o.Typography,{variant:"caption",className:t.badgeText,children:"LIMITED TIME OFFER"})]}),(0,h.jsx)(o.Typography,{variant:"h6",className:t.mainHeading,children:"Buy 2000 or more Ad Credits & Get 1000 Ad Credits BONUS for FREE! 🎉"})]})}),(0,h.jsx)(o.Box,{className:t.ctaSection,children:(0,h.jsx)(o.Box,{className:t.ctaContainer,children:(0,h.jsx)(o.Button,{variant:"contained",className:t.ctaButton,onClick:a,fullWidth:!0,children:"Buy Now & Get Bonus!"})})})]})]})}));const ps=(0,o.withStyles)((e=>({projectdialogContainer:{'& .MuiPaper-root, & [class*="MuiPaper-root-"]':{[e.breakpoints.down("md")]:{width:"100%"},[e.breakpoints.up("md")]:{width:"100%"}}},dialogHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 4px 0 16px"},Dialog:{flex:"1 1 auto",padding:"10px 16px",overflowY:"auto"},textField:{width:"100%",height:42,marginBottom:"0.25em"},Actions:{flex:"0 0 auto",display:"flex",alignItems:"center",padding:"0 16px 16px"}})))((function(e){const{open:t,onClose:a,classes:n}=e;return(0,h.jsxs)(o.Dialog,{open:t,onClose:a,style:{zIndex:3002},disableBackdropClick:!0,className:n.projectdialogContainer,children:[(0,h.jsxs)(o.Grid,{className:n.dialogHeader,children:[(0,h.jsx)(o.Typography,{variant:"h3",children:"Link Existing CTWA"}),(0,h.jsx)(o.IconButton,{onClick:a,children:(0,h.jsx)(d.Clear,{})})]}),(0,h.jsx)(o.DialogContent,{className:n.Dialog,children:(0,h.jsx)(o.Box,{className:n.selectContainer})}),(0,h.jsx)(o.DialogActions,{className:n.Actions,children:(0,h.jsx)(o.Grid,{item:!0,children:(0,h.jsx)(o.Button,{color:"primary",variant:"contained",onClick:()=>{this.linkWhatsappNumber(!0)},disabled:!1,endIcon:"",children:"Submit"})})})]})})),us=e=>{let{appId:t=J.sZ}=e;if(window.FB){const e=document.getElementById("fb-root");delete window.FB,e&&e.remove();const a=document.getElementById("facebook-jssdk");return a&&a.remove(),us({appId:t})}var a,n,s,o,i;window.fbAsyncInit=function(){window.FB.init({appId:t,cookie:!0,xfbml:!0,version:"v14.0"})},a=document,n="script",s="facebook-jssdk",i=a.getElementsByTagName(n)[0],a.getElementById(s)||((o=a.createElement(n)).id=s,o.src="https://connect.facebook.net/en_US/sdk.js",i.parentNode.insertBefore(o,i)),window.waitForFbq=function(e){void 0!==window.fbq?e():setTimeout((function(){window.waitForFbq(e)}),100)},window.launchWhatsAppSignup=function(){window.waitForFbq((function(){window.fbq("trackCustom","WhatsAppOnboardingStart",{appId:t,feature:"whatsapp_embedded_signup"})}))}};const ms=(0,i.connect)((e=>({assistantDetails:e.assistantDetails.data})),{})((function(e){const{assistantDetails:t,classes:a,pageValue:n,accountValue:s,fullWidthOnXs:i=!1}=e,{fbConnected:l,assistantId:c,whatsappNumber:p,selectedMetaAdAccountId:u}=t||{},m=(0,o.useTheme)(),g=(0,o.useMediaQuery)(m.breakpoints.down("sm")),b=(0,o.useMediaQuery)(m.breakpoints.down("xs"));return(0,h.jsx)(o.Tooltip,{title:l?s?.accountId?n?.pageId?"":"Select a Meta Page to create Ad":"Select an Ad Account to create Ad":"Connect your Facebook Account to create Ad",children:(0,h.jsx)(o.Box,{mr:g?1:2,className:i&&b?a.fullWidthOnMobile:"",children:(0,h.jsx)(o.Button,{startIcon:(0,h.jsx)(d.AddOutlined,{}),variant:"contained",color:"primary",disabled:!l||!s?.accountId||!n?.pageId,to:Xe(c)+"/create",component:r.Link,className:a.launchButton+(i&&b?" "+a.fullWidthOnMobile:""),size:g?"small":"medium",children:"Create Ad"})})})})),hs=(0,o.withStyles)((e=>({launchButton:{[e.breakpoints.down("sm")]:{padding:"4px 10px",fontSize:"0.8125rem"}},fullWidthOnMobile:{width:"100%"}})))(ms),gs=()=>{const e="undefined"!=typeof window&&window.webengage;return e||console.error("WebEngage is not available"),e},bs=e=>{try{if(!gs())return;const n={"Project Id":e?.projectId?.toString()},s={"Access Code Applied":e?.accessCodeApplied,"Virtual Number Purchased":e?.virtualNumberPurchased,"Virtual Number Plan":e?.virtualNumberPlan,"WABA Live Date":e?.WABALiveDate,"Profile Setup":e?.profileSetup,"Blue Tick Applied":e?.blueTickApplied,"Trial Activated Date":e?.trialActivatedDate,"Ad Setup Stage":e?.adSetupStage,"Agents Added":e?.agentsAdded,"WA Pay Stage":e?.waPayStage,"Last Template Created":e?.lastTemplateCreated,"Last Contact Added":e?.lastContactAdded,"Last Ad Created":e?.lastAdCreated?new Date(e?.lastAdCreated):""},o=(t=n,a=s,{...t,...Object.fromEntries(Object.entries(a).filter((e=>
1{let[t,a]=e;return null!=a})))});Object.entries(o).forEach((e=>{let[t,a]=e;return((e,t)=>{try{null!=t&&gs()&&window.webengage.user.setAttribute(e,t)}catch(a){console.error(`Error setting attribute: ${e} = ${t}`,a)}})(t,a)})),((e,t)=>{try{gs()&&(console.log("Tracking Event:",e,t),window.webengage.track(e,t))}catch(t){console.error(`Error tracking event: ${e}`,t)}})(e?.eventName,o)}catch(e){console.error("Error sending event to WebEngage:",e)}var t,a};let ys=!1,xs=!1,fs=[];const As=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{app_id:J.Em,widget:{activator:"#intercom-launcher"},hide_default_launcher:!1,alignment:"right",vertical_padding:20,horizontal_padding:20,...e}},Is=()=>{if("undefined"==typeof window)return!1;const e=document.querySelector(`script[src*="${J.xt}"]`),t=window.Intercom&&"function"==typeof window.Intercom;return xs=!(!e||!t),xs},Cs=()=>{if("undefined"==typeof window)return!1;try{const e=window.Intercom&&"function"==typeof window.Intercom,t=window.intercomSettings&&window.intercomSettings.app_id;return ys=!(!e||!t),ys}catch(e){return console.error("Error checking Intercom initialization:",e),!1}},_s=()=>new Promise(((e,t)=>{if("undefined"==typeof window)return void t(new Error("Window object not available"));if(Is())return void e();const a=document.querySelector(`script[src*="${J.xt}"]`);if(a)return a.onload=()=>{xs=!0,e()},void(a.onerror=t);const n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=`https://${J.xt}/widget/${J.Em}`,n.onload=()=>{xs=!0,e()},n.onerror=e=>{console.error("Failed to load Intercom script:",e),t(e)};const s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(n,s)})),Ss=function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{if("undefined"==typeof window)return;const a=window.intercomSettings||{};window.intercomSettings=t?{...a,...e}:e}catch(e){console.error("Error setting Intercom settings:",e)}},vs=e=>{try{if("undefined"==typeof window)return void console.warn("Window object not available, cannot boot Intercom");if(!Is())return console.warn("Intercom script not loaded, queueing boot command"),void Es("boot",e);Cs()?window.Intercom("update",e):(Ss(e,!1),window.Intercom("boot",e),ys=!0),Ts()}catch(e){console.error("Error booting Intercom:",e)}},Es=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;fs.push({method:e,data:t,timestamp:Date.now()})},Ts=()=>{if(Cs()&&0!==fs.length)try{fs.forEach((e=>{let{method:t,data:a}=e;a?window.Intercom(t,a):window.Intercom(t)})),fs=[]}catch(e){console.error("Error executing pending Intercom commands:",e)}},Ds=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{const t={app_id:J.Em};return e.user_id&&(t.user_id=String(e.user_id)),e.email&&(t.email=e.email),e.name&&(t.name=e.name),t}catch(e){return console.error("Error preparing Intercom payload:",e),null}},ws=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{const a=Ds(e,t);if(!a)throw new Error("Failed to prepare Intercom payload");return Is()||await _s(),Ss(a,!1),vs(a),a}catch(e){throw console.error("Error initializing Intercom with user:",e),e}};"undefined"!=typeof window&&window.addEventListener("load",(()=>{if(Is()&&!Cs()){const e=As();vs(e)}}));const Ns=new class{constructor(){this.initialized=!1,this.currentUser=null}async initializeForUser(e,t){try{if(!(0,u.x)().isAiSensy)return void console.log("🚫 Intercom disabled - not AiSensy tenant");if(!e.isAuthenticated||!e.user||!e.user.email)return;const t=this.prepareUserData(e.user),a=t.user_id;if(!a)return;if(this.currentUser&&this.currentUser.user_id===a)return;await ws(t,{}),this.initialized=!0,this.currentUser={...e.user,user_id:a}}catch(e){}}prepareUserData(e){if(!e)return{};const t={};return e?.assistantId&&(t.user_id=`${e.id}_${e.assistantId}`),e.email&&(t.email=e.email),e.displayName?t.name=e.displayName:e.name&&e.name!==e.email&&(t.name=e.name),(e.contact||e.phone)&&(t.phone=e.contact||e.phone),e.createdAt&&(t.created_at=Math.floor(new Date(e.createdAt).getTime()/1e3)),t.custom_attributes={project_id:e.assistantId},t}updateUser(e){if(!this.isInitialized())return!1;try{return window.Intercom("update",e),!0}catch{return!1}}updateUserAttributes(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.isInitialized())return console.error("[Intercom] Service not initialized properly"),!1;try{return window.Intercom("update",e),!0}catch(t){return console.error(":x: [Intercom] Failed to update user attributes:",t),console.error("Error details:",{message:t.message,stack:t.stack,attributes:e}),!1}}trackCustomEvent(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=e.toLowerCase().replace(/\s+/g,"_"),n={event_type:"custom",timestamp:(new Date).toLocaleStr
1ing("en-IN",{timeZone:"Asia/Kolkata",day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0}),...t};this.trackEvent(a,n)}async ensureCorrectUserContext(e){if(!e||!e.id||!e.assistantId)return;const t=`${e.id}_${e.assistantId}`;if(!this.currentUser||this.currentUser.user_id!==t){const a=this.prepareUserData({...e,assistantId:e.assistantId});await ws(a,{}),this.currentUser={...e,user_id:t},this.initialized=!0}}async trackEventWithAttributes(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;try{if(!(0,u.x)().isAiSensy)return!1;if(n&&n.id&&n.assistantId&&await this.ensureCorrectUserContext(n),!this.isInitialized())return console.warn("[Intercom] Not initialized, cannot track event"),!1;const s=n?.id&&n?.assistantId?`${n.id}_${n.assistantId}`:this.currentUser?.user_id,o=n?.assistantId||this.currentUser?.assistantId,i={...t,user_id:s,assistant_id:o,timestamp:Date.now(),url:"undefined"!=typeof window?window.location.pathname:void 0};return window.Intercom("trackEvent",e,i),a&&Object.keys(a).length>0&&this.updateUserAttributes(a),!0}catch(t){return console.error(`:x: [Intercom] Failed to track event ${e}:`,t),!1}}async trackEvent(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;try{if(!(0,u.x)().isAiSensy)return;if(a&&a.id&&a.assistantId&&await this.ensureCorrectUserContext(a),!this.isInitialized())return;const n=a?.id&&a?.assistantId?`${a.id}_${a.assistantId}`:this.currentUser?.user_id,s=a?.assistantId||this.currentUser?.assistantId,o={...t,user_id:n,assistant_id:s,timestamp:(new Date).toLocaleString("en-IN",{timeZone:"Asia/Kolkata",day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0}),source:"web"};window.Intercom("trackEvent",e,o)}catch(e){console.error("Failed to track Intercom event:",e)}}isInitialized(){return"undefined"!=typeof window&&"function"==typeof window.Intercom}},js=Ns;const ks=a.p+"0e358dc9fd0b233e80f9d704c2218f2a.svg";var Ls;function Rs(){return Rs=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},Rs.apply(null,arguments)}function Bs(e){return n.createElement("svg",Rs({width:37,height:36,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),Ls||(Ls=n.createElement("path",{d:"M25.208 11.75h-3.125v-.625a1.875 1.875 0 00-1.875-1.875h-3.75a1.875 1.875 0 00-1.875 1.875v.625h-3.125a.625.625 0 100 1.25h.625v11.25a1.25 1.25 0 001.25 1.25h10a1.25 1.25 0 001.25-1.25V13h.625a.625.625 0 100-1.25zm-9.375-.625a.625.625 0 01.625-.625h3.75a.625.625 0 01.625.625v.625h-5v-.625zm7.5 13.125h-10V13h10v11.25zm-6.25-8.125v5a.625.625 0 01-1.25 0v-5a.625.625 0 111.25 0zm3.75 0v5a.625.625 0 01-1.25 0v-5a.625.625 0 111.25 0z",fill:"#DC2625"})))}const Os=a.p+"cde1231c362e8370639a8e9281950027.svg";const Ps=a.p+"a787d8f048a14db3a3264a16c9b834dc.svg";const Ms=a.p+"e309590c0dc9be34123cbf2df09db106.svg";function Us(e){let{classes:t,dialogOpen:a,fbLoading:n,onDialogClose:s,selectedPage:i,setupChildBusinessAccount:r}=e;return(0,h.jsxs)(o.Dialog,{open:a,onClose:()=>s(),disableBackdropClick:n,children:[(0,h.jsx)(o.DialogContent,{children:(0,h.jsx)(o.Grid,{container:!0,direction:"column",className:t.content,children:(0,h.jsx)(o.Typography,{variant:"body1",style:{minHeight:30,marginTop:"20px"},children:"Do you want to use this page to run ads ?"})})}),(0,h.jsxs)(o.DialogActions,{style:{padding:"8px 32px 16px"},children:[(0,h.jsx)(o.Button,{variant:"outlined",onClick:()=>s(),children:"Cancel"}),(0,h.jsx)(o.Button,{color:"primary",variant:"contained",onClick:()=>r(i),children:"Confirm"})]})]})}function Fs(e){let{classes:t,closeCreateeNewPageDialog:a,coverPhotoName:n,coverPhotoSize:s,coverPhotoUrl:i,fbLoading:r,handleCreatePage:l,isCoverPhotoSelected:d,isCreateNewPageDialogOpen:c,isProfilePhotoSelected:p,newPageAbout:u,newPageName:m,pageAboutError:g,pageNameError:b,profilePhotoName:y,profilePhotoSize:x,removeCoverPhoto:f,removeProfilePhoto:A,setState:I,val
1idatePageAbout:C,validatePageName:_}=e;return(0,h.jsx)(o.Dialog,{open:c,PaperProps:{style:{width:"100%",maxWidth:"680px"}},onClose:a,children:(0,h.jsxs)("div",{style:{maxWidth:"680px",width:"100%"},children:[(0,h.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",borderBottom:"1px solid #F0F0F0",padding:"20px"},children:[(0,h.jsx)("div",{style:{display:"flex",flexDirection:"column",justifyContent:"flex-start",gap:"4px"},children:(0,h.jsx)("h1",{style:{fontFamily:"Inter",fontSize:"20px",fontWeight:500,lineHeight:"28px",color:"#404040",margin:0},children:"Create a New Facebook Page"})}),(0,h.jsx)("img",{src:ks,height:"24px",width:"24px",style:{cursor:"pointer",marginLeft:"10px"},onClick:a})]}),(0,h.jsxs)("div",{style:{padding:"20px",paddingTop:"27px",gap:"12px",display:"flex",flexDirection:"column",borderBottom:"1px solid #F0F0F0",paddingBottom:"32px"},children:[(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[(0,h.jsx)("p",{className:t.createPageSubHeading,children:"Page Name"}),(0,h.jsx)("p",{className:t.createPageHeadingDescription,children:"Use the name of your business, brand, or organization"}),(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[(0,h.jsx)(o.TextField,{placeholder:"Page Name",style:{marginTop:"12px",marginBottom:b?"0px":"20px"},value:m,onChange:e=>{const t=e.target.value,a=_(t);I({newPageName:t,pageNameError:a})},error:!!b}),b&&(0,h.jsx)(o.Typography,{variant:"caption",color:"error",style:{marginTop:"4px",marginLeft:"4px"},children:b})]})]}),(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[(0,h.jsx)("p",{className:t.createPageSubHeading,children:"About Page"}),(0,h.jsx)("p",{className:t.createPageHeadingDescription,children:"Write a short description about what your page represents"}),(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[(0,h.jsx)(o.TextField,{placeholder:"About Page",style:{marginTop:"12px",marginBottom:g?"0px":"20px"},value:u,onChange:e=>{const t=e.target.value,a=C(t);I({newPageAbout:t,pageAboutError:a})},error:!!g}),g&&(0,h.jsx)(o.Typography,{variant:"caption",color:"error",style:{marginTop:"4px",marginLeft:"4px"},children:g})]})]}),(0,h.jsxs)("div",{style:{display:"flex",gap:"16px",width:"100%",justifyContent:"space-between"},children:[(0,h.jsxs)("div",{style:{display:"none",flexDirection:"column",width:"100%"},children:[(0,h.jsx)("p",{className:t.createPageSubHeading,children:"Profile Photo"}),(0,h.jsx)("p",{className:t.createPageHeadingDescription,children:"Upload an image that represents your page"}),p?(0,h.jsxs)("div",{className:t.imageUploadedContainer,children:[(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[(0,h.jsx)("p",{className:t.uploadImageName,children:y}),(0,h.jsx)("p",{className:t.uploadImageSize,children:x})]}),(0,h.jsxs)("div",{style:{display:"flex",gap:"20px"},children:[(0,h.jsx)(o.Button,{variant:"text",color:"primary",onClick:()=>document.getElementById("profilePhotoInput").click(),children:"Replace"}),(0,h.jsx)("img",{src:Os,alt:"delete icon",style:{cursor:"pointer"},onClick:A})]})]}):va("mediaLibrary")&&(0,h.jsxs)("div",{className:t.imageUploadContainer,onClick:()=>{I({openMediaDialog:!0,mediaUploadingFor:"PROFILE"})},children:[(0,h.jsx)("img",{src:Ps,height:"32px",width:"32px"}),(0,h.jsx)("p",{className:t.uploadBtnText,children:"Click to Upload"})]})]}),(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column",width:"100%"},children:[(0,h.jsx)("p",{className:t.createPageSubHeading,children:"Cover Photo"}),(0,h.jsx)("p",{className:t.createPageHeadingDescription,children:"Add a cover photo to enhance your page"}),d?(0,h.jsxs)("div",{className:t.imageUploadedContainer,children:[(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[(0,h.jsx)("p",{className:t.uploadImageName,children:n}),(0,h.jsx)("p",{className:t.uploadImageSize,children:s})]}),(0,h.jsxs)("div",{style:{display:"flex",gap:"20px"},children:[va("mediaLibrary")&&(0,h.jsx)(o.Button,{variant:"text",color:"primary",onClick:()=>{I({openMediaDialog:!0,mediaUploadingFor:"COVER"})},children:"Replace"}),(0,h.jsx)("img",{src:Os,alt:"delete icon",style:{cursor:"pointer"},onClick:f})]})]}):va("mediaLibrary")&&(0,h.jsxs)("div",{className:t.imageUploadContainer,onClick:()=>{I({openMediaDialog:!0,mediaUploadingFor:"COVER"})},children:[(0,h.jsx)("img",{src:Ps,height:"32px",width:"32px"}),(0,h.jsx)("p",{className:t.uploadBtnText,children:"Click to Upload"})]})]})]})]}),(0,h.jsxs)("div",{style:{padding:"16px",display:"flex",justifyContent:"flex-end",gap:"12px"},children:[(0,h.jsx)(o.Button,{variant:"outlined",color:"primary",onClick:a,disabled:r,children:"Cancel"}),(0,h.jsx)(o.Button,{variant:"contained",color:"primary",onClick:l,disabled:r||_(m)||C(u)||!i,endIcon:r?(0,h.jsx)(o.CircularProgress,{size:18,style:{color:"grey"}}):"",children:"Create Page"})]})]})})}function Ws(e){let{submitOtpLoader:t,classes:a,linkWhatsappNumber:n,open:s,otp:i,setState:r}=e;return(0,h.jsxs)(o.Dialog,{open:s,maxWidth:"xs","aria-labelledby":"form-dialog-title",className:a.projectdialogContainer,disableBackdropClick:!0,children:[(0,h.jsxs)(o.Grid,{className:a.dialogHeader,children:[(0,h.jsx)(o.Typography,{variant:"h3",children:"One Time Password"}),(0,h.jsx)(o.IconButton,{onClick:()=>{r({open:!1,otpLoader:!1})},children:(0,h.jsx)(d.Clear,{})})]}),(0,h.jsxs)(o.DialogContent,{className:a.Dialog,children:[(0,h.jsx)(o.TextField,{name:"project",value:i,className:a.textField,onChange:(e,t)=>
1{r({otp:e.target.value})},placeholder:"Waiting for OTP...",gutterBot:!0}),(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,color:"textSecondary",children:"OTP recieved on registered WhatsApp Number"})]}),(0,h.jsx)(o.DialogActions,{className:a.Actions,children:(0,h.jsx)(o.Grid,{item:!0,children:(0,h.jsx)(o.Button,{color:"primary",variant:"contained",onClick:()=>{n(!0)},disabled:t,endIcon:t?(0,h.jsx)(o.CircularProgress,{size:18,color:"rgba(0, 0, 0, 0.26)"}):"",children:"Submit"})})})]})}function zs(e){let{isCreateNewPageSuccessDialogOpen:t,setState:a}=e;return(0,h.jsx)(o.Dialog,{open:t,PaperProps:{style:{width:"100%",maxWidth:"680px"}},onClose:()=>{a({isCreateNewPageSuccessDialogOpen:!1})},children:(0,h.jsxs)("div",{style:{maxWidth:"680px",width:"100%",display:"flex",flexDirection:"column"},children:[(0,h.jsx)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"flex-end",padding:"20px"},children:(0,h.jsx)("img",{src:ks,height:"24px",width:"24px",style:{cursor:"pointer",marginLeft:"10px"},onClick:()=>{a({isCreateNewPageSuccessDialogOpen:!1})}})}),(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%",justifyContent:"center",paddingBottom:"64px"},children:[(0,h.jsx)("img",{width:"56px",height:"56px",src:Ms,alt:"success icon"}),(0,h.jsx)("p",{style:{fontFamily:"Inter",fontWeight:600,fontSize:"20px",lineHeight:"30px",margin:0,marginTop:"16px"},children:"Your Page is Ready! 🎉"}),(0,h.jsx)("p",{style:{fontFamily:"Inter",fontWeight:400,fontSize:"14px",lineHeight:"21px",color:"#808080",textAlign:"center",margin:0,maxWidth:"448px",marginTop:"4px"},children:"You've successfully created your Facebook Page. Now, take the next steps to connect with your audience."})]})]})})}function Gs(e){let{classes:t,setState:a,snack:n,snackiv:s,snackmessage:i}=e;return(0,h.jsx)(o.Snackbar,{className:t.snackbar,open:n,onClose:()=>{a({snack:!1})},anchorOrigin:{vertical:"top",horizontal:"center"},autoHideDuration:3e3,children:(0,h.jsx)(O.Alert,{severity:s,onClose:()=>{a({snack:!1})},children:i})})}class Hs extends n.Component{constructor(e){super(e),this.state={open:!1,otp:"",snack:!1,snackmessage:"",snackiv:"",fbLoading:!1,loading:!1,otpLoader:!1,submitOtpLoader:!1,dialogOpen:!1,selectedPage:null,businessNumber:"",isProfilePhotoSelected:!1,isCoverPhotoSelected:!1,profilePhotoName:"",coverPhotoName:"",profilePhotoSize:"",coverPhotoSize:"",dragActive:!1,isCreateNewPageDialogOpen:!1,isCreateNewPageSuccessDialogOpen:!1,newPageName:"",pageNameError:"",newPageAbout:"",pageAboutError:"",openMediaDialog:!1,mediaUploadingFor:"",profilePhotoUrl:"",coverPhotoUrl:"",messages:[],leadFormTosAccepted:!1,acceptingLeadFormTos:!1,tosCheckboxChecked:!1}
1}validatePageName=e=>e.length<3||e.length>75?"Page name must be between 3 and 75 characters.":/[^a-zA-Z0-9\s&'-]/.test(e)?"Page name contains invalid characters.":/official/i.test(e)?"Page name cannot include 'official' unless authorized.":/^[A-Z\s]+$/.test(e)&&e.length>3?"Page name cannot be all uppercase unless it's an acronym.":"";validatePageAbout=e=>e.length<2||e.length>255?"About section must be between 2 and 255 characters.":(e.match(/https?:\/\//g)||[]).length>1?"About section should not contain excessive links.":"";handleCreatePage=()=>{this.setState({fbLoading:!0});const{newPageName:e,newPageAbout:t,profilePhotoUrl:a,coverPhotoUrl:n}=this.state,{assistantDetails:s}=this.props,{assistantId:o}=s||{};this.props.createPage({assistantId:o,pageName:e,pageDescription:t,profilePhotoUrl:a,coverPhotoUrl:n}).then((async e=>{this.setState({loading:!1,snack:!0,snackiv:"success",snackmessage:"Page Created Successfully"});const t={eventName:"Ad health",pageId:e.pageId,projectId:s.assistantId,projectOwnerId:s.clientId,adSetupStage:"Page created"};bs(t),await ht({triggerEvent:"FBM Stage",triggerNote:"Clicked FBM Stage - Page created",relatedProspectId:s.prospectId,activityCode:253}),this.props.getFbPages(o),this.props.selectPage(e?.pageObj),this.setupChildBusinessAccount(e?.pageObj),this.closeCreateeNewPageDialog()})).catch((e=>{this.setState({loading:!1,fbLoading:!1,selectedPage:null,snack:!0,snackiv:"error",snackmessage:e?.response?.data?.message||"Unable to create page to run ads"})}))};removeProfilePhoto=()=>{this.setState({isProfilePhotoSelected:!1,profilePhotoName:"",profilePhotoSize:""})};removeCoverPhoto=()=>{this.setState({isCoverPhotoSelected:!1,coverPhotoName:"",coverPhotoSize:""})};handleDragOver=e=>{e.preventDefault()};handleProfilePhotoDrop=e=>{const{publicUrl:t,fileName:a,fileSize:n}=e;this.setState({isProfilePhotoSelected:!0,profilePhotoName:a,profilePhotoUrl:t,profilePhotoSize:(n/1024).toFixed(2)+" KB",mediaUploadingFor:""})};handleCoverPhotoDrop=e=>{const{publicUrl:t,fileName:a,fileSize:n}=e;this.setState({isCoverPhotoSelected:!0,coverPhotoName:a,coverPhotoUrl:t,coverPhotoSize:(n/1024).toFixed(2)+" KB",mediaUploadingFor:""})};closeCreateeNewPageDialog=()=>{this.setState({isCreateNewPageDialogOpen:!1,isCoverPhotoSelected:!1,coverPhotoName:"",coverPhotoSize:"",isProfilePhotoSelected:!1,profilePhotoName:"",profilePhotoSize:"",newPageName:"",newPageAbout:"",fbLoading:!1})};sortByBusinessName=e=>e.sort((function(e,t){return e.metaBusinessName<t.metaBusinessName?-1:e.metaBusinessName>t.metaBusinessName?1:0}));componentDidMount=()=>{const{assistantDetails:e,pageValue:t}=this.props,{partner:a}=e||{},n=a?.systemUserAccessToken?a?.appId:J.sZ;if(us({appId:n}),t?.pageId){const a=t?.leadFormTosAccepted;void 0!==a?this.setState({leadFormTosAccepted:a,tosCheckboxChecked:!1}
1):this.fetchLeadFormTosStatus(e?.assistantId,t.pageId),!this.state.businessNumber&&t?.whatsappNumber&&this.setState({businessNumber:t.whatsappNumber})}};fetchLeadFormTosStatus=async(e,t)=>{if(e&&t)try{const a=await this.props.checkLeadFormPermissions({assistantId:e,pageId:t});if(a?.status){const e=a.leadFormTosAccepted||!1;this.setState({leadFormTosAccepted:e,tosCheckboxChecked:!1})}}catch(e){console.error("Error fetching lead form ToS status:",e),this.setState({leadFormTosAccepted:!1,tosCheckboxChecked:!1})}};componentDidUpdate(e){if(e.assistantDetails?.whatsappNumberOtp!==this.props.assistantDetails?.whatsappNumberOtp&&this.setState({otp:this.props.assistantDetails?.whatsappNumberOtp}),e.pageValue?.pageId!==this.props.pageValue?.pageId){const{assistantDetails:e,pageValue:t}=this.props,a=e?.assistantId,n=t?.pageId,s=t?.leadFormTosAccepted;void 0!==s?this.setState({leadFormTosAccepted:s,tosCheckboxChecked:!1}):this.fetchLeadFormTosStatus(a,n)}if(e.pageValue?.whatsappNumber!==this.props.pageValue?.whatsappNumber){const{assistantDetails:e}=this.props,{whatsappNumber:t}=this.props?.pageValue||{};if(!this.state.businessNumber&&t&&t!==this.state.businessNumber)this.setState({businessNumber:t});else if(!this.state.businessNumber){const{partner:t,whatsappNumber:a,isWhatsappVerified:n}=e||{};this.setState({businessNumber:n?a:""})}}}setupconnect=async()=>{const{assistantDetails:e}=this.props,{assistantId:t}=e||{};this.setState({fbLoading:!0}),js.trackCustomEvent("fbm_verification_submitted",{stage:"Facebook connected"});const a=await(async(e,t)=>{try{await mt().post(`${J.k}/api/rate-limit-connect-to-fb`,{assistantId:e})}catch(e){return t({alert:!0,message:e?.response?.data?.message||"Something went wrong. Please try again later!",severity:"error",code:e.response?.status||500}),!0}})(t,(async t=>{this.setState({snack:t.alert,snackmessage:t.message,snackiv:t.severity,fbLoading:!1});const a={eventName:"Ad health",projectId:e.assistantId,projectOwnerId:e.clientId,adSetupStage:"Facebook connected"};
1bs(a),await ht({triggerEvent:"FBM Stage",triggerNote:"Clicked FBM Stage - Facebook connected",relatedProspectId:e.prospectId,activityCode:253})}));a||window.FB.login((e=>{this.setupClientAccount(e)}),{scope:"public_profile,email,ads_read,ads_management,pages_show_list,business_management,pages_manage_metadata,pages_read_engagement,pages_manage_ads,pages_manage_engagement,pages_read_user_content,pages_messaging,page_events,catalog_management,pages_manage_ads,leads_retrieval",auth_type:"rerequest",return_scopes:!0})};checkPermissions=async(e,t)=>{const{adsPageOptional:a}=this.props?.assistantDetails?.specialAccess||{};return await this.props.getFbTokenInfo({inputToken:e,assistantId:t}).then((e=>{const{granularScopes:t}=e;let n=!1;for(let e=0;e<(t||[]).length;e++){const s=t[e];if((!a&&("pages_show_list"===s.scope||"pages_manage_metadata"===s.scope)||"business_management"===s.scope)&&(n=(s.target_ids||[]).length>0,n))break}return!n||(this.setState({snack:!0,snackmessage:"Please select OPT-IN to all for Business and Page to proceed.",snackiv:"error",fbLoading:!1}),!1)})).catch((e=>(this.setState({snack:!0,snackmessage:"Something went wrong! Please contact support",snackiv:"error",fbLoading:!1}),console.error(e),!1)))};generateConnectAdsLink=()=>{const{partnerId:e,assistantId:t}=this.props?.assistantDetails||{},{id:a}=this.props?.agent||{};this.setState({fbLoading:!0}),this.props.generateConnectAdsLink({assistantId:t,partnerId:e,agentId:a}).then((e=>{const{link:t}=e;this.setState({snack:!0,snackmessage:"Refresh this tab after connecting facebook!!",snackiv:"info"}),setTimeout((()=>{window.open(t,"_blank")}),2e3)})).catch((e=>{console.error(e)}))};setupClientAccount=async e=>{const{updateAssistantStore:t,assistantDetails:a}=this.props,{assistantId:n,partnerId:s}=a||{},{authResponse:o,status:i}=e,{grantedScopes:r}=o||{};if(console.log({response:e}),"connected"===i&&n&&r)if(r.includes("business_management"))if(r.includes("ads_management"))if(r.includes("ads_read"))if(r.includes("pages_show_list"))if(r.includes("pages_manage_metadata")){await this.checkPermissions(o.accessToken,n)&&this.props.fbConnect({assistantId:n,authResponse:o,status:i,partnerId:s}).then((e=>{const{assistantData:a}=e,{fbConnected:s,fbUserId:o,fbGrantedScopes:i,fbConnectedBy:r,selectedMetaPageId:l,selectedMetaAdAccountId:d}=a;t({fbConnected:s,fbUserId:o,fbGrantedScopes:i,fbConnectedBy:r,selectedMetaPageId:l,selectedMetaAdAccountId:d}),this.props.getFbAcc(n),this.props.getFbPages(n),this.setState({fbLoading:!1,snack:!0,snackmessage:"Facebook connected!",snackiv:"success"})})).catch((e=>{console.log(e),this.setState({fbLoading:!1,snack:!0,snackmessage:e?.response?.data?.message,snackiv:"error"})}))}else this.setState({fbLoading:!1,snack:!0,snackmessage:"Provide Page Management permission!",snackiv:"error"});else this.setState({fbLoading:!1,snack:!0,snackmessage:"Provide Page Read permission!",snackiv:"error"});else this.setState({fbLoading:!1,snack:!0,snackmessage:"Provide Ads Read permission!",snackiv:"error"});else this.setState({fbLoading:!1,snack:!0,snackmessage:"Provide Ads Management permission!",snackiv:"error"});else this.setState({fbLoading:!1,snack:!0,snackmessage:"Provide Business Management permission!",snackiv:"error"});else this.setState({fbLoading:!1,snack:!0,snackmessage:"Connection Failure!",snackiv:"error"})};disconnectClientAccount=()=>{const{updateAssistantStore:e,assistantDetails:t}=this.props,{assistantId:a,fbUserId:n,partnerId:s}=t||{};a&&n&&(this.setState({fbLoading:!0}),this.props.fbDisconnect({assistantId:a,fbUserId:n,partnerId:s}).then((async a=>{this.props.removeSelectedMetaPage();const{assistantData:n}=a,{fbConnected:s,selectedMetaPageId:o,selectedMetaAdAccountId:i,freezedMetaAdAccountId:r,freezedMetaPageId:l}=n;e({fbConnected:s,selectedMetaPageId:o,selectedMetaAdAccountId:i,freezedMetaAdAccountId:r,freezedMetaPageId:l}),this.props.updateStateValue({fbaccount:[],fbpages:[],accountValue:{},pageValue:{}});const d={eventName:"Ad health",projectId:t.assistantId,projectOwnerId:t.clientId,adSetupStage:"Facebook disconnected"};
1bs(d),await ht({triggerEvent:"FBM Stage",triggerNote:"Clicked FBM Stage - Facebook disconnected",relatedProspectId:t.prospectId,activityCode:253}),this.setState({fbLoading:!1,snack:!0,snackmessage:"Facebook disconnected!",snackiv:"success"})})).catch((e=>{console.log(e),this.setState({fbLoading:!1,snack:!0,snackmessage:e?.response?.data?.message,snackiv:"error"})})))};handleAcceptLeadFormTos=async()=>{const{assistantDetails:e,pageValue:t}=this.props,{assistantId:a}=e||{},{pageId:n}=t||{};if(a&&n)if(this.state.tosCheckboxChecked){this.setState({acceptingLeadFormTos:!0});try{const e=await this.props.acceptLeadFormTos({assistantId:a,pageId:n});if(!e?.status)throw new Error(e?.message||"Failed to accept ToS");this.setState({leadFormTosAccepted:!0,acceptingLeadFormTos:!1}),this.props.getFbPages&&this.props.getFbPages(a),this.setState({snack:!0,snackmessage:"Lead Form Terms of Service accepted successfully",snackiv:"success"})}catch(e){console.error("Error accepting lead form ToS:",e),this.setState({acceptingLeadFormTos:!1,snack:!0,snackmessage:e?.response?.data?.message||e?.message||"Failed to accept Terms of Service. Please try again.",snackiv:"error"})}}else this.setState({snack:!0,snackmessage:"Please check the checkbox to accept the Terms of Service",snackiv:"error"});else this.setState({snack:!0,snackmessage:"Please select a page first",snackiv:"error"})};linkWhatsappNumber=e=>{const{assistantDetails:t,pageValue:a}=this.props,{assistantId:n,whatsappNumber:s,assistantName:o,currency:i}=t||{},{otp:r,businessNumber:l}=this.state;if(!a?.pageId)return void this.setState({snack:!0,snackmessage:"Select facebook page !!",snackiv:"error"});if(l.length<10)return void this.setState({snack:!0,snackmessage:"Input valid whatsapp number !!",snackiv:"error"});if(e&&!r)return void this.setState({snack:!0,snackmessage:"Enter OTP !!",snackiv:"error"});e?this.setState({submitOtpLoader:!0}):this.setState({otpLoader:!0});const d=e?r:"";this.props.linkWhatsappNumberWithPage({assistantId:n,verificationCode:d,pageId:a.pageId,number:l||s,timezoneId:"INR"===i?71:1,vertical:"OTHER",bmName:o}).then((async e=>{const{otpState:a,message:o}=e;if("send"===a)this.setState({open:!0,otpLoader:!1});else if("verified"===a){this.props.updateWhatsappNumber(l||s),this.setState({open:!1,otpLoader:!1,snack:!0,snackmessage:o,snackiv:"success",submitOtpLoader:!1});const e={eventName:"Ad health",projectId:t.assistantId,projectOwnerId:t.clientId,adSetupStage:"Whatsapp number verified"};bs(e),await ht({triggerEvent:"FBM Stage",triggerNote:"Clicked FBM Stage - Whatsapp number verified",relatedProspectId:t.prospectId,activityCode:253})}else"pending"===a&&this.setState({open:!1,otpLoader:!1,snack:!0,snackmessage:o,snackiv:"info",submitOtpLoader:!1});this.props.fetchAssistantDetails(n,!0)})).catch((e=>{console.log("error:",e),this.setState({snack:!0,snackmessage:e?.response?.data?.message||"Something went wrong",snackiv:"error",otpLoader:!1,submitOtpLoader:!1});const{action:t,assistant:a}=e?.response?.data||{};if("reconnect"===t&&a){this.props.updateStateValue({fbaccount:[],fbpages:[],accountValue:{},pageValue:{}});const{fbConnected:e,fbUserId:t,fbGrantedScopes:n,selectedMetaPageId:s,selectedMetaAdAccountId:o,freezedMetaAdAccountId:i,freezedMetaPageId:r}=a||{};this.props.updateAssistantStore({fbConnected:e,fbUserId:t,fbGrantedScopes:n,selectedMetaPageId:s,selectedMetaAdAccountId:o,freezedMetaAdAccountId:i,freezedMetaPageId:r})}}))};setupChildBusinessAccount=e=>{this.setState({dialogOpen:!1,loading:!0});const{assistantDetails:t}=this.props,{assistantId:a,assistantName:n,currency:s}=t||{};this.props.setupBusinessAccount({assistantId:a,pageId:e?.pageId,timezoneId:"INR"===s?71:1,vertical:"OTHER",bmName:n}).then((async a=>{this.setState({dialogOpen:!1,loading:!0}),this.props.selectAdAccount(a.adAccount),this.props.selectPage(e),this.setState({loading:!1,snack:!0,snackiv:"success",snackmessage:"Account Setup Successfully"});const n={eventName:"Ad health",projectId:t.assistantId,projectOwnerId:t.clientId,adSetupStage:"Page connected"};
1bs(n),await ht({triggerEvent:"Meta Ads Connected",triggerNote:"Clicked Meta Ads Connected",relatedProspectId:t.prospectId,activityCode:208}),await ht({triggerEvent:"FBM Stage",triggerNote:"Clicked FBM Stage - Page connected",relatedProspectId:t.prospectId,activityCode:253})})).catch((e=>{this.props.selectPage({}),this.setState({loading:!1,selectedPage:null,snack:!0,snackiv:"error",snackmessage:e?.response?.data?.message||"Unable to setup account to run ads"})}))};onDialogClose=()=>{this.props.selectPage({}),this.setState({dialogOpen:!1,selectedPage:null})};onMediaSelect=e=>{const{mediaUploadingFor:t}=this.state;"COVER"==t?this.handleCoverPhotoDrop(e):"PROFILE"==t&&this.handleProfilePhotoDrop(e)};render(){var e=this;const{classes:t,assistantDetails:a,fbaccount:n,accountValue:s,fbpages:i,pageValue:r,agent:l}=this.props,{fbLoading:c,otpLoader:p,submitOtpLoader:m,loading:g,businessNumber:b}=this.state,{whatsappNumber:y}=r||{},{fbConnected:x,fbConnectedBy:f,whatsappNumber:A,freezedMetaPageId:I,partnerId:C,partner:_}=a||{},{id:S,power:v}=l||{},E=v>1||!f||f===S;return(0,h.jsxs)("div",{className:t.root,children:[(0,h.jsx)(o.Grid,{container:!0,justify:"center",children:(0,h.jsxs)(o.Grid,{item:!0,xs:12,md:11,lg:11,children:[(0,h.jsxs)("div",{className:t.contentContainer,style:{opacity:1},children:[(0,h.jsxs)(o.Grid,{container:!0,spacing:2,justify:"space-between",children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,md:7,children:[(0,h.jsx)(o.Typography,{variant:"h4",gutterBottom:!0,children:"Connect your Facebook account"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:`Allow ${C?"us":"AiSensy"} to receive advertisement analytics and\n              events from Facebook`}),(0,h.jsxs)(o.Typography,{variant:"body2",color:"textSecondary",style:{fontSize:"14px",marginTop:"8px"},children:["*Please select"," ",(0,h.jsx)("b",{style:{fontWeight:"900",color:"black"},children:"OPT into all"})," ","option for Business and Pages*"]})]}),(0,h.jsx)(o.Grid,{item:!0,xs:12,md:5,className:t.rightActionComponent,children:(0,h.jsx)(h.Fragment,{children:x?(0,h.jsx)(o.Tooltip,{title:E?"This will disconnect your Facebook Account":"You don't have permission to disconnect Facebook Account",children:(0,h.jsx)("div",{children:(0,h.jsx)(o.Button,{variant:"outlined",onClick:this.disconnectClientAccount,disabled:!E||c,style:{color:!E||c?"grey":"#fa5c5c",borderColor:!E||c?"grey":"#fa5c5c",padding:"5px 18px"},size:"large",endIcon:c?(0,h.jsx)(o.CircularProgress,{size:18,style:{color:"grey"}}):"",children:"Disconnect"})})}):(0,h.jsx)(o.Tooltip,{interactive:!0,title:"",children:(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Button,{disabled:c,style:{backgroundColor:c?"lightgrey":"#1877f2",color:"#fff",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"bold",padding:"5px 18px"},size:"large",onClick:(0,u.x)().isPartner?this.generateConnectAdsLink:this.setupconnect,endIcon:c?(0,h.jsx)(o.CircularProgress,{size:18,style:{color:"white"}}):C?(0,h.jsx)(d.OpenInNew,{size:18,style:{color:"white"}}):"",children:C?"Connect":"Continue With Facebook"})})})})})]}),(0,h.jsx)(o.Box,{my:4,children:(0,h.jsx)(o.Divider,{})}),(0,h.jsxs)(o.Grid,{container:!0,spacing:2,justify:"space-between",alignItems:"center",children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,md:7,children:[(0,h.jsx)(o.Typography,{variant:"h4",gutterBottom:!0,children:"Choose your Facebook page"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:"Select Facebook page which will be used to ad"})]}),(0,h.jsxs)(o.Grid,{item:!0,xs:12,md:5,className:t.rightActionComponent,children:[x&&!i.length&&a?.isWhatsappVerified?(0,h.jsx)(o.Tooltip,{title:"Create New Facebook Page",children:(0,h.jsx)("div",{children:(0,h.jsx)(o.Button,{color:"primary",variant:"contained",style:{marginLeft:"0.3em"},disabled:this.state.fbLoading,onClick:()=>{this.setState({isCreateNewPageDialogOpen:!0})},startIcon:(0,h.jsx)(d.AddOutlined,{}),endIcon:this.state.fbLoading?(0,h.jsx)(o.CircularProgress,{size:18,style:{color:"grey"}}):"",children:"Create Page"})})}):(0,h.jsx)(o.Tooltip,{title:f!==S&&I?"You don't have permission to change Facebook Page":"",children:(0,h.jsx)(o.Box,{className:t.
1selectContainer,children:(0,h.jsx)(O.Autocomplete,{classes:{groupUl:t.autoComplete},disableClearable:!0,id:"grouped-demo",disabled:!x||g||this.props.selectedMetaPageId,renderOption:(e,a)=>(0,ea.Oi)(e,a,t,!0),options:this.sortByBusinessName(i),getOptionDisabled:e=>!e.isAssigned&&!!e.metaBusinessId,getOptionLabel:e=>{const{pageName:t,pageId:a}=e;return t&&a?`${t} - ${a}`:""},onChange:(e,t)=>{this.props.selectPage(t),this.setState({selectedPage:t,dialogOpen:!0})},groupBy:e=>e.metaBusinessName,value:r,name:"fbpage",renderInput:e=>(0,h.jsx)(o.TextField,{...e,variant:"outlined",label:"Choose your page",classes:{root:t.textFieldRootAutocomplete},InputProps:{...e.InputProps}}),PaperComponent:e=>{let{children:t}=e;return(0,h.jsxs)(o.Paper,{children:[t,"66fe33ed494c320b70b659e6"==a?.partnerId&&(0,h.jsx)(o.Button,{fullWidth:!0,startIcon:(0,h.jsx)(d.AddOutlined,{style:{color:"#5383EC",width:"16px",height:"16px"}}),onMouseDown:()=>{this.setState({isCreateNewPageDialogOpen:!0})},style:{display:"flex",justifyContent:"flex-start",fontSize:"13px",lineHeight:"18.2px",fontFamily:"Inter",letterSpacing:"-0.02em",padding:"8px 5px 8px 15px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"#5383EC",borderTop:"1px solid #F0F0F0"},children:"Create Facebook Page"})]})}})})}),this.state.loading&&(0,h.jsx)(o.CircularProgress,{size:18,style:{marginLeft:"8px",color:"grey"}})]})]}),(0,h.jsx)(o.Box,{my:4,children:(0,h.jsx)(o.Divider,{})}),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.Grid,{container:!0,spacing:2,justify:"space-between",alignItems:"center",children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,md:7,children:[(0,h.jsx)(o.Typography,{variant:"h4",children:"Accept Lead Form Terms of Service"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:"You must accept the Terms of Service for Lead Form Ads before creating lead form campaigns"})]}),(0,h.jsx)(o.Grid,{item:!0,xs:12,md:5,className:t.rightActionComponent,children:this.state.leadFormTosAccepted?(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",children:[(0,h.jsx)(d.CheckCircleOutline,{style:{color:"#20A60E"}}),(0,h.jsx)(o.Typography,{style:{marginLeft:"6px",fontSize:"14px"},children:"Terms of Service accepted"})]}):(0,h.jsxs)(o.Box,{display:"flex",flexDirection:"column",gap:2,style:{width:"100%"},children:[(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",gap:1,style:{marginBottom:"8px"},children:[(0,h.jsx)("input",{type:"checkbox",id:"leadFormTosCheckbox",checked:this.state.tosCheckboxChecked,disabled:!r?.pageId,onChange:e=>{this.setState({tosCheckboxChecked:e.target.checked})},style:{width:"18px",height:"18px",cursor:r?.pageId?"pointer":"not-allowed"}}),(0,h.jsxs)("label",{htmlFor:"leadFormTosCheckbox",style:{cursor:"pointer",fontSize:"14px",display:"flex",alignItems:"center",gap:"4px"},children:["I accept the"," ",(0,h.jsxs)(o.Link,{href:"https://www.facebook.com/legal/leadgen/tos",target:"_blank",rel:"noopener noreferrer",style:{color:"#5383EC",textDecoration:"none",display:"flex",alignItems:"center",gap:"4px"},onClick:e=>e.stopPropagation(),children:["Terms of Service for Lead Form Ads",(0,h.jsx)(d.OpenInNew,{style:{fontSize:"14px"}})]})]})]}),(0,h.jsx)(o.Tooltip,{title:x?r?.pageId?"":"Select a Meta Page to accept the Terms of Service":"Connect your Facebook Account",children:(0,h.jsx)("div",{children:(0,h.jsx)(o.Button,{color:"primary",variant:"contained",onClick:this.handleAcceptLeadFormTos,disabled:!r?.pageId||this.state.acceptingLeadFormTos||!this.state.tosCheckboxChecked,endIcon:this.state.acceptingLeadFormTos?(0,h.jsx)(o.CircularProgress,{size:18,style:{color:"rgba(0, 0, 0, 0.26)"}}):null,style:{textTransform:"none"},children:this.state.acceptingLeadFormTos?"Accepting...":"Accept Terms"})})})]})})]}),(0,h.jsx)(o.Box,{my:4,children:(0,h.jsx)(o.Divider,{})})]}),(0,h.jsxs)(o.Grid,{container:!0,spacing:2,justify:"space-between",alignItems:"center",children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,md:7,children:[(0,h.jsx)(o.Typography,{variant:"h4",children:"Link Whatsapp Number"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:"Link your WhatsApp business number with selected Facebook page to re
1ceive messages directly over WhatsApp"})]}),(0,h.jsxs)(o.Grid,{item:!0,xs:12,md:5,className:t.rightActionComponent,children:[(0,h.jsx)(o.Tooltip,{title:y?"":"WhatsApp API Number is linked with selected Facebook Page",children:(0,h.jsx)(o.Box,{className:t.selectContainer,children:(0,h.jsx)(o.TextField,{className:`${t.otpTextField} ${x?t.otpTextFieldDisabled:""}`,name:"whatsappNumber",value:b,onChange:e=>{const t=e.target.value;/^\d*$/.test(t)&&this.setState({businessNumber:t})},InputProps:{endAdornment:y===b&&(0,h.jsx)(o.InputAdornment,{children:(0,h.jsx)(d.CheckCircleOutline,{style:{color:"#20A60E"}})})}})})}),(0,h.jsx)(h.Fragment,{children:y&&y===b?(0,h.jsx)(h.Fragment,{}):(0,h.jsx)(o.Tooltip,{title:x?r?.pageId?"Click to link your WhatsApp Number":"Select a Meta Page to send OTP":"Connect your Facebook Account",children:(0,h.jsx)("div",{children:(0,h.jsx)(o.Button,{color:"primary",variant:"contained",style:{marginLeft:"0.3em"},onClick:()=>this.linkWhatsappNumber(),endIcon:p?(0,h.jsx)(o.CircularProgress,{size:18,color:"rgba(0, 0, 0, 0.26)"}):"",disabled:p||!x||!r?.pageId||!s?.accountId,children:(0,h.jsx)(o.Typography,{children:"Verify"})})})})})]}),(0,h.jsx)(o.Box,{my:4})]})," ",(0,h.jsx)(o.Box,{my:4,children:(0,h.jsx)(o.Divider,{})}),(0,h.jsxs)(o.Grid,{container:!0,spacing:2,justify:"space-between",alignItems:"center",children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,md:7,children:[(0,h.jsx)(o.Typography,{variant:"h4",children:"Create Advertisement"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:"Click Create Ad to start receiving leads directly on your WhatsApp."})]}),(0,h.jsx)(o.Grid,{item:!0,xs:12,md:5,className:t.rightActionComponent,children:(0,h.jsx)(hs,{accountValue:s,pageValue:r})}),(0,h.jsx)(o.Box,{my:4})]})]}),(0,h.jsx)(o.Box,{my:8})]})}),(0,h.jsx)(Ws,{submitOtpLoader:this.state.submitOtpLoader,classes:this.props.classes,linkWhatsappNumber:this.linkWhatsappNumber,open:this.state.open,otp:this.state.otp,setState:function(){return e.setState(...arguments)}}),(0,h.jsx)(Us,{classes:this.props.classes,dialogOpen:this.state.dialogOpen,fbLoading:this.state.fbLoading,onDialogClose:this.onDialogClose,selectedPage:this.state.selectedPage,setupChildBusinessAccount:this.setupChildBusinessAccount}),(0,h.jsx)(Gs,{classes:this.props.classes,setState:function(){return e.setState(...arguments)},snack:this.state.snack,snackiv:this.state.snackiv,snackmessage:this.state.snackmessage}),(0,h.jsx)(Fs,{classes:this.props.classes,closeCreateeNewPageDialog:this.closeCreateeNewPageDialog,coverPhotoName:this.state.coverPhotoName,coverPhotoSize:this.state.coverPhotoSize,coverPhotoUrl:this.state.coverPhotoUrl,fbLoading:this.state.fbLoading,handleCreatePage:this.handleCreatePage,isCoverPhotoSelected:this.state.isCoverPhotoSelected,isCreateNewPageDialogOpen:this.state.isCreateNewPageDialogOpen,isProfilePhotoSelected:this.state.isProfilePhotoSelected,newPageAbout:this.state.newPageAbout,newPageName:this.state.newPageName,pageAboutError:this.state.pageAboutError,pageNameError:this.state.pageNameError,profilePhotoName:this.state.profilePhotoName,profilePhotoSize:this.state.profilePhotoSize,removeCoverPhoto:this.removeCoverPhoto,removeProfilePhoto:this.removeProfilePhoto,setState:function(){return e.setState(...arguments)},validatePageAbout:this.validatePageAbout,validatePageName:this.validatePageName}),(0,h.jsx)(zs,{isCreateNewPageSuccessDialogOpen:this.state.isCreateNewPageSuccessDialogOpen,setState:function(){return e.setState(...arguments)}}),(0,h.jsx)(B,{name:"mediaLibrary",multiSelect:!1,selectedProducts:[],openMediaDialog:this.state.openMediaDialog,toggleMediaDialog:()=>this.setState({openMediaDialog:!1}),onMediaSelect:this.onMediaSelect,mediaType:"IMAGE"})]})}}const Vs=(0,i.connect)((e=>({assistantDetails:e.assistantDetails.data,agent:e.login.user})),{updateAssistantStore:$.nt,fetchAssistantDetails:$.lq,createPage:ss.a3,fbConnect:M.PH,fbDisconnect:M.vy,getFbTokenInfo:ss.sJ,generateConnectAdsLink:M.M0,linkWhatsappNumberWithPage:ss.ls,setupBusinessAccount:ss.fc,acceptLeadFormTos:ss.DX,checkLeadFormPermissions:M.xS})(Hs),Ys=(0,o.withStyles)((e=>({root:{width:"100%"},contentContainer:{width:"100%",boxSizing:"border-box",padding:"40px",minHeight:200,backgroundColor:"white",borderRadius:"15p
1x",[e.breakpoints.down("sm")]:{padding:"25px 15px"}},projectdialogContainer:{'& .MuiPaper-root, & [class*="MuiPaper-root-"]':{[e.breakpoints.down("md")]:{width:"100%"},[e.breakpoints.up("md")]:{width:"100%"}}},message:{fontFamily:"Inter",fontSize:"16px",lineHeight:"19.8px",lineWidth:"0.1px",marginTop:"1.5rem"},autoComplete:{'& [class*=MuiAutocomplete-option][aria-disabled="true"]':{pointerEvents:"inherit",background:"white"},'& [class*=MuiAutocomplete-option][aria-disabled="true"]:active':{pointerEvents:"none",background:"white"}},textFieldRootAutocomplete:{width:"100%",padding:"2px 8px",background:"white",border:"1px solid grey","& label":{background:"white",color:"#b2b3b3 !important",padding:"0 6px",marginTop:-4}},truncate:{width:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},textField:{width:"100%",height:42,marginBottom:"0.25em"},Actions:{flex:"0 0 auto",display:"flex",alignItems:"center",padding:"0 16px 16px"},Dialog:{flex:"1 1 auto",padding:"10px 16px",overflowY:"auto"},dialogHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 4px 0 16px"},arrow:{color:"white"},snackbar:{zIndex:3e3,top:70},selectContainer:{[e.breakpoints.down("sm")]:{width:"80%"},[e.breakpoints.up("sm")]:{width:"60%"}},otpTextField:{width:"100%",padding:"8px 16px 7px 20px",background:"white",border:"1px solid grey"},otpTextFieldDisabled:{"& div":{color:"black !important"}},rightActionComponent:{display:"flex",justifyContent:"start",alignItems:"center"},createPageSubHeading:{fontFamily:"Inter",fontWeight:400,fontSize:"14px",lineHeight:"19.6px",color:"#232529",margin:0},createPageHeadingDescription:{fontFamily:"Inter",fontSize:"12px",fontWeight:400,lineHeight:"18px",margin:0},imageUploadContainer:{border:"1px dashed #D9D9D9",display:"flex",flexDirection:"column",alignItems:"center",paddingTop:"32px",paddingBottom:"32px",paddingLeft:"20px",paddingRight:"20px",borderRadius:"12px",marginTop:"12px",justifyContent:"center"},imageUploadedContainer:{background:"#F8F8F8",marginTop:"12px",display:"flex",padding:"16px",borderRadius:"12px",justifyContent:"space-between",flexWrap:"wrap"},uploadBtnText:{fontFamily:"Inter",fontWeight:400,fontSize:"14px",margin:0,gap:"8px",textAlign:"center",color:"#404040"},uploadImageName:{color:"#141414",fontFamily:"Inter",fontWeight:500,fontSize:"14px",margin:0,whiteSpace:"pre"},uploadImageSize:{color:"#808080",fontFamily:"Inter",fontWeight:400,fontSize:"12px",margin:0,lineHeight:"18px"}})))((0,r.withRouter)(Vs)),Zs=a.p+"cbae93621ff3a1ea6b1f34f5b83d39b5.png";function Ks(e){let{classes:t,sticky:a,fbConnected:n,accountValue:s,pageValue:i,power:r,partnerId:l,cbpType:d,allowPurchase:c,ongoingBillingProcess:p,pendingInvoices:u,assistantDetails:m,onLinkAd:g,onBuyCredits:b}=e;return(0,h.jsxs)(o.Grid,{container:!0,justify:"center",alignItems:"center",className:`${t.pageTitleContainer} ${t.fullWidth} ginger-page-header`,style:{boxShadow:a?"none":"rgb(235 234 234) 0px 0px 11px"},children:[(0,h.jsx)(o.Grid,{item:!0,xs:!0,style:{display:"flex",alignItems:"center"},children:(0,h.jsx)(o.Box,{pl:{xs:2,md:3},children:(0,h.jsx)(o.Typography,{variant:"h3",children:"Setup"})})}),(0,h.jsxs)(o.Grid,{item:!0,style:{display:"flex"},children:[!1,(0,h.jsxs)(o.Box,{mx:2,display:"flex",alignItems:"center",style:{gap:"4px"},children:[(0,h.jsx)("img",{src:Zs,alt:"WhatsApp",className:t.walletIcon}),(0,h.jsxs)(o.Typography,{color:"primary",variant:"h4",children:["Ad Credit: ","USD"===m.currency?"$":"₹"," ",(m.metaAdsCredit||0).toFixed(2)]})]})]}),(0,h.jsx)(o.Grid,{item:!0,children:(0,h.jsx)(o.Box,{ml:2,mr:2,display:"flex",alignItems:"center",children:(0,h.jsx)(B,{name:"gingerLauncher"})})}),(0,h.jsxs)(o.Box,{className:t.buttonContainer,children:[r>=2&&(!l||l!==J.kA&&m?.partner?.isZohoEnabled&&"NONE"!==m?.activePlan)&&("ENTERPRISE"!==d||c)&&(0,h.jsx)(o.Button,{onClick:()=>{b()},variant:"outlined",color:"primary",disabled:p||u?.length,className:t.buyCreditsButton,children:"Buy Credits"}),(0,h.jsx)(hs,{accountValue:s,pageValue:i,fullWidthOnXs:!0})]})]})}const Js=["Connect Your FB Account","Select Your Ad Page","Link Whatsapp Number","You've Won Ad Credits"];const $s=a.p+"03391cd5814bd1688e299f6459a1c6de.svg";a.p;
1const qs=a.p+"5e8c331b65d9f4e69236243cf0a15fed.svg";const Xs=a.p+"58c0fe552a387c5c3ef8037692ec0812.svg";a.p;a.p;const Qs=a.p+"6a54bdf7104e925e2f74ef3abffaedc9.svg";const eo=a.p+"4a2daf61a0e8bd9b024c6e282a18c710.svg";const to=a.p+"4bd3d7a884e9563c4aac9b2a2ac32647.svg";var ao=a(80827),no=a(56808);const so=(0,o.withStyles)((e=>({linkText:{color:"#0075E8",fontFamily:"Roboto, sans-serif",fontSize:"16px",fontWeight:500,lineHeight:"24px","&:hover":{textDecoration:"underline"}},root:{display:"flex",justifyContent:"space-between",backgroundColor:e.palette.rewardBackground.default,[e.breakpoints.down("1000")]:{paddingBottom:"12px"}},whatsappVerificationTag:{display:"flex",width:"9.19rem",height:"1.75rem",borderRadius:"3px",alignItems:"center",justifyContent:"center",background:"rgba(67, 184, 97, 0.2)"},whatsappVerificationTagTitle:{fontWeight:500,color:"#ffffff",fontSize:"10px",lineHeight:"12.5px"},wccDetails:{borderRadius:"20px"},goldReward:{width:"3rem",height:"6rem",marginLeft:"-4rem",position:"absolute",marginTop:"-2.75rem"},title:{color:"white",fontSize:"18px",fontWeight:"500",lineHeight:"18.75px"},subTitle:{marginTop:"8px",color:"white",fontFamily:"Roboto",fontSize:"16px",fontWeight:"400",lineHeight:"26px",color:"#71748E",maxWidth:"572px",width:"max-content",[e.breakpoints.down("1000")]:{width:"fit-content"}},info:{display:"flex",marginTop:"1rem",paddingLeft:"12px",gap:"10px"},infographic:{display:"flex",marginBottom:"8px",alignItems:"center",width:"100%"},progressStatusIcon:{width:"1.75rem",height:"1.75rem"},progressBar:{height:"2px",width:"9rem",marginLeft:"16px",display:"flex",alignItems:"center",justifyContent:"space-around",[e.breakpoints.down("2000")]:{width:"9rem"},[e.breakpoints.down("1900")]:{width:"8rem"},[e.breakpoints.down("1700")]:{width:"6rem"},[e.breakpoints.down("1500")]:{width:"4rem"},[e.breakpoints.down("1400")]:{width:"3rem"},[e.breakpoints.down("1200")]:{width:"3rem"}},stepDetail:{fontSize:"12px",lineHeight:"18px",fontFamily:"Roboto,sans-serif",fontWeight:400},stepName:{color:"#3F4155",fontSize:"14px",marginTop:"8px",lineHeight:"20px",fontWeight:500,fontFamily:"Roboto, sans-serif"},goldReward3D:{width:"12rem",height:"9rem",marginRight:"-3.5rem",[e.breakpoints.down("1400")]:{width:"10rem",height:"8rem",marginTop:"0rem",marginRight:"-3.2rem"},[e.breakpoints.down("1200")]:{display:"none"}},dashboadBannerBackground:{width:"336px",height:"max-content",[e.breakpoints.down("1000")]:{display:"none"}},rewardBannerImage:{objectFit:"cover",width:"100%",height:"100%",objectFit:"cover",borderRadius:"0 12px 12px 0",[e.breakpoints.down("1000")]:{display:"none"}},goldCoins:{position:"absolute",width:"180px",height:"121px",left:"50%",top:"30%",transform:"translateX(-50%)",[e.breakpoints.down("1000")]:{display:"none"}},stepContainer:{margin:"0px 40px",[e.breakpoints.down("lg")]:{margin:"0px 24px"},[e.breakpoints.down("md")]:{margin:"0px 4px"},[e.breakpoints.down("sm")]:{margin:"0px"},[e.breakpoints.down("xs")]:{margin:"0px"}},shimmerContainer:{width:"80%",padding:"10px",maxWidth:"500px"},shimmerLine:{height:15,width:"100%",background:"linear-gradient(to right, #e0e0e0 0%, #f0f0f0 50%, #e0e0e0 100%)",backgroundSize:"200% 100%",animation:"$shimmerAnimation 1.5s linear infinite",borderRadius:5,marginBottom:10},"& .shimmer-line:last-child":{marginBottom:0},"@keyframes shimmerAnimation":{"0%":{backgroundPosition:"200% 0"},"100%":{backgroundPosition:"-200% 0"}}})))((e=>{const[t,a]=(0,n.useState)(!1),{classes:s,propStyles:i,whatsappNumberLinked:r,assistantDetails:l,agentDetails:d,isPageSelected:c,adSetupDetails:p,isFbConnected:u,isWhatsappLinked:m,isSetupCompleted:g,adsDashboardConfig:b}=e,{currency:y,providerType:x,wabaProgressStep:f,fbManagerVerified:A,aggCreditUsage:I=0,isWhatsappVerified:C,aggCreditRecharged:_=0,fbConnected:S,selectedMetaPageId:v}=l,E=(["verified","VERIFIED"].includes(A),(0,o.useMediaQuery)("(max-width:600px)"));return(0,h.jsx)(o.Grid,{item:!0,xs:12,style:{paddingBottom:0},children:(0,h.jsxs)(o.Box,{borderRadius:"8px",className:s.root,boxShadow:"0 0 11px rgb(230,230,230)",children:[(0,h.jsxs)(o.Grid,{style:{padding:"1.5rem 0rem 1.5rem 1.5rem"},children:[(0,h.jsx)(o.Typography,{style:{color:"#3F4155",fontFamily:"Roboto",fontSize:"18px",fontWeight:600,lineHeight:"26px"},children:"Run Ads & Grow Your Business for Free! ✨"}
1),(0,h.jsxs)(o.Grid,{className:s.wccDetails,style:{width:E?"100%":"80%",marginTop:"0.5rem",padding:E?"0px":"0px 12px 12px 0px",background:"rgba(255, 255, 255, 0.1)"},children:[(0,h.jsx)(o.Typography,{className:s.subTitle,children:"Try our new Ads Manager and run ads to get leads on your WhatsApp! No approvals required."}),(0,h.jsxs)("div",{style:{display:"flex",gap:"32px"},children:[(0,h.jsx)(o.Link,{color:"primary",href:b?.tutorialDoc?b?.tutorialDoc:"https://vyaparapp.in/resources/click-to-whatsapp-ads-on-vyapar",target:"_blank",onClick:async()=>{await ht({triggerEvent:"Clicked on How to setup CTWA",triggerNote:"Clicked How to setup CTWA",relatedProspectId:l?.prospectId,activityCode:214})},children:(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"normal",style:{marginTop:"12px",gap:"4px"},children:[(0,h.jsx)(ao.A,{size:16,style:{color:"#0075E8"}}),(0,h.jsx)(o.Typography,{className:s.linkText,children:"How to setup Ads Manager?"})]})}),(0,h.jsx)(o.Link,{color:"primary",href:b?.tutorialVideo?b?.tutorialVideo:"https://youtu.be/Rv1RI9fanLY",target:"_blank",onClick:async()=>{await ht({triggerEvent:"Clicked on Video How to setup CTWA",triggerNote:"Clicked  Video How to setup CTWA",relatedProspectId:l?.prospectId,activityCode:214})},children:(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"normal",style:{marginTop:"12px",gap:"4px"},children:[(0,h.jsx)(no.A,{size:16,style:{color:"#0075E8"}}),(0,h.jsx)(o.Typography,{className:s.linkText,children:"Watch Video"})]})})]})]}),(0,h.jsxs)(o.Grid,{container:!0,spacing:3,className:s.info,children:[void 0===g&&(0,h.jsxs)(o.Box,{className:s.shimmerContainer,children:[(0,h.jsx)(o.Box,{className:s.shimmerLine,style:{width:"60%"}}),(0,h.jsx)(o.Box,{className:s.shimmerLine,style:{width:"80%"}}),(0,h.jsx)(o.Box,{className:s.shimmerLine,style:{width:"100%"}})]}),void 0!==g&&Js.map(((e,t)=>{let a=(e=>{switch(e){case"Connect Your FB Account":return u?100:0;case"Select your Ads Page":return u&&c?100:0;case"Link WhatsApp Number":return m&&u?100:0;case"Run Ads & Get Leads on WhatsApp":return m&&g?100:0;default:return 0}})(e),n=100===a,i=3===t?"":`STEP ${t+1}:`,r=n?qs:Xs,l={color:"#71748E"};return"Spend 500 WCC"===e&&"INR"!==y&&(e="Spend 6 WCC"),"Run Ads & Get Leads on WhatsApp"===e&&(r=$s,n?(i="",l={color:"#FFC022"}):e="Run Ads & Get Leads on WhatsApp"),(0,h.jsxs)(o.Grid,{item:!0,className:s.stepContainer,style:{opacity:1,paddingRight:0,paddingLeft:0,zIndex:1},children:[(0,h.jsxs)(o.Grid,{className:s.infographic,children:[(0,h.jsx)("img",{src:r,alt:"Reward Check",className:s.progressStatusIcon,style:{width:E?"1.25rem":r===$s?"2.5rem":"2rem",height:E?"1.25rem":"2rem"}}),!["You've Won ₹500 Ad Credits","Run Ads & Get Leads on WhatsApp"].includes(e)&&(0,h.jsx)(o.Grid,{className:s.progressBar,children:(0,h.jsx)("img",{src:Qs,alt:"progress arrow"})})]}),(0,h.jsxs)(o.Grid,{style:{display:"flex"},children:[(0,h.jsx)(o.Typography,{style:l,className:s.stepDetail,children:i}),(0,h.jsx)(o.Typography,{className:s.stepDetail,style:{color:3===t?"#FF8A00":"#ED1A3B",marginLeft:3===t?"0px":"8px",visibility:"initial"},children:3===t?"CONGRATULATIONS":!n&&"PENDING"})]}),(0,h.jsx)(o.Typography,{className:s.stepName,children:e})]},t)}))]}),!1]}),b?.rewardBannerImage?(0,h.jsx)(o.Grid,{style:{maxWidth:"336px"},children:(0,h.jsx)("img",{src:b?.rewardBannerImage,alt:"dashboard background banner",className:s.rewardBannerImage})}):(0,h.jsxs)(o.Grid,{style:{position:"relative"},children:[(0,h.jsx)("img",{src:to,alt:"gold coins",className:s.goldCoins}),(0,h.jsx)("img",{src:eo,alt:"dashboard background banner",className:s.dashboadBannerBackground})]})]})})}));function oo(e){let{assistantDetails:t,agent:a,pageValue:n,adAccountSetupCompleted:s}=e;return(0,h.jsx)(o.Grid,{container:!0,justify:"center",alignItems:"center",style:{background:"rgb(247 247 247)"},children:(0,h.jsx)(o.Grid,{item:!0,xs:12,md:11,lg:11,children:(0,h.jsx)(o.Box,{mt:3,mb:3,width:"100%",children:t?.fbConnected&&(n?.whatsappNumber||s)?(0,h.jsx)(Qt,{mt:0,mb:0}):(0,h.jsx)(B,{name:"adCreditReward",fallback:L()?(0,h.jsx)(so,{propStyles:{background:"#02545A"},whatsappNumberLinked:n?.whatsappNumber,assistantDetails:t,agentDetails:a}):null,propStyles:{background:"#02545A"},whatsappNumberLinked:n?.whatsappNumber,assistantDetails:t,agentDetails:a})})})})}var io=a(3633);const ro=e=>`metaAdSetup:${e}`;class lo extends n.Component{constructor(e){const{fbConnected:t,selectedMetaAdAccountId:a,assistantId:n}=e.assistantDetails;super(e);const s=(e=>{if(!e)return null;try{const t=window.localStorage.getItem(ro(e));if(!t)return null;const a=JSON.parse(t);return a&&"number"==typeof a.ts&&a.data?Date.now()-a.ts>18e5?(window.localStorage.removeItem(ro(e)),null):a.data:null}catch(e){return null}})(n)||{};this.state={tab:t&&a?"system":"setup",sticky:!1,fbaccount:s.fbaccount||[],fbpages:s.fbpages||[],accountValue:s.accountValue||{},pageValue:s.pageValue||{},isSyncing:!1,isLoading:!1,snack:{},linkAd:!1,templatedialogOpen:!1,selectedMetaPageId:void 0!==s.selectedMetaPageId?s.selectedMetaPageId:null,adAccountSetupCompleted:s.adAccountSetupCompleted||!1}}persistSetupCache=()=>{const{assistantId:e}=this.props?.assistantDetails||{},{fbaccount:t,fbpages:a,accountValue:n,pageValue:s,selectedMetaPageId:o,adAccountSetupCompleted:i}=this.state;((e,t)=>{if(e&&t)try{window.localStorage.setItem(ro(e),JSON.stringify({ts:Date.now(),data:t}))}catch(e){}})(e,{fbaccount:t,fbpages:a,accountValue:n,pageValue:s,selectedMetaPageId:o,adAccountSetupCompleted:i})};rootEle=(()=>s().createRef())();toggleTemplateCreditDialog=()=>{this.setState({templatedialogOpen:!this.state.templatedialogOpen})};sortByBusinessName=e=>e.sort((function(e,t){return e.metaBusinessName<t.metaBusinessName?-1:e.metaBusinessName>t.metaBusinessName?1:0}));componentDidMount=()=>{const{assistantDetails:e}=this.props,{assistantId:t,fbConnected:a}=e||{};a&&t&&this.fetchMetaAdAccount(t)};componentDidUpdate(e){const t=this.props.assistantDetails||{};t.fbConnected&&t.assistantId&&this.fetchedForAssistant!==t.assistantId&&this.setupFetchFailedFor!==t.assistantId&&!this.setupFetchInFlight&&this.fetchMetaAdAccount(t.assistantId)}componentWillUnmount(){this.setupRetryTimer&&clearTimeout(this.setupRetryTimer),this.cancelTokenSource&&this.cancelTokenSource.cancel("Operation canceled due to component unmounting."),this.cancelTokenMetaAdAccount&&this.cancelTokenMetaAdAccount.cancel("Operation canceled due to component unmounting.")}fetchedForAssistant=null;setupFetchFailedFor=null;setupFetchInFlight=!1;setupRetryTimer=null;fetchMetaAdAccount=(()=>{var e=this;return async function(t){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!e.setupFetchInFlight){e.setupFetchInFlight=!0,e.cancelTokenMetaAdAccount=(0,io.A)();
1try{const a=await e.props.loadMetaAdSetup(t,{cancelToken:e.cancelTokenMetaAdAccount.token}),{assistantId:n}=e.props.assistantDetails||{};if(n&&n!==t)return void(e.setupFetchInFlight=!1);const s=a.raw,{isValid:o,pageId:i,adAccountId:r}=a,l="boolean"==typeof s.isAdAccountSetupCompleted?s.isAdAccountSetupCompleted:Boolean(o&&i&&r);e.fetchedForAssistant=t,e.setupFetchFailedFor=null,e.setState({adAccountSetupCompleted:l,selectedMetaPageId:i},e.persistSetupCache),e.props.updateAssistantStore({fbConnected:o,selectedMetaPageId:o?i:"",selectedMetaAdAccountId:o?r:""}),e.props.updateAdSetupStore({fbConnected:o,selectedMetaPageId:o?i:"",selectedMetaAdAccountId:o?r:""})}catch(n){if((0,io.F)(n))return void(e.setupFetchInFlight=!1);const s=n?.response?.status;if((!s||s>=500)&&a<2)return void(e.setupRetryTimer=setTimeout((()=>{e.setupFetchInFlight=!1,e.fetchMetaAdAccount(t,a+1)}),1500*(a+1)));e.setupFetchInFlight=!1,console.log({error:n}),e.setupFetchFailedFor=t,e.setState({snack:{open:!0,severity:"error",message:n?.response?.data?.message||"Couldn't load your Facebook connection details. Please refresh the page."}})}e.setupFetchInFlight=!1,e.getFbAcc(t),e.getFbPages(t)}}})();removeSelectedMetaPage=()=>{this.setState({selectedMetaPageId:null})};updateWhatsappNumber=e=>{const t=this.state.fbpages.map((t=>(t.pageId===this.state.pageValue?.pageId&&(t.whatsappNumber=e),t)));this.setState({pageValue:{...this.state.pageValue,whatsappNumber:e},fbpages:t},this.persistSetupCache)};switchTab=e=>{this.setState({tab:e})};listScrolled=e=>{if(!this.offsetPosition){const e=this.rootEle&&this.rootEle.current;if(!e)return;this.offsetPosition=e.offsetTop}const t=e.currentTarget.scrollTop;this.setState({sticky:t>this.offsetPosition-59})};modifyList=(e,t)=>{const{freezedMetaPageId:a,freezedMetaAdAccountId:n}=this.props?.assistantDetails;return(0,ts.isEmpty)(e)?[]:e?.map((e=>{const{metaBusinessId:s,isAssigned:o,pageId:i,accountId:r}=e||{};let l=!1;i&&""!==t?l=i===(t=t||a):r&&""!==t&&(l=r===(t=t||n));let d="Limited";return o?d="Assigned":s||(d="Personal"),{...e,tag:d,freezed:l}}))};cancelTokenSource=null;cancelTokenMetaAdAccount=null;getFbPages=e=>{this.cancelTokenSource=(0,io.A)(),e&&(this.setState({isLoading:!0}),this.props.loadPages(e,{cancelToken:this.cancelTokenSource.token}).then((e=>{const{selectedMetaPageId:t,freezedMetaPageId:a,freezedMetaAdAccountId:n,fbConnectedBy:s}=this.props?.assistantDetails,{id:o}=this.props.agent||{},i=this.modifyList(e);this.setState({fbpages:i,isLoading:!1},(()=>{if(s&&s!==o&&n){const t=a?e?.find((e=>{let{pageId:t}=e;return t===a})):{};this.setState({pageValue:t},this.persistSetupCache)}else if(t){const a=e?.find((e=>{let{pageId:a}=e;return a===t}));this.setState({pageValue:a},this.persistSetupCache)}else this.persistSetupCache()}))})).catch((e=>{console.log("error:",e),this.setState({isLoading:!1})})))};getFbAcc=e=>{e&&(this.setState({isLoading:!0}),this.props.loadAdAccounts(e).then((e=>{const{selectedMetaAdAccountId:t,freezedMetaAdAccountId:a,fbConnectedBy:n}=this.props.assistantDetails||{},{id:s}=this.props.agent||{},o=this.modifyList(e);console.log({filteredAccounts:o,selectedMetaAdAccountId:t}),this.setState({fbaccount:o,isLoading:!1},(()=>{if(n&&n!==s&&a){const t=e?.find((e=>{let{isChildBMAdAccount:t}=e;return t}));this.setState({accountValue:t},this.persistSetupCache)}else if(t){const a=e?.find((e=>{let{accountId:a}=e;return a===t}));this.setState({accountValue:a},this.persistSetupCache)}else this.persistSetupCache()}))})).catch((e=>{console.log("error:",e),this.setState({isLoading:!1})})))};saveAdProfile=(e,t)=>{const{assistantId:a}=this.props?.assistantDetails;(0,ts.isEmpty)(e)||(0,ts.isEmpty)(t)||this.props.saveAdProfile({assistantId:a,selectedMetaAdAccountId:e.accountId,selectedMetaPageId:t.pageId}).then((()=>{})).catch((e=>console.log("error:",e)))};selectAdAccount=e=>{this.setState({accountValue:e},this.persistSetupCache),this.props.updateAssistantStore({selectedMetaAdAccountId:e.accountId})};selectPage=e=>{this.setState({pageValue:e},(()=>{this.persistSetupCache();const{freezedMetaAdAccountId:t,fbConnectedBy:a}=this.props?.assistantDetails,{id:n}=this.props?.agent;if(!a||a===n||!t){const{accountValue:t}=this.state;this.props.updateAssistantStore({selectedMetaPageId:e.pageId}),this.saveAdProfile(t,e)}}))};updateStateValue=e=>{this.setState(e)};syncMetaAcc=e=>{const{fbConnected:t,assistantId:a}=this.props.assistantDetails,{accountValue:n}=this.state,s=n?.accountId;t&&s&&a&&(this.setState({isSyncing:!0}),this.props.syncMetaAdAccount({assistantId:a,adAccountId:s,mode:e}).then((e=>{const{adAccountData:t,message:a}=e||{};this.setState({isSyncing:!1,accountValue:t})})).catch((e=>{console.log("error:",e);const{action:t,message:a,assistant:n}=e?.response?.data||{};if("reconnect"===t&&n){const{fbConnected:e,fbUserId:t,fbGrantedScopes:s,selectedMetaPageId:o,selectedMetaAdAccountId:i,freezedMetaAdAccountId:r,freezedMetaPageId:l}=n||{};this.props.updateAssistantStore({fbConnected:e,fbUserId:t,fbGrantedScopes:s,selectedMetaPageId:o,selectedMetaAdAccountId:i,freezedMetaAdAccountId:r,freezedMetaPageId:l}),this.setState({snack:{open:!0,severity:"error",message:a||"Session expired, Please re-connect Facebook"},isSyncing:!1,tab:"setup",accountValue:{},pageValue:{},fbaccount:[],fbpages:[]})}else this.setState({isSyncing:!1,snack:{open:!0,severity:"error",message:e?.response?.data?.message||"Something went wrong"}})}))),this.props.fetchAssistantDetails(a,!0)};closeLinkAdDialog=()=>{this.setState({linkAd:!1}
1)};render(){const{classes:e}=this.props,{projectId:t}=this.props.match.params,{tab:a,pageValue:n,accountValue:s,fbaccount:i,snack:r,linkAd:l}=this.state,{whatsappNumber:d,fbConnected:c,fbConnectedBy:p,freezedMetaAdAccountId:u,partnerId:m,metaAdsCredit:g,freeTierCoversationCount:b,currency:y,ongoingBillingProcess:x,cbpType:f,allowPurchase:A,pendingInvoices:I,providerType:C,autoWccRecharge:_}=this.props.assistantDetails,{id:S,power:v}=this.props.agent;window.innerWidth,window.innerWidth;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:`${e.root} ginger-page-root`,onScroll:this.listScrolled,children:[(0,h.jsx)(Ks,{classes:e,sticky:this.state.sticky,fbConnected:c,accountValue:s,pageValue:n,power:v,partnerId:m,cbpType:f,allowPurchase:A,ongoingBillingProcess:x,pendingInvoices:I,assistantDetails:this.props.assistantDetails,onLinkAd:()=>this.setState({linkAd:!0}),onBuyCredits:this.toggleTemplateCreditDialog}),(0,h.jsx)(oo,{assistantDetails:this.props.assistantDetails,agent:this.props.agent,pageValue:n,adAccountSetupCompleted:this.state.adAccountSetupCompleted}),L()&&(0,h.jsx)(cs,{onBuyCredits:this.toggleTemplateCreditDialog}),(0,h.jsx)(o.Grid,{container:!0,justify:"center",alignItems:"center",children:(0,h.jsx)("div",{className:`${e.detailContainer} `,children:(0,h.jsx)(o.Box,{children:(0,h.jsx)(Ys,{updateWhatsappNumber:this.updateWhatsappNumber,updateStateValue:this.updateStateValue,selectAdAccount:this.selectAdAccount,selectPage:this.selectPage,getFbPages:this.getFbPages,getFbAcc:this.getFbAcc,modifyList:this.modifyList,fbaccount:this.state.fbaccount,fbpages:this.state.fbpages,accountValue:this.state.accountValue,pageValue:this.state.pageValue,syncMetaAcc:this.syncMetaAcc,selectedMetaPageId:this.state.selectedMetaPageId,removeSelectedMetaPage:this.removeSelectedMetaPage})})})}),r.open&&(0,h.jsx)(o.Snackbar,{open:r.open,onClose:()=>{this.setState({snack:{}})},anchorOrigin:{vertical:"top",horizontal:"center"},autoHideDuration:3e3,children:(0,h.jsx)(O.Alert,{severity:r.severity,onClose:()=>{this.setState({snack:{}})},children:r.message})}),l&&(0,h.jsx)(ps,{open:l,onClose:this.closeLinkAdDialog})]}),(0,h.jsx)(B,{name:"metaAdsCreditDialog",dialogOpen:this.state.templatedialogOpen,toggleTemplateCreditDialog:this.toggleTemplateCreditDialog,assistantDetails:this.props.assistantDetails,fallback:(0,h.jsx)(ds,{dialogOpen:this.state.templatedialogOpen,toggleTemplateCreditDialog:this.toggleTemplateCreditDialog})})]})}}const co=(0,i.connect)((e=>({assistantDetails:e.assistantDetails.data,agent:e.login.user})),{updateAssistantStore:$.nt,fetchAssistantDetails:$.lq,updateAdSetupStore:$.jW,loadPages:M.VJ,loadAdAccounts:M.ae,loadMetaAdSetup:M.cg,saveAdProfile:M.KT,syncMetaAdAccount:M.ZM})(lo),po=(0,o.withStyles)((e=>({root:{width:"100%",height:"100%",background:"rgb(247, 247, 247)",boxSizing:"border-box",overflowX:"hidden",position:"relative"},pageTitleContainer:{position:"sticky",zIndex:100,top:0,height:60,boxSizing:"border-box",boxShadow:"0 0 11px rgb(230 230 230)",[e.breakpoints.down("md")]:{},[e.breakpoints.down("sm")]:{},[e.breakpoints.down("xs")]:{height:"fit-content"}},tabs:{fontSize:"14px",textTransform:"none",borderBottom:"2px solid #f0f0f0"},tabs2:{fontSize:"14px",textTransform:"none",borderBottom:"2px solid #f0f0f0"},guideContainer:{background:"white",borderRadius:"8px"},tabIndicator:{borderRadius:"0px 0px 0px 0px",height:3},tabPageTitleContainer:{position:"sticky",zIndex:100,top:0,height:124,boxShadow:"0 0 12px rgb(171 170 170)",boxSizing:"border-box"},detailContainer:{top:"60px",minHeight:"250px",height:"calc(100vh - 260px)",width:"100%",boxSizing:"border-box",[e.breakpoints.down("sm")]:{height:"calc(100vh - 70px - 50px - 10px - 50px)",paddingLeft:e.spacing(1),paddingRight:e.spacing(1),boxSizing:"border-box"}},autoComplete:{'& [class*=MuiAutocomplete-option][aria-disabled="true"]':{pointerEvents:"inherit",background:"white"},'& [class*=MuiAutocomplete-option][aria-disabled="true"]:active':{pointerEvents:"none",background:"white"}},textField:{width:200,padding:"2px 16px"},arrow:{color:"white"},fullWidth:{width:"100%",background:"white"},betaBadge:{color:"white",fontWeight:"600",marginLeft:"0.4em",height:"1.5em",alignItems:"center",fontSize:"0.7em"},searchboxContainer:{transition:"all 0.2s",position:"sticky",top:60,zIndex:50},textFieldRootAutocomplete:{width:"18em",[e.breakpoints.down("xs")]:{width:"14em"}},launchButton:{[e.breakpoints.down("sm")]:{padding:"4px 10px",fontSize:"0.8125rem"}},walletIcon:{width:"24px",height:"24px"},buttonContainer:{display:"flex",justifyContent:"space-between",gap:"1em",alignItems:"center",[e.breakpoints.down("xs")]:{marginTop:"12px",marginBottom:"4px",width:"100%",justifyContent:"space-between"}},buyCreditsButtonContainer:{width:"fit-content",[e.breakpoints.down("xs")]:{width:"100%"}}
1,buyCreditsButton:{marginLeft:"16px",padding:"6px 16px",fontSize:"14px",[e.breakpoints.down("sm")]:{marginLeft:"8px",padding:"4px 10px",fontSize:"0.8125rem",width:"100%"}}})))(co);var uo=a(27671),mo=a(5243);const ho={fontFamily:{primary:"Inter, sans-serif",secondary:"Roboto, sans-serif"},fontSize:{xsmall:12,small:14,medium:16,large:20,xlarge:25},fontWeight:{regular:400,medium:500,bold:700},lineHeight:{tight:1.2,normal:1.5,relaxed:1.75},letterSpacing:{normal:0,wide:1}},go={xs:0,sm:767,md:959,lg:1599,xl:1920},bo={colors:{primary:{main:"#0a474c",light:"#ebf5f3"},secondary:{main:"#fec000"},success:{main:"#4caf50",complete:"#388e3c",usageCapOk:"#1C7A5B",quotaLow:"#30a46c"},warning:{main:"#FFC260",quotaMedium:"#e2a73e"},error:{main:"#f44336",exceeded:"#FF0000",usageCapReached:"#D24A40",quotaHigh:"#e5484d"},info:{main:"#9013FE"},pending:{main:"#e65100"},resolved:{main:"#388e3c"},text:{primary:"#4A4A4A",secondary:"#6E6E6E",hint:"#B9B9B9",strong:"#222222"},background:{default:"#F6F7FF",light:"#F3F5FF",backdrop:"#f6f7ff"},surface:{default:"#ffffff",input:"rgb(240,240,240)",inputHover:"rgb(232,232,232)",inputDisabled:"rgb(246,246,246)",inputWhite:"#ffffff",inputWhiteHover:"rgb(250,250,250)",chip:"rgb(224,224,224)",chipHover:"rgb(214,214,214)"},border:{default:"#e0e0e0"},track:{aiTrialMeter:"#e3e6ff",usageCap:"#EDEFEE",quotaRamp:"rgba(0,0,0,0.08)",answerDistribution:"#F0F0F0"},common:{white:"#ffffff",black:"#000000"}},spacing:{none:0,xxsmall:4,xsmall:8,small:12,medium:16,large:24,xlarge:32,xxlarge:40,xxxlarge:48},radii:{none:0,small:4,medium:6,large:8,xlarge:12,pill:999,circle:"50%"},typography:ho,shadows:{none:"none",small:"0 0 11px rgb(230,230,230)"},zIndex:{base:0,dropdown:1e3,sticky:1100,modal:1300,tooltip:1500,snackbar:3400,popper:1e4},breakpoints:go,field:{paddingY:1,paddingX:4,innerPadding:12,menuRowHeight:36,menuVisibleRows:8,menuRowPaddingY:6,fontSize:ho.fontSize.small,fontWeight:ho.fontWeight.medium}},yo={error:bo.colors.error.exceeded,success:bo.colors.success.complete,aiTrialExceeded:bo.colors.error.main,usageCapOk:bo.colors.success.usageCapOk,usageCapReached:bo.colors.error.usageCapReached,quotaLow:bo.colors.success.quotaLow,quotaMedium:bo.colors.warning.quotaMedium,quotaHigh:bo.colors.error.quotaHigh},xo={trial:{background:bo.colors.track.aiTrialMeter,borderRadius:bo.radii.small,marginTop:bo.spacing.none,marginBottom:bo.spacing.large},usageCap:{background:bo.colors.track.usageCap,borderRadius:bo.radii.medium,marginTop:bo.spacing.none,marginBottom:bo.spacing.none},quotaRamp:{background:bo.colors.track.quotaRamp,borderRadius:bo.radii.pill,marginTop:bo.spacing.none,marginBottom:bo.spacing.none},answerDistribution:{background:bo.colors.track.answerDistribution,borderRadius:bo.radii.small,marginTop:bo.spacing.none,marginBottom:bo.spacing.none}},fo=Object.fromEntries(Object.entries({aiTrialMeter:"trial",aiTrialExceeded:"trial",usageCapOk:"usageCap",usageCapReached:"usageCap",quotaLow:"quotaRamp",quotaMedium:"quotaRamp",quotaHigh:"quotaRamp",answerDistribution:"answerDistribution"}).map((e=>{let[t,a]=e;return[t,xo[a]]}))),Ao=(0,_e.makeStyles)((()=>{return{root:{'& .MuiLinearProgress-bar, & [class*="MuiLinearProgress-bar-"]':{backgroundColor:e=>{let{status:t}=e;return yo[t]}},backgroundColor:e=>{let{status:t}=e;return fo[t]?.background},borderRadius:e=>{let{status:t}=e;return fo[t]?.borderRadius},marginTop:e=>{let{status:t}=e;return fo[t]?.marginTop??"10px"},marginBottom:e=>{let{status:t}=e;return fo[t]?.marginBottom??"10px"}},sizeSmall:{height:(e=.75,4*e),borderRadius:bo.radii.none},sizeLarge:{height:bo.spacing.xsmall},sizeXLarge:{height:bo.spacing.medium}};var e})),Io={className:"Wrap the component and put the class on the wrapper.",style:"Wrap the component and position the wrapper.",classes:"Reaches inside the component. Ask for a named prop instead.",sx:"Not supported. Ask for a named prop instead."},Co=["style","classes","sx"],_o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t={},a=[];return Object.keys(e).forEach((n=>{void 0===Io[n]||void 0===e[n]?t[n]=((e,t,a,n)=>{if(!e||"object"!=typeof e||Array.isArray(e))return e;if(!/Props$/i.test(t))return e;let s=!1;const o={};return Object.keys(e).forEach((a=>{-1!==Co.indexOf(a)&&void 0!==e[a]?(s=!0,n.push(`${t}.${a}`)):o[a]=e[a]}
1)),s?o:e})(e[n],n,0,a):a.push(n)})),t},So=e=>{let{value:t,variant:a,valueBuffer:n,color:s,status:i,size:r,...l}=e;const d=Ao({status:i,size:r}),c="small"===r?d.sizeSmall:"large"===r?d.sizeLarge:"xlarge"===r?d.sizeXLarge:null;return(0,h.jsx)(o.LinearProgress,{className:[d.root,c].filter(Boolean).join(" "),value:t,variant:a,valueBuffer:n,color:s,..._o(l,"ProgressBar")})};So.propTypes={value:He().number,variant:He().oneOf(["determinate","indeterminate","buffer","query"]),valueBuffer:He().number,color:He().oneOf(["primary","secondary"]),status:He().oneOf(["default","error","success","aiTrialMeter","aiTrialExceeded","usageCapOk","usageCapReached","quotaLow","quotaMedium","quotaHigh","answerDistribution"]),size:He().oneOf(["small","medium","large","xlarge"])},So.defaultProps={value:0,variant:"determinate",valueBuffer:void 0,color:"primary",status:"default",size:"medium"};const vo=So;var Eo;function To(){return To=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},To.apply(null,arguments)}function Do(e){return n.createElement("svg",To({xmlns:"http://www.w3.org/2000/svg",height:24,viewBox:"0 -960 960 960",width:24,fill:"#e8eaed"},e),Eo||(Eo=n.createElement("path",{d:"M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360zm0-80h360v-480H360v480zM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200zm160-240v-480 480z"})))}a.p;var wo=a(23800);const No=(0,o.styled)(o.Switch)((e=>{let{theme:t}=e;return{width:40,height:20,padding:0,display:"flex","&:active":{'& .MuiSwitch-thumb, & [class*="MuiSwitch-thumb-"]':{width:18},'& .MuiSwitch-switchBase.Mui-checked, & [class*="MuiSwitch-switchBase-"].Mui-checked':{transform:"translateX(14px)"}},'& .MuiSwitch-switchBase, & [class*="MuiSwitch-switchBase-"]':{padding:2,"&.Mui-checked":{transform:"translateX(20px)",color:"#fff",'& + .MuiSwitch-track, & + [class*="MuiSwitch-track-"]':{opacity:1,backgroundColor:"#2ECA45"}}},'& .MuiSwitch-thumb, & [class*="MuiSwitch-thumb-"]':{boxShadow:"0 2px 4px 0 rgb(0 35 11 / 20%)",width:16,height:16,borderRadius:8},'& .MuiSwitch-track, & [class*="MuiSwitch-track-"]':{borderRadius:10,opacity:1,backgroundColor:"dark"===t.palette.type?"rgba(255,255,255,.35)":"rgba(0,0,0,.25)",boxSizing:"border-box"}}})),jo=(0,o.makeStyles)((e=>({tableContainer:{width:"100%",overflow:"hidden",backgroundColor:"white",borderRadius:"8px"},scrollContainer:{overflowX:"auto",overflowY:"auto",maxHeight:"calc(100vh - 350px)",minHeight:400,"&::-webkit-scrollbar":{height:3,width:3},"&::-webkit-scrollbar-track":{backgroundColor:"#f1f1f1",borderRadius:3},"&::-webkit-scrollbar-thumb":{backgroundColor:"#c1c1c1",borderRadius:3,"&:hover":{backgroundColor:"#a8a8a8"}}},table:{minWidth:1200},stickyHeader:{backgroundColor:"white",position:"sticky",height:"52px",top:0,zIndex:12,"& th":{position:"sticky",top:0,fontWeight:600,fontSize:"12px",color:e.palette.text.secondary,borderBottom:`1px solid ${e.palette.divider}`,backgroundColor:"white"}},stickyCellOffOn:{position:"sticky",left:0,zIndex:10,backgroundColor:"white"},stickyCellAd:{position:"sticky",left:166,zIndex:10,backgroundColor:"white"},stickyHeaderCellOffOn:{position:"sticky",left:0,zIndex:11,backgroundColor:"white"},stickyHeaderCellAd:{position:"sticky",left:166,zIndex:11,backgroundColor:"white"},tableRow:{"&:hover":{"& $stickyCellOffOn":{backgroundColor:"white"},"& $stickyCellAd":{backgroundColor:"white"}}},emptyStateContainer:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:300,padding:e.spacing(4),position:"sticky",left:"50%",transform:"translateX(-50%)",width:"fit-content"},cellContent:{display:"flex",alignItems:"center",gap:e.spacing(1)},adCell:{display:"flex",alignItems:"flex-start",gap:e.spacing(1.5),maxWidth:250,position:"relative",opacity:1,visibility:"visible"},adCellContent:{display:"flex",flexDirection:"column",flex:1,gap:e.spacing(.5),minWidth:0,minHeight:"40px"},thumbnail:{width:40,height:40,borderRadius:4,objectFit:"cover",flexShrink:0},adName:{fontSize:"14px",fontWeight:400,color:e.palette.text.primary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:200},actionButtons:{display:"flex",alignItems:"center",gap:e.spacing(.5),marginTop:e.spacing(.5),opacity:1,visibility:"visible"},statusChip:{height:20,fontSize:"11px",fontWeight:500},statusLearning:{backgroundColor:"#E8F5E9",color:"#2E7D32"},statusOff:{backgroundColor:"#F5F5F5",color:"#616161"},statusDraft:{backgroundColor:"#FFF3E0",color:"#E65100"},statusError:{backgroundColor:"#FFEBEE",color:"#C62828"},deliveryIndicator:{width:8,height:8,borderRadius:"50%",marginRight:e.spacing(1),display:"inline-block"},indicatorGreen:{backgroundColor:"#4CAF50"},indicatorGrey:{backgroundColor:"#9E9E9E"},indicatorRed:{backgroundColor:"#F44336"},currency:{fontFamily:"Roboto, sans-serif",fontSize:"14px"},number:{fontSize:"14px"},recommendationBadge:{display:"inline-flex",alignItems:"center",gap:e.spacing(.5),fontSize:"12px",color:e.palette.primary.main},carouselChip:{backgroundColor:(0,ea.j5)(e.palette.primary.main,.08),color:e.palette.primary.main},carouselIcon:{color:e.palette.primary.main},toggleContainer:{display:"flex",alignItems:"center",gap:e.spacing(1)},checkboxContainer:{display:"flex",alignItems:"center"},loadingBarContainer:{position:"sticky",top:0,left:"0px",right:"0px",zIndex:13,backgroundColor:"white",borderBottom:`1px solid ${e.palette.divider}`,width:"100%"}}))),ko=[{id:"offOn",label:"Actions",minWidth:150,align:"left"},{id:"ad",label:"Ad Name",maxWidth:250,align:"left"},{id:"startDate",label:"Start Date",minWidth:200,align:"left"},{id:"delivery",label:"Status",minWidth:150,align:"left"},{id:"adType",label:"Ad Type",minWidth:150,align:"left"},{id:"dailyBudget",label:"Daily Budget",minWidth:120,align:"left"}],Lo=[{id:"impressions",maxWidth:200,align:"right",label:"Impressions"},{id:"reach",maxWidth:200,align:"right",label:"Reach"},{id:"frequency",maxWidth:200,align:"right",label:"Frequency"},{id:"clicks",maxWidth:200,align:"right",label:"Clicks"},{id:"unique_clicks",minWidth:200,align:"right",label:"Unique Clicks"},{id:"inline_link_clicks",minWidth:200,align:"right",label:"Inline Link Clicks"},{id:"ctr",minWidth:200,align:"right",label:"CTR (%)"},{id:"spend",minWidth:200,align:"right",label:"Spend",isCurrency:!0},{id:"cpc",minWidth:200,align:"right",label:"CPC",isCurrency:!0},{id:"cpm",minWidth:200,align:"right",label:"CPM",isCurrency:!0},{id:"quality_ranking",minWidth:200,align:"right",label:"Quality Ranking"},{id:"engagement_rate_ranking",minWidth:200,align:"right",label:"Engagement Rate Ranking"},{id:"outbound_clicks.outbound_click",minWidth:200,align:"right",label:"Outbound Click"},{id:"actions.link_click",minWidth:200,align:"right",label:"Link Click"},{id:"actions.omni_add_to_cart",minWidth:200,align:"right",label:"Omni Add To Cart"},{id:"actions.page_engagement",minWidth:200,align:"right",label:"Page Engagement"},{id:"actions.landing_page_view",minWidth:200,align:"right",label:"Landing Page View"},{id:"actions.add_to_cart",minWidth:200,align:"right",label:"Add To Cart"},{id:"actions.omni_landing_page_view",minWidth:200,align:"right",label:"Omni Landing Page View"},{id:"actions.onsite_web_app_add_to_cart",minWidth:200,align:"right",label:"Onsite Web App Add To Cart"},{id:"actions.onsite_web_view_content",minWidth:200,align:"right",label:"Onsite Web View Content"},{id:"actions.onsite_web_add_to_cart",minWidth:200,align:"right",label:"Onsite Web Add To Cart"},{id:"actions.post_engagement",minWidth:200,align:"right",label:"Post Engagement"},{id:"actions.post_interaction_gross",minWidth:200,align:"right",label:"Post Interaction Gross"},{id:"actions.view_content",minWidth:200,align:"right",label:"View Content"},{id:"actions.post",minWidth:200,align:"right",label:"Post"},{id:"actions.onsite_conversion.post_save",minWidth:200,align:"right",label:"Onsite Conversion Post Save"},{id:"actions.onsite_conversion.post_net_like",minWidth:200,align:"right",label:"Onsite Conversion Post Net Like"},{id:"actions.onsite_conversion.post_net_save",minWidth:200,align:"right",label:"Onsite Conversion Post Net Save"},{id:"actions.onsite_web_app_view_content",minWidth:200,align:"right",label:"Onsite Web App View Content"},{id:"actions.offsite_content_view_add_meta_leads",minWidth:200,align:"right",label:"Offsite Content View Add Meta Leads"},{id:"actions.video_view",minWidth:200,align:"right",label:"Video View"},{id:"actions.omni_view_content",minWidth:200,align:"right",label:"Omni View Content"},{id:"actions.offsite_conversion.fb_pixel_view_content",minWidth:200,align:"right",label:"Offsite Conversion Fb Pixel View Content"},{id:"actions.offsite_conversion.fb_pixel_add_to_cart",minWidth:200,align:"right",label:"Offsite Conversion Fb Pixel Add To Cart"},{id:"actions.post_reaction",minWidth:200,align:"right",label:"Post Reaction"},{id:"video_p25_watched_actions.video_view",minWidth:200,align:"right",label:"Video 25% Watched"},{id:"video_p50_watched_actions.video_view",minWidth:200,align:"right",label:"Video 50% Watched"},{id:"video_p75_watched_actions.video_view",minWidth:200,align:"right",label:"Video 75% Watched"},{id:"video_p100_watched_actions.video_view",minWidth:200,align:"right",label:"Video 100% Watched"},{id:"video_play_actions.video_view",minWidth:200,align:"right",label:"Video Plays"},{id:"video_avg_time_watched_actions.video_view",minWidth:200,align:"right",label:"Video Avg Time Watched (sec)"},{id:"actions.onsite_conversion.messaging_conversation_started_7d",minWidth:200,align:"right",label:"Messaging conversations started"},{id:"results[0].values[0].value",minWidth:200,align:"right",label:"Results"},{id:"result_rate[0].values[0].value",minWidth:200,align:"right",label:"Result rate"},{id:"cost_per_result[0].values[0].value",minWidth:200,align:"right",label:"Cost Per Result"},{id:"purchase_roas[0].value",minWidth:200,align:"right",label:"Results ROAS"},{id:"results_value",minWidth:200,align:"right",label:"Results value"}],Ro=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"₹";const a=parseFloat(e);return Number.isNaN(a)?"-":`${t}
1${a.toLocaleString("en-IN",{minimumFractionDigits:2,maximumFractionDigits:2})}`},Bo=e=>{const t=parseFloat(e);return Number.isNaN(t)?"-":t.toLocaleString("en-IN")},Oo=e=>{const t=parseFloat(e);return Number.isNaN(t)?"-":t.toFixed(2)},Po=e=>{if(null==e)return"-";const t="string"==typeof e&&""!==e.trim()?Number(e):e;return"number"!=typeof t||Number.isNaN(t)?e:Number.isInteger(t)?t:t.toFixed(2)},Mo=["impressions","reach","clicks","spend","ctr","cpc","cpm"];function Uo(e){let{accountId:t,rows:a,onToggle:s,onActionClick:i,onCheckboxChange:l,onStatusToggle:c,initialPage:p=0,initialRowsPerPage:u=10,visibleColumns:m=Mo,currencySymbol:g="₹",isLoading:b=!1,projectId:y}=e;const[x,f]=n.useState(p),[A,I]=n.useState(u),[C,_]=n.useState(new Set),S=jo();n.useEffect((()=>{f(p),I(u)}),[p,u]);const v=null==a||b,E=a||[];console.log({length:E.length});const T=n.useMemo((()=>m.map((e=>Lo.find((t=>t.id===e)))).filter(Boolean)),[m]),D=n.useMemo((()=>T.filter((e=>!ko.find((t=>t.id===e.id))))),[T]),w=ko.length+D.length,N=(e,t)=>{i&&i(e,t)},k=(e,t)=>{const a={ACTIVE:"#28C152",PAUSED:"#FF8400",CAMPAIGN_PAUSED:"#FEC000",ADSET_PAUSED:"#EFA95E",IN_PROCESS:"#1E90FF",PENDING_REVIEW:"#8859E7",ARCHIVED:"#F25D55",COMPLETED:"#2E8B57",Learning:"#28C152",Off:"#9E9E9E","In draft":"#FF8400","Not delivering":"#F25D55","INSUFFICIENT CREDIT":"#F25D55",PREPARING:"#00B8D9"};switch(e.id){case"offOn":const n=c&&t.isEditable&&"DRAFT"!==t.adStatus,s=C.has(t.adId),i="ACTIVE"===t.adStatus&&!ea.$y.includes(t?.adEffectiveStatus);return(0,h.jsxs)(o.Box,{className:S.toggleContainer,children:[n&&(0,h.jsx)(o.Tooltip,{title:s?"Updating status...":i?"Turn off campaign":"Turn on campaign",children:(0,h.jsx)(o.Box,{style:{display:"flex",alignItems:"center",gap:4,minWidth:52},children:s?(0,h.jsx)(o.CircularProgress,{size:18,style:{margin:"0 11px"}}):(0,h.jsx)(No,{checked:i,onChange:async e=>{e.stopPropagation();const a=i?"PAUSED":"ACTIVE";_((e=>new Set([...e,t.adId])));try{await c(t,a)}finally{_((e=>{const a=new Set(e);return a.delete(t.adId),a}))}},color:"primary"})})}),"DRAFT"!=t.adStatus&&(0,h.jsx)(o.Tooltip,{title:"Ad Analytics",children:(0,h.jsx)(o.IconButton,{size:"small",disabled:"DRAFT"==t.adStatus,onClick:()=>N("charts",t.adId),children:(0,h.jsx)(d.BarChart,{})})}),(t.isEditable||"DRAFT"==t.adStatus)&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Tooltip,{title:"Edit",children:(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>N("edit",t.adId),children:(0,h.jsx)(d.Edit,{})})}),(0,h.jsx)(o.Tooltip,{title:"Duplicate Ad",children:(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>N("duplicate",t.adId),children:(0,h.jsx)(Do,{style:{fill:"#7a7a7a"}})})})]})]});case"ad":const l=t.thumbnail?(0,wo.replaceDomainInData)(t.thumbnail):t.imageUrl?(0,wo.replaceDomainInData)(t.imageUrl):null,p=l,u="carousel"===t.adFormat,m=Array.isArray(t.cards)?t.cards.length:0,b=(e=>{const t=(0,j._E)()?.basename;return t||(e?"/projects/"+e+"/advertisement":null)})(y);return(0,h.jsx)(o.Box,{className:S.adCell,style:{display:"flex",alignItems:"center"},children:(0,h.jsxs)(r.Link,{to:b&&t.adId?"DRAFT"===t.adStatus?`${b}/edit/${t.adId}`:`${b}/${t.adId}/personal-analytics`:"#",style:{display:"flex",alignItems:"center",textDecoration:"none",color:"inherit",width:"100%"},children:[p?(0,h.jsxs)(o.Box,{style:{position:"relative",width:"36px",height:"36px",flexShrink:0,marginRight:8},children:[(0,h.jsx)(o.Avatar,{src:l,alt:t.adName||"Ad thumbnail",variant:"rounded",style:{width:"36px",height:"36px",borderRadius:"4px"},onError:e=>{e.target.style.display="none"}}),u?(0,h.jsx)(d.ViewCarousel,{className:S.carouselIcon,style:{position:"absolute",bottom:"-4px",right:"-4px",width:"14px",height:"14px",backgroundColor:"#fff",borderRadius:"50%",padding:"1px",boxShadow:"0 0 0 1px rgba(0,0,0,0.08)"}}):null]}):null,(0,h.jsxs)(o.Box,{style:{overflow:"hidden"},children:[(0,h.jsx)(o.Typography,{variant:"h5",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.adName||"UNDEFINED"}),u?(0,h.jsx)(o.Chip,{size:"small",label:`Carousel - ${m} cards`,className:S.carouselChip,style:{fontWeight:"bold",borderRadius:"12px",height:"18px",fontSize:"10px",marginTop:"2px"}}):null]})]})});case"delivery":if(!t.adEffectiveStatus||!t.adStatus)return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:"-"})});const x="ACTIVE"==t.adEffectiveStatus&&"ACTIVE"===t.adStatus&&!(Number(t?.impressions)>0),f=t?.pausedDueToInsufficientCredit?"INSUFFICIENT CREDIT":x?"PREPARING":"ACTIVE"==t.adEffectiveStatus?t.adStatus:t.adEffectiveStatus,A=a[f]||"#9E9E9E";return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Box,{style:{display:"flex",flexDirection:"column",gap:"4px",alignItems:"flex-start",width:"100%"},children:(0,h.jsx)(o.Chip,{size:"small",label:f,style:{background:A,color:"white"}})})});case"actions":return t.actions&&0!==t.actions.count?(0,h.jsx)(o.Box,{children:(0,h.jsxs)(o.Typography,{variant:"h5",children:[t.actions.count," recommendation",t.actions.count>1?"s":""]})}):(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:"-"})});case"attributionSetting":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:t.attributionSetting||"-"})});case"adType":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:"lead_form"==t.adType?"Lead Form":"whatsapp_status"==t.adType?"WhatsApp Status Ad":"website_to_whatsapp"==t.adType?"Website to WhatsApp Ad":"ctwa"==t?.adType||"WHATSAPP"==t?.destinationType?"CTWA":"Website Ad"})});case"startDate":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:t.startDate?ve()(t.startDate).format("MMM Do YYYY [at] HH:mm A"):"-"})});case"results":if(!t.results)return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:"-"})});const I=t.results.count?`${t.results.count} ${t.results.type}`:t.results.type;return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:I})});case"results_value":if(!t["purchase_roas[0].action_type"])return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:"-"})});const v=t["purchase_roas[0].action_type"];return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:Ro(t[`action_values.${v}`],g)})});case"reach":return(0,h.jsx)(o.Box,{pl:1,children:(0,h.jsx)(o.Typography,{variant:"h5",children:null!==t.reach&&void 0!==t.reach?Bo(t.reach):"-"})});case"frequency":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:null!==t.frequency&&void 0!==t.frequency?Oo(t.frequency):"-"})});case"costPerResult":return t.costPerResult&&t.costPerResult.amount?(0,h.jsx)(o.Box,{children:(0,h.jsxs)(o.Typography,{variant:"h5",children:[Ro(t.costPerResult.amount,g)," ",t.costPerResult.type]})}):(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:t.costPerResult?.type||"-"})});case"budget":if(!t.budget||!t.budget.amount)return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:t.budget?.type||"-"})});const E="Daily average"===t.budget.type;return(0,h.jsxs)(o.Box,{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"2px"},children:[(0,h.jsx)(o.Typography,{variant:"h5",children:Ro(t.budget.amount,g)}),(0,h.jsx)(o.Typography,{style:{color:"grey",fontSize:"12px"},children:E?"(Daily)":"(Lifetime)"})]});case"amountSpent":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:null!==t.amountSpent&&void 0!==t.amountSpent?Ro(t.amountSpent,g):"-"})});case"ends":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"body1",children:t.ends||"-"})});case"qualityRanking":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(ea.um,{value:t.qualityRanking})});case"engagementRateRanking":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(ea.um,{value:t.engagementRateRanking})});case"conversionRanking":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(ea.um,{value:t.conversionRanking})});case"quality_ranking":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(ea.um,{value:t.quality_ranking})});case"engagement_rate_ranking":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(ea.um,{value:t.engagement_rate_ranking})});case"impressions":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:null!==t.impressions&&void 0!==t.impressions?Bo(t.impressions):"-"})});case"spend":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:null!==t.spend&&void 0!==t.spend?Ro(t.spend,g):"-"})});case"result_rate[0].values[0].value":return(0,h.jsx)(o.Box,{children:(0,h.jsxs)(o.Typography,{variant:"h5",children:[Po(t[e.id]),t[e.i
1d]?"%":""]})});case"cpc":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:null!==t.cpc&&void 0!==t.cpc?Ro(t.cpc,g):"-"})});case"cpm":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:null!==t.cpm&&void 0!==t.cpm?Ro(t.cpm,g):"-"})});case"cost_per_result[0].values[0].value":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:t.spend/t["results[0].values[0].value"]?Ro(t.spend/t["results[0].values[0].value"],g):"-"})});case"cpp":return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:null!==t.cpp&&void 0!==t.cpp?Ro(t.cpp,g):"-"})});default:return(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.Typography,{variant:"h5",children:Po(t[e.id])})})}};return(0,h.jsx)(o.Paper,{className:S.tableContainer,children:(0,h.jsxs)(o.TableContainer,{className:S.scrollContainer,children:[b&&(0,h.jsx)(o.Box,{className:S.loadingBarContainer,children:(0,h.jsx)(vo,{variant:"indeterminate",size:"small"})}),(0,h.jsxs)(o.Table,{stickyHeader:!0,"aria-label":"meta ads manager table",className:S.table,children:[(0,h.jsx)(o.TableHead,{className:S.stickyHeader,children:(0,h.jsxs)(o.TableRow,{children:[ko.map((e=>{const t="offOn"===e.id,a="ad"===e.id,n=t?S.stickyHeaderCellOffOn:a?S.stickyHeaderCellAd:"";return(0,h.jsx)(o.TableCell,{align:e.align,className:n,style:{minWidth:e.minWidth,backgroundColor:"white",padding:"8px",border:"none"},children:(0,h.jsx)(o.Typography,{variant:"h5",color:"primary",children:e.label})},e.id)})),D.map(((e,t)=>(0,h.jsx)(o.TableCell,{align:"center",className:"",style:{minWidth:e.minWidth||100,backgroundColor:"white",padding:"8px",border:"none"},children:(0,h.jsx)(o.Typography,{variant:"h5",color:"primary",children:e.label})},t)))]})}),(0,h.jsx)(o.TableBody,{children:v&&t&&0==E.length?Array.from({length:A}).map(((e,t)=>(0,h.jsxs)(o.TableRow,{className:S.tableRow,children:[ko.map((e=>{const t="offOn"===e.id,a="ad"===e.id,n=t?S.stickyCellOffOn:a?S.stickyCellAd:"";return(0,h.jsx)(o.TableCell,{align:e.align,className:n,style:{padding:"8px",border:"none"},children:(0,h.jsx)(O.Skeleton,{variant:"text",width:"ad"===e.id?"80%":"60%",height:24})},e.id)})),D.map((e=>(0,h.jsx)(o.TableCell,{align:"center",style:{minWidth:e.minWidth||100,padding:"8px",border:"none"},children:(0,h.jsx)(O.Skeleton,{variant:"text",width:"100%",height:24})},e.id)))]},`skeleton-${t}`))):0===E.length?(0,h.jsx)(o.TableRow,{children:(0,h.jsx)(o.TableCell,{colSpan:w,align:"center",className:S.stickyCellOffOn,children:(0,h.jsxs)(o.Box,{className:S.emptyStateContainer,children:[(0,h.jsx)(o.Typography,{variant:"h5",color:"textSecondary",children:"No data available"}),t&&(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:"Create your first ad to see analytics here"})]})})}):E.map(((e,t)=>(0,h.jsxs)(o.TableRow,{role:"checkbox",tabIndex:-1,className:S.tableRow,style:t%2==0?{backgroundColor:"rgb(245, 245, 245)"}:{},children:[ko.map((a=>{const n="offOn"===a.id,s="ad"===a.id,i=n?S.stickyCellOffOn:s?S.stickyCellAd:"";return(0,h.jsx)(o.TableCell,{align:a.align,className:i,onClick:t=>{t.defaultPrevented||0!==t.button||t.metaKey||t.ctrlKey||t.altKey||t.shiftKey||"offOn"!==a.id&&"DRAFT"!=e.adStatus&&N("charts",e.adId)},style:t%2==0?{backgroundColor:"rgb(245, 245, 245)",padding:"8px",border:"none"}:{padding:"8px",border:"none"},children:k(a,e)},a.id)})),D.map((t=>(0,h.jsx)(o.TableCell,{align:"center",onClick:()=>N("charts",e.adId),style:{minWidth:t.minWidth||100,padding:"8px",border:"none"},children:k(t,e)},t.id)))]},e.id)))})]})]})})}var Fo=a(77218);const Wo={sections:[{label:"Impressions",key:"impressions"},{label:"Reach",key:"reach"},{label:"Frequency",key:"frequency"},{label:"Clicks",key:"clicks"},{label:"Unique Clicks",key:"unique_clicks"},{label:"Inline Link Clicks",key:"inline_link_clicks"},{label:"CTR (%)",key:"ctr"},{label:"Spend",key:"spend"},{label:"CPC",key:"cpc"},{label:"CPM",key:"cpm"},{label:"Outbound Click",key:"outbound_clicks.outbound_click"},{key:"actions.onsite_conversion.messaging_conversation_started_7d",label:"Messaging conversations started"}],tables:{resultsBreakdown:[{label:"Cost Per Result",key:"cost_per_result[0].values[0].value"},{label:"Results ROAS",key:"purchase_roas[0].value"},{label:"Result rate",key:"result_rate[0].values[0].value"},{label:"Results value",key:"results_value"},{label:"Results",key:"results[0].values[0].value"}],actionsBreakdown:[{key:"actions.link_click",label:"Link Click"},{key:"actions.omni_add_to_cart",label:"Omni Add To Cart"},{key:"actions.page_engagement",label:"Page Engagement"},{key:"actions.landing_page_view",label:"Landing Page View"},{key:"actions.add_to_cart",label:"Add To Cart"},{key:"actions.omni_landing_page_view",label:"Omni Landing Page View"},{key:"actions.onsite_web_app_add_to_cart",label:"Onsite Web App Add To Cart"},{key:"actions.onsite_web_view_content",label:"Onsite Web View Content"},{key:"actions.onsite_web_add_to_cart",label:"Onsite Web Add To Cart"},{key:"actions.post_engagement",label:"Post Engagement"},{key:"actions.post_interaction_gross",label:"Post Interaction Gross"},{key:"actions.view_content",label:"View Content"},{key:"actions.post",label:"Post"},{key:"actions.onsite_conversion.post_save",label:"Onsite Conversion Post Save"},{key:"actions.onsite_conversion.post_net_like",label:"Onsite Conversion Post Net Like"},{key:"actions.onsite_conversion.post_net_save",label:"Onsite Conversion Post Net Save"},{key:"actions.onsite_web_app_view_content",label:"Onsite Web App View Content"},{key:"actions.offsite_content_view_add_meta_leads",label:"Offsite Content View Add Meta Leads"},{key:"actions.video_view",label:"Video View"},{key:"actions.omni_view_content",label:"Omni View Content"},{key:"actions.offsite_conversion.fb_pixel_view_content",label:"Offsite Conversion Fb Pixel View Content"},{key:"actions.offsite_conversion.fb_pixel_add_to_cart",label:"Offsite Conversion Fb Pixel Add To Cart"},{key:"actions.post_reaction",label:"Post Reaction"}],videoBreakdown:[{label:"Video 25% Watched",key:"video_p25_watched_actions.video_view"},{label:"Video 50% Watched",key:"video_p50_watched_actions.video_view"},{label:"Video 75% Watched",key:"video_p75_watched_actions.video_view"},{label:"Video 100% Watched",key:"video_p100_watched_actions.video_view"},{label:"Video Plays",key:"video_play_actions.video_view"},{label:"Video Avg Time Watched (sec)",key:"video_avg_time_watched_actions.video_view"}]}},zo={actionsBreakdown:"Actions Breakdown",conversionsBreakdown:"Conversions Breakdown",videoBreakdown:"Video Breakdown",resultsBreakdown:"Results Breakdown"},Go=(()=>{const e=[];return Wo.sections.forEach((t=>{e.push({key:t.key,label:t.label,action_type:t.action_type})}
1)),Object.values(Wo.tables).forEach((t=>{t.forEach((t=>{e.push({key:t.key,label:t.label})}))})),e})().map((e=>{let t="Key Metrics";for(const[a,n]of Object.entries(Wo.tables))if(n.some((t=>t.key===e.key))){t=zo[a]||a;break}const a={id:e.key,name:e.label,category:t};return e.variants&&(a.facetIds={total:e.variants.total,value:e.variants.value,cost:e.variants.cost}),a})),Ho={"Key Metrics":["Key Metrics",...Object.values(zo)]},Vo=(0,o.makeStyles)((e=>({dialog:{'& .MuiDialog-paper, & [class*="MuiDialog-paper-"]':{width:"90%",maxWidth:"1200px",maxHeight:"90vh",margin:e.spacing(2)}},dialogHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:e.spacing(2,3),borderBottom:`1px solid ${e.palette.divider}`},dialogTitle:{fontSize:"20px",fontWeight:500,margin:0},dialogBody:{display:"flex",height:"calc(90vh - 200px)",overflow:"hidden"},leftPanel:{width:"70%",borderRight:`1px solid ${e.palette.divider}`,display:"flex",flexDirection:"column",overflow:"hidden"},rightPanel:{width:"30%",display:"flex",flexDirection:"column",overflow:"hidden"},searchContainer:{padding:e.spacing(2),borderBottom:`1px solid ${e.palette.divider}`,display:"flex",alignItems:"center",gap:e.spacing(1)},searchInput:{flex:1},collapseButton:{minWidth:"auto",textTransform:"none"},tabsContainer:{borderBottom:`1px solid ${e.palette.divider}`},tab:{minWidth:"auto",padding:e.spacing(1,2),textTransform:"none"},metricsContainer:{flex:1,overflowY:"auto",padding:e.spacing(1)},accordion:{boxShadow:"none",border:`1px solid ${e.palette.divider}`,marginBottom:e.spacing(1),"&:before":{display:"none"},"&.Mui-expanded":{margin:e.spacing(1,0)}},accordionSummary:{minHeight:48,"&.Mui-expanded":{minHeight:48}},accordionDetails:{flexWrap:"wrap",padding:e.spacing(1,2)},categoryHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%"},categoryName:{fontWeight:500,fontSize:"14px"},selectedCount:{fontSize:"12px",color:"#0a474c"},checkboxLabel:{margin:e.spacing(.5,0),width:"50%"},standardEventsTable:{marginTop:e.spacing(1),"& th":{fontWeight:600,fontSize:"12px",padding:e.spacing(1)},"& td":{padding:e.spacing(1)}},rightPanelHeader:{padding:e.spacing(2),borderBottom:`1px solid ${e.palette.divider}`},rightPanelTitle:{fontWeight:600,fontSize:"14px",marginBottom:e.spacing(.5)},rightPanelDescription:{fontSize:"12px",color:"#0a474c"},selectedColumnsList:{flex:1,overflowY:"auto",padding:0},listItem:{borderBottom:`1px solid ${e.palette.divider}`,padding:e.spacing(1,2),"&:hover":{backgroundColor:"#f0f0f0"}},dragHandle:{cursor:"grab",color:"#0a474c",marginRight:e.spacing(1)},dialogFooter:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:e.spacing(2,3),borderTop:`1px solid ${e.palette.divider}`},savePresetButton:{textTransform:"none",opacity:0,pointerEvents:"none"},footerActions:{display:"flex",gap:e.spacing(1)}})));function Yo(e){let{open:t,onClose:a,selectedColumns:s=[],onApply:i}=e;
1const r=Vo(),[l,c]=(0,n.useState)(0),[p,u]=(0,n.useState)(""),[m,g]=(0,n.useState)({}),[b,y]=(0,n.useState)(s.length>0?s:[]),[x,f]=(0,n.useState)(s.length>0?s:[]),A=["Key Metrics"],I=(0,n.useMemo)((()=>Ho[A[l]]||[]),[l]),C=(0,n.useMemo)((()=>{let e=Go;if(I.length>0&&(e=e.filter((e=>I.includes(e.category)))),p.trim()){const t=p.toLowerCase();e=e.filter((e=>e.name.toLowerCase().includes(t)))}return e}),[l,I,p]),_=(0,n.useMemo)((()=>{const e={};return C.forEach((t=>{e[t.category]||(e[t.category]=[]),e[t.category].push(t)})),e}),[C]),S=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const a=t?e.facetIds[t]:e.id;y((e=>e.includes(a)?e.filter((e=>e!==a)):[...e,a])),f((e=>e.includes(a)?e.filter((e=>e!==a)):[...e,a]))},v=e=>(t,a)=>{g((t=>({...t,[e]:a})))},E=e=>{const t=(e=>{const t=e.replace(/^(campaign|adset|ad)\./,"");for(const a of Wo.sections)if(a.key===e||a.key===t||a.key.replace(/^(campaign|adset|ad)\./,"")===t)return a;for(const a of Object.values(Wo.tables))for(const n of a)if(n.key===e||n.key===t||n.key.replace(/^(campaign|adset|ad)\./,"")===t)return n;return null})(e);if(t)return"total"===t.variant?`${t.label} - Total`:"value"===t.variant?`${t.label} - Value`:"cost"===t.variant?`${t.label} - Cost`:t.label;for(const t of Go){if(t.id===e)return t.name;if(t.facetIds){if(t.facetIds.total===e)return`${t.name} - Total`;if(t.facetIds.value===e)return`${t.name} - Value`;if(t.facetIds.cost===e)return`${t.name} - Cost`}}return e},T=()=>{y(s.length>0?s:[]),f(s.length>0?s:[]),u(""),g({}),a()};return(0,h.jsxs)(o.Dialog,{open:t,onClose:T,maxWidth:!1,className:r.dialog,children:[(0,h.jsxs)(o.Box,{className:r.dialogHeader,children:[(0,h.jsx)(o.Typography,{className:r.dialogTitle,children:"Customise columns"}),(0,h.jsx)(o.IconButton,{onClick:T,size:"small",children:(0,h.jsx)(d.Close,{})})]}),(0,h.jsxs)(o.DialogContent,{className:r.dialogBody,children:[(0,h.jsxs)(o.Box,{className:r.leftPanel,children:[(0,h.jsx)(o.Box,{className:r.searchContainer,children:(0,h.jsx)(o.TextField,{placeholder:"Search for metrics or column settings",value:p,onChange:e=>u(e.target.value),className:r.searchInput,InputProps:{startAdornment:(0,h.jsx)(o.InputAdornment,{position:"start",children:(0,h.jsx)(d.Search,{})})}})}),(0,h.jsx)(o.Box,{className:r.metricsContainer,children:Object.keys(_).map((e=>{const t=_[e],a=(e=>_[e]?.filter((e=>e.facetIds?b.includes(e.facetIds.total)||b.includes(e.facetIds.value)||b.includes(e.facetIds.cost):b.includes(e.id))).length||0)(e),n=!1!==m[e];return(0,h.jsxs)(o.Accordion,{expanded:n,onChange:v(e),className:r.accordion,children:[(0,h.jsx)(o.AccordionSummary,{className:r.accordionSummary,children:(0,h.jsxs)(o.Box,{className:r.categoryHeader,children:[(0,h.jsx)(o.Typography,{className:r.categoryName,children:e}),a>0&&(0,h.jsxs)(o.Typography,{className:r.selectedCount,children:[a," selected"]})]})}),(0,h.jsx)(o.AccordionDetails,{className:r.accordionDetails,children:"Standard events"===e?(0,h.jsxs)(o.Table,{size:"small",className:r.standardEventsTable,children:[(0,h.jsx)(o.TableHead,{children:(0,h.jsxs)(o.TableRow,{children:[(0,h.jsx)(o.TableCell,{children:"Metric"}),(0,h.jsx)(o.TableCell,{align:"center",children:"Total"}),(0,h.jsx)(o.TableCell,{align:"center",children:"Value"}),(0,h.jsx)(o.TableCell,{align:"center",children:"Cost"})]})}),(0,h.jsx)(o.TableBody,{children:t.map((e=>(0,h.jsxs)(o.TableRow,{children:[(0,h.jsx)(o.TableCell,{children:e.name}),(0,h.jsx)(o.TableCell,{align:"center",children:(0,h.jsx)(o.Checkbox,{checked:b.includes(e.facetIds.total),onChange:()=>S(e,"total"),size:"small",color:"primary"})}),(0,h.jsx)(o.TableCell,{align:"center",children:e.facetIds.value&&(0,h.jsx)(o.Checkbox,{checked:b.includes(e.facetIds.value),onChange:()=>S(e,"value"),size:"small",color:"primary"})}),(0,h.jsx)(o.TableCell,{align:"center",children:(0,h.jsx)(o.Checkbox,{checked:b.includes(e.facetIds.cost),onChange:()=>S(e,"cost"),size:"small",color:"primary"})})]},e.id)))})]}):t.map((e=>(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Checkbox,{checked:b.includes(e.id),onChange:()=>S(e),size:"small",color:"primary"}),label:e.name,className:r.checkboxLabel},e.id)))})]},e)}))})]}),(0,h.jsxs)(o.Box,{className:r.rightPanel,children:[(0,h.jsxs)(o.Box,{className:r.rightPanelHeader,children:[(0,h.jsxs)(o.Typography,{className:r.rightPanelTitle,children:[x.length," columns selected"]}),(0,h.jsx)(o.Typography,{className:r.rightPanelDescription,children:"Drag and drop to arrange columns as they'll appear in the table."})]}),(0,h.jsx)(Fo.JY,{onDragEnd:e=>{const{destination:t,source:a}=e;if(!t)return;const n=Array.from(x),[s]=n.splice(a.index,1),o="ad"===n[0]?1:0,i=Math.max(t.index,o);n.splice(i,0,s),f(n)},children:(0,h.jsx)(Fo.gL,{droppableId:"selectedColumns",children:e=>(0,h.jsxs)(o.List,{className:r.selectedColumnsList,ref:e.innerRef,...e.droppableProps,children:[x.map(((e,t)=>{const a="ad"===e;return(0,h.jsx)(Fo.sx,{draggableId:e,index:t,isDragDisabled:a,children:(t,n)=>(0,h.jsxs)(o.ListItem,{className:r.listItem,ref:t.innerRef,...t.draggableProps,style:{backgroundColor:n.isDragging?"#f5f5f5":void 0,...t.draggableProps.style},children:[(0,h.jsx)("span",{className:r.dragHandle,style:{display:"inline-flex",cursor:a?"default":"grab"},...a?{}:t.dragHandleProps,children:(0,h.jsx)(d.DragIndicator,{})}),(0,h.jsx)(o.ListItemText,{primary:E(e)}),!a&&(0,h.jsx)(o.ListItemSecondaryAction,{children:(0,h.jsx)(o.IconButton,{edge:"end",onClick:()=>(e=>{"ad"!==e&&(y((t=>t.filter((t=>t!==e)))),f((t=>t.filter((t=>t!==e)))))})(e),size:"small",children:(0,h.jsx)(d.Close,{fontSize:"small"})})})]})},e)})),e.placeholder]})})})]})]}),(0,h.jsxs)(o.Box,{className:r.dialogFooter,children:[(0,h.jsx)(o.Button,{className:r.savePresetButton,startIcon:(0,h.jsx)(d.Bookmark,{}),variant:"outlined",children:"Save as column preset"}),(0,h.jsxs)(o.Box,{className:r.footerActions,children:[(0,h.jsx)(o.Button,{onClick:T,variant:"outlined",children:"Cancel"}),(0,h.jsx)(o.Button,{onClick:()=>{i&&i(x),a()},variant:"contained",color:"primary",children:"Apply"})]})]})]})}const Zo=(e,t)=>(e||"").length>t?e.substring(0,t)+"..":e,Ko=(0,o.makeStyles)({select:{"&:focus":{backgroundColor:"transparent",borderRadius:8}}}),Jo=e=>{let{options:t,selectedOptions:a,onChange:s,isSelectorOpen:i,label:r,onSelectorClick:l,textFieldLabel:c,showSearch:p=!0}=e;
1const[u,m]=(0,n.useState)(""),[g,b]=(0,n.useState)(!0),y=Ko();return(0,h.jsxs)(o.Select,{classes:{select:y.select},onClick:e=>{e.target.value||l(!i),e.stopPropagation()},style:{width:"185px",fontSize:"0.8125rem",color:"black",backgroundColor:"rgb(240,240,240)",borderRadius:8,padding:"4px 10px","& .MuiSelect-select":{paddingRight:"2px"}},value:"",displayEmpty:!0,open:i,renderValue:()=>a.find((e=>"all"==e.name))?"All":((e,t)=>{let a="";return a=e.length>2?0==e[0].id?"All":`${(0,ts.startCase)(Zo(e?.[0]?.name,7))}, ${(0,ts.startCase)(Zo(e?.[1]?.name,7))} + ${e.length-2}`:1===e.length?`${(0,ts.startCase)(Zo(e[0]?.name||"",10))}`:e.length?`${(0,ts.startCase)(Zo(e?.[0]?.name||"",10))}, ${(0,ts.startCase)(Zo(e?.[1]?.name,10))||""}`:t,a.replace("Captured","Success")})(a,r),MenuProps:{getContentAnchorEl:()=>null,anchorOrigin:{vertical:"bottom",horizontal:"start"},transformOrigin:{vertical:"top",horizontal:"start"},style:{zIndex:35001,marginTop:"5px",marginLeft:"-10px",maxHeight:"450px"},variant:"menu"},IconComponent:()=>i?(0,h.jsx)(d.KeyboardArrowUp,{style:{width:"20px",height:"20px",marginRight:"-4px"}}):(0,h.jsx)(d.KeyboardArrowDown,{style:{width:"20px",height:"20px",marginRight:"-4px"}}),children:[p&&(0,h.jsx)(o.MenuItem,{value:"field",style:{width:"260px",backgroundColor:"white",position:"fixed",zIndex:"1",marginTop:"-8px",padding:"12px",borderTopLeftRadius:"8px"},children:(0,h.jsx)(o.TextField,{placeholder:c||"Search by name",style:{padding:"6px 16px",borderRadius:"6px",width:"100%",backgroundColor:"rgb(240, 240, 240)"},onKeyDown:e=>{e.stopPropagation()},onClick:e=>{e.stopPropagation()},InputProps:{endAdornment:(0,h.jsx)(o.InputAdornment,{position:"end",style:{color:"grey"},children:(0,h.jsx)(d.Search,{style:{width:"20px",height:"20px"}})})},value:u,renderValue:()=>u,onChange:e=>{m(e.target.value)}})}),(0,h.jsxs)(o.MenuItem,{value:0,style:{padding:"0px 4px",width:"260px",marginTop:p?"60px":"-8px"},onClick:()=>{let e=!a.some((e=>0===e.id)),n=a;n=e?t:[],s(n),b(!g)},children:[(0,h.jsx)(o.Checkbox,{color:"primary",checked:a.length===t.length,onChange:(e,n)=>{let o=a;o=n?t:[],s(o),b(!g)}}),"All"]}),t.filter((e=>e.name.includes(u))).reverse().slice(0,250).map(((e,n)=>(0,h.jsxs)(o.MenuItem,{value:e.id,style:{padding:"0px 4px",width:"260px"},onClick:()=>{let n=!a.some((t=>t.id===e.id)),o=a;n?o="all"==e.name?t:[...o,e]:"all"==e.name?o=[]:(o=o.filter((e=>"all"!=e.name)),o=o.filter((t=>t.id!=e.id))),s(o),b(!g)},children:[(0,h.jsx)(o.Checkbox,{color:"primary",checked:a.some((t=>t.id===e.id)),onChange:(n,o)=>{let i=a;o?i="all"==e.name?t:[...i,e]:"all"==e.name?i=[]:(i=i.filter((e=>"all"!=e.name)),i=i.filter((t=>t.id!=e.id))),s(i),b(!g)}}),"captured"===e.name?"Success":(0,ts.startCase)(Zo(e.name,21))]},n)))]})},$o=e=>{let{classes:t,selectedOption:a,selectorOpen:n,startDate:s,endDate:i,focusedInput:r,onStatusChange:l,onDateRangeChange:c,onFocusChange:p,onSelectorClick:u,onColumnsClick:m,onCustomizeClick:g}=e;return(0,h.jsxs)(o.Grid,{xs:12,md:11,lg:11,className:t.searchContainer,style:{margin:"16px 0px"},children:[(0,h.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[(0,h.jsx)(Jo,{options:[{id:3,name:"Draft"},{id:2,name:"Paused"},{id:1,name:"Active"}],onChange:l,selectedOptions:a,onSelectorClick:u,isSelectorOpen:n,label:"Select Status",textFieldLabel:"Search by status"},"status"),(0,h.jsx)(Ga,{startDate:s,endDate:i,onDatesChange:c,onFocusChange:p,focusedInput:r})]}),(0,h.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[(0,h.jsx)(o.Button,{variant:"outlined",startIcon:(0,h.jsx)(d.Settings,{}),onClick:g,children:"Customize Metrics"}),(0,h.jsx)(o.Button,{variant:"outlined",startIcon:(0,h.jsx)(d.ViewColumn,{}),onClick:m,children:"Columns"})]})]})},qo=(e,t,a,n)=>{const s=parseFloat(n?.spend)||0,o=parseFloat(n?.impressions)||0,i=parseFloat(n?.clicks)||0,r=parseFloat(n?.reach)||0,l=parseFloat(n?.unique_clicks)||0,d=parseFloat(n?.inline_link_clicks)||0,c=(parseFloat(n?.frequency),parseFloat(n?.totalLeadsGenerated)||0),p=parseFloat(n?.averageDailySpend)||0,u=parseFloat(n?.capiCount)||0,m=parseFloat(n?.cpc)||0,h=parseFloat(n?.cpm)||0,g=parseFloat(n?.cpp)||0,b=parseFloat(n?.ctr)||0,y=parseFloat(n?.messaging_conversations_started)||0,x=parseFloat(n?.outbound_clicks)||0,f=parseFloat(n?.unique_ctr)||
10;switch(e){case"numberOfLeads":return c.toString();case"clickThroughRate":return o>0?(i/o*100).toFixed(2):"0";case"averageDailySpend":return p.toString();case"costPerLead":return s>0&&c>0?(s/c).toFixed(2):"0";case"totalSpend":case"spend":return s.toString();case"capiCount":return u.toString();case"impressions":return o.toString();case"reach":return r.toString();case"frequency":return r>0?(o/r).toFixed(2):"0";case"clicks":return i.toString();case"uniqueClicks":return l.toString();case"inlineLinkClicks":return d.toString();case"uniqueCTR":return f||(o>0?(l/o*100).toFixed(2):"0");case"ctr":return b||(o>0?(i/o*100).toFixed(2):"0");case"cpm":return h||(o>0?(s/o*1e3).toFixed(2):"0");case"cpc":return m||(i>0?(s/i).toFixed(2):"0");case"cpp":return g||"0";case"outboundClick":return x||0;case"messagingConversationsStarted":return y||y.toString();default:return"0"}},Xo={numberOfLeads:{label:"Number of Leads",tooltip:"Total new leads generated",format:"number",getValue:(e,t,a)=>qo("numberOfLeads",0,0,a)},clickThroughRate:{label:"Click-Through Rate",tooltip:"Rate of clicks on ad impressions",format:"percentage",getValue:(e,t,a)=>qo("clickThroughRate",0,0,a)},costPerLead:{label:"Cost Per Lead",tooltip:"Average cost per new lead",format:"currency",getValue:(e,t,a)=>qo("costPerLead",0,0,a)},totalSpend:{label:"Total Spend",tooltip:"Total Ad account budget used till now",format:"currency",getValue:(e,t,a)=>qo("spend",0,0,a)},capiCount:{label:"Total CAPI Signals",tooltip:"Total conversion signals sent to meta",format:"number",getValue:(e,t,a)=>qo("capiCount",0,0,a)},impressions:{label:"Impressions",tooltip:"Total number of times your ad was shown",format:"number",getValue:(e,t,a)=>qo("impressions",0,0,a)},reach:{label:"Reach",tooltip:"Number of unique people who saw your ad",format:"number",getValue:(e,t,a)=>qo("reach",0,0,a)},frequency:{label:"Frequency",tooltip:"Average number of times each person saw your ad",format:"number",getValue:(e,t,a)=>qo("frequency",0,0,a)},clicks:{label:"Clicks",tooltip:"Total number of clicks on your ad",format:"number",getValue:(e,t,a)=>qo("clicks",0,0,a)},uniqueClicks:{label:"Unique Clicks",tooltip:"Number of unique people who clicked your ad",format:"number",getValue:(e,t,a)=>qo("uniqueClicks",0,0,a)},inlineLinkClicks:{label:"Inline Link Clicks",tooltip:"Number of clicks on links within your ad",format:"number",getValue:(e,t,a)=>qo("inlineLinkClicks",0,0,a)},cpm:{label:"CPM",tooltip:"Cost per 1,000 impressions",format:"currency",getValue:(e,t,a)=>qo("cpm",0,0,a)},cpc:{label:"CPC",tooltip:"Cost per click",format:"currency",getValue:(e,t,a)=>qo("cpc",0,0,a)},outboundClick:{label:"Outbound Click",tooltip:"Number of outbound clicks from your ad",format:"number",getValue:(e,t,a)=>qo("outboundClick",0,0,a)},messagingConversationsStarted:{label:"Messaging conversations started",tooltip:"The number of times a messaging conversation was started with your business after at least seven days of inactivity, attributed to your ads.",format:"number",getValue:(e,t,a)=>qo("messagingConversationsStarted",0,0,a)}},Qo=(0,o.makeStyles)((e=>({dialog:{"& [class*=MuiDialog-paper]":{width:"90%",maxHeight:"90vh",margin:e.spacing(2)}},dialogHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:e.spacing(2,3),borderBottom:`1px solid ${e.palette.divider}`},dialogTitle:{fontSize:"20px",fontWeight:500,margin:0},dialogBody:{padding:e.spacing(2,3),maxHeight:"calc(90vh - 200px)",overflowY:"auto"},metricsContainer:{marginTop:e.spacing(2)},checkboxLabel:{margin:e.spacing(.5,0),width:"50%"},dialogFooter:{display:"flex",justifyContent:"flex-end",alignItems:"center",padding:e.spacing(2,3),borderTop:`1px solid ${e.palette.divider}`,gap:e.spacing(1)},selectedCount:{fontSize:"14px",color:e.palette.text.secondary,marginBottom:e.spacing(2)}}))),ei=e=>{let{open:t,onClose:a,selectedMetrics:s=[],onApply:i}=e;const r=Qo(),[l,c]=(0,n.useState)(s.length>0?s:[]);(0,n.useEffect)((()=>{c(s)}),[s]);const p=()=>{c(s),a()},u=Object.keys(Xo);return(0,h.jsxs)(o.Dialog,{open:t,onClose:p,fullWidth:!0,className:r.dialog,children:[(0,h.jsxs)(o.Box,{className:r.dialogHeader,children:[(0,h.jsx)(o.Typography,{className:r.dialogTitle,children:"Customise Metrics"}),(0,h.jsx)(o.IconButton,{onClick:p,size:"small",children:(0,h.jsx)(d.Close,{})})]}
1),(0,h.jsxs)(o.DialogContent,{className:r.dialogBody,children:[(0,h.jsxs)(o.Typography,{className:r.selectedCount,children:["Select 6 metrics to display (",l.length,"/6 selected)"]}),(0,h.jsx)(o.Grid,{container:!0,spacing:2,className:r.metricsContainer,children:u.map((e=>{const t=Xo[e],a=l.includes(e),n=!a&&l.length>=6;return(0,h.jsx)(o.Grid,{item:!0,xs:6,sm:4,md:4,children:(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Checkbox,{checked:a,onChange:()=>(e=>{c((t=>t.includes(e)?t.filter((t=>t!==e)):t.length<6?[...t,e]:t))})(e),disabled:n,color:"primary",size:"small"}),label:t.label})},e)}))})]}),(0,h.jsxs)(o.Box,{className:r.dialogFooter,children:[(0,h.jsx)(o.Button,{onClick:p,variant:"outlined",children:"Cancel"}),(0,h.jsx)(o.Button,{onClick:()=>{i&&i(l),a()},disabled:6!=l.length,variant:"contained",color:"primary",children:"Apply"})]})]})},ti=e=>{let{classes:t,isLoading:a,selectedAccount:n,currencySymbol:s,selectedMetrics:i,onCustomizeClick:r,adAccountInsights:l}=e;return(0,h.jsx)(o.Grid,{container:!0,justify:"center",alignItems:"center",style:{background:"rgb(249 249 249)",marginBottom:"1em"},children:(0,h.jsx)(o.Grid,{item:!0,xs:12,md:11,lg:11,children:(0,h.jsx)(o.Grid,{container:!0,spacing:2,alignItems:"stretch",children:i.map((e=>{const i=Xo[e];if(!i)return null;const r=((e,t,a)=>"currency"===t?`${a} ${e}`:"percentage"===t?`${e}%`:e)(i.getValue(n,s,l?.aggregated||null),i.format,s);return(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:a?(0,h.jsx)(o.Box,{xs:12,md:11,lg:11,width:"100%",children:(0,h.jsx)(O.Skeleton,{className:t.roundedBox,style:{height:"108px"}})}):(0,h.jsxs)(o.Box,{className:t.roundedBox,style:{height:"70%"},children:[(0,h.jsxs)(o.Box,{display:"flex",width:"100%",children:[(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,nowrap:!0,children:i.label}),(0,h.jsx)(o.Box,{mb:"4px",ml:1,children:(0,h.jsx)(o.Tooltip,{enterTouchDelay:0,style:{fontSize:"1.2em"},placement:"top",title:i.tooltip,children:(0,h.jsx)(d.Info,{color:"disabled"})})})]}),(0,h.jsx)(o.Grid,{item:!0,xs:12,container:!0,style:{display:"flex",alignItems:"end"},children:(0,h.jsx)(o.Typography,{variant:"h3",style:{fontWeight:"bold"},children:(0,h.jsx)("span",{style:{fontSize:16,marginRight:2,fontFamily:"Roboto"},children:r})})})]})},e)}))})})})},ai={impressions:"0",spend:"0",newLeadsGenerated:"0",reach:"0",clicks:"0",accountId:"0",accountName:"0"},ni=["numberOfLeads","clickThroughRate","averageDailySpend","costPerLead","totalSpend","capiCount"];class si extends n.Component{constructor(e){super(e),this.state={open:!1,inputFocused:!1,adsLoader:!0,accAds:[],draftAds:[],nameQuery:"",selectorOpen:"",selectedOption:[],isDraftAds:!1,exportAdDataDialog:!1,startDate:ve()().subtract(29,"days").startOf("day"),endDate:ve()().endOf("day"),focusedInput:null,adsReportDownloading:!1,snackmessage:"",snackiv:"",snack:!1,customiseColumnsOpen:!1,selectedColumns:(()=>{try{const e=localStorage.getItem("adAnalytics_tableColumns");if(e){const t=JSON.parse(e),a=t.filter((e=>"avgdailyspend"!==e));return a.length!==t.length&&localStorage.setItem("adAnalytics_tableColumns",JSON.stringify(a)),a}}catch(e){console.error("Error loading saved columns:",e)}return["impressions","reach","clicks","spend","ctr","cpc","cpm"]})(),selectedMetrics:(()=>{try{const e=localStorage.getItem("adAnalytics_selectedMetrics");if(e){const t=JSON.parse(e).filter((e=>Xo.hasOwnProperty(e)));if(t.length>0&&t.length<=6)return t}}catch(e){console.error("Error loading saved metrics:",e)}return ni})(),customiseMetricsOpen:!1,reportMenuAnchor:null}}restoreFilterParameters=async()=>{const{accountValue:e,assistantDetails:t,adAccountInsights:a}=this.props,{assistantId:n}=t||{},s=e?.accountId;if(!n||!s)return null;if(a?.lastFetchParams){const e=a.lastFetchParams;if(e.accountId===s){let t=[];if(e.selectedOption){t=e.selectedOption.split(",").map((e=>e.trim())).map((e=>({id:"ACTIVE"===e?1:"PAUSED"===e?2:3,name:e.charAt(0)+e.slice(1).toLowerCase()})))}let a=e.startDate||null,n=e.endDate||null;return a&&"string"==typeof a&&(a=ve()(a)),n&&"string"==typeof n&&(n=ve()(n)),{page:e.page||1,limit:e.limit||_n.J6,nameQuery:e.nameQuery||"",startDate:a,endDate:n,selectedOption:t}}}try{(0,mo.fv)({assistantId:n,adAccountId:s,page:1,limit:_n.J6,nameQuery:"",startDate:null,endD
1ate:null,selectedOption:null});const e=(0,mo.fv)({assistantId:n,adAccountId:s,page:a?.pagination?.page||1,limit:a?.pagination?.limit||_n.J6,nameQuery:this.state.nameQuery||"",startDate:this.state.startDate,endDate:this.state.endDate,selectedOption:this.getAdEffectiveStatus()}),t=await(0,mo.Ig)(e);if(t?.lastFetchParams){const e=t.lastFetchParams;let a=[];if(e.selectedOption){a=e.selectedOption.split(",").map((e=>e.trim())).map((e=>({id:"ACTIVE"===e?1:"PAUSED"===e?2:3,name:e.charAt(0)+e.slice(1).toLowerCase()})))}let n=e.startDate||null,s=e.endDate||null;return n&&"string"==typeof n&&(n=ve()(n)),s&&"string"==typeof s&&(s=ve()(s)),{page:e.page||1,limit:e.limit||_n.J6,nameQuery:e.nameQuery||"",startDate:n,endDate:s,selectedOption:a}}}catch(e){console.error("Error restoring filter parameters from IndexedDB:",e)}return null};componentDidMount(){if(this.props.accountValue?.accountId&&this.props.assistantDetails?.assistantId){const{accountValue:e,assistantDetails:t,adAccountInsights:a}=this.props,n=t?.assistantId,s=e?.accountId;n&&s&&(0,mo.AX)(n,s,{accountValue:e,assistantDetails:t,adAccountInsights:a}),this.restoreFilterParameters().then((e=>{e?this.setState({nameQuery:e.nameQuery,startDate:e.startDate,endDate:e.endDate,selectedOption:e.selectedOption},(()=>{this.props.fetchAdAccountInsights({assistantId:this.props.assistantDetails?.assistantId,adAccountId:this.props.accountValue?.accountId,page:e.page,limit:e.limit,nameQuery:e.nameQuery,startDate:e.startDate,endDate:e.endDate,selectedOption:this.getAdEffectiveStatus(),bypassCache:!0})})):this.props.fetchAdAccountInsights({assistantId:this.props.assistantDetails?.assistantId,adAccountId:this.props.accountValue?.accountId,startDate:this.state.startDate,endDate:this.state.endDate,selectedOption:this.getAdEffectiveStatus(),nameQuery:this.state.nameQuery,bypassCache:!0})}))}}componentDidUpdate(e){e.tab!==this.props.tab&&(this.props.accountValue?.accountId?this.props.fetchAdAccountInsights({assistantId:this.props.assistantDetails?.assistantId,adAccountId:this.props.accountValue?.accountId,startDate:this.state.startDate,endDate:this.state.endDate,selectedOption:this.getAdEffectiveStatus(),nameQuery:this.state.nameQuery,bypassCache:!0}):this.props.clearAdAccountInsightsData()),e.accountValue?.accountId!==this.props.accountValue?.accountId&&(this.setState({nameQuery:""}),this.props.fetchAdAccountInsights({assistantId:this.props.assistantDetails?.assistantId,adAccountId:this.props.accountValue?.accountId,startDate:this.state.startDate,endDate:this.state.endDate,selectedOption:this.getAdEffectiveStatus(),nameQuery:this.state.nameQuery,bypassCache:!0})),!this.props.accountValue?.accountId&&this.state.accAds.length&&this.setState({accAds:[],adsLoader:!1})}componentWillUnmount(){(0,_n.ep)(),clearTimeout(this.syncDebounceTimer),clearTimeout(this.toastDebounceTimer)}getAdEffectiveStatus=()=>this.state.selectedOption?.length>0?this.state.selectedOption.map((e=>e.name.toUpperCase())).join(","):null;shouldFetchInsights=()=>{const{adAccountInsights:e}=this.props,{accountValue:t}=this.props;if(!t?.accountId||!e?.lastFetchParams)return!0;const a={accountId:t.accountId,startDate:this.state.startDate,endDate:this.state.endDate,selectedOption:this.getAdEffectiveStatus(),nameQuery:this.state.nameQuery,page:e.pagination?.page||1,limit:e.pagination?.limit||_n.J6},n=e.lastFetchParams;return!(n.accountId===a.accountId&&n.startDate?.format("YYYY-MM-DD")===a.startDate?.format("YYYY-MM-DD")&&n.endDate?.format("YYYY-MM-DD")===a.endDate?.format("YYYY-MM-DD")&&n.selectedOption===a.selectedOption&&n.nameQuery===a.nameQuery&&n.page===a.page&&n.limit===a.limit)||!e.data};handleChangeRowsPerPage=e=>{const t=parseInt(e.target.value,10);this.props.fetchAdAccountInsights({assistantId:this.props.assistantDetails?.assistantId,adAccountId:this.props.accountValue?.accountId,limit:t,page:1,nameQuery:this.state.nameQuery,startDate:this.state.startDate,endDate:this.state.endDate,selectedOption:this.getAdEffectiveStatus()})};fetchDraftAds=async()=>{const{clientId:e,assistantId:t}=this.props.assistantDetails;t&&e&&(this.setState({adsLoader:!0}),this.props.loadDraftAds({assistantId:t,clientId:e}).then((e=>{this.setState({draftAds:e,totalAds:e.count})})).catch((e=>{console.log(e)})))};handleReportMenuOpen=e=>{this.setState({reportMenuAnchor:e.currentTarget})};handleReportMenuClose=()=>{this.setState({reportMenuAnchor:null})};getAdsReport=(()=>{var e=this;return async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"aggregated";e.handleReportMenuClose();try{const{assistantId:a}=e.props.assistantDetails,n=e.props.accountValue?.accountId,s=e.state.nameQuery||"";if(!n||!a)return void e.setState({snack:!0,snackmessage:"Missing required account information",snackiv:"error"});await e.props.exportAdAccountInsights({adAccountId:n,assistantId:a,startDate:e.state.startDate,endD
1ate:e.state.endDate,adName:s,columns:e.state.selectedColumns,selectedOption:e.getAdEffectiveStatus(),reportType:t}),e.setState({reportMenuAnchor:null,exportAdDataDialog:!1,startDate:null,endDate:null})}catch(t){console.log({error:t}),e.setState({reportMenuAnchor:null,snack:!0,snackmessage:e.props.exportAdInsights?.error||"Error Generating Ad Analytics Report",snackiv:"error"})}}})();handleSyncInsights=()=>{const{assistantId:e}=this.props.assistantDetails,t=this.props.accountValue?.accountId;return t&&e?this.props.fetchAdAccountInsights({assistantId:e,adAccountId:t,page:this.props.adAccountInsights?.pagination?.page||1,limit:this.props.adAccountInsights?.pagination?.limit||_n.J6,nameQuery:this.state.nameQuery,startDate:this.state.startDate,endDate:this.state.endDate,selectedOption:this.getAdEffectiveStatus(),bypassCache:!0}):(this.setState({snack:!0,snackmessage:"Missing required account information",snackiv:"error"}),Promise.resolve())};syncDebounceTimer=null;toastDebounceTimer=null;pendingToastCount=0;handleStatusToggle=async(e,t)=>{const{assistantId:a}=this.props.assistantDetails;try{const n=e.metaAdId,s=this.props.accountValue?.accountId;await this.props.updateAdStatus(a,e.adId,n,s,t),this.props.patchAdStatuses({adId:e.adId,newStatus:t}),this.pendingToastCount+=1,clearTimeout(this.toastDebounceTimer),this.toastDebounceTimer=setTimeout((()=>{const e=this.pendingToastCount;this.pendingToastCount=0,this.setState({snack:!0,snackmessage:1===e?`Ad ${"ACTIVE"===t?"activated":"paused"} successfully`:`${e} ads updated successfully`,snackiv:"success"})}),800),clearTimeout(this.syncDebounceTimer),this.syncDebounceTimer=setTimeout((()=>{this.handleSyncInsights().catch((()=>{}))}),1500)}catch(e){throw this.setState({snack:!0,snackmessage:e?.response?.data?.message||"Failed to update ad status",snackiv:"error"}),e}};handleChangePage=(e,t)=>{const a=t+1;this.props.fetchAdAccountInsights({assistantId:this.props.assistantDetails?.assistantId,adAccountId:this.props.accountValue?.accountId,page:a,limit:this.props.adAccountInsights?.pagination?.limit||_n.J6,nameQuery:this.state.nameQuery,startDate:this.state.startDate,endDate:this.state.endDate,selectedOption:this.getAdEffectiveStatus()})};openCampaign(e){const{projectId:t}=this.props.match.params;this.props.history.push({pathname:`${Xe(t)}/${e}/personal-analytics`,state:{adAccountData:this.props.accountValue}})}openEditCampaign(e,t){const{projectId:a}=this.props.match.params;this.props.history.push({pathname:`${Xe(a)}/edit/${e}`,state:{isLiveAD:t}})}openDuplicateCampaign(e,t){const{projectId:a}=this.props.match.params;this.props.history.push({pathname:`${Xe(a)}/duplicate/${e}`,state:{isLiveAD:t}})}handleSearch=e=>{const{nameQuery:t}=this.state;"Enter"===e.key&&this.props.fetchAdAccountInsights({assistantId:this.props.assistantDetails?.assistantId,adAccountId:this.props.accountValue?.accountId,page:1,nameQuery:t,startDate:this.state.startDate,endDate:this.state.endDate,selectedOption:this.getAdEffectiveStatus()})};handleStatusChange=e=>{this.setState({selectedOption:e},(()=>{this.props.fetchAdAccountInsights({assistantId:this.props.assistantDetails?.assistantId,adAccountId:this.props.accountValue?.accountId,page:1,selectedOption:e.map((e=>e.name.toUpperCase())).join(","),startDate:this.state.startDate,endDate:this.state.endDate,nameQuery:this.state.nameQuery})}))};handleDateRangeChange=e=>{let{startDate:t,endDate:a}=e;this.setState({startDate:t,endDate:a},(()=>{this.props.fetchAdAccountInsights({assistantId:this.props.assistantDetails?.assistantId,adAccountId:this.props.accountValue?.accountId,page:this.props.adAccountInsights?.pagination?.page||1,limit:this.props.adAccountInsights?.pagination?.limit||_n.J6,nameQuery:this.state.nameQuery,startDate:t,endDate:a,selectedOption:this.getAdEffectiveStatus()})}))};handleSelectorClick=e=>{this.setState({selectorOpen:e})};handleColumnsClick=()=>{this.setState({customiseColumnsOpen:!0})};handleMetricChange=e=>{try{localStorage.setItem("adAnalytics_selectedMetrics",JSON.stringify(e))}catch(e){console.error("Error saving metrics to localStorage:",e)}this.setState({selectedMetrics:e})};handleCustomiseMetricsClick=()=>{this.setState({customiseMetricsOpen:!0})};combineAndSortArray=(e,t)=>{const a=e.concat(t);return a.sort(((e,t)=>new Date(t.createdAt)-new Date(e.createdAt))),a};render(){const{classes:e,accountValue:t,isLoading:a,tab:n,agentId:s,selectAdAccount:i,fbaccount:r}=this.props,{nameQuery:l}=this.state,{projectId:c}=this.props.match.params,{fbConnected:p,currency:u,adSetupDetails:m}=this.props.assistantDetails,g=t||ai,b=window.innerWidth<460,y=r.find((e=>e?.accountId===t?.accountId)),x="USD"==(g.accountId==m.selectedMetaAdAccountId?u:y?.currency)?"$":"₹",f=this.props.adAccountInsights?.pagination;return(0,h.jsxs)("div",{className:e.root,children:[p?null:(0,h.jsxs)(o.Grid,{container:!0,justify:"center",children:[(0,h.jsx)("div",{className:e.overlay}),(0,h.jsx)(o.Box,{mt:"12px",display:"flex",className:e.higherzIndex,children:(0,h.jsx)("div",{onClick:()=>this.props.history.push(Xe(c)+"/setup"),style:{cursor:"pointer"},children:(0,h.jsxs)(o.Typography,{variant:"h4",color:"primary",align:"center",className:e.message,children:["Connect and Setup Meta Ad Account to continue!",(0,h.jsx)(o.IconButton,{children:(0,h.jsx)(d.ArrowForward,{})})]})})})]}),(0,h.jsxs)(o.Grid,{container:!0,justify:"center",alignItems:"center",style:{background:"rgb(249 249 249)"},children:[(0,h.jsxs)(o.Grid,{xs:12,md:11,lg:11,className:e.searchContainer,children:[(0,h.jsx)(o.TextField,{placeholder:"Search by Ad name ",color:"primary",className:e.textFieldRoot,style:{backgroundColor:this.state.nameQuery||this.state.inputFocused?"white":"#f0f0f0"},onFocus:()=>{this.setState({inputFocused:!0})},onBlur:()=>{this.setState({inputFocused:!1})},value:l,name:"nameQuery",onChange:e=>this.setState({nameQuery:e.target.value}),onKeyDown:this.handleSearch,InputProps:{startAdornment:(0,h.jsx)(o.InputAdornment,{position:"start",children:(0,h.jsx)(d.Search,{})}),endAdornment:l?(0,h.jsx)(o.InputAdornment,{position:"end",children:(0,h.jsx)(o.IconButton,{style:{padding:"4px",marginRight:"-4px"},color:"primary",size:"small",onClick:()=>{this.setState({nameQuery:""},(()=>this.props.fetchAdAccountInsights({assistantId:this.props.assistantDetails?.assistantId,adAccountId:this.props.accountValue?.accountId,page:1,startDate:this.state.startDate,endD
1ate:this.state.endDate,selectedOption:this.getAdEffectiveStatus(),nameQuery:this.state.nameQuery})))},children:(0,h.jsx)(d.Close,{style:{fontSize:18}})})}):""}}),(0,h.jsxs)(o.Box,{className:e.controlsContainer,children:["system"===n?(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(o.Tooltip,{title:p?"":"Connect account first",children:(0,h.jsx)(O.Autocomplete,{disableClearable:!0,classes:{groupUl:e.autoComplete},disabled:!p,style:{marginRight:"7px",width:"38%"},options:r.filter((e=>!e?.isChildBMAdAccount)),onChange:(e,t)=>i(t),value:t,groupBy:e=>e.metaBusinessName||"Other Ad Accounts",getOptionLabel:e=>{const{accountName:t,accountId:a}=e;return t&&a?`${t} - ${a.split("_")[1]}`:""},renderOption:(t,a)=>(0,ea.Oi)(t,a,e),name:"fbaccount",renderInput:t=>(0,h.jsx)(o.TextField,{placeholder:"Choose ad account",...t,classes:{root:e.textFieldRootAutocomplete},InputProps:{...t.InputProps}})})})}):null,(0,h.jsxs)(o.Box,{style:{paddingTop:b?"5px":"",display:"flex"},children:["system"===n&&(0,h.jsx)(o.Tooltip,{title:"Sync Ads Insights & details",children:(0,h.jsx)(o.Button,{variant:"contained",color:"primary",size:"medium",startIcon:(0,h.jsx)(d.Autorenew,{className:!0===this.props.isSyncing?e.rotationIcon:""}),onClick:()=>this.props.syncMetaAcc(),style:{marginTop:"7px",marginBottom:"7px"},disabled:this.props.isSyncing||!t,children:"Sync"})}),"system"===n?(0,h.jsx)(o.Tooltip,{title:"Import Click-To-WhatsApp Ads from Facebook Business Manager",children:(0,h.jsx)(o.Button,{variant:"outlined",color:"primary",size:"medium",startIcon:(0,h.jsx)(d.ImportExport,{}),onClick:()=>this.props.syncMetaAcc("fetchCTWAds"),style:{marginTop:"7px",marginBottom:"7px",marginLeft:"7px",whiteSpace:"nowrap"},disabled:this.props.isSyncing||this.props.isLoading||!t,children:"Fetch Ads"})}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Tooltip,{title:"Sync Ad Account Insights",children:(0,h.jsx)(o.Button,{style:{left:"4px",marginTop:"7px",marginBottom:"7px",marginRight:"7px",whiteSpace:"nowrap"},color:"primary",variant:"outlined",startIcon:(0,h.jsx)(d.Autorenew,{className:!0===this.props.adAccountInsights?.isLoading?e.rotationIcon:""}),onClick:this.handleSyncInsights,disabled:this.props.adAccountInsights?.isLoading||!this.props.accountValue?.accountId,children:"Sync"})}),(0,h.jsx)(o.Tooltip,{title:"Download Ad Analytics Data",children:(0,h.jsx)(o.Button,{style:{left:"4px",marginTop:"7px",marginBottom:"7px",whiteSpace:"nowrap"},color:"primary",variant:"outlined",startIcon:(0,h.jsx)(d.GetApp,{}),onClick:this.handleReportMenuOpen,disabled:this.props.exportAdInsights?.isLoading,children:this.props.exportAdInsights?.isLoading?"Downloading Report...":"Download Report"})}),(0,h.jsxs)(o.Menu,{anchorEl:this.state.reportMenuAnchor,open:Boolean(this.state.reportMenuAnchor),onClose:this.handleReportMenuClose,children:[(0,h.jsx)(o.MenuItem,{onClick:()=>{this.getAdsReport("aggregated")},disabled:this.props.exportAdInsights?.isLoading,children:"Overall Performance Report"}),(0,h.jsx)(o.MenuItem,{onClick:()=>{this.getAdsReport("daily")},disabled:this.props.exportAdInsights?.isLoading,children:"Daily Performance Report"})]})]})]})]})]}),(0,h.jsx)($o,{classes:e,selectedOption:this.state.selectedOption,selectorOpen:this.state.selectorOpen,startDate:this.state.startDate,endDate:this.state.endDate,focusedInput:this.state.focusedInput,onStatusChange:this.handleStatusChange,onDateRangeChange:this.handleDateRangeChange,onFocusChange:e=>{this.setState({focusedInput:e})},onSelectorClick:this.handleSelectorClick,onColumnsClick:this.handleColumnsClick,isLoading:a,currencySymbol:x,selectedAccount:y,selectedMetrics:this.state.selectedMetrics,onCustomizeClick:this.handleCustomiseMetricsClick}),(0,h.jsx)(ti,{adAccountInsights:this.props.adAccountInsights,classes:e,isLoading:a,selectedAccount:y,currencySymbol:x,selectedMetrics:this.state.selectedMetrics,onCustomizeClick:this.handleCustomiseMetricsClick})]}),(0,h.jsx)(o.Grid,{container:!0,justify:"center",marginRight:"1em",children:(0,h.jsxs)(o.Grid,{container:!0,item:!0,xs:12,md:11,lg:11,children:[(0,h.jsx)(o.Grid,{container:!0,children:(0,h.jsxs)(o.Box,{className:e.tableWrapper,children:[(0,h.jsx)(Uo,{accountId:this.props.accountValue?.accountId,headerColumns:this.props.adAccountInsights.headerColumns,rows:this.props.adAccountInsights.data,isLoading:this.props.adAccountInsights?.isLoading,projectId:c,onActionClick:(e,t)=>{"charts"===e?this.openCampaign(t):"edit"===e?this.openEditCampaign(t):"duplicate"===e&&this.openDuplicateCampaign(t)},onStatusToggle:this.handleStatusToggle,initialPage:(f?.page||1)-1,initialRowsPerPage:f?.limit||_n.J6,visibleColumns:this.state.selectedColumns,currencySymbol:x}),(0,h.jsx)(o.Box,{my:8})]})}),(0,h.jsx)(o.Snackbar,{className:e.snackbar,open:this.state.snack,onClose:()=>{this.setState({snack:!1})},anchorOrigin:{vertical:"top",horizontal:"center"},autoHideDuration:3e3,children:(0,h.jsx)(O.Alert,{severity:this.state.snackiv,onClose:()=>{this.setState({snack:!1})},children:this.state.snackmessage})}),(0,h.jsx)("div",{className:e.fixedBottomContainer,children:(void 0!==this.props.adAccountInsights?.isLoadingAds?this.props.adAccountInsights.isLoadingAds:this.props.adAccountInsights?.isLoading)?(0,h.jsx)(o.Box,{xs:12,md:11,lg:11,children:(0,h.jsx)(O.Skeleton,{height:"50px",width:"360px"})}):(0,h.jsx)(o.TablePagination,{component:"div",count:f?.total||0,page:(f?.page||1)-1,onChangePage:this.handleChangePage,rowsPerPage:f?.limit||_n.J6,onChangeRowsPerPage:this.handleChangeRowsPerPage})})]})}),(0,h.jsx)(Yo,{open:this.state.customiseColumnsOpen,onClose:()=>this.setState({customiseColumnsOpen:!1}),selectedColumns:this.state.selectedColumns,onApply:e=>{const t=e.filter((e=>"avgdailyspend"!==e));try{localStorage.setItem("adAnalytics_tableColumns",JSON.stringify(t))}catch(e){console.error("Error saving columns to localStorage:",e)}this.setState({selectedColumns:t})}}),(0,h.jsx)(ei,{open:this.state.customiseMetricsOpen,onClose:()=>this.setState({customiseMetricsOpen:!1}),selectedMetrics:this.state.selectedMetrics,onApply:this.handleMetricChange})]})}}const oi=(0,i.connect)((e=>({assistantDetails:e.assistantDetails.data,adAccountInsights:e.ads.adAccountInsights,exportAdInsights:e.ads.exportAdInsights,updateAdStatusState:e.ads.updateAdStatus})),{fetchAdAccountInsights:_n.Qd,exportAdAccountInsights:_n.ak,clearAdAccountInsightsData:_n.Rp,updateAdStatus:_n.DA,patchAdStatuses:_n.yN,syncAd:_n.hr,loadDraftAds:uo.C$})(si),ii=(0,o.withStyles)((e=>({root:{width:"100%",height:"100%",background:"rgb(249,249,249)",boxSizing:"border-box",position:"relative"},overlay:{alignItems:"centre",background:"#fff",boxShadow:"3px 3px 30px rgb(255 255 255)",display:"flex",height:"100%",
1justifyContent:"centre",opacity:"0.6",width:"100%",position:"absolute",zIndex:20},higherzIndex:{zIndex:21},roundedBox:{minWidth:"95px",borderRadius:"12px",backgroundColor:"white",border:"1px black",padding:"1.2em 0.8em 1.2em 1.5em",display:"flex",flexDirection:"column",justifyContent:"space-between"},roundedBoxload:{width:"100%",height:"200px",borderRadius:"12px"},roundedBoxhead:{display:"flex",borderRadius:"12px",backgroundColor:"white",border:"1px black",padding:"1.2em"},container:{background:"white",borderRadius:"8px"},tableWrapper:{overflowX:"auto",width:"100%",marginTop:"1em"},tableContainer:{marginTop:"0.5em",overflowX:"auto",flexDirection:"column",flexWrap:"nowrap"},tableHeader:{background:"white",borderRadius:"8px",marginBottom:"1em",display:"flex",width:"100%",padding:4,alignItems:"center"},tableItem:{background:"white",marginBottom:"1em",borderRadius:"8px",cursor:"pointer",display:"flex",padding:4,alignItems:"center","&:hover":{background:"#efefef"}},totalContainer:{[e.breakpoints.down("md")]:{margin:"18px 12px 0 0"},[e.breakpoints.up("md")]:{margin:"24px 0 0 18px"}},fixedBottomContainer:{zIndex:15,marginTop:"20px",position:"fixed",height:"60px",borderTop:"1px solid lightgrey",background:"white",bottom:"0",left:70,right:"0",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",[e.breakpoints.down("sm")]:{left:"0px",height:"50px"}},textFieldRoot:{height:"42px",width:"80%",marginRight:"1em",[e.breakpoints.up("md")]:{width:"40%",marginRight:"0.5em",marginLeft:"0"},[e.breakpoints.down("xs")]:{width:"100%"}},tabItem2:{tabIcon:{fontSize:18,position:"relative",right:4,top:4}},qualityStatus:{padding:"4px",color:"white",fontWeight:"600",minWidth:"100px"},rotationIcon:{animation:"adsSpinnerRotation 2s infinite linear"},"@keyframes rotation":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(359deg)"}},gridCell:{padding:"16px 8px",flex:1,whiteSpace:"nowrap",textOverflow:"ellipsis"},searchContainer:{display:"flex",justifyContent:"space-between",alignItems:"center",[e.breakpoints.down("xs")]:{flexDirection:"column",justifyContent:"center"}},controlsContainer:{display:"flex",width:"60%",justifyContent:"end",alignItems:"center",flexDirection:"row",[e.breakpoints.down("xs")]:{width:"100%"},[e.breakpoints.down("450")]:{flexDirection:"column"}},dialogContainer:{'& [class*="MuiPaper-root"]':{[e.breakpoints.down("md")]:{width:"450px",minWidth:"100px",height:"550px",margin:"0",borderRadius:"8px"},[e.breakpoints.up("md")]:{width:"450px",height:"550px",margin:"unset",borderRadius:"8px"}}},dialogPaper:{borderRadius:"8px"},snackbar:{zIndex:3e3,top:70}})))((0,r.withRouter)(oi));function ri(e){let{classes:t,sticky:a,fbConnected:n,accountValue:s,pageValue:i,power:r,partnerId:l,cbpType:d,allowPurchase:c,ongoingBillingProcess:p,pendingInvoices:u,assistantDetails:m,onLinkAd:g,onBuyCredits:b}=e;return(0,h.jsxs)(o.Grid,{container:!0,justify:"center",alignItems:"center",className:`${t.pageTitleContainer} ${t.fullWidth} ginger-page-header`,style:{boxShadow:a?"none":"rgb(235 234 234) 0px 0px 11px"},children:[(0,h.jsx)(o.Grid,{item:!0,xs:!0,style:{display:"flex",alignItems:"center"},children:(0,h.jsx)(o.Box,{pl:{xs:2,md:3},children:(0,h.jsx)(o.Typography,{variant:"h3",children:"Ads Manager"})})}),(0,h.jsxs)(o.Grid,{item:!0,style:{display:"flex"},children:[!1,(0,h.jsxs)(o.Box,{mx:2,display:"flex",alignItems:"center",style:{gap:"4px"},children:[(0,h.jsx)("img",{src:Zs,alt:"WhatsApp",className:t.walletIcon}),(0,h.jsxs)(o.Typography,{color:"primary",variant:"h4",children:["Ad Credit: ","USD"===m.currency?"$":"₹"," ",(m.metaAdsCredit||0).toFixed(2)]})]})]}),(0,h.jsx)(o.Grid,{item:!0,children:(0,h.jsx)(o.Box,{ml:2,mr:1,display:"flex",alignItems:"center",children:(0,h.jsx)(B,{name:"gingerLauncher"})})}),(0,h.jsxs)(o.Box,{className:t.buttonContainer,children:[r>=2&&(!l||l!==J.kA&&m?.partner?.isZohoEnabled&&"NONE"!==m?.activePlan)&&("ENTERPRISE"!==d||c)&&(0,h.jsx)(o.Tooltip,{title:u?.length?"Clear your pending invoice to buy ad credits.":p?"A payment is already being processed. Please wait for it to complete.":"",arrow:!0,children:(0,h.jsx)("span",{children:(0,h.jsx)(o.Button,{onClick:()=>{b()},variant:"outlined",color:"primary",disabled:p||u?.length,className:t.buyCreditsButton,children:"Buy Credits"})})}),(0,h.jsx)(hs,{accountValue:s,pageValue:i,fullWidthOnXs:!0})]})]})}
1function li(e){let{assistantDetails:t,agent:a,pageValue:n,pagesResolved:s,adAccountSetupCompleted:i}=e;return(0,h.jsx)(o.Grid,{container:!0,justify:"center",alignItems:"center",style:{background:"rgb(247 247 247)"},children:(0,h.jsx)(o.Grid,{item:!0,xs:12,md:11,lg:11,children:(0,h.jsx)(o.Box,{mt:3,mb:3,width:"100%",children:t?.fbConnected&&(!s||n?.whatsappNumber||i)?(0,h.jsx)(Qt,{mt:0,mb:0}):(0,h.jsx)(B,{name:"adCreditReward",fallback:L()?(0,h.jsx)(so,{propStyles:{background:"#02545A"},whatsappNumberLinked:n?.whatsappNumber,assistantDetails:t,agentDetails:a}):null,propStyles:{background:"#02545A"},whatsappNumberLinked:n?.whatsappNumber,assistantDetails:t,agentDetails:a})})})})}var di=a(64128),ci=a(90175);const pi=(e,t)=>{if(!e)return!1;const a=Xt("isKnownPlan",null)(e,t);if("boolean"==typeof a)return a;const n="v3"===t?di.V3_PLANS:ci.V4_PLANS;return Boolean(n[e])};class ui extends n.Component{constructor(e){const{fbConnected:t,selectedMetaAdAccountId:a}=e.assistantDetails;super(e),this.state={tab:localStorage.getItem(`${this.props.match.params.projectId}aisensySelectedTabForAdsManager`)||"aisensy_ads",sticky:!1,fbaccount:[],fbpages:[],accountValue:null,selectedAdAccount:JSON.parse(localStorage.getItem(`${this.props.match.params.projectId}aisensySelectedAdAccountForFetchedAds`))||null,pageValue:{},pagesResolved:!1,adAccountSetupCompleted:!1,isSyncing:!1,isLoading:!1,snack:{},linkAd:!1,templatedialogOpen:!1,upgradePlanDialog:!1,fetchedAds:!1}}rootEle=(()=>s().createRef())();toggleTemplateCreditDialog=()=>{this.setState({templatedialogOpen:!this.state.templatedialogOpen})};sortByBusinessName=e=>e.sort((function(e,t){return e.metaBusinessName<t.metaBusinessName?-1:e.metaBusinessName>t.metaBusinessName?1:0}));componentDidMount=()=>{const{assistantDetails:e}=this.props,{assistantId:t,fbConnected:a}=e||{};a&&this.fetchMetaAdAccount(t)};componentDidUpdate=(e,t)=>{const{assistantDetails:a}=this.props,{fbConnected:n,assistantId:s}=a||{},{accountValue:o,tab:i,fetchedAds:r}=this.state,l=o?.accountId;e.assistantDetails?.assistantId!==this.props.assistantDetails?.assistantId&&this.props.assistantDetails.fbConnected&&this.fetchMetaAdAccount(this.props.assistantDetails?.assistantId),e.assistantDetails?.selectedMetaAdAccountId!==this.props.assistantDetails?.selectedMetaAdAccountId&&this.getFbAcc(this.props.assistantDetails?.assistantId),e.assistantDetails?.selectedMetaPageId!==this.props.assistantDetails?.selectedMetaPageId&&this.getFbPages(this.props.assistantDetails?.assistantId),n&&s&&l&&!r&&"aisensy_ads"===i&&(this.setState({fetchedAds:!0}),this.fetchAdsMetaAcc())};selectAdAccount=e=>{const t=JSON.stringify(e),a=this.props.match.params.projectId;this.setState({selectedAdAccount:e},(()=>{localStorage.setItem(`${a}aisensySelectedAdAccountForFetchedAds`,t)}))};fetchMetaAdAccount=async e=>{await this.props.loadMetaAdSetup(e).then((e=>{const{isValid:t,userId:a,pageId:n,adAccountId:s}=e,{adAccountSetupCompleted:o}=e;this.setState({adAccountSetupCompleted:o}),this.props.updateAssistantStore({fbConnected:t,selectedMetaPageId:t?n:"",selectedMetaAdAccountId:t?s:""}),this.props.updateAdSetupStore({fbConnected:t,selectedMetaPageId:t?n:"",selectedMetaAdAccountId:t?s:""})})).catch((e=>{console.log({error:e})})),this.getFbAcc(e),this.getFbPages(e)};updateWhatsappNumber=e=>{const t=this.state.fbpages.map((t=>(t.pageId===this.state.pageValue?.pageId&&(t.whatsappNumber=e),t)));this.setState({pageValue:{...this.state.pageValue,whatsappNumber:e},fbpages:t})};switchTab=e=>{const t=this.props.match.params.projectId;localStorage.setItem(`${t}aisensySelectedTabForAdsManager`,e),this.setState({tab:e})};listScrolled=e=>{this.offsetPosition||(this.offsetPosition=this.rootEle.current.offsetTop);const t=e.currentTarget.scrollTop;this.setState({sticky:t>this.offsetPosition-59})};modifyList=(e,t)=>{const{freezedMetaPageId:a,freezedMetaAdAccountId:n}=this.props?.assistantDetails;return(0,ts.isEmpty)(e)?[]:e?.map((e=>{const{metaBusinessId:s,isAssigned:o,pageId:i,accountId:r}=e||{};let l=!1;i&&""!==t?l=i===(t=t||a):r&&""!==t&&(l=r===(t=t||n));let d="Limited";return o?d="Assigned":s||(d="Personal"),{...e,tag:d,freezed:l}}))};getFbPages=e=>{e&&(this.setState({isLoading:!0}),this.props.loadPages(e).then((e=>{e={data:e};const{selectedMetaPageId:t,freezedMetaPageId:a,freezedMetaAdAccountId:n,fbConnectedBy:s}=this.props?.assistantDetails,{id:o}=this.props.agent||{},i=this.modifyList(e.data);this.setState({fbpages:i,isLoading:!1},(()=>
1{if(s&&s!==o&&n){const t=a?e.data?.find((e=>{let{pageId:t}=e;return t===a})):{};this.setState({pageValue:t,pagesResolved:!0})}else if(t){const a=e.data?.find((e=>{let{pageId:a}=e;return a===t}));this.setState({pageValue:a,pagesResolved:!0})}else this.setState({pagesResolved:!0})}))})).catch((e=>{console.log("error:",e),this.setState({isLoading:!1,pagesResolved:!0})})))};getFbAcc=e=>{e&&(this.setState({isLoading:!0}),this.props.loadAdAccounts(e).then((e=>{e={data:e};const{selectedMetaAdAccountId:t,freezedMetaAdAccountId:a,fbConnectedBy:n}=this.props.assistantDetails||{},{id:s}=this.props.agent||{},o=this.modifyList(e.data);this.setState({fbaccount:o,isLoading:!1},(()=>{if(n&&n!==s&&a){const t=e.data?.find((e=>{let{isChildBm:t}=e;return t}));this.setState({accountValue:t},(()=>{this.syncMetaAcc()}))}else if(t){const a=e.data?.find((e=>{let{accountId:a}=e;return a===t}));this.setState({accountValue:a},(()=>{this.syncMetaAcc()}))}}))})).catch((e=>{console.log("error:",e),this.setState({isLoading:!1})})))};saveAdProfile=(e,t)=>{const{assistantId:a}=this.props?.assistantDetails;(0,ts.isEmpty)(e)||(0,ts.isEmpty)(t)||this.props.saveAdProfile({assistantId:a,selectedMetaAdAccountId:e.accountId,selectedMetaPageId:t.pageId}).then((()=>{})).catch((e=>console.log("error:",e)))};selectPage=e=>{this.setState({pageValue:e},(()=>{const{freezedMetaAdAccountId:t,fbConnectedBy:a}=this.props?.assistantDetails,{id:n}=this.props?.agent;if(!a||a===n||!t){const{accountValue:t}=this.state;this.props.updateAssistantStore({selectedMetaPageId:e.pageId}),this.saveAdProfile(t,e)}}))};updateStateValue=e=>{this.setState(e)};syncMetaAcc=e=>{const{fbConnected:t,assistantId:a}=this.props.assistantDetails,{accountValue:n,tab:s,selectedAdAccount:o}=this.state,i="aisensy_ads"===s?n?.accountId:o?.accountId;t&&i&&a&&(this.setState({isSyncing:!0}),this.props.syncMetaAdAccount({assistantId:a,adAccountId:i,mode:e}).then((e=>{e={data:e};const{adAccountData:t,message:a}=e.data||{};this.setState({isSyncing:!1,..."aisensy_ads"===s?{accountValue:t}:{selectedAdAccount:t}})})).catch((e=>{console.log("error:",e);const{action:t,message:a,assistant:n}=e?.response?.data||{};if("reconnect"===t&&n){const{fbConnected:e,fbUserId:t,fbGrantedScopes:s,selectedMetaPageId:o,selectedMetaAdAccountId:i,freezedMetaAdAccountId:r,freezedMetaPageId:l}=n||{};this.props.updateAssistantStore({fbConnected:e,fbUserId:t,fbGrantedScopes:s,selectedMetaPageId:o,selectedMetaAdAccountId:i,freezedMetaAdAccountId:r,freezedMetaPageId:l}),this.setState({snack:{open:!0,severity:"error",message:a||"Session expired, Please re-connect Facebook"},isSyncing:!1,tab:"setup",pageValue:{},fbaccount:[],fbpages:[]})}else this.setState({isSyncing:!1,snack:{open:!0,severity:"error",message:e?.response?.data?.message||"Something went wrong"}})})))};fetchAdsMetaAcc=()=>{const{fbConnected:e,assistantId:t}=this.props.assistantDetails,{accountValue:a}=this.state,n=a?.accountId;e&&n&&t&&(this.setState({isSyncing:!0}),this.props.loadNewCtwAds({assistantId:t,adAccountId:n}).then((()=>{})).catch((e=>{console.log("error:",e)})))};closeLinkAdDialog=()=>{this.setState({linkAd:!1})};render(){const{classes:e}=this.props,{projectId:t}=this.props.match.params,{tab:a,pageValue:n,accountValue:s,fbaccount:i,snack:r,linkAd:l,selectedAccountValue:d}=this.state,{whatsappNumber:c,fbConnected:p,fbConnectedBy:u,freezedMetaAdAccountId:m,partnerId:g,metaAdsCredit:b,freeTierCoversationCount:y,currency:x,ongoingBillingProcess:f,cbpType:A,allowPurchase:I,pendingInvoices:C,providerType:_,autoWccRecharge:S,type:v,activePlan:E}=this.props.assistantDetails,{id:T,power:D}=this.props.agent,w=window.innerWidth<650,N=window.innerWidth<460,j="v3"===v?pi(E,"v3"):"FREE_FOREVER"!==E&&pi(E,"v4"),k="FREE_FOREVER"===E;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:`${e.root} ginger-page-root`,onScroll:this.listScrolled,children:[(0,h.jsx)(ri,{classes:e,sticky:this.state.sticky,fbConnected:p,accountValue:s,pageValue:n,power:D,partnerId:g,cbpType:A,allowPurchase:I,ongoingBillingProcess:f,pendingInvoices:C,assistantDetails:this.props.assistantDetails,onLinkAd:()=>this.setState({linkAd:!0}),onBuyCredits:this.toggleTemplateCreditDialog}),(0,h.jsx)(li,{assistantDetails:this.props.assistantDetails,agent:this.props.agent,pageValue:n,pagesResolved:this.state.pagesResolved,adAccountSetupCompleted:this.state.adAccountSetupCompleted}),(0,h.jsx)(o.Grid,{container:!0,alignItems:"center",justify:"center",ref:this.rootEle,className:e.searchboxContainer,style:{background:this.state.sticky?"white":"rgb(247 247 247)",boxShadow:this.state.sticky?"rgb(235 234 234) 0px 0px 11px":"none",maxHeight:N?"170px":w?"130px":"70px",marginBottom:"1em",paddingTop:"20px"},children:(0,h.jsx)(o.Grid,{container:!0,xs:12,md:11,lg:11,justify:"space-between",alignItems:"center",children:(0,h.jsx)(o.Grid,{item:!0,children:(0,h.jsxs)(o.Tabs,{value:a,onChange:(e,t)=>
1{k&&"system"===t?this.setState({upgradePlanDialog:!0}):this.switchTab(t)},indicatorColor:"primary",textColor:"primary",variant:"scrollable",scrollButtons:"auto","aria-label":"scrollable auto tabs example",TabIndicatorProps:{className:e.tabIndicator},children:[(0,h.jsx)(o.Tab,{label:(this.props.assistantDetails?.partner?.brandName||"AiSensy")+" Ads",value:"aisensy_ads",className:e.tabs}),(0,h.jsx)(o.Tab,{label:"Fetched Ads",value:"system",className:e.tabs})]})})})}),(0,h.jsx)(o.Grid,{container:!0,justify:"center",alignItems:"center",children:(0,h.jsx)("div",{className:`${e.detailContainer} `,children:"system"===a?k?this.setState({upgradePlanDialog:!0})&&null:(0,h.jsx)(o.Box,{children:(0,h.jsx)(ii,{switchTab:this.switchTab,pageData:n,isSyncing:this.state.isSyncing,isLoading:this.state.isLoading,accountValue:this.state.selectedAdAccount,updateStateValue:this.updateStateValue,tab:a,agentId:T,selectAdAccount:this.selectAdAccount,fbaccount:i,syncMetaAcc:this.syncMetaAcc})}):"aisensy_ads"===a?(0,h.jsx)(o.Box,{children:(0,h.jsx)(ii,{switchTab:this.switchTab,pageData:n,isSyncing:this.state.isSyncing,isLoading:this.state.isLoading,accountValue:this.state.accountValue?.isChildBMAdAccount?this.state.accountValue:{},updateStateValue:this.updateStateValue,tab:a,agentId:T,syncMetaAcc:this.syncMetaAcc,fbaccount:i})}):(0,h.jsx)(o.Box,{})})}),(0,h.jsx)(B,{name:"upgradePlanWrapper",purchaseNew:!j,dialogOpen:this.state.upgradePlanDialog,toggleUpgradeDialog:()=>{this.setState({upgradePlanDialog:!1})}}),r.open&&(0,h.jsx)(o.Snackbar,{open:r.open,onClose:()=>{this.setState({snack:{}})},anchorOrigin:{vertical:"top",horizontal:"center"},autoHideDuration:3e3,children:(0,h.jsx)(O.Alert,{severity:r.severity,onClose:()=>{this.setState({snack:{}})},children:r.message})}),l&&(0,h.jsx)(ps,{open:l,onClose:this.closeLinkAdDialog})]}),(0,h.jsx)(B,{name:"metaAdsCreditDialog",dialogOpen:this.state.templatedialogOpen,toggleTemplateCreditDialog:this.toggleTemplateCreditDialog,assistantDetails:this.props.assistantDetails})]})}}const mi=(0,i.connect)((e=>({assistantDetails:e.assistantDetails.data,agent:e.login.user})),{updateAssistantStore:$.nt,updateAdSetupStore:$.jW,loadMetaAdSetup:M.cg,loadPages:M.VJ,loadAdAccounts:M.ae,saveAdProfile:M.KT,syncMetaAdAccount:M.ZM,loadNewCtwAds:uo.xx})(ui),hi=(0,o.withStyles)((e=>({root:{width:"100%",height:"100%",background:"rgb(247, 247, 247)",boxSizing:"border-box",overflowX:"hidden",position:"relative"},pageTitleContainer:{position:"sticky",zIndex:100,top:0,height:60,boxSizing:"border-box",boxShadow:"0 0 11px rgb(230 230 230)",[e.breakpoints.down("md")]:{},[e.breakpoints.down("sm")]:{},[e.breakpoints.down("xs")]:{height:"fit-content"}},tabs:{fontSize:"14px",textTransform:"none",borderBottom:"2px solid #f0f0f0",display:"flex"},tabs2:{fontSize:"14px",textTransform:"none",borderBottom:"2px solid #f0f0f0"},guideContainer:{background:"white",borderRadius:"8px"},tabIndicator:{borderRadius:"0px 0px 0px 0px",height:3},tabPageTitleContainer:{position:"sticky",zIndex:100,top:0,height:124,boxShadow:"0 0 12px rgb(171 170 170)",boxSizing:"border-box"},detailContainer:{top:"60px",minHeight:"250px",height:"calc(100vh - 260px)",width:"100%",boxSizing:"border-box",[e.breakpoints.down("sm")]:{height:"calc(100vh - 70px - 50px - 10px - 50px)",paddingLeft:e.spacing(1),paddingRight:e.spacing(1),boxSizing:"border-box"}},autoComplete:{'& [class*=MuiAutocomplete-option][aria-disabled="true"]':{pointerEvents:"inherit",background:"white"},'& [class*=MuiAutocomplete-option][aria-disabled="true"]:active':{pointerEvents:"none",background:"white"}},textField:{width:200,padding:"2px 16px"},arrow:{color:"white"},fullWidth:{width:"100%",background:"white"},betaBadge:{color:"white",fontWeight:"600",marginLeft:"0.4em",height:"1.5em",alignItems:"center",fontSize:"0.7em"},searchboxContainer:{transition:"all 0.2s",position:"sticky",top:60,zIndex:50},textFieldRootAutocomplete:{width:"18em",[e.breakpoints.down("xs")]:{width:"14em"}},launchButton:{[e.breakpoints.down("sm")]:{padding:"4px 10px",fontSize:"0.8125rem"}},walletIcon:{width:"24px",height:"24px"},buttonContainer:{display:"flex",justifyContent:"space-between",gap:"1em",alignItems:"center",paddingLeft:"8px",[e.breakpoints.down("xs")]:{marginTop:"12px",marginBottom:"4px",width:"100%",justifyContent:"space-between"}},buyCreditsButtonContainer:{width:"fit-content",[e.breakpoints.down("xs")]:{width:"100%"}}
1,buyCreditsButton:{marginLeft:"16px",padding:"6px 16px",fontSize:"14px",[e.breakpoints.down("sm")]:{marginLeft:"0px",padding:"4px 10px",fontSize:"0.8125rem",width:"100%"}}})))(mi);var gi=a(58416),bi=a(59612),yi=a(50802),xi=a(8942),fi=a(17133),Ai=a(94796),Ii=a(70099),Ci=a(59514),_i=a(75107),Si=a(93893),vi=a(47504),Ei=a(48697),Ti=a(63324),Di=a(48309),wi=a(20085),Ni=a(98445),ji=a(52119),ki=a(60250),Li=a(87677),Ri=a(47489),Bi=a(88918),Oi=a(31127),Pi=a(66212),Mi=a(979),Ui=a(27827),Fi=a(36462),Wi=a(20543),zi=a(19312);const Gi={all:"All Time",today:"Today",yesterday:"Yesterday",thisWeek:"This Week",thisMonth:"This Month"};class Hi extends s().Component{state=(()=>({selectedOption:null===this.props.startDate&&null===this.props.endDate?"all":"today",previousSelectedOption:null===this.props.startDate&&null===this.props.endDate?"all":"today",openCustomDialog:!1,customStartDate:this.props.startDate||(0,Oi.A)(new Date),customEndDate:this.props.endDate||(0,Pi.A)(new Date),focusedInput:null}))();componentDidUpdate(e){e.startDate===this.props.startDate&&e.endDate===this.props.endDate||(null===this.props.startDate&&null===this.props.endDate?"all"!==this.state.selectedOption&&this.setState({selectedOption:"all"}):null!==this.props.startDate&&null!==this.props.endDate&&"all"===this.state.selectedOption&&this.setState({selectedOption:"today"}))}handleChange=e=>{const t=e.target.value;if(this.setState((e=>({selectedOption:t,previousSelectedOption:e.selectedOption,customStartDate:e.customStartDate,customEndDate:e.customEndDate}))),"custom"===t)return void this.setState({openCustomDialog:!0});if("all"===t)return void this.props.onChange(null,null);let a,n;switch(t){case"today":default:a=(0,Oi.A)(new Date),n=(0,Pi.A)(new Date);break;case"yesterday":const e=(0,Mi.A)(new Date,1);a=(0,Oi.A)(e),n=(0,Pi.A)(e);break;case"thisWeek":a=(0,Ui.A)(new Date),n=(0,Fi.A)(new Date);break;case"thisMonth":a=(0,Wi.A)(new Date),n=(0,zi.A)(new Date)}this.props.onChange(a,n)};handleCustomDateSubmit=()=>{this.setState({previousSelectedOption:"custom",openCustomDialog:!1}),this.props.onChange(this.state.customStartDate,this.state.customEndDate)};handleClose=()=>{this.setState({openCustomDialog:!1,selectedOption:this.state.previousSelectedOption,customStartDate:this.props.startDate,customEndDate:this.props.endDate})};render(){const e=e=>e.toLocaleDateString("en-GB"),t="custom"===this.state.selectedOption?`${e(this.state.customStartDate)} - ${e(this.state.customEndDate)}`:this.state.selectedOption,{label:a,className:n,disableUnderline:s,IconComponent:i}=this.props,r={};return n&&(r.className=n),s&&(r.disableUnderline=!0),i&&(r.IconComponent=i),a&&(r.renderValue=e=>`${a}: ${"custom"===e?t:Gi[e]||e}`,r.MenuProps={getContentAnchorEl:null,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},style:{marginTop:5}}),(0,h.jsxs)(Bi.MuiPickersUtilsProvider,{utils:Ri.A,children:[(0,h.jsxs)(o.Select,{value:this.state.selectedOption,onChange:this.handleChange,...r,children:[(0,h.jsx)(o.MenuItem,{value:"all",children:"All"}),(0,h.jsx)(o.MenuItem,{value:"today",children:"Today"}),(0,h.jsx)(o.MenuItem,{value:"yesterday",children:"Yesterday"}),(0,h.jsx)(o.MenuItem,{value:"thisWeek",children:"This Week"}),(0,h.jsx)(o.MenuItem,{value:"thisMonth",children:"This Month"}),(0,h.jsx)(o.MenuItem,{value:"custom",onClick:()=>this.setState({openCustomDialog:!0}),children:"custom"===this.state.selectedOption?t:"Custom Range"})]}),(0,h.jsxs)(o.Dialog,{open:this.state.openCustomDialog,onClose:this.handleClose,PaperProps:{style:{overflow:"visible"}},children:[(0,h.jsxs)("div",{style:{display:"flex",justifyContent:"space-between"},children:[(0,h.jsx)(o.DialogTitle,{children:(0,h.jsx)(o.Typography,{variant:"h4",children:"Personalized Date Range"})}),(0,h.jsx)(o.IconButton,{onClick:this.handleClose,children:(0,h.jsx)(d.Close,{})})]}),(0,h.jsx)(o.Divider,{}),(0,h.jsxs)(o.DialogContent,{style:{overflow:"visible"},children:[" ",(0,h.jsx)(o.Typography,{variant:"body1",style:{marginBottom:"5px",marginTop:"15px"},children:"Custom Date Range"}),(0,h.jsx)("div",{style:{paddingBottom:"20px"},children:(0,h.jsx)(Fa.DateRangePicker,{startDatePlaceholderText:"From",endDatePlaceholderText:"To",startDate:ve()(this.state.customStartDate),endDate:ve()(this.state.customEndDate),onDatesChange:e=>{let{startDate:t,endDate:a}=e;t&&a&&t.isAfter(a)||this.setState({customStartDate:t?.toDate()||null,customEndDate:a?.toDate()||null})},focusedInput:this.state.focusedInput,onFocusChange:e=>this.setState({focusedInput:e}),startDateId:"endDateCustom",endDateId:"startDateCustom",numberOfMonths:1,isOutsideRange:e=>!!e.isAfter(ve()(),"day")||!!this.state.focusedInput&&("startDate"===this.state.focusedInput&&this.state.customEndDate?e.isAfter(ve()(this.state.customEndDate)):!("endDate"!==this.state.focusedInput||!this.state.customStartDate)&&e.isBefore(ve()(this.state.customStartDate))),navPrev:(0,h.jsx)(Vi,{children:(0,h.jsx)(d.NavigateBefore,{})}),navNext:(0,h.jsx)(Vi,{children:(0,h.jsx)(d.NavigateNext,{})}),minimumNights:0,readOnly:!0,navPosition:"navPositionTop",hideKeyboardShortcutsPanel:!0,screenReaderInputMessage:" ",small:!0,customArrowIcon:null,displayFormat:"DD/MM/YYYY"})})]}),(0,h.jsx)(o.Divider,{}),(0,h.jsxs)(o.DialogActions,{children:[(0,h.jsx)(o.Button,{onClick:this.handleClose,color:"primary",variant:"outlined",children:"Cancel"}),(0,h.jsx)(o.Button,{onClick:this.handleCustomDateSubmit,color:"primary",variant:"contained",disabled:!this.state.customStartDate||!this.state.customEndDate,children:"Confirm"})]})]})]})}}function Vi(e){return(0,h.jsx)("div",{children:(0,h.jsx)(o.IconButton,{size:"small",children:e.children})})}const Yi=Hi;var Zi=a(39574),Ki=a(4179);const Ji=(0,o.makeStyles)((e=>({container:{position:"relative",display:"block",width:"100%"},dropdown:{position:"fixed",backgroundColor:e.palette.background.paper,border:`1px solid ${e.palette.divider}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",zIndex:999999,width:"520px",maxHeight:"420px",overflow:"hidden",[e.breakpoints.down("sm")]:{width:"100vw",height:"100vh",borderRadius:"0",boxShadow:"none",left:"0 !important",right:"0",bottom:"0",top:"0 !important",border:"none"}},dropdownContent:{padding:"24px",display:"flex",gap:"32px",[e.breakpoints.down("sm")]:{padding:"20px 16px",gap:"16px",flexDirection:"column",height:"100%",overflow:"auto",justifyContent:"flex-start"}},leftSection:{flex:"0 0 200px",display:"flex",flexDirection:"column",gap:"16px",[e.breakpoints.down("sm")]:{flex:"none",width:"100%",gap:"12px",alignItems:"center"}},rightSection:{flex:1,display:"flex",flexDirection:"column",gap:"12px",[e.breakpoints.down("sm")]:{width:"100%",gap:"8px"}},title:{fontSize:"16px",fontWeight:600,color:e.palette.text.primary,marginBottom:"16
1px"},previewBox:{width:"120px",height:"90px",border:`1px solid ${e.palette.divider}`,borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:e.palette.background.default,margin:"0 auto",position:"relative",overflow:"hidden",[e.breakpoints.down("sm")]:{width:"150px",height:"110px"}},previewRatio:{position:"absolute",border:`1px solid ${e.palette.primary.main}`,backgroundColor:e.palette.primary.light+"20",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease"},previewText:{fontSize:"14px",color:e.palette.text.primary,fontWeight:500},dimensionsContainer:{display:"flex",flexDirection:"column",gap:"4px",alignItems:"center"},dimensionText:{fontSize:"12px",color:e.palette.text.secondary},ratiosContainer:{display:"flex",gap:"16px",[e.breakpoints.down("sm")]:{gap:"8px",flexDirection:"column"}},ratioColumn:{flex:1,display:"flex",flexDirection:"column",gap:"4px",[e.breakpoints.down("sm")]:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px"}},columnTitle:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px",fontSize:"12px",fontWeight:600,color:e.palette.text.primary,[e.breakpoints.down("sm")]:{gridColumn:"1 / -1",fontSize:"14px",marginBottom:"12px",fontWeight:600}},ratioOption:{padding:"8px 12px",borderRadius:"4px",cursor:"pointer",fontSize:"12px",color:e.palette.text.primary,display:"flex",alignItems:"center",justifyContent:"space-between",transition:"all 0.2s ease","&:hover":{backgroundColor:e.palette.action.hover},"&.selected":{backgroundColor:e.palette.primary.main,color:"white"},[e.breakpoints.down("sm")]:{padding:"12px 16px",fontSize:"14px",minHeight:"48px",borderRadius:"8px",fontWeight:500,marginBottom:"6px"}},additionalOptions:{display:"flex",flexDirection:"column",gap:"4px",marginTop:"8px",[e.breakpoints.down("sm")]:{gap:"6px",marginTop:"12px"}},dragHandle:{width:"40px",height:"4px",backgroundColor:e.palette.divider,borderRadius:"2px",margin:"8px auto 16px",display:"none",[e.breakpoints.down("sm")]:{display:"block"}},closeButton:{position:"absolute",top:"16px",right:"16px",zIndex:10,display:"none",[e.breakpoints.down("sm")]:{display:"block"}},mobileDrawer:{[e.breakpoints.down("sm")]:{'& .MuiDrawer-paper, & [class*="MuiDrawer-paper-"]':{width:"100vw",maxWidth:"100vw",backgroundColor:"#ffffff",boxShadow:"-4px 0 20px rgba(0, 0, 0, 0.1)"}}}}))),$i={portrait:[{value:"9:16",label:"9:16"},{value:"2:3",label:"2:3"},{value:"3:4",label:"3:4"}],landscape:[{value:"16:9",label:"16:9"},{value:"3:2",label:"3:2"},{value:"4:3",label:"4:3"}],additional:[{value:"1:1",label:"1:1 (Square)"}]},qi=e=>{let{currentRatio:t,onRatioChange:a,children:s}=e;const i=Ji(),r=(0,o.useTheme)(),[l,d]=(0,n.useState)(!1),[c,p]=(0,n.useState)(t||"4:5"),[u,m]=(0,n.useState)({top:0,left:0}),g=(0,n.useRef)(null),b=e=>{p(e.value)},y=e=>{p(e.value),a(e.value),d(!1)},x=window.innerWidth<600;(0,n.useEffect)((()=>{const e=()=>{l&&!x&&d(!1)};return l&&!x&&(window.addEventListener("scroll",e,!0),document.addEventListener("scroll",e,!0)),()=>{window.removeEventListener("scroll",e,!0),document.removeEventListener("scroll",e,!0)}}),[l,x]);const f=(e=>{const[t,a]=e.split(":").map(Number),n=t/a;return n>1?{width:60,height:60/n}:{width:60*n,height:60}})(c),A=(e=>{const[t,a]=e.split(":").map(Number),n=1200,s=t/a;return s>1?{width:n,height:Math.round(n/s)}:{width:Math.round(n*s),height:n}})(c),I=()=>(0,h.jsxs)(o.Box,{className:i.dropdownContent,children:[(0,h.jsxs)(o.Box,{className:i.leftSection,children:[(0,h.jsx)(o.Typography,{className:i.title,children:"Aspect ratio"}),(0,h.jsx)(o.Box,{className:i.previewBox,children:(0,h.jsx)(o.Box,{className:i.previewRatio,style:{width:f.width,height:f.height,top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:(0,h.jsx)(o.Typography,{className:i.previewText,children:c})})}),(0,h.jsxs)(o.Box,{className:i.dimensionsContainer,children:[(0,h.jsxs)(o.Typography,{className:i.dimensionText,children:["Width ",A.width," px"]}),(0,h.jsxs)(o.Typography,{className:i.dimensionText,children:["Height ",A.height," px"]})]})]}),(0,h.jsxs)(o.Box,{className:i.rightSection,children:[(0,h.jsxs)(o.Box,{className:i.ratiosContainer,children:[(0,h.jsxs)(o.Box,{className:i.ratioColumn,children:[(0,h.jsxs)(o.Box,{className:i.columnTitle,children:[(0,h.jsx)(Zi.A,{size:16,style:{color:r.palette.text.secondary}}),"Portrait"]}),$i.portrait.map((e=>(0,h.jsx)(o.Box,{className:`${i.ratioOption} ${c===e.value?"selected":""}`,onMouseEnter:()=>b(e),onClick:()=>y(e),children:e.label},e.value)))]}),(0,h.jsxs)(o.Box,{className:i.ratioColumn,children:[(0,h.jsxs)(o.Box,{className:i.columnTitle,children:[(0,h.jsx)(Ki.A,{size:16,style:{color:r.palette.text.secondary}}),"Landscape"]}),$i.landscape.map((e=>(0,h.jsx)(o.Box,{className:`${i.ratioOption} ${c===e.value?"selected":""}`,onMouseEnter:()=>b(e),onClick:()=>y(e),children:e.label},e.value)))]})]}),(0,h.jsx)(o.Box,{className:i.additionalOptions,children:$i.additional.map((e=>(0,h.jsx)(o.Box,{className:`${i.ratioOption} ${c===e.value?"selected":""}`,onMouseEnter:()=>b(e),onClick:()=>y(e),children:e.label},e.value)))})]})]});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Box,{ref:g,className:i.container,onClick:()=>{l?d(!1):((()=>
1{if(g.current){const e=g.current.getBoundingClientRect();let t,a;if(window.innerWidth<600)t=0,a=0;else{const n=520;t=e.bottom+4,a=e.left;const s=window.innerWidth-n;a>s&&(a=s)}m({top:t,left:a})}})(),d(!0))},children:s}),x?(0,h.jsx)(o.Drawer,{anchor:"right",open:l,onClose:()=>d(!1),className:i.mobileDrawer,PaperProps:{style:{width:"100vw",maxWidth:"100vw",backgroundColor:"#ffffff",boxShadow:"-4px 0 20px rgba(0, 0, 0, 0.1)"}},children:(0,h.jsxs)(o.Box,{style:{display:"flex",flexDirection:"column",height:"100%",overflowX:"hidden"},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${r.palette.divider}`,backgroundColor:r.palette.background.paper},children:[(0,h.jsx)(o.Typography,{variant:"h6",style:{fontWeight:600},children:"Select Aspect Ratio"}),(0,h.jsx)(o.Box,{onClick:()=>d(!1),style:{cursor:"pointer",padding:"8px",borderRadius:"50%",backgroundColor:"rgba(0, 0, 0, 0.1)",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,h.jsx)(Ei.A,{size:24,color:"#666"})})]}),(0,h.jsx)(o.Box,{style:{flex:1,overflow:"auto"},children:I()})]})}):l&&(0,h.jsx)(o.Portal,{children:(0,h.jsx)(o.ClickAwayListener,{onClickAway:()=>{d(!1)},children:(0,h.jsx)(o.Box,{className:i.dropdown,style:{top:u.top,left:u.left},children:I()})})})]})};var Xi=a(45773);const Qi=(0,o.makeStyles)((e=>({root:{position:"relative",width:"100%",overflow:"hidden"},slideContainer:{display:"flex",transition:"transform 0.3s ease-in-out",padding:e.spacing(2,0)},slide:{flex:"0 0 100%",height:"auto",minHeight:"200px",minWidth:0,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"},navigationButton:{position:"absolute",top:"50%",transform:"translateY(-50%)",backgroundColor:"rgba(255, 255, 255, 0.8)","&:hover":{backgroundColor:"rgba(255, 255, 255, 0.9)"},padding:"3px"},prevButton:{left:0},nextButton:{right:0},dots:{display:"flex",justifyContent:"center",gap:e.spacing(1),marginTop:e.spacing(1),position:"relative",zIndex:1},dot:{width:8,height:8,borderRadius:"50%",backgroundColor:e.palette.grey[300],cursor:"pointer",transition:"background-color 0.3s"}}))),er=e=>{let{slides:t,currentSlide:a=0,updateCurrentSlide:s,activeColor:i="#0a474c",arrowsTop:r,syncSlideOnCountChange:l=!1}=e;
1const c=Qi(),[p,u]=(0,n.useState)(a),m=(0,n.useRef)(t.length);(0,n.useEffect)((()=>{l&&t.length!==m.current&&u(Math.min(Math.max(a,0),t.length-1)),m.current=t.length}),[t.length,a,l]);const g=(0,n.useCallback)((e=>{u(e),s&&s(e)}),[s]);return(0,h.jsxs)("div",{className:c.root,children:[(0,h.jsx)("div",{className:c.slideContainer,style:{transform:`translateX(-${100*p}%)`},children:t.map(((e,t)=>(0,h.jsx)("div",{className:c.slide,children:e},t)))}),(0,h.jsx)(o.IconButton,{className:`${c.navigationButton} ${c.prevButton}`,style:r?{top:r}:void 0,onClick:()=>{p>0&&g(p-1)},disabled:0===p,children:(0,h.jsx)(d.ChevronLeft,{})}),(0,h.jsx)(o.IconButton,{className:`${c.navigationButton} ${c.nextButton}`,style:r?{top:r}:void 0,onClick:()=>{p<t.length-1&&g(p+1)},disabled:p===t.length-1,children:(0,h.jsx)(d.ChevronRight,{})}),(0,h.jsx)("div",{className:c.dots,children:t.map(((e,t)=>(0,h.jsx)("div",{className:c.dot,style:{backgroundColor:t===p?i:void 0},onClick:()=>g(t)},t)))})]})};var tr=a(56108),ar=a(40605),nr=a(71785),sr=a(52036),or=a(67411),ir=a(35404);const rr=(0,o.makeStyles)((e=>({promptContainer:{padding:e.spacing(2),borderBottom:`1px solid ${e.palette.divider}`,transition:"all 0.2s ease",backgroundColor:e.palette.background.paper,"&:hover":{backgroundColor:"#f8f9fa"},"&:last-child":{borderBottom:"none"}},promptContent:{flex:1,minWidth:0,paddingRight:e.spacing(1)},iconButtonContainer:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:e.spacing(1),minWidth:"fit-content"}}))),lr=e=>{let{prompt:t,imageCount:a=0,styleType:n,aspectRatio:s,styles:i=[],mainResolutions:r=[],children:l,mediaType:d="image"}=e;const p=rr(),u=(0,o.useTheme)();return(0,h.jsxs)(o.Box,{className:p.promptContainer,children:[(0,h.jsxs)(o.Box,{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[(0,h.jsxs)(o.Box,{className:p.promptContent,children:[(0,h.jsx)(o.Typography,{variant:"body2",style:{marginBottom:"8px",fontWeight:500,fontSize:"14px",lineHeight:"20px",color:"#333"},children:t.length>120?t.slice(0,120)+"...":t}),(0,h.jsxs)(o.Typography,{variant:"caption",style:{color:"#666",fontSize:"12px",display:"flex",alignItems:"center",gap:"4px"},children:[(e=>{switch(e){case"AUTO":return(0,h.jsx)(c.A,{size:14,color:"#404040",style:{verticalAlign:"middle"}});case"GENERAL":return(0,h.jsx)(tr.A,{size:14,color:"#404040",style:{verticalAlign:"middle"}});case"REALISTIC":return(0,h.jsx)(ar.A,{size:14,color:"#404040",style:{verticalAlign:"middle"}});case"DESIGN":return(0,h.jsx)(nr.A,{size:14,color:"#404040",style:{verticalAlign:"middle"}});case"RENDER_3D":return(0,h.jsx)(sr.A,{size:14,color:"#404040",style:{verticalAlign:"middle"}});default:return(0,h.jsx)(or.A,{size:14,color:"#404040",style:{verticalAlign:"middle"}})}})(n)," ",i.find((e=>e.value===n))?.label," ","•"," ",s?r.find((e=>e.value===s))?.label:""]})]}),(0,h.jsxs)(o.Box,{className:p.iconButtonContainer,children:[(0,h.jsx)(o.Button,{size:"small",onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(t).then((()=>{})).catch((()=>{const e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}))},style:{display:"flex",alignItems:"center",gap:"4px",minWidth:"auto"},children:(0,h.jsx)(ir.A,{size:14})}),(0,h.jsx)(o.Typography,{variant:"caption",style:{color:"#666",fontSize:"12px",whiteSpace:"nowrap"},children:a>0?`${a} ${"video"===d?"Video":"Image"}${1!==a?"s":""}`:`No ${"video"===d?"videos":"images"} available`})]})]}),a>0&&(0,h.jsx)(o.Box,{style:{marginTop:u.spacing(2)},children:l})]})},dr=(0,o.makeStyles)((e=>({historyImagePreviewContainer:{marginTop:0},imageContainer:{position:"relative",overflow:"hidden",borderRadius:"8px",display:"flex",flexDirection:"column",alignItems:"center",flex:"1 1 0",minWidth:"120px",maxWidth:"calc(33.333% - 8px)",[e.breakpoints.down("sm")]:{minWidth:"100px",maxWidth:"calc(50% - 6px)"}},imageWrapper:{position:"relative",width:"100%",height:"200px",borderRadius:"8px",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f8f9fa",padding:"0px",boxSizing:"border-box"},image:{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",objectFit:"contain",display:"block"},actionButtons:{position:"absolute",top:"4px",right:"4px",display:"flex",gap:"4px",opacity:.9,transition:"opacity 0.2s ease",zIndex:15,pointerEvents:"auto"},actionButton:{backgroundColor:"rgba(255, 255, 255, 0.95)",color:"#0a474c",width:"36px",height:"36px",boxShadow:"0 2px 8px rgba(0,0,0,0.15)",zIndex:20,pointerEvents:"auto","&:hover":{backgroundColor:"rgba(255, 255, 255, 1)",boxShadow:"0 4px 12px rgba(0,0,0,0.2)"}},overlay:{position:"absolute",top:0,left:0,right:0,bottom:0,borderRadius:"8px",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"transparent",transition:"background-color 0.2s ease",pointerEvents:"none",zIndex:5},mobileImageContainer:{position:"relative",borderRadius:"8px",width:"100%",height:"auto",overflow:"hidden",border:"1px solid #E8E8E8",backgroundColor:"#f8f9fa",display:"flex",justifyContent:"center",alignItems:"center",padding:"0px",boxSizing:"border-box"},mobileImage:{width:"100%",height:"auto",maxWidth:"100%",maxHeight:"400px",objectFit:"contain",display:"block"},mobileActionButtons:{position:"absolute",top:"4px",right:"4px",display:"flex",gap:"4px",opacity:.9,zIndex:15,pointerEvents:"auto"},selectedOverlay:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"#258d3b1A",border:"2px s
1olid #0a474c",borderRadius:"6px",pointerEvents:"none"},desktopGrid:{display:"flex",gap:"12px",paddingTop:"8px",justifyContent:"flex-start",alignItems:"flex-start",flexWrap:"nowrap",width:"100%",overflowX:"auto",minHeight:"220px","&::-webkit-scrollbar":{height:"4px"},"&::-webkit-scrollbar-track":{backgroundColor:"#f1f1f1",borderRadius:"2px"},"&::-webkit-scrollbar-thumb":{backgroundColor:"#c1c1c1",borderRadius:"2px","&:hover":{backgroundColor:"#a8a8a8"}}},mobileCarouselContainer:{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"}}))),cr=e=>{let{images:t,promptId:a,onImageSelect:n,onImageModalOpen:s,onDownload:i,selectedIndex:r,onSelectedIndexChange:l,onHistoryDrawerToggle:d,prompt:c,timestamp:p,onPromptCopy:u,styleType:m,aspectRatio:g,styles:b=[],mainResolutions:y=[]}=e;const x=dr(),f=((0,o.useTheme)(),(e,t)=>{e.preventDefault(),e.stopPropagation(),t()}),A=e=>{e.currentTarget.style.opacity=1},I=e=>{e.currentTarget.style.opacity=0},C=e=>{const t=e.currentTarget.querySelector("button");t&&(t.style.opacity=1),e.currentTarget.style.backgroundColor="#258d3b1A"},_=e=>{const t=e.currentTarget.querySelector("button");t&&(t.style.opacity=0),e.currentTarget.style.backgroundColor="transparent"},S=t&&t.length>0?t[0].type:"image";return t&&0!==t.length?(0,h.jsx)(lr,{prompt:c,imageCount:t?.length||0,styleType:m,aspectRatio:g,styles:b,mainResolutions:y,mediaType:S,children:window.innerWidth>426?(0,h.jsx)(o.Box,{className:x.desktopGrid,children:t.map(((e,a)=>(0,h.jsx)(o.Box,{className:x.imageContainer,children:(0,h.jsxs)(o.Box,{className:x.imageWrapper,children:["video"===e.type?(0,h.jsx)("video",{src:e.url,poster:e.thumbnail,className:x.image,muted:!0,controls:!0}):(0,h.jsx)("img",{src:e.url,alt:`Generated ${e.type} ${a+1}`,className:x.image}),"video"===e.type&&(0,h.jsx)(o.Box,{style:{position:"absolute",top:"8px",right:"8px",backgroundColor:"rgba(0, 0, 0, 0.7)",borderRadius:"4px",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10},children:(0,h.jsx)(yi.A,{size:16,color:"white"})}),(0,h.jsxs)(o.Box,{className:x.actionButtons,onMouseEnter:A,onMouseLeave:I,children:[(0,h.jsx)(o.IconButton,{size:"small",onClick:n=>f(n,(()=>{s(e.url,e.fileName||`Generated ${"video"===e.type?"Video":"Image"} ${a+1}`,a,t.map((e=>e.url)))})),onMouseDown:e=>{e.stopPropagation()},className:x.actionButton,children:(0,h.jsx)(Ti.A,{size:16})}),(0,h.jsx)(o.IconButton,{size:"small",onClick:t=>f(t,(()=>{const t="video"===e.type?".mp4":".jpg",n="video"===e.type?`generated-video-${a+1}${t}`:`generated-image-${a+1}${t}`;i(e.url,n)})),onMouseDown:e=>{e.stopPropagation()},className:x.actionButton,children:(0,h.jsx)(Di.A,{size:16})})]}),(0,h.jsx)(o.Box,{className:x.overlay,onMouseEnter:C,onMouseLeave:_,children:(0,h.jsx)(o.Button,{variant:"contained",className:x.selectedButton,style:{opacity:0,transition:"opacity 0.2s",backgroundColor:"#0a474c",color:"white",fontWeight:500,padding:"8px 16px",borderRadius:"6px",boxShadow:"0 2px 8px rgba(0,0,0,0.2)",zIndex:25,pointerEvents:"auto"},onClick:()=>(e=>{l(null),console.log("History drawer media selected:",e),n(e.url,e.type,e.thumbnail),d()})(e),children:"video"===e.type?"Use Video":"Use Image"})})]})},a)))}):(0,h.jsx)(er,{slides:t.map(((e,a)=>(0,h.jsx)(o.Box,{className:x.mobileCarouselContainer,children:(0,h.jsxs)(o.Box,{className:x.mobileImageContainer,children:["video"===e.type?(0,h.jsx)("video",{src:e.url,poster:e.thumbnail,className:x.mobileImage,muted:!0,controls:!0}):(0,h.jsx)("img",{src:e.url,alt:`Generated ${e.type} ${a+1}`,className:x.mobileImage}),"video"===e.type&&(0,h.jsx)(o.Box,{style:{position:"absolute",top:"8px",right:"8px",backgroundColor:"rgba(0, 0, 0, 0.7)",borderRadius:"4px",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10},children:(0,h.jsx)(yi.A,{size:16,color:"white"})}),(0,h.jsxs)(o.Box,{className:x.mobileActionButtons,children:[(0,h.jsx)(o.IconButton,{size:"small",onClick:n=>f(n,(()=>{s(e.url,e.fileName||`Generated ${"video"===e.type?"Video":"Image"} ${a+1}`,a,t.map((e=>e.url)))})),onMouseDown:e=>{e.stopPropagation()},className:x.actionButton,children:(0,h.jsx)(Ti.A,{size:16})}),(0,h.jsx)(o.IconButton,{size:"small",onClick:t=>f(t,(()=>{const t="video"===e.type?".mp4":".jpg",n="video"===e.type?`generated-video-${a+1}${t}`:`generated-image-${a+1}${t}`;i(e.url,n)}
1)),onMouseDown:e=>{e.stopPropagation()},className:x.actionButton,children:(0,h.jsx)(Di.A,{size:16})})]}),(0,h.jsx)(o.Button,{variant:"contained",className:x.selectedButton,onClick:()=>(e=>{l(null),console.log("Mobile history drawer media selected:",e),n(e.url,e.type,e.thumbnail),d()})(e),style:{position:"absolute",bottom:"12px",left:"50%",transform:"translateX(-50%)",opacity:.9,backgroundColor:"#0a474c",color:"white",fontWeight:500,padding:"8px 16px",borderRadius:"6px",boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},children:r===a?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Xi.A,{size:16,style:{marginRight:"8px"}}),"Selected"]}):"video"===e.type?"Use Video":"Use Image"})]})},a))),updateCurrentSlide:()=>{}})}):(0,h.jsx)(lr,{prompt:c,imageCount:0,styleType:m,aspectRatio:g,styles:b,mainResolutions:y,mediaType:S})},pr=(0,o.makeStyles)((e=>({circularProgressContainer:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:5,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},circularProgressWrapper:{position:"relative",display:"inline-flex"},progressText:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"12px",fontWeight:600,color:e.palette.primary.main}}))),ur=e=>{let{progress:t=0}=e;const a=pr();return(0,h.jsx)(o.Box,{className:a.circularProgressContainer,children:(0,h.jsxs)(o.Box,{className:a.circularProgressWrapper,children:[(0,h.jsx)(o.CircularProgress,{variant:"determinate",value:t,size:60,thickness:4}),(0,h.jsxs)(o.Typography,{className:a.progressText,children:[Math.round(t),"%"]})]})})};var mr=a(43092),hr=a.n(mr),gr=a(72346),br=a(90336);const yr=async(e,t)=>{const a={...t,credentials:"include"};let n=await hr()(e,a);if(!n.ok&&401===n.status)try{await(0,br.u)(),n=await hr()(e,a)}catch(e){throw new Error("Authentication failed. Please try again.")}if(!n.ok){const e=await n.text();throw new Error(`${e}`)}return n},xr=[{value:"AUTO",label:"Auto"},{value:"GENERAL",label:"General"},{value:"REALISTIC",label:"Realistic"},{value:"DESIGN",label:"Design"},{value:"RENDER_3D",label:"3D Render"}],fr=[{value:"ASPECT_1_1",label:"1:1"},{value:"ASPECT_2_3",label:"2:3"},{value:"ASPECT_3_2",label:"3:2"},{value:"ASPECT_3_4",label:"3:4"},{value:"ASPECT_4_3",label:"4:3"},{value:"ASPECT_9_16",label:"9:16"},{value:"ASPECT_16_9",label:"16:9"}],Ar=(0,o.makeStyles)((e=>({container:{backgroundColor:e.palette.background.paper,backdropFilter:"blur(8px)"},headerContainer:{marginBottom:e.spacing(3),display:"flex",alignItems:"flex-start",gap:e.spacing(2),flexDirection:"column"},headerBadge:{borderRadius:"8px",padding:e.spacing(.75,1),display:"flex",alignItems:"center",gap:e.spacing(.5),flexWrap:"wrap"},sparklesIcon:{padding:e.spacing(.75,1),alignItems:"center",gap:e.spacing(.5),flexWrap:"wrap"},headerIcon:{color:e.palette.primary.main,animation:"pulse 2s infinite"},headerText:{fontSize:"0.875rem",fontWeight:600,color:e.palette.text.primary,paddingLeft:e.spacing(.5)},descriptionText:{color:e.palette.text.secondary},toggleContainer:{backgroundColor:"#f0f0f0",display:"flex",borderRadius:"8px",padding:"4px",width:"fit-content",minWidth:"200px",marginBottom:e.spacing(2)},toggleButton:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:e.spacing(.2),padding:e.spacing(.5,.5),borderRadius:"8px",border:"none",backgroundColor:"transparent",color:e.palette.text.secondary,fontSize:"0.7rem",fontWeight:600,cursor:"pointer",transition:"all 0.2s ease"},toggleButtonActive:{backgroundColor:"white",color:"black",borderRadius:"8px",transition:"all 0.2s ease"},tabContent:{marginTop:e.spacing(1.5)},templateButton:{width:"100%",justifyContent:"flex-start",gap:e.spacing(.75),borderRadius:"8px",border:`1px solid ${e.palette.divider}`,backgroundColor:e.palette.background.paper,padding:e.spacing(2),fontSize:"0.875rem",fontWeight:500,transition:"all 0.2s",marginBottom:e.spacing(1)},historyButton:{alignSelf:"flex-end",marginBottom:e.spacing(1),minWidth:"120px",height:"40px",fontSize:"0.875rem",fontWeight:500,borderRadius:"8px",backgroundColor:e.palette.background.paper,padding:e.spacing(1,2),transition:"all 0.2s","&:hover":{borderColor:e.palette.primary.main,backgroundColor:e.palette.primary.light+"10"}},dialogTitle:{display:"flex",alignItems:"center",gap:e.spacing(.8)},templateGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:e.spacing(2),marginTop:e.spacing(2),alignItems:"start"},templateCard:{position:"relative",overflow:"hidden",borderRadius:"12px",border:`1px solid ${e.palette.divider}`,backgroundColor:e.palette.background.paper,transition:"all 0.2s"}
1,templateImage:{aspectRatio:"16/9",width:"100%",overflow:"hidden"},templateImageContent:{height:"100%",width:"100%",objectFit:"cover",transition:"transform 0.3s"},templateInfo:{padding:e.spacing(1)},templateTitle:{fontSize:"0.875rem",fontWeight:600,color:e.palette.text.primary},templateDescription:{marginTop:e.spacing(.5),fontSize:"0.8rem",color:e.palette.text.secondary,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},promptField:{minHeight:"120px",marginTop:e.spacing(2),marginBottom:e.spacing(1.5),backgroundColor:e.palette.background.paper,borderRadius:"8px",border:`1px solid ${e.palette.divider}`},controlsContainer:{display:"flex",gap:e.spacing(.3),flexWrap:"wrap",alignItems:"flex-start",marginTop:e.spacing(1.5),justifyContent:"flex-start",width:"100%",maxWidth:"100%",overflow:"hidden",boxSizing:"border-box","& > *":{flex:"0 0 auto",minWidth:"70px",maxWidth:"100%",height:"auto",display:"flex",alignItems:"center",boxSizing:"border-box"},[e.breakpoints.down("lg")]:{gap:e.spacing(.6),"& > *":{minWidth:"65px",maxWidth:"100%"}},[e.breakpoints.down("md")]:{gap:e.spacing(.5),justifyContent:"flex-start","& > *":{minWidth:"60px",maxWidth:"100%"}},[e.breakpoints.down("sm")]:{flexDirection:"column",alignItems:"stretch",gap:e.spacing(1.5),"& > *":{width:"100%",minWidth:"unset",maxWidth:"100%",height:"auto",flex:"none"}}},mediaButton:{display:"flex",alignItems:"center",justifyContent:"center",gap:e.spacing(.5),borderRadius:"8px",border:`1px dashed ${e.palette.divider}`,backgroundColor:e.palette.background.paper,padding:e.spacing(2.5,2),transition:"all 0.2s",whiteSpace:"nowrap",fontSize:"0.8rem",minHeight:"40px",height:"40px",minWidth:"100px","&:hover":{borderColor:e.palette.primary.main,backgroundColor:e.palette.primary.light+"10"}},formControl:{display:"flex",flexDirection:"row",alignItems:"center",gap:e.spacing(.2),border:`1px solid ${e.palette.divider}`,borderRadius:"8px",minWidth:"12px",padding:e.spacing(.6),cursor:"pointer",transition:"all 0.2s ease-in-out","&:hover":{backgroundColor:"#f8f9fa",borderColor:e.palette.primary.main},[e.breakpoints.down("sm")]:{width:"90% !important",minWidth:"unset !important",maxWidth:"100% !important",justifyContent:"space-between",padding:e.spacing(1),flex:"1 1 auto !important"},'& .MuiInputLabel-root, & [class*="MuiInputLabel-root-"]':{fontSize:"0.75rem",color:e.palette.text.secondary,transform:"translate(14px, 9px) scale(1)",'&.MuiInputLabel-shrink, &[class*="MuiInputLabel-shrink-"]':{transform:"translate(14px, -9px) scale(0.75)"}},'& .MuiSelect-root, & [class*="MuiSelect-root-"]':{paddingRight:"27px !important",border:"none",outline:"none","&:before":{borderBottom:"none"},"&:after":{borderBottom:"none"},"&:hover:not(.Mui-disabled):before":{borderBottom:"none"},'& .MuiSelect-select, & [class*="MuiSelect-select-"]':{paddingRight:"0px !important",padding:e.spacing(.5),minHeight:"auto"}},'& .MuiSelect-icon, & [class*="MuiSelect-icon-"]':{right:"8px",width:"16px",display:"none"},'& .MuiSelect-select, & [class*="MuiSelect-select-"]':{paddingRight:"32px !important"}},mobileFormControl:{[e.breakpoints.down("sm")]:{flex:"1 1 auto",width:"90% !important",minWidth:"unset !important",maxWidth:"100% !important",paddingTop:"13px !important",paddingBottom:"13px !important"}},videoMobileFormControl:{[e.breakpoints.down("sm")]:{flex:"1 1 auto",width:"93% !important",minWidth:"unset !important",maxWidth:"100% !important",paddingTop:"13px !important",paddingBottom:"13px !important"}},iconButton:{width:"24px",height:"24px",padding:0,marginRight:e.spacing(1),flex:"0 0 auto",borderRadius:"6px","& svg":{width:"16px",height:"16px"},[e.breakpoints.down("sm")]:{marginRight:e.spacing(.5)}},aspectRatioBox:{borderRadius:"6px",backgroundColor:"transparent"},filePreviews:{display:"flex",flexWrap:"wrap",gap:e.spacing(1),marginTop:e.spacing(2),alignItems:"center",width:"100%",clear:"both"},generateButton:{width:"100%",gap:e.spacing(.75),cursor:"pointer",borderRadius:"8px",padding:e.spacing(1,2),fontSize:"0.875rem",fontWeight:500,backgroundColor:e.palette.primary.main,marginTop:e.spacing(2),color:"white",position:"relative",overflow:"hidden",height:"40px","&::before":{content:'""',position:"absolute",top:0,left:"-100%",width:"100%",height:"100%",background:"linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent)",animation:"shimmer 3s infinite"},"&:hover":{backgroundColor:e.palette.primary.main,color:"white"},"&:disabled":{backgroundColor:e.palette.primary.main,color:"white",boxShadow:"none"}},"@keyframes shimmer":{"0%":{left:"-100%"},"100%":{left:"100%"}},videoOverlay:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.2)"},videoIcon:{borderRadius:"50%",backgroundColor:e.palette.primary.main,padding:e.spacing(1.5),transition:"transform 0.2s"},mediaLibraryDialog:{padding:0,height:"80vh"},"@keyframes pulse":{"0%, 100%":{opacity:1},"50%":{opacity:.5}},"@keyframes blink":{"0%, 50%, 100%":{opacity:1},"25%, 75%":{opacity:0}
1},historyDrawer:{'& .MuiDrawer-paper, & [class*="MuiDrawer-paper-"]':{width:"400px",maxWidth:"90vw"}},historyDrawerHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:e.spacing(2),borderBottom:`1px solid ${e.palette.divider}`},historyDrawerContent:{padding:e.spacing(2),height:"100%",overflow:"auto"},historySearchBar:{marginBottom:e.spacing(2)},historyItem:{padding:e.spacing(2),border:`1px solid ${e.palette.divider}`,borderRadius:"8px",marginBottom:e.spacing(1),cursor:"pointer",transition:"all 0.2s"},historyItemTitle:{fontWeight:600,marginBottom:e.spacing(.5)},historyItemDescription:{color:e.palette.text.secondary,fontSize:"0.875rem"},historyItemDate:{color:e.palette.text.hint,fontSize:"0.75rem",marginTop:e.spacing(.5)},customCtaInput:{marginTop:e.spacing(2),backgroundColor:e.palette.background.paper,borderRadius:"8px",border:`1px solid ${e.palette.divider}`},manualUploadContainer:{marginTop:e.spacing(3)},mediaUrlField:{marginBottom:e.spacing(2),display:"flex",gap:e.spacing(1),alignItems:"center",backgroundColor:"white",[e.breakpoints.down("sm")]:{flexDirection:"column",alignItems:"stretch",gap:e.spacing(1.5)}},mediaUrlFieldBox:{width:"100%",padding:"2px",marginTop:"4px","& input":{width:"calc(100% - 80px)"},background:"rgb(240,240,240)"},orDivider:{display:"flex",alignItems:"center",margin:e.spacing(2,0),"&::before, &::after":{content:'""',flex:1,height:"1px",backgroundColor:e.palette.divider},"&::before":{marginRight:e.spacing(2)},"&::after":{marginLeft:e.spacing(2)}},mediaUrlFieldText:{fontSize:"0.8rem",fontWeight:400,color:e.palette.text.primary,[e.breakpoints.down("sm")]:{textAlign:"center",margin:e.spacing(.5,0)}},"@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}},"@keyframes pulse":{"0%, 100%":{opacity:1,transform:"scale(1)"},"50%":{opacity:.5,transform:"scale(0.8)"}},"@keyframes sparkle":{"0%":{opacity:1,transform:"scale(1) rotate(0deg)",filter:"brightness(1)"},"25%":{opacity:.9,transform:"scale(1.1) rotate(90deg)",filter:"brightness(1.2)"},"50%":{opacity:.7,transform:"scale(1.2) rotate(180deg)",filter:"brightness(1.4)"},"75%":{opacity:.9,transform:"scale(1.1) rotate(270deg)",filter:"brightness(1.2)"},"100%":{opacity:1,transform:"scale(1) rotate(360deg)",filter:"brightness(1)"}},historyDrawerMainContainer:{width:"100%",height:"100%",display:"flex",flexDirection:"column",backgroundColor:e.palette.background.paper},historySearchBarContainer:{padding:e.spacing(2),borderBottom:`1px solid ${e.palette.divider}`,backgroundColor:"white"},historySearchField:{width:"100%"},dateRangeSelector:{display:"flex",alignItems:"center",gap:e.spacing(1),padding:e.spacing(1),backgroundColor:e.palette.background.paper,border:`1px solid ${e.palette.divider}`,borderRadius:"8px",cursor:"pointer",transition:"all 0.2s ease",marginTop:e.spacing(1),"&:hover":{borderColor:e.palette.primary.main,backgroundColor:e.palette.primary.light+"05"}},historyLoadingContainer:{display:"flex",justifyContent:"center",alignItems:"center",padding:e.spacing(4),height:"200px"},historyContainer:{flex:1,overflow:"auto",padding:0},promptContainer:{padding:e.spacing(2),borderBottom:`1px solid ${e.palette.divider}`,cursor:"pointer",transition:"all 0.2s ease",backgroundColor:e.palette.background.paper,"&:hover":{backgroundColor:"#f8f9fa"},"&:last-child":{borderBottom:"none"}},promptContent:{flex:1,minWidth:0,paddingRight:e.spacing(1)},iconButtonContainer:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:e.spacing(1),minWidth:"fit-content"},iconButton:{padding:e.spacing(.4),borderRadius:"6px",transition:"all 0.2s ease","&:hover":{backgroundColor:e.palette.primary.light+"20",color:e.palette.primary.main}},imageGenerationContainer:{marginTop:e.spacing(3)},imageGenerationGrid:{display:"flex",gap:e.spacing(2),justifyContent:"center",alignItems:"flex-start",flexWrap:"nowrap",width:"100%",borderRadius:"8px",overflowX:"auto",paddingBottom:e.spacing(1),[e.breakpoints.down("sm")]:{flexWrap:"wrap",overflowX:"visible",justifyContent:"center"}},imageGenerationItem:{flex:"0 0 auto",minWidth:"200px",maxWidth:"300px",position:"relative",borderRadius:"0px",overflow:"hidden",backgroundColor:"white",transition:"all 0.3s ease",display:"flex",flexDirection:"column",cursor:"pointer",[e.breakpoints.down("sm")]:{flex:"1 1 100%",minWidth:"unset",maxWidth:"100%",width:"100%"}},imageGenerationContent:{flex:"1",display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",
1width:"100%",height:"100%",position:"relative"},imageGenerationActions:{position:"absolute",top:"8px",right:"8px",display:"flex",gap:"8px",opacity:0,transition:"opacity 0.2s ease",zIndex:10,padding:"4px",borderRadius:"4px"},imageGenerationActionButton:{backgroundColor:"rgba(255, 255, 255, 0.9)",color:"#0a474c",width:"36px",height:"36px",boxShadow:"0 2px 4px rgba(0,0,0,0.1)","&:hover":{backgroundColor:"rgba(255, 255, 255, 1)",boxShadow:"0 4px 8px rgba(0,0,0,0.2)"}},imageGenerationOverlay:{position:"absolute",top:0,left:0,right:0,bottom:0,borderRadius:"8px",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"transparent",opacity:0,transition:"all 0.3s ease",zIndex:2},imageGenerationUseButton:{backgroundColor:e.palette.primary.main,color:"white",borderRadius:"8px",padding:"8px 16px",fontSize:"0.8rem",fontWeight:500,textTransform:"none",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.2)","&:hover":{backgroundColor:e.palette.primary.main,color:"white",boxShadow:"none"}},streamingImageContainer:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},streamingImage:{width:"100%",height:"100%",objectFit:"contain",filter:"brightness(0.9) contrast(0.95)",opacity:.8,transition:"all 0.3s ease",border:`6px solid ${e.palette.divider}`,borderRadius:"8px"},streamingIndicator:{position:"absolute",bottom:"12px",right:"12px",backgroundColor:e.palette.primary.main,color:"white",padding:"6px 12px",borderRadius:"8px",display:"flex",alignItems:"center",gap:"6px",fontSize:"0.75rem",fontWeight:"500"},streamingDot:{width:"8px",height:"8px",backgroundColor:"white",borderRadius:"50%",animation:"pulse 1.5s ease-in-out infinite"},generatedImage:{width:"100%",height:"100%",objectFit:"contain",transition:"all 0.3s ease",borderRadius:"8px"},uploadButton:{paddingTop:"8px",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"16px",minWidth:"auto",whiteSpace:"nowrap",[e.breakpoints.down("sm")]:{width:"100%",minWidth:"unset"}},responsiveWrapper:{display:"flex",alignItems:"center",height:"44px",paddingRight:"5px",gap:e.spacing(1),[e.breakpoints.down("sm")]:{width:"100%",flex:"1 1 100%"}},responsiveWrapperDesktop:{display:{xs:"none",sm:"block"}},responsiveWrapperMobile:{[e.breakpoints.down("sm")]:{flex:"1 1 auto",width:"100% !important",minWidth:"unset !important",maxWidth:"100% !important",display:"block"},[e.breakpoints.up("sm")]:{display:"none"}}})));function Ir(e){let{imageFile:t,videoFile:a,thumbnailUrl:r,onImageFileChange:l,onVideoFileChange:c,onThumbnailUrlChange:p,onMediaSelect:m,assistantDetails:g,onImageGeneration:b,onVideoGeneration:y,uploadType:x,onUploadTypeChange:f,updateAssistantAdCredits:A,updateAssistantStore:I,isLoading:C=!1,onGenerationStateChange:_,mediaRecommendation:v,aiGeneratorOnly:E=!1,useButtonLabel:T,onUseGeneratedImage:D,hideTabToggle:w=!1}=e;const N=Ar(),j=(0,o.useTheme)(),k=(0,i.useDispatch)(),{showSnackbar:L}=(0,ls.dh)(),{isAiSensy:R}=(0,u.x)(),P=e=>{const t=g?.currency||"INR",a=g?.aiAdCreativeCount||0,n=Math.max(0,J.qJ-a);if(n>0)return`${n} free generations left`;if("VIDEO"===e){return`${"USD"===t?"$":"₹"} ${J.Fz.VIDEO_PER_SECOND[t]*Q} Ad Credits`}return`${"USD"===t?"$":"₹"} ${J.Fz[e][t]} Ad Credits`},M=e=>{const t=g?.currency||"INR";if("VIDEO"===e){return J.Fz.VIDEO_PER_SECOND[t]*Q}return J.Fz[e][t]};s().useEffect((()=>{const e=document.createElement("style");return e.textContent="\n            @keyframes blink {\n                0% { opacity: 1; }\n                50% { opacity: 0.4; }\n                100% { opacity: 1; }\n            }\n        ",document.head.appendChild(e),()=>document.head.removeChild(e)}),[]);const U=e=>"VIDEO_UPLOAD"===e?"video":"image",[F,W]=(0,n.useState)(U(x));s().useEffect((()=>{const e=U(x);e!==F&&("image"===e?(Me([null]),Fe([null]),ze([null]),a&&c&&c(null),r&&p&&p(null)):(Ne([null,null,null]),ke([null,null,null]),Re([null,null,null]),t&&l&&l(null)),Ee(0),De(null),Ye(""),Ke(""),He(null),Z(""),G(null),V(null),ae("None"),se(""),Ae(!1),Ce(!1)),W(e)}),[x]);const[z,G]=(0,n.useState)(null),[H,V]=(0,n.useState)(null),[Y,Z]=(0,n.useState)(""),[K,$]=(0,n.useState)("1:1"),[q,X]=(0,n.use
1State)("9:16"),[Q,ee]=(0,n.useState)(8),[te,ae]=(0,n.useState)("None"),[ne,se]=(0,n.useState)(""),[oe,ie]=(0,n.useState)(!1),[re,le]=(0,n.useState)("product"),[de,ce]=(0,n.useState)(!1),[pe,ue]=(0,n.useState)(""),[me,he]=(0,n.useState)(!1),[ge,be]=(0,n.useState)(["IMAGE","VIDEO"]),[ye,xe]=(0,n.useState)(!1),[fe,Ae]=(0,n.useState)(!1),[Ie,Ce]=(0,n.useState)(!1),[_e,Se]=(0,n.useState)(!1),[ve,Ee]=(0,n.useState)(0),[Te,De]=(0,n.useState)(null),[we,Ne]=(0,n.useState)([null,null,null]),[je,ke]=(0,n.useState)([null,null,null]),[Le,Re]=(0,n.useState)([null,null,null]),[Be,Oe]=(0,n.useState)([null]),[Pe,Me]=(0,n.useState)([null]),[Ue,Fe]=(0,n.useState)([null]),[We,ze]=(0,n.useState)([null]),[Ge,He]=(0,n.useState)(null),[Ve,Ye]=(0,n.useState)(""),[Ze,Ke]=(0,n.useState)(""),[Je,$e]=(0,n.useState)(!1),[qe,Xe]=(0,n.useState)(""),[Qe,et]=(0,n.useState)(""),[tt,at]=(0,n.useState)(0),[nt,st]=(0,n.useState)([]),[ot,it]=(0,n.useState)({open:!1,message:""}),[rt,lt]=(0,n.useState)(!1),[dt,ct]=(0,n.useState)([]),[pt,ut]=(0,n.useState)(0),[mt,ht]=(0,n.use
1State)(new Date(Date.now()-2592e6)),[gt,bt]=(0,n.useState)(new Date),[yt,xt]=(0,n.useState)(1),[ft,At]=(0,n.useState)(10),[It,Ct]=(0,n.useState)(null);(0,n.useEffect)((()=>{"AI_UPLOAD"===x&&(t?.publicUrl?m&&m([{publicUrl:t.publicUrl,fileType:"IMAGE",fileName:t.fileName||"Image"}]):a?.publicUrl&&m&&m([{publicUrl:a.publicUrl,fileType:"VIDEO",fileName:a.fileName||"Video"}]))}),[t,a,m,x]),(0,n.useEffect)((()=>{_&&_({isImageGenerating:fe,isVideoGenerating:Ie,isGenerating:fe||Ie})}),[fe,Ie,_]),(0,n.useEffect)((()=>{const e=e=>{if(fe||Ie){const t=fe?"Image generation is in progress. If you refresh now, you will lose your progress. Are you sure you want to leave?":"Video generation is in progress. If you refresh now, you will lose your progress. Are you sure you want to leave?";return e.preventDefault(),e.returnValue=t,t}};return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e)}}),[fe,Ie]);const _t=e=>{le(e),be("IMAGE"),ie(!0)},St=()=>{xt(1),At(10),ct([]),ut(0),ht(new Date(Date.now()-864e5)),bt(new Date),ce(!de)},vt=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Generated Image",a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];Xe(e),et(t),at(a),st(n.length>0?n:[e]),$e(!0)},Et=()=>{$e(!1),Xe(""),et(""),at(0),st([])},Tt=async(e,t)=>{try{it({open:!0,message:"Download initiated..."});const a=await hr()(e),n=await a.blob(),s=window.URL.createObjectURL(n),o=document.createElement("a");o.href=s,o.download=t,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(s),it({open:!0,message:"Download completed!"})}catch(e){it({open:!0,message:"Download failed. Please try again."})}},Dt=(0,n.useMemo)((()=>(0,ts.debounce)((()=>{(async()=>{try{if(!g?.assistantId)return;lt(!0);const e=e=>e?(0,gr.A)(e,"dd-MM-yyyy"):null,t=e(mt),a=e(gt),n=await k((0,gi.pI)({assistantId:g.assistantId,startDate:t,endDate:a,prompt:pe,limit:ft,page:yt})),s=n?.aiAdCreativePrompts||[];ut((n?.paggination||{}).totalCreativeCount||0),ct(s)}catch(e){L("Failed to load prompt history","error")}finally{lt(!1)}})()}),1e3)),[mt,gt,yt,ft,pe]);(0,n.useEffect)((()=>{de&&Dt()}),[Dt,de]);const wt=e=>{"second"===e?(be("IMAGE"),xe(!0)):(be("image"===F?"IMAGE":"VIDEO"),xe(!1)),he(!me)},Nt=e=>{let t=null;Array.isArray(e)&&e.length>0?t=e[0]:e&&!Array.isArray(e)&&(t=e),t&&(oe?("product"===re?G(t):"logo"===re&&V(t),ie(!1)):("image"===F?l&&l(t):c&&c(t),he(!1)))},jt=(e,t)=>{if(y&&y({publicUrl:e,fileName:"Generated Video",fileType:"VIDEO"}),t&&p){p({publicUrl:t,fileName:"Generated Video Thumbnail",fileType:"IMAGE"})}},kt=e=>{l&&l(e)},Lt=e=>{c&&c(e)},Rt=e=>{const[t,a]=e.split(":").map(Number),n=t/a,s=180;return n>1?{width:Math.min(s*n,280),height:s}:{width:s,height:Math.min(s/n,320)}};return(0,h.jsxs)("div",{className:N.container,children:[!E&&!w&&(0,h.jsxs)("div",{className:N.toggleContainer,children:[(0,h.jsx)(o.Tooltip,{title:Ie?"Video generation in progress":"",children:(0,h.jsxs)("button",{className:`${N.toggleButton} ${"image"===F?N.toggleButtonActive:""}`,onClick:()=>{Ie||f&&f("IMAGE_UPLOAD")},disabled:Ie,style:{opacity:Ie?.5:1,cursor:Ie?"not-allowed":"pointer"},children:[(0,h.jsx)(bi.A,{size:17}),(0,h.jsx)(o.Typography,{children:"Image"})]})}),(0,h.jsx)(o.Tooltip,{title:fe?"Image generation in progress":"",children:(0,h.jsxs)("button",{className:`${N.toggleButton} ${"video"===F?N.toggleButtonActive:""}`,onClick:()=>{fe||f&&f("VIDEO_UPLOAD")},disabled:fe,style:{opacity:fe?.5:1,cursor:fe?"not-allowed":"pointer"},children:[(0,h.jsx)(yi.A,{size:20}),(0,h.jsx)(o.Typography,{children:"Video"})]})})]}),!E&&v&&(0,h.jsx)(O.Alert,{severity:"info",style:{marginTop:"12px",marginBottom:"4px"},children:v}),!E&&(0,h.jsx)(o.Box,{className:N.manualUploadContainer,children:"image"===F?(0,h.jsx)(h.Fragment,{children:(0,h.jsxs)(o.Box,{className:N.mediaUrlField,children:[C?(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,width:"100%",style:{borderRadius:"10px"}}):(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(o.TextField,{variant:"outlined",className:N.mediaUrlFieldBox,placeholder:"Media URL",name:"url",value:t?.publicUrl||"",onChange:e=>{const t=e.target.value;if(t){kt({publicUrl:t,fileName:"Image",fileType:"IMAGE"})}else kt(null)},fullWidth:!0})}),(0,h.jsx)(o.Typography,{variant:"body2",className:N.mediaUrlFieldText,children:"OR"}),va("mediaLibrary")&&(0,h.jsx)(o.Button,{color:"primary",variant:"contained",onClick:()=>wt("first"),className:N.uploadButton,children:"Upload from Media Library"})]})}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.Box,{className:N.mediaUrlField,children:[C?(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,width:"100%",style:{borderRadius:"10px"}}):(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(o.TextField,{variant:"outlined",className:N.mediaUrlFieldBox,placeholder:"Video URL",name:"url",value:a?.publicUrl||"",onChange:e=>{const t=e.target.value;if(t){Lt({publicUrl:t,fileName:"Video",fileType:"VIDEO"})}else Lt(null)},fullWidth:!0})}),(0,h.jsx)(o.Typography,{variant:"body2",className:N.mediaUrlFieldText,children:"OR"}),va("mediaLibrary")&&(0,h.jsx)(o.Button,{color:"primary",variant:"contained",onClick:()=>wt("first"),className:N.uploadButton,children:"Upload from Media Library"})]}),(0,h.jsx)(o.Box,{style:{marginTop:j.spacing(2)},children:(0,h.jsxs)(o.Box,{className:N.mediaUrlField,children:[C?(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,width:"100%",style:{borderRadius:"10px"}}):(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(o.TextField,{variant:"outlined",className:N.mediaUrlFieldBox,placeholder:"Thumbn
1ail URL",name:"thumbnailUrl",value:r?.publicUrl||"",onChange:e=>{const t=e.target.value;if(t){p&&p({publicUrl:t,fileName:"Thumbnail",fileType:"IMAGE"})}else p&&p(null)},fullWidth:!0})}),(0,h.jsx)(o.Typography,{variant:"body2",className:N.mediaUrlFieldText,children:"OR"}),va("mediaLibrary")&&(0,h.jsx)(o.Button,{color:"primary",variant:"contained",onClick:()=>wt("second"),className:N.uploadButton,children:"Upload from Media Library"})]})})]})}),"image"===F&&R&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.Typography,{variant:"h6",className:N.orDivider,children:["OR"," "]}),(0,h.jsx)("div",{className:N.headerContainer,children:(0,h.jsxs)("div",{className:N.headerBadge,children:[(0,h.jsx)(S.A,{className:`${N.sparklesIcon} ${N.headerBadge} h-3 w-3 flex-shrink-0`,color:j.palette.primary.main}),(0,h.jsx)(o.Typography,{variant:"body1",children:"Generate Your Creatives with AI"})]})})]}),"image"===F&&R&&(0,h.jsxs)(o.Box,{className:N.tabContent,children:[(0,h.jsx)(o.Box,{style:{display:"flex",flexDirection:window.innerWidth<768?"column":"row",justifyContent:window.innerWidth<768?"flex-start":"space-between",alignItems:window.innerWidth<768?"flex-start":"center",gap:window.innerWidth<768?j.spacing(1):0,marginBottom:j.spacing(1)},children:(0,h.jsx)(o.Tooltip,{title:"View History",children:(0,h.jsx)(o.Button,{onClick:St,variant:"outlined",startIcon:(0,h.jsx)(ao.A,{size:18,style:{color:j.palette.primary.main}}),className:N.historyButton,children:"View History"})})}),(0,h.jsx)(o.TextField,{value:Y,onChange:e=>{const t=e.target.value;t.length<=2048&&Z(t)},placeholder:"Describe what you want to create...",multiline:!0,rows:4,variant:"outlined",fullWidth:!0,className:N.TextFieldRoot,inputProps:{maxLength:2048}}),Y.length>0&&Y.length<15&&(0,h.jsx)(o.Typography,{variant:"caption",style:{color:j.palette.error.main,marginTop:j.spacing(.5),display:"block"},children:"Please enter at least 15 characters"}),Y.length>=15&&(0,h.jsxs)(o.Box,{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:j.spacing(.5)},children:[Y.length>=2048&&(0,h.jsx)(o.Typography,{variant:"caption",style:{color:j.palette.error.main},children:"Maximum 2048 characters allowed. Please shorten your prompt."}),(0,h.jsxs)(o.Typography,{variant:"caption",style:{color:Y.length>=2048?j.palette.error.main:j.palette.text.secondary,marginLeft:"auto"},children:[Y.length," / 2048 characters"]})]}),(0,h.jsxs)(o.Box,{className:N.controlsContainer,children:[va("mediaLibrary")&&(0,h.jsx)(o.Tooltip,{title:"Select Product Image",children:(0,h.jsx)(o.Button,{onClick:()=>_t("product"),variant:"outlined",startIcon:(0,h.jsx)(fi.A,{size:20,style:{color:j.palette.primary.main}}),endIcon:(0,h.jsx)(Ai.A,{size:20}),className:N.mediaButton,children:"Product"})}),va("mediaLibrary")&&(0,h.jsx)(o.Tooltip,{title:"Select Brand Logo",children:(0,h.jsx)(o.Button,{onClick:()=>_t("logo"),variant:"outlined",startIcon:(0,h.jsx)(Ii.A,{size:20,style:{color:j.palette.primary.main}}),endIcon:(0,h.jsx)(Ai.A,{size:20}),className:N.mediaButton,children:"Logo"})}),(0,h.jsxs)(o.Box,{className:N.responsiveWrapper,style:{marginLeft:"6px"},children:[(0,h.jsx)(o.Tooltip,{title:"Select Image Aspect Ratio",children:(0,h.jsx)(o.IconButton,{style:{padding:"0px"},children:(0,h.jsx)(Ci.A,{size:20})})}),(0,h.jsx)(qi,{currentRatio:K,onRatioChange:$,style:{width:"100%",[j.breakpoints.down("sm")]:{width:"93%",flex:"1 1 auto"}},children:(0,h.jsxs)(o.Box,{size:"small",className:`${N.formControl} ${N.mobileFormControl}`,style:{cursor:"pointer",width:"100% !important",paddingLeft:"10px",paddingRight:"10px",paddingTop:"8px",paddingBottom:"8px",[j.breakpoints.down("sm")]:{flex:"1 1 auto",width:"100% !important",minWidth:"unset !important",maxWidth:"100% !important",paddingTop:"14px !important",paddingBottom:"14px !important"}},children:[(0,h.jsx)(o.Typography,{style:{fontSize:"14px",color:j.palette.text.primary,pointerEvents:"none"},children:K}),(0,h.jsx)(_i.A,{size:16,style:{marginLeft:"auto",color:j.palette.text.secondary,pointerEvents:"none",paddingLeft:"30px"}})]})})]}),(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",gap:j.spacing(.6),[j.breakpoints.down("sm")]:{width:"100%",flex:"1 1 100%",paddingTop:"0px"}},children:[(0,h.jsx)(o.Tooltip,{title:"Select Target Audience",children:(0,h.jsx)(o.IconButton,{className:N.iconButton,children:(0,h.jsx)(Si.A,{size:20,style:{backgroundColor:j.palette.primary.light+"20",borderRadius:"4px",paddingLeft:j.breakpoints.down("sm")?"0px":"15px"}})})}),(0,h.jsxs)(o.Box,{size:"small",className:N.formControl,style:{pointerEvents:"auto",[j.breakpoints.down("sm")]:{flex:"1 1 auto",width:"100%"}},children:[(0,h.jsxs)(o.Select,{defaultValue:"general",children:[(0,h.jsx)(o.MenuItem,{value:"general",children:"General"}),(0,h.jsx)(o.MenuItem,{value:"professional",children:"Professional"}),(0,h.jsx)(o.MenuItem,{value:"creative",children:"Creative"}),(0,h.jsx)(o.MenuItem,{value:"youth",children:"Youth"}),(0,h.jsx)(o.MenuItem,{value:"family",children:"Family"})]}),(0,h.jsx)(_i.A,{size:16,style:{marginLeft:"auto",color:j.palette.text.secondary,pointerEvents:"none"}})]})]}),(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)(o.Tooltip,{title:"Select Call To Action ",children:(0,h.jsx)(o.IconButton,{style:{padding:"0px"},className:N.iconButton,children:(0,h.jsx)(vi.A,{size:20,style:{backgroundColor:j.palette.primary.light+"20",borderRadius:"4px",paddingLeft:j.breakpoints.down("sm")?"0px":"15px",paddingRight:"6px"}})})}),(0,h.jsxs)(o.Box,{size:"small",className:N.formControl,children:[(0,h.jsx)(o.Select,{value:te,onChange:e=>ae(e.target.value),children:[{value:"None",label:"None"},{value:"Shop now",label:"Shop Now"},{value:"Learn more",label:"Learn More"},{value:"Get started",label:"Get Started"},{value:"Buy now",label:"Buy Now"},{value:"Sign up",label:"Sign Up"},{value:"Download now",label:"Download Now"},{value:"Try free",label:"Try for Free"},{value:"Contact us",label:"Contact Us"},{value:"custom",label:"Custom..."}].map((e=>(0,h.jsx)(o.MenuItem,{value:e.value,children:e.label},e.value)))}),(0,h.jsx)(_i.A,{size:16,style:{marginLeft:"auto",color:j.palette.text.secondary,pointerEvents:"none"}})]})]}),"custom"===te&&(0,h.jsx)(o.TextField,{value:ne,onChange:e=>se(e.target.value),placeholder:"Enter your custom call-to-action text...",variant:"outlined",fullWidth:!0,className:N.mediaUrlFieldBox}),(z||H)&&(0,h.jsxs)(o.Box,{className:N.filePreviews,children:[z&&(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",gap:j.spacing(1),padding:j.spacing(1),border:`1px solid ${j.palette.divider}`,borderRadius:"8px",backgroundColor:j.palette.background.paper,maxWidth:"200px"},children:[(0,h.jsx)("img",{src:z.publicUrl||z.url||z.thumbnailUrl,alt:"Product Preview",style:{width:"40px",height:"40px",objectFit:"cover",borderRadius:"4px"}}),(0,h.jsxs)(o.Box,{style:{flex:1,minWidth:0},children:[(0,h.jsx)(o.Typography,{variant:"caption",style:{fontSize:"10px",fontWeight:500,color:j.palette.text.primary,display:"block",marginBottom:"2px"},children:"Product"}),(0,h.jsx)(o.Typography,{variant:"body2",style:{fontSize:"12px",color:j.palette.text.secondary,textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",maxWidth:"120px"},children:z.name||z.fileName||"Selected Media"})]}),(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>G(null),style:{padding:"4px"},children:(0,h.jsx)(Ei.A,{size:16})})]}),H&&(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",gap:j.spacing(1),padding:j.spacing(1),border:`1px solid ${j.palette.divider}`,borderRadius:"8px",backgroundColor:j.palette.background.paper,maxWidth:"200px"},children:[(0,h.jsx)("img",{src:H.publicUrl||H.url||H.thumbnailUrl,alt:"Logo Preview",style:{width:"40px",height:"40px",objectFit:"cover",borderRadius:"4px"}}),(0,h.jsxs)(o.Box,{style:{flex:1,minWidth:0},children:[(0,h.jsx)(o.Typography,{variant:"caption",style:{fontSize:"10px",fontWeight:500,color:j.palette.text.primary,display:"block",marginBottom:"2px"},children:"Logo"}),(0,h.jsx)(o.Typography,{variant:"body2",style:{fontSize:"12px",color:j.palette.text.secondary,textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",maxWidth:"120px"},children:H.name||H.fileName||"Selected Logo"})]}),(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>V(null),style:{padding:"4px"},children:(0,h.jsx)(Ei.A,{size:16})})]})]}),(0,h.jsx)(o.Tooltip,{title:Ie?"Video generation in progress":Y.trim()?"":"Please enter a prompt for image generation",disableHoverListener:""!==Y.trim()&&!Ie,children:(0,h.jsx)("span",{style:{display:"block",width:"100%"},children:(0,h.jsx)(o.Button,{size:"large",variant:"contained",className:N.generateButton,startIcon:(0,h.jsx)(S.A,{size:20,style:{animation:"blink 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",WebkitAnimation:"blink 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}}),onClick:fe||Ie?null:async()=>
1{if(!Y.trim())return void L("Please enter a prompt for image generation","warning");if(!g?.assistantId)return void L("Assistant details not available. Please refresh the page.","error");if(Ie)return void L("Video generation is in progress. Please wait for it to complete.","warning");Ae(!0),Ee(0),De("processing"),Ne([null,null,null]),ke([null,null,null]),Re([null,null,null]),He(null),Ye(""),Ke("");try{const e=(await yr(`${J.k}/ai-ad-creative/generate-ad-creative`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:Y,aspectRatio:"1:1"===K?"ASPECT_1_1":"2:3"===K?"ASPECT_2_3":"3:2"===K?"ASPECT_3_2":"3:4"===K?"ASPECT_3_4":"4:3"===K?"ASPECT_4_3":"9:16"===K?"ASPECT_9_16":"16:9"===K?"ASPECT_16_9":"ASPECT_1_1",styleType:"AUTO",assistantId:g?.assistantId,productImage:z?.publicUrl||"",logoImage:H?.publicUrl||"",character:!0,audience:"general",font:"default",cta:"custom"===te?ne:"None"===te?"":te,productUrl:""})})).body.getReader(),t=new TextDecoder;let a=[null,null,null],n=[null,null,null],s=[null,null,null];for(;;){const{value:o,done:i}=await e.read();if(i)break;const r=t.decode(o).split("\n").filter((e=>e.trim()));for(const e of r){let t=e;if(e.startsWith("data: ")&&(t=e.substring(6)),t&&": ping"!==t)try{const e=JSON.parse(t);if(e.stage&&(Ye(e.stage),Ke(e.data||""),"start"===e.stage?Ee(10):"concepts"===e.stage?Ee(30):"images"===e.stage?Ee(50):"complete"===e.stage&&(Ee(100),De("completed"))),"concept"===e.stage&&void 0!==e.concept_index&&(n[e.concept_index]=e.data,ke([...n])),"image_stream"===e.stage&&void 0!==e.image_index&&e.data&&(s[e.image_index]=e.data,Re([...s])),"image_complete"===e.stage&&void 0!==e.image_index){a[e.image_index]=e.data,n[e.image_index]=e.concept,s[e.image_index]=null,Ne([...a]),ke([...n]),Re([...s]);const t=a.filter((e=>null!==e)).length;Ee(50+15*t)}if("complete"===e.type){const t=g?.aiAdCreativeCount||0;if(Math.max(0,J.qJ-t)<=0){const e=M("IMAGE");A((g?.metaAdsCredit||0)-e)}I({aiAdCreativeCount:t+1}),De("completed"),Ee(100),Ke(e.message||"Generation completed"),L("Image generation completed successfully!","success")}if("image_error"===e.stage){De("failed");const t=e.error||e.message||"Image generation failed";L(`Image generation failed: ${t}`,"error")}"error"===e.type&&(De("failed"),L(e.message||"Image generation failed","error"))}catch(e){console.error("Error parsing streaming data:",e)}}}}catch(e){De("failed");const t=e.message||"Something went wrong during image generation";L(t,"error")}finally{Ae(!1)}},disabled:fe||Ie||!Y.trim()||Y.length<15,children:fe?"Generating...":Ie?"Video generation in progress...":`Generate Image (${P("IMAGE")})`})})}),"image"===F&&(we.some((e=>null!==e))||Le.some((e=>null!==e))||fe)&&(0,h.jsx)(o.Box,{className:N.imageGenerationContainer,children:(0,h.jsx)(o.Box,{className:N.imageGenerationGrid,children:[0,1,2].map((e=>{const t=we[e],a=Le[e],n=null!==t,s=null!==a,i=fe&&!t&&!a,r=Rt(K);return(0,h.jsx)(o.Box,{className:N.imageGenerationItem,style:{width:`${r.width}px`,height:`${r.height}px`,[j.breakpoints.down("sm")]:{width:"100%",height:"auto",aspectRatio:`${r.width}/${r.height}`}},onClick:()=>(n||s)&&He(e),children:(0,h.jsx)(o.Box,{className:N.imageGenerationContent,children:s?(0,h.jsx)(o.Box,{className:N.streamingImageContainer,children:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("img",{src:a,alt:`Generating ${e+1}`,className:N.streamingImage}),(0,h.jsxs)(o.Box,{className:N.streamingIndicator,children:[(0,h.jsx)(o.Box,{className:N.streamingDot}),"Generating..."]}),(0,h.jsxs)(o.Box,{className:N.imageGenerationActions,onMouseEnter:e=>{e.currentTarget.style.opacity=1},onMouseLeave:e=>{e.currentTarget.style.opacity=0},children:[(0,h.jsx)(o.IconButton,{size:"small",onClick:t=>{t.preventDefault(),t.stopPropagation();const n=Le.filter((e=>null!==e)).concat(we.filter((e=>null!==e)));vt(a,`Generated Image ${e+1}`,e,n)},className:N.imageGenerationActionButton,children:(0,h.jsx)(Ti.A,{size:18})}),(0,h.jsx)(o.IconButton,{size:"small",onClick:t=>{t.preventDefault(),t.stopPropagation(),Tt(a,`generated-image-${e+1}.jpg`)},className:N.imageGenerationActionButton,children:(0,h.jsx)(Di.A,{size:18})})]}),(0,h.jsx)(o.Box,{className:N.imageGenerationOverlay,onMouseEnter:e=>{e.currentTarget.style.opacity=1},onMouseLeave:e=>{e.currentTarget.style.opacity=0},children:(0,h.jsx)(o.Button,{onClick:()=>{He(e),D?D(a):(b(a),l({publicUrl:a,fileName:"Generated Image",fileType:"IMAGE"}))},variant:"contained",className:N.imageGenerationUseButton,children:T||"Use this"})})]})}):n?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.Box,{className:N.imageGenerationActions,onMouseEnter:e=>{e.currentTarget.style.opacity=1},onMouseLeave:e=>{e.currentTarget.style.opacity=0},children:[(0,h.jsx)(o.IconButton,{size:"small",onClick:a=>{a.preventDefault(),a.stopPropagation();const n=Le.filter((e=>
1null!==e)).concat(we.filter((e=>null!==e)));vt(t,`Generated Image ${e+1}`,e,n)},className:N.imageGenerationActionButton,children:(0,h.jsx)(Ti.A,{size:18})}),(0,h.jsx)(o.IconButton,{size:"small",onClick:a=>{a.preventDefault(),a.stopPropagation(),Tt(t,`generated-image-${e+1}.jpg`)},className:N.imageGenerationActionButton,children:(0,h.jsx)(Di.A,{size:18})})]}),(0,h.jsx)(o.Box,{className:N.imageGenerationOverlay,onMouseEnter:e=>{e.currentTarget.style.opacity=1,e.currentTarget.style.backgroundColor="rgba(0, 0, 0, 0.3)";const t=e.currentTarget.parentElement.querySelector(`.${N.imageGenerationActions}`);t&&(t.style.opacity=1)},onMouseLeave:e=>{e.currentTarget.style.opacity=0,e.currentTarget.style.backgroundColor="transparent";const t=e.currentTarget.parentElement.querySelector(`.${N.imageGenerationActions}`);t&&(t.style.opacity=0)},children:(0,h.jsx)(o.Button,{onClick:()=>{He(e),D?D(t):(b(t),l({publicUrl:t,fileName:"Generated Image",fileType:"IMAGE"}))},variant:"contained",className:N.imageGenerationUseButton,children:T||"Use this"})}),(0,h.jsx)("img",{src:t,alt:`Generated ${e+1}`,className:N.generatedImage})]}):i&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(O.Skeleton,{variant:"rectangular",width:"100%",height:"100%",animation:"wave",style:{borderRadius:"0px",backgroundColor:"#f0f0f0",position:"absolute",top:0,left:0,right:0,bottom:0}}),(0,h.jsx)(ur,{progress:ve})]})})},e)}))})})]})]}),"video"===F&&R&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.Typography,{variant:"h6",className:N.orDivider,children:["OR"," "]}),(0,h.jsx)("div",{className:N.headerContainer,children:(0,h.jsxs)("div",{className:N.headerBadge,children:[(0,h.jsx)(S.A,{className:`${N.sparklesIcon} ${N.headerBadge} h-3 w-3 flex-shrink-0`,color:j.palette.primary.main}),(0,h.jsx)(o.Typography,{variant:"body1",children:"Generate Your Video Creatives with AI"})]})})]}),"video"===F&&R&&(0,h.jsxs)(o.Box,{className:N.tabContent,children:[(0,h.jsx)(o.Box,{style:{display:"flex",flexDirection:window.innerWidth<768?"column":"row",justifyContent:window.innerWidth<768?"flex-start":"space-between",alignItems:window.innerWidth<768?"flex-start":"center",gap:window.innerWidth<768?j.spacing(1):0,marginBottom:j.spacing(1)},children:(0,h.jsx)(o.Tooltip,{title:"View History",children:(0,h.jsx)(o.Button,{onClick:St,variant:"outlined",startIcon:(0,h.jsx)(ao.A,{size:18,style:{color:j.palette.primary.main}}),className:N.historyButton,children:"View History"})})}),(0,h.jsx)(o.TextField,{value:Y,onChange:e=>{const t=e.target.value;t.length<=2048&&Z(t)},placeholder:"Describe what you want to create...",multiline:!0,rows:4,variant:"outlined",fullWidth:!0,className:N.TextFieldRoot,inputProps:{maxLength:2048}}),Y.length>0&&Y.length<15&&(0,h.jsx)(o.Typography,{variant:"caption",style:{color:j.palette.error.main,marginTop:j.spacing(.5),display:"block"},children:"Please enter at least 15 characters"}),Y.length>=15&&(0,h.jsxs)(o.Box,{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:j.spacing(.5)},children:[Y.length>=2048&&(0,h.jsx)(o.Typography,{variant:"caption",style:{color:j.palette.error.main},children:"Maximum 2048 characters allowed. Please shorten your prompt."}),(0,h.jsxs)(o.Typography,{variant:"caption",style:{color:Y.length>=2048?j.palette.error.main:j.palette.text.secondary,marginLeft:"auto"},children:[Y.length," / 2048 characters"]})]}),(0,h.jsxs)(o.Box,{className:N.controlsContainer,children:[va("mediaLibrary")&&(0,h.jsx)(o.Tooltip,{title:"Select Product Image",children:(0,h.jsx)(o.Button,{onClick:()=>_t("product"),variant:"outlined",startIcon:(0,h.jsx)(fi.A,{size:20,style:{color:j.palette.primary.main}}),endIcon:(0,h.jsx)(Ai.A,{size:20}),className:N.mediaButton,children:"Product"})}),(0,h.jsxs)(o.Box,{className:N.responsiveWrapper,style:{height:"43px"},children:[(0,h.jsx)(o.Tooltip,{style:{padding:"0px"},title:"Select Video Aspect Ratio",children:(0,h.jsx)(o.IconButton,{style:{padding:"0px"},children:(0,h.jsx)(Ci.A,{size:20})})}),(0,h.jsx)(qi,{currentRatio:q,onRatioChange:X,style:{width:"100%",[j.breakpoints.down("sm")]:{width:"100%",flex:"1 1 auto"}},children:(0,h.jsxs)(o.Box,{size:"small",className:`${N.formControl} ${N.videoMobileFormControl}`,style:{cursor:"pointer",width:"100% !important",paddingLeft:"10px",paddingRight:"10px",paddingTop:"8px",paddingBottom:"8px",[j.breakpoints.down("sm")]:{flex:"1 1 auto",width:"100% !important",minWidth:"unset !important",maxWidth:"100% !important",paddingTop:"14px !important",paddingBottom:"14px !important"}},children:[(0,h.jsx)(o.Typography,{style:{fontSize:"14px",color:j.palette.text.primary,pointerEvents:"none"},children:q}),(0,h.jsx)(_i.A,{size:16,style:{marginLeft:"auto",color:j.palette.text.secondary,pointerEvents:"none",paddingLeft:"30px"}})]})})]}),(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)(o.Tooltip,{style:{padding:"0px"},title:"Select Target Audience",children:(0,h.jsx)(o.IconButton,{className:N.iconButton,children:(0,h.jsx)(Si.A,{size:20,style:{backgroundColor:j.palette.primary.light+"20",borderRadius:"4px",paddingRight:"5px"}})})}),(0,h.jsxs)(o.Box,{size:"small",className:N.formControl,children:[(0,h.jsxs)(o.Select,{defaultValue:"general",children:[(0,h.jsx)(o.MenuItem,{value:"general",children:"General"}),(0,h.jsx)(o.MenuItem,{value:"professional",children:"Professional"}),(0,h.jsx)(o.MenuItem,{value:"creative",children:"Creative"}),(0,h.jsx)(o.MenuItem,{value:"youth",children:"Youth"}),(0,h.jsx)(o.MenuItem,{value:"family",children:"Family"})]}),(0,h.jsx)(_i.A,{size:16,style:{marginLeft:"auto",color:j.palette.text.secondary,pointerEvents:"none"}})]})]}),z&&(0,h.jsx)(o.Box,{className:N.filePreviews,children:z&&(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",gap:j.spacing(1),padding:j.spacing(1),border:`1px solid ${j.palette.divider}`,borderRadius:"8px",backgroundColor:j.palette.background.paper,maxWidth:"200px"},children:[(0,h.jsx)("img",{src:z.publicUrl||z.url||z.thumbnailUrl,alt:"Product Preview",style:{width:"40px",height:"40px",objectFit:"cover",borderRadius:"4px",border:`1px solid ${j.palette.divider}`}}),(0,h.jsxs)(o.Box,{style:{flex:1,minWidth:0},children:[(0,h.jsx)(o.Typography,{variant:"caption",style:{display:"block",fontWeight:500,color:j.palette.text.primary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:"Product"}),(0,h.jsx)(o.Typography,{variant:"caption",style:{display:"block",color:j.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.name||z.fileName||"Selected Media"})]}),(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>{G(null)},style:{color:j.palette.text.secondary,padding:"4px"},children:(0,h.jsx)(Ei.A,{size:16})})]})}),(0,h.jsx)(o.Tooltip,{title:fe?"Image generation in progress":Y.trim()?"":"Please enter a prompt for video generation",disableHoverListener:""!==Y.trim()&&!fe,children:(0,h.jsx)("span",{style:{display:"block",width:"100%"},children:(0,h.jsx)(o.Button,{size:"large",variant:"contained",className:N.generateButton,startIcon:(0,h.jsx)(S.A,{size:20,style:{animation:"blink 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",WebkitAnimation:"blink 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}}),onClick:Ie||fe?null:async()=>
1{if(Y.trim())if(g?.assistantId)if(fe)L("Image generation is in progress. Please wait for it to complete.","warning");else{Ce(!0),Ee(0),De("processing"),Oe([null]),Me([null]),Fe([null]),ze([null]);try{const e=(await yr(`${J.k}/ai-ad-creative/generate-ad-creative`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:Y,aspectRatio:"1:1"===q?"ASPECT_1_1":"2:3"===q?"ASPECT_2_3":"3:2"===q?"ASPECT_3_2":"3:4"===q?"ASPECT_3_4":"4:3"===q?"ASPECT_4_3":"9:16"===q?"ASPECT_9_16":"16:9"===q?"ASPECT_16_9":"ASPECT_9_16",assistantId:g?.assistantId,productImage:z?.publicUrl||"",productUrl:"",character:!0,audience:"general",font:"default",adType:"video",duration:Q,adObjective:"awareness"})})).body.getReader(),t=new TextDecoder;for(;;){const{value:a,done:n}=await e.read();if(n)break;const s=t.decode(a).split("\n").filter((e=>e.trim()));for(const e of s){let t=e;if(e.startsWith("data: ")&&(t=e.substring(6)),t&&": ping"!==t)try{const e=JSON.parse(t);if(e.stage&&(Ye(e.stage),Ke(e.data||""),"start"===e.stage?Ee(10):"concepts"===e.stage?Ee(20):"concept"===e.stage?Ee(30):"videos"===e.stage?Ee(40):"video_complete"===e.stage?Ee(90):"complete"===e.stage&&(Ee(100),De("completed"))),void 0===e.progress||e.stage||Ee(e.progress||0),"video_stream"===e.stage&&e.data){const t=e.data?.video_url||e.data,a=e.data?.f
1irst_frame_url||null;Me([t]),ze([a])}if("video_complete"===e.stage){const t=e.data?.video_url||e.data,a=e.data?.first_frame_url||null;Oe([t]),Fe([a]),Me([null]),ze([null])}if("final"===e.stage||"done"===e.stage||"complete"===e.stage||"video_complete"===e.stage){const e=g?.aiAdCreativeCount||0;if(Math.max(0,J.qJ-e)<=0){const e=M("VIDEO");A((g?.metaAdsCredit||0)-e)}I({aiAdCreativeCount:e+1}),De("completed"),Ee(100),L("Video generation completed successfully!","success")}"video_error"===e.stage&&(De("failed"),L(e.error||e.message||"Video generation failed","error")),"error"===e.stage&&(De("failed"),L(e.error||e.message||"Video generation failed due to internal checks, please try with a different prompt","error"))}catch(e){console.error("Error parsing streaming data:",e)}}}}catch(e){De("failed"),"Video generation failed due to internal checks, please try with a different prompt"==e.message?L("Video generation failed due to internal checks, please try with a different prompt","error"):L(e.message||"Something went wrong during video generation","error")}finally{Ce(!1)}}else L("Assistant details not available. Please refresh the page.","error");else L("Please enter a prompt for video generation","warning")},disabled:Ie||fe||!Y.trim()||Y.length<15,children:Ie?"Generating...":fe?"Image generation in progress...":`Generate Video (${P("VIDEO")})`})})}),"video"===F&&(Be.some((e=>null!==e))||Pe.some((e=>null!==e))||Ie)&&(0,h.jsx)(o.Box,{className:N.imageGenerationContainer,children:(0,h.jsx)(o.Box,{className:N.imageGenerationGrid,children:[0].map((e=>{const t=Be[e],a=Pe[e],n=Ue[e],s=We[e],i=null!==t,r=null!==a,l=Ie&&!t&&!a,d=Rt(q);return(0,h.jsx)(o.Box,{className:N.imageGenerationItem,style:{width:`${d.width}px`,height:`${d.height}px`},onClick:()=>(i||r)&&He(e),children:(0,h.jsx)(o.Box,{className:N.imageGenerationContent,children:r?(0,h.jsxs)(o.Box,{className:N.streamingImageContainer,children:[(0,h.jsx)("video",{src:a,poster:s,className:N.streamingImage,muted:!0}),(0,h.jsxs)(o.Box,{className:N.streamingIndicator,children:[(0,h.jsx)(o.Box,{className:N.streamingDot}),"Generating..."]}),(0,h.jsxs)(o.Box,{className:N.imageGenerationActions,onMouseEnter:e=>{e.currentTarget.style.opacity=1},onMouseLeave:e=>{e.currentTarget.style.opacity=0},children:[(0,h.jsx)(o.IconButton,{size:"small",onClick:e=>{e.preventDefault(),e.stopPropagation(),Xe(a),et("Generated Video"),$e(!0)},className:N.imageGenerationActionButton,children:(0,h.jsx)(Ti.A,{size:16})}),(0,h.jsx)(o.IconButton,{size:"small",onClick:t=>{t.preventDefault(),t.stopPropagation(),Tt(a,"generated-video.mp4"),s&&Tt(s,`generated-video-thumbnail-${e+1}.jpg`)},className:N.imageGenerationActionButton,children:(0,h.jsx)(Di.A,{size:16})})]}),(0,h.jsx)(o.Box,{className:N.imageGenerationOverlay,onMouseEnter:e=>{e.currentTarget.style.opacity=1,e.currentTarget.style.backgroundColor="rgba(0, 0, 0, 0.3)";const t=e.currentTarget.parentElement.querySelector(`.${N.imageGenerationActions}`);t&&(t.style.opacity=1)},onMouseLeave:e=>{e.currentTarget.style.opacity=0,e.currentTarget.style.backgroundColor="transparent";const t=e.currentTarget.parentElement.querySelector(`.${N.imageGenerationActions}`);t&&(t.style.opacity=0)},children:(0,h.jsx)(o.Button,{onClick:()=>{He(e),jt(a,s)},variant:"contained",className:N.imageGenerationUseButton,children:"Use this"})})]}):i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("video",{src:t,poster:n,className:N.generatedImage,muted:!0}),(0,h.jsxs)(o.Box,{className:N.imageGenerationActions,onMouseEnter:e=>{e.currentTarget.style.opacity=1},onMouseLeave:e=>{e.currentTarget.style.opacity=0},children:[(0,h.jsx)(o.IconButton,{size:"small",onClick:e=>{e.preventDefault(),e.stopPropagation(),Xe(t),et("Generated Video"),$e(!0)},className:N.imageGenerationActionButton,children:(0,h.jsx)(Ti.A,{size:16})}),(0,h.jsx)(o.IconButton,{size:"small",onClick:a=>{a.preventDefault(),a.stopPropagation(),Tt(t,"generated-video.mp4"),n&&Tt(n,`generated-video-thumbnail-${e+1}.jpg`)},className:N.imageGenerationActionButton,children:(0,h.jsx)(Di.A,{size:16})})]}),(0,h.jsx)(o.Box,{className:N.imageGenerationOverlay,onMouseEnter:e=>{e.currentTarget.style.opacity=1,e.currentTarget.style.backgroundColor="rgba(0, 0, 0, 0.3)";const t=e.currentTarget.parentElement.querySelector(`.${N.imageGenerationActions}`);t&&(t.style.opacity=1)},onMouseLeave:e=>{e.currentTarget.style.opacity=0,e.currentTarget.style.backgroundColor="transparent";const t=e.currentTarget.parentElement.querySelector(`.${N.imageGenerationActions}`);t&&(t.style.opacity=0)},children:(0,h.jsx)(o.Button,{onClick:()=>{He(e),jt(t,n)},variant:"contained",className:N.imageGenerationUseButton,children:"Use this"})})]}):l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(O.Skeleton,{variant:"rect",width:"100%",height:"100%",style:{position:"absolute",top:0,left:0,right:0,bottom:0}}),(0,h.jsx)(ur,{progress:ve})]}):null})},e)}))})})]})]}),(0,h.jsx)(o.Drawer,{anchor:"right",open:de,onClose:St,className:N.historyDrawer,PaperProps:{style:{width:window.innerWidth>768?"600px":"100vw",maxWidth:"100vw",backgroundColor:"#ffffff",boxShadow:"-4px 0 20px rgba(0, 0, 0, 0.1)"}},children:(0,h.jsxs)(o.Box,{style:{display:"flex",flexDirection:"column",height:"100%",overflowX:"hidden"},className:N.historyDrawerMainContainer,children:[(0,h.jsxs)(o.Box,{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"20px 24px",borderBottom:"1px solid #E8E8E8",backgroundColor:"#ffffff",position:"sticky",top:0,zIndex:10},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,h.jsx)(o.Box,{style:{backgroundColor:"#ebf5f3",borderRadius:"8px",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,h.jsx)(wi.A,{size:20,color:"#0a474c"})}),(0,h.jsx)(o.Typography,{variant:"h5",style:{color:"#0a474c",fontWeight:500,fontSize:"18px",lineHeight:"24px"},children:"Previous Ai Generated Ads"})]}),(0,h.jsx)(o.IconButton,{onClick:St,size:"small",style:{backgroundColor:"#f5f5f5",borderRadius:"8px",padding:"8px","&:hover":{backgroundColor:"#e0e0e0"}},children:(0,h.jsx)(d.Close,{style:{fontSize:"20px",color:"#666"}})})]}),(0,h.jsxs)(o.Box,{className:N.historySearchBarContainer,children:[(0,h.jsx)(o.Box,{className:N.historySearchBar,children:(0,h.jsx)(o.TextField,{placeholder:"Search Previous Ai Generated Ads...",value:pe,id:"searchPreviousQuery",name:"searchPreviousQuery",className:N.historySearchField,onKeyDown:e=>(e=>{"Enter"===e.key&&Z(e.target.value)})(e),onChange:e=>{ue(e.target.value),xt(1)},InputProps:{startAdornment:(0,h.jsx)(o.InputAdornment,{position:"start",children:(0,h.jsx)(Ni.A,{size:18,style:{color:"#808080"}})})}})}),(0,h.jsxs)(o.Box,{className:N.dateRangeSelector,onClick:e=>{if(e.target.closest&&!e.target.closest("[class*=MuiSelect-root]")){const e=document.querySelector("#dateRangeSelector [class*=MuiSelect-root]");e&&e.click()}},children:[(0,h.jsx)(ji.A,{size:16,color:"#808080"}),(0,h.jsx)(o.Box,{style:{flex:1},children:(0,h.jsx)(Yi,{startDate:mt,endDate:gt,id:"dateRangeSelector",name:"dateRangeSelector",onChange:(e,t)=>
1{ht(e),bt(t),xt(1)}})})]})]}),(0,h.jsxs)(o.Box,{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 24px",borderBottom:"1px solid #E8E8E8",backgroundColor:"#fafafa",position:"sticky",top:"80px",zIndex:9},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",gap:8},children:[(0,h.jsx)(o.Typography,{variant:"caption",style:{color:"#666",fontSize:"12px"},children:"Show:"}),(0,h.jsxs)(o.Select,{value:ft,onChange:e=>(At(e.target.value),void xt(1)),size:"small",variant:"outlined",style:{minWidth:"100px",height:"32px",fontSize:"12px",paddingRight:"24px"},children:[(0,h.jsx)(o.MenuItem,{value:5,style:{paddingRight:"16px"},children:"5 per page"}),(0,h.jsx)(o.MenuItem,{value:10,style:{paddingRight:"16px"},children:"10 per page"}),(0,h.jsx)(o.MenuItem,{value:25,style:{paddingRight:"16px"},children:"25 per page"}),(0,h.jsx)(o.MenuItem,{value:50,style:{paddingRight:"16px"},children:"50 per page"})]})]}),(0,h.jsx)(O.Pagination,{count:Math.ceil(pt/ft),color:"primary",size:"small",shape:"rounded",page:yt,onChange:(e,t)=>
1{xt(t)},style:{'& .MuiPaginationItem-root, & [class*="MuiPaginationItem-root-"]':{fontSize:"12px",minWidth:"32px",height:"32px"}}})]}),rt?(0,h.jsx)(o.Box,{className:N.historyLoadingContainer,children:(0,h.jsx)(o.CircularProgress,{size:24})}):(0,h.jsx)(o.Box,{className:N.historyContainer,children:(()=>{const{data:e}={data:dt,total:pt},n=e.reduce(((e,t)=>{const a=new Date(t.createdAt).toLocaleDateString("en-GB");return e[a]||(e[a]=[]),e[a].push(t),e}),{});return Object.entries(n).map((e=>{let[n,s]=e;return(0,h.jsx)(o.Box,{id:n,name:n,children:s.map(((e,s)=>{const o=[...(e.imageResult||[]).map((e=>({...e,type:"image",url:e.url}))),...(e.videoResult||[]).map((e=>({...e,type:"video",url:e.url?.video_url||e.url,thumbnail:e.url?.first_frame_url})))];return(0,h.jsx)(cr,{images:o,promptId:e._id,prompt:e.userPrompt,timestamp:e.createdAt,styleType:e.styleType,aspectRatio:e.aspectRatio,styles:xr,mainResolutions:fr,onPromptCopy:e=>{navigator.clipboard.writeText(e).then((()=>{L("Prompt copied to clipboard!","success")})).catch((()=>{const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),L("Prompt copied to clipboard!","success")}))},onImageSelect:function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"image",s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(Ct(null),He(null),"video"===n){if(!y&&!c)return void L("Video isn't supported here — pick an image instead","info");Ne([null,null,null]),ke([null,null,null]),Re([null,null,null]),t&&l&&l(null);const a={publicUrl:e,fileName:"Generated Video",fileType:"VIDEO"};if(y&&y(a),c&&c(a),s&&p){p({publicUrl:s,fileName:"Generated Video Thumbnail",fileType:"IMAGE"})}}else D?D(e):(Oe([null]),Me([null]),Fe([null]),ze([null]),a&&c&&c(null),s&&p&&p(null),b(e),l({publicUrl:e,fileName:"Generated Image",fileType:"IMAGE"}))},onImageModalOpen:vt,onDownload:Tt,selectedIndex:It,onSelectedIndexChange:Ct,onHistoryDrawerToggle:St},e._id||`${n}-${s}`)}))},n)}))})()})]})}),(0,h.jsx)(B,{name:"mediaLibrary",openMediaDialog:oe,toggleMediaDialog:()=>{ie(!oe)},onMediaSelect:Nt,mediaType:ge,isFromMetaAds:!0,flowConfiguration:{isEnabled:!0},hideProduct:!1,selectedProducts:[],match:{params:{projectId:"current-project"}}}),(0,h.jsx)(B,{name:"mediaLibrary",openMediaDialog:me,toggleMediaDialog:wt,onMediaSelect:ye?e=>{let t=null;Array.isArray(e)&&e.length>0?t=e[0]:e&&!Array.isArray(e)&&(t=e),t&&p&&p(t),he(!1)}:Nt,mediaType:ge,isFromMetaAds:!0,flowConfiguration:{isEnabled:!1},selectedProducts:[],match:{params:{projectId:"current-project"}}}),(0,h.jsx)(o.Dialog,{open:Je,onClose:Et,maxWidth:!1,fullWidth:!0,PaperProps:{style:{backgroundColor:"transparent",boxShadow:"none",maxWidth:"90vw",maxHeight:"95vh",margin:"16px",overflow:"hidden",width:"90vw"}},children:(0,h.jsxs)(o.Box,{style:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.9)",borderRadius:"12px",padding:"20px",width:"100%",height:"100%",maxWidth:"90vw",maxHeight:"95vh",overflow:"hidden",boxSizing:"border-box"},children:[(0,h.jsxs)(o.Box,{style:{position:"absolute",top:"16px",right:"16px",display:"flex",gap:"12px",zIndex:10},children:[(0,h.jsx)(o.IconButton,{onClick:e=>{e.preventDefault(),e.stopPropagation();const t=qe.includes("video")||qe.includes(".mp4")?".mp4":".jpg",a=Qe.includes(".")?Qe:`${Qe}${t}`;Tt(qe,a)},style:{backgroundColor:"rgba(255, 255, 255, 0.9)",color:"#0a474c",width:"48px",height:"48px",boxShadow:"0 4px 12px rgba(0,0,0,0.3)"},children:(0,h.jsx)(Di.A,{size:24})}),(0,h.jsx)(o.IconButton,{onClick:e=>{e.preventDefault(),e.stopPropagation(),Et()},style:{backgroundColor:"rgba(255, 255, 255, 0.9)",color:"#0a474c",width:"48px",height:"48px",boxShadow:"0 4px 12px rgba(0,0,0,0.3)"},children:(0,h.jsx)(Ei.A,{size:24})})]}),nt.length>1&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.IconButton,{onClick:e=>{e.preventDefault(),e.stopPropagation(),(()=>{if(nt.length>1){const e=0===tt?nt.length-1:tt-1;at(e),Xe(nt[e]),et(`Generated Image ${e+1}`)}})()},style:{position:"absolute",left:"16px",top:"50%",transform:"translateY(-50%)",backgroundColor:"rgba(255, 255, 255, 0.9)",color:"#0a474c",width:"48px",height:"48px",boxShadow:"0 4px 12px rgba(0,0,0,0.3)",zIndex:10},children:(0,h.jsx)(ki.A,{size:24})}),(0,h.jsx)(o.IconButton,{onClick:e=>{e.preventDefault(),e.stopPropagation(),(()=>{if(nt.length>1){const e=(tt+1)%nt.length;at(e),Xe(nt[e]),et(`Generated Image ${e+1}`)}})()},style:{position:"absolute",right:"16px",top:"50%",transform:"translateY(-50%)",backgroundColor:"rgba(255, 255, 255, 0.9)",color:"#0a474c",width:"48px",height:"48px",boxShadow:"0 4px 12px rgba(0,0,0,0.3)",zIndex:10},children:(0,h.jsx)(Li.A,{size:24})})]}),(0,h.jsx)(o.Box,{style:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",maxWidth:"85vw",maxHeight:"calc(90vh - 120px)",overflow:"visible",position:"relative",margin:"0 auto"},children:qe.includes("video")||qe.includes(".mp4")?(0,h.jsx)("video",{src:qe,controls:!0,style:{maxWidth:"85vw",maxHeight:"80vh",width:"auto",height:"auto",objectFit:"contain",borderRadius:"8px"}}):(0,h.jsx)("img",{src:qe,alt:Qe,style:{maxWidth:"85vw",maxHeight:"80vh",width:"auto",height:"auto",objectFit:"contain",borderRadius:"8px",boxShadow:"0 8px 32px rgba(0,0,0,0.3)",display:"block"}})}),(0,h.jsxs)(o.Box,{style:{display:"flex",flexDirection:"column",alignItems:"center",marginTop:"16px",width:"80%"},children:[nt.length>1&&(0,h.jsxs)(o.Typography,{variant:"body2",style:{color:"rgba(255, 255, 255, 0.8)",marginBottom:"4px",fontSize:"14px"},children:[tt+1," of ",nt.length]}),(0,h.jsx)(o.Typography,{variant:"h6",style:{color:"white",textAlign:"center",fontWeight:500,textShadow:"0 2px 4px rgba(0,0,0,0.5)",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Qe})]})]})}),(0,h.jsx)(o.Snackbar,{open:ot.open,autoHideDuration:3e3,onClose:()=>{it({open:!1,message:""})},message:ot.message,anchorOrigin:{vertical:"bottom",horizontal:"center"},style:{backgroundColor:j.palette.primary.main,color:"white"}}),(0,h.jsx)(o.Drawer,{anchor:"right",onClose:()=>Se(!1),PaperProps:{style:{width:window.innerWidth>768?"600px":"100vw",maxWidth:"100vw",backgroundColor:"#ffffff",boxShadow:"-4px 0 20px rgba(0, 0, 0, 0.1)",zIndex:1e3}},BackdropProps:{style:{zIndex:999}},ModalProps:{style:{zIndex:1e3}},children:(0,h.jsxs)(o.Box,{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 12px 8px 24px",boxShadow:"0px 4px 8px #f3efef"},children:[(0,h.jsx)(o.Typography,{variant:"h4",style:{fontWeight:600},children:"Purchase AI Credits"}),(0,h.jsx)(o.IconButton,{onClick:()=>Se(!1),style:{padding:"8px"},children:(0,h.jsx)(Ei.A,{size:24})})]}),(0,h.jsx)(o.Box,{style:{padding:"0px 24px",paddingTop:"12px"},children:(0,h.jsxs)(o.Typography,{variant:"h6",style:{fontSize:"12px"},children:["AI credits are used to power AI-generated content creation, including:",(0,h.jsx)("br",{}),"• AI-generated ad creatives and videos",(0,h.jsx)("br",{}),"• AI-powered content optimization",(0,h.jsx)("br",{}),"• AI-driven audience targeting and insights"]})}),(0,h.jsx)(o.Box,{style:{padding:"24px 16px",flex:1,overflow:"auto",backgroundColor:"#f9f8f873",maxHeight:"calc(100vh - 140px)"},children:(0,h.jsx)(B,{name:"aiCredit",showSnackbar:e=>{console.log("Snackbar:",e)},closeDialog:()=>Se(!1),assistantDetails:g,isFromAdsMediaSection:!0}
1)})]})},3333)]})}const Cr=10,_r=e=>"whatsapp_status"!==e,Sr=function(){return{mediaType:arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image",imageUrl:"",videoUrl:"",headline:"",description:"",websiteUrl:""}},vr="#0a474c",Er="undefined"!=typeof Symbol?Symbol("carouselCardKey"):"__carouselCardKey";let Tr=0;const Dr=e=>(void 0===e[Er]&&(e[Er]="card-"+Tr++),e[Er]),wr=(0,o.makeStyles)((e=>({list:{maxHeight:480,overflowY:"auto",overflowX:"hidden",padding:"2px 4px 2px 2px",scrollBehavior:"smooth","&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{background:"#f1f3f3",borderRadius:8},"&::-webkit-scrollbar-thumb":{background:"rgba(10, 71, 76, 0.25)",borderRadius:8,"&:hover":{background:"rgba(10, 71, 76, 0.45)"}}},emptyList:{boxSizing:"border-box",minHeight:270,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,padding:16,border:"1px dashed #d5dcdb",borderRadius:8,backgroundColor:"#f7f8f8"},emptyListIcon:{fontSize:32,color:"rgba(10, 71, 76, 0.35)"},accordion:{marginBottom:10,borderRadius:8,border:"1px solid #e3e7e7",boxSizing:"border-box",boxShadow:"none","&:before":{display:"none"},"&$accordionExpanded":{margin:0,marginBottom:10}},accordionExpanded:{},accordionDragging:{borderColor:vr,boxShadow:"0 6px 16px rgba(10, 71, 76, 0.18)"},accordionActivePreview:{borderColor:"#2f7d52",borderWidth:1.5},accordionSummary:{minHeight:44,'& [class*="MuiAccordionSummary-content"]':{display:"flex",alignItems:"center",overflow:"hidden",gap:8}},dragHandle:{display:"flex",alignItems:"center",marginRight:4},mediaTypeBadge:{flex:"0 0 auto",fontSize:"0.65rem",padding:"2px 8px",borderRadius:10,backgroundColor:"#f1f3f3",color:e.palette.text.secondary,whiteSpace:"nowrap",textTransform:"capitalize"},cardPreviewText:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},removeButton:{padding:2},accordionDetails:{display:"flex",flexDirection:"column",paddingTop:0},cardColumns:{display:"flex",gap:16,alignItems:"flex-start"},mediaColumn:{flex:"0 0 38%",minWidth:0,maxWidth:220},mediaColumnNarrow:{flex:"0 0 26%",minWidth:0,maxWidth:160},fieldsColumn:{flex:1,minWidth:0,display:"flex",flexDirection:"column"},mediaBox:{position:"relative",height:160,borderRadius:6,overflow:"hidden",backgroundColor:"#f7f8f8",display:"flex",alignItems:"center",justifyContent:"center"},mediaClickTarget:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},mediaClearButton:{position:"absolute",top:2,right:2,padding:2,backgroundColor:"rgba(255,255,255,0.85)","&:hover":{backgroundColor:"#fff"}},mediaImage:{width:"100%",height:"100%",objectFit:"cover",display:"block"},mediaVideo:{width:"100%",height:"100%",objectFit:"cover",display:"block",backgroundColor:"#000"},fieldLabelRow:{display:"flex",justifyContent:"space-between",alignItems:"center"},fieldLabelActions:{display:"flex",alignItems:"center",gap:4},headerActions:{display:"flex",alignItems:"center",gap:8},addButton:{backgroundColor:e.palette.primary.main,color:"#fff",textTransform:"none","&:hover":{backgroundColor:e.palette.primary.dark}},aiButton:{backgroundColor:e.palette.primary.main,color:"#fff",textTransform:"none","&:hover":{backgroundColor:e.palette.primary.dark}},applyToAllButton:{color:vr,textTransform:"none",fontSize:"0.7rem",padding:"0 4px",minWidth:"auto",whiteSpace:"nowrap","&.Mui-disabled":{color:e.palette.text.disabled}}}))),Nr={width:"100%"},jr={padding:"5px 8px",fontSize:"0.75rem",lineHeight:"16px"},kr=e=>{let{label:t,mediaKind:a,mediaUrl:s,disabled:i,onOpenPicker:r,onUrlChange:l,urlPlaceholder:c}=e;const p=wr(),[u,m]=(0,n.useState)(!1),g="video"===a,b=Boolean(s);return i?(0,h.jsx)(o.Box,{mb:1,children:(0,h.jsx)(o.Box,{className:p.mediaBox,px:1,children:(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",align:"center",children:"Media locked while live"})})}):(0,h.jsxs)(o.Box,{mb:1,children:[(0,h.jsxs)(o.Box,{className:p.mediaBox,children:[(0,h.jsx)(o.Box,{className:p.mediaClickTarget,onClick:r,title:`Choose ${t}`,children:b?g?(0,h.jsx)("video",{src:`${s}
1#t=0.1`,className:p.mediaVideo,muted:!0,playsInline:!0,preload:"metadata"}):(0,h.jsx)("img",{src:s,alt:`Card ${t}`,className:p.mediaImage}):(0,h.jsxs)(o.Box,{display:"flex",flexDirection:"column",alignItems:"center",children:[g?(0,h.jsx)(d.Videocam,{style:{color:"rgba(10, 71, 76, 0.35)",fontSize:24}}):(0,h.jsx)(d.ImageOutlined,{style:{color:"rgba(10, 71, 76, 0.35)",fontSize:24}}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{fontSize:"0.65rem"},children:`Add ${t}`})]})}),b&&(0,h.jsx)(o.IconButton,{size:"small",className:p.mediaClearButton,onClick:()=>l(""),title:`Remove ${t}`,children:(0,h.jsx)(d.Close,{style:{fontSize:14}})})]}),(0,h.jsx)(o.Link,{component:"button",variant:"caption",onClick:()=>m((e=>!e)),style:{color:vr,display:"block",marginTop:4},children:u?"Hide URL field":"Or paste a URL instead"}),u&&(0,h.jsx)(o.TextField,{variant:"outlined",size:"small",fullWidth:!0,placeholder:c,onChange:e=>l(e.target.value),style:{...Nr,marginTop:4},inputProps:{style:jr}})]})},Lr=e=>{let{cards:t=[],adTypeValue:a,disabled:s=!1,assistantId:i,assistantDetails:r,updateAssistantAdCredits:l,updateAssistantStore:c,activePreviewIndex:p,onCardsChange:m}=e;const g=wr(),b="website_traffic"===a||"website_to_whatsapp"===a,[y,x]=(0,n.useState)(null),[f,A]=(0,n.useState)(!1),[I,C]=(0,n.useState)(0),{showSnackbar:_}=(0,ls.dh)(),{isAiSensy:v}=(0,u.x)(),E=(0,n.useRef)(null),T=(0,n.useRef)([]),D=(0,n.useRef)(null),w=(0,n.useMemo)((()=>t.map(((e,t)=>e.imageUrl||e.videoUrl?null:t)).filter((e=>null!==e))),[t]),N=Math.max(Cr-(t.length-w.length),0),j=(0,n.useMemo)((()=>{const e={};return t.forEach(((t,a)=>{t.imageUrl&&(e[t.imageUrl]=a+1),t.videoUrl&&(e[t.videoUrl]=a+1)})),e}),[t]);(0,n.useEffect)((()=>{(e=>{const t=E.current,a=T.current[e];if(!t||!a)return;const n=t.getBoundingClientRect(),s=a.getBoundingClientRect(),o=s.top-n.top+t.scrollTop,i=o+s.height;o<t.scrollTop?t.scrollTop=o:i>t.scrollTop+t.clientHeight&&(t.scrollTop=i-t.clientHeight)})(p??0)}),[p,t.length]);const k=(e,a)=>{m(t.map(((t,n)=>n===e?{...t,...a}:t)))},L=()=>{const e=t[0];m(t.map(((t,a)=>0===a?t:{...t,headline:e.headline,description:e.description})))},R=y?"thumbnail"===y.field||"video"!==t[y.index]?.mediaType?"IMAGE":"VIDEO":"IMAGE";return(0,h.jsxs)(o.Box,{children:[(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1,children:[(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"h5",children:"Cards"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:t.length>0?`${t.length} of 10 — drag to reorder`:"0 of 10"})]}),(0,h.jsxs)(o.Box,{className:g.headerActions,children:[va("mediaLibrary")&&(0,h.jsx)(o.Button,{variant:"contained",startIcon:(0,h.jsx)(d.Add,{}),onClick:()=>A(!0),disabled:s||N<=0,size:"small",className:g.addButton,children:"Add Images & Videos"}),v&&(0,h.jsx)(o.Button,{variant:"contained",startIcon:(0,h.jsx)(S.A,{size:15}),onClick:()=>{const e=D.current;if(!e?.scrollIntoView)return;const t=e.getBoundingClientRect().top;e.scrollIntoView({behavior:"smooth",block:"start"}),setTimeout((()=>{D.current&&D.current.getBoundingClientRect().top===t&&D.current.scrollIntoView({block:"start"})}),250)},size:"small",className:g.aiButton,children:"Generate Images with AI"})]})]}),0===t.length?(0,h.jsxs)(o.Box,{className:g.emptyList,children:[(0,h.jsx)(d.ViewCarousel,{className:g.emptyListIcon}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",align:"center",children:"Add at least 2 images or videos to build your carousel"})]}):(0,h.jsx)(Fo.JY,{onDragEnd:e=>{const{destination:a,source:n}=e;if(!a)return;const s=Array.from(t),[o]=s.splice(n.index,1);s.splice(a.index,0,o),m(s)},children:(0,h.jsx)(Fo.gL,{droppableId:"carouselCards",type:"CAROUSEL_CARD",children:e=>(0,h.jsxs)(o.Box,{...e.droppableProps,ref:t=>{e.innerRef(t),E.current=t},className:g.list,children:[t.map(((e,a)=>(0,h.jsx)(Fo.sx,{draggableId:Dr(e),index:a,isDragDisabled:s,children:(n,i)=>(0,h.jsxs)(o.Accordion,{ref:e=>{n.innerRef(e),T.current[a]=e},...n.draggableProps,expanded:I===a,onChange:(e,t)=>
1C(t?a:null),classes:{expanded:g.accordionExpanded},className:`${g.accordion} ${i.isDragging?g.accordionDragging:""} ${a===p?g.accordionActivePreview:""}`,style:n.draggableProps.style,TransitionProps:{unmountOnExit:!1},children:[(0,h.jsxs)(o.AccordionSummary,{expandIcon:(0,h.jsx)(d.ExpandMore,{}),className:g.accordionSummary,children:[(0,h.jsx)(o.Box,{...n.dragHandleProps,className:g.dragHandle,style:{cursor:s?"default":"grab"},children:(0,h.jsx)(d.DragIndicator,{fontSize:"small",color:"disabled"})}),(0,h.jsx)(o.Typography,{variant:"body2",noWrap:!0,children:`Card ${a+1}`}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",className:g.cardPreviewText,children:e.headline||"Untitled"}),(0,h.jsx)(o.Typography,{variant:"caption",className:g.mediaTypeBadge,children:"video"===e.mediaType?"Video":"Image"}),(0,h.jsx)(o.IconButton,{size:"small",onClick:e=>{e.stopPropagation(),(e=>{m(t.filter(((t,a)=>a!==e)))})(a)},disabled:s,title:"Remove card",className:g.removeButton,children:(0,h.jsx)(d.Close,{style:{fontSize:16}})})]}),(0,h.jsx)(o.AccordionDetails,{className:g.accordionDetails,children:(0,h.jsxs)(o.Box,{className:g.cardColumns,children:["video"===e.mediaType?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Box,{className:g.mediaColumnNarrow,children:(0,h.jsx)(kr,{label:"video",mediaKind:"video",mediaUrl:e.videoUrl,disabled:s,onOpenPicker:()=>{va("mediaLibrary")&&x({index:a,field:"media"})},onUrlChange:e=>k(a,{videoUrl:e}),urlPlaceholder:"Video URL"})}),(0,h.jsx)(o.Box,{className:g.mediaColumnNarrow,children:(0,h.jsx)(kr,{label:"thumbnail",mediaKind:"image",mediaUrl:e.imageUrl,disabled:s,onOpenPicker:()=>{va("mediaLibrary")&&x({index:a,field:"thumbnail"})},onUrlChange:e=>k(a,{imageUrl:e}),urlPlaceholder:"Thumbnail URL"})})]}):(0,h.jsx)(o.Box,{className:g.mediaColumn,children:(0,h.jsx)(kr,{label:"image",mediaKind:"image",mediaUrl:e.imageUrl,disabled:s,onOpenPicker:()=>{va("mediaLibrary")&&x({index:a,field:"media"})},onUrlChange:e=>k(a,{imageUrl:e}),urlPlaceholder:"Image URL"})}),(0,h.jsxs)(o.Box,{className:g.fieldsColumn,children:[(0,h.jsxs)(o.Box,{className:g.fieldLabelRow,children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:"Headline"}),(0,h.jsxs)(o.Box,{className:g.fieldLabelActions,children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:`${(e.headline||"").length}/40`}),0===a&&(0,h.jsx)(o.Button,{size:"small",onClick:L,disabled:s||!((e.headline||"").length>1||(e.description||"").length>1),className:g.applyToAllButton,children:"Apply to all cards"})]})]}),(0,h.jsx)(o.TextField,{variant:"outlined",size:"small",fullWidth:!0,value:e.headline||"",onChange:e=>k(a,{headline:e.target.value.slice(0,40)}),style:{...Nr,marginBottom:6},inputProps:{style:jr}}),(0,h.jsxs)(o.Box,{className:g.fieldLabelRow,children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:"Description"}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:`${(e.description||"").length}/30`})]}),(0,h.jsx)(o.TextField,{variant:"outlined",size:"small",fullWidth:!0,value:e.description||"",onChange:e=>k(a,{description:e.target.value.slice(0,30)}),style:{...Nr,marginBottom:b?6:0},inputProps:{style:jr}}),b&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:"Website URL"}),(0,h.jsx)(o.TextField,{variant:"outlined",size:"small",fullWidth:!0,placeholder:"https://",value:e.websiteUrl||"",onChange:e=>k(a,{websiteUrl:e.target.value}),disabled:s,style:Nr,inputProps:{style:jr}})]})]})]})})]})},Dr(e)))),e.placeholder]})})}),(0,h.jsx)("div",{ref:D,style:{marginTop:16},children:(0,h.jsx)(Ir,{aiGeneratorOnly:!0,assistantDetails:r,updateAssistantAdCredits:l,updateAssistantStore:c,useButtonLabel:"Add as new card",onUseGeneratedImage:e=>{t.length>=Cr?_("There are already 10 cards in the Carousel","warning"):(m([...t,{...Sr("image"),imageUrl:e}]),_("Image added to the carousel","success"))}})}),(0,h.jsx)(B,{name:"mediaLibrary",openMediaDialog:Boolean(y),toggleMediaDialog:()=>x(null),onMediaSelect:e=>{const a=Array.isArray(e)?e[0]:e;if(a&&y){const e=(0,wo.replaceDomainInData)(a.publicUrl);if("thumbnail"===y.field)k(y.index,{imageUrl:e});else{const a=t[y.index];k(y.index,"video"===a?.mediaType?{videoUrl:e}:{imageUrl:e})}}x(null)},mediaType:R,isFromMetaAds:!0,flowConfiguration:{isEnabled:!1},selectedProducts:[],match:{params:{projectId:i}}}),(0,h.jsx)(B,{name:"mediaLibrary",openMediaDialog:f,toggleMediaDialog:()=>A(!1),onMediaSelect:e=>
1{const a=(Array.isArray(e)?e:[e]).filter(Boolean);if(A(!1),0===a.length)return;let n=0;const s=t.map(((e,t)=>{if(!w.includes(t)||n>=a.length)return e;const s=a[n++],o="VIDEO"===s?.fileType,i=(0,wo.replaceDomainInData)(s?.publicUrl||"");return{...e,mediaType:o?"video":"image",imageUrl:o?"":i,videoUrl:o?i:""}})),o=Math.max(Cr-s.length,0),i=a.slice(n,n+o).map((e=>{const t="VIDEO"===e?.fileType,a=(0,wo.replaceDomainInData)(e?.publicUrl||"");return{...Sr(t?"video":"image"),imageUrl:t?"":a,videoUrl:t?a:""}}));m([...s,...i])},mediaType:["IMAGE","VIDEO"],multiSelect:!0,isFromMetaAds:!0,flowConfiguration:{isEnabled:!1},selectedProducts:[],match:{params:{projectId:i}},carouselPlacedCardNumberByUrl:j,getCarouselPendingCardNumber:e=>e<w.length?w[e]+1:t.length+(e-w.length)+1,onRemoveCarouselMedia:e=>{const a=j[e];a&&m(t.filter(((e,t)=>t!==a-1)))},maxSelectable:N,maxSelectableMessage:`You can select up to ${N} more — a carousel is limited to 10 cards`})]})},Rr=()=>"undefined"!=typeof window&&void 0!==window.FB,Br=e=>{let{pageId:t}=e;return new Promise(((e,a)=>{if(Rr())if(t)try{window.FB.ui({method:"lead_gen",page_id:t},(t=>{if(t&&!t.error_code)t.formID||t.form_id?e({formId:t.formID||t.form_id,formName:t.name||t.formName}):a("Form creation was cancelled");else if(t&&t.error_code){const e=Or(t.error_code,t.error_message);a(e)}else a("Form creation was cancelled")}))}catch(e){a(e.message||"Failed to open lead form dialog")}else a("Page ID is required to create a lead form");else a("Facebook SDK is not loaded. Please refresh the page and try again.")}))},Or=(e,t)=>({100:"Invalid parameter. Please check your Page ID and try again.",190:"Access token has expired. Please reconnect your Facebook account.",200:"You don't have permission to create lead forms for this page.",4:"Application request limit reached. Please try again later.",10:"This feature is not available for your account.",2:"An unexpected error occurred. Please try again."}[e]||t||"An error occurred while creating the lead form.");var Pr=a(93816);const Mr=e=>(0,h.jsxs)("svg",{width:16,height:16,xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,h.jsx)("path",{d:"M11.824 1.3c-.111 0-.167 0-.21.021a.201.201 0 0 0-.088.087c-.022.043-.022.1-.022.212v.76c0 .112 0 .168.021.21a.21.21 0 0 0 .087.088c.043.022.1.022.212.023.251.002.353.008.434.024a1.3 1.3 0 0 1 1.021 1.021c.022.109.025.256.025.754v.803c0 .562 0 .992.126 1.391.11.352.293.677.534.955a2.5 2.5 0 0 0 .38.351 2.5 2.5 0 0 0-.38.35 2.699 2.699 0 0 0-.534.956c-.127.4-.127.83-.126 1.39v.804c0 .498-.003.645-.025.754a1.3 1.3 0 0 1-1.021 1.021 2.471 2.471 0 0 1-.434.024c-.113.001-.17.001-.212.023a.199.199 0 0 0-.087.088c-.021.042-.021.098-.021.21v.76c0 .112 0 .169.022.211.02.038.05.069.088.088.043.022.099.021.21.02.277-.001.502-.01.707-.05a2.7 2.7 0 0 0 2.121-2.122c.052-.263.052-.56.052-.956v-.78c0-.7.008-.897.06-1.063a1.3 1.3 0 0 1 .258-.46c.114-.133.279-.242.875-.608l.015-.01A.2.2 0 0 0 16 8.494v-.986a.2.2 0 0 0-.088-.158l-.007-.004-.008-.005c-.596-.366-.76-.476-.875-.608a1.3 1.3 0 0 1-.258-.46c-.052-.166-.06-.364-.06-1.063v-.78c0-.395 0-.693-.052-.956a2.7 2.7 0 0 0-2.121-2.121 3.8 3.8 0 0 0-.707-.052zm-7.644 0c.111 0 .167 0 .21.021a.2.2 0 0 1 .088.087c.022.043.022.1.022.212v.76c0 .112 0 .168-.022.21a.2.2 0 0 1-.086.088c-.043.022-.1.022-.212.023a2.456 2.456 0 0 0-.434.024 1.3 1.3 0 0 0-1.021 1.021c-.022.109-.025.256-.025.754v.803c0 .562 0 .992-.126 1.391a2.7 2.7 0 0 1-.534.955A2.5 2.5 0 0 1 1.659 8a2.5 2.5 0 0 1 .38.35 2.7 2.7 0 0 1 .535.956c.127.4.126.83.126 1.39v.804c0 .498.003.645.025.754a1.3 1.3 0 0 0 1.021 1.021c.081.016.183.022.434.024.113.001.17.001.212.023a.2.2 0 0 1 .086.088c.022.042.022.098.022.21v.76c0 .112 0 .169-.022.211a.2.2 0 0 1-.088.088c-.043.022-.099.021-.21.02a3.796 3.796 0 0 1-.707-.05 2.7 2.7 0 0 1-2.121-2.122c-.052-.263-.052-.56-.052-.956v-.78c0-.7-.008-.897-.06-1.063a1.3 1.3 0 0 0-.258-.46C.868 9.135.703 9.026.107 8.66a.2.2 0 0 1-.103-.167v-.986a.2.2 0 0 1 .088-.158.063.063 0 0 0 .015-.01c.596-.365.76-.475.875-.607a1.3 1.3 0 0 0 .258-.46c.052-.166.06-.364.06-1.063v-.78c0-.395 0-.693.052-.956a2.7 2.7 0 0 1 2.121-2.121A3.8 3.8 0 0 1 4.18 1.3zM8 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"}),(0,h.jsx)("path",{d:"M12.2 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM4.8 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"})]});var Ur=a(99947),Fr=a.n(Ur);function Wr(e){const{classes:t,fallbackParameters:a,handleFallbackParamInput:s,carouselComponent:i,metaComponent:r,name:l,anchorEl:d,onClose:c}=e,p=(0,n.useMemo)((()=>d?.innerText?.replace(/[\r\n]/g,"")),[d]),u=Boolean(d),m=u?"simple-popover":void 0,g=(0,n.useRef)(null),b=`If we can't find ${p}`;return(0,n.useEffect)((()=>{g&&g.current&&g.current.focus()}
1),[a]),(0,h.jsx)(o.Popover,{id:m,open:u,anchorEl:d,onClose:c,anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},style:{marginTop:12},elevation:2,children:(0,h.jsxs)(o.Grid,{container:!0,direction:"column",children:[(0,h.jsx)(o.Grid,{item:!0,children:(0,h.jsxs)(o.Box,{p:1,bgcolor:"rgb(240,240,240)",style:{display:"flex",alignItems:"center",gap:8},children:[(0,h.jsx)(Mr,{fill:"#4A4A4A"}),(0,h.jsxs)(o.Typography,{variant:"h6",children:["Recipient's ",(0,h.jsx)("strong",{children:p})," value will be inserted here"]})]})}),(0,h.jsx)(o.Grid,{item:!0,children:(0,h.jsxs)(o.Grid,{container:!0,alignItems:"stretch",children:[(0,h.jsx)(o.Grid,{item:!0,style:{display:"flex",alignItems:"center",borderRight:"1px solid #e0e0e0"},children:(0,h.jsx)(o.Box,{px:1,py:"0.5px",children:(0,h.jsx)(o.Typography,{variant:"body2",style:{fontWeight:"bold"},children:"Fallback"})})}),(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsx)(o.TextField,{inputRef:g,autoFocus:!0,size:"small",variant:"outlined",classes:{root:t.textFieldRoot},inputProps:{style:{padding:"8px 8px",fontSize:14}},style:{borderRadius:0,backgroundColor:"#fff"},onKeyDown:e=>{"Enter"!==e.key&&"Return"!==e.key||(e.preventDefault(),c())},placeholder:b,value:i||r?a[l]:a[p],onChange:e=>s(i||r?l:p,e.target.value,i,r)},"fallback-input")})]})})]})})}function zr(e){let{onClick:t,children:a,isFallbackExists:n,withClickedState:s,classes:i}=e;const r=n?(0,h.jsx)(d.CheckOutlined,{}):(0,h.jsx)(d.ReportProblemOutlined,{}),l={color:n?"#0a474c":"rgb(102, 60, 0)",backgroundColor:n?"#d6ede9":"#ffe082"};return(0,h.jsxs)("span",{style:{display:"inline-flex",position:"relative",alignItems:"center"},children:[(0,h.jsx)("span",{contentEditable:!1,style:{position:"absolute",left:0,top:5.5}}),(0,h.jsx)(o.Button,{startIcon:r,className:i.attributeBtn,classes:{startIcon:i.icon},ref:e=>{s&&e&&e.click()},disableRipple:!0,style:l,color:n?"primary":"default",size:"small",variant:"contained",onClick:t,children:a}),(0,h.jsx)("span",{contentEditable:!1,style:{position:"absolute",right:0,top:5.5}})]})}function Gr(e){const{classes:t,name:a,parameters:s,attributes:i,handleParamInput:r,fallbackParameters:l,handleFallbackParamInput:d,editableStyles:c,carouselComponent:p,metaComponent:u,placeholder:m}=e,g=i.map((e=>`$${e.action?e.action+"_":""}${e.name}`)),b=new RegExp(`(${g.map((e=>`\\${e}`)).join("|")})`,"g"),y=s[a]||"",x=y.replace(/[\u200B-\u200D\uFEFF]/g,""),f=e=>{r(a,e.replace(/\r?\n|\r/g,""),p,u)},A=(0,n.useRef)(null),I=(0,n.useRef)(0),C=()=>function(e){let t=0;const a=window.getSelection();if(!a)return;if(0==a.rangeCount)return t;const n=a.getRangeAt(0),s=n.cloneRange();return s.selectNodeContents(e),s.setEnd(n.endContainer,n.endOffset),t=s.toString().length,t}(A.current)||0,_=()=>{return e=C(),I.current=e;var e},S=(0,Pr.Y)(A,f),[v,E]=(0,n.useState)(null),[T,D]=(0,n.useState)(null),[w,N]=(0,n.useState)(""),[j,k]=(0,n.useState)(!1),L=()=>D(null),R=(0,n.useMemo)((()=>Fr()(x,b,((e,n)=>{let s;if(p||u)s=l[a];else{const t=e.trim(),a={};Object.keys(l).forEach((e=>{const t=e.trim();a[t]=l[e]})),s=a[t]}return(0,h.jsx)(zr,{classes:t,isFallbackExists:!!(s||"").trim(),iconClass:t.icon,withClickedState:e===w&&j,onClick:e=>E(e.currentTarget),children:e},n+e)}))),[x,JSON.stringify(l),b,a,p,u,w,j]),B=(0,n.useMemo)((()=>b.test(y)),[y]);return(0,h.jsxs)(o.Grid,{container:!0,alignItems:"center",style:{...c||{padding:"9px 10px 9px 15px"}},className:B?t.editableWithAttribute:t.editable,children:[(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)("div",{ref:A,className:t.editableInput,onKeyUp:function(e){_(),k(!1)},onMouseUp:e=>{_()},placeholder:m||"Type or select an attribute",children:R},`${p?.componentType||u?.componentType}`+a+"attrinput"),!e.isFromFlow&&!!v&&(0,h.jsx)(Wr,{...e,anchorEl:v,fallbackParameters:l,handleFallbackParamInput:d,carouselComponent:p,metaComponent:u,name:a,onClose:()=>{E(null),k(!1),setTimeout((()=>{!function(e){const t=window.getSelection();t.selectAllChildren(e),t.collapseToEnd()}(A.current)}),10)}})]})}),(0,h.jsxs)(o.Grid,{item:!0,children:[(0,h.jsx)(o.Tooltip,{enterTouchDelay:0,style:{fontSize:"1.2em"},placement:"top",title:"Add attributes from user data",children:(0,h.jsx)(o.Box,{mt:"-4.5px",children:(0,h.jsx)(o.IconButton,{"aria-controls":"attributes-menu","aria-haspopup":"true",onClick:e=>{return t=e.currentTarget,D(t);var t},size:"small",children:(0,h.jsx)(Mr,{fill:"#4A4A4A"})})})}),(0,h.jsx)(o.Menu,{id:"attributes-menu",keepMounted:!0,anchorEl:T,open:!!T,onClose:()=>L(),elevation:2,children:g.map((e=>(0,h.jsx)(o.MenuItem,{onClick:()=>(e=>{N(e),k(!0),A.current.focus();const t=C(),a=(s=t,o=e,(n=y).substr(0,s)+o+n.substr(s));var n,s,o;/^((?!chrome|android).)*safari/i.test(navigator.userAgent)?(f(a),setTimeout((()=>{k(!1),N("")}),0),setTimeout((()=>{const a=t+e.length,n=document.createRange(),s=window.getSelection();if(A.current&&A.current.firstChild&&s){const e=A.current.firstChild,t=e.textContent?e.textContent.length:0,o=Math.min(a,t);n.setStart(e,o),n.collapse(!0),s.removeAllRanges(),s.addRange(n)}}),10)):S.update(a),L()})(e),children:e},e)))})]})]})}const Hr=(0,o.createStyles)({editable:{borderRadius:"8px",backgroundColor:"rgb(240,240,240)"},editableWithAttribute:{borderRadius:"8px",backgroundColor:"rgb(240,240,240)",padding:"10px 10px 10px 10px"},editableInput:{fontSize:"14px",fontWeight:500,fontFamily:"Roboto, sans-serif",color:"#4A4A4A","&:focus":{border:"none",outline:"none"},"&:empty:before":{content:"attr(placeholder)",cursor:"text",color:"#B5B5B5",fontSize:"14px",fontFamily:"Roboto, sans-serif"}},editableIcon:{color:"#4A4A4A"},textFieldRoot:{backgroundColor:"rgb(240,240,240)",outline:"none",border:"none",borderRadius:"8px",width:"100%",padding:"0",boxShadow:"none",boxSizing:"border-box",fontFamily:"Roboto, sans-serif",fontSize:"8px",fontWeight:500},attributeBtn:{width:"fit-content",padding:"2px 12px",marginRight:"1px",marginLeft:"1.5px"},icon:{"&& > svg":{fontSize:12,marginRight:-5}}}),Vr=(0,o.withStyles)(Hr)((0,n.memo)(Gr));var Yr=a(47359),Zr=a.n(Yr),Kr=a(20011),Jr=a(802);function $r(e){const{classes:t,limitedTimeOffer:a,setLimitedTimeOffer:n,assistantTimezone:i}=e,r=a?.parameters?.[0]?.limited_time_offer?.expiration_time_ms,[l,c]=s().useState(Zr()(r)),[p,u]=s().useState(i||"Asia/Calcutta"),m=(e,t)=>
1{const s=JSON.parse(JSON.stringify(a)),o=Zr()(e||l).tz(t||p,!0).valueOf();s.parameters[0].limited_time_offer.expiration_time_ms=o,n(s)};return(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(o.Box,{className:t.datePicker,style:{paddingLeft:"2px"},children:(0,h.jsxs)(Bi.MuiPickersUtilsProvider,{utils:Ri.A,children:[(0,h.jsxs)(Kr.A,{item:!0,xs:12,md:6,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,style:{color:"#000000",marginTop:"16px"},children:"Select Date"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",paragraph:!0,style:{marginBottom:4},children:"Select coupon expiry date"}),(0,h.jsx)(Bi.KeyboardDatePicker,{style:{marginTop:"0px",width:"100%",marginBottom:"30px"},className:t.paddingControl,disableToolbar:!0,minDate:new Date,maxDate:new Date((new Date).setDate((new Date).getDate()+60)),format:"dd/MM/yyyy",margin:"normal",id:"date-picker-inline",value:l,onChange:e=>{c(e),m(e)},KeyboardButtonProps:{"aria-label":"change date"}})]}),(0,h.jsxs)(Kr.A,{item:!0,xs:12,md:6,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,style:{color:"#000000"},children:"Select Time"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",paragraph:!0,style:{marginBottom:4},children:"Select coupon expiry time"}),(0,h.jsx)(Bi.KeyboardTimePicker,{className:t.paddingControl,style:{marginTop:"0px",width:"100%",marginBottom:"30px"},margin:"normal",id:"time-picker",value:l,onChange:e=>{c(e),m(e)},KeyboardButtonProps:{"aria-label":"change time"},keyboardIcon:(0,h.jsx)(d.AccessTimeOutlined,{})})]}),(0,h.jsxs)(Kr.A,{item:!0,xs:12,md:6,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,style:{color:"#000000"},children:"Select Timezone"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",paragraph:!0,style:{marginBottom:4},children:"Select timezone for Expiry date & time"}),(0,h.jsx)(O.Autocomplete,{className:t.timeZoneClass,disableClearable:!0,style:{paddingLeft:0},options:Jr.timeZones,defaultValue:{label:"Chennai, Kolkata, Mumbai, New Delhi (Asia/Calcutta)",value:"+05:30"},onChange:(e,t)=>
1{const a=t?.label?.split(" (")?.pop().slice(0,-1);u(a),m(l,a)},getOptionLabel:e=>{const t=e?.label?.split(" (")?.pop()||"";return`${t.substring(0,t.length-1)} (${e.value})`||""},name:"timezone",renderInput:e=>(0,h.jsx)(o.TextField,{...e,style:{height:"42px",width:"100%",paddingTop:"unset",paddingRight:2},variant:"outlined",InputProps:{...e.InputProps}})})]})]})})})}const qr=["codPaymentReminderSettings","codPaymentReminderFollowupSettings"];const Xr=["amount","productName","productId","quantity"],Qr=(0,o.withStyles)((e=>({bottomMargin:{marginBottom:e.spacing(3),"& .ClickToAction-arrowTop-316":{bottom:-80}},textField:{'& .MuiIconButton-root, & [class*="MuiIconButton-root-"]':{padding:0,background:"red",color:"red"},'& .MuiFormHelperText-root, & [class*="MuiFormHelperText-root-"]':{background:"red",color:"red"},'& .MuiFormControl-root, & [class*="MuiFormControl-root-"]':{background:"red",color:"red"},'& .MuiTextField-root, & [class*="MuiTextField-root-"]':{background:"red",color:"red"},'& .MuiInputBase-root, & [class*="MuiInputBase-root-"]':{background:"red",color:"red"},'& .MuiInput-root, & [class*="MuiInput-root-"]':{background:"red",color:"red"},'& .MuiInputBase-formControl, & [class*="MuiInputBase-formControl-"]':{background:"red",color:"red"},'& .MuiInput-formControl, & [class*="MuiInput-formControl-"]':{background:"red",color:"red"}}})))((e=>{const{classes:t,topicName:a,attributes:s,parameters:i,carouselIndex:r,selectedTemplate:l,fallbackParameters:d,setTemplateMessage:c,cards:p,setCards:u,buttons:m,setButtons:g,handlePaymentParams:b,paymentParams:y,limitedTimeOffer:x,setLimitedTimeOffer:f}=e,A=l?.parameters||0,I=(0,n.useMemo)((()=>[y?.amount,y?.productName,y?.productId,y?.quantity]),[y?.productName,y?.productId]),C=(0,n.useCallback)(((e,t)=>{b({key:Xr[e],value:t})}),[b]),_=(0,n.useCallback)(((e,t)=>{b({key:e,value:t})}),[b]),S=(0,n.useCallback)(((e,t,a,n)=>{if(a){const{idx:n=0,componentType:s}=a,o=JSON.parse(JSON.stringify(p)),i=o?.[r]?.components?.filter((e=>{let{type:t,sub_type:a}=e;return"BUTTON"!==t?t===s:t===s&&"URL"===a}));return i[n].parameters[e].text=t,void u(o)}if(n){const{idx:a,componentType:s}=n;if("BUTTON"===s){const n=JSON.parse(JSON.stringify(m));let s=n[a].parameters[e].type;return"AUTHENTICATION"===l?.category&&"COPY_CODE"===n[a].sub_type&&(n[a].sub_type="URL",n[a].parameters[e].type="text",delete n[a].parameters[e].coupon_code,s="text"),n[a].parameters[e][s]=t,void g(n)}}const s=[...i];s.splice(e,1,t),c("parameters",s)}),[i,p,r,m,l?.category,u,g,c]),v=(0,n.useCallback)(((e,t,a,n)=>{if(a){const{idx:n=0,componentType:s}=a,o=JSON.parse(JSON.stringify(p)),i=o?.[r]?.components?.filter((e=>{let{type:t,sub_type:a}=e;return"BUTTON"!==t?t===s:t===s&&"URL"===a}));return i[n].parameters[e].fallbackText=t,void u(o)}if(n){const{idx:a,componentType:s}=n;if("BUTTON"===s){const n=JSON.parse(JSON.stringify(m));return n[a].parameters[e].fallbackText=t,void g(n)}}const s={...d};s[e]=t,c("fallbackParameters",s)}),[d,p,r,m,u,g,c]),E=p?.[r]?.components?.find((e=>"BODY"===e.type))?.parameters,T=p?.[r]?.components?.filter((e=>"BUTTON"===e.type&&"URL"===e.sub_type));return(0,h.jsxs)(o.Box,{children:[A>0&&(0,h.jsxs)(o.Grid,{item:!0,xs:12,className:t.bottomMargin,children:[(0,h.jsxs)(o.Typography,{variant:"h5",gutterBottom:!0,children:[A," ",1===A?"Parameter":"Parameters"]}),(0,h.jsxs)(o.Typography,{variant:"body2",color:"textSecondary",style:{maxWidth:"18rem",overflow:"hidden"},children:["You can personalize messages with - $FirstName, $Name, $MobileNumber etc. ",(0,h.jsx)("br",{}),"You can also use your custom attributes - $my_custom_attribute_name."]}),Array.from({length:A},((e,t)=>(0,h.jsx)(o.Box,{my:1,children:(0,h.jsxs)(o.Grid,{container:!0,alignItems:"center",children:[(0,h.jsx)(o.Grid,{item:!0,xs:1,children:(0,h.jsx)(o.Typography,{variant:"h5",align:"start",children:t+1})}),(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsx)(Vr,{name:t,attributes:s,parameters:i,handleParamInput:S,fallbackParameters:d,handleFallbackParamInput:v})})]})},`attr-${t}`)))]}),"ORDER_DETAILS"===l.type&&!qr.includes(a)&&(0,h.jsxs)(o.Grid,{item:!0,xs:12,className:t.bottomMargin,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Payment Parameters"}),(0,h.jsxs)(o.Typography,{variant:"body2",color:"textSecondary",style:{maxWidth:"18rem",overflow:"hidden"},children:["You can set payment details messages. ",(0,h.jsx)("br",{}),"You can also use your custom attributes - $my_custom_attribute_name."]}
1),[{label:"Amount",key:"amount",dynamicAttributeSupported:!1},{label:"Product Name",key:"productName",dynamicAttributeSupported:!0},{label:"Product Id",key:"productId",dynamicAttributeSupported:!0},{label:"Quantity",key:"quantity",dynamicAttributeSupported:!1}].map(((e,t)=>(0,h.jsx)(o.Box,{my:1,children:(0,h.jsxs)(o.Grid,{container:!0,alignItems:"center",children:[(0,h.jsx)(o.Grid,{item:!0,xs:1,children:(0,h.jsx)(o.Typography,{variant:"h5",align:"start",children:t+1})}),(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:e.dynamicAttributeSupported?(0,h.jsx)(Vr,{name:t,attributes:s,parameters:I,handleParamInput:C,fallbackParameters:d,handleFallbackParamInput:v,placeholder:e.label}):(0,h.jsx)(o.TextField,{type:"number",inputProps:{min:0,step:1},name:`payment-${e.key}`,value:y?.[Xr[t]]||"",onChange:e=>{const a=e.target.value.replace(/\D/g,"");_(Xr[t],a?parseInt(a,10):"")},placeholder:e.label,fullWidth:!0})})]})},`payment-param-${e.key}-${t}`)))]}),"LIMITED_TIME_OFFER"===l.type&&x?.parameters?.length&&(0,h.jsxs)(o.Grid,{item:!0,xs:12,className:t.bottomMargin,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Limited Time Offer Parameters"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{maxWidth:"18rem",overflow:"hidden"},children:"Select the expiration date for this offer"}),(0,h.jsx)($r,{classes:t,limitedTimeOffer:x,setLimitedTimeOffer:f})]}),(E?.length||T?.length)&&(0,h.jsx)(o.Grid,{item:!0,xs:12,style:{marginBottom:16},children:(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Carousel Card #"+(r+1)+" Parameters"})}),E?.length&&(0,h.jsxs)(o.Grid,{item:!0,xs:12,className:t.bottomMargin,children:[(0,h.jsxs)(o.Typography,{variant:"body2",color:"textSecondary",style:{maxWidth:"18rem",overflow:"hidden"},children:[E.length," ",1===E.length?"Body Parameter":"Body Parameters"]}),Array.from({length:E.length},((e,t)=>(0,h.jsx)(o.Box,{my:1,children:(0,h.jsxs)(o.Grid,{container:!0,alignItems:"center",children:[(0,h.jsx)(o.Grid,{item:!0,xs:1,children:(0,h.jsx)(o.Typography,{variant:"h5",align:"start",children:t+1})}),(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsx)(Vr,{attributes:s,carouselComponent:{idx:0,componentType:"BODY"},parameters:E?.map((e=>e.text)),name:t,handleParamInput:S,fallbackParameters:E?.map((e=>e.fallbackText)),handleFallbackParamInput:v})})]})},`card-body-${t}`)))]}),T?.length?(0,h.jsx)(h.Fragment,{children:Array.from({length:T?.length||0},((e,a)=>"#SAMPLE-CLICK-TRACKING#"===T[a]?.parameters?.[0]?.text?(0,h.jsx)(h.Fragment,{}):(0,h.jsxs)(o.Grid,{item:!0,xs:12,className:t.bottomMargin,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{maxWidth:"18rem",overflow:"hidden"},children:1===T.length?`${T[a].parameters?.length||0} ${1===(T[a].parameters?.length||0)?"Button Parameter":"Button Parameters"}`:`Button #${a+1} - ${T[a].parameters?.length||0} ${1===(T[a].parameters?.length||0)?"Parameter":"Parameters"}`}),Array.from({length:T[a].parameters?.length||0},((e,t)=>(0,h.jsx)(o.Box,{my:1,children:(0,h.jsxs)(o.Grid,{container:!0,alignItems:"center",children:[(0,h.jsx)(o.Grid,{item:!0,xs:1,children:(0,h.jsx)(o.Typography,{variant:"h5",align:"start",children:t+1})}),(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsx)(Vr,{attributes:s,carouselComponent:{idx:a,componentType:"BUTTON"},parameters:T[a]?.parameters.map((e=>e.text)),name:t,handleParamInput:S,fallbackParameters:T[a]?.parameters?.map((e=>e.fallbackText)),handleFallbackParamInput:v})})]})},`card-body-${a}-${t}`)))]})))}):(0,h.jsx)(h.Fragment,{}),m?.length?(0,h.jsx)(h.Fragment,{children:Array.from({length:m?.length||0},((e,a)=>"#SAMPLE-CLICK-TRACKING#"===m?.[a]?.parameters?.[0]?.text?(0,h.jsx)(h.Fragment,{}):(0,h.jsxs)(o.Grid,{item:!0,xs:12,className:t.bottomMargin,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{maxWidth:"18rem",overflow:"hidden"},children:1===m.length?`${m[a]?.parameters?.length||0} ${1===(m[a]?.parameters?.length||0)?"Button Parameter":"Button Parameters"}`:`Button #${a+1} - ${m[a]?.parameters?.length||0} ${1===(m[a]?.parameters?.length||0)?"Parameter":"Parameters"}`}),Array.from({length:m?.[a]?.parameters?.length||0},((e,t)=>(0,h.jsx)(o.Box,{my:1,children:(0,h.jsxs)(o.Grid,{container:!0,alignItems:"center",children:[(0,h.jsx)(o.Grid,{item:!0,xs:1,children:(0,h.jsx)(o.Typography,{variant:"h5",align:"start",children:t+1})}),(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsx)(Vr,{attributes:s,metaComponent:{idx:a,componentType:"BUTTON"},parameters:m?.[a]?.parameters?.map((e=>e[e.type])),name:t,handleParamInput:S,fallbackParameters:m?.[a]?.parameters?.map((e=>e.fallbackText)),handleFallbackParamInput:v})})]})},`card-body-${a}-${t}`)))]})))}):(0,h.jsx)(h.Fragment,{})]})})),el=-180,tl=e=>{if(null==e||""===e)return null;const t=Number(e);return Number.isNaN(t)?"Latitude must be a number between -90 and 90.":t<-90||t>90?"Latitude must be between -90 and 90.":null},al=e=>{if(null==e||""===e)return null;const t=Number(e);return Number.isNaN(t)?"Longitude must be a number between -180 and 180.":t<el||t>180?"Longitude must be between -180 and 180.":null},nl=e=>{switch(e){case"IMAGE":return"Size < 5MB, Accepted formats - .png or .jpeg";case"VIDEO":return"Size < 16MB, Accepted formats - .mp4";case"FILE":return"Size < 100MB, Accepted formats - .pdf, .DOCX & .XLSX";case"AUDIO":return"Size < 16MB, Accepted formats - .mp3";default:return""}},sl=(0,o.withStyles)((e=>({bottomMargin:{marginBottom:e.spacing(3),"& .ClickToAction-arrowTop-316":{bottom:-80}},textFieldRoot:{padding:"0",width:"100%",border:"none",outline:"none",fontWeight:500,fontSize:"15px",boxShadow:"none",borderRadius:"8px",boxSizing:"border-box",fontFamily:"Roboto, sans-serif",backgroundColor:"rgb(240,240,240)"}})))((e=>{const{media:t,classes:a,onMediaSelect:s,selectedTemplate:i,toggleMediaDialog:r,setLocationMessage:l,cards:c,setCards:p,carouselIndex:u,mediaCount:m,onLocationCoordValidityChange:g,mediaHeading:b,useInlineMediaUpload:y}=e,{type:x=""}=i||{}
1,[f,A]=(0,n.useState)(null),[I,C]=(0,n.useState)(null),[_,S]=(0,n.useState)(null),v="LOCATION"===x?e.payload||t:{};(0,n.useEffect)((()=>{if("LOCATION"!==x||!g)return;const e=tl(v?.latitude),t=al(v?.longitude);C(e),S(t),g(!(!e&&!t))}),[x,v?.latitude,v?.longitude]);const E=e=>{const{name:a,value:n}=e.target;if("publicUrl"===a&&(n&&!(e=>{if(!e||"string"!=typeof e)return!1;try{const t=e.trim(),a=new URL(t);return"http:"===a.protocol||"https:"===a.protocol}catch(e){return!1}})(n)?A("Invalid URL"):A(null)),"LOCATION"===x&&("latitude"===a||"longitude"===a)){const e=tl("latitude"===a?n:v?.latitude),t=al("longitude"===a?n:v?.longitude);C(e),S(t),g&&g(!(!e&&!t))}const o={[a]:n};if("LOCATION"===x)l&&l(o);else if("CAROUSEL"===x){const e=JSON.parse(JSON.stringify(c)),t=e?.[u]?.components?.find((e=>{let{type:t}=e;return"HEADER"===t})),a=t.parameters[0].type;t.parameters[0][a].link=n,p(e)}else{const e={...t,...o};s(e)}},T=()=>{let e=t.url||"";const a=c?.[u]?.components?.find((e=>{let{type:t}=e;return"HEADER"===t}));if(a){const t=a.parameters[0].type;e=a.parameters[0][t].link}return e},D=i.headerType||x;return(0,h.jsx)(o.Grid,{item:!0,xs:12,children:["TEXT","LOCATION","ORDER_DETAILS"].includes(D)?"LOCATION"===x&&(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Location"}),(0,h.jsx)(o.Typography,{gutterBottom:!0,variant:"body2",color:"textSecondary",style:{maxWidth:"18rem",overflow:"hidden"},children:"Fill in the latitude, longitude, name, and address fields to send location message"}),(0,h.jsx)(o.Grid,{item:!0,xs:12,style:{position:"relative"},children:(0,h.jsxs)(o.Grid,{alignItems:"center",children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,style:{marginBottom:8},children:[(0,h.jsx)(o.TextField,{multiline:!0,name:"latitude",variant:"outlined",onChange:E,placeholder:"Latitude",value:v?.latitude??"",classes:{root:a.textFieldRoot}}),(0,h.jsx)(o.Box,{style:{minHeight:18},children:I&&(0,h.jsx)(o.Typography,{variant:"body2",color:"error",children:I})})]}),(0,h.jsxs)(o.Grid,{item:!0,xs:12,style:{marginBottom:8},children:[(0,h.jsx)(o.TextField,{multiline:!0,name:"longitude",variant:"outlined",onChange:E,placeholder:"Longitude",value:v?.longitude??"",classes:{root:a.textFieldRoot}}),(0,h.jsx)(o.Box,{style:{minHeight:18},children:_&&(0,h.jsx)(o.Typography,{variant:"body2",color:"error",children:_})})]}),(0,h.jsxs)(o.Grid,{item:!0,xs:12,style:{marginBottom:8},children:[(0,h.jsx)(o.TextField,{multiline:!0,variant:"outlined",name:"locationName",onChange:E,placeholder:"Location Name",classes:{root:a.textFieldRoot},value:v?.locationName??""}),(0,h.jsx)(o.Box,{style:{minHeight:18}})]}),(0,h.jsxs)(o.Grid,{item:!0,xs:12,style:{marginBottom:8},children:[(0,h.jsx)(o.TextField,{multiline:!0,name:"address",variant:"outlined",onChange:E,placeholder:" Location Address",value:v?.address??"",classes:{root:a.textFieldRoot}}),(0,h.jsx)(o.Box,{style:{minHeight:18}})]})]})})]}):(0,h.jsxs)(o.Box,{children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,className:a.bottomMargin,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,style:b?{marginTop:16,color:"rgba(0, 0, 0, 0.7)"}:void 0,children:b||("number"==typeof m&&m>0?`${m} Media`:"Media")}),(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,color:"textSecondary",children:nl(D)}),y?(0,h.jsxs)(o.Grid,{container:!0,spacing:1,alignItems:"stretch",children:[(0,h.jsx)(o.Grid,{item:!0,xs:12,md:5,children:(0,h.jsx)(o.TextField,{fullWidth:!0,name:"publicUrl",variant:"outlined",onChange:E,placeholder:"Media Url",value:T(),classes:{root:a.textFieldRoot},error:!!f,helperText:f})}),(0,h.jsx)(o.Grid,{item:!0,xs:12,md:1,style:{display:"flex",alignItems:"center",justifyContent:"center"},children:(0,h.jsx)(o.Typography,{color:"textSecondary",variant:"body1",children:"OR"})}),(0,h.jsx)(o.Grid,{item:!0,xs:12,md:6,children:(0,h.jsx)(o.Button,{fullWidth:!0,size:"small",color:"primary",variant:"contained",onClick:r,startIcon:(0,h.jsx)(d.PermMediaOutlined,{}),style:{height:"100%"},children:"Upload"})})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.TextField,{name:"publicUrl",variant:"outlined",onChange:E,placeholder:"Media Url",value:T(),classes:{root:a.textFieldRoot},error:!!f,helperText:f}),(0,h.jsxs)(o.Grid,{container:!0,spacing:1,alignItems:"center",style:{textAlign:"center",marginTop:8},children:[(0,h.jsx)(o.Grid,{item:!0,xs:2,children:(0,h.jsx)(o.Typography,{color:"textSecondary",variant:"body1",children:"OR"})}),(0,h.jsx)(o.Grid,{item:!0,xs:10,children:(0,h.jsx)(o.Button,{fullWidth:!0,size:"small",color:"primary",variant:"contained",onClick:r,startIcon:(0,h.jsx)(d.PermMediaOutlined,{}),children:"Upload from Media Library"})})]})]})]}),"FILE"===D&&(0,h.jsxs)(o.Grid,{item:!0,xs:12,className:a.bottomMargin,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"File Name"}),(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,color:"textSecondary",children:"Display name of media file, visible on download."}),(0,h.jsx)(o.TextField,{name:"filename",variant:"outlined",onChange:E,value:t.filename||"",placeholder:"Display file name",classes:{root:a.textFieldRoot}})]})]})})})),ol=-180,il=e=>{if(null==e||""===e)return null;const t=Number(e);return Number.isNaN(t)?"Latitude must be a number between -90 and 90.":t<-90||t>90?"Latitude must be between -90 and 90.":null},rl=e=>{if(null==e||""===e)return null;const t=Number(e);return Number.isNaN(t)?"Longitude must be a number between -180 and 180.":t<ol||t>180?"Longitude must be between -180 and 180.":null},ll=e=>{switch(e){case"IMAGE":return"Size < 5MB, Accepted formats - .png or .jpeg";case"VIDEO":return"Size < 16MB, Accepted formats - .mp4";case"FILE":return"Size < 100MB, Accepted formats - .pdf, .DOCX & .XLSX";case"AUDIO":return"Size < 16MB, Accepted formats - .mp3";default:return""}},dl=(0,o.withStyles)((e=>({textFieldRoot:{padding:"0",width:"100%",border:"none",outline:"none",fontWeight:500,fontSize:"15px",boxShadow:"none",borderRadius:"8px",boxSizing:"border-box",fontFamily:"Roboto, sans-serif",backgroundColor:"rgb(240,240,240)"},bottomMargin:{marginBottom:e.spacing(3),"& .ClickToAction-arrowTop-316":{bottom:-80}}})))((e=>{const{media:t,classes:a,showguide:s,carouselIndex:i,onMediaSelect:r,selectedTemplate:l,templateParamList:c,toggleMediaDialog:p,setLocationMessage:u,oldHandleParamInput:m,cards:g,setCards:b,buttons:y,setButtons:x,limitedTimeOffer:f,setLimitedTimeOffer:A,handlePaymentParam
1s:I,paymentParams:C,onLocationCoordValidityChange:_}=e,{type:S="",parameters:v,category:E}=l||{},[T,D]=(0,n.useState)(null),[w,N]=(0,n.useState)(null),j="LOCATION"===S?t:e.payload;(0,n.useEffect)((()=>{if("LOCATION"!==S||!_)return;const e=il(j?.latitude),t=rl(j?.longitude);D(e),N(t),_(!(!e&&!t))}),[S,j?.latitude,j?.longitude]);const k=g?.[i]?.components?.find((e=>"BODY"===e.type))?.parameters?.map((e=>{let{text:t}=e;return t})),L=g?.[i]?.components?.filter((e=>"BUTTON"===e.type&&"URL"===e.sub_type)),R=e=>{const{name:a,value:n}=e.target,s={[a]:n};if("LOCATION"===S){if("latitude"===a||"longitude"===a){const e=il("latitude"===a?n:j?.latitude),t=rl("longitude"===a?n:j?.longitude);D(e),N(t),_&&_(!(!e&&!t))}u&&u(s)}else{t.publicUrl=t.url;const e={...t,...s};r(e)}},B=function(e,t,a){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;const{value:s}=e.target,o=JSON.parse(JSON.stringify(g)),r=o?.[i]?.components?.filter((e=>{let{type:t,sub_type:n}=e;return"BUTTON"!==t?t===a:t===a&&"URL"===n}));if("HEADER"===a){const e=r[n].parameters[0].type;r[n].parameters[0][e].link=s}else r[n].parameters[t].text=s;b(o)};return(0,h.jsxs)(o.Box,{px:2,pt:1,children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,style:{position:"relative"},children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,style:{top:"-32px",left:"32px",position:"absolute"},children:"Parameters"}),s&&(0,h.jsxs)(o.Typography,{variant:"body2",color:"textSecondary",children:["You can personalize messages with - $FirstName, $Name, $MobileNumber, $LastName ",(0,h.jsx)("br",{}),"You can also use your custom attributes - $my_custom_attribute_name."]}),(0,h.jsx)(o.Grid,{container:!0,spacing:1,children:Array.from({length:v},((e,t)=>(0,h.jsxs)(o.Grid,{item:!0,style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)(o.Grid,{style:{marginBottom:8},children:(0,h.jsx)(o.Typography,{variant:"h5",align:"center",children:`{{${t+1}}}`})}),(0,h.jsx)(o.Grid,{style:{marginBottom:8,marginLeft:"1rem"},children:(0,h.jsx)(o.TextField,{name:t,variant:"outlined",placeholder:"value",value:c[t],classes:{root:a.textFieldRoot},onChange:e=>m(e,t)})})]},t)))})]}),"ORDER_DETAILS"===l.type&&(0,h.jsxs)(o.Grid,{item:!0,xs:12,className:a.bottomMargin,spacing:1,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Payment Parameters"}),(0,h.jsxs)(o.Typography,{variant:"body2",color:"textSecondary",style:{maxWidth:"18rem",overflow:"hidden"},children:["You can set payment details messages. ",(0,h.jsx)("br",{}),!1]}),(0,h.jsx)(o.Box,{style:{display:"flex",gap:"20px"},children:[{label:"Product Name",key:"productName",width:"40%"},{label:"Quantity",key:"quantity",width:"30%"},{label:"Amount",key:"amount",width:"30%"}].map(((e,t)=>(0,h.jsx)(o.Box,{my:1,width:e.width,children:(0,h.jsxs)(o.Grid,{container:!0,alignItems:"center",children:[!1,(0,h.jsx)(o.TextField,{name:"name",style:{width:"100%"},value:C[e.key],onChange:t=>I({key:e.key,value:t.target.value}),placeholder:e.label})]})},t+"attr")))})]}),(0,h.jsx)(o.Box,{mt:6}),"CAROUSEL"===S&&(0,h.jsxs)(o.Grid,{item:!0,xs:12,style:{position:"relative"},children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,style:{top:"-32px",position:"absolute"},children:"Carousel Card #"+(i+1)+" Parameters"}),k?.length&&(0,h.jsxs)(o.Grid,{item:!0,xs:12,className:a.bottomMargin,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{maxWidth:"18rem",overflow:"hidden"},children:"Body Parameters"}),Array.from({length:k.length},((e,t)=>(0,h.jsxs)(o.Grid,{item:!0,style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)(o.Grid,{item:!0,style:{marginBottom:8},children:(0,h.jsx)(o.Typography,{variant:"h5",align:"center",children:`{{${t+1}}}`})}),(0,h.jsx)(o.Grid,{style:{marginBottom:8,marginLeft:"1rem"},children:(0,h.jsx)(o.TextField,{variant:"outlined",name:t,placeholder:"value",value:k[t],classes:{root:a.textFieldRoot},onChange:e=>B(e,t,"BODY")})})]},t)))]}),L?.length?(0,h.jsx)(h.Fragment,{children:Array.from({length:L?.length},((e,t)=>"#SAMPLE-CLICK-TRACKING#"===L[t]?.parameters?.[0]?.text?(0,h.jsx)(h.Fragment,{}):(0,h.jsxs)(o.Grid,{item:!0,xs:12,className:a.bottomMargin,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{maxWidth:"18rem",overflow:"hidden"},children:1===y.length?"Button Parameters":`Button #${t+1} Parameters`}),Array.from({length:L[t]?.parameters?.length||0},((e,n)=>(0,h.jsxs)(o.Grid,{item:!0,style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)(o.Grid,{item:!0,style:{marginBottom:8},children:(0,h.jsx)(o.Typography,{variant:"h5",align:"center",children:`{{${n+1}}}`})}),(0,h.jsx)(o.Grid,{style:{marginBottom:8,marginLeft:"1rem"},children:(0,h.jsx)(o.TextField,{variant:"outlined",name:n,placeholder:"value",value:L[t].parameters[n].text,classes:{root:a.textFieldRoot},onChange:e=>B(e,n,"BUTTON",t)})})]},n)))]})))}):(0,h.jsx)(h.Fragment,{})]}),"LIMITED_TIME_OFFER"===l.type&&f?.parameters?.length&&(0,h.jsxs)(o.Grid,{item:!0,xs:12,className:a.bottomMargin,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Limited Time Offer Parameters"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{maxWidth:"18rem",overflow:"hidden"},children:"Select the expiration date for this offer"}),(0,h.jsx)($r,{classes:a,limitedTimeOffer:f,setLimitedTimeOffer:A})]}),y?.length?(0,h.jsx)(h.Fragment,{children:Array.from({length:y.length},((e,t)=>"#SAMPLE-CLICK-TRACKING#"===y?.[t]?.parameters?.[0]?.text?(0,h.jsx)(h.Fragment,{}):(0,h.jsxs)(o.Grid,{item:!0,xs:12,className:a.bottomMargin,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{maxWidth:"18rem",overflow:"hidden"},children:1===y.length?"Button Parameters":`Button #${t+1} Parameters`}),Array.from({length:y?.[t]?.parameters?.length||0},((e,n)=>{const s=y[t].parameters[n].type;return(0,h.jsxs)(o.Grid,{item:!0,style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)(o.Grid,{item:!0,style:{marginBottom:8},children:(0,h.jsx)(o.Typography,{variant:"h5",align:"center",children:`{{${n+1}}}`})}),(0,h.jsx)(o.Grid,{style:{marginBottom:8,marginLeft:"1rem"},children:(0,h.jsx)(o.TextField,{variant:"outlined",name:n,placeholder:"value",value:y[t].parameters[n][s],classes:{root:a.textFieldRoot},onChange:e=>((e,t,a)=>{const{value:n}=e.target,s=JSON.parse(JSON.stringify(y));let o=s[t].parameters[a].type;"AUTHENTICATION"===E&&"COPY_CODE"===s[t].sub_type&&(s[t].sub_type="URL",s[t].parameters[a].type="text",delete s[t].parameters[a].coupon_code,o="text"),s[t].parameters[a][o]=n,x(s)})(e,t,n)})})]},n)}))]})))}):(0,h.jsx)(h.Fragment,{}),(0,h.jsx)(o.Grid,{item:!0,xs:12,children:["TEXT","LOCATION","ORDER_DETAILS"].includes(S)?"LOCATION"===S&&(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Location"}),(0,h.jsx)(o.Typography,{gutterBottom:!0,variant:"body2",color:"textSecondary",style:{maxWidth:"18rem",overflow:"hidden"},children:"Fill in the latitude, longitude, name, and address fields to send location message"}),(0,h.jsx)(o.Grid,{item:!0,style:{position:"relative"},children:(0,h.jsxs)(o.Grid,{alignItems:"center",children:[(0,h.jsxs)(o.Grid,{item:!0,style:{marginBottom:8},children:[(0,h.jsx)(o.TextField,{multiline:!0,name:"latitude",variant:"outlined",onChange:R,placeholder:"Latitude",value:j?.latitude??"",classes:{root:a.textFieldRoot}}),(0,h.jsx)(o.Box,{style:{minHeight:18},children:T&&(0,h.jsx)(o.Typography,{variant:"body2",color:"error",children:T})})]}),(0,h.jsxs)(o.Grid,{item:!0,style:{marginBottom:8},children:[(0,h.jsx)(o.TextField,{multiline:!0,name:"longitude",variant:"outlined",onChange:R,placeholder:"Longitude",value:j?.longitude??"",classes:{root:a.textFieldRoot}}),(0,h.jsx)(o.Box,{style:{minHeight:18},children:w&&(0,h.jsx)(o.Typography,{variant:"body2",color:"error",children:w})})]}),(0,h.jsxs)(o.Grid,{item:!0,style:{marginBottom:8},children:[(0,h.jsx)(o.TextField,{multiline:!0,variant:"outlined",name:"locationName",onChange:R,placeholder:"Location Name",classes:{root:a.textFieldRoot},value:j?.locationName??""}),(0,h.jsx)(o.Box,{style:{minHeight:18}})]}),(0,h.jsxs)(o.Grid,{item:!0,style:{marginBottom:8},children:[(0,h.jsx)(o.TextField,{multiline:!0,name:"address",variant:"outlined",onChange:R,placeholder:" Location Address",value:j?.address??"",classes:{root:a.textFieldRoot}}),(0,h.jsx)(o.Box,{style:{minHeight:18}})]})]})})]}):(0,h.jsxs)(o.Box,{children:[(0,h.jsxs)(o.Grid,{item:!0,xs:6,className:a.bottomMargin,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Media"}),(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,color:"textSecondary",children:ll(S)}),(0,h.jsx)(o.TextField,{name:"publicUrl",variant:"outlined",onChange:e=>{"CAROUSEL"!==S?R(e):B(e,null,"HEADER")},placeholder:"Media Url",value:(()=>{let e=t.url||"";const a=g?.[i]?.components?.find((e=>{let{type:t}=e;return"HEADER"===t}));if(a){const t=a.parameters[0].type;e=a.parameters[0][t].link}return e})(),classes:{root:a.textFieldRoot}}),(0,h.jsxs)(o.Grid,{container:!0,spacing:4,alignItems:"center",style:{textAlign:"center",marginTop:8,display:"flex"},children:[(0,h.jsx)(o.Grid,{item:!0,children:(0,h.jsx)(o.Typography,{color:"textSecondary",variant:"body1",children:"OR"})}),(0,h.jsx)(o.Grid,{item:!0,xs:10,children:(0,h.jsx)(o.Button,{fullWidth:!0,size:"small",color:"primary",variant:"contained",onClick:p,startIcon:(0,h.jsx)(d.PermMediaOutlined,{}),children:"Upload from Media Library"})})]})]}),"CAROUSEL"!==S&&(0,h.jsxs)(o.Grid,{item:!0,xs:6,className:a.bottomMargin,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"File Name"}),(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,color:"textSecondary",children:"Display name of media file, visible on download."}),(0,h.jsx)(o.TextField,{name:"fileName",variant:"outlined",onChange:R,value:t.filename||"",placeholder:"Display file name",classes:{root:a.textFieldRoot}})]})]})})]})})),cl=e=>{const{topicName:t,showguide:a,oldTextParameters:n,templateParamList:s,oldHandleParamInput:i,selectedTemplate:r,attributes:l,parameters:d,fallbackParameters:c,setTemplateMessage:p,carouselIndex:u,cards:m,setCards:g,media:b,payload:y,onMediaSelect:x,toggleMediaDialog:f,setLocationMessage:A,onLocationCoordValidityChange:I,buttons:C,setButtons:_,handlePaymentParam
1s:S,paymentParams:v,limitedTimeOffer:E,setLimitedTimeOffer:T,mediaCount:D,mediaHeading:w,beforeMediaContent:N,useInlineMediaUpload:j}=e,{name:k=""}=r||{};return k?(0,h.jsx)(o.Box,{children:n?(0,h.jsx)(o.Box,{children:(0,h.jsx)(dl,{media:b,showguide:a,carouselIndex:u,cards:m,setCards:g,buttons:C,setButtons:_,limitedTimeOffer:E,setLimitedTimeOffer:T,onMediaSelect:x,selectedTemplate:r,templateParamList:s,toggleMediaDialog:f,setLocationMessage:A,onLocationCoordValidityChange:I,oldHandleParamInput:i,handlePaymentParams:S,paymentParams:v})}):(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(Qr,{topicName:t,attributes:l,parameters:d,carouselIndex:u,cards:m,setCards:g,buttons:C,setButtons:_,limitedTimeOffer:E,setLimitedTimeOffer:T,selectedTemplate:r,fallbackParameters:c,setTemplateMessage:p,handlePaymentParams:S,paymentParams:v}),N,(0,h.jsx)(sl,{media:b,payload:y,onMediaSelect:x,selectedTemplate:r,toggleMediaDialog:f,setLocationMessage:A,onLocationCoordValidityChange:I,cards:m,setCards:g,carouselIndex:u,mediaCount:D,mediaHeading:w,useInlineMediaUpload:j})]})}):null};function pl(e){if(e.length>1024)return{valid:!1,msg:"Template format length over 1024 characters."};if(e.split("\n").map((e=>e.trim())).join("\n").includes("\n\n\n"))return{valid:!1,msg:"Consecutive empty lines not allowed in template format"};if(!function(e){const t=ul(e).length;return e.replace(/\s+/g," ").split(" ").length-t>=2*t+1}(e))return{valid:!1,msg:"This template contains too many variable parameters relative to the message length. You need to decrease the number of parameters or increase your message word count."};const t=e.replace(/\{\{[0-9]+\}\}/g,(e=>e.substring(2,e.length-2)));if(!!/(\{|\})/g.test(t))return{valid:!1,msg:"Extra curly braces found in template format"};return!/(\[|\])/g.test(t)?{valid:!0,msg:"Format seems legit."}:{valid:!1,msg:"'[' or ']' aren't allowed in template format."}}function ul(e){const t=[];e.replace(/\{\{[0-9]+\}\}/g,(function(e){t.push(e.substring(2,e.length-2))}));return t}function ml(e){if(!e||"string"!=typeof e)return!1;try{const t=/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i,a=encodeURI(e);return t.test(a)}catch(e){return!1}}const hl=e=>{const t=/^(?!\s*$).{0,25}$/,a=e?.length||0;if(!a)return{valid:!0,msg:"No buttons found!"};if(a>10)return{valid:!1,msg:"Maximum 10 buttons allowed!"};const n={URL:{count:0,maxCount:2},PHONE_NUMBER:{count:0,maxCount:1},QUICK_REPLY:{count:0,maxCount:10}};if(a<=2)for(const t of e)n[t.type].count++;if(a>2){let t=e[0].type;n[t].count++;for(let s=1;s<a-1;s++){const a=e[s].type,o=e[s+1].type;if("QUICK_REPLY"===t&&"QUICK_REPLY"!==a&&"QUICK_REPLY"===o)return{valid:!1,msg:"Invalid Button Combination!"};n[a].count++,t=a}n[a-1].count++}for(const e in n)if(n[e].count>n[e].maxCount)return{valid:!1,msg:`${e} button count is more than ${n[e].maxCount}`};for(const a of e){const{type:e,text:n,url:s,example:o}=a;if("URL"===e){if(!ml(s))return{valid:!1,msg:"Invalid Card Media URL"};const e=ul(s);if(e?.length&&!o?.length)return{valid:!1,msg:"Missing Card URL Button Params Sample Value"}}if("PHONE_NUMBER"===e){const e=/^\d+$/,t=a.extension+a.number;if(!e.test(t))return{valid:!1,msg:"Invalid Phone Number Format"}}if(!n||!t.test(n))return{valid:!1,msg:`Invalid Card ${e} Text`}}return{valid:!0,msg:"Buttons seems legit"}},gl={compareFormatAndSample:function(e,t,a){const n=e.replace(/\{\{[0-9]+\}\}/g,(e=>"")),s=t.replace(/\[([^\]]+)\]/g,(e=>""));return a&&(e.match(/\{\{[0-9]+\}\}/g)||[]).some(((e,t)=>e!==`{{${t+1}}}`))?{valid:!1,msg:"Invalid parameter ordering"}:n===s?{valid:!0,msg:"Format seems legit."}:{valid:!1,msg:"Sample message doesn't match with template format"}},extractParameters:ul,validateFormat:pl,validateUrl:ml,validateTemplateButtons:hl,validateCarouselTemplate:e=>{const{carouselTemplates:t,buttons:a}=e;if(a.length>2)return{valid:!1,msg:"Max 2 buttons allowed"};const n=hl(a);if(!n.valid)return n;const s=t.some((e=>e.templateFooter));for(const e of t){const{templateFooter:t}=e;if(!t&&s)return{valid:!1,msg:"Template body is required for all cards"};const a=pl(t);
1if(!a.valid)return a}return{valid:!0,msg:"Carousel format seems legit."}},validateLimitedTimeOffer:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return!e.text||e.text.length>16?{valid:!1,msg:"Please provide Limited Time Offer Text upto 16 characters!"}:"MARKETING"!==t?{valid:!1,msg:"Limited Time Offer Templates can only have MARKETING as their category!"}:e.has_expiration&&!a.find((e=>{let{subType:t}=e;return"COUPON_CODE"===t}))?{valid:!1,msg:"Coupon Code button is mandatory when offer expiration is enabled!"}:{valid:!0,msg:"No errors found!"}},formatToSendableLimitedTimeOfferFormat:e=>{if(!e?.has_expiration)return;return{type:"limited_time_offer",parameters:[{type:"limited_time_offer",limited_time_offer:{expiration_time_ms:Date.now()+36e5}}]}},validateAuthenticationTemplate:function(e,t,a){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];return 1!==n.filter((e=>{let{type:t}=e;return"COPY_CODE"===t})).length&&1!==n.length?{valid:!1,msg:"Exactly one Copy Code button is mandatory for authentication templates, with no other buttons!"}:"TEXT"!==e?{valid:!1,msg:"Authentication templates can only have TEXT as their template type!"}:t&&(isNaN(t)||t<1||t>90)?{valid:!1,msg:"Expiration warning should be between 1 to 90 minutes!"}:{valid:!0,msg:"No errors found!"}}},bl=e=>{const{components:t}=e||{},a=t?.find((e=>"HEADER"===e.type));if(!a)return null;const n=a.format.toLowerCase();return{type:"HEADER",parameters:[{type:n,[n]:{link:""}}]}},yl=e=>{const{components:t}=e||{},a=t?.find((e=>"BODY"===e.type));if(!a)return null;if(!a.example?.body_text?.[0]?.length)return;return{type:"BODY",parameters:a.example.body_text[0].map((e=>({type:"TEXT",text:""})))}},xl=(e,t)=>{const{components:a}=e||{},n=a?.find((e=>"BUTTONS"===e.type))?.buttons;if(!n)return[];const s=[];for(let e=0;e<n.length;e++){const{example:a,type:o,urlMetadata:i,url:r}=n[e],l=[];["quick_reply","QUICK_REPLY"].includes(o)&&l.push({type:"payload",payload:JSON.stringify({cardIndex:t,buttonIndex:e})});for(const e of a||[])l.push({type:"text",text:""});if(l.length){const t={type:"BUTTON",sub_type:o,index:e,parameters:l};if(["url","URL"].includes(o)){gl.extractParameters(i?.url||r).length||(t.parameters=[{type:"text",text:"#SAMPLE-CLICK-TRACKING#"}])}s.push(t)}}return s},fl=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const t=[];let a=!0;for(const t of e){const{components:e}=t||{},n=e?.find((e=>"BODY"===e.type));if(n&&n.example?.body_text?.[0]?.length>0){a=!1;break}}for(let n=0;n<e.length;n++){const s=bl(e[n]);if(null===s)return{valid:!1,msg:"Header is missing!"};const o=yl(e[n]);if(null===o&&!a)return{valid:!1,msg:"Body is missing!"};const i=[s,...xl(e[n],n)];o&&i.push(o),t.push({card_index:n,components:i})}return t},Al=e=>"MARKETING"===e?.category,Il=(0,_e.makeStyles)((()=>({tooltip:{background:"#FFFFFF",color:"#111827",padding:"12px 14px",borderRadius:8,maxWidth:280,boxSh
1adow:"0 6px 18px rgba(0,0,0,0.18)",border:"1px solid rgba(0,0,0,0.06)"},arrow:{color:"#FFFFFF","&::before":{border:"1px solid rgba(0,0,0,0.06)"}},header:{display:"flex",alignItems:"center",gap:8,marginBottom:6},icon:{fontSize:18,color:"#F59E0B",marginRight:6},title:{fontWeight:600,fontSize:13,lineHeight:"18px",color:"#111827"},body:{fontSize:12,lineHeight:"17px",color:"#4B5563",marginBottom:12},blockedWrapper:{display:"block",width:"100%",maxWidth:"100%",boxSizing:"border-box",overflow:"hidden",cursor:"not-allowed",opacity:.6,pointerEvents:"auto"}}))),Cl=e=>{e.preventDefault(),e.stopPropagation()},_l={modifiers:{flip:{enabled:!1},preventOverflow:{enabled:!1,boundariesElement:"viewport"}},style:{zIndex:1500}},Sl=e=>{let{onClickHere:t,classes:a}=e;return(0,h.jsxs)(o.Box,{children:[(0,h.jsxs)(o.Box,{className:a.header,children:[(0,h.jsx)(d.LockOutlined,{className:a.icon}),(0,h.jsx)(o.Typography,{className:a.title,children:"Marketing messaging is disabled"})]}),(0,h.jsx)(o.Typography,{className:a.body,children:"You have opted out from marketing messaging, please opt in to use this template."}),(0,h.jsx)(o.Button,{variant:"contained",color:"primary",size:"small",onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},children:"Enable Marketing"})]})},vl=e=>{let{show:t,children:a,placement:n,onClickHere:s}=e;const i=Il();return t?(0,h.jsx)(o.Tooltip,{arrow:!0,interactive:!0,placement:n,enterDelay:400,leaveDelay:0,enterTouchDelay:0,TransitionProps:{timeout:0},title:(0,h.jsx)(Sl,{onClickHere:s,classes:i}),PopperProps:_l,classes:{tooltip:i.tooltip,arrow:i.arrow},children:(0,h.jsx)("span",{className:i.blockedWrapper,onClick:Cl,onMouseDown:Cl,children:a})}):a};class El extends s().Component{handleClickHere=()=>{const{projectId:e,history:t}=this.props;e&&t&&t.push((e=>`/projects/${e}/manage/optout?highlight=marketing-optin`)(e))};render(){const{show:e,children:t,placement:a="top"}=this.props;return(0,h.jsx)(vl,{show:e,placement:a,onClickHere:this.handleClickHere,children:t})}}class Tl extends n.Component{constructor(e){super(e),this.state={automationEnabled:!1,automationTemplateName:"",automationCampaignName:"",automationPhoneField:"phone",automationNameField:"full_name",templates:[],isLoadingTemplates:!1,selectedTemplate:null,parameters:[],fallbackParameters:{},media:{},cards:[],carouselIndex:0,existingCampaigns:[],isLoadingCampaigns:!1,selectedCampaignName:"",newCampaignExpanded:!1,mediaLibraryOpen:!1,hoveredTemplate:null,templateSearchInput:"",campaignSearchInput:""},this.hoverTimeout=null,this.lastEmittedAutomation=null}componentDidMount(){const e=this.props.automation;e&&this.loadAutomationState(e),this.props.assistantId&&(this.fetchTemplates(),this.fetchExistingCampaigns()),this.props.onGetConfigRef&&this.props.onGetConfigRef(this.getAutomationConfig),this.updatePreviewData()}componentWillUnmount(){this.hoverTimeout&&clearTimeout(this.hoverTimeout)}componentDidUpdate(e,t){const a=this.props.automation,n=e.automation,s=null!==a&&a===this.lastEmittedAutomation;a===n||s||(a&&(a.enabled||a.templateName)?this.loadAutomationState(a):a||this.setState({automationEnabled:!1,automationTemplateName:"",automationCampaignName:"",selectedTemplate:null,parameters:[],fallbackParameters:{},media:{},cards:[],carouselIndex:0},(()=>{this.updatePreviewData()}))),this.props.assistantId&&this.props.assistantId!==e.assistantId&&(this.fetchTemplates(),this.fetchExistingCampaigns()),this.props.onGetConfigRef&&this.props.onGetConfigRef!==e.onGetConfigRef&&this.props.onGetConfigRef(this.getAutomationConfig),t.selectedTemplate===this.state.selectedTemplate&&t.parameters===this.state.parameters&&t.media===this.state.media&&t.cards===this.state.cards&&t.carouselIndex===this.state.carouselIndex||this.updatePreviewData()}fetchExistingCampaigns=async()=>{const e=this.props.assistantId||this.props.assistantDetails?.assistantId||this.props.connectProps?.assistantId;if(e){this.setState({isLoadingCampaigns:!0});try{const t=await this.props.fetchApiCampaigns(e);t&&Array.isArray(t)&&this.setState({existingCampaigns:t})}catch(e){console.error("Error fetching existing campaigns:",e)}finally{this.setState({isLoadingCampaigns:!1})}}else console.log("Missing assistantId, skipping campaigns fetch")};loadAutomationState=e=>{let t=[],a={};e.fallbackParameters&&"object"==typeof e.fallbackParameters&&Object.entries(e.fallbackParameters).forEac
1h((e=>{let[t,n]=e;a[`$${t}`]=n||""})),e.templateParameters&&e.templateParameters.length>0&&(t=e.templateParameters.map((e=>"field"===e.type?`$${e.fieldKey||""}`:"custom"===e.type&&e.value||"")));const n=e.campaignName||"",s=this.state.existingCampaigns.find((e=>e.name===n));let o={};e.media&&(o={url:e.media.url||"",publicUrl:e.media.url||"",filename:e.media.filename||""});let i=[];e.cards&&Array.isArray(e.cards)&&e.cards.length>0&&(i=e.cards),this.setState({automationEnabled:e.enabled||!1,automationTemplateName:e.templateName||"",automationCampaignName:n,automationPhoneField:e.phoneField||"phone",automationNameField:e.nameField||"full_name",parameters:t,fallbackParameters:a,media:o,selectedCampaignName:s?n:"",newCampaignExpanded:!s&&!!n,cards:i,carouselIndex:0},(()=>{this.updatePreviewData()})),e.enabled&&e.templateName&&this.fetchTemplates().then((a=>{if(a&&a.length>0){const n=a.find((t=>t.name===e.templateName&&"APPROVED"===t.status?.toUpperCase()));if(n){let e=t;0===t.length&&n.parameters>0&&(e=Array.from({length:n.parameters},(()=>""))),this.setState({selectedTemplate:n,parameters:e},(()=>{this.updatePreviewData()}))}}}))};fetchTemplates=async()=>{const e=this.props.assistantId||this.props.assistantDetails?.assistantId||this.props.connectProps?.assistantId;if(!e)return console.log("Missing assistantId, skipping templates fetch"),Promise.resolve([]);this.setState({isLoadingTemplates:!0});try{const t=(await this.props.fetchTemplates(e)).filter((e=>!(!e||!e.name)&&"APPROVED"===e.status?.toUpperCase()));return this.setState({templates:t}),Promise.resolve(t)}catch(e){return console.error("Error fetching templates:",e),Promise.resolve([])}finally{this.setState({isLoadingTemplates:!1})}};handleAutomationToggle=e=>{this.setState({automationEnabled:e},(()=>{e&&this.fetchTemplates(),this.updateAutomationInParent()}))};handleTemplateSelect=e=>{if(!e)return void this.setState({automationTemplateName:"",automationCampaignName:"",selectedTemplate:null,parameters:[],fallbackParameters:{},media:{},selectedCampaignName:"",cards:[],carouselIndex:0},(()=>{this.updateAutomationInParent()}));const t=this.state.templates.find((t=>t.name===e&&"APPROVED"===t.status?.toUpperCase()));if(!t)return void console.warn(`Template "${e}" not found or not approved`);const a=t.parameters||0,n=Array.from({length:a},(()=>""));let s=[];"CAROUSEL"===t.type&&t.carouselCards?.length&&(s=fl(t.carouselCards)),this.setState({automationTemplateName:e,automationCampaignName:`LeadForm_${e}`,selectedTemplate:t,parameters:n,fallbackParameters:{},selectedCampaignName:"",media:{},cards:s,carouselIndex:0},(()=>{this.updatePreviewData(),this.updateAutomationInParent()}))};handleCampaignNameChange=e=>{this.setState({automationCampaignName:e.target.value},(()=>{this.updateAutomationInParent()}))};handleExistingCampaignSelect=e=>{if(!e)return void this.setState({selectedCampaignName:"",automationCampaignName:"",newCampaignExpanded:!1,automationTemplateName:"",selectedTemplate:null,parameters:[],fallbackParameters:{},media:{},cards:[],carouselIndex:0},(()=>{this.updateAutomationInParent()}));const t=this.state.existingCampaigns.find((t=>t.name===e));if(!t)return void this.setState({selectedCampaignName:"",automationCampaignName:"",newCampaignExpanded:!1,automationTemplateName:"",selectedTemplate:null,parameters:[],fallbackParameters:{},media:{},cards:[],carouselIndex:0},(()=>{this.updateAutomationInParent()}));const a=t.payload?.templateName;if(!a)return void this.setState({selectedCampaignName:e,automationCampaignName:e,newCampaignExpanded:!1,automationTemplateName:"",selectedTemplate:null,parameters:[],fallbackParameters:{},media:{},cards:[],carouselIndex:0},(()=>{this.updateAutomationInParent()}));const n=this.state.templates.find((e=>e.name===a&&"APPROVED"===e.status?.toUpperCase()));let s=[];if(t.payload?.templateParameters&&Array.isArray(t.payload.templateParameters))s=t.payload.templateParameters.map((e=>"field"===e.type?`$${e.fieldKey||""}`:"custom"===e.type&&e.value||""));else if(n){const e=n.parameters||0;s=Array.from({length:e},(()=>""))}let o={};t.payload?.media&&(o={url:t.payload.media.url||"",publicUrl:t.payload.media.url||"",filename:t.payload.media.filename||""});let i=[];t.payload?.cards&&Array.isArray(t.payload.cards)?i=t.payload.cards:n&&"CAROUSEL"===n.type&&n.carouselCards?.length&&(i=fl(n.carouselCards)),this.setState({selectedCampaignName:e,automationCampaignName:e,newCampaignExpanded:!1,automationTemplateName:a,selectedTemplate:n||null,parameters:s,fallbackParameters:{},media:o,cards:i,carouselIndex:0},(()=>{this.updatePreviewData(),this.updateAutomationInParent()}))};handleCreateNewCampaignClick=()=>{this.setState({newCampaignExpanded:!this.state.newCampaignExpanded,selectedCampaignName:"",automationCampaignName:"",automationTemplateName:"",selectedTemplate:null,parameters:[],fallbackParameters:{},media:{}})};toggleMediaDialog=()=>{va("mediaLibrary")&&this.setState({mediaLibraryOpen:!this.state.mediaLibraryOpen})};extractFilenameFromUrl=e=>{if(!e)return"media_file";try{const t=e.split("/");return(t[t.length-1]||"media_file").split("?")[0]||"media_file"}catch{return"media_file"}};onMediaSelect=e=>{const t=e?.publicUrl||e?.url||"",a={...e,filename:e?.filename||this.extractFilenameFromUrl(t)};if("CAROUSEL"===this.state.selectedTemplate?.type){const e=JSON.parse(JSON.stringify(this.state.cards||[])),a=e[this.state.carouselIndex];if(a){const n=a.components?.find((e=>"HEADER"===e.type));if(n&&n.parameters&&n.parameters.length>0){const a=n.parameters[0].type||n.format||"IMAGE",s=a.toLowerCase();return n.format=a,n.parameters[0][s]?n.parameters[0][s].link=t:n.parameters[0]={type:a,[s]:{link:t}},void this.setState({cards:e,mediaLibraryOpen:!1},(()=>{this.updateAutomationInParent(),this.updatePreviewData()}))}}}this.setState({media:a,mediaLibraryOpen:!1},(()=>{this.updateAutomationInParent(),this.updatePreviewData()}))};setCards=e=>{this.setState({cards:e},(()=>{this.updateAutomationInParent(),this.updatePreviewData()}))};
1setCarouselIndex=e=>{this.setState({carouselIndex:e})};getAllQuestions=()=>{const e=this.props.questions||this.props.parentState?.leadForm?.questions||[];return e&&0!==e.length?e.map((e=>({key:e.key||e.type?.toLowerCase(),type:e.type,label:e.label||e.type}))):[]};getLeadFormAttributes=()=>{const e=this.props.questions||this.props.parentState?.leadForm?.questions||[];return e&&0!==e.length?e.map((e=>({name:e.key||e.type}))):[]};setTemplateMessage=(e,t)=>{this.setState({[e]:t},(()=>{this.updateAutomationInParent()}))};getCarouselMediaCount=()=>{const{selectedTemplate:e,cards:t}=this.state;if(!e||"CAROUSEL"!==e.type)return;if(!t||!Array.isArray(t)||0===t.length)return 0;let a=0;return t.forEach((e=>{const t=e?.components?.find((e=>{let{type:t}=e;return"HEADER"===t}));if(t&&t.parameters&&t.parameters.length>0){const e=t.parameters[0],n=e.type||t.format,s=n?.toLowerCase(),o=s&&e[s]?.link||e.image?.link||e.video?.link||e.document?.link||e.audio?.link;o&&""!==String(o).trim()&&a++}})),a};getAutomationConfig=()=>{const{automationEnabled:e,automationTemplateName:t,automationCampaignName:a,automationPhoneField:n,automationNameField:s,parameters:o,fallbackParameters:i,selectedCampaignName:r,media:l,selectedTemplate:d,cards:c}=this.state;let p={enabled:!1};const u=e=>Object.entries(e||{}).reduce(((e,t)=>{let[a,n]=t;return e[a.startsWith("$")?a.substring(1):a]=n||"",e}),{}),m=e=>e.map((e=>{if("string"==typeof e&&e.startsWith("$")){return{type:"field",fieldKey:e.substring(1)}}return{type:"custom",value:e||""}}));if(e&&r){if(p={enabled:!0,campaignName:r,phoneField:n,nameField:s,fieldMappings:[],templateParameters:m(o),fallbackParameters:u(i)},t&&(p.templateName=t),l&&(l.url||l.publicUrl)){const e=l.publicUrl||l.url||"";p.media={url:e,filename:l.filename||this.extractFilenameFromUrl(e),fileType:d?.headerType||d?.type||"IMAGE"}}"CAROUSEL"===d?.type&&c&&c.length>0&&(p.cards=c)}else if(e&&t){if(p={enabled:!0,templateName:t,campaignName:a||`LeadForm_${t}`,phoneField:n,nameField:s,fieldMappings:[],templateParameters:m(o),fallbackParameters:u(i)},l&&(l.url||l.publicUrl)){const e=l.publicUrl||l.url||"";p.media={url:e,filename:l.filename||this.extractFilenameFromUrl(e),fileType:d?.headerType||d?.type||"IMAGE"}}"CAROUSEL"===d?.type&&c&&c.length>0&&(p.cards=c)}return p};updateAutomationInParent=()=>{const e=this.getAutomationConfig();this.lastEmittedAutomation=e,this.props.onChange?this.props.onChange(e):this.props.changeState&&this.props.changeState("leadFormAutomation",e),this.updatePreviewData()};updatePreviewData=()=>{if(this.props.onPreviewDataChange){let e=this.state.selectedTemplate;e&&"CAROUSEL"===e.type&&this.state.cards?.length>0&&(e={...e,carouselCards:this.state.cards}),this.props.onPreviewDataChange({selectedTemplate:e,parameters:this.state.parameters,media:this.state.media,cards:this.state.cards,carouselIndex:this.state.carouselIndex||0,isHoverPreview:!1})}};render(){const{classes:e}=this.props;if(this.props.hideIfNoForm&&(!this.props.questions||0===this.props.questions.length))return(0,h.jsx)(o.Box,{p:2,children:(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:"Please select a lead form in the Ad Creative section to configure automation."})});const t=this.state.selectedTemplate&&(this.state.newCampaignExpanded||this.state.selectedCampaignName);return(0,h.jsx)(o.Grid,{container:!0,spacing:2,children:(0,h.jsxs)(o.Grid,{item:!0,xs:12,children:[(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Switch,{checked:this.state.automationEnabled,onChange:e=>this.handleAutomationToggle(e.target.checked),color:"primary"}),label:(0,h.jsx)(o.Typography,{variant:"body2",children:"Enable Automation"}),style:{marginBottom:16}}),this.state.automationEnabled&&(0,h.jsx)(o.Box,{children:(0,h.jsxs)(o.Grid,{container:!0,spacing:2,alignItems:"flex-start",children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px"},children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,md:6,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:8},children:"Select Existing Campaign"}),this.state.isLoadingCampaigns?(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",children:[(0,h.jsx)(o.CircularProgress,{size:16}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{marginLeft:8}
1,children:"Loading campaigns..."})]}):(0,h.jsx)(O.Autocomplete,{clearOnEscape:!0,options:this.state.existingCampaigns.filter((e=>{const t=(this.state.campaignSearchInput||"").toLowerCase();return(e.name||"").toLowerCase().includes(t)})).slice(0,100).map((e=>e.name)),value:this.state.selectedCampaignName||null,onChange:(e,t,a)=>{"select-option"!==a&&"clear"!==a||(this.handleExistingCampaignSelect(t||""),this.setState({campaignSearchInput:""}))},onInputChange:(e,t,a)=>{"input"===a&&this.setState({campaignSearchInput:t})},popupIcon:(0,h.jsx)(d.SearchOutlined,{style:{fontSize:"20px"}}),renderInput:t=>(0,h.jsx)(o.TextField,{...t,fullWidth:!0,variant:"outlined",style:{marginTop:"0px !important"},classes:{root:e.TextFieldRoot},InputProps:{...t.InputProps,classes:{input:e.inputPadding}},placeholder:"Select an existing campaign"})})]}),(0,h.jsxs)(o.Grid,{item:!0,xs:12,md:6,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:8},children:"Or Create New Campaign"}),(0,h.jsx)(o.Button,{variant:"outlined",color:"primary",onClick:this.handleCreateNewCampaignClick,fullWidth:!0,style:{textTransform:"none",height:"40px"},children:"+ Create New Campaign"})]})]}),(this.state.newCampaignExpanded||this.state.selectedCampaignName)&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,style:{marginTop:16},children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:8},children:this.state.selectedCampaignName?"Template (Change Template)":"Select Template"}),this.state.isLoadingTemplates?(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",children:[(0,h.jsx)(o.CircularProgress,{size:16}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{marginLeft:8},children:"Loading templates..."})]}):(0,h.jsx)(O.Autocomplete,{clearOnEscape:!0,options:this.state.templates.filter((e=>{if("APPROVED"!==e.status?.toUpperCase())return!1;const t=(this.state.templateSearchInput||"").toLowerCase();return(e.name||"").toLowerCase().includes(t)})).slice(0,100).map((e=>e.name)),getOptionDisabled:e=>{const t=this.state.templates.find((t=>t.name===e));return this.props.isMarketingDisabled&&Al(t)},value:this.state.automationTemplateName||null,onChange:(e,t,a)=>{"select-option"!==a&&"clear"!==a||(this.handleTemplateSelect(t||""),this.setState({templateSearchInput:""}))},onInputChange:(e,t,a)=>{"input"===a&&this.setState({templateSearchInput:t})},popupIcon:(0,h.jsx)(d.SearchOutlined,{style:{fontSize:"20px"}}),renderInput:t=>(0,h.jsx)(o.TextField,{...t,fullWidth:!0,variant:"outlined",classes:{root:e.TextFieldRoot},InputProps:{...t.InputProps,classes:{input:e.inputPadding}},placeholder:"Select a template"}),renderOption:e=>{const t=this.state.templates.find((t=>t.name===e&&"APPROVED"===t.status?.toUpperCase()));if(!t)return null;const a=this.props.isMarketingDisabled&&Al(t),n=(0,h.jsx)(o.Box,{onMouseEnter:e=>{this.hoverTimeout&&clearTimeout(this.hoverTimeout),this.hoverTimeout=setTimeout((()=>{if(this.props.onPreviewDataChange){const e=t.parameters||0,a=Array.from({length:e},(()=>"Sample"));let n=[];"CAROUSEL"===t.type&&t.carouselCards?.length&&(n=fl(t.carouselCards));let s={};t.headerType&&t.headerMedia&&(s={url:t.headerMedia,publicUrl:t.headerMedia,filename:t.headerMedia.split("/").pop()||"media_file"}),this.props.onPreviewDataChange({selectedTemplate:t,parameters:a,media:s,cards:n,carouselIndex:0,isHoverPreview:!0})}this.setState({hoveredTemplate:t})}),200)},onMouseLeave:()=>{this.hoverTimeout&&clearTimeout(this.hoverTimeout),this.hoverTimeout=setTimeout((()=>{this.updatePreviewData(),this.setState({hoveredTemplate:null})}),200)},style:{display:"flex",alignItems:"center",width:"100%",padding:"8px 16px"},children:(0,h.jsx)(o.Typography,{variant:"body1",noWrap:!0,style:{flex:1},children:e})});return(0,h.jsx)(El,{show:a,projectId:this.props.match?.params?.projectId,history:this.props.history,children:n})}})]}),(0,h.jsxs)(o.Grid,{item:!0,xs:12,style:{marginTop:16},children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:8},children:"Campaign Name"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:e.TextFieldRoot},InputProps:{classes:{input:e.inputPadding}},placeholder:"LeadForm_TemplateName",value:this.state.automationCampaignName,onChange:this.handleCampaignNameChange,disabled:!!this.state.selectedCampaignName&&!this.state.newCampaignExpanded}),this.state.selectedCampaignName&&!this.state.newCampaignExpanded&&(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{marginTop:4,display:"block"},children:"To edit campaign name, create a new campaign or clear the existing campaign selection"})]})]}),t&&"CAROUSEL"===this.state.selectedTemplate?.type&&this.state.cards?.length>0&&(0,h.jsx)(o.Grid,{item:!0,xs:12,children:(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2,p:2,style:{backgroundColor:"#f5f5f5",borderRadius:8},children:[(0,h.jsx)(o.Button,{variant:"outlined",size:"small",disabled:0===this.state.carouselIndex,onClick:()=>this.setCarouselIndex(this.state.carouselIndex-1),children:"Previous"}),(0,h.jsxs)(o.Typography,{variant:"body2",color:"textSecondary",children:["Card ",this.state.carouselIndex+1," of"," ",this.state.cards.length]}),(0,h.jsx)(o.Button,{variant:"outlined",size:"small",disabled:this.state.carouselIndex>=this.state.cards.length-1,onClick:()=>this.setCarouselIndex(this.state.carouselIndex+1),children:"Next"})]})}),t&&(0,h.jsx)(o.Grid,{item:!0,xs:12,style:{marginTop:16},children:(0,h.jsx)(cl,{selectedTemplate:this.state.selectedTemplate,attributes:this.getLeadFormAttributes(),parameters:this.state.parameters,fallbackParameters:this.state.fallbackParameters,setTemplateMessage:this.setTemplateMessage,media:this.state.media,onMediaSelect:this.onMediaSelect,toggleMediaDialog:this.toggleMediaDialog,cards:this.state.cards,setCards:this.setCards,carouselIndex:this.state.carouselIndex,mediaCount:this.getCarouselMediaCount()})})]})}),this.state.mediaLibraryOpen&&(0,h.jsx)(B,{name:"mediaLibrary",openMediaDialog:this.state.mediaLibraryOpen,toggleMediaDialog:this.toggleMediaDialog,onMediaSelect:this.onMediaSelect,mediaType:this.state.selectedTemplate?.headerType||this.state.selectedTemplate?.type||"IMAGE",isFromMetaAds:!0})]})})}}const Dl=e=>({TextFieldRoot:{width:"100%",padding:"2px",marginTop:"0px !important","& input":{width:"calc(100% - 80px)",marginTop:"0px !important"},background:"rgb(240,240,240)"},inputPadding:{padding:"12px 10px"}}),wl={fetchApiCampaigns:gi.Se,fetchTemplates:gi.QK},Nl=(0,i.connect)((e=>({isMarketingDisabled:Boolean(e.assistantDetails?.data?.optSetting?.disableMarketingMessaging)})),wl)((0,r.withRouter)((0,o.withStyles)(Dl)(Tl))),jl=((0,i.connect)((e=>({assistantDetails:e.assistantDetails?.data,assistantId:e.login?.user?.assistantId||e.assistantDetails?.data?.assistantId,pageDetails:e.pageDetails?.pageDetails,isMarketingDisabled:Boolean(e.assistantDetails?.data?.optSetting?.disableMarketingMessaging)})),wl)((0,r.withRouter)((0,o.withStyles)(Dl)(Tl))),/\*(\**[^*\n]+\**)\*/g),kl=/_(_*[^_\n]+_*)_/g,Ll=/~(~*[^_\
1n]+~*)~/g,Rl=/((?:http|https)?:\/\/[^\s<]+)/g;function Bl(e){return"<b>"+e.substring(1,e.length-1)+"</b>"}function Ol(e){return"<i>"+e.substring(1,e.length-1)+"</i>"}function Pl(e){return"<s>"+e.substring(1,e.length-1)+"</s>"}const Ml=function(e){return(0,ts.escape)(e).split(Rl).map(((e,t)=>{return t%2==1?`<a style="word-break: break-word" target="_blank" rel="noopener noreferrer" href="${a=e}">${a}</a>`:function(e){let t=e.replace(jl,Bl);return t=t.replace(kl,Ol),t=t.replace(Ll,Pl),t}(e);var a})).join("")},Ul=a.p+"60623e6ad41751507aa5251df655060f.png";var Fl=a(47766);const Wl=(e,t)=>{let a=e||"";return(t||[]).forEach(((e,t)=>{const n=new RegExp(`\\{\\{${t+1}\\}\\}`);e&&(a=a.replace(n,`[${e}]`))})),a};function zl(e,t){let a=e||"";return(t||[]).forEach(((e,t)=>{const n=new RegExp(`\\{\\{${t+1}\\}\\}`);e&&(a=a.replace(n,`[${e}]`))})),a}const Gl={backgroundColor:"#f5f5f5",borderRadius:"8px",boxShadow:"none",margin:"16px",width:"auto"},Hl={borderBottom:"1px dashed #000",paddingBottom:"8px",marginBottom:"12px"},Vl=e=>{let{type:t,total:a,productName:n,quantity:s}=e;return(0,h.jsx)(o.Card,{style:Gl,children:(0,h.jsxs)(o.CardContent,{children:["ORDER_DETAILS"===t&&(0,h.jsxs)(o.Typography,{style:Hl,variant:"h6",component:"h2",children:["ORDER # ","{{Order number}}"]}),(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,h.jsx)(o.Box,{style:{width:"40px",height:"40px",background:"#a3a7ac",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,h.jsx)(d.Image,{style:{color:"#e6e5e5",fontSize:"32px"}})}),(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{component:"p",children:n||"{{Product name}}"}),(0,h.jsxs)(o.Typography,{color:"textSecondary",children:["Quantity ",s||"{{#}}"]})]})]}),"ORDER_DETAILS"===t&&(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"space-between",style:{borderTop:"1px dashed #000",padding:"8px 0px",marginTop:"12px"},children:[(0,h.jsx)(o.Typography,{variant:"h5",component:"h2",children:"Total"}),(0,h.jsxs)(o.Typography,{variant:"h5",component:"h2",children:["₹",a?a*s:"{{#}}"]})]})]})})};var Yl=a(44665);const Zl=s().memo((0,o.withStyles)((e=>({root:{width:"100%",maxWidth:"340px",background:e.palette.primary.light},message:{clear:"both",background:"white",maxWidth:"340px",width:"100%",position:"relative",lineHeight:"24px",fontSize:"16px","&::after":{position:"absolute",content:'""',width:0,height:0,borderStyle:"solid"}},received:{background:"white",borderRadius:"0px 5px 5px 5px",boxShadow:"rgba(60, 64, 67, 0.3) 0px 0px 0px 0px, rgba(60, 64, 67, 0.15) -0.5px 1.5px 0px 0px",filter:"drop-shadow(0px 0.5px 0px rgba(60, 64, 67, 0.3)) drop-shadow(1px 1px 2px rgba(60, 64, 67, 0.15))","&::after":{content:'""',borderWidth:"0px 10px 10px 0",borderColor:"transparent #fff transparent transparent",top:"0",left:"-10px"}},received2:{background:"white",borderRadius:5,boxShadow:"rgba(60, 64, 67, 0.3) 0px 0px 0px 0px, rgba(60, 64, 67, 0.15) -0.5px 1.5px 0px 0px",filter:"drop-shadow(0px 0.5px 0px rgba(60, 64, 67, 0.3)) drop-shadow(1px 1px 2px rgba(60, 64, 67, 0.15))"},media:{height:140,width:"calc(100% - 32px)",padding:"16px",borderRadius:"20px",border:0},messageBox:{whiteSpace:"pre-line",wordBreak:"break-word",color:"#000000"},agentMessageAction:{"& .defaultTheme":{borderRadius:"6px",maxWidth:"100%",boxShadow:"0px 2px 1px -1px rgb(0 0 0 / 20%), 0px 1px 1px 0px rgb(0 0 0 / 14%), 0px 1px 3px 0px rgb(0 0 0 / 12%)"}},header:{fontWeight:"600",padding:"8px 16px"},footer:{color:"#A9A9A9",fontSize:"14px",fontWeight:"500",padding:"0px 16px",paddingBottom:"8px"},icon:{width:"50px",height:"50px",color:"#a0a0a0"},whatsappIcon:{width:"30px",height:"30px",position:"absolute",top:-15,left:-15,zIndex:1},bigWhatsappIcon:{width:"50px",height:"50px",position:"absolute",top:-25,left:-25,zIndex:1},disclaimer:{color:"#A9A9A9",fontSize:"12px",maxWidth:340},fileIcon:{marginTop:"3px",height:"45px"},deleteIcon:{left:327,zIndex:1,top:-10,width:"25px",height:"25px",cursor:"pointer",position:"absolute",color:"rgb(250, 92, 92)"},normalMessage:{clear:"both",background:"white",maxWidth:"340px",width:"100%",position:"relative",lineHeight:"24px",fontSize:"16px"}
1,normalReceived:{background:"white",borderRadius:5,boxShadow:"rgba(60, 64, 67, 0.3) 0px 0px 0px 0px, rgba(60, 64, 67, 0.15) -0.5px 1.5px 0px 0px",filter:"drop-shadow(0px 0.5px 0px rgba(60, 64, 67, 0.3)) drop-shadow(1px 1px 2px rgba(60, 64, 67, 0.15))"}})))((function(e){const{type:t,classes:a,bigIcon:s,payload:i,maxHeight:r,isHideIcon:l,showDisclaimer:c,carouselIndex:p,carouselCards:u=[],selectedTemplate:m,cards:g,formattedButtons:b,key:y,paymentParams:x,formattedLimitedTimeOffer:f,isHideImagePreview:A=!1}=e,[I,C]=(0,n.useState)({}),{text:_="",caption:S=""}=i;let v=(_||S).split(" | [")[0];const E=l&&"CAROUSEL"!==t,T=A?0:e.disclaimerMargin||(E?0:16),D=u.length>0;if(u?.length){let e=g?.[p]?.components?.find((e=>"BODY"===e.type))?.parameters?.map((e=>{let{text:t}=e;return t}));e?.length||(e=u?.[p]?.components?.find((e=>"BODY"===e.type))?.example?.body_text?.[0]?.map((e=>e))),v=Wl(v,e)}const{limitedTimeOffer:w,buttons:N=[]}=m||{},j=m?.headerType||t,k=(()=>{if(!D)return j;const e=u?.[p]||{},t=e?.components?.find((e=>"HEADER"===e.type));return t?.format})(),L=g?.[p]?.components?.find((e=>{let{type:t}=e;return"HEADER"===t}))?.parameters?.[0]?.[k.toLowerCase()]?.link||i.url;return(0,n.useEffect)((()=>{L&&!I?.media&&(async()=>{try{const e=await(0,Yl.k_)(L),t=e.headers["content-type"];C({contentType:t,media:URL.createObjectURL(e.data)})}catch(e){console.error("Error fetching media:",e)}})()}),[L]),(0,h.jsxs)(o.Box,{style:{width:"100%"},children:[(0,h.jsx)(o.Grid,{style:{display:"flex"},children:(0,h.jsxs)(o.Box,{className:e.hideMessageTopEdge?`${a.normalMessage} ${a.normalReceived}`:`${a.message} ${a.received}`,style:e.isHideIcon&&"CAROUSEL"!==t?{overflow:"hidden"}:{},children:[!e.isHideIcon&&(0,h.jsx)("img",{src:Ul,alt:"WhatsApp",className:s?a.bigWhatsappIcon:a.whatsappIcon}),["TEXT","ORDER_STATUS"].includes(t)||["TEXT"].includes(j)?["TEXT"].includes(j)&&["ORDER_DETAILS"].includes(t)&&(0,h.jsx)(Vl,{type:t,total:x?.amount,quantity:x?.quantity,productName:x?.productName}):L?"AUDIO"===t?(0,h.jsx)("audio",{controls:!0,loop:!0,src:i.url,style:{width:"100%"}}):(0,h.jsx)(o.CardMedia,{className:a.media,alt:"media",title:i.filename||"Download media",..."FILE"===j&&"application/pdf"!==I.contentType?{component:()=>(0,h.jsx)(o.Box,{height:"140px",bgcolor:Fl.Dg[j]??"#f8f8f8",style:{border:"16px solid white",borderRadius:"20px",display:"flex",justifyContent:"center",alignItems:"center"},children:(0,h.jsx)(d.Description,{className:a.icon,style:{color:Fl.fz[j]}})})}:{component:"IMAGE"===k?"img":"iframe",src:(0,wo.replaceDomainInData)(I.media)},onError:()=>{console.log("fallback triggered!!")},style:"LIMITED_TIME_OFFER"===t?{borderRadius:"20px 20px 0 0",paddingBottom:"0px"}:{}}):["ORDER_DETAILS","CATALOGUE_MESSAGE","MULTI_PRODUCT_MESSAGE"].includes(t)?(0,h.jsx)(Vl,{type:t,total:x?.amount,quantity:x?.quantity,productName:x?.productName}):A?null:(0,h.jsx)(o.Box,{height:"140px",bgcolor:Fl.Dg[j]??"#f8f8f8",style:{border:"16px solid white",borderRadius:"LIMITED_TIME_OFFER"!==t?"20px":"20px 20px 0 0",display:"flex",justifyContent:"center",alignItems:"center",borderBottom:"LIMITED_TIME_OFFER"!==t&&"0px"},children:"IMAGE"===j?(0,h.jsx)(d.Image,{className:a.icon,style:{color:Fl.fz[j]}}):"FILE"===j?(0,h.jsx)(d.Description,{className:a.icon,style:{color:Fl.fz[j]}}):"VIDEO"===j?(0,h.jsx)(d.PlayCircleFilled,{className:a.icon,style:{color:Fl.fz.VIDEO}}):"TEXT"===j||"ORDER_DETAILS"===t?(0,h.jsx)(o.Box,{style:{height:300,width:300}}):"LOCATION"===t?(0,h.jsx)(d.LocationOn,{className:a.icon,style:{color:Fl.fz.LOCATION}}):"CAROUSEL"===t?(0,h.jsx)(o.Box,{style:{display:"flex"},children:"IMAGE"===i.mediaType?(0,h.jsx)(d.Image,{className:a.icon,style:{color:Fl.fz.IMAGE}}):"VIDEO"===i.mediaType?(0,h.jsx)(d.PlayCircleFilled,{className:a.icon,style:{color:Fl.fz.VIDEO}}):null}):(0,h.jsxs)(o.Box,{style:{display:"flex"},children:[(0,h.jsx)(d.Image,{className:a.icon,style:{color:Fl.fz.IMAGE}}),(0,h.jsx)(d.PlayCircleFilled,{className:a.icon,style:{color:Fl.fz.VIDEO}}),(0,h.jsx)(d.Description,{className:`${a.icon} ${a.fileIcon}`,style:{color:Fl.fz.FILE}})]})}),i.headerText&&(0,h.jsx)(o.Box,{style:{overflowWrap:"break-word"},children:(0,h.jsx)(o.Typography,{className:a.header,children:i.headerText})}),"AUDIO"!==t&&(0,h.jsxs)(o.CardContent,{style:r?{maxHeight:r,overflowX:"auto",padding:"8px 16px"}:{padding:"8px 16px"},children:["ORDER_STATUS"===t&&(0,h.jsxs)(o.Typography,{variant:"h5",color:"primary",align:"left",style:"TEXT"===t?{paddingTop:"8px",minHeight:40}:e.lineHeight||e.minHeight?{overflow:"hidden",minHeight:`${e.lineHeight?e.lineHeight*e.lines:e.minHeight||2.5}em`,maxHeight:e.lineHeight*e.lines+"em",lineHeight:`${e.lineHeight}em`}:{},className:a.messageBox,children:["Status: ","{{Order Status}}"]}),(0,h.jsx)(o.Typography,{variant:"h5",color:"primary",align:"left",style:"TEXT"===t?{paddingTop:"8px",minHeight:40}:e.lineHeight||e.minHeight?{overflow:"hidden",minHeight:`${e.lineHeight?e.lineHeight*e.lines:e.minHeight||2.5}em`,maxHeight:e.lineHeight*e.lines+"em",lineHeight:`${e.lineHeight}em`}:{},className:a.messageBox,dangerouslySetInnerHTML:{__html:Ml(v)}})]}),i.footerText&&(0,h.jsx)(o.Box,{style:{overflowWrap:"break-word"},children:(0,h.jsx)(o.Typography,{className:a.footer,children:i.footerText})})]})}),!A&&"CAT"!==i.actionType&&"None"!==i.actionType&&(0,h.jsx)(o.Box,{width:"100%",maxWidth:"340px",className:a.agentMessageAction}),(0,h.jsx)(o.Box,{style:{height:T}}),c&&(0,h.jsx)(o.Typography,{className:a.disclaimer,style:{color:"TEXT"===t&&"transparent"},children:"Disclaimer: This is just a graphical representation of the message that will be delivered. Actual message will consist of media selected and may appear different."}),(0,h.jsx)(o.Box,{style:{height:T}})]},y)})),((e,t)=>JSON.stringify(e)===JSON.stringify(t))),Kl=e=>{const{media:t,parameters:a,selectedTemplate:n,setCarouselIndex:s,carouselIndex:i=0,addCarou
1selTemplate:r,cards:l,compact:c=!1}=e,p=n?.type;let u=n?.templateCTAUrl;const m=Wl(n?.format||n?.payload?.text,a),g="CAROUSEL"===p,{carouselCards:b=[]}=n;if(!u){const e=(n?.callToAction||[]).filter((e=>"URL"===e.type));if(e.length>0&&(u=e[0].buttonValue,a&&a.length>0)){const t=a[a.length-1];t&&(y=e[0].buttonValue,x=t,u=y.replace(/{{(\d+)}}/g,(function(e,t){return`[${x}]`})))}}var y,x;n?.sampleCTAUrl&&!u&&(u=n?.sampleCTAUrl);const f=e=>{const t=e.match(/{{\d+}}/g);return t?.length||0},A=()=>{const{format:e}=n;let t=f(e)||0;t+=(e=>{let t=0;const{components:a=[]}=b[e]||{},s=(0,ts.isEmpty)(n.buttons)&&"CAROUSEL"===p?a.find((e=>"BUTTONS"===e.type))?.buttons:n.buttons;return s?.forEach((e=>{const{url:a="",type:n}=e;t+="URL"===n?f(a):0})),t})(0);for(let e=0;e<i;e++){const{components:a=[]}=b[e]||{},n=a.find((e=>"BODY"===e.type))||{};t+=n.example?.body_text[0]?.length||0}return t},I=()=>({parameters:a,templateCTAUrl:u,buttons:n.buttons,text:"TEXT"===p?m:"",caption:"TEXT"!==p?m:"",actionType:n?.actionType,footerText:n?.footerText,headerText:n?.headerText,callToAction:n?.callToAction,quickReplies:n?.quickReplies,url:"LOCATION"===p?null:t?.url,address:"LOCATION"===p?t?.address:null,filename:"LOCATION"===p?null:t?.filename,latitude:"LOCATION"===p?t?.latitude:null,locationName:"LOCATION"===p?t?.name:null,longitude:"LOCATION"===p?t?.longitude:null}),C=(e,t)=>{if("HEADER"===e)return{...I(),text:m,parameters:a,caption:"",footerText:"",headerText:"",callToAction:[],actionType:"None",templateCTAUrl:""};{const{carouselCards:e}=n,{components:s=[]}=e[t]||{},o=s.find((e=>"HEADER"===e.type))||{},i=s.find((e=>"BODY"===e.type))||{},r=s.find((e=>"BUTTONS"===e.type))||{},l=i.text||"",d=r.buttons||[],c=A(),p=o.format||"",u=i.example?.body_text[0]?.length||0,m=(e=>e.map((e=>{const{type:t}=e;return"URL"!==t?e:{...e,url:Wl(e.url,a)}})))(d);return{caption:"",address:null,footerText:"",headerText:"",latitude:null,parameters:[],longitude:null,locationName:null,actionType:n?.actionType,callToAction:d,templateCTAUrl:"rverv",mediaType:p,buttons:m,text:zl(l,a.slice(c,c+u))}}};return(0,h.jsxs)(o.Box,{style:c?{width:"100%"}:{width:"100%",minWidth:"300px",maxWidth:"500px"},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",flexDirection:"row",alignContent:"center",justifyContent:"center",width:"100%",position:"relative",transition:"all 0.2s"},children:[!c&&(0,h.jsx)(o.Box,{style:{marginTop:"auto",display:"flex",justifyContent:"flex-end",width:"10%",overflow:"clip",padding:"8px 16px"},children:(0,h.jsx)(o.Box,{style:{minWidth:"200px",opacity:.5,transform:"scaleY(0.9)"},children:(0,h.jsx)(Jl,{...e,carouselIndex:i-1,carouselCards:b,createCarouselPayload:C})})}),(0,h.jsx)(o.Box,{style:{padding:8,width:c?"100%":"80%"},children:(0,h.jsx)(ql,{...e,carouselIndex:i,carouselCards:b,createPayload:e=>g?C(e):I(),createCarouselPayload:C})}),!c&&(0,h.jsx)(o.Box,{style:{marginTop:"auto",width:"10%",overflow:"clip",padding:"8px 16px"},children:(0,h.jsx)(o.Box,{style:{minWidth:"200px",opacity:.5,transform:"scaleY(0.9)"},children:(0,h.jsx)($l,{...e,carouselIndex:i+1,carouselCards:b,createCarouselPayload:C})})})]}),!c&&(0,h.jsx)(Xl,{carouselIndex:i,setCarouselIndex:s,carouselCards:b,cards:l,addCarouselTemplate:r}),b?.length&&r&&(0,h.jsx)(o.Box,{style:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:16},children:(0,h.jsx)(o.Button,{variant:"outlined",startIcon:(0,h.jsx)(d.AddOutlined,{}),style:{padding:"0 48px"},disabled:b?.length>=10||!r,onClick:()=>r(i+1),children:"Add Card"})})]})},Jl=s().memo((function(e){const{bigIcon:t,maxHeight:a,selectedTemplate:n,createCarouselPayload:s,carouselCards:o,carouselIndex:i,cards:r}=e;return i<0?(0,h.jsx)(h.Fragment,{}):(0,h.jsx)(Zl,{type:"CAROUSEL",bigIcon:t,isHideIcon:!0,hideMessageTopEdge:!0,maxHeight:a,payload:{...s("FOOTER",i)},carouselCards:o,carouselIndex:i,selectedTemplate:n,cards:r,lineHeight:1.8,lines:3},i)}),Ql),$l=s().memo((function(e){const{bigIcon:t,maxHeight:a,selectedTemplate:n,createCarouselPayload:s,carouselCards:o,carouselIndex:i,cards:r}=e;return i-1>=(o?.length||r?.length||0)-1?(0,h.jsx)(h.Fragment,{}):(0,h.jsx)(Zl,{type:"CAROUSEL",bigIcon:t,isHideIcon:!0,hideMessageTopEdge:!0,maxHeight:a,payload:{...s("FOOTER",i)},carouselCards:o,carouselIndex:i,selectedTemplate:n,cards:r,lineHeight:1.8,lines:3},i)}),Ql),ql=s().memo((function(e){const{bigIcon:t,maxHeight:a,selectedTemplate:n,createPayload:s,createCarouselPayload:i,carouselCards:r,carouselIndex:l,cards:c,isHideIcon:p,deleteC
1arouselTemplate:u,setCarouselIndex:m,compact:g=!1}=e,b=(c?.length?c:r)?.length||0;return(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",position:"relative",children:[(0,h.jsx)(Zl,{bigIcon:t,maxHeight:a,isHideIcon:p,payload:{...s("HEADER")},type:"TEXT",showDisclaimer:!1,disclaimerMargin:5,selectedTemplate:n,carouselCards:[]},"header"),(0,h.jsxs)(o.Box,{style:{minWidth:"200px",width:"100%",position:"relative"},children:[(0,h.jsx)(Zl,{type:"CAROUSEL",bigIcon:t,isHideIcon:!0,hideMessageTopEdge:!0,showCarouselButtons:!0,maxHeight:a,showDisclaimer:!1,payload:{...i("FOOTER",l)},carouselCards:r,carouselIndex:l,selectedTemplate:n,cards:c,minHeight:1.6*3},l),l>0&&(0,h.jsx)(o.IconButton,{style:{position:"absolute",top:g?100:"50%",transform:g?"translateY(-50%)":void 0,left:g?4:-40,borderRadius:"50%",background:"#00000073",padding:g?4:8,color:"gray",cursor:"pointer",zIndex:2},onClick:()=>m(l-1),children:(0,h.jsx)(d.ArrowBackIosOutlined,{style:{cursor:"pointer",fontSize:14,color:"white"}})}),l<b-1&&(0,h.jsx)(o.IconButton,{style:{position:"absolute",top:g?100:"50%",transform:g?"translateY(-50%)":void 0,right:g?4:-40,borderRadius:"50%",background:"#00000073",padding:g?4:8,color:"gray",cursor:"pointer",zIndex:2},onClick:()=>m(l+1),children:(0,h.jsx)(d.ArrowForwardIosOutlined,{style:{cursor:"pointer",fontSize:14,color:"white"}})}),r?.length>1&&u&&(0,h.jsx)(o.IconButton,{style:{position:"absolute",top:-8,right:-8,borderRadius:"50%",background:"rgb(219,219,219, 0.67)",padding:4,color:"gray",cursor:"pointer"},onClick:()=>u(l-1),children:(0,h.jsx)(d.Delete,{style:{fontSize:14,padding:0}})})]})]})})),Xl=s().memo((function(e){const{carouselIndex:t,setCarouselIndex:a,carouselCards:n,cards:s,addCarouselTemplate:i}=e,r=s?.length?s:n,l=r?.length||0;return(0,h.jsx)(o.Grid,{container:!0,spacing:1,style:{display:"flex",width:"100%",alignItems:"center",justifyContent:"center",height:48},children:r.map(((e,n)=>(0,h.jsx)(o.Grid,{item:!0,style:{paddingBottom:8},children:(0,h.jsx)(o.Tooltip,{interactive:!0,title:l<10&&i?(0,h.jsx)(o.Box,{style:{cursor:"pointer"},onClick:()=>i(n+1),children:(0,h.jsx)(o.Typography,{variant:"h6",children:"Add"})}):"",children:(0,h.jsx)(o.IconButton,{onClick:()=>a(n),style:{padding:"0.3rem",borderRadius:"50%",background:t===n?"darkGray":"lightGray"}})})},n)))})}),Ql);function Ql(e,t){return e.carouselIdx===t.carouselIdx}const ed=s().memo(Kl),td=e=>{const{media:t,bigIcon:a,maxHeight:n,parameters:s,showDisclaimer:i,selectedTemplate:r,setCarouselIndex:l,carouselIndex:d=0,addCarouselTemplate:c,deleteCarouselTemplate:p,cards:u,formattedButtons:m,paymentParams:g,formattedLimitedTimeOffer:b,maxWidth:y="340px",interactiveActionMarginBottomNone:x=!1,fullHeight:f=!1}=e,A=r?.type;let I=r?.templateCTAUrl;const C=Wl(r?.format||r?.payload?.text,s),_="CAROUSEL"===A;let S=[];if(r&&(S=r.carouselCards),!I){const e=(r?.callToAction||[]).filter((e=>"URL"===e.type));if(e.length>0&&(I=e[0].buttonValue,s&&s.length>0)){const t=s[s.length-1];t&&(v=e[0].buttonValue,E=t,I=v.replace(/{{(\d+)}}/g,(function(e,t){return`[${E}]`})))}}var v,E;r?.sampleCTAUrl&&!I&&(I=r?.sampleCTAUrl);const T=e=>{const t=e.match(/{{\d+}}/g);return t?.length||0},D=()=>{const{format:e}=r;let t=T(e)||0;t+=(e=>{let t=0;const{components:a=[]}=S[e]||{},n=(0,ts.isEmpty)(r.buttons)&&"CAROUSEL"===A?a.find((e=>"BUTTONS"===e.type))?.buttons:r.buttons;return n?.forEach((e=>{const{url:a="",type:n}=e;t+="URL"===n?T(a):0})),t})(0);for(let e=0;e<d;e++){const{components:a=[]}=S[e]||{},n=a.find((e=>"BODY"===e.type))||{};t+=n.example?.body_text[0]?.length||0}return t},w=()=>({parameters:s,templateCTAUrl:I,buttons:r?.buttons||[],text:"TEXT"===A?C:"",caption:"TEXT"!==A?C:"",actionType:r?.actionType,footerText:r?.footerText,headerText:r?.headerText,headerType:r?.headerType,callToAction:r?.callToAction,quickReplies:r?.quickReplies,url:"LOCATION"===A?null:t?.url,address:"LOCATION"===A?t?.address:null,filename:"LOCATION"===A?null:t?.filename,latitude:"LOCATION"===A?t?.latitude:null,locationName:"LOCATION"===A?t?.name:null,longitude:"LOCATION"===A?t?.longitude:null}),N=e=>{if("HEADER"===e)return{...w(),text:C,parameters:s,caption:"",footerText:"",headerText:"",callToAction:[],actionType:"None",templateCTAUrl:""};{const{carouselCards:e}=r,{components:t=[]}=e[d]||{},a=t.find((e=>"HEADER"===e.type))||{},n=t.find((e=>"BODY"===e.type))||{},o=t.find((e=>"BUTTONS"===e.type))||{},i=n.text||"",l=o.buttons||[],c=D(),p=a.format||"",u=n.example?.body_text[0]?.length||0,m=(e=>e.map((e=>{const{type:t}=e;return"URL"!==t?e:{...e,url:Wl(e.url,s)}})))(l);return{caption:"",address:null,footerText:"",headerText:"",latitude:null,parameters:[],longitude:null,locationName:null,actionType:r?.actionType,callToAction:l,templateCTAUrl:"rverv",mediaType:p,buttons:m,text:zl(i,s.slice(c,c+u))}}},j=()=>{return"CAROUSEL"===A?(0,h.jsx)(ed,{media:t,bigIcon:a,maxHeight:n,parameters:s,showDisclaimer:i,selectedTemplate:r,isHideIcon:e.isHideIcon,compact:e.compact,setCarouselIndex:l,carouselIndex:d,addCarou
1selTemplate:c,deleteCarouselTemplate:p,cards:u,formattedButtons:m}):(0,h.jsx)(o.Box,{style:{...f&&{height:"100%"}},children:(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",justifyContent:"center",style:{...f&&{height:"100%"}},children:(0,h.jsx)(Zl,{bigIcon:a,maxHeight:n,isHideIcon:e.isHideIcon,payload:{...(I="HEADER",_?N(I):w())},type:_?"TEXT":r?.type,showDisclaimer:!_&&i,selectedTemplate:r,carouselCards:[],formattedButtons:m,paymentParams:g,formattedLimitedTimeOffer:b,maxWidth:y,interactiveActionMarginBottomNone:x,fullHeight:f})})});var I};return(0,h.jsx)(j,{})},ad=s().memo(td,((e,t)=>JSON.stringify(e)===JSON.stringify(t))),nd=e=>({FULL_NAME:(0,h.jsx)(d.Person,{fontSize:"small"}),FIRST_NAME:(0,h.jsx)(d.Person,{fontSize:"small"}),LAST_NAME:(0,h.jsx)(d.Person,{fontSize:"small"}),EMAIL:(0,h.jsx)(d.Email,{fontSize:"small"}),PHONE:(0,h.jsx)(d.Phone,{fontSize:"small"}),WORK_EMAIL:(0,h.jsx)(d.Email,{fontSize:"small"}),WORK_PHONE_NUMBER:(0,h.jsx)(d.Phone,{fontSize:"small"}),COMPANY_NAME:(0,h.jsx)(d.Business,{fontSize:"small"}),JOB_TITLE:(0,h.jsx)(d.Work,{fontSize:"small"}),STREET_ADDRESS:(0,h.jsx)(d.Home,{fontSize:"small"}),CITY:(0,h.jsx)(d.Home,{fontSize:"small"}),STATE:(0,h.jsx)(d.Home,{fontSize:"small"}),ZIP:(0,h.jsx)(d.Home,{fontSize:"small"}),COUNTRY:(0,h.jsx)(d.Home,{fontSize:"small"}),DATE_TIME:(0,h.jsx)(d.CalendarToday,{fontSize:"small"}),DATE_OF_BIRTH:(0,h.jsx)(d.CalendarToday,{fontSize:"small"}),CUSTOM:(0,h.jsx)(d.Person,{fontSize:"small"})}[e]||(0,h.jsx)(d.Person,{fontSize:"small"})),sd=e=>{if("CUSTOM"===e.type)return e.label||"Custom Question";return{FULL_NAME:"Full Name",FIRST_NAME:"First Name",LAST_NAME:"Last Name",EMAIL:"Email",PHONE:"Phone Number",WORK_EMAIL:"Work Email",WORK_PHONE_NUMBER:"Work Phone",COMPANY_NAME:"Company Name",JOB_TITLE:"Job Title",STREET_ADDRESS:"Street Address",CITY:"City",STATE:"State/Province",ZIP:"Zip/Postal Code",COUNTRY:"Country",DATE_TIME:"Select Date & Time",DATE_OF_BIRTH:"Date of Birth",GENDER:"Gender",MARITIAL_STATUS:"Marital Status",RELATIONSHIP_STATUS:"Relationship Status",MILITARY_STATUS:"Military Status"}[e.type]||e.type},od=(0,o.withStyles)((e=>({previewContainer:{display:"flex",justifyContent:"center",padding:e.spacing(2)},previewCard:{width:"100%",maxWidth:320,backgroundColor:"#fff",borderRadius:8,overflow:"hidden",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",display:"flex",flexDirection:"column",minHeight:450},stepNavHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:e.spacing(1,2),borderBottom:"1px solid #e0e0e0",backgroundColor:"#f9f9fb"},navButton:{padding:e.spacing(.5)},content:{flex:1,padding:e.spacing(2),backgroundColor:"#fff",display:"flex",flexDirection:"column",overflow:"auto"},greetingPreview:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",flex:1,padding:e.spacing(2)},questionsPreview:{flex:1},questionPreviewItem:{marginBottom:e.spacing(2)},contactInfoPreview:{marginTop:e.spacing(2)},privacyPreview:{padding:e.spacing(2),textAlign:"center"},emptyState:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:150,backgroundColor:"#F9F9FB",borderRadius:8},questionLabel:{display:"flex",alignItems:"center",gap:6,marginBottom:e.spacing(.5),color:"#666"},TextFieldRoot:{width:"100%",padding:"2px",marginTop:"4px","& input":{width:"calc(100% - 80px)"},background:"rgb(240,240,240)"},inputPadding:{padding:"8px 10px"},optionsPreview:{display:"flex",flexDirection:"column",gap:6,padding:e.spacing(1),backgroundColor:"#F9F9FB",borderRadius:8},optionItem:{display:"flex",alignItems:"center",gap:8},radioCircle:{width:14,height:14,borderRadius:"50%",border:"2px solid #999"},contactInfoField:{marginBottom:e.spacing(1)},thankYouContainer:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",flex:1,textAlign:"center",padding:e.spacing(3,2)},logoPlaceholder:{marginBottom:e.spacing(2)},logoCircle:{width:60,height:60,borderRadius:"50%",backgroundColor:"#e0e0e0",display:"flex",alignItems:"center",justifyContent:"center"},thankYouTitle:{fontWeight:600,marginBottom:e.spacing(1.5),fontSize:"1.25rem"},thankYouBody:{marginBottom:e.spacing(2),fontSize:"0.875rem",lineHeight:1.5},divider:{width:"100%",height:1,backgroundColor:"#e0e0e0",margin:e.spacing(2,0)},successConfirmation:{display:"flex",alignItems:"center",gap:6,justifyContent:"center"},infoIcon:{fontSize:16,color:"#999"},fixedButtonContainer:{padding:e.spacing(2),borderTop:"1px solid #e0e0e0",backgroundColor:"#fff"},flowBadge:{display:"flex",alignItems:"center",gap:6,padding:e.spacing(1,2),backgroundColor:"#e8f5e9",borderRadius:16,marginBottom:e.spacing(2)},thankYouButton:{backgroundColor:"#1877F2",color:"#fff",textTransform:"none",borderRadius:8,padding:e.spacing(1.2,3),fontWeight:600,"&:disabled":{backgroundColor:"#1877F2",color:"#fff",opacity:.8}},privacySection:{marginTop:e.spacing(2)}})))((e=>{let{classes:t,formName:a,customQuestions:s=[],contactInfoFields:i=[],verifyPhoneWithOtp:r=!1,privacyPolicyUrl:l,privacyPolicyLinkText:c,thankYouTitle:p,thankYouBody:u,thankYouButtonText:m,thankYouButtonType:g,connectedFlowName:b,previewMode:y="form",builderStep:x=0,greetingHeadline:f="",greetingDescription:A="",greetingEnabled:I=!0}=e;const C=I&&(f||A),_=(C?1:0)+s.length+(i.length>
10?1:0)+1,[S,v]=(0,n.useState)(0);(0,n.useEffect)((()=>{3===x&&v(_-1)}),[x,_]);let E=!1,T=!1,D=!1,w=!1,N=-1,j=0;return C&&(S===j&&(E=!0),j++),S>=j&&S<j+s.length&&(T=!0,N=S-j),j+=s.length,i.length>0&&(S===j&&(D=!0),j++),S===j&&(w=!0),(0,h.jsx)(o.Box,{className:t.previewContainer,children:(0,h.jsxs)(o.Box,{className:t.previewCard,children:[_>1&&(0,h.jsxs)(o.Box,{className:t.stepNavHeader,children:[(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>{S>0&&v(S-1)},disabled:0===S,className:t.navButton,children:(0,h.jsx)(d.ArrowBack,{fontSize:"small"})}),(0,h.jsxs)(o.Typography,{variant:"caption",color:"textSecondary",children:[S+1," of ",_]}),(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>{S<_-1&&v(S+1)},disabled:S>=_-1,className:t.navButton,children:(0,h.jsx)(d.ArrowForward,{fontSize:"small"})})]}),(0,h.jsx)(o.Box,{className:t.content,children:E?(0,h.jsxs)(o.Box,{className:t.greetingPreview,children:[a&&(0,h.jsx)(o.Typography,{variant:"h6",style:{marginBottom:16,fontWeight:600,textAlign:"center"},children:a}),f&&(0,h.jsx)(o.Typography,{variant:"h6",style:{marginBottom:12,fontWeight:600,textAlign:"center"},children:f}),A&&(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{whiteSpace:"pre-wrap",textAlign:"center"},children:A})]}):T&&N>=0?(0,h.jsx)(h.Fragment,{children:s[N]&&(0,h.jsxs)(o.Box,{className:t.questionPreviewItem,children:[(0,h.jsxs)(o.Box,{className:t.questionLabel,children:[nd(s[N].type),(0,h.jsxs)(o.Typography,{variant:"body2",style:{fontWeight:500},children:[sd(s[N]),s[N].isMandatory&&(0,h.jsx)("span",{style:{color:"#f44336"},children:" *"})]})]}),s[N].options&&s[N].options.length>0?(0,h.jsx)(o.Box,{className:t.optionsPreview,children:s[N].options.map(((e,a)=>(0,h.jsxs)(o.Box,{className:t.optionItem,children:[(0,h.jsx)(o.Box,{className:t.radioCircle}),(0,h.jsx)(o.Typography,{variant:"body2",children:e.value||`Option ${a+1}`})]},a)))}):(0,h.jsx)(o.TextField,{variant:"outlined",size:"small",fullWidth:!0,placeholder:sd(s[N]),disabled:!0,classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}}})]})}):D?(0,h.jsxs)(o.Box,{className:t.contactInfoPreview,children:[(0,h.jsx)(o.Typography,{variant:"body2",style:{fontWeight:500,marginBottom:16},children:"Contact Information"}),i.map(((e,a)=>(0,h.jsxs)(o.Box,{className:t.contactInfoField,style:{marginBottom:16},children:[(0,h.jsxs)(o.Box,{className:t.questionLabel,children:[nd(e.type),(0,h.jsxs)(o.Typography,{variant:"body2",style:{fontWeight:500},children:[sd({type:e.type}),e.isMandatory&&(0,h.jsx)("span",{style:{color:"#f44336"},children:" *"})]})]}),(0,h.jsx)(o.TextField,{variant:"outlined",size:"small",fullWidth:!0,placeholder:sd({type:e.type}),disabled:!0,classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding},endAdornment:(0,h.jsx)(o.InputAdornment,{position:"end",children:(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{fontSize:"10px"},children:"Auto-filled"})})}}),"PHONE"===e.type&&r&&(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{fontSize:"10px",marginTop:4,display:"block"},children:"Will be verified with OTP"})]},a))),l&&(0,h.jsx)(o.Box,{className:t.privacySection,style:{marginTop:16},children:(0,h.jsxs)(o.Typography,{variant:"caption",color:"textSecondary",style:{display:"flex",alignItems:"center",gap:4},children:[(0,h.jsx)(d.Info,{fontSize:"inherit"}),"By submitting, you agree to our"," ",(0,h.jsx)("a",{href:l,target:"_blank",rel:"noopener noreferrer",style:{color:"#1976D2",textDecoration:"underline"},children:c||"Privacy Policy"})]})})]}):w?(0,h.jsxs)(o.Box,{className:t.thankYouContainer,children:[(0,h.jsx)(o.Box,{className:t.logoPlaceholder,children:(0,h.jsx)(o.Box,{className:t.logoCircle})}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:8},children:a||"Company Name"}),(0,h.jsx)(o.Typography,{variant:"h6",className:t.thankYouTitle,children:p||"Thanks, you're all set."}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",className:t.thankYouBody,children:u||"You can visit our website or exit the form now."}),(0,h.jsx)(o.Box,{className:t.divider}
1),(0,h.jsxs)(o.Box,{className:t.successConfirmation,children:[(0,h.jsx)(d.Info,{className:t.infoIcon}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:"You successfully submitted your responses."})]})]}):(0,h.jsx)(o.Box,{className:t.emptyState,children:(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:"No content to preview"})})}),w&&g&&(0,h.jsx)(o.Box,{className:t.fixedButtonContainer,children:(0,h.jsx)(o.Button,{variant:"contained",fullWidth:!0,className:t.thankYouButton,startIcon:(k=g,{VIEW_WEBSITE:(0,h.jsx)(d.Language,{fontSize:"small"}),WHATSAPP:(0,h.jsx)(d.WhatsApp,{fontSize:"small"}),CALL_BUSINESS:(0,h.jsx)(d.PhoneInTalk,{fontSize:"small"}),DOWNLOAD:(0,h.jsx)(d.GetApp,{fontSize:"small"})}[k]||(0,h.jsx)(d.Language,{fontSize:"small"})),disabled:!0,children:m||"View website"})})]})});var k})),id=function(){return`${arguments.length>0&&void 0!==arguments[0]?arguments[0]:"id"}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`};function rd(e){let{classes:t,question:a,questionIndex:n,dragHandleProps:s,availableParameters:i,conditionalLogicEnabled:r,creatingParameterFor:l,generateKeyFromName:c,handleAddConditionalQuestion:p,handleAddOption:u,handleConditionalQuestionChange:m,handleCreateNewParameter:g,handleOptionChange:b,handleQuestionChange:y,handleRemoveConditionalQuestion:x,handleRemoveOption:f,mode:A,newParamKey:I,newParamName:C,setDrawerState:_}=e;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1,children:(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Switch,{size:"small",disabled:"edit"===A,checked:a.isMandatory||!1,onChange:e=>y(a.id,"isMandatory",e.target.checked),color:"primary"}),label:(0,h.jsx)(o.Typography,{variant:"caption",children:"Mandatory"})})}),("CUSTOM"===a.type||"DATE_TIME"===a.type)&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.Box,{mt:1.5,children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{marginBottom:4,display:"block"},children:"Question Label *"}),(0,h.jsx)(o.TextField,{fullWidth:!0,disabled:"edit"===A,variant:"outlined",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:"DATE_TIME"===a.type?"e.g., Appointment time":"e.g., What is your budget?",value:a.label||"",onChange:e=>y(a.id,"label",e.target.value)})]}),(0,h.jsxs)(o.Box,{mt:1.5,children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{marginBottom:4,display:"block"},children:"Map to Parameter"}),(0,h.jsxs)(o.TextField,{select:!0,fullWidth:!0,variant:"outlined",disabled:"edit"===A,classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:"Select parameter to map",value:a.mappedParameter||"",onChange:e=>{const t=e.target.value;if("create_new"===t){const e=a.label?.trim()||"",t=e?c(e):"";_({creatingParameterFor:a.id,newParamName:e,newParamKey:t})}else y(a.id,"mappedParameter",t||null)},SelectProps:{renderValue:e=>{if(!e)return"Don't map";if("create_new"===e)return"Create new parameter...";const t=i.find((t=>t.key===e));return t?t.name:e},displayEmpty:!0},children:[(0,h.jsx)(o.MenuItem,{value:"",children:(0,h.jsx)("em",{children:"Don't map"})}),(0,h.jsx)(o.MenuItem,{value:"create_new",children:"Create new parameter..."}),i.filter((e=>"CUSTOM"===e.type&&!e.archived)).map((e=>(0,h.jsx)(o.MenuItem,{value:e.key,children:e.name},e.key)))]})]}),l===a.id&&(0,h.jsxs)(o.Box,{mt:1.5,p:1.5,style:{border:"1px solid #e0e0e0",borderRadius:6,backgroundColor:"#f9f9fb"},children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{marginBottom:8,display:"block",fontWeight:500},children:"Create New Parameter"}),(0,h.jsxs)(o.Box,{mb:1.5,children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{marginBottom:4,display:"block"},children:"Parameter Name *"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",size:"small",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:"e.g., Budget Range",value:C,onChange:e=>{const t=e.target.value,a=c(t);_({newParamName:t,newParamKey:a})}})]}),(0,h.jsxs)(o.Box,{mb:1.5,children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{marginBottom:4,display:"block"},children:"Parameter Key *"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",size:"small",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:"e.g., budget_range",value:I,onChange:e=>{const t=e.target.value.toLowerCase().replace(/[^a-z0-9_]/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"");_({newParamKey:t})},helperText:"Lowercase letters, numbers, and underscores only"})]}),(0,h.jsxs)(o.Box,{display:"flex",gap:1,children:[(0,h.jsx)(o.Button,{size:"small",variant:"contained",color:"primary",onClick:async()=>{await g(a.id,C,I)},disabled:!C.trim()||!I.trim(),style:{textTransform:"none"},children:"Save Parameter"}),(0,h.jsx)(o.Button,{size:"small",variant:"outlined",onClick:()=>{_({creatingParameterFor:null,newParamName:"",newParamKey:""})},style:{textTransform:"none"},children:"Cancel"})]})]}),"DATE_TIME"===a.type&&(0,h.jsxs)(o.Box,{mt:1.5,children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{marginBottom:4,display:"block"}
1,children:"Inline Context"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:"We will verify and call you to confirm your appointment.",value:a.inline_context||"",onChange:e=>y(a.id,"inline_context",e.target.value)})]}),"CUSTOM"===a.type&&(0,h.jsx)(o.Box,{mt:1.5,children:(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Switch,{size:"small",disabled:"edit"===A,checked:a.isMultipleChoice||!1,onChange:e=>y(a.id,"isMultipleChoice",e.target.checked),color:"primary"}),label:(0,h.jsx)(o.Typography,{variant:"body2",children:"Multiple Choice Question"})})}),a.isMultipleChoice&&(0,h.jsxs)(o.Box,{mt:1.5,children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",gutterBottom:!0,style:{display:"block"},children:"Options *"}),(a.options||[]).map(((e,n)=>(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",gap:1,mb:1,children:[(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",disabled:"edit"===A,classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:`Option ${n+1}`,value:e.value,onChange:e=>b(a.id,n,e.target.value)}),"edit"!==A&&(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>f(a.id,n),children:(0,h.jsx)(d.Delete,{fontSize:"small"})}),a.isMultipleChoice&&r&&!a.conditionalQuestions?.[e.key]&&(0,h.jsx)(o.Button,{size:"small",onClick:t=>p(a.id,e.key,t),style:{textTransform:"none"},children:"Add Conditional"})]},n))),"edit"!==A&&(0,h.jsx)(o.Button,{size:"small",startIcon:(0,h.jsx)(d.Add,{}),onClick:()=>u(a.id),style:{textTransform:"none"},children:"Add Option"}),a.isMultipleChoice&&(!a.options||a.options.length<2)&&(0,h.jsx)(o.Typography,{variant:"caption",color:"error",style:{display:"block",marginTop:4},children:"Add at least 2 options for multiple choice"})]}),a.conditionalQuestions&&Object.keys(a.conditionalQuestions).length>0&&(0,h.jsxs)(o.Box,{mt:2,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",gutterBottom:!0,style:{marginBottom:12,fontWeight:500},children:"Conditional Questions"}),Object.entries(a.conditionalQuestions).map((e=>{let[n,s]=e;const r=a.options?.find((e=>e.key===n));return(0,h.jsxs)(o.Paper,{elevation:1,style:{marginBottom:12,padding:12,borderLeft:"3px solid #1976d2"},children:[(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1,children:[(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",gap:1,children:(0,h.jsx)(o.Chip,{label:`If "${r?.value||n}" is selected`,size:"small",variant:"outlined",color:"primary",style:{fontSize:"0.7rem",height:20}})}),(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>x(a.id,n),children:(0,h.jsx)(d.Delete,{fontSize:"small"})})]}),(0,h.jsx)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1,children:(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Switch,{size:"small",disabled:"edit"===A,checked:s.isMandatory||!1,onChange:e=>m(a.id,n,"isMandatory",e.target.checked),color:"primary"}),label:(0,h.jsx)(o.Typography,{variant:"caption",children:"Mandatory"})})}),("CUSTOM"===s.type||"DATE_TIME"===s.type)&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.Box,{mt:1.5,children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{marginBottom:4,display:"block"},children:"Question Label *"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:"DATE_TIME"===s.type?"e.g., Appointment time":"e.g., What is your budget?",value:s.label||"",onChange:e=>m(a.id,n,"label",e.target.value)})]}),"CUSTOM"===s.type&&(0,h.jsxs)(o.Box,{mt:1.5,children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{marginBottom:4,display:"block"},children:"Map to Parameter"}),(0,h.jsxs)(o.TextField,{select:!0,fullWidth:!0,variant:"outlined",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:"Select parameter to map",value:s.mappedParameter||"",onChange:e=>{const t=e.target.value;if("create_new"===t){const e=s.label?.trim()||"",t=e?c(e):"";_({creatingParameterFor:`${a.id}_${n}`,newParamName:e,newParamKey:t})}else m(a.id,n,"mappedParameter",t||null)},SelectProps:{renderValue:e=>{if(!e)return"Don't map";if("create_new"===e)return"Create new parameter...";const t=i.find((t=>t.key===e));return t?t.name:e},displayEmpty:!0},children:[(0,h.jsx)(o.MenuItem,{value:"",children:(0,h.jsx)("em",{children:"Don't map"})}),(0,h.jsx)(o.MenuItem,{value:"create_new",children:"Create new parameter..."}),i.filter((e=>"CUSTOM"===e.type&&!e.archived)).map((e=>(0,h.jsx)(o.MenuItem,{value:e.key,children:e.name},e.key)))]})]}),l===`${a.id}_${n}`&&(0,h.jsxs)(o.Box,{mt:1.5,p:1.5,style:{border:"1px solid #e0e0e0",borderRadius:6,backgroundColor:"#f9f9fb"},children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{marginBottom:8,display:"block",fontWeight:500},children:"Create New Parameter"}),(0,h.jsxs)(o.Box,{mb:1.5,children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{marginBottom:4,display:"block"},children:"Parameter Name *"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",size:"small",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:"e.g., Budget Range",value:C,onChange:e=>{const t=e.target.value,a=c(t);_({newParamName:t,newParamKey:a})}})]}),(0,h.jsxs)(o.Box,{mb:1.5,children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{marginBottom:4,display:"block"},children:"Parameter Key *"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",size:"small",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:"e.g., budget_range",value:I,onChange:e=>{const t=e.target.value.toLowerCase().replace(/[^a-z0-9_]/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"");_({newParamKey:t})},helperText:"Lowercase letters, numbers, and underscores only"})]}),(0,h.jsxs)(o.Box,{display:"flex",gap:1,children:[(0,h.jsx)(o.Button,{size:"small",variant:"contained",color:"primary",onClick:async()=>{const e=await g(`${a.id}_${n}`,C,I);e&&m(a.id,n,"mappedParameter",e)},disabled:!C.trim()||!I.trim(),style:{textTransform:"none"},children:"Save Parameter"}),(0,h.jsx)(o.Button,{size:"small",variant:"outlined",onClick:()=>{_({creatingParameterFor:null,newParamName:"",newParamKey:""})},style:{textTransform:"none"},children:"Cancel"})]})]}),"DATE_TIME"===s.type&&(0,h.jsxs)(o.Box,{mt:1.5,children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",style:{marginBottom:4,display:"block"}
1,children:"Inline Context"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:"We will verify and call you to confirm your appointment.",value:s.inline_context||"",onChange:e=>m(a.id,n,"inline_context",e.target.value)})]}),"CUSTOM"===s.type&&(0,h.jsx)(o.Box,{mt:1.5,children:(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Switch,{size:"small",disabled:"edit"===A,checked:s.isMultipleChoice||!1,onChange:e=>m(a.id,n,"isMultipleChoice",e.target.checked),color:"primary"}),label:(0,h.jsx)(o.Typography,{variant:"body2",children:"Multiple Choice Question"})})})]}),s.isMultipleChoice&&"CUSTOM"===s.type&&(0,h.jsxs)(o.Box,{mt:1.5,children:[(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",gutterBottom:!0,style:{display:"block"},children:"Options *"}),(s.options||[]).map(((e,i)=>(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",gap:1,mb:1,children:[(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:`Option ${i+1}`,value:e.value,onChange:t=>{const o=[...s.options||[]];o[i]={...e,value:t.target.value},m(a.id,n,"options",o)}}),(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>{const e=(s.options||[]).filter(((e,t)=>t!==i));m(a.id,n,"options",e)},children:(0,h.jsx)(d.Delete,{fontSize:"small"})})]},i))),(0,h.jsx)(o.Button,{size:"small",startIcon:(0,h.jsx)(d.Add,{}),onClick:()=>{const e=[...s.options||[],{value:"",key:id("opt")}];m(a.id,n,"options",e)},style:{textTransform:"none"},children:"Add Option"}),(!s.options||s.options.length<2)&&(0,h.jsx)(o.Typography,{variant:"caption",color:"error",style:{display:"block",marginTop:4},children:"Add at least 2 options for multiple choice"})]})]},n)}))]})]})]})}function ld(e){let{conditionalQuestionMenuAnchor:t,handleCreateConditionalQuestion:a,hasAppointmentQuestion:n,onClose:s,open:i,setDrawerState:r}=e;return(0,h.jsxs)(o.Menu,{anchorEl:t,open:Boolean(t),onClose:()=>r({conditionalQuestionMenuAnchor:null,conditionalQuestionParentId:null,conditionalQuestionOptionKey:null}),children:[(0,h.jsx)(o.MenuItem,{onClick:()=>{a("SHORT_ANSWER"),r({conditionalQuestionMenuAnchor:null})},children:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"body2",children:"Short answer"}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:"Get additional info in a sentence or 2"})]})}),(0,h.jsx)(o.MenuItem,{onClick:()=>{a("MULTIPLE_CHOICE"),r({conditionalQuestionMenuAnchor:null})},children:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"body2",children:"Multiple choice"}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:"Add questions and conditional logic to filter leads"})]})}),!n()&&(0,h.jsx)(o.MenuItem,{onClick:()=>{a("DATE_TIME"),r({conditionalQuestionMenuAnchor:null})},children:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"body2",children:"Appointment time"}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:"Let people request a time to meet with you"})]})})]})}function dd(e){let{blockDisplayForNonTargetedViewer:t,classes:a,error:n,getStepValidation:s,handleButtonTypeChange:i,setDrawerState:r,thankYouBody:l,thankYouButtonText:d,thankYouButtonType:c,thankYouPhoneNumber:p,thankYouTitle:u,thankYouWebsiteUrl:m}=e;return(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"subtitle1",gutterBottom:!0,style:{fontWeight:500},children:"Completion"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:12},children:"Customize the thank you page shown after form submission"}),(0,h.jsxs)(o.Grid,{container:!0,spacing:2,children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:4},children:"Title"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:a.TextFieldRoot},InputProps:{classes:{input:a.inputPadding}},placeholder:"Thank you!",value:u,onChange:e=>r({thankYouTitle:e.target.value})})]}),(0,h.jsxs)(o.Grid,{item:!0,xs:12,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:4},children:"Body"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:a.TextFieldRoot},InputProps:{classes:{input:a.inputPadding}},placeholder:"We'll be in touch shortly.",multiline:!0,rows:2,value:l,onCh
1ange:e=>r({thankYouBody:e.target.value})})]}),(0,h.jsxs)(o.Grid,{item:!0,xs:6,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:4},children:"Button Type"}),(0,h.jsx)(o.TextField,{select:!0,fullWidth:!0,variant:"outlined",classes:{root:a.TextFieldRoot},InputProps:{classes:{input:a.inputPadding},style:{height:"40px"}},value:c||"",onChange:e=>i(e.target.value),SelectProps:{renderValue:e=>{const t=ea.O2.find((t=>t.value===e));return t?t.label:""},displayEmpty:!0},children:ea.O2.map((e=>(0,h.jsx)(o.MenuItem,{value:e.value,children:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"body2",children:e.label}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:e.description})]})},e.value)))})]}),(0,h.jsxs)(o.Grid,{item:!0,xs:6,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:4},children:"Button Text"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:a.TextFieldRoot},InputProps:{classes:{input:a.inputPadding},style:{height:"40px"}},placeholder:"Visit Website",value:d,onChange:e=>r({thankYouButtonText:e.target.value})})]}),"VIEW_WEBSITE"===c&&(0,h.jsxs)(o.Grid,{item:!0,xs:12,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:4},children:"Website URL *"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:a.TextFieldRoot},InputProps:{classes:{input:a.inputPadding}},placeholder:"https://yoursite.com",value:m,onChange:e=>r({thankYouWebsiteUrl:e.target.value}),onBlur:()=>r({thankYouWebsiteUrl:(0,ea.iP)(m)}),error:!s().ending}),!s().ending&&(0,h.jsx)(o.Typography,{variant:"caption",color:"error",style:{marginTop:4,display:"block"},children:m.trim()?"Please enter a valid URL (e.g., https://example.com)":"Website URL is required"})]}),"CALL_BUSINESS"===c&&(0,h.jsxs)(o.Grid,{item:!0,xs:12,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:4},children:"Business Phone Number *"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:a.TextFieldRoot},InputProps:{classes:{input:a.inputPadding}},placeholder:"+1234567890",value:p,onChange:e=>r({thankYouPhoneNumber:e.target.value}),error:!s().ending}),!s().ending&&(0,h.jsx)(o.Typography,{variant:"caption",color:"error",style:{marginTop:4,display:"block"},children:"Business Phone Number is required"})]})]}),(0,h.jsxs)(o.Box,{mt:2,children:[(0,h.jsx)(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Advanced Settings"}),(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Switch,{checked:t,onChange:e=>r({blockDisplayForNonTargetedViewer:e.target.checked}),color:"primary"}),label:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"body2",children:"Filter Organic Leads"}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:"Only show form to ad viewers"})]})})]})]})}function cd(e){let{assistantId:t,error:a,onClose:n,reconnectRequired:s,setDrawerState:i,success:r,tosLink:l}=e;return(0,h.jsxs)(h.Fragment,{children:[a&&(0,h.jsx)(O.Alert,{severity:"error",onClose:()=>i({error:null,tosLink:null,reconnectRequired:!1}),style:{marginBottom:12},children:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"body2",children:a}),l&&(0,h.jsx)(o.Button,{href:l,target:"_blank",rel:"noopener noreferrer",color:"primary",size:"small",style:{marginTop:8,textTransform:"none"},endIcon:(0,h.jsx)(d.OpenInNew,{fontSize:"small"}),children:"Accept Lead Generation Terms of Service"}),s&&(0,h.jsx)(o.Button,{color:"primary",size:"small",style:{marginTop:8,textTransform:"none"},onClick:()=>{n(),t&&(window.location.href=`${Xe(t)}`)},children:"Reconnect Meta Account"})]})}),r&&(0,h.jsx)(O.Alert,{severity:"success",onClose:()=>i({success:null}),style:{marginBottom:12},children:r})]})}function pd(e){let{classes:t,currentStep:a,handleCreateForm:n,handleUpdateAutomation:s,isCreating:i,isFormValid:r,isUpdating:l,mode:d,onClose:c,setDrawerState:p}=e;return(0,h.jsx)(o.Box,{className:t.footer,children:"edit"===d?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Button,{variant:"outlined",onClick:c,style:{textTransform:"none"},children:"Cancel"}),(0,h.jsx)(o.Button,{variant:"contained",color:"primary",onClick:s,disabled:l,style:{textTransform:"none"},children:l?"Saving...":"Save Changes"})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Button,{variant:"outlined",onClick:()=>{a>0&&p({currentStep:a-1})},disabled:0===a,style:{textTransform:"none"},children:"Previous"}),(0,h.jsx)(o.Box,{display:"flex",gap:1,children:a<4?(0,h.jsx)(o.Button,{variant:"contained",color:"primary",onClick:()=>{a<4&&p({currentStep:a+1})},style:{textTransform:"none"},children:"Next"}):(0,h.jsx)(o.Button,{variant:"contained",color:"primary",onClick:n,disabled:i||!r(),style:{textTransform:"none"},children:i?"Creating...":"Create Form"})})]})})}function ud(e){let{classes:t,error:a,formName:n,formType:s,getStepValidation:i,greetingDescription:r,greetingEnabled:l,greetingHeadline:
1d,mode:c,setDrawerState:p,verifyPhoneWithOtp:u}=e;return(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"subtitle1",gutterBottom:!0,style:{fontWeight:500},children:"Intro • Optional"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:12},children:"Add a greeting to introduce your form"}),(0,h.jsxs)(o.Box,{mb:1.5,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:4},children:"Form Name *"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:"Enter form name",value:n,onChange:e=>p({formName:e.target.value}),disabled:"edit"===c})]}),(0,h.jsxs)(o.Box,{mb:2,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:4},children:"Form type"}),(0,h.jsxs)(o.RadioGroup,{value:s||"more_volume",onChange:e=>p({formType:e.target.value,..."higher_intent"!==e.target.value&&{verifyPhoneWithOtp:!1}}),children:[(0,h.jsx)(o.FormControlLabel,{value:"more_volume",control:(0,h.jsx)(o.Radio,{color:"primary",size:"small"}),disabled:"edit"===c,label:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"body2",children:"More volume"}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:"Use a form that's quick to fill in and submit on a mobile device."})]}),style:{alignItems:"flex-start",marginBottom:8}}),(0,h.jsx)(o.FormControlLabel,{value:"higher_intent",control:(0,h.jsx)(o.Radio,{color:"primary",size:"small"}),disabled:"edit"===c,label:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"body2",children:"Higher intent"}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:"Add a review step that gives people a chance to confirm their info."})]}),style:{alignItems:"flex-start"}})]}),"higher_intent"===s&&(0,h.jsx)(o.Box,{pl:4,mt:.5,children:(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Checkbox,{checked:u,onChange:e=>p({verifyPhoneWithOtp:e.target.checked}),color:"primary",size:"small",disabled:"edit"===c}),label:(0,h.jsx)(o.Typography,{variant:"caption",children:"Require leads to verify their phone number with a one-time passcode."})})})]}),(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Switch,{checked:!1!==l,onChange:e=>p({greetingEnabled:e.target.checked}),color:"primary",disabled:"edit"===c}),label:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"body2",children:"Greeting"}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:"Add a headline and description to introduce your form"})]}),style:{marginBottom:16}}),!1!==l&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.Box,{mb:1.5,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:4},children:"Headline *"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:"Enter headline",value:d||"",onChange:e=>p({greetingHeadline:e.target.value}),inputProps:{maxLength:60},error:!i().intro&&!(d||"").trim(),disabled:"edit"===c}),!i().intro&&!(d||"").trim()&&(0,h.jsx)(o.Typography,{variant:"caption",color:"error",style:{marginTop:4,display:"block"},children:"Headline is required when greeting is enabled"}),d&&(0,h.jsxs)(o.Typography,{variant:"caption",color:"textSecondary",style:{marginTop:4,display:"block"},children:[(d||"").length,"/60"]})]}),(0,h.jsxs)(o.Box,{mb:1.5,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:4},children:"Description *"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:"Enter description",value:r||"",onChange:e=>p({greetingDescription:e.target.value}),error:!i().intro&&!(r||"").trim(),multiline:!0,rows:2,disabled:"edit"===c}),!i().intro&&!(r||"").trim()&&(0,h.jsx)(o.Typography,{variant:"caption",color:"error",style:{marginTop:4,display:"block"},children:"Description is required when greeting is enabled"})]})]})]})}function md(e){let{currentStep:t,existingForms:a,isLoadingForms:n,loadFormForEdit:s,mode:i,setDrawerState:r}=e;return(0,h.jsxs)(o.Box,{children:[(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[(0,h.jsx)(o.Typography,{variant:"h6",children:"Existing Lead Forms"}),(0,h.jsx)(o.Button,{variant:"contained",color:"primary",startIcon:(0,h.jsx)(d.Add,{}),onClick:()=>r({mode:"create",currentStep:0}),style:{textTransform:"none"},children:"Create New Form"})]}),n?(0,h.jsx)(o.Box,{display:"flex",justifyContent:"center",p:4,children:(0,h.jsx)(o.CircularProgress,{})}):0===a.length?(0,h.jsx)(o.Box,{p:3,textAlign:"center",children:(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:"No lead forms found. Create one to get started."})}):(0,h.jsx)(o.List,{children:a.map((e=>(0,h.jsx)(o.Paper,{style:{marginBottom:8},children:(0,h.jsxs)(o.ListItem,{children:[(0,h.jsx)(o.ListItemText,{primary:e.name,secondary:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Chip,{label:e.status||"ACTIVE",size:"small",style:{marginRight:8,height:20,fontSize:"0.7rem"}}),(0,h.jsx)(o.Chip,{label:e.automation?.enabled?"Automation Enabled":"No Automation",size:"small",color:e.automation?.enabled?"primary":"default",style:{height:20,fontSize:"0.7rem"}})]})}),(0,h.jsx)(o.ListItemSecondaryAction,{children:(0,h.jsx)(o.Button,{variant:"outlined",size:"small",startIcon:(0,h.jsx)(d.Edit,{}),onClick:()=>s(e),style:{textTransform:"none"},children:"Edit Automation"})})]})},e.formId)))})]})}function hd(e){let{automationPreviewData:t,classes:a,contactInfoFields:n,currentStep:s,customQuestions:i,formName:r,greetingDescription:l,greetingEnabled:d,greetingHeadline:c,previewCarou
1selIndex:p,previewMode:u,privacyPolicyLinkText:m,privacyPolicyUrl:g,setDrawerState:b,thankYouBody:y,thankYouButtonText:x,thankYouButtonType:f,thankYouTitle:A,verifyPhoneWithOtp:I}=e;return(0,h.jsx)(o.Grid,{item:!0,xs:12,md:5,children:(0,h.jsx)(o.Box,{style:{position:"sticky",top:20,display:"flex",justifyContent:"center",alignItems:"flex-start",width:"100%"},children:4===s&&t?.selectedTemplate?(0,h.jsx)(o.Box,{style:{width:"100%",maxWidth:340,padding:"16px"},children:(0,h.jsx)(ad,{media:t.media||{},parameters:t.parameters||[],selectedTemplate:t.selectedTemplate,showDisclaimer:!0,carouselIndex:p,setCarouselIndex:e=>{b({previewCarouselIndex:e})},cards:t.cards||[],formattedButtons:[]})}):4===s?(0,h.jsx)(o.Box,{style:{width:"100%",maxWidth:320,padding:"16px"},children:(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",align:"center",children:"Select a template to see preview"})}):(0,h.jsx)(o.Box,{style:{width:"100%",maxWidth:320},children:(0,h.jsx)(od,{classes:a,formName:r,customQuestions:i,contactInfoFields:n.filter((e=>e.enabled)),verifyPhoneWithOtp:I,privacyPolicyUrl:g,privacyPolicyLinkText:m,thankYouTitle:A,thankYouBody:y,thankYouButtonText:x,thankYouButtonType:f,previewMode:u,builderStep:s,greetingHeadline:c,greetingDescription:l,greetingEnabled:d})})})})}function gd(e){let{classes:t,error:a,getStepValidation:n,privacyPolicyLinkText:s,privacyPolicyUrl:i,setDrawerState:r}=e;return(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"subtitle1",gutterBottom:!0,style:{fontWeight:500},children:"Privacy Policy"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:12},children:"Add your privacy policy URL and link text"}),(0,h.jsxs)(o.Box,{mb:1.5,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:4},children:"Privacy Policy URL *"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:"https://yoursite.com/privacy",value:i,onChange:e=>r({privacyPolicyUrl:e.target.value}),error:!n().privacy}),!n().privacy&&(0,h.jsx)(o.Typography,{variant:"caption",color:"error",style:{marginTop:4,display:"block"},children:"Privacy Policy URL is required"})]}),(0,h.jsxs)(o.Box,{mb:1.5,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:4},children:"Link Text"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},placeholder:"Privacy Policy",value:s,onChange:e=>r({privacyPolicyLinkText:e.target.value})})]})]})}function bd(e){let{availableParameters:t,categoryDropdownAnchor:a,classes:n,conditionalLogicEnabled:s,contactInfoDescription:i,contactInfoFields:r,creatingParameterFor:l,customQuestions:c,formType:p,generateKeyFromName:u,getQuestionTypeDisplayName:m,getStepValidation:g,handleAddFieldFromCategory:b,handleAddConditionalQuestion:y,handleAddOption:x,handleConditionalQuestionChange:f,handleOptionChange:A,handleQuestionChange:I,handleRemoveConditionalQuestion:C,handleRemoveOption:_,handleAddQuestion:S,handleContactFieldParameterChange:v,handleCreateNewParameter:E,handleDragEnd:T,handleRemoveContactField:D,handleRemoveQuestion:w,hasConditionalQuestions:N,mode:j,newParamKey:k,newParamName:L,onClose:R,open:B,questionDropdownAnchor:O,setDrawerState:P,submenuAnchor:M,submenuCategory:U,verifyPhoneWithOtp:F}=e;return(0,h.jsxs)(o.Box,{children:[(0,h.jsxs)(o.Box,{mb:1.5,children:[(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"subtitle1",gutterBottom:!0,style:{fontWeight:500},children:"Questions • Optional"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:"Add questions to your form to better understand your leads"})]}),(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",gap:1,style:{minWidth:150,justifyContent:"flex-end"}})]}),(0,h.jsx)(o.Box,{style:{minHeight:20,marginTop:4},children:!g().questions&&s&&(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:"At least one multiple choice question is required when conditional logic is enabled"})})]}),c.length>0&&(0,h.jsx)(o.Box,{mb:2,children:(0,h.jsx)(Fo.JY,{onDragEnd:T,children:(0,h.jsx)(Fo.gL,{droppableId:"customQuestions",type:"QUESTION",children:e=>(0,h.jsxs)(o.Box,{...e.droppableProps,ref:e.innerRef,children:[c.map(((e,a)=>(0,h.jsx)(Fo.sx,{draggableId:e.id,index:a,isDragDisabled:"edit"===j,children:(i,r)=>(0,h.jsxs)(o.Paper,{ref:i.innerRef,...i.draggableProps,elevation:r.isDragging?4:1,style:{marginBottom:8,padding:8,backgroundColor:r.isDragging?"#f5f5f5":"white",...i.draggableProps.style},children:[(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1,children:[(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",gap:1,children:[(0,h.jsx)(o.Box,{...i.dragHandleProps,style:{cursor:"grab"},children:(0,h.jsx)(d.DragIndicator,{fontSize:"small",color:"disabled"})}),(0,h.jsxs)(o.Typography,{variant:"caption",color:"textSecondary",children:["Step ",a+1]}),"CUSTOM"===e.type&&(0,h.jsx)(o.Chip,{label:m(e),size:"small",variant:"outlined",style:{marginLeft:8,height:20,fontSize:"0.65rem"}}),"DATE_TIME"===e.type&&(0,h.jsx)(o.Chip,{label:m(e),size:"small",variant:"outlined",style:{marginLeft:8,height:20,fontSize:"0.65rem"}})]}),(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>w(e.id),style:{padding:4},title:"Delete question",children:"edit"!==j&&(0,h.jsx)(d.Delete,{fontSize:"small"})})]}),(0,h.jsx)(rd,{classes:n,question:e,questionIndex:a,dragHandleProps:i,availableParameters:t,conditionalLogicEnabled:s,creatingParameterFor:l,mode:j,newParamKey:k,newParamName:L,generateKeyFromName:u,handleAddConditionalQuestion:y,handleAddOption:x,handleConditionalQuestionChange:f,handleCreateNewParameter:E,handleOptionChange:A,handleQuestionChange:I,handleRemoveConditionalQuestion:C,handleRemoveOption:_,setDrawerState:P})]})},e.id))),e.placeholder]})})})}),(0,h.jsxs)(o.Box,{mb:2,children:["edit"!==j&&(0,h.jsx)(o.Button,{variant:"outlined",startIcon:(0,h.jsx)(d.Add,{}),onClick:e=>{const t=e.currentTarget;P({questionDropdownAnchor:t})},style:{textTransform:"none"},children:"Add question"}),O&&(0,h.jsxs)(o.Menu,{anchorEl:O,open:Boolean(O),onClose:()=>P({questionDropdownAnchor:null}),children:[(0,h.jsx)(o.MenuItem,{onClick:()=>{S("MULTIPLE_CHOICE"),P({questionDropdownAnchor:null})},children:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"body2",children:"Multiple choice"}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:"Add questions and conditional logic to filter leads"})]})}),(0,h.jsx)(o.MenuItem,{onClick:()=>{S("SHORT_ANSWER"),P({questionDropdownAnchor:null})},children:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"body2",children:"Short answer"}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:"Get additional info in a sentence or 2"})]})}),(0,h.jsx)(o.MenuItem,{onClick:()=>{S("DATE_TIME"),P({questionDropdownAnchor:null})},children:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"body2",children:"Appointment time"}),(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:"Let people request a time to meet with you"})]})})]})]}),(0,h.jsxs)(o.Box,{mb:1.5,children:[(0,h.jsx)(o.Typography,{variant:"subtitle1",style:{fontWeight:500},gutterBottom:!0,children:"Contact information"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:8,display:"block"}
1,children:"Ask for contact information and additional personal details. This will be prefilled from their Facebook account."}),(0,h.jsxs)(o.Box,{mb:1.5,children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:4},children:"Description"}),(0,h.jsx)(o.TextField,{fullWidth:!0,variant:"outlined",classes:{root:n.TextFieldRoot},InputProps:{classes:{input:n.inputPadding}},placeholder:"Let people know how the information that they give you will be used or shared. See examples",value:i||"",onChange:e=>P({contactInfoDescription:e.target.value}),multiline:!0,rows:2})]}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:8,fontWeight:500},children:"Contact Information Fields"}),r.filter((e=>e.enabled)).length>0?(0,h.jsx)(o.Box,{children:r.filter((e=>e.enabled)).map((e=>{const a=ea.Ty.find((t=>t.value===e.type));if(!a)return null;const s="FULL_NAME"===e.type||"PHONE"===e.type;return(0,h.jsxs)(o.Box,{mb:1,p:1,style:{border:"1px solid #e0e0e0",borderRadius:6,backgroundColor:"#f9f9fb"},children:[(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,h.jsxs)(o.Box,{display:"flex",flexDirection:"column",gap:.5,flex:1,children:[(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",gap:.5,children:[e.locked&&(0,h.jsx)(d.Lock,{fontSize:"small",color:"disabled"}),(0,h.jsxs)(o.Typography,{variant:"caption",style:{fontWeight:500},children:[a.label,e.isMandatory&&(0,h.jsx)("span",{children:" *"})]})]}),e.locked?(0,h.jsx)(o.Chip,{label:`Parameter: ${e.type}`,size:"small",style:{height:20,fontSize:"0.65rem",backgroundColor:"#f5f5f5",color:"#666",alignSelf:"flex-start"}}):(0,h.jsxs)(o.Box,{mt:.5,children:[(0,h.jsxs)(o.TextField,{select:!0,size:"small",variant:"outlined",fullWidth:!0,value:e.mappedParameter||"",onChange:t=>{const n=t.target.value;if("create_new"===n){const t=a.label||e.type,n=u(t);P({creatingParameterFor:`contact_${e.type}`,newParamName:t,newParamKey:n,creatingParameterForFieldType:e.type})}else v(e.type,n)},SelectProps:{displayEmpty:!0,renderValue:e=>{if(!e)return"Don't map";if("create_new"===e)return"Create new parameter...";const a=t.find((t=>t.key===e));return a?a.name:e}},style:{minWidth:200},classes:{root:n.TextFieldRoot},InputProps:{classes:{input:n.inputPadding}},children:[(0,h.jsx)(o.MenuItem,{value:"",children:"Don't map"}),t.map((e=>(0,h.jsxs)(o.MenuItem,{value:e.key,children:[e.name," (",e.key,")"]},e.key))),(0,h.jsx)(o.MenuItem,{value:"create_new",children:"Create new parameter..."})]}),l===`contact_${e.type}`&&(0,h.jsxs)(o.Box,{mt:1,p:1,style:{border:"1px solid #e0e0e0",borderRadius:4,backgroundColor:"#fafafa"},children:[(0,h.jsx)(o.TextField,{fullWidth:!0,size:"small",variant:"outlined",label:"Parameter Name",value:L,onChange:e=>P({newParamName:e.target.value}),style:{marginBottom:8},classes:{root:n.TextFieldRoot},InputProps:{classes:{input:n.inputPadding}}}),(0,h.jsx)(o.TextField,{fullWidth:!0,size:"small",variant:"outlined",label:"Parameter Key",value:k,onChange:e=>P({newParamKey:e.target.value}),helperText:"Lowercase letters, numbers, and underscores only. Must start with a letter.",style:{marginBottom:8},classes:{root:n.TextFieldRoot},InputProps:{classes:{input:n.inputPadding}}}),(0,h.jsxs)(o.Box,{display:"flex",gap:1,children:[(0,h.jsx)(o.Button,{size:"small",variant:"contained",color:"primary",onClick:async()=>{await E(`contact_${e.type}`,L,k)},children:"Save Parameter"}),(0,h.jsx)(o.Button,{size:"small",onClick:()=>{P({creatingParameterFor:null,newParamName:"",newParamKey:"",creatingParameterForFieldType:null})},children:"Cancel"})]})]})]})]}),!s&&(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>D(e.type),style:{padding:4},children:(0,h.jsx)(d.Delete,{fontSize:"small"})})]}),"PHONE"===e.type&&"higher_intent"===p&&F&&(0,h.jsx)(o.Box,{mt:.5,pl:4,children:(0,h.jsx)(o.Typography,{variant:"caption",color:"textSecondary",children:"Verified with a one-time passcode (set under Form type)"})})]},e.type)}))}):(0,h.jsx)(o.Box,{mb:2,children:(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:'No contact fields added yet. Use "Add category" below to add fields.'})}),(0,h.jsxs)(o.Box,{mb:1.5,children:[(0,h.jsx)(o.Button,{variant:"outlined",startIcon:(0,h.jsx)(d.Add,{}),onClick:e=>{const t=e.currentTarget;P({categoryDropdownAnchor:t})},style:{textTransform:"none"},children:"Add category"}),(0,h.jsx)(o.Menu,{anchorEl:a,open:Boolean(a),onClose:()=>P({categoryDropdownAnchor:null,submenuAnchor:null,submenuCategory:null}),getContentAnchorEl:null,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:ea.mf.map((e=>(0,h.jsx)(o.MenuItem,{onMouseEnter:t=>{P({submenuAnchor:t.currentTarget,submenuCategory:e.id})},style:{minWidth:180},children:(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",children:[(0,h.jsx)(o.Typography,{variant:"body2",children:e.label}),(0,h.jsx)(d.ArrowForward,{fontSize:"small",style:{marginLeft:8,fontSize:14}})]})},e.id)))}),(0,h.jsx)(o.Menu,{anchorEl:M,open:Boolean(M)&&Boolean(U),onClose:()=>P({submenuAnchor:null,submenuCategory:null}),getContentAnchorEl:null,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},style:{pointerEvents:"none"},PaperProps:{style:{pointerEvents:"auto"}},children:U&&ea.mf.find((e=>e.id===U))?.types.map((e=>{const t=ea.Ty.find((t=>t.value===e));if(!t)return null;const a=r.find((t=>t.type===e)),n=a?.enabled;return(0,h.jsx)(o.MenuItem,{onClick:()=>b(e),disabled:a?.locked||n,style:{minWidth:150},children:(0,h.jsxs)(o.Typography,{variant:"body2",children:[t.label,n&&(0,h.jsx)("span",{style:{color:"#999",marginLeft:8},children:"(Added)"})]})},e)}))})]})]})]})}function yd(e){let{classes:t,currentStep:a,getStepValidation:n,mode:s,setDrawerState:i}=e;
1return(0,h.jsx)(o.Box,{className:t.sidebar,children:[{id:0,label:"Intro",icon:null},{id:1,label:"Questions",icon:null},{id:2,label:"Privacy Policy",icon:null},{id:3,label:"Completion",icon:null},{id:4,label:"Automation",icon:null}].map((e=>{const r=n();let l=!0;0===e.id?l=r.intro:1===e.id?l=r.questions:2===e.id?l=r.privacy:3===e.id?l=r.ending:4===e.id&&(l=!0);const c=a===e.id,p="edit"===s&&4!==e.id;return(0,h.jsxs)(o.Box,{className:t.stepItem,onClick:()=>i({currentStep:e.id}),style:{backgroundColor:c?"#ebf5f3":"transparent",cursor:"pointer",opacity:p?.6:1},children:[(0,h.jsx)(o.Box,{className:t.stepIndicator,style:{backgroundColor:c?"#0a474c":"#E0E0E0"}}),(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",children:[(0,h.jsx)(o.Typography,{variant:"body1",style:{color:c?"#0a474c":"#666",fontWeight:c?600:400,fontSize:"0.9375rem"},children:e.label}),p&&(0,h.jsx)(d.Lock,{fontSize:"small",style:{color:"#999",fontSize:"14px"}})]})]},e.id)}))})}const xd=()=>{const e=new Date;return`Untitled Form ${e.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} ${e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0})}`},fd=()=>ea.Ty.map((e=>({type:e.value,enabled:"FULL_NAME"===e.value||"PHONE"===e.value,isMandatory:"FULL_NAME"===e.value||"PHONE"===e.value,locked:e.locked||!1,mappedParameter:null})));class Ad extends n.Component{constructor(e){super(e),this.getAutomationConfigRef=null,this.state={formName:xd(),customQuestions:[],contactInfoFields:fd(),formType:"more_volume",verifyPhoneWithOtp:!1,privacyPolicyUrl:"",privacyPolicyLinkText:"Privacy Policy",draggedItem:null,thankYouTitle:"Thank you!",thankYouBody:"We'll be in touch shortly.",thankYouButtonType:"VIEW_WEBSITE",thankYouButtonText:"Visit Website",thankYouWebsiteUrl:"",thankYouPhoneNumber:"",thankYouDownloadFileUrl:"",isOptimizedForQuality:!1,blockDisplayForNonTargetedViewer:!1,isCreating:!1,error:null,tosLink:null,reconnectRequired:!1,success:null,currentStep:0,automation:null,previewMode:"form",mode:"create",editingForm:null,existingForms:[],isLoadingForms:!1,isUpdating:!1,greetingEnabled:!0,greetingHeadline:"",greetingDescription:"",descriptionType:"PARAGRAPH",conditionalLogicEnabled:!1,questionDropdownAnchor:null,categoryDropdownAnchor:null,submenuAnchor:null,submenuCategory:null,contactInfoDescription:"",availableParameters:[],isLoadingParameters:!1,creatingParameterFor:null,newParamName:"",newParamKey:"",automationPreviewData:{selectedTemplate:null,parameters:[],media:{},cards:[],carouselIndex:0},previewCarouselIndex:0,conditionalQuestionMenuAnchor:null,conditionalQuestionParentId:null,conditionalQuestionOptionKey:null}}setDrawerState=(()=>{var e=this;return function(){return e.setState(...arguments)}})();componentDidMount(){this.fetchAvailableParameters(),this.props.editMode&&this.props.editForm?this.loadFormForEdit(this.props.editForm):"manage"===this.props.initialView&&(this.setState({mode:"manage"}),this.fetchExistingForms())}componentDidUpdate(e){!e.open&&this.props.open&&(this.props.editMode&&this.props.editForm?this.loadFormForEdit(this.props.editForm):"manage"===this.props.initialView?(this.setState({mode:"manage"}),this.fetchExistingForms()):this.setState({mode:"create",currentStep:0,formName:xd(),customQuestions:[],contactInfoFields:fd(),formType:"more_volume",verifyPhoneWithOtp:!1,privacyPolicyUrl:"",privacyPolicyLinkText:"Privacy Policy",thankYouTitle:"Thank you!",thankYouBody:"We'll be in touch shortly.",thankYouButtonType:"VIEW_WEBSITE",thankYouButtonText:"Visit Website",thankYouWebsiteUrl:"",thankYouPhoneNumber:"",isOptimizedForQuality:!1,blockDisplayForNonTargetedViewer:!1,greetingEnabled:!0,greetingHeadline:"",greetingDescription:"",descriptionType:"PARAGRAPH",conditionalLogicEnabled:!1,contactInfoDescription:"",automation:null,error:null,success:null}))}fetchAvailableParameters=async()=>{const{assistantId:e}=this.props;if(e){this.setState({isLoadingParameters:!0});try{const t=await this.props.fetchLeadFormParameters(e);if(t?.status){const e=t.data?.all||[];this.setState({availableParameters:e})}}catch(e){console.error("Error fetching parameters:",e)}finally{this.setState({isLoadingParameters:!1})}}};handleButtonTypeChange=e=>{this.setState({thankYouButtonType:e})};getAllQuestions=()=>{const{customQuestions:e,contactInfoFields:t}=this.state,a=[];for(const t of e)if(a.push(t),t.conditionalQuestions)for(const e of Object.values(t.conditionalQuestions))
1a.push(e);for(const e of t)e.enabled&&a.push({type:e.type});return a};handleAddQuestion=(()=>{var e=this;return function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"CUSTOM";const{customQuestions:a}=e.state,n={id:id("q"),type:"SHORT_ANSWER"===t||"MULTIPLE_CHOICE"===t?"CUSTOM":t,questionType:"SHORT_ANSWER"===t||"MULTIPLE_CHOICE"===t?t:void 0,key:`custom_${Date.now()}`,label:"DATE_TIME"===t?"Appointment time":"",inline_context:"DATE_TIME"===t?"We will verify and call you to confirm your appointment.":void 0,options:[],isMultipleChoice:"MULTIPLE_CHOICE"===t,conditionalQuestions:{},isMandatory:!0,mappedParameter:null};e.setState({customQuestions:[...a,n]})}})();handleRemoveQuestion=e=>{const{customQuestions:t}=this.state;this.setState({customQuestions:t.filter((t=>t.id!==e))})};handleDragEnd=e=>{const{destination:t,source:a,type:n}=e;if(t&&"QUESTION"===n){const{customQuestions:e}=this.state,n=Array.from(e),[s]=n.splice(a.index,1);n.splice(t.index,0,s),this.setState({customQuestions:n})}};handleQuestionChange=(e,t,a)=>{const{customQuestions:n}=this.state;this.setState({customQuestions:n.map((n=>{if(n.id!==e)return n;const s={...n,[t]:a};return"type"===t&&"CUSTOM"!==a&&(s.key=a.toLowerCase(),s.label="",s.options=[],s.isMultipleChoice=!1,s.conditionalQuestions={}),"questionType"===t&&(s.questionType=a,s.isMultipleChoice="MULTIPLE_CHOICE"===a,"MULTIPLE_CHOICE"!==a&&(s.options=[],s.conditionalQuestions={})),"mappedParameter"===t&&"create_new"===a&&s.label,s}))})};generateKeyFromName=e=>e.trim().toLowerCase().replace(/[^a-z0-9_]/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"");handleCreateNewParameter=async(e,t,a)=>{const{assistantId:n}=this.props;if(!n||!t.trim())return this.setState({error:"Parameter name is required"}),null;const s=a&&a.trim()?a.trim().toLowerCase().replace(/[^a-z0-9_]/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""):this.generateKeyFromName(t);if(!s||!/^[a-z][a-z0-9_]*$/.test(s))return this.setState({error:"Parameter key must start with a letter and contain only lowercase letters, numbers, and underscores"}),null;try{const a=await this.props.fetchLeadFormParameters(n);if(a?.status){const{custom:o,limit:i,all:r}=a.data;if(r.some((e=>e.key===s)))return this.setState({error:`Parameter key "${s}" already exists. Please use a different key.`}),null;if(o.length>=i)return this.setState({error:`Parameter limit reached. Maximum ${i} custom parameters allowed.`}),null;const l=await this.props.saveLeadFormParameters({assistantId:n,parameters:[...a.data.preDefined,...o,{key:s,name:t.trim(),type:"CUSTOM",dataType:"TEXT"}]});if(l?.status){if(e&&e.startsWith("contact_")){const t=e.replace("contact_","");this.setState({contactInfoFields:this.state.contactInfoFields.map((e=>e.type===t?{...e,mappedParameter:s}:e))})}else this.handleQuestionChange(e,"mappedParameter",s);return this.setState({creatingParameterFor:null,newParamName:"",newParamKey:"",creatingParameterForFieldType:null}),await this.fetchAvailableParameters(),s}}}catch(e){console.error("Error creating parameter:",e),this.setState({error:e.response?.data?.message||"Failed to create parameter"})}return null};handleAddOption=e=>{const{customQuestions:t}=this.state;this.setState({customQuestions:t.map((t=>{if(t.id!==e)return t;const a=t.options||[],n={value:"",key:id("opt")};return{...t,options:[...a,n]}}))})};handleRemoveOption=(e,t)=>{const{customQuestions:a}=this.state;this.setState({customQuestions:a.map((a=>a.id!==e?a:{...a,options:a.options.filter(((e,a)=>a!==t)),conditionalQuestions:Object.fromEntries(Object.entries(a.conditionalQuestions||{}).filter((e=>{let[n]=e;return n!==a.options[t]?.key})))}))})};handleOptionChange=(e,t,a)=>{const{customQuestions:n}=this.state;this.setState({customQuestions:n.map((n=>{if(n.id!==e)return n;const s=[...n.options||[]];return s[t]={...s[t],value:a,key:s[t]?.key||id("opt")},{...n,options:s}}))})};hasAppointmentQuestion=()=>{const{customQuestions:e}=this.state;return e.some((e=>"DATE_TIME"===e.type))||e.some((e=>e.conditionalQuestions&&Object.values(e.conditionalQuestions).some((e=>"DATE_TIME"===e.type))))};handleAddConditionalQuestion=(e,t,a)=>{this.setState({conditionalQuestionMenuAnchor:a.currentTarget,conditionalQuestionParentId:e,conditionalQuestionOptionKey:t})};handleCreateConditionalQuestion=e=>{const{customQuestions:t,conditionalQuestionParentId:a,conditionalQuestionOptionKey:n}=this.state;let s;s="DATE_TIME"===e?{id:id("q"),type:"DATE_TIME",key:`conditional_${Date.now()}`,label:"Appointment time",inline_context:"We will verify and call you to confirm your appointment.",isConditional:!0,parentQuestionId:a,dependentOptionKey:n}:{id:id("q"),type:"CUSTOM",questionType:"MULTIPLE_CHOICE"===e?"MULTIPLE_CHOICE":"SHORT_ANSWER",key:`conditional_${Date.now()}`,label:"",options:[],isMultipleChoice:"MULTIPLE_CHOICE"===e,isConditional:!0,parentQuestionId:a,dependentOptionKey:n},this.setState({customQuestions:t.map((e=>e.id!==a?e:{...e,conditionalQuestions:{...e.conditionalQuestions||{},[n]:s}})),conditionalQuestionMenuAnchor:null,conditionalQuestionParentId:null,conditionalQuestionOptionKey:null})};getQuestionTypeDisplayName=e=>{if("DATE_TIME"===e.type)return"Appointment";if("CUSTOM"===e.type){if("SHORT_ANSWER"===e.questionType)return"Short Answer";if("MULTIPLE_CHOICE"===e.questionType)return"Multiple Choice"}return e.type||"Custom"};hasConditionalQuestions=()=>{const{customQuestions:e}=this.state;return e.some((e=>e.conditionalQuestions&&Object.keys(e.conditionalQuestions).length>0))};handleRemoveConditionalQuestion=(e,t)=>{const{customQuestions:a}=this.state;this.setState({customQuestions:a.map((a=>
1{if(a.id!==e)return a;const{[t]:n,...s}=a.conditionalQuestions||{};return{...a,conditionalQuestions:s}}))})};handleConditionalQuestionChange=(e,t,a,n)=>{const{customQuestions:s}=this.state;this.setState({customQuestions:s.map((s=>{if(s.id!==e)return s;const o=s.conditionalQuestions?.[t];return o?{...s,conditionalQuestions:{...s.conditionalQuestions,[t]:{...o,[a]:n}}}:s}))})};handleContactFieldToggle=(e,t)=>{const{contactInfoFields:a}=this.state;this.setState({contactInfoFields:a.map((a=>a.type===e?{...a,enabled:t,isMandatory:!(!t||"FULL_NAME"!==a.type&&"PHONE"!==a.type)||a.isMandatory}:a))})};handleContactFieldMandatory=(e,t)=>{const{contactInfoFields:a}=this.state;"FULL_NAME"!==e&&"PHONE"!==e&&this.setState({contactInfoFields:a.map((a=>a.type===e?{...a,isMandatory:t}:a))})};handleContactFieldParameterChange=async(e,t)=>{const{contactInfoFields:a}=this.state;if("create_new"===t){const t=ea.Ty.find((t=>t.value===e)),a=t?.label||e,n=this.generateKeyFromName(a);this.setState({creatingParameterFor:`contact_${e}`,newParamName:a,newParamKey:n,creatingParameterForFieldType:e})}else this.setState({contactInfoFields:a.map((a=>a.type===e?{...a,mappedParameter:t||null}:a))})};handleAddFieldFromCategory=e=>{const{contactInfoFields:t}=this.state;t.find((t=>t.type===e));this.handleContactFieldToggle(e,!0),this.setState({categoryDropdownAnchor:null,submenuAnchor:null,submenuCategory:null})};handleRemoveContactField=e=>{const{contactInfoFields:t}=this.state;"FULL_NAME"!==e&&"PHONE"!==e&&this.setState({contactInfoFields:t.map((t=>t.type===e?{...t,enabled:!1}:t))})};getStepValidation=()=>{const{greetingEnabled:e,greetingHeadline:t,greetingDescription:a,conditionalLogicEnabled:n,customQuestions:s,privacyPolicyUrl:o,thankYouButtonType:i,thankYouWebsiteUrl:r,thankYouPhoneNumber:l,thankYouDownloadFileUrl:d}=this.state,c=!e||t.trim()&&a.trim(),p=!n||s.some((e=>e.isMultipleChoice&&e.options&&e.options.length>0)),u=o.trim().length>0;let m=!0;return"VIEW_WEBSITE"===i?m=(0,ea.Xc)((0,ea.iP)(r)):"CALL_BUSINESS"===i?m=l.trim().length>0:"DOWNLOAD"===i&&(m=d.trim().length>0),{intro:c,questions:p,privacy:u,ending:m}};isFormValid=()=>{const{formName:e,contactInfoFields:t}=this.state,a=this.getStepValidation();if(!e.trim())return!1;const n=t.find((e=>"FULL_NAME"===e.type))?.enabled,s=t.find((e=>"PHONE"===e.type))?.enabled;return!(!n||!s)&&(a.intro&&a.questions&&a.privacy&&a.ending)};validateForm=()=>{const{formName:e,customQuestions:t,contactInfoFields:a,privacyPolicyUrl:n,thankYouButtonType:s,thankYouWebsiteUrl:o}=this.state;if(console.log("Validating form:",{formName:e,customQuestions:t,contactInfoFields:a,privacyPolicyUrl:n}),!e.trim())return console.log("Validation failed: Form name is required"),this.setState({error:"Form name is required"}),!1;const i=a.find((e=>"FULL_NAME"===e.type))?.enabled,r=a.find((e=>"PHONE"===e.type))?.enabled;if(!i||!r)return console.log("Validation failed: Full Name and Phone Number must be enabled"),this.setState({error:"Full Name and Phone Number must be enabled in Contact Information"}),!1;for(const e of t){if("CUSTOM"===e.type){if(!e.label?.trim())return console.log("Validation failed: Custom questions must have a label"),this.setState({error:"Custom question must have a label"}),!1;if(e.isMultipleChoice&&(!e.options||e.options.length<2))return console.log("Validation failed: Multiple choice questions need at least 2 options"),this.setState({error:`Multiple choice question "${e.label}" needs at least 2 options`}),!1;if(e.isMultipleChoice&&e.options?.some((e=>!e.value?.trim())))return console.log("Validation failed: All options must have a value"),this.setState({error:`All options in "${e.label}" must have a value`}),!1}if(e.conditionalQuestions)for(const[t,a]of Object.entries(e.conditionalQuestions))if(!a.label?.trim())return console.log("Validation failed: Conditional questions must have a label"),this.setState({error:`Conditional question for option "${t}" must have a label`}),!1}if(!n.trim())return console.log("Validation failed: Privacy policy URL is required"),this.setState({error:"Privacy policy URL is required"}),!1;try{new window.URL(n)}catch{return console.log("Validation failed: Invalid privacy policy URL"),this.setState({error:"Please enter a valid privacy policy URL"}),!1}return"VIEW_WEBSITE"!==s||(0,ea.Xc)((0,ea.iP)(o))?(console.log("Form validation passed!"),!0):(console.log("Validation failed: Invalid thank you page website URL"),this.setState({error:"Please enter a valid website URL for the thank you page (e.g., https://example.com)"}),!1)};loadFormForEdit=e=>{const t=e.questions||[],a=this.state.contactInfoFields.map((e=>{const a=t.find((t=>t.type===e.type||"PHONE"===e.type&&"PHONE_OTP"===t.type));return a&&a.mappedParameter?{...e,mappedParameter:a.mappedParameter}:e})),n=!0===e.phoneVerificationEnabled||t.some((e=>"PHONE_OTP"===e.type)),s=t.filter((e=>"CUSTOM"===e.type||"DATE_TIME"===e.type)).map((e=>({conditionalQuestions:{},id:id("q"),inline_context:"DATE_TIME"===e.type?e.inline_context||"We will verify and call you to confirm your appointment."
1:e.inline_context,isMandatory:!0,isMultipleChoice:!!e.options?.length,key:e.key,label:e.label,mappedParameter:e.mappedParameter,options:e.options,questionType:"DATE_TIME"===e.type?"DATE_TIME":e.options?.length?"MULTIPLE_CHOICE":"SHORT_ANSWER",type:"CUSTOM"}))),o=e.thankYouPage||{},i=e.privacyPolicy||{},r=e.greeting||{};this.setState({mode:"edit",editingForm:e,formName:e.name||"",automation:e.automation||null,contactInfoFields:a,formType:e.isOptimizedForQuality||n?"higher_intent":"more_volume",verifyPhoneWithOtp:n,currentStep:4,customQuestions:s,privacyPolicyUrl:i.url||"",privacyPolicyLinkText:i.linkText||"Privacy Policy",thankYouTitle:o.title||"Thank you!",thankYouBody:o.body||"We'll be in touch shortly.",thankYouButtonType:o.buttonType||"VIEW_WEBSITE",thankYouButtonText:o.buttonText||"Visit Website",thankYouWebsiteUrl:o.websiteUrl||"",thankYouPhoneNumber:o.phoneNumber||"",thankYouDownloadFileUrl:o.downloadFileUrl||o.gatedFileUrl||"",greetingEnabled:!(!r.headline&&!r.description),greetingHeadline:r.headline||"",greetingDescription:r.description||"",descriptionType:r.descriptionType||"PARAGRAPH"})};fetchExistingForms=async()=>{const{assistantId:e,pageId:t}=this.props;if(e&&t){this.setState({isLoadingForms:!0});try{const a=await this.props.fetchLeadForms({assistantId:e,pageId:t,status:"ACTIVE",limit:100});a?.status&&a?.data&&this.setState({existingForms:a.data})}catch(e){console.error("Error fetching existing forms:",e),this.setState({error:"Failed to fetch lead forms. Please try again."})}finally{this.setState({isLoadingForms:!1})}}};handleUpdateAutomation=async()=>{const{assistantId:e}=this.props,{editingForm:t}=this.state;if(e&&t?.formId){this.setState({isUpdating:!0,error:null});try{const a=this.getAutomationConfigRef?this.getAutomationConfigRef():this.state.automation;console.log("Sending automation config to backend:",JSON.stringify(a,null,2)),console.log("Template parameters in automation:",a?.templateParameters);const n=await this.props.updateLeadFormAutomation({assistantId:e,formId:t.formId,automation:a});n?.status?(this.setState({success:"Automation settings updated successfully!"}),this.props.onFormUpdated&&this.props.onFormUpdated(t),setTimeout((()=>{this.props.onClose(),this.resetForm()}),1500)):this.setState({error:n?.message||"Failed to update automation settings"})}catch(e){console.error("Error updating automation:",e),this.setState({error:e.response?.data?.message||e.message||"Failed to update automation settings"})}finally{this.setState({isUpdating:!1})}}else this.setState({error:"Missing required information"})};handleCreateForm=async()=>{if(console.log("handleCreateForm called"),!this.validateForm())return;const{assistantId:e,pageId:t}=this.props;if(console.log("Props:",{assistantId:e,pageId:t}),!e||!t)return console.log("Missing assistantId or pageId"),void this.setState({error:"Assistant ID and Page ID are required"});this.setState({isCreating:!0,error:null});try{const{formName:a,customQuestions:n,contactInfoFields:s,verifyPhoneWithOtp:o,privacyPolicyUrl:i,privacyPolicyLinkText:r,thankYouTitle:l,thankYouBody:d,thankYouButtonType:c,thankYouButtonText:p,thankYouWebsiteUrl:u,thankYouPhoneNumber:m,blockDisplayForNonTargetedViewer:h}=this.state,g=this.getAutomationConfigRef?this.getAutomationConfigRef():this.state.automation,b=[];for(const e of n){const t={type:e.type};if("DATE_TIME"===e.type?(t.label=e.label||"Appointment time",e.inline_context?t.inline_context=e.inline_context:t.inline_context="We will verify and call you to confirm your appointment."):"CUSTOM"===e.type&&(t.key=e.key||`custom_question_${b.length}`,e.label&&(t.label=e.label),e.mappedParameter&&(t.mappedParameter=e.mappedParameter),e.isMultipleChoice&&e.options?.length>0&&(t.options=e.options.map(((e,t)=>({key:e.key||`option_${t}`,value:e.value||e}))))),b.push(t),e.conditionalQuestions&&Object.keys(e.conditionalQuestions).length>0)for(const[a,n]of Object.entries(e.conditionalQuestions)){const s=e.options?.find((e=>e.key===a)),o=s?.key||a,i={type:n.type||"CUSTOM",dependent_key:e.key||t.key,dependent_option:o};"DATE_TIME"===n.type?(i.label=n.label||"Appointment time",n.inline_context?i.inline_context=n.inline_context:i.inline_context="We will verify and call you to confirm your appointment."):(i.key=n.key||`conditional_${b.length}`,i.label=n.label,n.isMultipleChoice&&n.options?.length>0&&(i.options=n.options.map(((e,t)=>({key:e.key||`option_${t}`,value:e.value||e}
1))))),b.push(i)}}for(const e of s)if(e.enabled){const t={type:e.type};e.mappedParameter&&(t.mappedParameter=e.mappedParameter),b.push(t)}const y={title:l,body:d,buttonType:c,buttonText:p};"VIEW_WEBSITE"===c&&(y.websiteUrl=(0,ea.iP)(u)),"CALL_BUSINESS"===c&&(y.phoneNumber=m),"DOWNLOAD"===c&&(y.downloadFileUrl=this.state.thankYouDownloadFileUrl,y.gatedFileUrl=this.state.thankYouDownloadFileUrl);const x={assistantId:e,pageId:t,name:a,questions:b,privacyPolicy:{url:i,linkText:r},thankYouPage:y,greeting:this.state.greetingEnabled?{headline:this.state.greetingHeadline,description:this.state.greetingDescription,descriptionType:this.state.descriptionType||"PARAGRAPH"}:null,isOptimizedForQuality:"higher_intent"===this.state.formType,verifyPhoneWithOtp:"higher_intent"===this.state.formType&&o,blockDisplayForNonTargetedViewer:h,automation:g||null};console.log("Creating lead form with payload:",x),console.log("API URL:",`${J.k}/meta-ads/create-lead-form`);const f=await this.props.createLeadForm(x);if(console.log("API Response:",f),f?.status){const e=f.data;this.setState({success:"Lead form created successfully!"}),this.setState({formName:xd(),customQuestions:[],contactInfoFields:fd(),formType:"more_volume",verifyPhoneWithOtp:!1}),this.props.onFormCreated&&this.props.onFormCreated(e)}else this.setState({error:f?.message||"Failed to create lead form"})}catch(e){console.error("Error creating lead form:",e);const{action:t,assistant:a}=e.response?.data||{};"accept_lead_gen_tos"===t?this.setState({error:e.response?.data?.message||"You need to accept Facebook's Lead Generation Terms of Service.",tosLink:a?.link||"https://www.facebook.com/legal/leadgen/tos",reconnectRequired:!1}):"reconnect_meta_for_lead_ads"===t?this.setState({error:e.response?.data?.message||"You need to reconnect your Meta account with additional permissions for Lead Form Ads.",tosLink:null,reconnectRequired:!0}):this.setState({error:e.response?.data?.message||e.message||"Failed to create lead form",tosLink:null,reconnectRequired:!1})}finally{this.setState({isCreating:!1})}};handleSelectForm=e=>{this.props.onFormSelected&&this.props.onFormSelected({label:e.name,value:e.formId,...e}),this.props.onClose()};resetForm=()=>{this.setState({formName:xd(),customQuestions:[],contactInfoFields:fd(),formType:"more_volume",verifyPhoneWithOtp:!1,privacyPolicyUrl:"",privacyPolicyLinkText:"Privacy Policy",thankYouTitle:"Thank you!",thankYouBody:"We'll be in touch shortly.",thankYouButtonType:"VIEW_WEBSITE",thankYouButtonText:"Visit Website",thankYouWebsiteUrl:"",thankYouPhoneNumber:"",blockDisplayForNonTargetedViewer:!1,error:null,success:null,mode:"create",editingForm:null,automation:null,currentStep:0})};handleCreateWithFacebookDialog=async()=>{const{pageId:e}=this.props;if(Rr())if(e){this.setState({isCreating:!0,error:null});try{const t=await Br({pageId:e});t?.formId&&(this.setState({success:`Lead form created via Facebook! Form ID: ${t.formId}`}),this.props.onFormCreated&&this.props.onFormCreated({formId:t.formId,name:t.formName||"Facebook Lead Form"}))}catch(e){this.setState({error:"string"==typeof e?e:"Failed to create lead form via Facebook dialog"})}finally{this.setState({isCreating:!1})}}else this.setState({error:"Page ID is required to use Facebook dialog"});else this.setState({error:"Facebook SDK is not loaded. Please use the custom form builder."})};render(){const{classes:e,open:t,onClose:a}=this.props,{formName:n,customQuestions:s,contactInfoFields:i,verifyPhoneWithOtp:r,privacyPolicyUrl:l,privacyPolicyLinkText:c,thankYouTitle:p,thankYouBody:u,thankYouButtonType:m,thankYouButtonText:g,thankYouWebsiteUrl:b,isOptimizedForQuality:y,blockDisplayForNonTargetedViewer:x,isCreating:f,error:A,tosLink:I,success:C,currentStep:_,previewMode:S,mode:v,editingForm:E,existingForms:T,isLoadingForms:D,isUpdating:w}=this.state;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Drawer,{anchor:"right",open:t,onClose:a,classes:{paper:e.drawerPaper},children:(0,h.jsxs)(o.Box,{className:e.drawerContainer,children:[(0,h.jsxs)(o.Box,{className:e.header,children:[(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,h.jsx)(o.Typography,{variant:"h5",className:e.headerTitle,children:"edit"===v?`Edit Automation: ${E?.name||"Lead Form"}`:"manage"===v?"Manage Lead Forms":n||"Create Lead Form"}),(0,h.jsx)(o.IconButton,{onClick:a,size:"small",children:(0,h.jsx)(d.Close,{})})]}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:"edit"===v?"Edit WhatsApp automation settings for this lead form":"manage"===v?"View and edit automation settings for your lead forms":"Build a custom lead form for your ad"})]}),(0,h.jsx)(o.Divider,{}),(0,h.jsx)(o.Box,{className:e.content,children:(0,h.jsxs)(o.Box,{className:e.contentInner,children:[(0,h.jsx)(cd,{assistantId:this.props.assistantId,error:A,onClose:a,reconnectRequired:this.state.reconnectRequired,setDrawerState:this.setDrawerState,success:C,tosLink:I}),"manage"===v&&(0,h.jsx)(md,{currentStep:_,existingForms:T,isLoadingForms:D,loadFormForEdit:this.loadFormForEdit,mode:v,setDrawerState:this.setDrawerState}),"manage"!==v&&(0,h.jsxs)(o.Grid,{container:!0,spacing:2,children:[(0,h.jsx)(o.Grid,{item:!0,xs:12,md:2,children:(0,h.jsx)(yd,{classes:e,currentStep:_,getStepValidation:this.getStepValidation,mode:v,setDrawerState:this.setDrawerState})}),(0,h.jsx)(o.Grid,{item:!0,xs:12,md:5,children:(0,h.jsxs)(o.Box,{children:[0===_&&(0,h.jsx)(ud,{classes:e,error:A,formName:n,formType:this.state.formType,getStepValidation:this.getStepValidation,greetingDescription:this.state.greetingDescription,greetingEnabled:this.state.greetingEnabled,greetingHeadline:this.state.greetingHeadline,mode:v,setDrawerState:this.setDrawerState,verifyPhoneWithOtp:r}),1===_&&(0,h.jsx)(bd,{availableParameters:this.state.availableParameters,categoryDropdownAnchor:this.state.categoryDropdownAnchor,classes:e,conditionalLogicEnabled:this.state.conditionalLogicEnabled,contactInfoDescription:this.state.contactInfoDescription,contactInfoFields:i,creatingParameterFor:this.state.creatingParameterFor,customQuestions:s,formType:this.state.formType,generateKeyFromName:this.generateKeyFromName,getQuestionTypeDisplayName:this.getQuestionTypeDisplayName,getStepValidation:this.getStepValidation,handleAddFieldFromCategory:this.handleAddFieldFromCategory,handleAddConditionalQuestion:this.handleAddConditionalQuestion,handleAddOption:this.handleAddOption,handleConditionalQuestionChange:this.handleConditionalQuestionChange,handleOptionChange:this.handleOptionChange,handleQuestionChange:this.handleQuestionChange,handleRemoveConditionalQuestion:this.handleRemoveConditionalQuestion,handleRemoveOption:this.handleRemoveOption,handleAddQuestion:this.handleAddQuestion,handleContactFieldParameterChange:this.handleContactFieldParameterChange,handleCreateNewParameter:this.handleCreateNewParameter,handleDragEnd:this.handleDragEnd,handleRemoveContactField:this.handleRemoveContactField,handleRemoveQuestion:this.handleRemoveQuestion,hasConditionalQuestions:this.hasConditionalQuestions,mode:v,newParamKey:this.state.newParamKey,newParamName:this.state.newParamName,onClose:a,open:t,questionDropdownAnchor:this.state.questionDropdownAnchor,setDrawerState:this.setDrawerState,submenuAnchor:this.state.submenuAnchor,submenuCategory:this.state.submenuCategory,verifyPhoneWithOtp:r}),2===_&&(0,h.jsx)(gd,{classes:e,error:A,getStepValidation:this.getStepValidation,privacyPolicyLinkText:c,privacyPolicyUrl:l,setDrawerState:this.setDrawerState}),3===_&&(0,h.jsx)(dd,{blockDisplayForNonTargetedViewer:x,classes:e,error:A,getStepValidation:this.getStepValidation,handleButtonTypeChange:this.handleButtonTypeChange,setDrawerState:this.setDrawerState,thankYouBody:u,thankYouButtonText:g,thankYouButtonType:m,thankYouPhoneNumber:this.state.thankYouPhoneNumber,thankYouTitle:p,thankYouWebsiteUrl:b}),(4===_||"edit"===v)&&(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"subtitle1",gutterBottom:!0,style:{fontWeight:500,marginBottom:8},children:"edit"===v?"WhatsApp Automation":"Automation • Optional"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:16},children:"Configure WhatsApp automation to automatically send messages to leads when they submit the form at Meta."}),(0,h.jsx)(Nl,{automation:this.state.automation,onChange:e=>{this.setState({automation:e})},onGetConfigRef:e=>{this.getAutomationConfigRef=e},onPreviewDataChange:e=>
1{this.setState({automationPreviewData:e,previewCarouselIndex:e.carouselIndex||0})},questions:"edit"===v&&E?.questions?E.questions.map((e=>({key:e.key||e.type?.toLowerCase(),label:e.label||e.type}))):this.getAllQuestions(),assistantId:this.props.assistantId,classes:e})]})]})}),(0,h.jsx)(hd,{automationPreviewData:this.state.automationPreviewData,classes:e,contactInfoFields:i,currentStep:_,customQuestions:s,formName:n,greetingDescription:this.state.greetingDescription,greetingEnabled:this.state.greetingEnabled,greetingHeadline:this.state.greetingHeadline,previewCarouselIndex:this.state.previewCarouselIndex,previewMode:S,privacyPolicyLinkText:c,privacyPolicyUrl:l,setDrawerState:this.setDrawerState,thankYouBody:u,thankYouButtonText:g,thankYouButtonType:m,thankYouTitle:p,verifyPhoneWithOtp:r})]})]})}),"manage"!==v&&(0,h.jsx)(pd,{classes:e,currentStep:_,handleCreateForm:this.handleCreateForm,handleUpdateAutomation:this.handleUpdateAutomation,isCreating:f,isFormValid:this.isFormValid,isUpdating:w,mode:v,onClose:a,setDrawerState:this.setDrawerState})]})}),this.state.conditionalQuestionMenuAnchor&&(0,h.jsx)(ld,{conditionalQuestionMenuAnchor:this.state.conditionalQuestionMenuAnchor,handleCreateConditionalQuestion:this.handleCreateConditionalQuestion,hasAppointmentQuestion:this.hasAppointmentQuestion,onClose:a,open:t,setDrawerState:this.setDrawerState})]})}}const Id=(0,i.connect)(null,{createLeadForm:gi.BQ,fetchLeadForms:gi.s$,fetchLeadFormParameters:gi.fW,saveLeadFormParameters:gi.aM,updateLeadFormAutomation:gi.x3},null,{forwardRef:!0})((0,o.withStyles)((e=>({drawerPaper:{width:"90%",maxWidth:1200,[e.breakpoints.down("md")]:{width:"95%"},[e.breakpoints.down("sm")]:{width:"100%"}},drawerContainer:{display:"flex",flexDirection:"column",height:"100%",backgroundColor:"#fff"},header:{padding:"20px 24px",backgroundColor:"#fff",borderBottom:"1px solid #e0e0e0",[e.breakpoints.down("sm")]:{padding:"16px"}},headerTitle:{fontWeight:600,fontSize:18},content:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",backgroundColor:"#F9F9FB"},contentInner:{flex:1,overflow:"auto",padding:"16px",[e.breakpoints.down("sm")]:{padding:"12px"}},TextFieldRoot:{width:"100%",padding:"2px",marginTop:"4px",background:"rgb(240,240,240)"},inputPadding:{padding:"8px 10px"},footer:{padding:"16px 70px 16px 40px",borderTop:"1px solid #e0e0e0",display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"#fff",gap:16,flexShrink:0,[e.breakpoints.down("sm")]:{padding:"12px 16px",flexDirection:"column",gap:12}},questionCard:{padding:"16px",borderRadius:8,backgroundColor:"#fff",boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},formCard:{padding:"20px",borderRadius:8,backgroundColor:"#fff",boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},previewContainer:{position:"sticky",top:0,padding:"16px",backgroundColor:"#F9F9FB",borderRadius:8,minHeight:400},sidebar:{padding:e.spacing(1.5),backgroundColor:"#F9F9FB",borderRadius:8,minHeight:400,position:"sticky",top:e.spacing(1)},stepItem:{display:"flex",alignItems:"center",gap:e.spacing(1),padding:e.spacing(1,.75),borderRadius:4,marginBottom:e.spacing(.75),cursor:"pointer",transition:"background-color 0.2s"},stepIndicator:{width:12,height:12,borderRadius:"50%",flexShrink:0}})))(Ad));class Cd extends n.Component{constructor(e){super(e),this.state={openMediaDialog:!1,mediaType:"IMAGE",isResolutionDropdownOpen:!1,adType:"image",isGenerating:!1,isImageGenerating:!1,isVideoGenerating:!1,websiteUrlError:"",leadFormDrawerOpen:!1,isSyncingLeadForms:!1,editingLeadForm:null,hasLeadFormPermissions:null,leadFormTosAccepted:!1,checkingPermissions:!1,formatIndicatorStyle:{left:0,width:0,opacity:0}},this.imageTabRef=s().createRef(),this.videoTabRef=s().createRef(),this.carouselTabRef=s().createRef()}isDuplicateAd=(()=>window.location.pathname.includes("duplicate"))();isCreateAd=(()=>window.location.pathname.includes("create"))();updateFormatIndicatorStyle=()=>{const{adFormat:e,uploadType:t}=this.props.parentState||{},a=("carousel"===e?this.carouselTabRef:"VIDEO_UPLOAD"===t?this.videoTabRef:this.imageTabRef).current;if(!a)return;const{offsetLeft:n,offsetWidth:s}=a;this.setState((e=>e.formatIndicatorStyle.left===n&&e.formatIndicatorStyle.width===s&&1===e.formatIndicatorStyle.opacity?null:{formatIndicatorStyle:{left:n,width:s,opacity:1}}))};scheduleFormatIndicatorUpdate=()=>{this.formatIndicatorRaf&&cancelAnimationFrame(this.formatIndicatorRaf),this.formatIndicatorRaf=requestAnimationFrame((()=>{this.formatIndicatorRaf=null,this.updateFormatIndicatorStyle()}
1))};componentDidMount(){const{websiteUrl:e}=this.props.parentState;e&&this.setState({websiteUrlError:this.validateUrl(e)}),"LEAD"===this.props.parentState?.adType?.type&&(this.checkLeadFormPermissions(),this.fetchLeadForms()),this.scheduleFormatIndicatorUpdate()}componentWillUnmount(){this.formatIndicatorRaf&&cancelAnimationFrame(this.formatIndicatorRaf)}componentDidUpdate(e){const t="LEAD"===this.props.parentState?.adType?.type,a="LEAD"===e.parentState?.adType?.type,n=this.props.pageDetails?.pageId,s=e.pageDetails?.pageId;t&&!a&&(console.log("Ad type changed to LEAD, fetching lead forms"),this.checkLeadFormPermissions(),this.fetchLeadForms()),t&&n&&n!==s&&(console.log("Page details changed while on LEAD ad type, fetching lead forms"),this.checkLeadFormPermissions(),this.fetchLeadForms()),e.parentState?.adFormat===this.props.parentState?.adFormat&&e.parentState?.uploadType===this.props.parentState?.uploadType&&e.parentState?.adType?.value===this.props.parentState?.adType?.value||this.scheduleFormatIndicatorUpdate()}checkLeadFormPermissions=async()=>{const e=this.props.assistantDetails?.assistantId,t=this.props.pageDetails?.pageId||this.props.parentState?.selectedPage?.pageId;if(e&&t){this.setState({checkingPermissions:!0});try{const a=await this.props.checkLeadFormPermissions({assistantId:e,pageId:t});a?.status&&this.setState({hasLeadFormPermissions:a.hasLeadFormPermissions||!1,leadFormTosAccepted:a.leadFormTosAccepted||!1,checkingPermissions:!1})}catch(e){console.error("Error checking lead form permissions:",e),this.setState({hasLeadFormPermissions:!1,leadFormTosAccepted:!1,checkingPermissions:!1})}}};fetchLeadForms=async()=>{const{assistantDetails:e,pageDetails:t}=this.props,a=e?.assistantId,n=t?.pageId||this.props.parentState?.selectedPage?.pageId;if(console.log("fetchLeadForms called:",{assistantId:a,pageId:n,pageDetails:t}),a&&n)try{const e=await this.props.fetchLeadForms({assistantId:a,pageId:n,status:"ACTIVE",limit:50});if(console.log("Lead forms API response:",e),e?.status&&e?.data){const t=e.data,{parentState:a,changeState:n}=this.props,s=a?.leadFormId,o=a?.leadForm;if(s&&!o?.value){const e=t.find((e=>e.formId===s));e&&(console.log("Auto-selecting lead form from saved leadFormId:",e),n("leadForm",{label:e.name,value:e.formId,...e}))}}}catch(e){console.error("Error fetching lead forms:",e)}else console.log("Missing assistantId or pageId, skipping lead forms fetch")};handleOpenLeadFormDrawer=()=>{this.setState({leadFormDrawerOpen:!0})};handleCloseLeadFormDrawer=()=>{this.setState({leadFormDrawerOpen:!1,editingLeadForm:null})};handleLeadFormCreated=e=>{this.fetchLeadForms(),e?.formId&&(this.props.changeState("leadForm",{label:e.name,value:e.formId,...e}),this.props.changeState("leadFormId",e.formId))};handleSyncLeadFormsFromMeta=async()=>{const{assistantDetails:e,pageDetails:t}=this.props,a=e?.assistantId,n=t?.pageId||this.props.parentState?.selectedPage?.pageId;if(a&&n){this.setState({isSyncingLeadForms:!0});try{const e=await this.props.syncLeadForms({assistantId:a,pageId:n});if(e?.status){const{syncedCount:t}=e.data||{};await this.fetchLeadForms(),console.log(`Successfully synced ${t||0} lead forms from Meta`)}else console.error("Failed to sync lead forms:",e?.message)}catch(e){console.error("Error syncing lead forms:",e)}finally{this.setState({isSyncingLeadForms:!1})}}else console.log("Missing assistantId or pageId, skipping sync")};handleLeadFormSelected=e=>{this.props.changeState("leadForm",e),this.props.changeState("leadFormId",e?.value||e?.formId||""),this.setState({leadFormDrawerOpen:!1})};hasLeadFormPermissions=()=>{const{assistantDetails:e}=this.props,t=e?.fbGrantedScopes||"";return t.includes("pages_manage_ads")&&t.includes("leads_retrieval")};onMediaSelect=e=>{const{mediaType:t}=this.state,{uploadType:a}=this.props.parentState;if("VIDEO_UPLOAD"===a&&"VIDEO"===t)this.props.changeState("videoFile",e);else if("VIDEO_UPLOAD"===a&&"IMAGE"===t)this.props.changeState("thumbnailUrl",e);else if("IMAGE"===t&&"IMAGE_UPLOAD"===a)this.props.changeState("imageFile",e);else if("AI_UPLOAD"===a&&e&&e.length>0){const t=e[0];"VIDEO"===t.fileType?this.props.changeState("videoFile",t):"IMAGE"===t.fileType&&this.props.changeState("imageFile",t)}};handleInput=e=>{const{name:t,value:a}=e.target;this.props.changeState(t,a);const n={selectedMedia:{},previewImageUrl:(0,wo.replaceDomainInData)(e.target.value)};this.props.createnewAds(n)};
1onChangename=e=>{const{name:t}=e.target;let a=e.target.value.replace(/^\s+/,"");a.length<256&&this.props.changeState(t,a)};onChangeCaption=e=>{const{name:t}=e.target;let a=e.target.value.replace(/^\s+/,"");a.length<=2200&&this.props.changeState(t,a)};onChangeHeadline=e=>{const{name:t}=e.target;let a=e.target.value.replace(/^\s+/,"");a.length<=40&&this.props.changeState(t,a)};onChangeHeadlineDescription=e=>{const{name:t}=e.target;let a=e.target.value.replace(/^\s+/,"");a.length<=30&&this.props.changeState(t,a)};onImageGeneration=e=>{const t="string"==typeof e?{publicUrl:e,fileName:"Generated Image",fileType:"IMAGE"}:{...e,fileType:"IMAGE"};this.props.changeState("imageFile",t),this.props.changeState("uploadType","IMAGE_UPLOAD")};onVideoGeneration=e=>{const t="string"==typeof e?{publicUrl:e,fileName:"Generated Video",fileType:"VIDEO"}:{...e,fileType:"VIDEO"};this.props.changeState("videoFile",t),this.props.changeState("uploadType","VIDEO_UPLOAD")};handleUploadTypeToggle=(e,t)=>{"IMAGE_UPLOAD"===t?this.props.changeState("uploadType","IMAGE_UPLOAD"):"VIDEO_UPLOAD"===t&&this.props.changeState("uploadType","VIDEO_UPLOAD")};handleGenerationStateChange=e=>{this.setState({isGenerating:e.isGenerating,isImageGenerating:e.isImageGenerating,isVideoGenerating:e.isVideoGenerating}),this.props.onGenerationStateChange&&this.props.onGenerationStateChange(e)};validateUrl=e=>{if(!e)return"";return/^https:\/\/([\w-]+\.)+[\w-]+(\/[^\s]*)?$/.test(e)?"":"Please enter a valid URL (e.g., https://example.com)"};handleWebsiteUrlChange=e=>{const{changeState:t}=this.props,a=e.target.value;t("websiteUrl",a);const n=this.validateUrl(a);this.setState({websiteUrlError:n})};handleWebsiteUrlBlur=e=>{const t=e.target.value,a=this.validateUrl(t);this.setState({websiteUrlError:a})};render(){const{classes:e,parentState:t,isLiveAD:a,assistantDetails:n,pageDetails:s}=this.props,{adName:i,adCaption:r,adHeadline:l,adHeadlineDescription:c,imageFile:p,videoFile:u,thumbnailUrl:m,ctaButton:g="APPLY_NOW",websiteUrl:b="",leadForm:y,adFormat:x="single",cards:f=[],uploadType:A}=t,I=_r(t?.adType?.value),C="carousel"===x,_=C?"":l,S=C?"":c,v=b,E=C?"Headlines and descriptions are added per card in Carousel mode — edit them in the card strip below.":"",{leadForms:T,isLoadingLeadForms:D}=this.props,{leadFormDrawerOpen:w,hasLeadFormPermissions:N,leadFormTosAccepted:j,checkingPermissions:k,isSyncingLeadForms:L}=this.state,R=[{value:"APPLY_NOW",label:"Apply now"},{value:"BOOK_NOW",label:"Book now"},{value:"CONTACT_US",label:"Contact us"},{value:"DOWNLOAD",label:"Download"},{value:"LEARN_MORE",label:"Learn more"},{value:"SEE_MENU",label:"See menu"},{value:"SHOP_NOW",label:"Shop now"},{value:"SIGN_UP",label:"Sign up"},{value:"WATCH_MORE",label:"Watch more"},{value:"DONATE_NOW",label:"Donate now"}],B="LEAD"===t?.adType?.type,P=B?ea.qN:R;return(0,h.jsxs)(o.Grid,{container:!0,spacing:this.props.isSmallScreen?2:4,marginTop:"3em",children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,md:12,style:{display:"flex",flexDirection:"column",justifyContent:"center",minWidth:"221px",marginBottom:"20px"},children:[(0,h.jsx)(o.Grid,{container:!0,style:{display:"flex",justifyContent:"space-between",gap:"20px"},className:e.bottomMargin,children:(0,h.jsxs)(o.Grid,{item:!0,xs:12,children:[(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"end",children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Ad Name"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:`${(i||"").length}/255`})]}),(0,h.jsx)(o.Tooltip,{title:a&&!this.isDuplicateAd?"You can't edit the Ad name once the ad is live":"",placement:"top",children:this.props.parentState.isAdFetched||this.isCreateAd?(0,h.jsx)(o.TextField,{variant:"outlined",classes:{root:e.TextFieldRoot},InputProps:{classes:{input:e.inputPadding}},placeholder:"Enter Ad Name ",name:"adName",id:"adName",onChange:this.onChangename,value:i,disabled:a&&!this.isDuplicateAd}):(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,style:{borderRadius:"10px"}})})]})}),(0,h.jsx)(o.Grid,{container:!0,style:{display:"flex",gap:"20px"},className:e.bottomMargin,children:(0,h.jsxs)(o.Grid,{item:!0,xs:12,children:[(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"end",children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Primary Text"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:`${(r||"").length}/2200`})]}),this.props.parentState.isAdFetched||this.isCreateAd?(0,h.jsx)(o.TextField,{variant:"outlined",classes:{root:e.TextFieldRoot},InputProps:{classes:{input:e.inputPadding}},placeholder:"Enter Ad Caption ",name:"adCaption",id:"adCaption",onChange:this.onChangeCaption,value:r,multiline:!0,rows:4}):(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:100,style:{borderRadius:"10px"}})]})}),(0,h.jsxs)(o.Grid,{container:!0,style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"20px"},className:e.bottomMargin,children:["whatsapp_status"!==t?.adType?.value&&(0,h.jsxs)(o.Grid,{item:!0,style:{minWidth:0},children:[(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"end",className:C?e.mutedFieldLabel:void 0,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Headline"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:`${(_||"").length}/40`})]}),this.props.parentState.isAdFetched||this.isCreateAd?(0,h.jsx)(o.Tooltip,{title:E,placement:"top",children:(0,h.jsx)("div",{children:(0,h.jsx)(o.TextField,{variant:"outlined",classes:{root:e.TextFieldRoot},InputProps:{classes:{input:e.inputPadding}},placeholder:"Enter Display Headline ",name:"adHeadline",id:"adHeadline",onChange:this.onChangeHeadline,value:_,disabled:C,multiline:!0,rows:1})})}):(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,style:{borderRadius:"10px"}})]}),"whatsapp_status"!==t?.adType?.value&&(0,h.jsxs)(o.Grid,{item:!0,style:{minWidth:0},children:[(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"end",className:C?e.mutedFieldLabel:void 0,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Description"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:`${(S||"").length}/30`})]}),this.props.parentState.isAdFetched||this.isCreateAd?(0,h.jsx)(o.Tooltip,{title:E,placement:"top",children:(0,h.jsx)("div",{children:(0,h.jsx)(o.TextField,{variant:"outlined",classes:{root:e.TextFieldRoot},InputProps:{classes:{input:e.inputPadding}},placeholder:"Enter Description ",name:"adHeadlineDescription",id:"adHeadlineDescription",onChange:this.onChangeHeadlineDescription,value:S,disabled:C,multiline:!0,rows:1})})}):(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,style:{borderRadius:"10px"}})]})]}),["website_traffic","website_to_whatsapp"].includes(t?.adType?.value)&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.Box,{display:"flex",style:{gap:"20px"},className:e.bottomMargin,flexWrap:"wrap",alignItems:"flex-start",children:[(0,h.jsxs)(o.Box,{flex:1,minWidth:"300px",display:"flex",flexDirection:"column",children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"CTA Button"}),(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,color:"textSecondary",children:"Select the CTA button for your ad"}),t.isAdFetched||this.isCreateAd?(0,h.jsx)(o.TextField,{select:!0,variant:"outlined",fullWidth:!0,classes:{root:e.TextFieldRoot},InputProps:{classes:{input:e.inputPadding}},name:"ctaButton",value:g,onChange:e=>this.props.changeState("ctaButton",e.target.value),placeholder:"Select CTA Button",children:R.map((e=>(0,h.jsx)(o.MenuItem,{value:e.value,children:e.label},e.value)))}):(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,style:{borderRadius:"10px"}})]}),!C&&(0,h.jsxs)(o.Box,{flex:1,minWidth:"300px",display:"flex",flexDirection:"column",children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Destination"}),(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,color:"textSecondary",children:"Enter the Destination URL"}),t.isAdFetched||this.isCreateAd?(0,h.jsx)(o.TextField,{variant:"outlined",fullWidth:!0,classes:{root:e.TextFieldRoot},InputProps:{classes:{input:e.inputPadding}},placeholder:"https://example.com",name:"websiteUrl",id:"websiteUrl",onCh
1ange:this.handleWebsiteUrlChange,onBlur:this.handleWebsiteUrlBlur,value:v,type:"url",error:!!this.state.websiteUrlError,helperText:this.state.websiteUrlError,FormHelperTextProps:{style:{marginTop:"4px",fontSize:"12px"}}}):(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,style:{borderRadius:"10px"}})]})]}),"website_to_whatsapp"===t?.adType?.value&&(0,h.jsx)(o.Box,{className:e.bottomMargin,minWidth:"300px",maxWidth:"640px",children:(0,h.jsxs)(o.Box,{display:"flex",alignItems:"flex-start",style:{gap:"8px",padding:"8px 12px",borderRadius:"8px",background:"rgba(29, 158, 117, 0.08)"},children:[(0,h.jsx)(xi.A,{style:{color:"#1D9E75",fontSize:"18px",marginTop:"2px"}}),(0,h.jsxs)(o.Box,{children:[(0,h.jsxs)(o.Typography,{variant:"body2",style:{color:"#0F6E56"},children:["Your website will open with a WhatsApp button — replies go to ",s?.whatsappNumber||"the number"," — the verified number on “",s?.pageName||"your Page","”. Set automatically."]}),(0,h.jsxs)(o.Typography,{variant:"body2",style:{color:"#0F6E56",marginTop:"4px"},children:[(0,h.jsx)("b",{children:"Note:"})," the WhatsApp button appears only when the ad is opened in the Facebook or Instagram mobile app. Clicks from desktop browsers open your website without the button."]})]})]})})]}),B&&(0,h.jsx)(h.Fragment,{children:(0,h.jsxs)(o.Box,{display:"flex",style:{gap:"20px"},className:e.bottomMargin,flexWrap:"wrap",alignItems:"flex-start",children:[(0,h.jsxs)(o.Box,{flex:2,minWidth:"300px",display:"flex",flexDirection:"column",children:[(0,h.jsx)(o.Box,{mb:1,children:(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:1,children:[(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Lead Form"}),(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,color:"textSecondary",children:"Select or create a lead form to collect user information"})]}),(0,h.jsx)(o.Tooltip,{title:j&&N?"":j?"Missing pages_manage_ads permission. Please reconnect your Meta account":"Please accept Lead Form Terms of Service in the Ads Setup page",placement:"top",children:(0,h.jsx)("span",{children:(0,h.jsx)(o.Button,{variant:"outlined",color:"primary",size:"small",startIcon:(0,h.jsx)(d.Add,{}),onClick:this.handleOpenLeadFormDrawer,style:{textTransform:"none",marginTop:4},disabled:!j||!N||k,children:"Create New"})})})]})}),t.isAdFetched||this.isCreateAd?(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Tooltip,{title:j&&N?"":j?"Missing pages_manage_ads permission. Please reconnect your Meta account":"Please accept Lead Form Terms of Service in the Ads Setup page",placement:"top",children:(0,h.jsx)("div",{children:(0,h.jsxs)(o.TextField,{select:!0,variant:"outlined",fullWidth:!0,classes:{root:e.TextFieldRoot},InputProps:{classes:{input:e.inputPadding},startAdornment:D?(0,h.jsx)(o.CircularProgress,{size:20,style:{marginRight:8}}):(0,h.jsx)(d.Description,{fontSize:"small",style:{marginRight:8,color:"#666"}})},SelectProps:{MenuProps:{getContentAnchorEl:null,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"}},renderValue:e=>{if(!e)return"";const t=T.find((t=>t.formId===e));return t?t.name:""}},value:y?.value||"",disabled:!j||!N||k||D||L,onChange:e=>{const t=T.find((t=>t.formId===e.target.value));t&&(this.props.changeState("leadForm",{label:t.name,value:t.formId,...t}),this.props.changeState("leadFormId",t.formId))},placeholder:"Select Lead Form",children:[(0,h.jsx)(o.MenuItem,{value:"",disabled:!0,children:D?"Loading forms...":"Select a Lead Form"}),T.map((e=>(0,h.jsx)(o.MenuItem,{value:e.formId,children:(0,h.jsx)(o.Typography,{variant:"body2",children:e.name})},e.formId))),0===T.length&&!D&&(0,h.jsx)(o.MenuItem,{value:"",disabled:!0,children:(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:"No lead forms found. Create one to continue."})}),(0,h.jsx)(o.Divider,{}),(0,h.jsx)(o.MenuItem,{onClick:this.handleSyncLeadFormsFromMeta,disabled:this.state.isSyncingLeadForms,children:(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",gap:1,children:[this.state.isSyncingLeadForms?(0,h.jsx)(o.CircularProgress,{size:16}):(0,h.jsx)(d.Refresh,{fontSize:"small"}),(0,h.jsx)(o.Typography,{variant:"body2",children:this.state.isSyncingLeadForms?"Syncing...":"Sync from Meta"})]})})]})})}),y?.value&&(0,h.jsx)(o.Box,{mt:1.5,children:(0,h.jsx)(o.Tooltip,{title:j&&N?"":j?"Missing pages_manage_ads permission. Please reconnect your Meta account":"Please accept Lead Form Terms of Service in the Ads Setup page",placement:"top",children:(0,h.jsx)("span",{children:(0,h.jsx)(o.Button,{variant:"outlined",color:"primary",size:"small",startIcon:(0,h.jsx)(d.Edit,{}),onClick:()=>{const e=T.find((e=>e.formId===y.value));e&&this.setState({leadFormDrawerOpen:!0,editingLeadForm:e})},disabled:!j||!N||k||D,style:{textTransform:"none"},fullWidth:!0,children:"Edit Automation"})})})})]}):(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,style:{borderRadius:"10px"}})]}),(0,h.jsxs)(o.Box,{flex:1,minWidth:"250px",display:"flex",flexDirection:"column",children:[(0,h.jsx)(o.Box,{mb:1,children:(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:1,children:[(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"CTA Button"}),(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,color:"textSecondary",children:"Button text shown on your ad"})]}),(0,h.jsx)(o.Box,{style:{width:100}})]})}),t.isAdFetched||this.isCreateAd?(0,h.jsx)(o.TextField,{select:!0,variant:"outlined",fullWidth:!0,classes:{root:e.TextFieldRoot},InputProps:{classes:{input:e.inputPadding}},name:"ctaButton",value:g,onChange:e=>this.props.changeState("ctaButton",e.target.value),placeholder:"Select CTA Button",children:P.map((e=>(0,h.jsx)(o.MenuItem,{value:e.value,children:e.label},e.value)))}):(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,style:{borderRadius:"10px"}})]})]})}
1),(0,h.jsxs)(o.Grid,{item:!0,style:{marginBottom:"16px"},children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Media"}),(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,color:"textSecondary",children:"Upload your media from the media library or generate with AI"}),(0,h.jsxs)("div",{className:e.mediaFormatToggle,children:[(0,h.jsx)("div",{className:e.mediaFormatIndicator,style:{left:this.state.formatIndicatorStyle.left,width:this.state.formatIndicatorStyle.width,opacity:this.state.formatIndicatorStyle.opacity}}),(0,h.jsxs)("button",{ref:this.imageTabRef,className:`${e.mediaFormatButton} ${"carousel"!==x&&"VIDEO_UPLOAD"!==A?e.mediaFormatButtonActive:""}`,onClick:()=>{this.props.changeState("uploadType","IMAGE_UPLOAD"),this.props.changeState("adFormat","single")},children:[(0,h.jsx)(bi.A,{size:16}),(0,h.jsx)(o.Typography,{children:"Image"})]}),(0,h.jsxs)("button",{ref:this.videoTabRef,className:`${e.mediaFormatButton} ${"carousel"!==x&&"VIDEO_UPLOAD"===A?e.mediaFormatButtonActive:""}`,onClick:()=>{this.props.changeState("uploadType","VIDEO_UPLOAD"),this.props.changeState("adFormat","single")},children:[(0,h.jsx)(yi.A,{size:16}),(0,h.jsx)(o.Typography,{children:"Video"})]}),I&&(0,h.jsxs)("button",{ref:this.carouselTabRef,className:`${e.mediaFormatButton} ${"carousel"===x?e.mediaFormatButtonActive:""}`,onClick:()=>{this.props.changeState("adFormat","carousel"),0===f.length&&this.props.changeState("cards",[Sr(),Sr()])},children:[(0,h.jsx)(d.ViewCarousel,{fontSize:"small"}),(0,h.jsx)(o.Typography,{children:"Carousel"})]})]})]}),"carousel"===x?(0,h.jsx)(o.Grid,{item:!0,style:{marginBottom:"16px",minWidth:0},children:(0,h.jsx)(Lr,{cards:f,adTypeValue:t?.adType?.value,assistantId:n?.assistantId,assistantDetails:this.props.assistantDetails,updateAssistantAdCredits:this.props.updateAssistantAdCredit,updateAssistantStore:this.props.updateAssistantStore,activePreviewIndex:t?.previewCardIndex??0,onCardsChange:e=>{if(this.props.changeState("cards",e),e.length>f.length)this.props.changeState("previewCardIndex",e.length-1);else if(e.length<f.length){const a=t?.previewCardIndex??0;this.props.changeState("previewCardIndex",Math.min(a,e.length-1))}}})}):(0,h.jsx)(Ir,{imageFile:p,videoFile:u,thumbnailUrl:m,onImageFileChange:e=>{this.props.changeState("imageFile",e),e&&this.props.changeState("uploadType","IMAGE_UPLOAD")},onVideoFileChange:e=>{this.props.changeState("videoFile",e),e&&this.props.changeState("uploadType","VIDEO_UPLOAD")},onThumbnailUrlChange:e=>this.props.changeState("thumbnailUrl",e),onMediaSelect:this.onMediaSelect,assistantDetails:this.props.assistantDetails,onImageGeneration:this.onImageGeneration,onVideoGeneration:this.onVideoGeneration,uploadType:this.props.parentState.uploadType,onUploadTypeChange:this.handleUploadTypeToggle,hideTabToggle:!0,fetchAssistantDetails:this.props.fetchAssistantDetails,updateAssistantAdCredits:this.props.updateAssistantAdCredit,updateAssistantStore:this.props.updateAssistantStore,isLoading:!this.props.parentState.isAdFetched&&!this.isCreateAd,onGenerationStateChange:this.handleGenerationStateChange,mediaRecommendation:"whatsapp_status"===t?.adType?.value?"For WhatsApp Status and Instagram Stories, a vertical 9:16 image or video (recommended 1080×1920) works best. This isn't enforced — other sizes are still accepted.":void 0})]}),(0,h.jsx)(Id,{open:w,onClose:()=>{this.handleCloseLeadFormDrawer(),this.setState({editingLeadForm:null})},assistantId:n?.assistantId,assistantDetails:n,pageId:this.props.pageDetails?.pageId||t?.selectedPage?.pageId,onFormCreated:this.handleLeadFormCreated,onFormSelected:this.handleLeadFormSelected,editMode:!!this.state.editingLeadForm,editForm:this.state.editingLeadForm,onFormUpdated:()=>{this.fetchLeadForms(),this.setState({editingLeadForm:null})}})]})}}const _d=(0,i.connect)((e=>({aiAdParams:e.assistantDetails.aiAdParams,assistantDetails:e.assistantDetails.data,pageDetails:e.ads.pageDetails,leadForms:(0,gi.w8)(e),isLoadingLeadForms:(0,gi.Sc)(e)})),{createnewAds:_n.lw,FetchNames:_n.TH,FetchDetails:_n.$g,fetchAssistantDetails:$.lq,updateAssistantAdCredit:$.WC,updateAssistantStore:$.nt,updateAiAdParameters:e=>({type:"UPDATE_AI_AD_PARAMS",payload:e}),checkLeadFormPermissions:M.xS,fetchLeadForms:gi.s$,syncLeadForms:gi.JZ})(Cd),Sd=(0,o.withStyles)((e=>({root:{width:"100%",padding:"20px 10px",display:"flex"},codeTextFieldRoot:{width:"105px",padding:"0 0 0 24px",position:"absolute",zIndex:1,margin:"8px 0 0 2px",background:"rgb(240,240,240)","& input":{padding:"10px 0 !important"},"& button":{width:"12px",position:"relative",left:"7px",background:"rgb(240,240,240)",borderRadius:0,"&:hover":{background:"rgb(240,240,240)"}},"& div":{paddingRight:"0px !important"}},bottomMargin:{marginBottom:e.spacing(4)},mediaFormatToggle:{position:"relative",backgroundColor:"#f0f0f0",display:"flex",borderRadius:"8px",padding:"4px",width:"fit-content",minWidth:"260px",marginBottom:e.spacing(2)},mediaFormatIndicator:{position:"absolute",top:4,bottom:4,borderRadius:"8px",backgroundColor:"white",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.12)",transition:"left 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.15s ease"},mediaFormatButton:{position:"relative",zIndex:1,flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:e.spacing(.5),padding:e.spacing(.75,1.5),borderRadius:"8px",border:"none",backgroundColor:"transparent",color:e.palette.text.secondary,fontSize:"0.8125rem",fontWeight:600,cursor:"pointer",transition:"color 0.2s ease"},mediaFormatButtonActive:{color:"black"}
1,mutedFieldLabel:{opacity:.5},TextFieldRoot:{width:"100%",padding:"2px",marginTop:"4px","& input":{width:"calc(100% - 80px)"},background:"rgb(240,240,240)"},ad:{display:"flex",justifyContent:"center",marginTop:"1.35em",marginBottom:"2em",[e.breakpoints.up("md")]:{minWidth:"315px"}},textFieldRoot1:{width:"100%",padding:"2px 10px",paddinTop:"4px",paddingLeft:"50px",marginTop:"4px","& input":{width:"calc(100% - 80px)",marginLeft:"80px"},background:"rgb(240,240,240)"},inputPadding:{padding:"12px 10px"},codeTextFieldRoot2:{width:"72px",height:"40px",padding:"0 0 0 22px",position:"absolute",zIndex:1,marginTop:"6px","& input":{padding:"12px 0 !important"}},historySearchBarContainer:{display:"flex",gap:"20px",width:"100%",[e.breakpoints.down("sm")]:{flexDirection:"column",gap:"12px",width:"100%"},borderBottom:"1px solid #E8E8E8",padding:"16px"},historySearchBar:{flex:"1 1 auto",minWidth:0,[e.breakpoints.down("sm")]:{maxWidth:"calc(100% - 32px)"}},dateRangeSelector:{flex:"0 0 auto",border:"2px solid #E8E8E8",borderRadius:"8px",padding:"4px",paddingLeft:"16px",display:"flex",alignItems:"center",justifyContent:"center",gap:8,marginRight:"32px",cursor:"pointer",transition:"border-color 0.2s ease","&:hover":{borderColor:"#0a474c"},[e.breakpoints.down("sm")]:{width:"calc(100% - 36px)",padding:"4px 0px",marginRight:"0px"}},promptContainer:{margin:"16px",borderRadius:"8px",padding:"16px",backgroundColor:"#ffffff","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.02)",cursor:"pointer"},"&:hover $iconButtonContainer":{opacity:1}},promptContent:{flex:1,maxWidth:"30rem"},iconButtonContainer:{opacity:0,[e.breakpoints.down("sm")]:{opacity:1},display:"flex",flexDirection:"column",gap:8,transition:"opacity 0.3s ease, visibility 0.3s ease"},icon:{marginRight:24,"&:hover":{cursor:"pointer"}},dialogTitle:{"& [class*=MuiTypography-h6]":{fontSize:20,fontWeight:600,color:"rgb(0,0,0,0.87)"}},textFieldPopper:{[e.breakpoints.down("md")]:{left:"12px !important",minWidth:"calc(100% - 35px)"},[e.breakpoints.up("md")]:{left:"calc(12.5vw - 16px) !important",minWidth:"calc(25vw + 54px)"}},iconButton:{borderRadius:"4px",border:"1px solid #E8E8E8",backgroundColor:"white","&:hover":{backgroundColor:"#0a474c",color:"white"},padding:6},selectedButton:{marginTop:"16px",color:"white",background:"linear-gradient(90deg, #0a474c 0%, #0c5456 46.36%, #0d6161 59.52%,#0e6e6b 100%)"},unselectedButton:{marginTop:"16px",color:"black",backgroundColor:"white",border:"1px solid #E8E8E8","&:hover":{backgroundColor:"#E8E8E8"}},qualityStatus:{'& .MuiChip-label, & [class*="MuiChip-label-"]':{color:"white"}},generateButton:{background:"linear-gradient(90deg, #0a474c 0%, #0c5456 46.36%, #0d6161 59.52%,#0e6e6b 100%)",color:"white",borderRadius:"8px",animation:"$gradient 4s ease infinite",position:"relative",overflow:"hidden","&:before":{content:'""',position:"absolute",top:0,left:"-100%",width:"100%",height:"100%",background:"linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent)",animation:"$shine 1.2s linear infinite"},"&:hover":{boxShadow:"0px 2px 6px 0px #3C404326"},"&:disabled":{color:"white"},width:"100%",padding:"8px 16px",height:"40px"},promptHistoryButton:{color:"#0a474c",border:"1px solid #0a474c",borderRadius:"8px",padding:"6px 24px","&:disabled":{color:"#808080",border:"1px solid #808080"}},promptHistoryButtonSmall:{color:"#0a474c",padding:"8px","&:disabled":{color:"#808080"}},textArea:{width:"100%",'& .MuiOutlinedInput-root, & [class*="MuiOutlinedInput-root-"]':{backgroundColor:"#f5f5f5",borderRadius:"8px","&:hover":{backgroundColor:"#ebebeb"},"&.Mui-focused":{backgroundColor:"#ffffff"}}},characterCounter:{color:"#808080"},aiLogoContainer:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#ebf5f3",borderRadius:"6px",padding:"8px",animation:"$gradient 4s ease infinite",position:"relative",overflow:"hidden","&:before":{content:'""',position:"absolute",top:0,left:"-100%",width:"100%",height:"100%",background:"linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent)",animation:"$shine 1.2s linear infinite"}},shimmerAnimation:{position:"relative",overflow:"hidden","&::before":{content:'""',position:"absolute",top:0,left:"-100%",width:"100%",height:"100%",background:"linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.6) 50%, transparent 100%)",animation:"$shimmer 2s ease-in-out infinite",zIndex:1}},historyDrawerMainContainer:{display:"flex",flexDirection:"column",height:"100%",overflowX:"hidden",
1width:"42rem",[e.breakpoints.down("sm")]:{width:"100%"}},historyImagePreviewContainer:{width:"100%"},historyLoadingContainer:{display:"flex",justifyContent:"center",marginTop:"auto",marginBottom:"auto",width:"100%"},historyContainer:{flex:1,overflowY:"auto",backgroundColor:"#f9f9f9",width:"100%"},assetContainer:{display:"flex",gap:"40px",[e.breakpoints.down("sm")]:{flexDirection:"column"}},assetImageContainer:{display:"flex",flexDirection:"column",width:"200px",height:"200px",border:"1px solid #E8E8E8",borderRadius:"8px",justifyContent:"center",alignItems:"center",cursor:"pointer",position:"relative"},assetImage:{objectFit:"cover",width:"100%",height:"100%",borderRadius:"8px",cursor:"pointer"},deleteButton:{position:"absolute",top:"8px",right:"8px",backgroundColor:"white",border:"1px solid #E8E8E8",borderRadius:"4px",padding:"4px",cursor:"pointer",zIndex:1,"&:hover":{backgroundColor:"#E8E8E8"}},"@global":{"@keyframes gradient":{"0%":{backgroundPosition:"0% 50%"},"50%":{backgroundPosition:"100% 50%"},"100%":{backgroundPosition:"0% 50%"}},"@keyframes shimmer":{"0%":{left:"-100%"},"100%":{left:"100%"}},"@keyframes shine":{"0%":{left:"-100%"},"100%":{left:"100%"}}},adDetailMedia:{display:"flex",alignItems:"center",[e.breakpoints.up(1100)]:{display:"flex",flexDirection:"row"},[e.breakpoints.down(1100)]:{flexDirection:"column",gap:"5px"},[e.breakpoints.down(950)]:{display:"flex",flexDirection:"row"},[e.breakpoints.down(700)]:{flexDirection:"column",gap:"5px"}}})))((0,r.withRouter)((vd=_d,e=>{const t=(0,o.useTheme)(),a=(0,o.useMediaQuery)(t.breakpoints.down("sm"));return(0,h.jsx)(vd,{...e,theme:t,isSmallScreen:a})})));var vd;class Ed extends n.Component{constructor(e){super(e),this.state={createPixelDialogOpen:!1,pixelName:"",pixelDescription:"",pixelNameError:"",pixelOptions:[],pixelsLoading:!1,pixelSearchQuery:"",creatingPixel:!1,snackbar:{open:!1,message:"",severity:"success"},code:"",hasLeadFormPermissions:null,leadFormTosAccepted:!1,checkingPermissions:!1,whatsappNumberLinked:null},this.debouncedSearchPixels=this.debounce(this.searchPixels,500)}debounce=(e,t)=>{let a;return function(){for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];clearTimeout(a),a=setTimeout((()=>e(...s)),t)}};componentDidMount(){const e=this.props.assistantId||this.props.match?.params?.projectId;e&&(this.props.fetchPixels({assistantId:e}),this.checkLeadFormPermissions(),this.checkWhatsappNumberLinked(e))}checkWhatsappNumberLinked=async e=>{try{const{raw:t}=await this.props.loadMetaAdSetup(e),a=t?.whatsappNumberLinked;"boolean"==typeof a&&this.setState({whatsappNumberLinked:a})}catch(e){console.log("AdType: whatsappNumberLinked check failed",e?.message)}};componentDidUpdate(e){const t=e.assistantId||e.match?.params?.projectId,a=this.props.assistantId||this.props.match?.params?.projectId,n=e.parentState?.selectedMetaPageId,s=this.props.parentState?.selectedMetaPageId;(t!==a||n!==s)&&a&&s&&this.checkLeadFormPermissions();e.parentState;const o=this.props.parentState?.adType,i=this.props.parentState?.adObjective;if("LEAD"===o?.type&&(!i||"OUTCOME_LEADS"!==i.value)){const e=ea.c8.find((e=>"OUTCOME_LEADS"===e.value));e&&this.props.changeState("adObjective",e)}}checkLeadFormPermissions=async()=>{const e=this.props.assistantId||this.props.match?.params?.projectId,t=this.props.parentState?.selectedMetaPageId;if(e&&t){this.setState({checkingPermissions:!0});try{const a=await this.props.checkWizardLeadFormPermissions({assistantId:e,pageId:t});if(console.log("AdType: Permission check response:",a),a?.status){const e=!0===a.hasLeadFormPermissions,t=!0===a.leadFormTosAccepted;console.log("AdType: Setting permissions state:",{hasPermissions:e,tosAccepted:t,rawHasPermissions:a.hasLeadFormPermissions,rawTosAccepted:a.leadFormTosAccepted}),this.setState({hasLeadFormPermissions:e,leadFormTosAccepted:t,checkingPermissions:!1},(()=>{console.log("AdType: State updated:",{hasLeadFormPermissions:this.state.hasLeadFormPermissions,leadFormTosAccepted:this.state.leadFormTosAccepted})}))}else console.log("AdType: API returned status false, setting permissions to fal
1se"),this.setState({hasLeadFormPermissions:!1,leadFormTosAccepted:!1,checkingPermissions:!1})}catch(e){console.error("AdType: Error checking lead form permissions:",e),console.error("AdType: Error response:",e?.response?.data),this.setState({hasLeadFormPermissions:!1,leadFormTosAccepted:!1,checkingPermissions:!1})}}else console.log("AdType: Missing assistantId or pageId, skipping permission check",{assistantId:e,pageId:t})};handleCreatePixel=()=>{this.setState({createPixelDialogOpen:!0})};handleCloseCreatePixelDialog=()=>{this.setState({createPixelDialogOpen:!1,pixelName:"",pixelDescription:"",pixelNameError:""})};handlePixelNameChange=e=>{const t=e.target.value;t.length<=100&&this.setState({pixelName:t,pixelNameError:""===t.trim()?"Pixel name is required":""})};handlePixelDescriptionChange=e=>{const t=e.target.value;t.length<=1024&&this.setState({pixelDescription:t})};handleCreatePixelSubmit=async()=>{const{assistantId:e,match:t}=this.props,{pixelName:a,pixelDescription:n}=this.state,s=e||t?.params?.projectId;if(a&&""!==a.trim())if(s){this.setState({creatingPixel:!0});try{const e=await this.props.createPixel({assistantId:s,pixelName:a.trim(),pixelDescription:n.trim()||""});this.setState({creatingPixel:!1,createPixelDialogOpen:!1,pixelName:"",pixelDescription:"",pixelNameError:"",snackbar:{open:!0,message:e?.message||"Pixel created successfully!",severity:"success"}}),s&&setTimeout((()=>{this.props.fetchPixels({assistantId:s})}),500)}catch(e){const t=e?.response?.data?.message||e?.message||"Failed to create pixel. Please try again.";this.setState({creatingPixel:!1,snackbar:{open:!0,message:t,severity:"error"}})}}else this.setState({snackbar:{open:!0,message:"Assistant ID is missing. Please try again.",severity:"error"}});else this.setState({pixelNameError:"Pixel name is required"})};handleSnackbarClose=(e,t)=>{"clickaway"!==t&&this.setState({snackbar:{open:!1,message:"",severity:"success"}})};isAdTypeOptionDisabled=e=>{if("ctwa"===e.value||"website_to_whatsapp"===e.value)return!1===this.state.whatsappNumberLinked;if("lead_form"!==e.value)return!1;const{hasLeadFormPermissions:t,leadFormTosAccepted:a}=this.state;return null!==t&&!this.state.checkingPermissions&&(!1===t||!1===a)};getAdTypeOptionTooltip=e=>{if("ctwa"===e.value||"website_to_whatsapp"===e.value)return!1===this.state.whatsappNumberLinked?"Verify your WhatsApp number in Setup (Link Whatsapp Number) to run WhatsApp Ads":null;if("lead_form"!==e.value)return null;const{hasLeadFormPermissions:t,leadFormTosAccepted:a}=this.state;return null===t||this.state.checkingPermissions?null:!1===t?"Please reconnect your Meta account with the 'pages_manage_ads' permission to run Lead Form Ads":!1===a?"Accept the Lead Form Terms of Service in Setup to run Lead Form Ads":null};handleAdTypeSelect=e=>{const{changeState:t}=this.props;t("adType",e),t("pixel",""),t("conversionEvent",""),t("leadForm","");const{objective:a,goal:n}=(0,ea.Nj)(e?.type);t("adObjective",a||""),t("optimizationGoal",n||"")};render(){const{classes:e,parentState:t,isAdFetched:a,isCreateAd:n,changeState:s,isLiveAD:i}=this.props,{adType:r,optimizationGoal:l,adObjective:c,pixel:p,conversionEvent:u}=t||{};let m=c;if("LEAD"===r?.type){const e=ea.c8.find((e=>"OUTCOME_LEADS"===e.value));e&&(m=e)}const g=ea.Kx;return(0,h.jsxs)(o.Grid,{container:!0,spacing:3,children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,children:[(0,h.jsxs)(o.Box,{style:{marginBottom:"16px"},children:[(0,h.jsx)(o.Box,{style:{display:"flex",alignItems:"flex-start",gap:"14px",marginBottom:"16px"}}),a||n?(0,h.jsx)(o.Grid,{container:!0,spacing:2,children:g.map((t=>{const a=r?.value===t.value,n=i||this.isAdTypeOptionDisabled(t),s=i?null:this.getAdTypeOptionTooltip(t),l=(0,h.jsxs)(o.Box,{onClick:()=>{n||a||this.handleAdTypeSelect(t)},className:`${e.adTypeCard} ${a?e.adTypeCardSelected:""} ${n?e.adTypeCardDisabled:""}`,children:[Ut[t.value]||null,(0,h.jsxs)(o.Box,{className:e.adTypeCardBody,children:[(0,h.jsx)(o.Box,{className:e.adTypeCardTitleRow,children:(0,h.jsx)(o.Typography,{variant:"h6",className:e.adTypeCardTitle,children:t.label})}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",className:e.adTypeCardDescription,children:t.description})]}),a?(0,h.jsx)(d.CheckCircle,{className:`${e.adTypeRadio} ${e.adTypeRadioSelected}`}):(0,h.jsx)(d.RadioButtonUnchecked,{className:e.adTypeRadio})]});return(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:6,children:s?(0,h.jsx)(o.Tooltip,{title:s,placement:"top",arrow:!0,children:(0,h.jsx)("span",{style:{display:"block",height:"100%"},children:l})}):l},t.value)}))}):(0,h.jsx)(o.Grid,{container:!0,spacing:2,children:g.map((e=>(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:6,children:(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:112,style:{borderRadius:"12px"}})},e.value)))})]}),(0,h.jsxs)(o.Box,{style:{display:"flex",gap:"20px",width:"100%"},children:[(0,h.jsx)(o.Box,{style:{width:"50%"},children:(0,h.jsx)(X,{isFetching:!(a||n),options:ea.c8.filter((e=>"OUTCOME_LEADS"===e.value?"LEAD"===r?.type:"LEAD"!==r?.type||"OUTCOME_LEADS"===e.value)),value:m,onChange:async(e,t)=>{s("adObjective",t),s("optimizationGoal",""),s("pixel",""),s("conversionEvent",""),s("leadForm","")},placeholder:"Select Ad Objective",classes:e,label:"Ad Objective",marginBottom:"16
1px",isDisabled:i||"LEAD"===r?.type})}),(0,h.jsx)(o.Box,{style:{width:"50%"},children:(0,h.jsx)(X,{isFetching:!(a||n),options:ea.c8.find((e=>e?.value==m?.value))?.optimizationGoals?.filter((e=>"GOALS"==e.value||e.conversionLocations?.includes(r?.type)))||[],showDescription:!0,showHeader:!0,value:l,onChange:async(e,t)=>{s("optimizationGoal",t),s("conversionEvent",""),s("pixel","")},isDisabled:!c?.value||!r?.value||i,placeholder:"Select data source",classes:e,label:"Performance Goal",marginBottom:"16px"})})]}),("OFFSITE_CONVERSIONS"===l?.value||"VALUE"===l?.value)&&(0,h.jsx)(o.Grid,{item:!0,xs:12,children:(()=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",justifyContent:"space-between",style:{marginBottom:"8px"}}),a||n?(0,h.jsx)("div",{children:(0,h.jsx)(X,{isFetching:!(a||n),options:this.props.pixels.filter((e=>"ACTIVE"===e.status)).map((e=>({label:`${e.name} (${e.pixelId})`,value:e.pixelId}))),value:p,onChange:async(e,t)=>{if(s("pixel",t),t?.value&&this.props.assistantId)try{await this.props.fetchPixelDetails({assistantId:this.props.assistantId,pixelId:t.value})}catch(e){console.error("Error fetching pixel details:",e)}},placeholder:"Select Pixel",classes:e,label:"Pixel "+("OFFSITE_CONVERSIONS"==l?.value||"VALUE"==l?.value?"":"(Optional)"),description:"Attach a Facebook Pixel ID to track conversions and optimize your ad performance",marginBottom:"16px",button:(0,h.jsx)(o.Button,{size:"small",variant:"outlined",color:"primary",onClick:()=>this.handleCreatePixel(),startIcon:(0,h.jsx)(Qe.A,{size:16}),style:{textTransform:"none",fontSize:"13px",padding:"6px 12px"},children:"Create New Pixel"}),isDisabled:!c?.value||!r?.value||!l?.value||i})}):(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,style:{borderRadius:"10px"}})]}))()}),p?.value&&("OFFSITE_CONVERSIONS"===l?.value||"VALUE"===l?.value)&&(0,h.jsx)(o.Grid,{item:!0,xs:12,style:{marginTop:"20px"},children:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(X,{isFetching:!(a||n),options:ea.rO.filter((e=>e.supportedTypes.includes(c?.value)&&!("VALUE"==l?.value&&"PURCHASE"==e.value))),value:u,onChange:(e,t)=>
1{s("conversionEvent",t)},placeholder:"Select Conversion Event",classes:e,showDescription:!0,showEventType:!0,label:"Conversion Event",marginBottom:"16px",isDisabled:i})})})]}),(0,h.jsxs)(o.Dialog,{open:this.state.createPixelDialogOpen,onClose:(e,t)=>{"backdropClick"!==t&&this.handleCloseCreatePixelDialog()},maxWidth:"sm",fullWidth:!0,className:e.createPixelDialog,children:[(0,h.jsxs)(o.DialogTitle,{className:e.dialogTitle,children:[(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",gap:5,children:(0,h.jsx)(o.Typography,{variant:"h5",className:e.dialogTitleText,children:"Create Pixel"})}),(0,h.jsx)(o.IconButton,{onClick:this.handleCloseCreatePixelDialog,className:e.closeButton,size:"small",children:(0,h.jsx)(d.Close,{})})]}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",className:e.dialogSubtitle,children:"Set up a new Meta Pixel to track conversions and optimize your ad performance"})]}),(0,h.jsx)(o.DialogContent,{className:e.dialogContent,children:(0,h.jsxs)(o.Box,{className:e.contentCard,children:[(0,h.jsxs)(o.Box,{mb:2,children:[(0,h.jsx)(o.Typography,{variant:"body2",className:e.inputLabel,children:"Pixel Name"}),(0,h.jsx)(o.Paper,{className:e.inputCard,elevation:0,children:(0,h.jsx)(o.TextField,{variant:"outlined",fullWidth:!0,placeholder:"Enter pixel name",value:this.state.pixelName,onChange:this.handlePixelNameChange,error:!!this.state.pixelNameError,helperText:this.state.pixelNameError,classes:{root:e.TextFieldRoot},InputProps:{classes:{input:e.inputPadding},endAdornment:(0,h.jsx)(o.InputAdornment,{position:"end",children:(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",className:e.charCount,children:`${(this.state.pixelName||"").length}/100`})})},FormHelperTextProps:{style:{marginTop:"4px",fontSize:"12px"}}})})]}),(0,h.jsxs)(o.Box,{mb:2,children:[(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",gap:1,style:{marginBottom:"8px"},children:(0,h.jsx)(o.Typography,{variant:"body2",className:e.inputLabel,children:"Description"})}),(0,h.jsx)(o.Paper,{className:e.inputCard,elevation:0,children:(0,h.jsxs)(o.Box,{position:"relative",children:[(0,h.jsx)(o.TextField,{variant:"outlined",fullWidth:!0,multiline:!0,rows:4,placeholder:"Describe this pixel for future reference",value:this.state.pixelDescription,onChange:this.handlePixelDescriptionChange,classes:{root:e.TextFieldRoot},InputProps:{classes:{input:e.inputPadding}}}),(0,h.jsx)(o.Box,{position:"absolute",bottom:"12px",right:"14px",style:{pointerEvents:"none"},children:(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",className:e.charCount,children:`${(this.state.pixelDescription||"").length}/1024`})})]})})]})]})}),(0,h.jsxs)(o.DialogActions,{className:e.dialogActions,children:[(0,h.jsx)(o.Button,{onClick:this.handleCloseCreatePixelDialog,variant:"outlined",className:e.cancelButton,children:"Cancel"}),(0,h.jsx)(o.Button,{onClick:this.handleCreatePixelSubmit,variant:"contained",color:"primary",disabled:!this.state.pixelName||""===this.state.pixelName.trim()||!!this.state.pixelNameError||this.state.creatingPixel,startIcon:this.state.creatingPixel?(0,h.jsx)(o.CircularProgress,{size:16,color:"inherit"}):null,children:this.state.creatingPixel?"Creating...":"Create Pixel"})]})]}),(0,h.jsx)(o.Snackbar,{open:this.state.snackbar.open,autoHideDuration:3e3,onClose:this.handleSnackbarClose,anchorOrigin:{vertical:"top",horizontal:"center"},children:(0,h.jsx)(O.Alert,{onClose:this.handleSnackbarClose,severity:this.state.snackbar.severity,children:this.state.snackbar.message})})]})}}const Td=(0,i.connect)((e=>({assistantDetails:e.assistantDetails.data,assistantId:e.login?.user?.assistantId||e.assistantDetails?.data?.assistantId,pixels:e.audience.pixels,pixelsLoading:e.audience.pixelsLoading,pixelsError:e.audience.pixelsError,pixelsPagination:e.audience.pixelsPagination,pixelEvents:e.audience.pixelEvents,pixelEventsCustomFields:e.audience.pixelEventsCustomFields})),{fetchPixels:z.aR,fetchPixelDetails:z.X3,createPixel:z.Vn,loadMetaAdSetup:M.cg,checkWizardLeadFormPermissions:M.xS})(Ed),Dd=(0,o.withStyles)((e=>
1({adTypeCard:{display:"flex",alignItems:"flex-start",gap:"14px",borderRadius:"12px",padding:"16px",height:"100%",boxSizing:"border-box",border:"0.5px solid #e0e0e0",background:"transparent",cursor:"pointer",transition:"all 0.2s"},adTypeCardSelected:{border:`0.5px solid ${e.palette.primary.main}`,boxShadow:`0 0 0 1px ${e.palette.primary.main}`,background:"linear-gradient(90deg, rgba(37, 211, 102, 0.07) 0%, rgba(255, 255, 255, 0) 60%)"},adTypeCardDisabled:{cursor:"not-allowed",opacity:.5},adTypeCardBody:{minWidth:0,flex:1},adTypeCardTitleRow:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},adTypeCardTitle:{fontWeight:700,fontSize:"15px",lineHeight:1.3},adTypeCardDescription:{fontSize:"13px",marginTop:"2px"},adTypeTag:{fontSize:"10px",fontWeight:700,letterSpacing:"0.4px",padding:"2px 8px",borderRadius:"10px"},adTypeTagRecommended:{backgroundColor:"rgba(37, 211, 102, 0.15)",color:"#0a7c43"},adTypeTagBeta:{backgroundColor:"rgba(124, 58, 237, 0.12)",color:"#7C3AED"},adTypeRadio:{fontSize:"22px",flexShrink:0,color:"#cfcfcf"},adTypeRadioSelected:{color:e.palette.primary.main},textFieldRoot1:{width:"100%",padding:"2px 10px",paddinTop:"4px",paddingLeft:"50px",marginTop:"4px","& input":{width:"calc(100% - 80px)",marginLeft:"80px"},background:"rgb(240,240,240)"},inputRoot:{'&[class*="MuiOutlinedInput-root"][class*=MuiAutocomplete-input]':{padding:12},'&&[class*="MuiOutlinedInput-root"]':{padding:0},'&[class*="MuiOutlinedInput-root"][class*=MuiAutocomplete-inputRoot]':{paddingRight:"0 !important",paddingLeft:"0 !important"}},selectRoot:{backgroundColor:"rgb(240,240,240)",borderRadius:"8px",'& .MuiSelect-select, & [class*="MuiSelect-select-"]':{overflow:"hidden",textOverflow:"ellipsis"}},inputPadding:{padding:"12px 10px"},adTypeInputPadding:{padding:"0px 0px"},createPixelDialog:{'& .MuiDialog-paper, & [class*="MuiDialog-paper-"]':{borderRadius:"12px",overflow:"hidden"}},textFieldRoot:{backgroundColor:"rgb(240,240,240)",outline:"none",border:"none",borderRadius:"8px",width:"100%",padding:"0",boxShadow:"none",boxSizing:"border-box",fontFamily:"Roboto, sans-serif",fontSize:"15px",fontWeight:500,maxHeight:"12em",overflow:"auto","&::-webkit-scrollbar":{width:"4px"}},dialogTitle:{padding:e.spacing(3,3,2),backgroundColor:"#F5F5F5",borderBottom:"none",[e.breakpoints.down("sm")]:{padding:e.spacing(2.5,2.5,1.5)},[e.breakpoints.down("xs")]:{padding:e.spacing(2,2,1.5)}},dialogTitleText:{fontWeight:600,fontSize:"1.25rem",lineHeight:1.5},dialogSubtitle:{marginTop:e.spacing(1),fontSize:"0.875rem",lineHeight:1.5},closeButton:{padding:e.spacing(.5),marginLeft:"auto"},dialogContent:{backgroundColor:"#F5F5F5"},contentCard:{backgroundColor:"white",padding:e.spacing(2.5),borderRadius:"8px",[e.breakpoints.down("sm")]:{padding:e.spacing(2)},[e.breakpoints.down("xs")]:{padding:e.spacing(1.5)}},inputLabel:{marginBottom:e.spacing(1),fontWeight:500,fontSize:"0.875rem",[e.breakpoints.down("xs")]:{fontSize:"0.8125rem",marginBottom:e.spacing(.75)}},inputCard:{backgroundColor:"transparent",padding:0,borderRadius:"8px",border:"none",boxShadow:"none",'& .MuiOutlinedInput-root, & [class*="MuiOutlinedInput-root-"]':{backgroundColor:"#F9F9FB","& fieldset":{border:"none"},"&:hover fieldset":{border:"none"},"&.Mui-focused fieldset":{border:"none"}},'& .MuiInputBase-root, & [class*="MuiInputBase-root-"]':{backgroundColor:"#F9F9FB"}},charCount:{fontSize:"12px",marginRight:"10px"},TextFieldRoot:{width:"100%",marginTop:"4px",background:"#F9F9FB"},dialogActions:{padding:e.spacing(2,3),justifyContent:"flex-end",gap:e.spacing(1),backgroundColor:"#F5F5F5",borderTop:"none",[e.breakpoints.down("sm")]:{padding:e.spacing(1.5,2.5)},[e.breakpoints.down("xs")]:{padding:e.spacing(1.5,2),flexDirection:"column-reverse","& button":{width:"100%"}}},cancelButton:{textTransform:"none",borderRadius:"8px"}})))((0,r.withRouter)(Td));var wd=a(64810),Nd=a(5825);const jd=()=>(0,h.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"49",viewBox:"0 0 48 49",fill:"none",children:[(0,h.jsx)("rect",{y:"49",width:"49",height:"48",rx:"24",transform:"rotate(-90 0 49)",fill:"#FEE2E1"}
1),(0,h.jsx)("path",{d:"M37.497 30.6907L27.0031 12.4665C26.7409 12.02 26.3665 11.6498 25.9171 11.3925C25.4678 11.1353 24.959 11 24.4412 11C23.9234 11 23.4145 11.1353 22.9652 11.3925C22.5158 11.6498 22.1414 12.02 21.8792 12.4665L11.3853 30.6907C11.133 31.1225 11 31.6137 11 32.1139C11 32.614 11.133 33.1052 11.3853 33.5371C11.6442 33.9862 12.0179 34.3585 12.4681 34.6155C12.9183 34.8726 13.4288 35.0052 13.9473 34.9998H34.9351C35.4531 35.0048 35.9631 34.872 36.4128 34.6149C36.8626 34.3579 37.236 33.9859 37.4946 33.5371C37.7473 33.1054 37.8807 32.6144 37.8811 32.1142C37.8815 31.614 37.749 31.1228 37.497 30.6907ZM35.8326 32.5759C35.7412 32.7319 35.6098 32.8608 35.4521 32.9494C35.2944 33.038 35.1159 33.083 34.9351 33.0799H13.9473C13.7664 33.083 13.5879 33.038 13.4302 32.9494C13.2725 32.8608 13.1412 32.7319 13.0497 32.5759C12.9668 32.4356 12.9231 32.2756 12.9231 32.1127C12.9231 31.9497 12.9668 31.7898 13.0497 31.6495L23.5436 13.4253C23.6369 13.2699 23.7688 13.1414 23.9265 13.0522C24.0842 12.963 24.2624 12.9161 24.4436 12.9161C24.6248 12.9161 24.8029 12.963 24.9606 13.0522C25.1183 13.1414 25.2502 13.2699 25.3435 13.4253L35.8374 31.6495C35.9196 31.7902 35.9625 31.9504 35.9616 32.1133C35.9608 32.2763 35.9162 32.436 35.8326 32.5759ZM23.4812 25.3999V20.6C23.4812 20.3454 23.5823 20.1012 23.7623 19.9212C23.9424 19.7411 24.1866 19.64 24.4412 19.64
1C24.6958 19.64 24.9399 19.7411 25.12 19.9212C25.3 20.1012 25.4011 20.3454 25.4011 20.6V25.3999C25.4011 25.6545 25.3 25.8987 25.12 26.0788C24.9399 26.2588 24.6958 26.3599 24.4412 26.3599C24.1866 26.3599 23.9424 26.2588 23.7623 26.0788C23.5823 25.8987 23.4812 25.6545 23.4812 25.3999ZM25.8811 29.7199C25.8811 30.0047 25.7967 30.2831 25.6385 30.5199C25.4802 30.7567 25.2553 30.9413 24.9922 31.0503C24.7291 31.1593 24.4396 31.1878 24.1602 31.1322C23.8809 31.0766 23.6243 30.9395 23.4229 30.7381C23.2215 30.5367 23.0844 30.2802 23.0288 30.0008C22.9733 29.7215 23.0018 29.432 23.1108 29.1688C23.2198 28.9057 23.4043 28.6808 23.6411 28.5226C23.8779 28.3644 24.1564 28.2799 24.4412 28.2799C24.8231 28.2799 25.1893 28.4316 25.4594 28.7017C25.7294 28.9717 25.8811 29.338 25.8811 29.7199Z",fill:"#DC2625"})]});var kd=a(46758);const Ld=(0,o.withStyles)((e=>({platformCard:{borderRadius:"8px",padding:"16px",cursor:"pointer",transition:"background-color 0.2s",display:"flex",flexDirection:"column"},platformCardHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"},positionChip:{display:"flex",alignItems:"center",justifyContent:"center",padding:"5px 14px",borderRadius:"20px",border:"1px solid #a19a9a",cursor:"pointer",transition:"all 0.2s",minHeight:"20px",width:"fit-content","&:hover":{border:"1px solid #a19a9a"}},positionChipSelected:{backgroundColor:e.palette.primary.main,borderRadius:"20px",color:"white","&:hover":{backgroundColor:e.palette.primary.dark},'& .MuiTypography-root, & [class*="MuiTypography-root-"]':{color:"white"}}})))((e=>{let{platform:t,platformIcon:a,platformTitle:n,selectedPositions:s=[],isAiSensy:i,isPlatformSelected:r=!1,onPlatformToggle:l,onPositionToggle:d,classes:c}=e;const p="facebook"===t?ea._R:ea.s3,u=s.length===p.length;return(0,h.jsxs)(o.Box,{className:c.platformCard,children:[(0,h.jsxs)(o.Box,{className:c.platformCardHeader,style:{cursor:"pointer"},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",gap:"12px"},onClick:e=>{e.stopPropagation(),l(t,r)},children:[(0,h.jsx)(o.Checkbox,{checked:r,onChange:e=>{e.stopPropagation(),l(t,r)},onClick:e=>{e.stopPropagation()},color:"primary",style:{padding:"4px"}}),(0,h.jsx)("img",{src:a,alt:`${n} icon`,style:{width:"24px",height:"24px"}}),(0,h.jsx)(o.Typography,{variant:"h6",style:{fontWeight:600},children:n})]}),r&&(0,h.jsx)(o.Typography,{variant:"body2",style:{color:"#0a474c",fontSize:"12px",fontWeight:500,whiteSpace:"nowrap",cursor:"pointer"},onClick:e=>{e.stopPropagation(),l(t,u?"clear-all":"select-all")},children:u?"Clear All":"Select All"})]}),r&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:"12px"},children:[s.length," placements"]}),(0,h.jsx)(o.Grid,{container:!0,spacing:1,style:{flex:1,alignContent:"flex-start"},children:p.map((e=>{const a=s.includes(e.value);return(0,h.jsx)(o.Grid,{item:!0,style:{width:"auto"},children:(0,h.jsx)(o.Tooltip,{title:e.description||e.label,placement:"top",children:(0,h.jsxs)(o.Box,{className:`${c.positionChip} ${a?c.positionChipSelected:""}`,onClick:a=>{a.stopPropagation(),d(t,e.value)},children:[a&&(0,h.jsx)(Xi.A,{size:12,style:{marginRight:"3px"}}),(0,h.jsx)(o.Typography,{variant:"body2",style:{fontSize:"11px",whiteSpace:"nowrap"},children:e.label})]})})},e.value)}))})]})]})})),Rd=a.p+"980f51fe02c1b4e6018978f5ac2f1025.png",Bd=a.p+"e719d8b29f452a16302dde353806c1fa.png";var Od=a(44041);function Pd(e){let{advanceFilterOptions:t,advanceSearchOptions:a,advanceTargetLoading:n,classes:i,selectedAdvanceTargets:r,changeState:l,deprecatedAdvanceTargets:c,parentState:p,handleAdvanceTargetChange:u,handleAdvanceTargetSelection:m,targetOptionComponent:g}=e;return(0,h.jsxs)(o.Grid,{item:!0,xs:!0,className:i.bottomMargin,children:[(0,h.jsxs)("div",{className:i.targetTitleContainer,children:[(0,h.jsx)(o.Typography,{variant:"h5",style:{marginBottom:"0.35em"},children:"Advanced Targeting"}),(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)("div",{className:i.colorDot,style:{backgroundColor:"#efa95e"}}),(0,h.jsx)(o.Typography,{variant:"body2",className:i.targetTypeText,children:"Interests"})]}),(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)("div",{className:i.colorDot,style:{backgroundColor:"#8859E7"}}),(0,h.jsx)(o.Typography,{variant:"body2",className:i.targetTypeText,children:"Demographics"})]}),(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)("div",{className:i.colorDot,style:{backgroundColor:"#28c152"}}),(0,h.jsx)(o.Typography,{variant:"body2",className:i.targetTypeText,children:"Behaviors"})]})]})]}),!as().isEmpty(r)&&(0,h.jsx)("div",{className:i.targetMainContainer,children:r.map((e=>{const t=c.some((t=>
1t.id===e.value.id));return(0,h.jsxs)("div",{className:`${i.targetItem} ${t?i.deprecated:e?.value?.path&&"Interests"===e?.value?.path[0]?i.interests:e?.value?.path&&"Demographics"===e?.value?.path[0]?i.demographics:e?.value?.path&&"Behaviors"===e?.value?.path[0]?i.behaviors:""}`,children:[(0,h.jsx)("div",{className:i.targetInfo,children:(0,h.jsx)("div",{className:i.targetNameGroup,children:(0,h.jsx)(o.Tooltip,{title:e.label,children:(0,h.jsxs)(o.Typography,{className:i.targetName,children:[t&&(0,h.jsx)(d.InfoOutlined,{style:{width:"15px",marginRight:"5px"}}),e.label,t&&(0,h.jsx)(o.Chip,{label:"DEPRECATED",className:i.deprecatedChip,component:"span"})]})})})}),(0,h.jsx)("div",{className:i.rightSection,children:(0,h.jsx)(o.IconButton,{size:"small",className:i.removeButton,onClick:()=>{const t=r.filter((t=>t.value.id!==e.value.id));m(null,t)},children:(0,h.jsx)(Ei.A,{size:16,className:`${t?i.deprecatedRemoveIcon:e?.value?.path&&"Interests"===e?.value?.path[0]?i.interestsRemoveIcon:e?.value?.path&&"Demographics"===e?.value?.path[0]?i.demographicsRemoveIcon:e?.value?.path&&"Behaviors"===e?.value?.path[0]?i.behaviorsRemoveIcon:""}`})})})]},`${e.value.type}-${e.value.id}`)}))}),(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsx)(wd.Ay,{multiple:!0,value:r,onChange:m,loading:n,className:`${i.autocompletePadding} ${r.length>0?"advanced-targeting-autocomplete":""}`,style:{borderRadius:"0 0 8px 8px"},options:a.filter((e=>e?.type)).map((e=>{const{name:t}=e;return{label:t,value:e}})),filterOptions:e=>e.filter((e=>{const{value:a}=e,{id:n,type:s}=a||{};return!t?.includes(`${s}-${n}`)})),getOptionLabel:e=>e.label||e,renderOption:g,renderInput:e=>(0,h.jsx)(o.TextField,{...e,variant:"outlined",placeholder:"Type Interests, Demographics or behaviours and press enter to add",classes:{root:`${i.textFieldRoot} ${r.length>0?i.noTopRadius:""}`},InputProps:{...e.InputProps,endAdornment:(0,h.jsx)(s().Fragment,{children:(0,h.jsx)(o.InputAdornment,{children:n?(0,h.jsx)(o.IconButton,{children:(0,h.jsx)(o.CircularProgress,{size:16})}):null})})},onChange:u,onKeyDown:e=>{"Backspace"===e.key&&""===e.target.value&&e.stopPropagation()},name:"advanceTargets"}),renderTags:()=>null,classes:{inputRoot:i.inputRoot}})}),(0,h.jsxs)(o.Box,{style:{marginTop:24,display:"block"},children:[(0,h.jsxs)(o.Typography,{variant:"h5",gutterBottom:!0,style:{marginBottom:8,display:"flex",alignItems:"center"},children:["Audience expansion",(0,h.jsx)(o.Tooltip,{title:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.Typography,{variant:"body2",display:"block",style:{marginBottom:4},children:[(0,h.jsx)("strong",{children:"On:"})," Meta can show your ad to more people similar to your targeting. Location, age, language and exclusions stay fixed. Often improves performance."]}),(0,h.jsxs)(o.Typography,{variant:"body2",display:"block",children:[(0,h.jsx)("strong",{children:"Off:"})," Ad is shown only to your selected audience—no expansion beyond your targeting."]})]}),arrow:!0,placement:"right",children:(0,h.jsx)(d.InfoOutlined,{style:{width:"16px",marginLeft:"6px",color:"#666",cursor:"pointer"}})})]}),(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Switch,{color:"primary",checked:!0===p.advantageAudience,disabled:!0===p.advantageAudienceLocked,onChange:e=>l("advantageAudience",e.target.checked)}),label:(0,h.jsx)(o.Typography,{variant:"body2",component:"span",children:"Allow Meta to expand audience"})}),!0===p.advantageAudienceLocked&&(0,h.jsx)(o.Typography,{variant:"caption",component:"p",style:{color:"#666",marginTop:"-4px"},children:"Advantage+ audience can’t be turned off after an ad is created. Create a new ad to set detailed targeting, lookalikes or custom audiences as controls."})]})]})}function Md(e){let{classes:t,isWhatsappStatusAd:a,resolvedFacebookPositions:n,resolvedInstagramPositions:s,selectedPlatforms:i,parentState:r,handlePlatformToggle:l,handlePositionToggle:d,renderLockedPlacementCard:c}=e;const{isAiSensy:p}=(0,u.x)();return(0,h.jsxs)(o.Grid,{item:!0,xs:!0,className:t.bottomMargin,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:p?"Platforms & Placements":"Platforms"}),a?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,color:"textSecondary",style:{marginBottom:"16
1px"},children:"WhatsApp Status ads also appear on Instagram Stories — Meta requires both placements, so they're pre-selected for you."}),(0,h.jsxs)(o.Grid,{container:!0,spacing:1,children:[(0,h.jsx)(o.Grid,{item:!0,xs:12,md:6,children:c({icon:Ul,title:"WhatsApp",positionLabel:"Status"})}),(0,h.jsx)(o.Grid,{item:!0,xs:12,md:6,children:c({icon:Bd,title:"Instagram",positionLabel:"Stories"})})]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,color:"textSecondary",style:{marginBottom:"16px"},children:p?"Select platforms and specific placements to target your ads":"Select platforms to target your ads"}),(0,h.jsxs)(o.Grid,{container:!0,spacing:1,children:[(0,h.jsx)(o.Grid,{item:!0,xs:12,md:6,children:(0,h.jsx)(Ld,{platform:"instagram",platformIcon:Bd,platformTitle:"Instagram",selectedPositions:s,isAiSensy:p,isPlatformSelected:Array.isArray(r.selectedPlatforms)&&r.selectedPlatforms.includes("instagram"),onPlatformToggle:l,onPositionToggle:d})}),(0,h.jsx)(o.Grid,{item:!0,xs:12,md:6,children:(0,h.jsx)(Ld,{platform:"facebook",platformIcon:Rd,platformTitle:"Facebook",selectedPositions:n,isAiSensy:p,isPlatformSelected:Array.isArray(r.selectedPlatforms)&&r.selectedPlatforms.includes("facebook"),onPlatformToggle:l,onPositionToggle:d})})]})]})]})}function Ud(e){let{classes:t,adSetupDetails:a,isLoading:n,audiences:i,customAndLookalikeAudiences:r,excludedCustomAndLookalikeAudiences:l,nonSelectableAudiences:d,createAudienceMenuAnchor:c,showExcludeAudiences:p,AudiencesIcon:u,changeState:m,setState:g,debouncedAudienceSearch:b}=e;return(0,h.jsxs)(o.Grid,{item:!0,xs:!0,className:t.bottomMargin,children:[(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1,children:[(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,style:{marginBottom:0},children:"Select Custom or Lookalike Audience"}),(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,style:{color:"#6E6E6E",marginBottom:"16px"},children:"Select multiple custom or lookalike audience to target your ads to."})]}),(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",style:{gap:"12px"},children:[(0,h.jsx)(o.Button,{size:"small",variant:"outlined",color:"primary",startIcon:(0,h.jsx)(Qe.A,{size:16}),style:{textTransform:"none",fontSize:"13px",padding:"6px 12px"},onClick:e=>g({createAudienceMenuAnchor:e.currentTarget}),children:"Create Custom or Lookalike Audience"}),(0,h.jsx)(o.Tooltip,{title:p&&!as().isEmpty(l)?"Remove the excluded audiences to hide this section":"",children:(0,h.jsx)("span",{children:(0,h.jsx)(o.Button,{size:"small",variant:"outlined",color:"primary",disabled:p&&!as().isEmpty(l),style:{textTransform:"none",fontSize:"13px",padding:"6px 12px"},onClick:()=>g({showExcludeAudiences:!p}),children:p?"Hide Excluded Audiences":"Exclude Audiences"})})})]}),(0,h.jsxs)(o.Menu,{anchorEl:c,open:Boolean(c),onClose:()=>g({createAudienceMenuAnchor:null}),getContentAnchorEl:null,anchorOrigin:{vertical:"bottom",horizontal:"left"},children:[(0,h.jsx)(o.MenuItem,{onClick:()=>g({createAudienceMenuAnchor:null,createAudienceType:"custom",createAudienceOpen:!0}),children:"Custom Audience"}),(0,h.jsx)(o.MenuItem,{onClick:()=>g({createAudienceMenuAnchor:null,createAudienceType:"lookalike",createAudienceOpen:!0}),children:"Lookalike Audience"})]})]}),(0,h.jsxs)(o.Box,{style:{width:"100%"},children:[(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsx)(wd.Ay,{multiple:!0,options:i.filter((e=>!d.find((t=>t.audienceId==e.audienceId)))).filter(((e,t,a)=>t===a.findIndex((t=>t.audienceId===e.audienceId)))).map((e=>{const{name:t,audienceId:a}=e;return{label:as().compact([t,`(${a})`]).join(" "),value:e}})),getOptionLabel:e=>e.label||e,value:r,onChange:(e,t,a,n)=>{const{name:s,audienceId:o,accountId:i,type:l}=n?.option?.value;r.find((e=>e.audienceId==o))||m("customAndLookalikeAudiences",[...r,{name:s,audienceId:o,accountId:i,type:l}])},loading:n,className:t.autocompletePadding,renderInput:e=>(0,h.jsx)(o.TextField,{...e,variant:"outlined",placeholder:as().isEmpty(r)?"Search Custom or Lookalike Audiences":"",classes:{root:t.textFieldRoot},InputProps:{...e.InputProps,startAdornment:(0,h.jsx)(o.InputAdornment,{position:"start",children:(0,h.jsx)(Ni.A,{size:20,className:t.
1searchIcon})}),endAdornment:(0,h.jsx)(s().Fragment,{children:(0,h.jsx)(o.InputAdornment,{children:n?(0,h.jsx)(o.IconButton,{children:(0,h.jsx)(o.CircularProgress,{size:16})}):(0,h.jsx)(h.Fragment,{})})})},onChange:e=>b(e.target.value),onKeyDown:e=>{"Backspace"===e.key&&""===e.target.value&&e.stopPropagation()},name:"location"}),renderOption:e=>{let{label:t,value:n}=e;return(0,h.jsxs)(o.Box,{width:"100%",style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)(o.Box,{width:"70%",pr:1,children:(0,h.jsx)(o.Typography,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t||""})}),(0,h.jsxs)(o.Box,{width:"30%",style:{display:"flex",justifyContent:"flex-end",color:"#95a5a6",fontSize:"13px",alignItems:"center"},children:[n?.accountId==a?.selectedMetaAdAccountId?"Owned":"Fetched"," ","- ",as().startCase(n?.type)]})]})},renderTags:()=>null,classes:{inputRoot:t.inputRoot,input:t.autocompleteInput}})}),!as().isEmpty(r)&&(0,h.jsx)("div",{className:t.locationMainContainer,children:r.filter(((e,t,a)=>t===a.findIndex((t=>t.audienceId===e.audienceId)))).map(((e,n)=>(0,h.jsxs)("div",{className:t.locationItem,children:[(0,h.jsxs)("div",{className:t.locationInfo,children:[(0,h.jsx)(u,{className:t.locationPin,fill:"#28c153"}),(0,h.jsx)("div",{className:t.locationNameGroup,children:(0,h.jsxs)(o.Typography,{className:t.locationName,style:{width:"100%"},children:[e?.name," (",e?.audienceId,")"]})})]}),(0,h.jsxs)("div",{className:t.rightSection,children:[(0,h.jsxs)(o.Typography,{className:t.locationType,children:[e?.accountId==a?.selectedMetaAdAccountId?"Owned":"Fetched"," ","- ",as().startCase(e?.type)]}),(0,h.jsx)(o.IconButton,{size:"small",className:t.removeButton,onClick:()=>{const t=r.filter((t=>t.audienceId!==e.audienceId));m("customAndLookalikeAudiences",t)},children:(0,h.jsx)(Ei.A,{size:16,className:t.removeIcon})})]})]},e?.audienceId)))})]}),p&&(0,h.jsxs)(o.Box,{style:{width:"100%",marginTop:"24px"},children:[(0,h.jsx)(o.Typography,{children:"Exclude Custom or Lookalike Audiences"}),(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,style:{color:"#6E6E6E",marginBottom:"16px"},children:"Select custom or lookalike audience to exclude from your ads."}),(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsx)(wd.Ay,{multiple:!0,options:i.filter((e=>!d.find((t=>t.audienceId==e.audienceId)))).filter(((e,t,a)=>t===a.findIndex((t=>t.audienceId===e.audienceId)))).map((e=>{const{name:t,audienceId:a}=e;return{label:as().compact([t,`(${a})`]).join(" "),value:e}})),getOptionLabel:e=>e.label||e,value:l,onChange:(e,t,a,n)=>{const{name:s,audienceId:o,accountId:i,type:r}=n?.option?.value;d.find((e=>e.audienceId==o))||m("excludedCustomAndLookalikeAudiences",[...l,{name:s,audienceId:o,accountId:i,type:r}])},loading:n,className:t.autocompletePadding,renderInput:e=>(0,h.jsx)(o.TextField,{...e,variant:"outlined",placeholder:as().isEmpty(l)?"Search Custom or Lookalike Audiences":"",classes:{root:t.textFieldRoot},InputProps:{...e.InputProps,startAdornment:(0,h.jsx)(o.InputAdornment,{position:"start",children:(0,h.jsx)(Ni.A,{size:20,className:t.searchIcon})}),endAdornment:(0,h.jsx)(s().Fragment,{children:(0,h.jsx)(o.InputAdornment,{children:n?(0,h.jsx)(o.IconButton,{children:(0,h.jsx)(o.CircularProgress,{size:16})}):(0,h.jsx)(h.Fragment,{})})})},onChange:e=>b(e.target.value),onKeyDown:e=>{"Backspace"===e.key&&""===e.target.value&&e.stopPropagation()},name:"location"}),renderOption:e=>{let{label:t,value:n}=e;return(0,h.jsxs)(o.Box,{width:"100%",style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)(o.Box,{width:"70%",pr:1,children:(0,h.jsx)(o.Typography,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t||""})}),(0,h.jsxs)(o.Box,{width:"30%",style:{display:"flex",justifyContent:"flex-end",color:"#95a5a6",fontSize:"13px",alignItems:"center"},children:[n?.accountId==a?.selectedMetaAdAccountId?"Owned":"Fetched"," ","- ",as().startCase(n?.type)]})]})},renderTags:()=>null,classes:{inputRoot:t.inputRoot,input:t.autocompleteInput}})}),!as().isEmpty(l)&&(0,h.jsx)("div",{className:t.locationMainContainer,children:l.filter(((e,t,a)=>t===a.findIndex((t=>
1t.audienceId===e.audienceId)))).map(((e,n)=>(0,h.jsxs)("div",{className:t.locationItem,children:[(0,h.jsxs)("div",{className:t.locationInfo,children:[(0,h.jsx)(u,{className:t.locationPin,fill:"#28c153"}),(0,h.jsx)("div",{className:t.locationNameGroup,children:(0,h.jsxs)(o.Typography,{className:t.locationName,style:{width:"100%"},children:[e?.name," (",e?.audienceId,")"]})})]}),(0,h.jsxs)("div",{className:t.rightSection,children:[(0,h.jsxs)(o.Typography,{className:t.locationType,children:[e?.accountId==a?.selectedMetaAdAccountId?"Owned":"Fetched"," ","- ",as().startCase(e?.type)]}),(0,h.jsx)(o.IconButton,{size:"small",className:t.removeButton,onClick:()=>{const t=l.filter((t=>t.audienceId!==e.audienceId));m("excludedCustomAndLookalikeAudiences",t)},children:(0,h.jsx)(Ei.A,{size:16,className:t.removeIcon})})]})]},e?.audienceId)))})]})]})}function Fd(e){let{classes:t,excludedSelectedLocations:a,geoLocations:n,groupedLocations:i,isLoading:r,selectedLocations:l,locationRadiusMap:d,radiusAnchorEl:c,searchLocation:p,selectedLocationId:u,showExcludeLocations:m,changeState:g,MapPin:b,handleChangeD:y,handleLocationOptions:x,handleRadiusChange:f,handleRadiusClick:A,handleRadiusClose:I,verifyGeoLocations:C,setState:_}=e;return(0,h.jsxs)(o.Grid,{item:!0,xs:!0,className:t.bottomMargin,children:[(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,style:{marginBottom:0},children:"Select Locations"}),(0,h.jsx)(o.Tooltip,{title:m&&!as().isEmpty(a)?"Remove the excluded locations to hide this section":"",children:(0,h.jsx)("span",{children:(0,h.jsx)(o.Button,{size:"small",variant:"outlined",color:"primary",disabled:m&&!as().isEmpty(a),style:{textTransform:"none",fontSize:"13px",padding:"6px 12px"},onClick:()=>_({showExcludeLocations:!m}),children:m?"Hide Excluded Locations":"Exclude Locations"})})})]}),(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsx)(wd.Ay,{multiple:!0,options:p.map((e=>{const{name:t,country_name:a,region:n}=e;return{label:as().compact([t,n,a]).join(", "),value:e}})),getOptionLabel:e=>e.label||e,value:l,onChange:(e,t,a,n)=>{C(t,n,a)},loading:r,className:t.autocompletePadding,renderInput:e=>(0,h.jsx)(o.TextField,{...e,variant:"outlined",placeholder:as().isEmpty(l)?"Search cities, regions, countries, pin codes":"",classes:{root:t.textFieldRoot},InputProps:{...e.InputProps,startAdornment:(0,h.jsx)(o.InputAdornment,{position:"start",children:(0,h.jsx)(Ni.A,{size:20,className:t.searchIcon})}),endAdornment:(0,h.jsx)(s().Fragment,{children:(0,h.jsx)(o.InputAdornment,{children:r?(0,h.jsx)(o.IconButton,{children:(0,h.jsx)(o.CircularProgress,{size:16})}):(0,h.jsx)(h.Fragment,{})})})},onChange:y,onKeyDown:e=>{"Backspace"===e.key&&""===e.target.value&&e.stopPropagation()},name:"location"}),renderOption:x,renderTags:()=>null,classes:{inputRoot:t.inputRoot,input:t.autocompleteInput}})}),!as().isEmpty(l)&&(0,h.jsxs)("div",{className:t.locationMainContainer,children:[Object.entries(i).map((e=>{let[a,s]=e;return(0,h.jsxs)("div",{children:[(0,h.jsx)(o.Typography,{className:t.countryTitle,variant:"h5",gutterBottom:!0,children:a}),s.map((e=>(0,h.jsxs)("div",{className:t.locationItem,children:[(0,h.jsxs)("div",{className:t.locationInfo,children:[(0,h.jsx)(b,{className:t.locationPin,fill:"#28c153"}),(0,h.jsxs)("div",{className:t.locationNameGroup,children:[(0,h.jsx)(o.Tooltip,{title:"zip"===e?.value?.type&&e?.value?.region?`${e.value.name}, ${e.value.region}`:e?.value?.name,children:(0,h.jsx)(o.Typography,{className:t.locationName,children:"zip"===e?.value?.type&&e?.value?.region?`${e.value.name}, ${e.value.region}`:e.value.name})}),kd.DV.includes(e.value.type)&&(0,h.jsxs)(o.Button,{endIcon:(0,h.jsx)(_i.A,{size:16}),variant:"text",className:t.radiusButton,onClick:t=>A(t,e.value.key,e.value.radius),children:["+",e.value.radius," km"]})]})]}),(0,h.jsxs)("div",{className:t.rightSection,children:[(0,h.jsx)(o.Typography,{className:t.locationType,children:(0,kd.Cm)(e.value.type)}),(0,h.jsx)(o.IconButton,{size:"small",className:t.removeButton,onClick:()=>{const t=l.filter((t=>t.value.key!==e.value.key));g("selectedLocations",t),_((t=>{const a={...t.locationRadiusMap};return delete a[e.value.key],{locationRadiusMap:a}}));const a=kd.w7[e?.value?.type]||"cities",s=n[a].filter((t=>(t.key||t)!==e.value.key));g("geoLocations",{...n,[a]:s})},children:(0,h.jsx)(Ei.A,{size:16,className:t.removeIcon})})]})]},e.value.key)))]},a)})),(0,h.jsx)(o.Popover,{open:Boolean(c),anchorEl:c,onClose:I,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{elevation:2},children:(0,h.jsxs)("div",{className:t.radiusPopover,children:[(0,h.jsx)(o.Typography,{className:t.radiusTitle,children:"Select Radius"}),(0,h.jsx)("div",{className:t.radiusSliderContainer,children:(()=>{const e=l.find((e=>e.value.key===u)),a=e?.value?.type;return(0,h.jsx)(Od.A,{className:t.radiusSlider,value:d[u]||kd.Px[a]||40,onChange:f,min:kd.MU[a],max:kd.SM[a],step:1,marks:[{value:kd.MU[a],label:`${kd.MU[a]||1}km`},{value:kd.SM[a],label:`${kd.SM[a]||80}km`}],valueLabelDisplay:"auto"})})()})]})})]})]})}const Wd=new Array(54).fill(1).map(((e,t)=>`${t+13}`));function zd(e){let{FromAge:t,ToAge:a,classes:n,gender:s,isMobile:i,changeState:r}=e;return(0,h.jsx)(o.Grid,{container:!0,style:{display:"flex",gap:"20px",marginTop:"24px"},className:n.bottomMargin,children:(0,h.jsxs)(o.Grid,{container:!0,spacing:2,direction:i?"column":"row",children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,md:6,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Select Gender"}),(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,color:"textSecondary",children:"Choose target gender preference"}),(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsx)(wd.Ay,{disableClearable:!0,autoHighlight:!0,options:["MALE","FEMALE","ALL"],onChange:(e,t,a)=>{r("gender",t)},value:s,renderInput:e=>(0,h.jsx)(o.TextField,{...e,variant:"outlined",classes:{root:n.textFieldRoot},InputProps:{...e.InputProps},placeholder:"Select Gender",name:"gender",value:s}),classes:{inputRoot:n.inputRoot}})})]}),(0,h.jsxs)(o.Grid,{item:!0,xs:12,sm:6,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Select age group"}),(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,color:"textSecondary",children:"Pick specific target age group"}),(0,h.jsxs)(o.Grid,{container:!0,spacing:1,children:[(0,h.jsx)(o.Grid,{item:!0,xs:5,children:(0,h.jsx)(wd.Ay,{disableClearable:!0,autoHighlight:!0,options:Wd.slice(0,-1),getOptionLabel:e=>
1"66"===e?"65+":e,onChange:(e,t,a)=>{r("FromAge",t)},value:t,renderInput:e=>(0,h.jsx)(o.TextField,{...e,variant:"outlined",classes:{root:n.textFieldRoot},InputProps:{...e.InputProps},placeholder:"Select",name:"FromAge",value:t}),classes:{inputRoot:n.inputRoot}})}),(0,h.jsx)(o.Grid,{item:!0,xs:2,style:{display:"flex",alignItems:"center",justifyContent:"center"},children:(0,h.jsx)(o.Typography,{children:"To"})}),(0,h.jsx)(o.Grid,{item:!0,xs:5,children:(0,h.jsx)(wd.Ay,{disableClearable:!0,autoHighlight:!0,options:Wd.filter((e=>e>=t)),getOptionLabel:e=>"66"===e?"65+":e,onChange:(e,t,a)=>{r("ToAge",t)},value:a,renderInput:e=>(0,h.jsx)(o.TextField,{...e,variant:"outlined",classes:{root:n.textFieldRoot},InputProps:{...e.InputProps},placeholder:"Select",name:"toAge",value:a}),classes:{inputRoot:n.inputRoot}})})]})]})]})})}function Gd(e){let{classes:t,gender:a,selectedPlatforms:n,audienceKey:i,audienceSearchLoading:r,hasLoadedInitialAudiences:l,savedAudiences:d,parentState:c,changeAudience:p,handleAudienceSearch:u,handleAudienceSelect:m,loadLatestAudiences:g}=e;return(0,h.jsxs)(o.Grid,{item:!0,xs:12,className:t.bottomMargin,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Use Saved Audiences"}),(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,style:{color:"#6E6E6E",marginBottom:"16px"},children:"Quickly target the right audience by applying pre-saved settings tailored to your needs"}),(0,h.jsx)(o.Box,{style:{maxWidth:"480px"},children:(0,h.jsx)(wd.Ay,{options:d,getOptionLabel:e=>e.audienceName,onChange:m,value:c.selectedAudience,loading:r,onFocus:e=>{l&&""!==e.target.value||g()},clearOnBlur:!1,renderInput:e=>(0,h.jsx)(o.TextField,{...e,variant:"outlined",placeholder:"Search saved audiences",classes:{root:t.textFieldRoot},InputProps:{...e.InputProps,startAdornment:(0,h.jsx)(o.InputAdornment,{position:"start",children:(0,h.jsx)(Ni.A,{size:20,className:t.searchIcon})}),endAdornment:(0,h.jsxs)(s().Fragment,{children:[r?(0,h.jsx)(o.CircularProgress,{size:20,style:{marginRight:60}}):null,e.InputProps.endAdornment]})},onChange:u}),renderOption:e=>(0,h.jsxs)(o.Box,{onClick:t=>{e===c.selectedAudience&&p(e)},width:"100%",children:[(0,h.jsxs)(o.Typography,{variant:"body1",style:{display:"flex",alignItems:"center"},children:[e.audienceName,e.changed&&(0,h.jsx)(o.Typography,{variant:"caption",style:{marginLeft:"8px",color:"#f39c12",backgroundColor:"#fef5e7",padding:"2px 6px",borderRadius:"4px",fontSize:"11px"},children:"Modified"})]}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:`Gender: ${"ALL"===e.gender?"Male, Female":e.gender} • Age: ${e.minAge}-${e.maxAge} • Platforms: ${e.selectedPlatforms?.map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(", ")||""}`})]}),classes:{inputRoot:t.inputRoot}},i)})]})}class Hd extends n.Component{constructor(e){super(e),this.state={allFiltersLocal:null,isLoading:!1,advanceTargetLoading:!1,value:[18,65],age:[],searchLocation:[],selectedLocation:[],LocationValue:[],type:"",country_code:"",region_id:"",key:"",snack:!1,severity:"",advanceSearchOptions:[],advanceFilterOptions:[],radiusAnchorEl:null,selectedLocationId:null,locationRadiusMap:{},savedAudiences:[],audienceSearchLoading:!1,hasLoadedInitialAudiences:!1,audienceKey:0,createAudienceOpen:!1,createAudienceType:"custom",createAudienceMenuAnchor:null,createAudienceSnack:{show:!1,severity:"success",msg:""},showExcludeAudiences:(this.props.parentState?.excludedCustomAndLookalikeAudiences||[]).length>0,showExcludeLocations:(this.props.parentState?.excludedSelectedLocations||[]).length>0},this.handleLocationChange=this.handleLocationChange.bind(this)}isDuplicateAd=(()=>window.location.pathname.includes("duplicate"))();isCreateAd=(()=>window.location.pathname.includes("create"))();componentDidUpdate(e){this.state.showExcludeAudiences||!as().isEmpty(e.parentState?.excludedCustomAndLookalikeAudiences)||as().isEmpty(this.props.parentState?.excludedCustomAndLookalikeAudiences)||this.setState({showExcludeAudiences:!0}),this.state.showExcludeLocations||!as().isEmpty(e.parentState?.excludedSelectedLocations)||as().isEmpty(this.props.parentState?.excludedSelectedLocations)||this.setState({showExcludeLocations:!0})}componentDidMount(){if(this.props.parentState.selectedAudience?this.setState({savedAudiences:[this.props.parentState.selectedAudience],hasLoadedInitialAudiences:!0}):this.loadLatestAudiences(),as().isEmpty(this.props.selectedAdvanceTargets)||this.setAdvanceFilterOptions(this.props.selectedAdvanceTargets),!as().isEmpty(this.props.selectedLocations)){const e={};this.props.selectedLocations.forEach((t=>{t?.value?.type&&kd.DV.includes(t.value.type)&&t.value.radius&&(e[t.value.key]=t.value.radius)})),this.setState({locationRadiusMap:e})}const{assistantDetails:e}=this.props;this.props.fetchAudiences({assistantId:e?.assistantId,page:1,searchTerm:"",type:"ALL",limit:50,source:"META_ADS_TWO_TIER"})}componentWillUnmount(){this.debouncedLogHi.cancel(),this.debouncedTargetSearch.cancel()}debounce=(e,t)=>{let a;return function(){for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];clearTimeout(a),a=setTimeout((()=>e(...s)),t)}};debouncedLogHi=(()=>as().debounce((e=>{let{selectedMetaAdAccountId:t,assistantId:a}=this.props.assistantDetails;t||(t=this.props.adSetupDetails.selectedMetaAdAccountId),this.props.searchLocations({assistantId:a,adAccountId:t,text:e}).then((e=>{const t=(0,kd.CL)(e?.data);this.setState({searchLocation:t,isLoading:!1})}
1)).catch((e=>{console.error(e),this.setState({isLoading:!1,searchLocation:[]})}))}),500))();debouncedAudienceSearch=(()=>as().debounce((e=>{let{selectedMetaAdAccountId:t,assistantId:a}=this.props.assistantDetails;t||(t=this.props.adSetupDetails.selectedMetaAdAccountId),this.props.fetchAudiences({assistantId:a,page:1,searchTerm:e,type:"ALL",limit:50,source:"META_ADS_TWO_TIER"})}),500))();onSnackbarClose=()=>{this.setState({snack:!1})};onCreateAudienceSnackClose=()=>{this.setState({createAudienceSnack:{...this.state.createAudienceSnack,show:!1}})};refreshAudiencesList=async()=>{const{assistantDetails:e,adSetupDetails:t}=this.props,a=e?.adSetupDetails?.selectedMetaAdAccountId||t?.selectedMetaAdAccountId;if(a)try{await this.props.syncAudiences({assistantId:e?.assistantId,adAccountId:a})}catch(e){}this.props.fetchAudiences({assistantId:e?.assistantId,page:1,searchTerm:"",type:"ALL",limit:50,source:"META_ADS_TWO_TIER"})};handleChangeD=(e,t,a)=>{this.debouncedLogHi(e.target.value),this.setState({isLoading:!0})};debouncedTargetSearch=(()=>as().debounce((e=>{let{selectedMetaAdAccountId:t,assistantId:a}=this.props.assistantDetails||{};if(t||(t=this.props.adSetupDetails.selectedMetaAdAccountId),t&&a){const n=(0,ea.oj)(this.props.geoLocations);this.props.searchTargets({assistantId:a,adAccountId:t,text:e,countries:n}).then((e=>{this.setState({advanceSearchOptions:(0,ea.p1)(e.data,n),advanceTargetLoading:!1})})).catch((e=>{console.error(e),this.setState({advanceTargetLoading:!1})}))}}),700))();handleAdvanceTargetChange=e=>{this.state.advanceTargetLoading||this.setState({advanceTargetLoading:!0}),this.debouncedTargetSearch(e.target.value)};verifyGeoLocations=(e,t,a)=>{try{const n=t.option.value;if(as().isEmpty(n))return;const{type:s,key:o}=n,{geoLocations:i,excludedGeoLocations:r}=this.props,{cities:l=[],places:d=[]}=i,c=kd.w7[s]||"cities",p=i[c]||[];if("select-option"===a){if((0,kd.cL)(s,o,r))return void this.setState({snack:!0});if(s&&kd.DV.includes(s)){const e=("city"===s?l:d).find((e=>e.key===o));e&&e.radius?(n.radius=e.radius,n.distance_unit=e.distance_unit||kd.PG):(n.radius=kd.Px[s],n.distance_unit=kd.PG),this.setState((e=>({locationRadiusMap:{...e.locationRadiusMap,[o]:n.radius}})))}const e=(0,kd.Qv)(s,n),t={...i,[c]:[...p,e]};this.props.changeState("geoLocations",t)}else if("remove-option"===a){const e=p.filter((e=>o!==(e?.key||e))),t={...i,[c]:e};this.props.changeState("geoLocations",t)}return e=e.filter(((e,t,a)=>t===a.findIndex((t=>t.label===e.label)))),void this.props.changeState("selectedLocations",e)}catch(e){console.log({error:e})}};verifyExcludedGeoLocations=(e,t,a)=>{try{const n=t.option.value;if(as().isEmpty(n))return;const{type:s,key:o}=n,{geoLocations:i,excludedGeoLocations:r}=this.props,l=kd.w7[s]||"cities",d=r[l]||[];if("select-option"===a){if((0,kd.cL)(s,o,i))return void this.setState({snack:!0});const e=(0,kd.Qv)(s,n),t={...r,[l]:[...d,e]};this.props.changeState("excludedGeoLocations",t)}else if("remove-option"===a){const e=d.filter((e=>o!==(e?.key||e))),t={...r,[l]:e};this.props.changeState("excludedGeoLocations",t)}return e=e.filter(((e,t,a)=>t===a.findIndex((t=>t.label===e.label)))),void this.props.changeState("excludedSelectedLocations",e)}catch(e){console.log({error:e})}};handleLocationChange(e){let{position:t,address:a,places:n}=e;this.setState({position:t,address:a})}setAdvanceFilterOptions=e=>{const t=e.map((e=>{let{label:t,value:a}=e;const{id:n,type:s}=a||{};return`${s}-${n}`}));this.setState({advanceFilterOptions:t})};handleAdvanceTargetSelection=(()=>{var e=this;return function(t){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];e.setAdvanceFilterOptions(a);const n=a.reduce(((e,t)=>{const{value:a}=t||{},{type:n}=a||{};return n?(e[n]?e[n].push(a):e[n]=[a],e):e}),{});e.props.changeState("advanceTargets",n),e.props.changeState("selectedAdvanceTargets",a),setTimeout((()=>{const e=document.querySelector(".advanced-targeting-autocomplete");if(e){const t=e.getBoundingClientRect();t.top>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)||e.scrollIntoView({behavior:"smooth",block:"center"})}}),100)}})();handleRadiusClick=(e,t,a)=>
1{this.setState({radiusAnchorEl:e.currentTarget,selectedLocationId:t,locationRadiusMap:{...this.state.locationRadiusMap,[t]:a}})};handleRadiusClose=()=>{this.setState({radiusAnchorEl:null,selectedLocationId:null})};handleRadiusChange=(e,t)=>{const{selectedLocationId:a}=this.state,n=this.props?.selectedLocations?.find((e=>e.value.key===a));if(!n)return;const s=n.value.type,o=Math.round(t);if(!kd.DV.includes(s))return;const i=kd.MU[s],r=kd.SM[s];if(o<i||o>r)return;this.setState((e=>({locationRadiusMap:{...e.locationRadiusMap,[a]:o}})));const l=(this.props.selectedLocations||[]).map((e=>{if(e.value.key===a){const t={...e,value:{...e.value,radius:o,distance_unit:e.value.distance_unit||kd.PG}},{geoLocations:n}=this.props,s=kd.w7[e.value.type]||"cities",i=(n[s]||[]).map((e=>e.key===a?{...e,radius:o,distance_unit:"kilometer"}:e));return this.props.changeState("geoLocations",{...n,[s]:i}),t}return e}));this.props.changeState("selectedLocations",l)};handleLocationOptions=e=>{let{label:t,value:a}=e;return(0,h.jsxs)(o.Box,{width:"100%",style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)(o.Box,{width:"70%",pr:1,children:(0,h.jsx)(o.Typography,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t||""})}),(0,h.jsx)(o.Box,{width:"30%",style:{display:"flex",justifyContent:"flex-end",color:"#95a5a6",fontSize:"13px",alignItems:"center"},children:(0,kd.Cm)(a.type)})]})};targetOptionComponent=e=>{let{label:t,value:a}=e;const n={Behaviours:"#28c152",Behaviors:"#28c152",Interests:"#efa95e",Demographics:"#8859e7"},{path:s,audience_size_lower_bound:i,audience_size_upper_bound:r}=a,l=s[0];let d=[];i&&d.push(i.toLocaleString()),r&&d.push(r.toLocaleString()),d=d.join(" - ");const c={...a,audience:d};return(0,h.jsx)(o.Tooltip,{placement:"left",title:(0,h.jsx)(o.Box,{p:1.5,children:["name","type","audience","description"].map((e=>c[e]?(0,h.jsxs)(o.Typography,{variant:"body2",gutterBottom:!0,children:[(0,h.jsx)("b",{children:`${as().startCase(e)} : `}),"type"!==e?c[e]:as().startCase(c[e])]}):(0,h.jsx)(h.Fragment,{})))}),arrow:!0,classes:{arrow:this.props.classes.arrow},children:(0,h.jsxs)(o.Box,{width:"100%",style:{display:"flex"},children:[(0,h.jsx)(o.Box,{width:"70%",pr:1,children:(0,h.jsx)(o.Typography,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t})}),(0,h.jsx)(o.Box,{width:"30%",style:{display:"flex",justifyContent:"end"},children:(0,h.jsx)(o.Chip,{style:{borderRadius:"6px",color:n[l]?n[l]:"",borderColor:n[l]?n[l]:"",fontWeight:600,fontSize:"0.8em",alignItems:"center"},label:l,size:"small",variant:"outlined"})})]})})};MapPin=e=>{let{className:t,fill:a}=e;return(0,h.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"32",height:"32",fill:a,viewBox:"0 0 256 256",className:t,children:(0,h.jsx)("path",{d:"M128,16a88.1,88.1,0,0,0-88,88c0,75.3,80,132.17,83.41,134.55a8,8,0,0,0,9.18,0C136,236.17,216,179.3,216,104A88.1,88.1,0,0,0,128,16Zm0,56a32,32,0,1,1-32,32A32,32,0,0,1,128,72Z"})})};AudiencesIcon=e=>{let{className:t,fill:a}=e;return(0,h.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"32",height:"32",fill:a,viewBox:"0 0 256 256",className:t,children:(0,h.jsx)("path",{d:"M117.25,157.92a60,60,0,1,0-66.5,0A95.83,95.83,0,0,0,3.53,219.2a8,8,0,1,0,13.4,8.81,80,80,0,0,1,134.14,0,8,8,0,0,0,13.4-8.81A95.83,95.83,0,0,0,117.25,157.92ZM84,108a44,44,0,1,1,44,44A44.05,44.05,0,0,1,84,108Zm139.81,98.29a8,8,0,0,1-11.12,2.29A79.83,79.83,0,0,0,172,172a8,8,0,0,1,0-16,44,44,0,1,0-16.34-84.87,8,8,0,1,1-5.94-14.85,60,60,0,0,1,55.53,105.64,95.83,95.83,0,0,1,23.31,19.67A8,8,0,0,1,223.81,206.29Z"})})};debouncedAudienceSearch=(()=>as().debounce((e=>{const{assistantId:t}=this.props.assistantDetails;this.props.searchAudiences({assistantId:t,text:e}).then((e=>{this.setState({savedAudiences:e,audienceSearchLoading:!1})})).catch((e=>{console.error("Error searching audiences:",e),this.setState({audienceSearchLoading:!1})}))}),500))();loadLatestAudiences=()=>{const{assistantId:e}=this.props.assistantDetails;this.setState({audienceSearchLoading:!0}),this.props.fetchLatestAudiences(e).then((e=>{this.setState({savedAudiences:e,audienceSearchLoading:!1,hasLoadedInitialAudiences:!0})})).catch((e=>{console.error("Error loading latest audiences:",e),this.setState({audie
1nceSearchLoading:!1,hasLoadedInitialAudiences:!0})}))};handleAudienceSearch=e=>{const t=e.target.value;""!==t?(this.setState({audienceSearchLoading:!0}),this.debouncedAudienceSearch(t)):this.loadLatestAudiences()};handleAudienceSelect=(e,t)=>{if(!t)return this.setState((e=>({audienceKey:e.audienceKey+1}))),this.props.changeState("gender","ALL"),this.props.changeState("FromAge","18"),this.props.changeState("ToAge","65"),this.props.changeState("selectedPlatforms","whatsapp_status"===this.props.parentState?.adType?.value?["instagram","whatsapp"]:[]),this.props.changeState("selectedAudience",null),this.props.changeState("audienceName",""),this.props.changeState("selectedLocations",[]),this.props.changeState("geoLocations",{}),this.props.changeState("excludedSelectedLocations",[]),this.props.changeState("excludedGeoLocations",{}),this.props.changeState("selectedAdvanceTargets",[]),this.props.changeState("advanceTargets",{}),void(this.props.getEstimatedDeliveryUsers&&this.props.getEstimatedDeliveryUsers());this.changeAudience(t)};bucketizeAudienceLocations=(()=>function(){const e={countries:[],cities:[],regions:[],places:[],zips:[]};return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach((t=>{const{type:a}=t.value,n=kd.w7[a]||"cities";e[n].push((0,kd.Qv)(a,t.value))})),e})();changeAudience=e=>{const{gender:t,minAge:a,maxAge:n,geoLocation:s,excludedGeoLocation:o,advanceTargets:i,selectedPlatforms:r}=e;if(this.props.changeState("gender",t),this.props.changeState("FromAge",a),this.props.changeState("ToAge",n),this.props.changeState("selectedPlatforms","whatsapp_status"===this.props.parentState?.adType?.value?["instagram","whatsapp"]:r||[]),this.props.changeState("selectedAudience",e),this.props.changeState("audienceName",e.audienceName),this.props.changeState("selectedLocations",s),this.props.changeState("geoLocations",this.bucketizeAudienceLocations(s)),this.props.changeState("excludedSelectedLocations",o||[]),this.props.changeState("excludedGeoLocations",this.bucketizeAudienceLocations(o||[])),i){const e=Object.entries(i).reduce(((e,t)=>{let[a,n]=t;return[...e,...n.map((e=>({label:e.name,value:e})))]}),[]);this.props.changeState("selectedAdvanceTargets",e),this.props.changeState("advanceTargets",i)}else this.props.changeState("selectedAdvanceTargets",[]),this.props.changeState("advanceTargets",{});this.props.getEstimatedDeliveryUsers&&this.props.getEstimatedDeliveryUsers()};handlePlatformToggle=(e,t)=>{const{adPlacements:a={},selectedPlatforms:n=[]}=this.props.parentState,{facebookPositions:s,instagramPositions:o}=a,i={facebook:{positions:ea._R,positionKey:"facebookPositions",positionsArray:s},instagram:{positions:ea.s3,positionKey:"instagramPositions",positionsArray:o}}[e];if(!i)return;(Array.isArray(i.positionsArray)&&i.positionsArray.length>0?i.positionsArray:n.includes(e)?i.positions.map((e=>e.value)):[]).length,i.positions.length;const r=n.includes(e);if("select-all"===t){const e=i.positions.map((e=>e.value));this.props.changeState("adPlacements",{...a,[i.positionKey]:e})}else if("clear-all"===t)this.props.changeState(`${e}_positions`,[]),this.props.changeState("selectedPlatforms",n.filter((t=>t!==e))),this.props.changeState("adPlacements",{...a,[i.positionKey]:[]});else if(!0===t)this.props.changeState(`${e}_positions`,[]),this.props.changeState("selectedPlatforms",n.filter((t=>t!==e))),this.props.changeState("adPlacements",{...a,[i.positionKey]:[]});else{const t=i.positions.map((e=>e.value)),s=r?n:[...n,e];this.props.changeState("selectedPlatforms",s),this.props.changeState("adPlacements",{...a,[i.positionKey]:t})}};handlePositionToggle=(e,t)=>{const{adPlacements:a,selectedPlatforms:n=[]}=this.props.parentState,{facebookPositions:s,instagramPositions:o}=a;if("facebook"===e){const e=Array.isArray(s)&&s.length>0?[...s]:n.includes("facebook")?ea._R.map((e=>e.value)):[],o=e.indexOf(t);o>-1?e.splice(o,1):e.push(t),this.props.changeState("adPlacements",{...a,facebookPositions:e});const i=this.props.parentState.selectedPlatforms||[];0===e.length?this.props.changeState("selectedPlatforms",i.filter((e=>"facebook"!==e))):i.includes("facebook")||this.props.changeState("selectedPlatforms",[...i,"facebook"])}else if("instagram"===e){const e=Array.isArray(o)&&o.length>0?[...o]:n.includes("instagram")?ea.s3.map((e=>e.value)):[],s=e.indexOf(t);s>-1?e.splice(s,1):e.push(t),this.props.changeState("adPlacements",{...a,instagramPositions:e});const i=this.props.parentState.selectedPlatforms||[];0===e.length?this.props.changeState("selectedPlatforms",i.filter((e=>"instagram"!==e))):i.includes("instagram")||this.props.changeState("selectedPlatforms",[...i,"instagram"])}};renderLockedPlacementCard=e=>{let{icon:t,title:a,positionLabel:n}=e;return(0,h.jsxs)(o.Box,{style:{borderRadius:"8px",padding:"16px",display:"flex",flexDirection:"column"},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",gap:"12px"},children:[(0,h.jsx)(o.Tooltip,{title:"Required by Meta for WhatsApp Status ads",children:(0,h.jsx)("span",{children:(0,h.jsx)(o.Checkbox,{checked:!0,color:"primary",style:{padding:"4px",pointerEvents:"none"},inputProps:{"aria-label":`${a} placement (required)`}})})}),(0,h.jsx)("img",{src:t,alt:`${a} icon`,style:{width:"24px",height:"24px"}}),(0,h.jsx)(o.Typography,{variant:"h6",style:{fontWeight:600},children:a})]}),(0,h.jsx)(o.Typography,{variant:"body2",style:{color:"#0a474c",fontSize:"12px",fontWeight:500,whiteSpace:"nowrap"},children:"Required"})]}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:"12px"},children:"1 placement"}),(0,h.jsx)(o.Grid,{container:!0,spacing:1,style:{flex:1,alignContent:"flex-start"},children:(0,h.jsx)(o.Grid,{item:!0,style:{width:"auto"},children:(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"5px 14px",borderRadius:"20px",border:"1px solid #a19a9a",minHeight:"20px",width:"fit-content",backgroundColor:"#0a474c",color:"white"},children:[(0,h.jsx)(Xi.A,{size:12,style:{marginRight:"3px"}}),(0,h.jsx)(o.Typography,{variant:"body2",style:{fontSize:"11px",whiteSpace:"nowrap",color:"white"},children:n})]})})})]})};render(){var e=this;const{classes:t,selectedPlatforms:a,agent:n,adSetupDetails:i}=this.props,{isLoading:r,snack:l,advanceTargetLoading:d,advanceSearchOptions:c,advanceFilterOptions:p}=this.state,{gender:u,selectedLocations:m,excludedSelectedLocations:g,FromAge:b,ToAge:y,selectedAdvanceTargets:x,geoLocations:f,excludedGeoLocations:A,adPlacements:I,customAndLookalikeAudiences:C,excludedCustomAndLookalikeAudiences:_,adType:S}=this.props.parentState,v="whatsapp_status"===S?.value,E=window.innerWidth<=960,T=e=>as().groupBy(e,(e=>{if(e?.value?.country_name)return e.value.country_name;const t=e?.value?.country_code||e?.value?.country;if(t){const e=Nd.A.find((e=>e.isoCode===t));return e?e.name:"Others"}return"Others"})),D=T(m),w=T(g),{facebookPositions:N,instagramPositions:j}=I,k=Array.isArray(j)&&j.length>0?j:a.includes("instagram")?ea.s3.map((e=>e.value)):[],L=Array.isArray(N)&&N.length>0?N:a.includes("facebook")?ea._R.map((e=>e.value)):[],R=[...C,..._];return(0,h.jsxs)(o.Grid,{container:!0,marginTop:"3em",children:[(0,h.jsx)(o.Grid,{xs:12,md:12,children:(0,h.jsxs)(o.Grid,{item:!0,xs:!0,style:{flexDirection:"column",justifyContent:"center",minWidth:"221px"},children:[(0,h.jsx)(Gd,{classes:t,gender:u,selectedPlatforms:a,audienceKey:this.state.audienceKey,audienceSearchLoading:this.state.audienceSearchLoading,hasLoadedInitialAudiences:this.state.hasLoadedInitialAudiences,savedAudiences:this.state.savedAudiences,parentState:this.props.parentState,changeAudience:this.changeAudience,handleAudienceSearch:this.handleAudienceSearch,handleAudienceSelect:this.handleAudienceSelect,loadLatestAudiences:this.loadLatestAudiences}
1),(0,h.jsx)(Ud,{classes:t,adSetupDetails:i,isLoading:r,audiences:this.props.audiences,customAndLookalikeAudiences:C,excludedCustomAndLookalikeAudiences:_,nonSelectableAudiences:R,createAudienceMenuAnchor:this.state.createAudienceMenuAnchor,showExcludeAudiences:this.state.showExcludeAudiences,AudiencesIcon:this.AudiencesIcon,changeState:this.props.changeState,setState:function(){return e.setState(...arguments)},debouncedAudienceSearch:this.debouncedAudienceSearch}),(0,h.jsx)(Fd,{classes:t,excludedSelectedLocations:g,geoLocations:f,groupedLocations:D,isLoading:r,selectedLocations:m,locationRadiusMap:this.state.locationRadiusMap,radiusAnchorEl:this.state.radiusAnchorEl,searchLocation:this.state.searchLocation,selectedLocationId:this.state.selectedLocationId,showExcludeLocations:this.state.showExcludeLocations,changeState:this.props.changeState,MapPin:this.MapPin,handleChangeD:this.handleChangeD,handleLocationOptions:this.handleLocationOptions,handleRadiusChange:this.handleRadiusChange,handleRadiusClick:this.handleRadiusClick,handleRadiusClose:this.handleRadiusClose,verifyGeoLocations:this.verifyGeoLocations,setState:function(){return e.setState(...arguments)}}),this.state.showExcludeLocations&&(0,h.jsxs)(o.Grid,{item:!0,xs:!0,className:t.bottomMargin,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Exclude Locations"}),(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,color:"textSecondary",children:"People in these locations will not be shown this ad"}),(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsx)(wd.Ay,{multiple:!0,options:this.state.searchLocation.map((e=>{const{name:t,country_name:a,region:n}=e;return{label:as().compact([t,n,a]).join(", "),value:e}})),getOptionLabel:e=>e.label||e,value:g,onChange:(e,t,a,n)=>{this.verifyExcludedGeoLocations(t,n,a)},loading:r,className:t.autocompletePadding,renderInput:e=>(0,h.jsx)(o.TextField,{...e,variant:"outlined",placeholder:as().isEmpty(g)?"Search cities, regions, countries, pin codes":"",classes:{root:t.textFieldRoot},InputProps:{...e.InputProps,startAdornment:(0,h.jsx)(o.InputAdornment,{position:"start",children:(0,h.jsx)(Ni.A,{size:20,className:t.searchIcon})}),endAdornment:(0,h.jsx)(s().Fragment,{children:(0,h.jsx)(o.InputAdornment,{children:r?(0,h.jsx)(o.IconButton,{children:(0,h.jsx)(o.CircularProgress,{size:16})}):(0,h.jsx)(h.Fragment,{})})})},onChange:this.handleChangeD,onKeyDown:e=>{"Backspace"===e.key&&""===e.target.value&&e.stopPropagation()},name:"excludedLocation"}),renderOption:this.handleLocationOptions,renderTags:()=>null,classes:{inputRoot:t.inputRoot,input:t.autocompleteInput}})}),!as().isEmpty(g)&&(0,h.jsx)("div",{className:t.locationMainContainer,children:Object.entries(w).map((e=>{let[a,n]=e;return(0,h.jsxs)("div",{children:[(0,h.jsx)(o.Typography,{className:t.countryTitle,variant:"h5",gutterBottom:!0,children:a}),n.map((e=>(0,h.jsxs)("div",{className:t.locationItem,children:[(0,h.jsxs)("div",{className:t.locationInfo,children:[(0,h.jsx)(this.MapPin,{className:t.locationPin,fill:"#e05e5e"}),(0,h.jsx)("div",{className:t.locationNameGroup,children:(0,h.jsx)(o.Tooltip,{title:"zip"===e?.value?.type&&e?.value?.region?`${e.value.name}, ${e.value.region}`:e?.value?.name,children:(0,h.jsx)(o.Typography,{className:t.locationName,children:"zip"===e?.value?.type&&e?.value?.region?`${e.value.name}, ${e.value.region}`:e.value.name})})})]}),(0,h.jsxs)("div",{className:t.rightSection,children:[(0,h.jsx)(o.Typography,{className:t.locationType,children:(0,kd.Cm)(e.value.type)}),(0,h.jsx)(o.IconButton,{size:"small",className:t.removeButton,onClick:()=>{const t=g.filter((t=>t.value.key!==e.value.key));this.props.changeState("excludedSelectedLocations",t);const a=kd.w7[e?.value?.type]||"cities",n=(A[a]||[]).filter((t=>(t.key||t)!==e.value.key));this.props.changeState("excludedGeoLocations",{...A,[a]:n})},children:(0,h.jsx)(Ei.A,{size:16,className:t.removeIcon})})]})]},e.value.key)))]},a)}))})]}),(0,h.jsx)(zd,{FromAge:b,ToAge:y,classes:t,gender:u,isMobile:E,changeState:this.props.changeState}),(0,h.jsx)(Md,{classes:t,isWhatsappStatusAd:v,resolvedFacebookPositions:L,resolvedInstagramPositions:k,selectedPlatforms:a,parentState:this.props.parentState,handlePlatformToggle:this.handlePlatformToggle,handlePositionToggle:this.handlePositionToggle,renderLockedPlacementCard:this.renderLockedPlacementCard}),this.props.deprecatedAdvanceTargets?.length?this.props.deprecatedAdvanceTargets.some((e=>!as().isEmpty(x)&&x.some((t=>t.value.id===e.id))))&&(0,h.jsx)("div",{className:t.bottomMargin,children:(0,h.jsx)(Vd,{})}):null,(0,h.jsx)(Pd,{advanceFilterOptions:p,advanceSearchOptions:c,advanceTargetLoading:d,classes:t,selectedAdvanceTargets:x,changeState:this.props.changeState,deprecatedAdvanceTargets:this.props.deprecatedAdvanceTargets,parentState:this.props.parentState,handleAdvanceTargetChange:this.handleAdvanceTargetChange,handleAdvanceTarget
1Selection:this.handleAdvanceTargetSelection,targetOptionComponent:this.targetOptionComponent})]})}),(0,h.jsx)(o.Snackbar,{open:l,onClose:this.onSnackbarClose,anchorOrigin:{vertical:"top",horizontal:"center"},autoHideDuration:1500,children:(0,h.jsx)(O.Alert,{severity:"error",onClose:this.onSnackbarClose,children:"Locations are overlaping"})}),(0,h.jsx)(Fe,{open:this.state.createAudienceOpen,onClose:()=>this.setState({createAudienceOpen:!1,createAudienceType:"custom"}),audienceType:this.state.createAudienceType,assistantDetails:this.props.assistantDetails,onSuccess:e=>{this.setState({createAudienceOpen:!1,createAudienceType:"custom",createAudienceSnack:{show:!0,severity:"success",msg:e}}),this.refreshAudiencesList()},onError:e=>{this.setState({createAudienceSnack:{show:!0,severity:"error",msg:e}})}}),(0,h.jsx)(o.Snackbar,{open:this.state.createAudienceSnack.show,onClose:this.onCreateAudienceSnackClose,anchorOrigin:{vertical:"top",horizontal:"center"},autoHideDuration:3e3,children:(0,h.jsx)(O.Alert,{severity:this.state.createAudienceSnack.severity,onClose:this.onCreateAudienceSnackClose,children:this.state.createAudienceSnack.msg})})]})}}const Vd=()=>(0,h.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:"16px",padding:"16px",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px"},children:[(0,h.jsx)(jd,{style:{color:"#ef4444"}}),(0,h.jsxs)("div",{style:{flex:1},children:[(0,h.jsx)("div",{style:{display:"flex",alignItems:"center",marginBottom:"4px"},children:(0,h.jsx)(o.Typography,{variant:"subtitle2",style:{fontSize:"0.875rem",fontWeight:600,color:"#991b1b"},children:"Deprecated Targeting Detected"})}),(0,h.jsx)(o.Typography,{variant:"body2",style:{fontSize:"0.875rem",color:"#b91c1c"},children:"Some of your selected advanced targets are no longer supported by the platform. Please remove or replace them to ensure your Ad can be published."})]})]}),Yd=(0,i.connect)((e=>({pageDetails:e.ads.pageDetails,allFilters:e.filters.allFilters,filename:e.ads.filename,details:e.ads.details,previewImageUrl:e.ads.previewImageUrl,assistantDetails:e.assistantDetails.data,adSetupDetails:e.assistantDetails.adSetupDetails,agent:e.login.user,audiences:e.audience.audiences})),{fetchAudiences:z._L,syncAudiences:z.zJ,searchLocations:gi.X8,searchTargets:gi.jf,searchAudiences:gi.cx,fetchLatestAudiences:gi.hv})(Hd),Zd=(0,o.withStyles)((e=>({root:{width:"100%",padding:"20px 10px",marginTop:"5%"},bottomMargin:{marginBottom:e.spacing(4)},filterTypeContainer:{borderRadius:"5px",minHeight:100},ad:{display:"flex",marginTop:"1.35em",marginBottom:"2em",justifyContent:"center",[e.breakpoints.up("md")]:{minWidth:"315px"}},textFieldRoot:{backgroundColor:"rgb(240,240,240)",outline:"none",border:"none",borderRadius:"8px",width:"100%",padding:"0",boxShadow:"none",boxSizing:"border-box",fontFamily:"Roboto, sans-serif",fontSize:"15px",fontWeight:500,maxHeight:"12em",overflow:"auto","&::-webkit-scrollbar":{width:"4px"}},inputPadding:{padding:"12px 10px"},inputRoot:{'&[class*="MuiOutlinedInput-root"][class*="MuiAutocomplete-input"]':{padding:12},'&&[class*="MuiOutlinedInput-root"]':{padding:0},'&[class*="MuiOutlinedInput-root"][class*="MuiAutocomplete-inputRoot"]':{paddingRight:"0 !important",paddingLeft:"0 !important"}},snackbar:{zIndex:5e3},arrow:{color:"white"},qualityStatus:{'& [class*="MuiChip-label"]':{color:"white",fontSize:"0.9em"}},locationMainContainer:{backgroundColor:"#f0f0f0",borderRadius:"8px",padding:"14px",marginTop:e.spacing(2)},countryTitle:{color:"#2d3436",marginBottom:e.spacing(1)},locationItem:{backgroundColor:"#ffffff",borderRadius:"8px",padding:"6px 16px",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px",boxShadow:"0 1px 2px rgba(0,0,0,0.05)"},removeButton:{padding:4,"&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)"}},removeIcon:{color:"#666"},locationInfo:{display:"flex",alignItems:"center",gap:"8px",flex:1},locationPin:{color:"#28c153",width:20,height:20},locationNameGroup:{display:"flex",alignItems:"center",justifyContent:"flex-start"},locationName:{fontSize:"13px",fontWeight:400,color:"#2d3436",width:"70px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},locationType:{color:"#95a5a6",fontSize:"13px"},rightSection:{display:"flex",alignItems:"center",gap:e.spacing(2)},radiusButton:{color:"#2d3436",fontSize:"13px",textTransform:"none",padding:"4px 8px",paddingLeft:0,minWidth:"unset",marginLeft:"8px","&:hover":{backgroundColor:"transparent"}},radiusPopover:{padding:e.spacing(2),width:280},radiusSlider:{height:4,'& [class*="MuiSlider-rail"]':{height:4,backgroundColor:"#e0e0e0"},'& [class*="MuiSlider-track"]':{height:4}},radiusTitle:{fontSize:"16px",fontWeight:500,marginBottom:e.spacing(3),color:"#2d3436"},radiusSliderContainer:{padding:e.spacing(0,1)},autocompleteInput:{paddingLeft:"8px !important"},searchIcon:{color:"#666",marginLeft:e.spacing(1)},targetTitleContainer:{display:"flex",alignItems:"center",justifyContent:"space-between",[e.breakpoints.down("xs")]:{flexDirection:"column",alignItems:"flex-start",ga
1p:"4px",marginBottom:"4px"}},targetMainContainer:{borderRadius:"8px 8px 0 0",padding:"12px",marginTop:e.spacing(1),border:"1px solid #e0e0e0",display:"flex",flexWrap:"wrap",gap:"8px",width:"100%",boxSizing:"border-box",maxWidth:"100vw",overflowX:"hidden",[e.breakpoints.down("xs")]:{padding:"8px",gap:"4px"}},targetTypeTitle:{color:"#2d3436",marginBottom:e.spacing(1)},targetItem:{backgroundColor:"#ffffff",borderRadius:"8px",padding:"4px 6px 4px 12px",display:"flex",alignItems:"center",boxShadow:"0 1px 2px rgba(0,0,0,0.05)",maxWidth:"100%",boxSizing:"border-box",border:"1px solid #e0e0e0",[e.breakpoints.down("xs")]:{width:"100%",padding:"4px 4px 4px 8px"}},interests:{border:"1px solid #efa95e",color:"#efa95e"},demographics:{border:"1px solid #8859E7",color:"#8859E7"},behaviors:{border:"1px solid #28c152",color:"#28c152"},deprecated:{border:"1px dashed #ef4444",color:"#ef4444"},interestsRemoveIcon:{color:"#efa95e"},demographicsRemoveIcon:{color:"#8859e7"},behaviorsRemoveIcon:{color:"#28c152"},deprecatedRemoveIcon:{color:"#ef4444"},targetInfo:{display:"flex",alignItems:"center",gap:"8px",flex:1,paddingRight:4,minWidth:0,[e.breakpoints.down("xs")]:{maxWidth:"calc(100% - 28px)",gap:"4px"}},targetNameGroup:{display:"flex",alignItems:"center",justifyContent:"flex-start",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},targetName:{fontSize:"13px",fontWeight:400,maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",display:"flex",alignItems:"center",textOverflow:"ellipsis",[e.breakpoints.down("xs")]:{fontSize:"12px"}},targetType:{color:"#95a5a6",fontSize:"13px"},colorDot:{width:8,height:8,borderRadius:"50%",marginRight:4},targetTypeText:{lineHeight:0,marginRight:8,color:"#808080"},noTopRadius:{borderTopLeftRadius:"0 !important",borderTopRightRadius:"0 !important",'& [class*="MuiOutlinedInput-root"]':{borderTopLeftRadius:0,borderTopRightRadius:0}},deprecatedChip:{height:"auto",padding:"0 4px",borderRadius:"4px",marginLeft:e.spacing(1),backgroundColor:"#ef4444",color:"#ffffff",fontSize:"10px",fontWeight:"bold",textTransform:"uppercase",letterSpacing:"0.05em",'& [class*="MuiChip-label"]':{paddingLeft:0,paddingRight:0}}})))(Yd);var Kd=a(14645);let Jd;Jd=new class{constructor(e){Kd.A.init(e,{persistence:"localStorage"}),window.mixpanel=Kd.A}startSession(e,t){if(e)Kd.A.identify(e,t);else{const e=Kd.A.get_distinct_id();localStorage.setItem("mixpanel_distinct_id",e),Kd.A.identify(e)}}track(e,t){Kd.A.track(e,t)}identify(e){Kd.A.identify(e)}alias(e){Kd.A.alias(e)}getDistinctId(){return Kd.A.get_distinct_id()}}(J.ZF);const $d=Jd;var qd;function Xd(){return Xd=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},Xd.apply(null,arguments)}function Qd(e){return n.createElement("svg",Xd({width:20,height:20,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),qd||(qd=n.createElement("path",{d:"M13.75 18.125a.625.625 0 01-.625.625h-6.25a.625.625 0 110-1.25h6.25a.625.625 0 01.625.625zm3.125-10a6.84 6.84 0 01-2.628 5.407 1.268 1.268 0 00-.497 1V15a1.25 1.25 0 01-1.25 1.25h-5A1.25 1.25 0 016.25 15v-.469a1.25 1.25 0 00-.487-.989 6.842 6.842 0 01-2.638-5.379c-.02-3.723 2.99-6.824 6.71-6.913a6.875 6.875 0 017.04 6.875zm-1.25 0A5.626 5.626 0 009.865 2.5c-3.048.072-5.506 2.609-5.49 5.656a5.598 5.598 0 002.16 4.398A2.5 2.5 0 017.5 14.53V15h5v-.469a2.513 2.513 0 01.974-1.98 5.596 5.596 0 002.151-4.426zm-1.258-.73a4.5 4.5 0 00-3.638-3.636.625.625 0 10-.208 1.232c1.295.218 2.393 1.317 2.613 2.614a.625.625 0 001.232-.21z",fill:"#FFA000"})))}a.p;var ec;function tc(){return tc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},tc.apply(null,arguments)}function ac(e){return n.createElement("svg",tc({width:10,height:15,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),ec||(ec=n.createElement("path",{d:"M2.75 1.125a1.125 1.125 0 11-2.25 0 1.125 1.125 0 012.25 0zM8.375 2.25a1.125 1.125 0 100-2.25 1.125 1.125 0 000 2.25zm-6.75 4.125a1.125 1.125 0 100 2.25 1.125 1.125 0 000-2.25zm6.75 0a1.125 1.125 0 100 2.25 1.125 1.125 0 000-2.25zm-6.75 6.375a1.125 1.125 0 100 2.25 1.125 1.125 0 000-2.25zm6.75 0a1.125 1.125 0 100 2.25 1.125 1.125 0 000-2.25z",fill:"#000"})))}a.p;var nc,sc;function oc(){return oc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},oc.apply(null,arguments)}function ic(e){return n.createElement("svg",oc({width:11,height:10,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),nc||(nc=n.createElement("g",{clipPath:"url(#cellular_signal_svg__clip0_1508_173752)"},n.createElement("path",{d:"M1.426 8.655h7.8v-7.8l-7.8 7.8z",fill:"#fff"}))),sc||(sc=n.createElement("defs",null,n.createElement("clipPath",{id:"cellular_signal_svg__clip0_1508_173752"},n.createElement("path",{fill:"#fff",transform:"translate(.84 .27)",d:"M0 0h9.36v9.36H0z"})))))}a.p;var rc,lc;function dc(){return dc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},dc.apply(null,arguments)}function cc(e){return n.createElement("svg",dc({width:11,height:10,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),rc||(rc=n.createElement("g",{clipPath:"url(#battery_svg__clip0_1508_173755)"},n.createElement("path",{d:"M7.186 1.635h-.651v-.78h-1.56v.78h-.652a.521.521 0 00-.518.52v5.978c0 .288.234.522.518.522h2.86a.522.522 0 00.522-.518V2.154a.521.521 0 00-.519-.519z",fill:"#fff"}))),lc||(lc=n.createElement("defs",null,n.createElement("clipPath",{id:"battery_svg__clip0_1508_173755"},n.createElement("path",{fill:"#fff",transform:"translate(.879 .27)",d:"M0 0h9.36v9.36H0z"})))))}a.p;var pc,uc;function mc(){return mc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},mc.apply(null,arguments)}function hc(e){return n.createElement("svg",mc({width:15,height:15,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),pc||(pc=n.createElement("g",{clipPath:"url(#arrow_back_svg__clip0_1273_7073)"},n.createElement("path",{d:"M11.72 6.935H4.6l3.27-3.27-.83-.825-4.68 4.68 4.68 4.68.824-.824L4.6 8.106h7.12v-1.
117z",fill:"#fff"}))),uc||(uc=n.createElement("defs",null,n.createElement("clipPath",{id:"arrow_back_svg__clip0_1273_7073"},n.createElement("path",{fill:"#fff",transform:"translate(.02 .5)",d:"M0 0h14.04v14.04H0z"})))))}a.p;var gc,bc;function yc(){return yc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},yc.apply(null,arguments)}function xc(e){return n.createElement("svg",yc({width:10,height:11,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),gc||(gc=n.createElement("g",{clipPath:"url(#whatsapp_verify_svg__clip0_1508_173766)"},n.createElement("path",{d:"M9.303 5.519L8.35 4.43l.133-1.44-1.408-.32-.737-1.247-1.326.57-1.326-.57-.737 1.244-1.408.316.132 1.443-.951 1.092.951 1.088-.132 1.443 1.408.32.737 1.244 1.326-.573 1.326.569.737-1.244 1.408-.32-.133-1.44.952-1.087zm-5.035 1.84L2.786 5.875l.577-.577.905.908 2.281-2.29.577.578L4.268 7.36z",fill:"#00E25C"}))),bc||(bc=n.createElement("defs",null,n.createElement("clipPath",{id:"whatsapp_verify_svg__clip0_1508_173766"},n.createElement("path",{fill:"#fff",transform:"translate(.137 .838)",d:"M0 0h9.36v9.36H0z"})))))}a.p;var fc,Ac;function Ic(){return Ic=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},Ic.apply(null,arguments)}function Cc(e){return n.createElement("svg",Ic({width:15,height:15,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),fc||(fc=n.createElement("g",{clipPath:"url(#cell_phone_svg__clip0_1508_173772)"},n.createElement("path",{d:"M11.845 9.496c-.72 0-1.415-.117-2.065-.327a.572.572 0 00-.59.14l-.919 1.152c-1.656-.79-3.206-2.281-4.03-3.995l1.14-.971a.597.597 0 00.14-.597 6.524 6.524 0 01-.327-2.065.584.584 0 00-.58-.58H2.592c-.316 0-.696.141-.696.58 0 5.435 4.522 9.95 9.95 9.95.416 0 .58-.368.58-.69v-2.018a.584.584 0 00-.58-.579z",fill:"#fff"}))),Ac||(Ac=n.createElement("defs",null,n.createElement("clipPath",{id:"cell_phone_svg__clip0_1508_173772"},n.createElement("path",{fill:"#fff",transform:"translate(.14 .498)",d:"M0 0h14.04v14.04H0z"})))))}a.p;var _c,Sc;function vc(){return vc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},vc.apply(null,arguments)}function Ec(e){return n.createElement("svg",vc({width:15,height:15,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),_c||(_c=n.createElement("g",{clipPath:"url(#more_whatsapp_svg__clip0_1508_173775)"},n.createElement("path",{d:"M7.56 5.178c.644 0 1.17-.527 1.17-1.17 0-.644-.526-1.17-1.17-1.17-.643 0-1.17.526-1.17 1.17 0 .643.527 1.17 1.17 1.17zm0 1.17c-.643 0-1.17.526-1.17 1.17 0 .643.527 1.17 1.17 1.17.644 0 1.17-.527 1.17-1.17 0-.644-.526-1.17-1.17-1.17zm0 3.51c-.643 0-1.17.526-1.17 1.17 0 .643.527 1.17 1.17 1.17.644 0 1.17-.527 1.17-1.17 0-.644-.526-1.17-1.17-1.17z",fill:"#fff"}))),Sc||(Sc=n.createElement("defs",null,n.createElement("clipPath",{id:"more_whatsapp_svg__clip0_1508_173775"},n.createElement("path",{fill:"#fff",transform:"translate(.54 .498)",d:"M0 0h14.04v14.04H0z"})))))}a.p;var Tc,Dc;function wc(){return wc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},wc.apply(null,arguments)}function Nc(e){return n.createElement("svg",wc({width:14,height:15,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),Tc||(Tc=n.createElement("g",{clipPath:"url(#whatsapp-send_svg__clip0_1508_173782)"},n.createElement("path",{d:"M13.126 7.093a.876.876 0 01-.447.766l-9.183 5.25a.883.883 0 01-.432.115.875.875 0 01-.82-1.166L3.72 7.685a.219.219 0 01.203-.148h3.953a.437.437 0 00.438-.467.448.448 0 00-.452-.408H3.925a.219.219 0 01-.208-.15l-1.476-4.37a.875.875 0 011.252-1.055l9.187 5.244a.875.875 0 01.446.762z",fill:"#43B861"}))),Dc||(Dc=n.createElement("defs",null,n.createElement("clipPath",{id:"whatsapp-send_svg__clip0_1508_173782"},n.createElement("path",{fill:"#fff",transform:"translate(0 .1)",d:"M0 0h14v14H0z"})))))}a.p;var jc,kc;function Lc(){return Lc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},Lc.apply(null,arguments)}function Rc(e){return n.createElement("svg",Lc({width:15,height:15,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),jc||(jc=n.createElement("g",{clipPath:"url(#smiley_svg__clip0_1508_173805)"},n.createElement("path",{d:"M7.016 1.27a5.847 5.847 0 00-5.844 5.85c0 3.229 2.615 5.85 5.844 5.85a5.853 5.853 0 005.856-5.85c0-3.23-2.62-5.85-5.856-5.85zm.006 10.53a4.679 4.679 0 01-4.68-4.68 4.679 4.679 0 014.68-4.68 4.679 4.679 0 014.68 4.68 4.679 4.679 0 01-4.68 4.68zm2.047-5.265a.876.876 0 100-1.755.876.876 0 100 1.755zm-4.095 0a.876.876 0 100-1.755.876.876 0 100 1.755zm2.048 3.802a3.215 3.215 0 002.99-2.047h-5.98a3.215 3.215 0 002.99 2.047z",fill:"#9DA3A7"}))),kc||(kc=n.createElement("defs",null,n.createElement("clipPath",{id:"smiley_svg__clip0_1508_173805"},n.createElement("path",{fill:"#fff",transform:"translate(0 .1)",d:"M0 0h14.04v14.04H0z"})))))}a.p;var Bc,Oc;function Pc(){return Pc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},Pc.apply(null,arguments)}function Mc(e){return n.createElement("svg",Pc({width:15,height:15,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),Bc||(Bc=n.createElement("g",{clipPath:"url(#attach_file_svg__clip0_1273_7124)"},n.createElement("path",{d:"M7.482 2.919l4.757 4.757a2.34 2.34 0 11-3.309 3.31L3.76 5.813a1.463 1.463 0 012.068-2.068L10.17 8.09c.228.227.228.6 0 .827a.587.587 0 01-.827 0l-3.93-3.93-.62.62 3.93 3.93a1.463 1.463 0 002.068-2.068L6.448 3.126A2.34 2.34 0 103.14 6.435l5.17 5.17a3.216 3.216 0 004.551 0 3.216 3.216 0 000-4.55L8.103 2.298l-.62.62z",fill:"#9DA3A7"}))),Oc||(Oc=n.createElement("defs",null,n.createElement("clipPath",{id:"attach_file_svg__clip0_1273_7124"},n.createElement("path",{fill:"#fff",transform:"translate(.898 .1)",d:"M0 0h14.04v14.04H0z"})))))}a.p;var Uc,Fc;function Wc(){return Wc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},Wc.apply(null,arguments)}function zc(e){return n.createElement("svg",Wc({width:15,height:15,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),Uc||(Uc=n.createElement("g",{clipPath:"url(#photo_camera_svg__clip0_1508_173813)",fill:"#9DA3A7"},n.createElement("path",{d:"M8.095 9.11a1.872 1.872 0 100-3.745 1.872 1.872 0 000 3.744z"}),n.createElement("path",{d:"M6.224 1.27l-1.07 1.17H3.298c-.644 0-1.17.526-1.17 1.17v7.02c0 .643.526 1.17 1.17 1.17h9.36c.643 0 1.17-.527 1.17-1.17V3.61c0-.644-.527-1.17-1.17-1.17h-1.854L9.734 1.27h-3.51zm1.755 8.774a2.926 2.926 0 010-5.85 2.926 2.926 0 010 5.85z"}))),Fc||(Fc=n.createElement("defs",null,n.createElement("clipPath",{id:"photo_camera_svg__clip0_1508_173813"},n.createElement("path",{fill:"#fff",transform:"translate(.957 .1)",d:"M0 0h14.04v14.04H0z"})))))}a.p;var Gc;function Hc(){return Hc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},Hc.apply(null,arguments)}function Vc(e){return n.createElement("svg",Hc({width:12,height:12,fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),Gc||(Gc=n.createElement("path",{d:"M5.732 1.475a4.568 4.568 0 100 9.135 4.568 4.568 0 000-9.135zm0 8.432a3.865 3.865 0 110-7.73 3.865 3.865 0 010 7.73zm.702-1.757a.351.351 0 01-.351.352.703.703 0 01-.703-.703V6.042a.351.351 0 010-.703.703.703 0 01.703.703V7.8a.351.351 0 01.351.351zM5.03 4.11a.527.527 0 111.054 0 .527.527 0 01-1.054 0z",fill:"gray"})))}a.p;const Yc={root:{height:"450px",width:"235px",minWidth:"235px",borderRadius:"19px",borderWidth:"35px 12px 35px 12px",borderStyle:"solid",borderColor:"#F7F7F8",backgroundColor:"#F7F7F8",position:"relative"},innerScreen:{borderRadius:"7px",backgroundImage:`url('${a.p+"8d85baf8163d60d4a32f2afa8c48f1c7.svg"}')`,backgroundRepeat:"no-repeat",backgroundSize:"cover",backgroundColor:"#E8E1D5",backgroundHeight:"500px",width:"100%",height:"100%",display:"flex",flexDirection:"column",overflow:"hidden",justifyContent:"space-between"},timeText:{fontFamily:"Roboto",fontWeight:400,fontSize:"7px",color:"white",margin:0}},Zc=(0,o.withStyles)(Yc)((e=>{const{classes:t,iceBreakers:a,greetingMessage:n,pageDetails:s,whatsappBusinessName:i,whatsappDisplayImage:r}=e,{picture:l,pageName:d}=s||{};return(0,h.jsxs)("div",{className:t.root,style:{backgroundRepeat:"no-repeat",backgroundSize:"cover"},children:[(0,h.jsxs)("div",{className:t.innerScreen,children:[(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[(0,h.jsxs)("div",{style:{height:"12px",backgroundColor:"#054D47",display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0 10px 0 10px"},children:[(0,h.jsx)("p",{className:t.timeText,children:ve()().format("HH:mm")}
1),(0,h.jsxs)("div",{style:{display:"flex",gap:"5px"},children:[(0,h.jsx)(ic,{}),(0,h.jsx)(cc,{})]})]}),(0,h.jsxs)("div",{style:{display:"flex",height:"38px",backgroundColor:"#085B53",padding:"0 7px 0 7px",justifyContent:"space-between"},children:[(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)(hc,{}),(0,h.jsx)(o.Avatar,{src:l||r||"",style:{height:"19px",width:"19px",marginLeft:"2px"}}),(0,h.jsx)("p",{style:{fontFamily:"Roboto",fontWeight:700,fontSize:"11px",color:"white",marginLeft:"5px"},children:d||i||"Business Name"}),(0,h.jsx)(xc,{style:{marginLeft:"2px"}})]}),(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"9px"},children:[(0,h.jsx)(Cc,{}),(0,h.jsx)(Ec,{})]})]})]}),(0,h.jsx)("div",{style:{padding:"8px"},children:(0,h.jsxs)("div",{style:{backgroundColor:"white",borderRadius:"12px",padding:"8px 8px 8px 8px"},children:[(0,h.jsx)("p",{style:{fontSize:"7px",color:"grey",margin:0,marginBottom:"5px"},children:n}),a?.map((e=>{let{iceBreakerText:t}=e;return(0,h.jsxs)("div",{style:{padding:"7px 0 7px 0",borderBottom:"1px solid #F0F0F0",display:"flex",justifyContent:"space-between"},children:[(0,h.jsx)("p",{style:{margin:0,fontFamily:"Roboto",fontSize:"10px",color:"#404040",fontFamily:500,maxWidth:"150px",marginLeft:"5px"},children:t}),(0,h.jsx)(Nc,{})]})})),(0,h.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",paddingTop:"12px"},children:[(0,h.jsxs)("div",{style:{display:"flex",gap:"2px",alignItems:"center"},children:[(0,h.jsx)(Rc,{}),(0,h.jsx)("p",{style:{fontFamily:"Roboto",fontFamily:400,fontSize:"11px",color:"#9DA3A7",margin:"0"},children:"Type a message"})]}),(0,h.jsxs)("div",{style:{display:"flex",gap:"7px",alignItems:"center"},children:[(0,h.jsx)(Mc,{}),(0,h.jsx)(zc,{})]})]})]})})]}),(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center",position:"absolute",bottom:"-30px"},children:[(0,h.jsx)(Vc,{}),(0,h.jsx)("p",{style:{fontFamily:"Inter",fontWeight:500,fontSize:"9px",lineHeight:"140%",color:"#808080"},children:"This message will be pre-filled for the customer."})]})]})}));var Kc=a(11859),Jc=a(79296);const $c=e=>{let{iceBreakers:t=[],handleRemoveIceBreaker:a,handleEditIceBreaker:n,greetingMessage:s,setGreetingMessage:i,isDisabled:r,switchChecked:l,flows:c,onChangeIceBreakerFlow:p,classes:u,handleDragStart:m,handleDragOver:g,handleDrop:b,draggedRef:y,containerRef:x,handleDragEnd:f,isAdFetched:A,draggable:I,isLiveAD:C,isLiveChat:_,handleFlowBlock:S,reduxIceBreakers:v,totalAdsCount:E,iceBreakerName:T,setIceBreakerName:D,fromSaveIceBreakerDialog:w=!1}=e;const N=window.location.pathname.includes("create"),j=window.location.pathname.includes("chat-settings"),k=window.location.pathname.includes("duplicate"),L=window.location.pathname.includes("edit"),{adId:R}=(0,Jc.g)(),B=()=>{const e=c?.map((e=>({flowId:e._id,flowName:e.flowName,status:e.status,totalAdCount:e?.flow?.nodes[0]?.data?.ads?.length||0,ads:e?.flow?.nodes[0]?.data?.ads||[]})));return[{flowId:"",flowName:"No Flow Selected",status:!0,totalAdCount:0,ads:[]},...e]},P=e=>{if(!e.status)return!1;if(_)return!0;if(L){const t=e.ads?.find((e=>e._id===R));if(t)return!0}return e.totalAdCount<E},M=e=>{if(!e.status)return"Flow is Inactive";if(_)return"";if(L){const t=e.ads?.find((e=>e._id===R));if(t)return""}return e.totalAdCount<E?"":`Max ${E} Ads Allowed in a single flow`};return(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column",width:"100%"},children:[(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column",width:"100%"},children:[(0,h.jsx)("h3",{style:{color:"#232529",fontFamily:"Inter",fontWeight:500,fontSize:"14px",lineHeight:"140%",letterSpacing:"-2%",margin:0,marginBottom:"11px",marginTop:"13px"},children:"Icebreaker Name"}),A||N||j?(0,h.jsx)(o.Input,{placeholder:"Icebreaker Name",fullWidth:!0,value:T,onChange:e=>D(e.target.value),style:{backgroundColor:"#F0F0F0",padding:"10px",borderRadius:"8px"}}):(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,style:{borderRadius:"10px"}})]}),!_&&(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column",width:"100%"},children:[(0,h.jsxs)("h3",{style:{color:"#232529",fontFamily:"Inter",fontWeight:500,fontSize:"14px",lineHeight:"140%",letterSpacing:"-2%",margin:0,marginBottom:"11px",marginTop:"13px"},children:["Greeting message",(0,h.jsx)("span",{style:{color:"#C64D4D"},children:"*"})]}),A||N||j?(0,h.jsx)(o.Tooltip,{title:C&&!k?"You can't edit the greeting message once the ad is live":"",children:(0,h.jsx)(o.Input,{placeholder:"Greeting Message",fullWidth:!0,value:s,onChange:e=>i(e.target.value),disabled:r||!l||w,style:{backgroundColor:"#F0F0F0",padding:"10px",borderRadius:"8px"}})}):(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,style:{borderRadius:"10px"}})]}),(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column",marginTop:"24px"},ref:x,children:[(0,h.jsx)("h3",{style:{color:"#232529",fontFamily:"Inter",fontWeight:500,fontSize:"14px",lineHeight:"140%",letterSpacing:"-2%",margin:0,marginBottom:"11px"},children:"Icebreakers"}),t&&t.length>0?t.map(((e,s)=>{const{iceBreakerText:i,flowId:c,iceBreakerId:x}=e||{};let _="";if(v)for(let e of v?.iceBreakers)e.iceBreakerId===x&&(_=e?.blockId||"");return(0,h.jsxs)("div",{className:u.iceBreakerMessagesDiv,style:I?{cursor:"grab"}:{cursor:"default"},onMouseDown:e=>{I&&(e.currentTarget.style.cursor="grabbing"),y.current=e.currentTarget},onMouseUp:e=>{I&&(e.currentTarget.style.cursor="grab")},draggable:I,onDragStart:e=>m(e,s),onDragOver:g,onDrop:()=>b(s),handleDragEnd:f,children:[(0,h.jsx)("div",{className:`${u.iconWrapper} ${u.displayNone_600}
1`,children:(0,h.jsx)(ac,{className:u.displayNone_600})}),A||N||j?(0,h.jsx)(o.Tooltip,{title:C&&!k?"You can't edit icebreaker text once the ad is live":"",children:(0,h.jsx)(o.Input,{placeholder:"Ice Breaker Text",value:i,disabled:r||!l||w,required:!0,style:{backgroundColor:"#F0F0F0",padding:"8px",borderRadius:"8px",width:"100%",fontSize:"14px",fontFamily:"Inter",fontWeight:500,lineHeight:"150%"},onChange:e=>n(e,s),endAdornment:(0,h.jsxs)("p",{style:{color:"#808080",fontFamily:500,fontSize:"12px",lineHeight:"150%",margin:0},children:[i.length,"/80"]})})}):(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,style:{borderRadius:"10px",width:"100%"}}),(0,h.jsx)("div",{className:u.flowSelectDiv,children:A||N||j?(0,h.jsx)(o.Select,{displayEmpty:!0,style:{width:"100px",backgroundColor:"#F0F0F0",padding:"8px",width:"100%",borderRadius:"8px"},onChange:e=>{const t=e.target.value,a=B().find((e=>e.flowId===t));P(a)&&p(e,s)},value:c||"",disabled:r&&!L||!l||w,color:"primary",children:B().map(((e,t)=>(0,h.jsx)(o.MenuItem,{value:e.flowId,name:e.flowName,style:{color:P(e)?"inherit":"#A0A0A0",cursor:P(e)?"pointer":"not-allowed",opacity:P(e)?1:.6},onClick:t=>{e.status||t.stopPropagation()},children:(0,h.jsx)(o.Tooltip,{title:M(e),placement:"right",children:(0,h.jsx)("span",{style:{width:"100%",display:"inline-block"},children:e.flowName})})},e.flowId||t)))}):(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,style:{borderRadius:"10px"}})}),_?(0,h.jsxs)("div",{className:u.flowBlockContainer,onClick:e=>{S(e,s)},children:[(0,h.jsxs)("div",{value:"Edit",disabled:!0,style:{backgroundColor:"#F0F0F0",padding:"10px",borderRadius:"8px",fontSize:"14px",fontFamily:"Inter",fontWeight:500,lineHeight:"150%",width:"123px",display:"flex",alignItems:"center",justifyContent:"space-between",color:"#959595",boxSizing:"border-box",cursor:"pointer"},children:[(0,h.jsx)("span",{children:"Edit"}),(0,h.jsx)(d.Edit,{style:{padding:0}})]}),!r&&t.length>1&&(0,h.jsx)(o.Button,{variant:"contained",color:"primary",onClick:()=>a(s),disabled:!l||w,className:u.display_600,children:"Remove"})]}):(0,h.jsxs)("div",{className:u.flowBlockContainer,children:[(0,h.jsx)(o.Button,{variant:"contained",color:"primary",disabled:!c||!i||w,style:{minWidth:"fit-content",whiteSpace:"nowrap"},onClick:e=>S(e,s),children:"Choose Block"}),!r&&t.length>1&&(0,h.jsx)(o.Button,{variant:"contained",color:"primary",onClick:()=>a(s),disabled:!l||w,className:u.display_600,children:"Remove"})]}),!r&&t.length>1&&!w&&(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(o.IconButton,{style:{padding:0},onClick:()=>a(s),disabled:!l,children:(0,h.jsx)(Bs,{className:u.displayNone_600})})})]},s)})):(0,h.jsx)("div",{style:{width:"100%",display:"flex",justifyContent:"center",color:"#404040",margin:"40px 0 40px 0"},children:"No Ice Breakers Added"})]})]})},qc=(0,i.connect)((e=>({reduxIceBreakers:e.assistantDetails.iceBreakers,flows:[...e.flow.flows],assistantDetails:e.assistantDetails.data})),{updateFlowPopupStatus:$.cb,handleIceBreakerFlowChange:Kc.UQ,updateCurrentPopupFlowId:$.s$,updateIceBreakers:$.W$,clearFlowState:Kc.jW,getFlows:Kc.Qj,fetchIceBreakers:_n.jc})((e=>{const{classes:t,isLiveChat:a,flows:s,changeState:i,greetingMessage:r,switchChecked:l,iceBreakers:c,isSwitchLoading:p,isLiveAD:u,isAdFetched:m,pageDetails:g,whatsappBusinessName:b,whatsappDisplayImage:y,debouncedUpdateIceBreakers:x,iceBreakerName:f,isIceBreakerSaving:A,showSaveIceBreakerModal:I,handleSaveIceBreaker:C,iceBreakerNodeId:_,handleUpdateIceBreaker:S,totalAdsCount:v,currSelectedSavedIceBreaker:E,savedIceBreakers:T}=e,[D,w]=(0,n.useState)(null),[N,j]=(0,n.useState)(""),[k,L]=(0,n.useState)(""),[R,B]=(0,n.useState)(!1),[P,M]=(0,n.useState)(!1),[U,F]=(0,n.useState)(""),W=(0,n.useRef)(null),z=(0,n.useRef)(null),G=(0,Jc.g)(),[H,V]=(0,n.useState)(null),{showSnackbar:Y}=(0,ls.dh)(),Z=window.location.pathname.includes("duplicate"),K=window.location.pathname.includes("create"),J=window.location.pathname.includes("edit"),$=!m&&J||J&&m&&u,q=e=>{i("currSelectedSavedIceBreaker",e)},X=e=>{i("iceBreakerName",e)},Q=()=>{const e=(()=>{if(l){if(!f)return"Icebreaker Name is required";if(!a&&!r)return"Greeting Message is required";if(0===c.length)return"At least One Ice Breaker is required";if(c.some((e=>{let{iceBreakerText:t}=e;return!t})))return"Ice Breaker Text Cannot be Empty";if(c.some((e=>{let{flowId:t,blockId:a}=e;return t&&!a})))return"Please select blocks for all flows";for(let e=0;e<c.length-1;e++){const{iceBreakerText:t}=c[e];for(let a=e+1;a<c.length;a++){const{iceBreakerText:e}=c[a];if(t===e)return"Duplicate Icebreaker Texts are not allowed"}}}})();return!e||(Y(e,"warning"),!1)},ee=()=>{const{projectId:t}=G;e.clearFlowState(),e.getFlows(t);const a=[{iceBreakerText:"",flowId:"",iceBreakerId:`${Date.now()}`,blockId:"",blockHandle:""}];i("iceBreakers",a),i("greetingMessage",""),X(""),q(null),j(""),V(null)},te=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const{projectId:a}=G;a&&(M(!0),e.fetchIceBreakers({assistantId:a,text:t}).then((e=>{(e=>{i("savedIceBreakers",e)})(e),M(!1),console.log(e)})).catch((e=>{M(!1),console.log("Error fetching Ice Breakers",e),F("Error fetching Icebreakers"),B(!0),L("error")})))},ae=()=>E&&E.name!==f,ne=()=>{if(!E)return!1;const{iceBreakerFlowMapping:e}=E.iceBreakers;if((K||J||Z)&&E.iceBreakers.rawMetaIceBreakers.text!==r)return!0;
1if(e.length!==c.length)return!0;for(let t=0;t<e.length;t++){if(e[t].iceBreaker!==c[t].iceBreakerText)return!0;if(e[t].flowId!==c[t].flowId)return!0;if(e[t].blockId!==c[t].blockId)return!0;if(e[t].blockHandle!==c[t].blockHandle)return!0}return!1},se=(0,n.useMemo)((()=>as().debounce(te,500)),[]);return(0,h.jsxs)("div",{className:t.root,children:[(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:""+(a||$?"none":"1px solid #F0F0F0"),padding:""+(a||$?"0":"0 0 24px 0")},children:[(0,h.jsx)(o.Typography,{style:{fontSize:"18px",fontWeight:500,fontFamily:"Inter"},children:"Icebreaker Message"}),a&&(0,h.jsxs)(h.Fragment,{children:[" ",p?(0,h.jsx)(o.CircularProgress,{style:{width:"20px",height:"20px"}}):(0,h.jsx)(o.Tooltip,{title:u&&!Z?"You can't change icebreaker status once the ad is live":"",children:(0,h.jsx)("span",{style:{display:"inline-block"},children:(0,h.jsx)(o.Switch,{color:"primary",checked:l,disabled:$,onChange:()=>{i("switchChecked",!l)}})})})]})]}),(0,h.jsxs)("div",{style:{backgroundColor:"#FFFBEBBF",borderRadius:"12px",padding:"15px 19px",marginTop:"24px",display:"flex",flexDirection:"column"},children:[(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",alignItems:"flex-start"},children:[(0,h.jsx)("div",{style:{width:"20px",height:"20px"},children:(0,h.jsx)(Qd,{style:{width:"20px",height:"20px"}})}),(0,h.jsx)(o.Typography,{style:{fontFamily:"Inter",fontWeight:600,fontSize:"16px",margin:0,lineHeight:"150%",color:"#92400D"},children:"For You"})]}),(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column",color:"#92400D",fontFamily:"Inter",fontWeight:500,fontSize:"14px",marginTop:"12px",gap:"5px"},children:[(0,h.jsxs)(o.Typography,{children:["1."," ",a?"This message will be pre-filled the first time someone taps your WhatsApp number on mobile.":"This message will be pre-filled when customers click your ad and\n            open WhatsApp"]}),(0,h.jsx)(o.Typography,{children:"2. Connect each icebreaker message to a specific WhatsApp flow to automate customer conversation"})]})]}),!$&&(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column",width:"100%",opacity:""+($&&!J?"0.6":J||l?"1":"0.6")},children:[(0,h.jsx)("h3",{style:{color:"#232529",fontFamily:"Inter",fontWeight:500,fontSize:"14px",lineHeight:"140%",letterSpacing:"-2%",margin:0,marginBottom:"11px",marginTop:"13px"},children:"Search Saved Icebreakers"}),(0,h.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"20px"},children:[m||K||a?(0,h.jsx)(o.Tooltip,{title:u&&!Z?"Ice Breaker text can't be edited after the ad is live":"",children:(0,h.jsx)(O.Autocomplete,{options:T,getOptionLabel:e=>e.name,disabled:$||a&&!l||!l,value:H,loading:P,onFocus:e=>{T&&0!==T.length||te()},onChange:(e,t)=>
1{t?V(t):ee()},clearOnBlur:!1,renderInput:e=>(0,h.jsx)(o.TextField,{...e,variant:"outlined",value:N,disabled:a&&!l,placeholder:"Search saved Icebreakers",classes:{root:t.textFieldRoot},InputProps:{...e.InputProps,startAdornment:(0,h.jsx)(o.InputAdornment,{position:"start",children:(0,h.jsx)(Ni.A,{size:20,className:t.searchIcon})}),endAdornment:(0,h.jsxs)(h.Fragment,{children:[P?(0,h.jsx)(o.CircularProgress,{size:20,style:{marginRight:60}}):null,e.InputProps.endAdornment]})},onChange:e=>{const t=e.target.value;j(t),se(t)}}),renderOption:t=>(0,h.jsx)(o.Box,{onClick:n=>{q(t),X(t.name),(t=>{const{iceBreakers:n}=t,s=n.rawMetaIceBreakers.text,{iceBreakerNodeId:o}=n;let r=[];const{status:l,rawMetaIceBreakers:d}=n;if(d&&l&&d.ice_breakers&&n&&n.iceBreakerFlowMapping){const t=n.iceBreakerFlowMapping;r=d.ice_breakers.map((n=>{let{title:s}=n;const o=t.find((e=>e.iceBreaker===s))||{},i=o?.flowId,r=o?.iceBreakerId,l=!!o?.blockId&&e.flows?.find((e=>e._id===i))?.flow?.nodes?.some((e=>e.id===o?.blockId)),d=l&&o?.blockId||"",c=l&&o?.blockHandle||"",p=e.flows?.find((e=>e._id===i))?.flow?.nodes[0]?.data?.ads?.length||0;return{flowId:J||a||p<v?i:"",iceBreakerText:s,iceBreakerId:r,blockId:J||a||p<v?d:"",blockHandle:J||a||p<v?c:""}}))}x({iceBreakerNodeId:_,iceBreakers:r}),a||i("switchChecked",l),i("greetingMessage",s),i("iceBreakers",r),i("iceBreakerNodeId",_),i("prevIceBreakerNodeId",o)})(t)},width:"100%",children:(0,h.jsx)(o.Typography,{variant:"body1",style:{display:"flex",alignItems:"center"},children:t.name})}),classes:{inputRoot:t.inputRoot},style:{width:"100%"}})}):(0,h.jsx)(O.Skeleton,{variant:"rectangular",height:40,style:{borderRadius:"10px",width:"100%"}}),(0,h.jsx)(o.Button,{color:"primary",variant:"contained",style:{whiteSpace:"nowrap",height:"40px"},onClick:ee,children:"Create New"})]})]}),(0,h.jsx)("div",{className:t.overlay,style:{marginTop:"24px",opacity:""+($&&!J?"0.6":J||l?"1":"0.6")},children:(0,h.jsxs)("div",{className:t.iceBreakerDiv,children:[(0,h.jsx)("div",{style:{width:"100%"},children:(0,h.jsx)("div",{style:{width:"100%"},children:(0,h.jsx)("div",{children:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)($c,{totalAdsCount:v,iceBreakers:c,greetingMessage:r,setGreetingMessage:e=>{i("greetingMessage",e)},handleRemoveIceBreaker:e=>{if(0===c.length)return;const t=c.filter(((t,a)=>a!==e));i("iceBreakers",t)},handleEditIceBreaker:(e,t)=>{const a=e.target.value.trimStart();if(a.length>80)return;const n=[...c];n[t].iceBreakerText=a,i("iceBreakers",n)},isDisabled:$,switchChecked:l,flows:s||[],onChangeIceBreakerFlow:(t,a)=>{const n=c.map(((n,s)=>{if(a===s){let a="",s="";const o=e.flows.find((e=>e._id===t.target.value));if(o){const e=o.flow.edges;for(let t of e)if(t.sourceHandle.includes("icebreaker")){const e=t.sourceHandle?.split("-").reverse()[0];e===n.iceBreakerId&&(a=t.target||"",s=t.targetHandle||"")}}return{...n,blockId:a,blockHandle:s}}{const t=e.reduxIceBreakers.iceBreakers.find((e=>e.iceBreakerId===n.iceBreakerId));if(t)return{...n,blockId:t.blockId,blockHandle:t.blockHandle}}})),s=n[a],o=s.flowId;n[a].flowId=t.target.value,i("iceBreakers",n),e.handleIceBreakerFlowChange(s.iceBreakerId,_,o)},classes:t,handleDragStart:(e,t)=>{w(t),e.dataTransfer.effectAllowed="move",z.current&&z.current.classList.add("dragging")},handleDragOver:e=>{e.preventDefault()},handleDrop:e=>{if(null===D||D===e)return;const t=[...c],[a]=t.splice(D,1);t.splice(e,0,a),i("iceBreakers",t),w(null),W.current&&(W.current.style.cursor="grab",W.current=null),z.current&&z.current.classList.remove("dragging")},draggedRef:W,handleDragEnd:()=>{z.current&&z.current.classList.remove("dragging")},containerRef:z,isAdFetched:m,draggable:!$,isLiveAD:u,isLiveChat:a,handleFlowBlock:(t,a)=>{const n=c[a].flowId;i("currSelectedFlowId",n),e.updateFlowPopupStatus(!0),e.updateCurrentPopupFlowId(n)},reduxIceBreakers:e.reduxIceBreakers,iceBreakerName:f,setIceBreakerName:X}),(0,h.jsxs)("div",{style:{width:"100%",display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[$?(0,h.jsx)("div",{children:" "}):(0,h.jsx)(o.Button,{variant:"outlined",color:"primary",startIcon:(0,h.jsx)(d.AddOutlined,{}),style:{width:"190px",marginTop:"12px",marginBottom:"12px",paddingTop:"10px",paddingBottom:"10px"},onClick:()=>
1{if(c.length>=4)return void Y("Only Max 4 Icebreakers Can be Added","warning");const t=c.map((t=>{const a=e.reduxIceBreakers.iceBreakers.find((e=>e.iceBreakerId===t.iceBreakerId));if(a)return{...t,blockId:a.blockId,blockHandle:a.blockHandle}}));i("iceBreakers",[...t,{iceBreakerText:"",flowId:"",iceBreakerId:`${Date.now()}`,blockId:"",blockHandle:""}])},children:"Add New Icebreaker"}),(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"10px"},children:[(ne()||ae())&&(0,h.jsx)(o.Button,{variant:"outlined",color:"primary",style:{marginTop:"12px",marginBottom:"12px",paddingTop:"10px",paddingBottom:"10px"},onClick:()=>{Q()&&S(E._id)},children:"Update"}),(0,h.jsx)(o.Button,{onClick:()=>{Q()&&C()},color:"primary",variant:"contained",className:t.dialogSaveBtn,style:{paddingTop:"10px",paddingBottom:"10px"},children:ne()||ae()?"Save as New":"Save Icebreakers"})]})]})]})})})}),(0,h.jsx)("div",{style:{padding:"20px",paddingRight:0},children:(0,h.jsx)(Zc,{iceBreakers:c||[],greetingMessage:r||"",pageDetails:g,whatsappBusinessName:b,whatsappDisplayImage:y})})]})}),(0,h.jsx)(o.Snackbar,{className:t.snackbar,open:R,onClose:()=>{B(!1)},anchorOrigin:{vertical:"top",horizontal:"center"},autoHideDuration:3e3,children:(0,h.jsx)(O.Alert,{severity:k,onClose:()=>{B(!1)},children:U})})]})})),Xc=(0,o.withStyles)((e=>({root:{display:"flex",flexDirection:"column",width:"100%"},overlay:{alignItems:"centre",background:"#fff",display:"flex",height:"100%",justifyContent:"centre",width:"100%",zIndex:20,display:"flex",flexDirection:"column"},iceBreakerDiv:{display:"flex",justifyContent:"space-between",[e.breakpoints.down("1400")]:{alignItems:"center",flexDirection:"column"}},iceBreakerMessagesDiv:{display:"flex",backgroundColor:"#FAFAFA",alignItems:"center",padding:"12px",borderRadius:"8px",marginBottom:"12px",gap:"12px",cursor:"grab",[e.breakpoints.down("600")]:{flexDirection:"column"}},flowSelectDiv:{maxWidth:"212px",width:"100%",[e.breakpoints.down("600")]:{maxWidth:"100%"}},displayNone_600:{[e.breakpoints.down("600")]:{display:"none"}},display_600:{display:"none",[e.breakpoints.down("600")]:{display:"block"}},flowBlockContainer:{width:"100%",display:"flex",justifyContent:"space-between",alignItems:"center",[e.breakpoints.up("600")]:{width:"fit-content"}},iconWrapper:{width:"20px",height:"20px"},searchIcon:{color:"#666",marginLeft:e.spacing(1)},textFieldRoot:{backgroundColor:"rgb(240,240,240)",outline:"none",border:"none",borderRadius:"8px",width:"100%",padding:"0",boxShadow:"none",boxSizing:"border-box",fontFamily:"Roboto, sans-serif",fontSize:"15px",fontWeight:500,maxHeight:"12em",overflow:"auto","&::-webkit-scrollbar":{width:"4px"}},inputRoot:{'&[class*="MuiOutlinedInput-root"][class*=MuiAutocomplete-input]':{padding:12},'&&[class*="MuiOutlinedInput-root"]':{padding:0},'&[class*="MuiOutlinedInput-root"][class*=MuiAutocomplete-inputRoot]':{paddingRight:"0 !important",paddingLeft:"0 !important"}},saveIceBreakerBtn:{padding:"8px 16px",borderRadius:"8px",fontSize:"14px",fontWeight:"500"},disabledBtn:{background:"rgba(0, 0, 0, 0.12)",color:"rgba(0, 0, 0, 0.26)",border:"none"},dialogSaveBtn:{[e.breakpoints.down("xs")]:{width:"100%"}},saveIceBreakerDialogTitle:{[e.breakpoints.down("xs")]:{maxWidth:"100%"}},saveIceBreakerDialogWrapper:{display:"flex",justifyContent:"space-between",alignItems:"center",[e.breakpoints.down("xs")]:{alignItems:"flex-start",paddingRight:"24px",width:"100%",boxSizing:"border-box"}},saveIceBreakerCloseIcon:{marginRight:24,"&:hover":{cursor:"pointer"},[e.breakpoints.down("xs")]:{display:"none"}},iceBreakerDetailValues:{[e.breakpoints.down("xs")]:{marginTop:"-8px"},saveIceBreakerBtnContainer:{display:"flex",gap:"8px",[e.breakpoints.down("xs")]:{flexDirection:"column",width:"100%"}},dialogSaveBtn:{paddingTop:"10px",paddingBottom:"10px",[e.breakpoints.down("xs")]:{width:"100%"}}},snackbar:{zIndex:3e3,top:70}})))(qc);var Qc=a(68049);function ep(e){return(0,h.jsx)(B,{name:"flowsPage",...e,fallback:(0,h.jsxs)(o.Box,{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gridGap:8,p:3,textAlign:"center",children:[(0,h.jsx)(o.Typography,{variant:"h4",children:"Flow builder not available here"}),(0,h.jsx)(o.Typography,{variant:"body2",style:{color:"#666",maxWidth:460},children:"Ice breaker messages can be added and edited. Connecting a chatbot flow to an ice breaker is still done from the Flows section."})]})})}const tp=(e,t)=>{for(let a=0;a<t.length;a++)e=e.replace(`{{${a+1}}}`,t[a]);return e},ap=(e,t,a,n)=>{let{assistantDetails:s,onError:o}=n,i=[],r=!1;const{Easyinsightskey:l,isOrderFlowEnabled:d,assistantId:c,flowConfiguration:p}=s;return e.forEach((e=>{let n={messageId:e.id};if("keywordBox"===e.type)n={...n,keywords:e.data.keywords?.map((e=>(e||"").toUpperCase().trim())),templates:e?.data?.templates?.map((e=>({id:e._id,name:e.name,quickReplies:e?.carouselCards?.length?e?.carouselCards?.[0]?.components?.find((e=>"BUTTONS"===e.type)).buttons.map((a=>({label:a.text,triggerMessageId:t.find((t=>t.sourceHandle.includes(":--:")?t.sourceHandle===a.text.trimEnd().split(" ").join("_")+`:--:${e._id}`:t.sourceHandle===a.text.trimEnd().split(" ").join("_")))?.target}))):e?.buttons?.length?e?.buttons?.map((a=>({label:a.text,triggerMessageId:t.find((t=>t.sourceHandle.includes(":--:")?t.sourceHandle===a.text.trimEnd().split(" ").join("_")+`:--:${e._id}`:t.sourceHandle===a.text.trimEnd().split(" ").join("_")))?.target}))):e?.quickReplies?.length?e?.quickReplies?.map((a=>({label:a,triggerMessageId:t.find((t=>t.sourceHandle.includes(":--:")?t.sourceHandle===a.trimEnd().split(" ").join("_")+`:--:${e._id}`:t.sourceHandle===a.trimEnd().split(" ").join("_")))?.target}))):[]}))),qrCampaigns:e?.data?.qrCampaigns?.map((e=>({id:e._id,name:e.name,payload:e.payload,activeCustomMessage:e?.activeCustomMessage}
1))),ad:e.data.ad?{adId:e.data.ad.adId,triggerMessageId:t.find((e=>"ad-right-0"===e.sourceHandle))?.target}:null,ads:e.data.ads?e.data.ads.map((e=>({adId:e.adId,triggerMessageId:t.find((t=>t.sourceHandle===`ad-right-${e.adId}`))?.target,iceBreakers:e.iceBreakers?.iceBreakerFlowMapping?.map((a=>{const n=t.find((t=>{const n=t.sourceHandle.split("-").reverse()[0],s=t.sourceHandle.split("-").reverse()[1]||"",o=a.iceBreakerId,i=e.iceBreakers?.iceBreakerNodeId;return n===o&&i===s&&n&&s&&o&&i}))?.target;return{...a,triggerMessageId:n}}))}))):null,iceBreakers:e?.data?.iceBreakers?.map((e=>{const a=t.find((t=>{const a=t.sourceHandle.split("-").reverse()[0],n=t.sourceHandle.split("-").reverse()[1]||"",s=e.id.split("-").reverse()[0],o=e.id.split("-").reverse()[1]||"";return a===s&&o===n&&a&&n&&s&&o}))?.target;return{...e,triggerMessageId:a}}))||[],regex:e.data.regex,regexCaseSensitive:!!e.data.regexCaseSensitive,triggerMessageId:t.find((e=>"keyword-right-keyword"===e.sourceHandle))?.target,orderTriggerMessageId:t.find((e=>"keyword-order-right-keyword"===e.sourceHandle))?.target,isOrderEnabled:!(!d||!t.find((e=>"keyword-order-right-keyword"===e.sourceHandle))?.target&&!e?.data?.isOrderEnable)};else if("masterComponent"===e.type){let o=[];e.data.content.forEach((n=>{let i={};if("message"===n.type){if(i={type:n.data.buttons.length?"INTERACTIVE":"text"},!n.data.text)return void(r=!0);if("text"===i.type)i={...i,type:"TEXT",text:n.data.text};else{if((e=>{if(!e.length)return!0;const t=e;for(let e=0;e<t.length;e++)if(!t[e].text)return!0;return!1})(n?.data?.buttons))return void(r=!0);i={...i,interactive:{type:"button",body:{text:n.data.text},action:{buttons:n?.data?.buttons?.map((n=>({type:"reply",reply:{id:`message_with_button-${e.id}-${n.id}-|${a}`,title:n.text},triggerMessageId:t.find((t=>t.sourceHandle===`message_with_button-right-${e.id}-${n.id}`))?.target})))}}}}}else if("questionMessage"===n.type){if(i={type:"QUESTION"},!n.data.text)return void(r=!0);i={...i,skipable:n.data.skipable,text:n.data.text,attribute:n.data.attribute,triggerMessageId:t.find((t=>t.sourceHandle===`question-right-${e.id}`))?.target,errorTriggerMessageId:t.find((t=>t.sourceHandle===`question-error-right-${e.id}`))?.target,attributeNumberOfAttempt:n.data.attributeNumberOfAttempt||"1",attributeFormatValue:n.data.attributeFormatValue||{},attributeFormatValidationErrorMessage:n.data.attributeFormatValidationErrorMessage,attributeFormat:n.data.attributeFormat||"Any",mediaType:n.data.mediaType||""}}else if("questionMediaMessage"===n.type){if(i={type:"QUESTION"},!n.data.text)return void(r=!0);i={...i,text:n.data.text,attribute:n.data.attribute,skipable:n.data.skipable,triggerMessageId:t.find((t=>t.sourceHandle===`question-media-right-${e.id}`))?.target,errorTriggerMessageId:t.find((t=>t.sourceHandle===`question-error-right-${e.id}`))?.target,attributeNumberOfAttempt:n.data.attributeNumberOfAttempt||"1",attributeFormatValidationErrorMessage:n.data.attributeFormatValidationErrorMessage,attributeFormat:"Media",mediaType:n.data.mediaType||"Any"}}else if("whatsappPay"===n.type)i={type:"WHATSAPPPAY"},i={...i,amount:n.data.amount,title:n.data.title,currency:"Dollar"===n.data.currency?"USD":"INR",paymentMode:n.data.paymentMode,productName:n.data.productName,productQuantity:n.data.productQuantity,templateName:n.data.templateName,isCustomProduct:n.data.isCustomProduct,notes:n.data.notes,triggerMessageId:t.find((t=>t.sourceHandle===`whatsapp-pay-right-${e.id}`))?.target};else if("ConversionApi"===n.type){if(i={type:"ConversionApi"},"Lead"!==n?.data?.conversionType&&("Purchase"!==n?.data?.conversionType||!n?.data?.currencyCode||isNaN(Number(n?.data?.value))||0===Number(n?.data?.value)))return void(r=!0);i={...i,value:n.data.value,conversionType:n.data.conversionType,currencyCode:n.data.currencyCode||"INR",triggerMessageId:t.find((t=>t.sourceHandle===`set-conversion-right-${e.id}`))?.target}}else if("setAVariable"===n.type){if(i={type:"SETAVARIABLE"},!n.data.value)return void(r=!0);i={...i,value:n.data.value,attribute:n.data.attribute,triggerMessageId:t.find((t=>t.sourceHandle===`set-a-varibale-right-${e.id}`))?.target}}else if("condition"===n.type){if(i={type:"CONDITION"},!n.data.condition&&!n.data.attributeOne)return void(r=!0);i={...i,conditionKey:n.data.conditionKey,attributeOne:"$"+n.data.attributeOne,attributeTwo:n.data.attributeTwo,rangeObject:n.data.rangeObject,trueTriggerMessageId:t.find((t=>t.sourceHandle===`condition-right-true-${e.id}`))?.target,falseTriggerMessageId:t.find((t=>t.sourceHandle===`condition-right-false-${e.id}`))?.target}}else if("questionAddressMessage"===n.type){if(i={type:"QUESTIONADDRESS"},!n.data.text)return void(r=!0);i={...i,text:n.data.text,attribute:n.data.attribute,formattedAttribute:n.data.formattedAttribute,triggerMessageId:t.find((t=>t.sourceHandle===`question-address-message-right-${e.id}`))?.target}}else if("questionLocationMessage"===n.type){if(i={type:"QUESTIONLOCATION"},!n.data.text)return void(r=!0);i={...i,text:n.data.text,longitudeAttribute:n.data.longitudeAttribute,latitudeAttribute:n.data.latitudeAttribute,triggerMessageId:t.find((t=>t.sourceHandle===`question-location-message-right-${e.id}`))?.target}}else if("addTag"===n.type){if(i={type:"ADDTAG"},!(n?.data?.tags||[]).length)return void(r=!0);i={...i,tags:n.data.tags,triggerMessageId:t.find((t=>t.sourceHandle===`add-tag-right-${e.id}`))?.target}}else if("setupWebhook"===n.type){if(i={type:"SETUPWEBHOOK"},!n.data.requestObject)return void(r=!0);i={...i,requestObject:n.data.requestObject,attribute:n.data.attribute||"",responseKey:n?.data?.responseKey||"",statusCodes:(n?.data?.statusCodes||[]).map((e=>({code:e.code,triggerMessageId:t.find((t=>t.sourceHandle===`${e.handleId}`))?.target}))),triggerMessageId:t.find((t=>t.sourceHandle===`setup-webhoook-right-${e.id}`))?.target,capturingAttributes:n?.data?.capturingAttributes}}else if("easyinsights"===n.type){if(i={type:"EASYINSIGHTS"},!n.data.eventType)return void(r=!0);if("Status Change"===n.data.eventType&&!n.data.conversionName)return void(r=!0);if(!("Transaction"!==n.data.eventType||n.data.revenue&&n.data.currency&&n.data.discount&&n.data.offerCode))return void(r=!0);i={...i,key:l,eventType:n.data.eventType,conversionName:n.data.conversionName,revenue:n.data.revenue,currency:n.data.currency,discount:n.data.discount,offerCode:n.data.offerCode,triggerMessageId:t.find((t=>t.sourceHandle===`easyinsights-right-${e.id}`))?.target}}else if("imageWithCaption"===n.type){if(!n.data.url||!n.data.fileType)return void(r=!0);(n?.data?.buttons||[]).length>0?i={type:"INTERACTIVE",interactive:{type:"button",header:{type:"file"===n.data.fileType.toLowerCase()?"document":n.data.fileType.toLowerCase(),["file"===n.data.fileType.toLowerCase()?"document":n.data.fileType.toLowerCase()]:{link:n.data.url,..."FILE"==n.data.fileType?{filename:n.data?.fileName}:{}}},body:{text:n.data.text||"."},action:{buttons:n?.data?.buttons?.map((n=>({type:"reply",reply:{id:`message_with_button-${e.id}-${n.id}-|${a}`,title:n.text},triggerMessageId:t.find((t=>t.sourceHandle===`message_with_button-right-${e.id}-${n.id}`))?.target})))}}}:(i={type:n.data.fileType,url:n.data.url,caption:n.data.text,size:n.data.fileSize},"FILE"==n.data.fileType&&(i={...i,filename:n.data?.fileName}))}else if("templateMessage"===n.type)i={type:"TEMPLATE",template:{...n.data,templateType:n.data.type,name:n.data.name,templateLanguage:n.data.templateLanguage,namespace:n.data.namespace,parameters:n.data.parameters,format:n.data.format,templateParams:n.data.parameters?n.data.templateParams.slice(0,n.data.parameters):[],isTemplate:!0,url:n.data.url,filename:n.data.filename,..."TEXT"===n.data.type?{text:tp(n.data.format,n.data.templateParams)}:{caption:tp(n.data.format,n.data.templateParams)}}};else if("listMessage"===n.type){if(!n.data.body||!n?.data?.sections?.length||(e=>{if(!e.length)return!0;const t=e;for(let e=0;e<t.length;e++){if(!t[e].items.length)return!0;for(let a=0;a<t[e].items.length;a++)if(!t[e].items[a].title)return!0}return!1})(n?.data?.sections))return void(r=!0);i={type:"INTERACTIVE",interactive:{type:"list",...n.data.header?{header:{type:"text",text:n.data.header}}:{},body:{text:n.data.body},...n.data.footer?{footer:{text:n.data.footer}}:{},action:{button:n.data.buttonTitle,sections:n?.data?.sections?.map((e=>({id:e.id,title:e.title,rows:e?.items?.map((e=>({id:e.id+`-|${a}
1`,title:e.title,description:e.description,triggerMessageId:t.find((t=>t.sourceHandle===e.id))?.target})))})))}}}}else if("whatsappForms"===n.type){if(!(n.data.body&&n?.data?.flowId&&n?.data?.flowStatus&&n?.data?.screenName&&n?.data?.buttonTitle))return void(r=!0);i={triggerMessageId:t.find((t=>t.sourceHandle===`whatsapp-forms-${e.id}`))?.target,attributeFormatValidationErrorMessage:n.data.attributeFormatValidationErrorMessage,type:"INTERACTIVE",interactive:{type:"flow",...n.data.header?{header:{type:"text",text:n.data.header}}:{},body:{text:n.data.body},...n.data.footer?{footer:{text:n.data.footer}}:{},action:{name:"flow",parameters:{flow_message_version:"3",flow_action:n?.data?.flowAction||"navigate",flow_token:n.data.flowToken||"<FLOW_TOKEN>",flow_id:n.data.flowId,flow_cta:n.data.buttonTitle,mode:n.data.flowStatus.toLowerCase(),..."data_exchange"!=n.data.flowAction?{flow_action_payload:{screen:n.data.screenName,data:n.data.attributeName||""}}:{}}}}}}else if("catalogueMessage"===n.type){if(!n?.data?.body)return void(r=!0);i={type:"INTERACTIVE",interactive:{type:"catalog_message",body:{text:n.data.body},...n.data.footer?{footer:{text:n.data.footer}}:{},action:{name:"catalog_message"}}}}else if("singleProductMessage"===n.type){if(!n?.data?.product?.catalogueId)return void(r=!0);i={type:"INTERACTIVE",interactive:{type:"product",...n.data.body?{body:{text:n.data.body}}:{},...n.data.footer?{footer:{text:n.data.footer}}:{},action:{catalog_id:n.data.product.catalogueId,product_retailer_id:n.data.product.retailerId}}}}else if("multiProductMessage"===n.type){if(!(n?.data?.header&&n?.data?.body&&n?.data?.sections?.length&&n?.data?.sections[0]?.products?.length))return void(r=!0);i={type:"INTERACTIVE",interactive:{type:"product_list",...n.data.header?{header:{type:"text",text:n.data.header}}:{},body:{text:n.data.body},...n.data.footer?{footer:{text:n.data.footer}}:{},action:{catalog_id:n?.data?.sections[0]?.products[0].catalogueId,sections:n?.data?.sections?.map((e=>({id:e.id,title:e.title,product_items:e?.products?.map((e=>({product_retailer_id:e.retailerId})))})))}}}}else"humanIntervention"===n.type?i={...i,type:"HUMANINTERVENTION",isRequesting:!0}:"connectFlows"===n.type?i={...i,flowId:n.data.flowId,flowName:n.data.flowName,type:"CONNECTFLOWS"}:"iceBreaker"===n.type&&(i={type:"ICEBREAKERS",iceBreakers:n.data.iceBreakers?.map((e=>{const a=t.find((t=>{const a=t.sourceHandle.split("-").reverse()[0],n=t.sourceHandle.split("-").reverse()[1]||"",s=e.id.split("-").reverse()[0],o=e.id.split("-").reverse()[1]||"";return a===s&&o===n&&a&&n&&s&&o}))?.target;return{...e,triggerMessageId:a}}))});i={...i,delay:n.data?.delay},n?.data?.timeoutToggle&&(p?.timeoutEnabled||J._T.includes(c)||s?.flowsProFeatureEnabled)&&(i={...i,time:+n?.data?.time,timeoutMessageTriggerId:t.find((t=>t.sourceHandle===`component-right-timeout-${e.id}`))?.target}),o.push(i)})),n={...n,content:o,defaultTriggerMessageId:t.find((t=>t.sourceHandle===`master-component-right-${e.id}`))?.target}}i.push(n)})),r?(o("Please fill all required fields "),[]):i},np=e=>{const t=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=e.adAccountData?.timezone,{fromDate:n,toDate:s,selectedCells:o}=e;if(!s)return{invalidSlots:[]};const i=new Set;let r=Zr().tz(n,a).startOf("day");const l=Zr().tz(s,a).endOf("day");if(l.diff(r,"days")>=6)return{invalidSlots:[]};for(;r.isSameOrBefore(l);)i.add(r.day()),r.add(1,"day");const d=[],c=new Set;for(const e of o){const[t]=e.split("-");if("7"===t)continue;const a=parseInt(t,10);i.has(a)||(d.push(e),c.add(a))}if(d.length>0){const e=[...c].map((e=>t[e])).join(", "),s=[];for(r=Zr().tz(n,a);r.isSameOrBefore(l);)s.push(t[r.day()]),r.add(1,"day");const o=[...new Set(s)];return{invalidSlots:d,message:`You have scheduled this ad set to run on ${e}. But the selected date range only includes ${1===o.length?o[0]:`${o[0]} to ${o[o.length-1]}`}. Please change your date range or schedule.`}}return{invalidSlots:[]}},sp=e=>{let t;try{t=new window.URL(e)}catch(e){return!1}return"http:"===t.protocol&&e?.startsWith("http://")||"https:"===t.protocol&&e?.startsWith("https://")},op=(e,t)=>{const a=new Map;for(const t of e){const e=t.split("-"),n=parseInt(e[0],10),s=parseInt(e[1],10);n>=0&&n<=6&&s>=0&&s<=23&&(a.has(s)||a.set(s,[]),a.get(s).push(n))}const n=[],s=Array.from(a.keys()).sort(((e,t)=>e-t));for(const e of s){const s=60*e,o=60*(e+1),i=Array.from(new Set(a.get(e))).sort(((e,t)=>e-t));n.push({start_minute:s,end_minute:o,days:i,timezone_type:"viewer"===t.value?"USER":"ADVERTISER"})}return n},ip=e=>["website_traffic","website_to_whatsapp"].includes(e.adType?.value),rp=e=>"whatsapp_status"===e.adType?.value?"Carousel format is not supported for WhatsApp Status ads":(e.adPlacements?.facebookPositions||[]).includes("story")?"Carousel format cannot be combined with the Story placement":"",lp=e=>{try{return new window.URL(e),!0}catch(e){return!1}},dp=(e,t,a)=>("video"===e.mediaType?e.videoUrl:e.imageUrl)?e.imageUrl&&!lp(e.imageUrl)?`Card #${t+1}
1: image URL is invalid`:e.videoUrl&&!lp(e.videoUrl)?`Card #${t+1}: video URL is invalid`:e.headline?e.headline.length>40?`Card #${t+1}: headline must be 40 characters or fewer`:e.description&&e.description.length>30?`Card #${t+1}: description must be 30 characters or fewer`:a&&!e.websiteUrl?`Card #${t+1}: website URL is required`:e.websiteUrl&&!lp(e.websiteUrl)?`Card #${t+1}: website URL is invalid`:"":`Card #${t+1}: headline is required`:`Card #${t+1}: image or video is required`,cp=e=>{const{cards:t}=e;if(!Array.isArray(t)||t.length<2||t.length>Cr)return!0;if(rp(e))return!0;const a=ip(e);return t.some(((e,t)=>!!dp(e,t,a)))},pp=e=>{const{cards:t}=e;if(!Array.isArray(t)||t.length<2)return"A carousel needs at least 2 cards";if(t.length>Cr)return"A carousel can have at most 10 cards";const a=rp(e);if(a)return a;const n=ip(e);for(let e=0;e<t.length;e++){const a=dp(t[e],e,n);if(a)return a}return""},up=(e,t,a)=>{const{metaAdsCredit:n,currency:s}=t,{adCaption:o,adName:i,imageFile:r,videoFile:l,thumbnailUrl:d,uploadType:c,adHeadline:p,gender:u,selectedLocations:m,FromAge:h,ToAge:g,dailyBudget:b,duration:y,selectedPlatforms:x=[],iceBreakers:f,greetingMessage:A,switchChecked:I,adAccountData:C,lifetimeBudget:_,customAndLookalikeAudiences:S,adFormat:v}=e,{accountId:E}=C||{},T="INR"===(t?.adSetupDetails?.selectedMetaAdAccountId==E?s:C?.currency)?"INR":"USD",D=ea.xt[T],w=ea.VO[T];switch(a){case 0:return!e.selectedAdType;case 1:return"carousel"===v?!o||!i||e.isGenerating||cp(e):!o||!i||!(r||l)||"VIDEO_UPLOAD"===c&&!sp(l?.publicUrl)||"VIDEO_UPLOAD"===c&&d&&!sp(d?.publicUrl)&&!sp(d)||"IMAGE_UPLOAD"===c&&!sp(r?.publicUrl)||"whatsapp_status"!==e.adType?.value&&!p||e.isGenerating;case 2:return!u||(0,ts.isEmpty)(m)&&(0,ts.isEmpty)(S)||!h||!g||!Array.isArray(x)||0===x?.length;case 3:{let t="";if("lifetime_budget"===e.selectedBudget.value&&e.isScheduledAd)if(0===e.selectedCells.size)t="Please select a valid schedule";else{const{invalidSlots:a,message:n}=np(e);a.length>0&&(t=n)}const a=e.startDateError||e.isStartDateNull||e.endDateError||e.isEndDateNull;return"daily_budget"===e.selectedBudget.value?!b||b<D||!y||"USD"!==s&&b&&+n-2*b<0||t||a:!_||_<w||!y||"USD"!==s&&_&&+n-D*y<0||t||a}case 4:return["website_traffic","website_to_whatsapp"].includes(e.adType?.value)?!e.websiteUrl||""===e.websiteUrl.trim():!b||b<D||"USD"!==s&&b&&+n-2*b<0||!(()=>{if(!I)return!0;if(!A||!f||0===f.length)return!1;if(f.some((e=>!e?.iceBreakerText)))return!1;if(f.some((e=>{let{flowId:t,blockId:a}=e;return t&&!a})))return!1;for(let e=0;e<f.length-1;e++){const{iceBreakerText:t}=f[e];for(let a=e+1;a<f.length;a++){const{iceBreakerText:e}=f[a];if(t===e)return!1}}return!0})();default:return!0}},mp=(e,t)=>{const{imageFile:a,videoFile:n,thumbnailUrl:s,uploadType:o,switchChecked:i,iceBreakers:r,greetingMessage:l,adAccountData:d,duration:c}=e,{accountId:p}=d||{},{currency:u,metaAdsCredit:m}=t,h="INR"===(t?.adSetupDetails?.selectedMetaAdAccountId==p?u:d?.currency)?"INR":"USD",g=ea.xt[h],b=ea.VO[h];if(""===e.adName)return"Ad Name is required";if(""===e.adCaption)return"Ad Caption is required";if("carousel"===e.adFormat){const t=pp(e);if(t)return t}else{if("whatsapp_status"!==e.adType?.value&&""===e.adHeadline)return"Ad Headline is required";if("IMAGE_UPLOAD"===o&&!sp(a?.publicUrl))return"Please enter a valid image url";if("VIDEO_UPLOAD"===o&&!sp(n?.publicUrl))return"Please enter a valid video url";if("VIDEO_UPLOAD"===o&&s&&!sp(s?.publicUrl)&&!sp(s))return"Please enter a valid thumbnail url"}if((!e.selectedLocations||0===e.selectedLocations?.length)&&0===e.customAndLookalikeAudiences.length)return"Select at least one location";if(!e.selectedPlatforms||0===e.selectedPlatforms?.length)return"Select at least one Ad platform";if("daily_budget"===e.selectedBudget.value){if(e.dailyBudget<g)return`Daily Budget should be at least ${g} ${(void 0).props?.assistantDetails?.currency}`}else if(e.lifetimeBudget<b)return`Lifetime Budget should be at least ${b} ${(void 0).props?.assistantDetails?.currency}`;if("daily_budget"===e.selectedBudget.value){if(parseInt(m)-2*e.dailyBudget<0)return"Insufficient Balance"}else if(parseInt(m)-g*c<0)return"Insufficient Balance";if(e.startDateError||e.isStartDateNull)return"Invalid Ad Start Date";if(e.endDateError||e.isEndDateNull)return"Invalid Ad End Date";if("lifetime_budget"===e.selectedBudget.value&&e.isScheduledAd&&0===e.selectedCells.size)return"Please select a valid schedule";if("lifetime_budget"===e.selectedBudget.value&&e.isScheduledAd){const{invalidSlots:t,message:a}=np(e);if(t.length>0)return a}if(i){if(!l)return"Greeting Message is required";if(0===r.length)return"At least One Ice Breaker is required";if(r.some((e=>{let{iceBreakerText:t}=e;return!t})))return"Ice Breaker Text Cannot be Empty";if(r.some((e=>{let{flowId:t,blockId:a}=e;return t&&!a})))return"Please select blocks for all flows";for(let e=0;e<r.length-1;e++){const{iceBreakerText:t}=r[e];for(let a=e+1;a<r.length;a++){const{iceBreakerText:e}=r[a];if(t===e)return"Duplicate Icebreaker Texts are not allowed"}}}return["website_traffic","website_to_whatsapp"].includes(e.adType?.value)&&!e.websiteUrl?"Website URL is required":""};var hp=a(55248);const gp="—",bp=["countries","cities","regions","places","zips"],yp=bp.reduce(((e,t)=>({...e,[t]:[]})),{}),xp=["regions","cities","places","zips"],fp=e=>{const t=e||{};return[...(t.countries||[]).map(String),...xp.flatMap((e=>(t[e]||[]).map((e=>{const t=e.name||e.key||"";if(!e.radius)return t;const a="mile"===e.distance_unit?"mi":"km";return`${t} (+${e.radius}${a})`}
1))))].filter(Boolean)},Ap=(e,t)=>{const a={};(Array.isArray(t)?t:[]).forEach((e=>{e&&e.key&&(a[e.key]=e)}));const n={};return Object.keys(e||{}).forEach((t=>{n[t]=(e[t]||[]).map((e=>{if(!e||"object"!=typeof e)return e;const t=a[e.key]||{};return{...t,...e,name:e.name||t.name||e.key}}))})),n},Ip=e=>e&&e.flexible_spec&&e.flexible_spec[0]||e||{},Cp=e=>"interests"===e?"Interests":"behaviors"===e||"behaviours"===e?"Behaviors":"Demographics",_p=e=>{const t=(e||{}).geoLocation;return t?{...yp,...Ap(t,(e||{}).geoLocationDisplay)}:{...yp}},Sp=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.generation&&e.generation.normalizedInput&&e.generation.normalizedInput.url||e.websiteUrl||""},vp=(e,t)=>(e||{})[t]||{},Ep=e=>(e||{}).currency||vp(e,"analytics").currency||vp(e,"prediction").currency||"INR",Tp=e=>Number((e||{}).duration)||Number(vp(e,"selected").durationDays)||Number(vp(e,"prediction").predictedDurationDays)||Number(vp(e,"payload").duration)||0,Dp=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return{labels:e,head:e.slice(0,t).join(", "),all:e.join(", "),hidden:Math.max(0,e.length-t)}},wp=e=>Dp((e=>{const t=(e||{}).geoLocationDisplay;return Array.isArray(t)&&t.length?fp({places:t}):fp((e||{}).geoLocation)})(e)),Np=e=>Dp((e=>{const t=Ip(e);return Object.keys(t).flatMap((e=>{const a=t[e];return Array.isArray(a)?a.map((e=>e&&(e.name||e.id))).filter(Boolean).map((t=>({bucket:e,name:String(t)}))):[]}))})((e||{}).advanceTargets).map((e=>e.name))),jp=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const a=Zr()();let n=Zr()(e).set({hour:a.hour(),minute:a.minute(),second:a.second(),millisecond:a.millisecond()});return t&&(n=n.add(t,"seconds")),n.toDate()},kp=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{adId:t,assistantId:a,assistantName:n,adAccountId:s,metaPageId:o,adDescription:i,adName:r,budgetType:l,dailyBudget:d,lifetimeBudget:c,headline:p,headlineDescription:u,gender:m,minAge:h,maxAge:g,geoLocation:b,excludedGeoLocation:y,adStartDate:x,adStopDate:f,isEndDate:A,duration:I,advanceTargets:C,selectedPlatforms:_,audienceId:S,duplicateAd:v,isScheduledAd:E,adType:T,adObjective:D,optimizationGoal:w,conversionEvent:N,ctaButton:j,websiteUrl:k,pixelId:L,adPlacements:R,customAndLookalikeAudiences:B,excludedCustomAndLookalikeAudiences:O,leadFormId:P,advantageAudience:M,uploadType:U,imageUrl:F,videoUrl:W,adSetSchedule:z,timezoneType:G,iceBreakers:H,adTemplate:V}=e,Y={adId:t,assistantId:a,assistantName:n,adAccountId:s,metaPageId:o,adDescription:i,adName:r,dailyBudget:"daily_budget"===l?d:0,headline:p,headlineDescription:u,gender:m,minAge:parseInt(h),maxAge:parseInt(g),geoLocation:b,excludedGeoLocation:y,adStopDate:A?f:"",adStartDate:x,duration:I,advanceTargets:C,selectedPlatforms:_,audienceId:S||"",duplicateAd:!!v,iceBreakers:{status:!1},isScheduledAd:!!E,lifetimeBudget:"lifetime_budget"===l?c:0,adType:T||"",adObjective:D||"",optimizationGoal:w||"",conversionEvent:N||"",ctaButton:j||"APPLY_NOW",websiteUrl:k,pixelId:L||"",adPlacements:R||{},customAndLookalikeAudiences:B||[],excludedCustomAndLookalikeAudiences:O||[],leadFormId:P||"",advantageAudience:M?1:0,...V?.templateId&&{adTemplate:V}};return E&&(Y.adSetSchedule=z,Y.timezoneType=G),H&&H.status&&(Y.iceBreakers=H),"VIDEO_UPLOAD"===U?(Y.videoUrl=W,Y.imageUrl=F):"IMAGE_UPLOAD"===U&&(Y.imageUrl=F),Y};var Lp=a(10870),Rp=a(29363),Bp=a(97571),Op=a(8992);const Pp=(0,i.connect)((e=>({})),{}
1)((function(e){const{classes:t,payload:a,maxHeight:n,ctaButton:i,websiteUrl:r,activeCardIndex:l,onActiveCardChange:c}=e,{pageDetails:p,previewLink:u,adCaption:m,adHeadline:g,adHeadlineDescription:b,mediaType:y,imageFile:x,videoFile:f,thumbnailUrl:A,ctaButton:I,adType:C,adFormat:_,cards:S=[]}=a||{},{picture:v,pageName:E,whatsappNumber:T}=p||{},D="carousel"===_&&Array.isArray(S)&&S.length>0,w=m||" Enter Caption",N=g||`Contact ${E}`||"Enter Headline",j=i||I,k=e=>{if(!e||"string"!=typeof e)return!1;const t=e.trim();return""!==t&&"@media"!==t&&"media"!==t&&(t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/")||t.startsWith("data:"))},L=x?.publicUrl?(0,wo.replaceDomainInData)(x.publicUrl):null,R=f?.publicUrl?(0,wo.replaceDomainInData)(f.publicUrl):null,B=x&&k(L),O=f&&k(R),P={APPLY_NOW:"Apply now",BOOK_NOW:"Book now",CONTACT_US:"Contact us",DOWNLOAD:"Download",LEARN_MORE:"Learn more",REQUEST_TIME:"Request time",SEE_MENU:"See menu",SHOP_NOW:"Shop now",SIGN_UP:"Sign up",WATCH_MORE:"Watch more",DONATE_NOW:"Donate now"}[j]||(j?j.toString().replace(/_/g," ").toLowerCase().replace(/^\w|\s\w/g,(e=>e.toUpperCase())):"Visit website"),M=e=>{let{cardMediaType:a,cardImageUrl:n,cardVideoUrl:s,cardThumbnailUrl:i,cardHeadline:r,cardDescription:l,cardWebsiteUrl:c,mediaTitle:p}=e;const u=k(n),m=k(s),g=D?t.carouselMedia:t.media;return(0,h.jsxs)(o.Box,{style:{width:"100%",minWidth:0},children:[u||m?"VIDEO"===a&&m?(0,h.jsx)(o.CardMedia,{className:g,src:s,alt:"media",title:p,component:"video",controls:!0,poster:(0,wo.replaceDomainInData)(i)}):u?(0,h.jsx)(o.CardMedia,{className:g,src:n,alt:"media",title:p,component:"img"}):null:(0,h.jsx)(o.Box,{height:D?"300px":"250px",width:"100%",bgcolor:"#fafafa",style:{display:"flex",justifyContent:"center"},children:(0,h.jsx)(o.Grid,{style:{display:"flex",flexDirection:"column",justifyContent:"center"},children:(0,h.jsx)(d.ImageOutlined,{style:{width:"100px",height:"100px",color:"rgb(208 212 208)"}})})}),(0,h.jsxs)(o.Box,{bgcolor:"#fafafa",style:{display:"flex"},children:[(0,h.jsx)(o.Box,{style:{display:"flex",width:"60%",minWidth:0,justifyContent:"space-between"},children:(0,h.jsxs)(o.Box,{style:{width:"100%",minWidth:0},children:[(0,h.jsx)(o.Typography,{variant:"h5",style:{margin:"10px",marginBottom:"0px",fontSize:"12px"},gutterBottom:!0,children:["website_traffic","website_to_whatsapp"].includes(C?.value)?c?c.replace(/^https?:\/\//,""):"WEBSITE":"lead_form"===C?.value?"LEAD FORM":"WHATSAPP"}),(0,h.jsx)(o.Typography,{variant:"h5",style:{marginLeft:"10px",fontSize:"14px",fontWeight:"bold",color:""+(r?"black":"rgb(211 214 211)"),whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r}),l&&(0,h.jsx)(o.Typography,{variant:"body2",style:{marginLeft:"10px",fontSize:"12px",color:"rgb(120,120,120)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:l}),(0,h.jsx)(o.Box,{marginBottom:.5})]})}),(0,h.jsx)(o.Box,{style:{display:"flex",alignItems:"center",width:"40%"},children:["website_traffic","website_to_whatsapp"].includes(C?.value)?(0,h.jsx)(o.Tooltip,{title:c||"No URL added",placement:"top",arrow:!0,children:(0,h.jsx)("span",{style:{display:"inline-flex"},children:(0,h.jsx)(o.Button,{variant:"outlined",style:{color:c?"#darkgreen":"rgba(0, 0, 0, 0.26)",borderColor:c?"darkgreen":"rgba(0, 0, 0, 0.26)",cursor:c?"pointer":"not-allowed",marginLeft:"30px",whiteSpace:"nowrap"},href:c||void 0,target:"_blank",rel:"noopener noreferrer",size:"small",disabled:!c,component:c?"a":"button",children:P})})}):"lead_form"===C?.value?(0,h.jsx)(o.Button,{variant:"outlined",style:{color:"#darkgreen",borderColor:"darkgreen",marginLeft:"30px"},size:"small",children:P}):(0,h.jsx)(o.Button,{variant:"outlined",style:{color:"#darkgreen",borderColor:"darkgreen"},size:"small",startIcon:(0,h.jsx)(xi.A,{}),children:"Whatsapp"})})]})]})};return"whatsapp_status"===C?.value?(0,h.jsx)("a",{href:u,target:"_blank",rel:"noopener noreferrer",style:{cursor:u?"pointer":"default",width:"fit-content",display:"inline-block",justifySelf:"center"},children:(0,h.jsx)(o.Tooltip,{title:u?"Click to see how people will experience your ad":"",placement:"top",children:(0,h.jsxs)(o.Box,{className:t.
1statusCard,children:[B||O?"VIDEO"===y&&O?(0,h.jsx)("video",{src:R,poster:(0,wo.replaceDomainInData)(A),className:t.statusMedia,autoPlay:!0,muted:!0,loop:!0,playsInline:!0}):B?(0,h.jsx)("img",{src:L,alt:"media",className:t.statusMedia}):null:(0,h.jsx)(o.Box,{className:t.statusMedia,style:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#111"},children:(0,h.jsx)(d.ImageOutlined,{style:{width:"80px",height:"80px",color:"rgba(255,255,255,0.3)"}})}),(0,h.jsx)(o.Box,{style:{position:"absolute",top:0,left:0,right:0,height:"35%",background:"linear-gradient(180deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0) 100%)",pointerEvents:"none"}}),(0,h.jsx)(o.Box,{style:{position:"absolute",bottom:0,left:0,right:0,height:"30%",background:"linear-gradient(0deg, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0) 100%)",pointerEvents:"none"}}),(0,h.jsx)(o.Box,{style:{position:"absolute",top:"8px",left:"8px",right:"8px",display:"flex",gap:"4px"},children:[0,1,2].map((e=>(0,h.jsx)(o.Box,{style:{flex:1,height:"3px",borderRadius:"3px",backgroundColor:0===e?"#fff":"rgba(255,255,255,0.35)"}},e)))}),(0,h.jsxs)(o.Box,{style:{position:"absolute",top:"16px",left:"8px",right:"8px",display:"flex",alignItems:"center"},children:[(0,h.jsx)(o.Avatar,{src:(0,wo.replaceDomainInData)(v),style:{width:"28px",height:"28px",marginRight:"8px",border:"1px solid rgba(255,255,255,0.6)"}}),(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{style:{color:"#fff",fontSize:"12px",fontWeight:600,lineHeight:1.2},children:E||"Page Name"}),(0,h.jsx)(o.Typography,{style:{color:"rgba(255,255,255,0.75)",fontSize:"10px",lineHeight:1.2},children:"Sponsored"})]})]}),m&&(0,h.jsx)(o.Typography,{style:{position:"absolute",bottom:"56px",left:"12px",right:"12px",color:"#fff",fontSize:"12px",whiteSpace:"pre-line",wordBreak:"break-word",textShadow:"0px 1px 2px rgba(0,0,0,0.6)"},children:w}),(0,h.jsx)(o.Box,{style:{position:"absolute",bottom:"14px",left:"12px",right:"12px",display:"flex",justifyContent:"center"},children:(0,h.jsx)(o.Button,{variant:"contained",size:"small",startIcon:(0,h.jsx)(xi.A,{style:{fontSize:"16px"}}),style:{backgroundColor:"#fff",color:"#075E54",borderRadius:"20px",textTransform:"none",fontWeight:600,fontSize:"12px",boxShadow:"0px 2px 4px rgba(0,0,0,0.3)"},children:"Chat on WhatsApp"})})]})})}):(0,h.jsxs)(o.Box,{style:{width:"fit-content"},children:[(0,h.jsx)("a",{href:u,target:"_blank",rel:"noopener noreferrer",style:{cursor:u?"pointer":"default",width:"fit-content",display:"inline-block"},children:(0,h.jsx)(o.Tooltip,{title:u?"Click to see how people will experience your ad":"",placement:"top",children:(0,h.jsxs)(o.Card,{className:t.root,style:{width:"300px",overflow:"hidden"},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",width:"100%",justifyContent:"space-between"},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",margin:"15px 15px 0"},children:[(0,h.jsx)(o.Box,{style:{marginRight:"10px"},children:(0,h.jsx)(o.Avatar,{src:(0,wo.replaceDomainInData)(v)})}),(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"h5",children:E||"Page Name"}),(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginRight:"0.2em"},children:"sponsored"}),(0,h.jsx)(Op.A,{style:{fontSize:"15px"},color:"textSecondary"})]})]})]}),!e.isFromFlowKeyword&&(0,h.jsx)(Bp.A,{style:{margin:"15px 15px 0",fontSize:"18px",display:"flex"},color:"textSecondary"})]}),(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.CardContent,{style:n?{maxHeight:n,overflowX:"auto",padding:"16px",paddingBottom:"8px"}:{padding:"16px",paddingBottom:"8px"},children:(0,h.jsx)(o.Typography,{variant:"h6",align:"left",style:{color:""+(m?"black":"rgb(178 182 178)"),whiteSpace:"pre-line",wordBreak:"break-word"},children:w})}),D?(0,h.jsx)(er,{syncSlideOnCountChange:!0,currentSlide:Math.min(Math.max(l??0,0),S.length-1),arrowsTop:"166px",updateCurrentSlide:c,slides:S.map(((e,t)=>{const a="video"===e.mediaType,n=e.imageUrl?(0,wo.replaceDomainInData)(e.imageUrl):null,o=e.videoUrl?(0,wo.replaceDomainInData)(e.videoUrl):null;return(0,h.jsx)(s().Fragment,{children:M({cardMediaType:a?"VIDEO":"IMAGE",cardImageUrl:n,cardVideoUrl:o,cardThumbnailUrl:n,cardHeadline:e.headline||"Enter Headline",cardDescription:e.description,cardWebsiteUrl:e.websiteUrl,mediaTitle:e.headline||"Card media"})},t)}))}):M({cardMediaType:y,cardImageUrl:L,cardVideoUrl:R,cardThumbnailUrl:A,cardHeadline:N,cardDescription:b,cardWebsiteUrl:r,mediaTitle:("VIDEO"===y?f?.filename:x?.filename)||"Download media"}),!e.isFromFlowKeyword&&(0,h.jsx)(o.Box,{style:{display:"flex",width:"100%"},children:(0,h.jsxs)(o.Box,{style:{display:"flex",width:"100%",margin:"10px",marginTop:"0px",justifyContent:"space-between"},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center"},color:"primary",children:[(0,h.jsx)(Rp.A,{style:{margin:"10px",marginBottom:"0px",marginRight:"0.2em",fontSize:"15px"}}),(0,h.jsx)(o.Typography,{color:"primary",variant:"h5",style:{margin:"10px",marginBottom:"0px",marginLeft:"0px",fontSize:"13px"},gutterBottom:!0,children:"Like"})]}),(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center"},color:"primary",children:[(0,h.jsx)(Lp.A,{style:{margin:"10px",marginBottom:"0px",marginRight:"0.2em",fontSize:"15px",transform:"rotateY(180deg)"}}),(0,h.jsx)(o.Typography,{color:"primary",variant:"h5",style:{margin:"10px",marginBottom:"0px",marginLeft:"0",fontSize:"13px"},gutterBottom:!0,children:"Share"})]})]})})]})]})})}),"website_to_whatsapp"===C?.value&&!e.hideInAppBrowserNote&&(0,h.jsxs)(o.Box,{style:{marginTop:"16px",width:"300px"},children:[(0,h.jsx)(o.Typography,{variant:"body2",style:{fontSize:"12px",color:"rgb(120,120,120)",marginBottom:"8px",lineHeight:1.4},children:"On tap in the Facebook/Instagram mobile app, your website opens with a WhatsApp button (mobile only):"}),(0,h.jsxs)(o.Box,{style:{borderRadius:"4px",overflow:"hidden",backgroundColor:"#fff",boxShadow:"0px 2px 1px -1px rgb(0 0 0 / 20%), 0px 1px 1px 0px rgb(0 0 0 / 14%), 0px 1px 3px 0px rgb(0 0 0 / 12%)"},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",padding:"8px 12px",borderBottom:"1px solid #f0f
10f0"},children:[(0,h.jsx)(o.Typography,{style:{fontSize:"12px",color:"#666"},children:"✕"}),(0,h.jsxs)(o.Box,{style:{flex:1,textAlign:"center"},children:[(0,h.jsx)(o.Typography,{style:{fontSize:"12px",fontWeight:600,color:"#111"},children:r?r.replace(/^https?:\/\//,"").split("/")[0]:"yourwebsite.com"}),(0,h.jsx)(o.Typography,{style:{fontSize:"10px",color:"#999"},children:"Facebook"})]}),(0,h.jsx)(o.Typography,{style:{fontSize:"12px",color:"#666"},children:"⋯"})]}),(0,h.jsx)(o.Box,{style:{height:"80px",backgroundColor:"#fafafa",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,h.jsx)(o.Typography,{style:{fontSize:"11px",color:"#c0c0c0"},children:"Your website"})}),(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",padding:"10px 12px",borderTop:"1px solid #f0f0f0"},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[(0,h.jsxs)(o.Box,{style:{position:"relative",width:"28px",height:"28px",borderRadius:"50%",overflow:"hidden",backgroundColor:"#e8f5ee",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",color:"#109d59",fontWeight:600,flexShrink:0},children:[(E||"P").charAt(0).toUpperCase(),v&&(0,h.jsx)("img",{src:v,alt:"",onError:e=>{e.currentTarget.style.display="none"},style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}})]}),(0,h.jsxs)(o.Box,{style:{minWidth:0},children:[(0,h.jsx)(o.Typography,{style:{fontSize:"12px",fontWeight:600,color:"#111",lineHeight:1.3,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:E||"Your Page"}),T&&(0,h.jsx)(o.Typography,{style:{fontSize:"11px",color:"#888",lineHeight:1.3,whiteSpace:"nowrap"},children:T.startsWith("+")?T:`+${T}`})]})]}),(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",gap:"5px",backgroundColor:"#128C7E",borderRadius:"18px",padding:"6px 12px",flexShrink:0},children:[(0,h.jsx)(xi.A,{style:{color:"#fff",fontSize:"15px"}}),(0,h.jsx)(o.Typography,{style:{fontSize:"12px",fontWeight:600,color:"#fff"},children:"WhatsApp"})]})]})]})]})]})})),Mp=(0,o.withStyles)((e=>({root:{height:"100%",boxShadow:"0px 2px 1px -1px rgb(0 0 0 / 20%), 0px 1px 1px 0px rgb(0 0 0 / 14%), 0px 1px 3px 0px rgb(0 0 0 / 12%)"},media:{maxHeight:600,"object-fit":"contain"},carouselMedia:{width:"100%",height:300,objectFit:"cover",display:"block",backgroundColor:"#000"},statusCard:{position:"relative",width:"270px",aspectRatio:"9 / 16",borderRadius:"12px",overflow:"hidden",backgroundColor:"#000",boxShadow:"0px 2px 1px -1px rgb(0 0 0 / 20%), 0px 1px 1px 0px rgb(0 0 0 / 14%), 0px 1px 3px 0px rgb(0 0 0 / 12%)"},statusMedia:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}})))(Pp),Up=(e,t)=>{const{changeState:a,classes:s,parentState:i}=e,[r,l]=(0,n.useState)(i.selectedCells),[d,c]=(0,n.useState)(null),[p,u]=(0,n.use
1State)(null),[m,g]=(0,n.useState)(!1),[b,y]=(0,n.useState)(!1),[x,f]=(0,n.useState)(new Set);(0,n.useEffect)((()=>{a("selectedCells",r)}),[r]),(0,n.useEffect)((()=>{if(d&&p){const e=new Set(r),[t,n]=[Math.min(d.row,p.row),Math.max(d.row,p.row)],[s,o]=[Math.min(d.col,p.col),Math.max(d.col,p.col)];for(let a=t;a<=n;a++)for(let t=s;t<=o;t++){const n=A(a,t);b&&e.has(n)?e.delete(n):b||e.add(n)}const i=C(e);a("selectedSlotsCount",i)}}),[d,p]),(0,n.useImperativeHandle)(t,(()=>({clearAllSchedule:I})));const A=(e,t)=>`${e}-${t}`,I=()=>{l(new Set)},C=e=>{let t=0;for(let a of e)"7"!==a[0]&&t++;return t},_=(e,t)=>{g(!0),e<=7&&(c({row:e,col:t}),u({row:e,col:t}),y(r.has(A(e,t))),f(new Set(r))),7===e&&(v(t),y(r.has(A(e,t))),c({row:0,col:t}),u({row:6,col:t}))},S=e=>{if(m&&d&&p){for(let t=0;t<7;t++){const[a,n]=[Math.min(d.row,p.row),Math.max(d.row,p.row)],[s,o]=[Math.min(d.col,p.col),Math.max(d.col,p.col)],i=t>=a&&t<=n&&e>=s&&e<=o;if(b&&i)return!1;if(!r.has(A(t,e))&&!i)return!1}return!0}for(let t=0;t<7;t++)if(!r.has(A(t,e)))return!1;return!0},v=e=>{l((t=>{const a=new Set(t),n=S(e);for(let t=0;t<7;t++){const s=A(t,e);n?a.delete(s):a.add(s)}return a}))},E=(e,t)=>{m&&d&&u({row:e,col:t})},T=()=>{if(d&&p){const e=new Set(r),[t,a]=[Math.min(d.row,p.row),Math.max(d.row,p.row)],[n,s]=[Math.min(d.col,p.col),Math.max(d.col,p.col)];for(let o=t;o<=a;o++)for(let t=n;t<=s;t++)if(7===o){for(let a=0;a<7;a++){const n=A(a,t);b?e.delete(n):e.add(n)}b?e.delete(A(7,t)):e.add(A(7,t))}else{const a=A(o,t);b?e.delete(a):e.add(a)}for(let t=0;t<24;t++)Array.from({length:7}).every(((a,n)=>e.has(A(n,t))))?e.add(A(7,t)):e.delete(A(7,t));l(e)}
1g(!1),c(null),u(null),f(new Set)},D=(e,t)=>{l((a=>{const n=A(e,t),s=new Set(a);return s.has(n)?s.delete(n):s.add(n),s}))},w=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"row",gap:"8px"},children:[(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column",paddingTop:"20px",gap:"4px",position:"sticky",left:0,zIndex:1,paddingLeft:"20px",paddingRight:"5px",background:"#F9F9FB"},children:[w.map((e=>(0,h.jsx)("div",{style:{height:"45px",paddingRight:"5px",fontSize:"12px",display:"flex",alignItems:"center",justifyContent:"flex-end",fontFamily:"Inter",fontWeight:600,lineHeight:"100%",fontFamily:"Inter, sans-serif"},children:e},e))),(0,h.jsx)("div",{style:{height:"45px",fontSize:"12px",display:"flex",alignItems:"center",justifyContent:"flex-end",marginTop:"4px",fontFamily:"Inter",fontWeight:600,lineHeight:"100%",fontFamily:"Inter, sans-serif",whiteSpace:"nowrap"},children:"Every day"})]}),(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",gap:"4px"},children:[(0,h.jsx)("div",{style:{display:"flex",gap:"6px",marginBottom:"4px"},children:Array.from({length:8}).map(((e,t)=>{const a=3*t%12||12,n=t>=4?"pm":"am";return(0,h.jsx)("div",{style:{width:"102px",color:"#1c1e21",fontSize:"12px",fontFamily:"Inter",fontWeight:400,lineHeight:"100%",fontFamily:"Inter, sans-serif"},children:`${a} ${n}`},t)}))}),(0,h.jsx)("div",{style:{display:"flex",flexDirection:"column",width:"fit-content",gap:"4px"},onMouseUp:T,onMouseLeave:T,children:Array.from({length:7}).map(((e,t)=>(0,h.jsx)("div",{className:s.outerRow,children:Array.from({length:8}).map(((e,a)=>(0,h.jsx)("div",{className:s.outerCol,children:Array.from({length:3}).map(((e,n)=>{const i=3*a+n;let l=((e,t)=>{if(7===e)return Array.from({length:7}).every(((e,a)=>r.has(A(a,t))));if(!m||!d||!p)return r.has(A(e,t));const[a,n]=[Math.min(d.row,p.row),Math.max(d.row,p.row)],[s,o]=[Math.min(d.col,p.col),Math.max(d.col,p.col)],i=e>=a&&e<=n&&t>=s&&t<=o;return b?!i&&x.has(A(e,t)):!!i||x.has(A(e,t))})(t,i);const c=i%12||12,u=i>=12?"PM":"AM";return(0,h.jsx)(o.Tooltip,{title:`${w[t]}, ${c} ${u}`,placement:"top",children:(0,h.jsx)("div",{className:s.innerCell,style:{backgroundColor:l?"#3C777C":"#E8E8ED"},onMouseDown:()=>_(t,i),onMouseMove:()=>E(t,i)})},n)}))},a)))},t)))}),(0,h.jsx)("div",{className:s.outerRow,onMouseUp:T,style:{marginTop:"8px"},children:Array.from({length:8}).map(((e,t)=>(0,h.jsx)("div",{className:s.outerCol,children:Array.from({length:3}).map(((e,a)=>{const n=3*t+a;let i=S(n);(i&&!r.has(A(7,n))||!i&&r.has(A(7,n)))&&D(7,n);const l=n%12||12,d=n>=12?"PM":"AM";return(0,h.jsx)(o.Tooltip,{title:`Every day, ${l} ${d}`,placement:"top",children:(0,h.jsx)("div",{className:s.innerCell,style:{backgroundColor:i?"#3C777C":"#E8E8ED"},onMouseDown:()=>_(7,n),onMouseMove:()=>E(7,n)})},a)}))},t)))})]})]})},Fp=(0,n.forwardRef)(Up);class Wp extends n.Component{constructor(e){super(e),this.state={currency:this.props?.adAccountData?.currency||"INR",templatedialogOpen:!1,isBudgetDropdownOpen:!1},this.schedulerRef=s().createRef()}componentDidMount(){const e=this.getSelectedSlotsCount();this.setState({selectedCount:e})}isEditAd=(()=>window.location.pathname.includes("edit")&&this.props.parentState.isLiveAD)();timezoneOptions=[{label:"Use Viewer's time zone",value:"viewer"},{label:"Use this ad account's time zone",value:"ad_account"}];budgetOptions=[{label:"Lifetime Budget",value:"lifetime_budget"},{label:"Daily Budget",value:"daily_budget"}];isDuplicateAd=(()=>window.location.pathname.includes("duplicate"))();isCreateAdPage=(()=>window.location.pathname.includes("create"))();toggleTemplateCreditDialog=()=>{this.setState({templatedialogOpen:!this.state.templatedialogOpen})};toggleScheduledAd=()=>{"lifetime_budget"===this.props.parentState.selectedBudget.value&&this.props.changeState("isScheduledAd",!this.props.parentState.isScheduledAd)};getMinToDate=()=>{const{parentState:e}=this.props,t=e.adStatus,a=Zr()().startOf("day"),n=Zr()().startOf("day").add(1,"days"),s=Zr()(e.fromDate).startOf("day"),o=Zr()(e.toDate).startOf("day");Zr()(e.adjusttedOriginalEndDate).startOf("day");if(this.isCreateAdPage)return Zr()(e.fromDate).add(2,"days").toDate();if("DRAFT"===t)return a.isAfter(s)&&a.diff(o,"days")<=2?Zr()(a).add(2,"days").toDate():Zr()(s).add(2,"days").toDate();if(o.diff(s,"days")<=2)return Zr()(e.fromDate).add(2,"days").toDate();const i=s.add(2,"days").startOf("day");return i.isBefore(n)?n.toDate():i.toDate()};hasInSufficientCredits=()=>{const{selectedBudget:e,dailyBudget:t,duration:a}=this.props.parentState,{assistantDetails:n,adAccountData:s}=this.props,{currency:o,metaAdsCredit:i}=n||{},{currency:r}=s||{},l="INR"===(n?.adSetupDetails?.selectedMetaAdAccountId==s?.accountId?o:r)?250:5;return"daily_budget"===e.value?t&&+i-2*t<0:+i-l*a<0};getMinBudget=()=>{const{selectedBudget:e}=this.props.parentState,{assistantDetails:t,adAccountData:a}=this.props,{currency:n}=t||{},{currency:s}=a||{},o="INR"===(t?.adSetupDetails?.selectedMetaAdAccountId==a?.accountId?n:s);return"lifetime_budget"===e?.value?o?2500:25:o?250:5};isBudgetBelowMinimum=()=>{const{selectedBudget:e,dailyBudget:t,lifetimeBudget:a}=this.props.parentState,n="lifetime_budget"===e?.value?a:t;return Boolean(n)&&+n<this.getMinBudget()};CheckIcon=()=>(0,h.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,h.jsx)("circle",{cx:"8",cy:"8",r:"8",f
1ill:"#48465D"}),(0,h.jsx)("rect",{width:"9.14286",height:"9.14286",transform:"translate(3.42969 3.42871)",fill:"#48465D"}),(0,h.jsx)("path",{d:"M11.1823 5.72716C11.1383 5.68272 11.0858 5.64745 11.0281 5.62338C10.9703 5.59931 10.9083 5.58691 10.8457 5.58691C10.7831 5.58691 10.7212 5.59931 10.6634 5.62338C10.6056 5.64745 10.5532 5.68272 10.5091 5.72716L6.97697 9.26403L5.493 7.77532C5.44724 7.73111 5.39322 7.69635 5.33402 7.67302C5.27483 7.6497 5.21162 7.63826 5.148 7.63936C5.08438 7.64046 5.02161 7.65408 4.96325 7.67944C4.9049 7.7048 4.85211 7.74141 4.80791 7.78717C4.7637 7.83293 4.72894 7.88695 4.70562 7.94615C4.68229 8.00534 4.67085 8.06855 4.67195 8.13217C4.67305 8.19579 4.68667 8.25856 4.71203 8.31692C4.73739 8.37527 4.774 8.42806 4.81976 8.47226L6.64035 10.2928C6.68442 10.3373 6.73686 10.3726 6.79464 10.3966C6.85241 10.4207 6.91438 10.4331 6.97697 10.4331C7.03956 10.4331 7.10153 10.4207 7.1593 10.3966C7.21708 10.3726 7.26951 10.3373 7.31359 10.2928L11.1823 6.4241C11.2305 6.3797 11.2689 6.32582 11.2951 6.26584C11.3214 6.20587 11.335 6.1411 11.335 6.07563C11.335 6.01015 11.3214 5.94539 11.2951 5.88541C11.2689 5.82544 11.2305 5.77155 11.1823 5.72716Z",fill:"white"})]});getSelectedSlotsCount=()=>{let e=0;for(let t of this.props.parentState.selectedCells)"7"!==t[0]&&e++;return e};validateTimeSlotsAgainstDateRange(){const e=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],t=this.props.parentState.adAccountData?.timezone,{fromDate:a,toDate:n,selectedCells:s,startDateError:o,endDateError:i}=this.props.parentState;if(o)return{invalidSlots:[""],message:"Invalid Ad Start Date"};if(i)return{invalidSlots:[""],message:"Invalid Ad End Date"};if(!n)return{invalidSlots:[]};const r=new Set;let l=Zr().tz(a,t).startOf("day");const d=Zr().tz(n,t).endOf("day");if(d.diff(l,"days")>=6)return{invalidSlots:[]};for(;l.isSameOrBefore(d);)r.add(l.day()),l.add(1,"day");const c=[],p=new Set;for(const e of s){const[t]=e.split("-");if("7"===t)continue;const a=parseInt(t,10);r.has(a)||(c.push(e),p.add(a))}if(c.length>0){const n=[...p].map((t=>e[t])).join(", "),s=[];for(l=Zr().tz(a,t);l.isSameOrBefore(d);)s.push(e[l.day()]),l.add(1,"day");const o=[...new Set(s)];return{invalidSlots:c,message:`You have scheduled this ad set to run on ${n}. But the selected date range only includes ${1===o.length?o[0]:`${o[0]} to ${o[o.length-1]}`}. Please change your date range or schedule.`}}return{invalidSlots:[]}}render(){const{classes:e,assistantDetails:t,adAccountData:a,agent:s,parentState:i,isLiveAD:r}=this.props,{power:l}=s,{currency:d}=a||{},{metaAdsCredit:c,ongoingBillingProcess:p,cbpType:u,allowPurchase:m,pendingInvoices:g,partnerId:b,currency:y}=t||{},x=t?.adSetupDetails?.selectedMetaAdAccountId==a?.accountId?y:d,{dailyBudget:f,lifetimeBudget:A,duration:I,isEndDate:C,toDate:_,fromDate:S,keyThird:v,selectedBudget:E,isScheduledAd:T,originalDuration:D,adEffectiveStatus:w}=i,{invalidSlots:N,message:j}=this.validateTimeSlotsAgainstDateRange();return(0,h.jsxs)(o.Grid,{container:!0,style:{display:"flex"},children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,md:12,style:{display:"flex",flexDirection:"column",justifyContent:"center",marginBottom:"20px"},children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,style:{marginBottom:"2em"},children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Select per day budget"}),(0,h.jsx)(o.Box,{position:"relative",children:(0,h.jsx)(O.Autocomplete,{disableClearable:!0,options:this.budgetOptions,onOpen:()=>{this.isEditAd||this.setState({isBudgetDropdownOpen:!0})},onClose:()=>{this.setState({isBudgetDropdownOpen:!1})},open:this.state.isBudgetDropdownOpen,onChange:(e,t)=>
1{"daily_budget"===t.value&&(this.props.changeState("isScheduledAd",!1),f||this.props.changeState("dailyBudget","INR"===x?500:5)),"lifetime_budget"===t.value&&(this.props.changeState("isEndDate",!0),A||this.props.changeState("lifetimeBudget","INR"===x?2500:25)),this.props.changeState("selectedBudget",t)},getOptionLabel:e=>e?.label?e.label:"",value:this.props.parentState.selectedBudget,name:"budgetType",renderInput:t=>(0,h.jsx)(o.TextField,{...t,placeholder:"Type",variant:"outlined",classes:{root:e.codeTextFieldRoot},style:{width:"150px",paddingLeft:"10px",backgroundColor:"#E9E9E9",paddingTop:"1px",borderTopRightRadius:0,borderBottomRightRadius:0,paddingRight:"5px",'& [class*="MuiAutocomplete-popupIndicator"]':{borderRadius:"4px"}},InputProps:{...t.InputProps,endAdornment:this.isEditAd?null:t.InputProps.endAdornment},value:this.props.parentState.selectedBudget?.label})})}),(0,h.jsx)(o.TextField,{variant:"outlined",classes:{root:e.TextFieldRoot},style:{paddingLeft:"80px"},onChange:e=>{let t=e.target.value;""!==t?(t=t.replace(/[^0-9]/g,""),t=t.replace(/^0+(?=\d)/,""),"lifetime_budget"===E?.value?this.props.changeState("lifetimeBudget",t):this.props.changeState("dailyBudget",t)):"lifetime_budget"===E?.value?this.props.changeState("lifetimeBudget",t):this.props.changeState("dailyBudget",t)},error:this.isBudgetBelowMinimum(),value:"lifetime_budget"===E?.value?A||"":f||"",placeholder:"lifetime_budget"===E?.value?"USD"===x?"$25":"₹2500":"USD"===x?"$5":"₹500",name:"budget",type:"number"}),this.isBudgetBelowMinimum()&&(0,h.jsx)(o.Typography,{variant:"body2",style:{color:"#f44336",marginTop:"6px"},children:`Minimum ${"lifetime_budget"===E?.value?"lifetime":"daily"} budget is ${"USD"===x?"$":"₹"}${this.getMinBudget().toLocaleString()}`})]}),(0,h.jsxs)(o.Grid,{item:!0,xs:12,children:[(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,children:"Select Advertisement Duration"}),(0,h.jsx)(o.Grid,{style:{display:"flex",flexDirection:"column",marginTop:"0.6em",marginBottom:"30px"},children:(0,h.jsxs)(o.Grid,{container:!0,spacing:2,style:{display:"flex"},children:[(0,h.jsx)(Bi.MuiPickersUtilsProvider,{utils:Ri.A,children:(0,h.jsxs)(o.Grid,{item:!0,xs:12,md:6,children:[(0,h.jsx)(o.Grid,{style:{display:"flex",alignItems:"center",height:"42px"},children:(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,style:{color:"#000000",marginTop:"8px"},children:"Select Start Date"})}),(0,h.jsx)(Bi.KeyboardDatePicker,{style:{marginTop:"0px",width:"100%"},className:e.paddingControl,disableToolbar:!0,minDate:r&&!this.isDuplicateAd?S:new Date,minDateMessage:"The date cannot be earlier than today",maxDate:new Date((new Date).setDate((new Date).getDate()+60)),format:"dd/MM/yyyy",margin:"normal",id:"date-picker-inline",disabled:r&&!this.isDuplicateAd,value:S,onChange:this.props.handleFromDateChange,KeyboardButtonProps:{"aria-label":"change date"},onError:e=>{this.props.parentState.startDateError!==e&&this.props.changeState("startDateError",e)}}),r&&!this.isDuplicateAd&&(0,h.jsx)(o.Typography,{variant:"body2",gutterBottom:!0,className:e.helperText,children:"You cannot edit the start date of published AD"})]})}),(0,h.jsx)(Bi.MuiPickersUtilsProvider,{utils:Ri.A,children:(0,h.jsxs)(o.Grid,{item:!0,xs:12,md:6,children:[(0,h.jsxs)(o.Grid,{style:{display:"flex",alignItems:"center",height:"42px"},children:["daily_budget"===E.value&&(0,h.jsx)(o.Checkbox,{color:"primary",style:{paddingLeft:0},checked:C,onChange:(e,t)=>
1{this.props.changeState("isEndDate",t)}}),"daily_budget"===E.value&&(0,h.jsx)(o.Typography,{variant:"h5",gutterBottom:!0,style:{color:"#000000",marginTop:"8px"},children:"Select End Date"})]}),C&&(0,h.jsx)(Bi.KeyboardDatePicker,{style:{marginTop:"0px",width:"100%"},className:e.paddingControl,disableToolbar:!0,minDate:this.getMinToDate(),minDateMessage:`The date cannot be earlier than ${Zr()(this.getMinToDate()).format("DD/MM/YYYY")}`,format:"dd/MM/yyyy",margin:"normal",id:"date-picker-inline",value:_,onError:e=>{this.props.parentState.endDateError!==e&&this.props.changeState("endDateError",e)},onChange:this.props.handleToDateChange,KeyboardButtonProps:{"aria-label":"change date"}})]})})]})})]}),(0,h.jsx)(o.Grid,{item:!0,xs:12,children:(0,h.jsxs)(o.Box,{style:{display:"flex",flexDirection:"column"},children:[(0,h.jsxs)(o.Box,{style:{backgroundColor:"#F0F0F0",paddingLeft:"20px",borderRadius:"8px",borderTopRightRadius:"12px",borderBottomRightRadius:"12px",display:"flex",alignItems:"center",gap:"16px",marginBottom:"10px",justifyContent:"space-between",height:"60px",boxSizing:"border-box"},children:[(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"16px"},children:[(0,h.jsx)(o.Tooltip,{title:"lifetime_budget"!==E.value?"Ad scheduling is only available when you use lifetime budget":"",placement:"top",children:(0,h.jsx)("span",{style:{display:"inline-flex"},children:(0,h.jsx)(Hp,{checked:T,onChange:this.toggleScheduledAd})})}),(0,h.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",flexDirection:"column",justifyContent:"center",gap:"4px"},children:[(0,h.jsx)(o.Typography,{style:{fontFamily:"Inter",fontWeight:500,fontSize:"14px",lineHeight:"140%",color:"#24232F",letterSpacing:0},children:"Run Ads on a Custom Schedule"}),(0,h.jsx)(o.Typography,{style:{fontFamily:"Inter",fontWeight:400,fontSize:"10px",lineHeight:"100%",letterSpacing:0,color:"#48465D"},children:"Select when your ads should run during the week. Click and drag to select time blocks."})]})]}),(0,h.jsx)(o.Tooltip,{title:"lifetime_budget"!==E?.value?"Ad scheduling is only available when you use lifetime budget":"",placement:"top",children:(0,h.jsx)(O.Autocomplete,{className:e.displayNone_1200,value:this.props.parentState.selectedTimezone,onChange:(e,t)=>
1{this.props.changeState("selectedTimezone",t)},disabled:"lifetime_budget"!==E.value,options:this.timezoneOptions,getOptionLabel:e=>e.label,popupIcon:(0,h.jsx)(Vp,{}),disableClearable:!0,style:{height:"100%"},PopperComponent:Gp,ListboxProps:{style:{padding:0,margin:0},className:e.noHoverBg},renderInput:e=>(0,h.jsx)(o.TextField,{...e,variant:"outlined",InputProps:{...e.InputProps,style:{height:"100%",fontSize:"14px",fontWeight:500,lineHeight:"140%",fontFamily:"Inter",color:"#48465D"}},style:{width:"250px",height:"100%",paddingTop:0,paddingBottom:0,background:"#E9E9E9",borderBottomLeftRadius:0,borderTopLeftRadius:0,paddingRight:0,paddingLeft:"5.5px",'& [class*="MuiOutlinedInput-root"]':{"& fieldset":{border:"none"},"&:hover fieldset":{border:"none"},"&.Mui-focused fieldset":{border:"none"},height:"100%",borderRadius:"0px"},'& [class*="MuiInputBase-input"]':{height:"100%",padding:"8px"}}}),renderOption:(e,t)=>(console.log(t,e),(0,n.createElement)(o.Box,{component:"li",...e,key:e.value,style:{display:"flex",alignItems:"center",padding:0,height:"36px",margin:0,width:"400px"}},(0,h.jsx)(o.Radio,{checked:this.props.parentState.selectedTimezone.value===e.value,color:"primary",value:this.props.parentState.selectedTimezone,tabIndex:-1,size:"small",style:{marginRight:"8px",marginTop:0,padding:0}}),(0,h.jsx)(o.Typography,{style:{padding:0,margin:0},children:e.label})))})})]}),T&&(0,h.jsx)(O.Autocomplete,{className:e.display_1200,disableClearable:!0,autoHighlight:!0,options:this.timezoneOptions,getOptionLabel:e=>e.label,onChange:(e,t)=>
1{this.props.changeState("selectedTimezone",t)},value:this.props.parentState.selectedTimezone,renderInput:t=>(0,h.jsx)(o.TextField,{...t,variant:"outlined",classes:{root:e.textFieldRoot},InputProps:{...t.InputProps},placeholder:"Select Timezone",name:"timezone",value:this.props.parentState.selectedTimezone?.label}),classes:{inputRoot:e.inputRoot}}),T&&(0,h.jsx)(o.Box,{style:{display:"flex",flexDirection:"column"},children:(0,h.jsx)(o.Box,{className:e.schedulerOuterDiv,children:(0,h.jsx)(o.Box,{className:e.schedulerInnerDiv,style:{display:"flex"},children:(0,h.jsx)(Fp,{parentState:this.props.parentState,changeState:this.props.changeState,classes:e,ref:this.schedulerRef})})})})]})}),(0,h.jsx)(o.Grid,{item:!0,xs:12,style:{marginTop:"19px"},children:(0,h.jsxs)(o.Box,{className:e.adBudgetFooter,children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"flex-start",flexDirection:"column"},children:[(0,h.jsx)(o.Typography,{variant:"h5",children:`${C?"Total Estimated":"Daily"} Budget : ${"USD"===x?"$":"₹"} ${("daily_budget"===E.value?C?f*I||0:f||0:A||0).toLocaleString()}`}),C&&(0,h.jsxs)(o.Typography,{variant:"body2",gutterBottom:!0,className:e.helperText,style:{marginBottom:"0"},children:["Estimated Budget From"," ",Zr()(S).isBefore(Zr()())?Zr()().format("DD/MM/YYYY"):Zr()(S).format("DD/MM/YYYY")," ","to ",Zr()(_).format("DD/MM/YYYY")]})]}),T&&(0,h.jsxs)(o.Box,{className:e.timeSlotCountDiv,children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center"},children:[(0,h.jsx)(this.CheckIcon,{}),(0,h.jsxs)(o.Typography,{style:{fontFamily:"Inter",fontWeight:500,fontSize:"14px",lineHeight:"140%",marginLeft:"8px",color:"#24232F"},children:[this.props.parentState.selectedSlotsCount," Time slots selected"]})]}),(0,h.jsx)(o.Typography,{style:{fontFamily:"Inter",fontWeight:600,fontSize:"16px",lineHeight:"140%",color:"#0A474C",marginLeft:"25px",cursor:"pointer"},onClick:()=>{this.props.changeState("selectedCells",new Set),this.props.changeState("selectedSlotsCount",0),this.schedulerRef.current?.clearAllSchedule()},children:"Clear All"})]})]})}),"lifetime_budget"===this.props.parentState?.selectedBudget.value&&T&&N.length>0&&(0,h.jsxs)(o.Grid,{item:!0,xs:12,style:{marginTop:"20px",backgroundColor:"#FFE5E6",color:"#EC0004",display:"flex",padding:"20px",paddingLeft:"24px",gap:"8px",borderRadius:"8px",alignItems:"flex-start"},children:[(0,h.jsx)(zp,{}),(0,h.jsx)(o.Typography,{style:{fontFamily:"Inter",fontWeight:500,fontSize:"14px",lineHeight:"140%",marginTop:"-2px"},children:j})]}),(0,h.jsxs)(o.Box,{style:{gap:"10px",display:"flex",flexDirection:"column",marginTop:"20px"},children:[this.hasInSufficientCredits()&&"You don't have sufficient credit to run this ad. Add more credit to run this ad",this.hasInSufficientCredits()&&l>=2&&!b&&("ENTERPRISE"!==u||m)&&(0,h.jsx)(o.Button,{onClick:()=>{this.toggleTemplateCreditDialog()},variant:"outlined",color:"primary",style:{padding:"4px 10px",fontSize:"0.8125rem"},children:"Buy Credits"})]})]}),(0,h.jsx)(B,{name:"metaAdsCreditDialog",dialogOpen:this.state.templatedialogOpen,toggleTemplateCreditDialog:this.toggleTemplateCreditDialog,assistantDetails:this.props.assistantDetails})]},v)}}const zp=()=>(0,h.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,h.jsx)("g",{"clip-path":"url(#clip0_652_5104)",children:(0,h.jsx)("path",{d:"M8 16C12.418 16 16 12.418 16 8C16 3.582 12.418 0 8 0C3.582 0 0 3.582 0 8C0 12.418 3.582 16 8 16ZM9 9C9 9.26522 8.89464 9.51957 8.70711 9.70711C8.51957 9.89464 8.26522 10 8 10C7.73478 10 7.48043 9.89464 7.29289 9.70711C7.10536 9.51957 7 9.26522 7 9V4C7 3.73478 7.10536 3.48043 7.29289 3.29289C7.48043 3.10536 7.73478 3 8 3C8.26522 3 8.51957 3.10536 8.70711 3.29289C8.89464 3.48043 9 3.73478 9 4V9ZM8 10.984C8.13135 10.984 8.26142 11.0099 8.38276 11.0602C8.5041 11.1105 8.61435 11.1842 8.70721 11.2771C8.80007 11.37 8.87372 11.4803 8.92396 11.6017C8.97419 11.7231 9.00003 11.8531 9 11.9845C8.99997 12.1159 8.97406 12.2459 8.92377 12.3673C8.87347 12.4886 8.79976 12.5989 8.70686 12.6917C8.61395 12.7846 8.50367 12.8582 8.3823 12.9085C8.26093 12.9587 8.13085 12.9845 7.9995 12.9845C7.73422 12.9844 7.47983 12.879 7.29229 12.6914C7.10475 12.5037 6.99943 12.2493 6.9995 11.984C6.99957 11.7187 7.10501 11.4643 7.29264 11.2768C7.48027 11.0893 7.73472 10.9839 8 10.984Z",fill:"#EC0004"})}),(0,h.jsx)("defs",{children:(0,h.jsx)("clipPath",{id:"clip0_652_5104",children:(0,h.jsx)("rect",{width:"16",height:"16",fill:"white"})})})]});function Gp(e){return(0,h.jsx)(o.Popper,{...e,style:{width:398,zIndex:1300},placement:"bottom-end"})}const Hp=(0,o.withStyles)((e=>
1({root:{width:42,height:26,padding:0},switchBase:{padding:0,margin:2,transitionDuration:"300ms","&$checked":{transform:"translateX(16px)",color:"#fff","& + $track":{backgroundColor:"#65C466",opacity:1,border:0},"&$disabled + $track":{backgroundColor:"#B5E0B5",opacity:.5}},"&$focusVisible $thumb":{color:"#33cf4d",border:"6px solid #fff"},"&$disabled $thumb":{color:e.palette.grey[300]},"&$disabled + $track":{backgroundColor:e.palette.grey[300],opacity:1}},thumb:{boxSizing:"border-box",width:22,height:22},track:{borderRadius:13,backgroundColor:"#78788029",opacity:1,transition:e.transitions.create(["background-color"],{duration:500})},checked:{},disabled:{},focusVisible:{}})))((e=>{let{classes:t,...a}=e;return(0,h.jsx)(o.Switch,{focusVisibleClassName:t.focusVisible,disableRipple:!0,classes:{root:t.root,switchBase:t.switchBase,thumb:t.thumb,track:t.track,checked:t.checked,disabled:t.disabled},...a})}));function Vp(e){return(0,h.jsx)(o.SvgIcon,{...e,viewBox:"0 0 25 24",children:(0,h.jsx)("path",{d:"M17.4662 9.51758L12.5007 14.4831L7.53516 9.51758",stroke:"#48465D",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})}const Yp=(0,i.connect)((e=>({assistantDetails:e.assistantDetails.data,agent:e.login.user})),{})(Wp),Zp=(0,o.withStyles)((e=>({root:{width:"100%",padding:"20px 10px"},bottomMargin:{marginBottom:e.spacing(4)},filterTypeContainer:{borderRadius:"5px",minHeight:100},inputPadding:{padding:"12px 10px"},inputRoot:{'&[class*="MuiOutlinedInput-root"][class*=MuiAutocomplete-input]':{padding:12},'&&[class*="MuiOutlinedInput-root"]':{padding:0}},snackbar:{zIndex:5e3},codeTextFieldRoot:{width:"60px",height:"43px",padding:"0 0 0 30px",position:"absolute",zIndex:1,margin:"5px 0 0 0px",'& .MuiAutocomplete-popupIndicator, & [class*="MuiAutocomplete-popupIndicator-"]':{backgroundColor:"#E9E9E9",borderTopRightRadius:0,borderBottomRightRadius:0,"&:hover":{backgroundColor:"#E9E9E9"}},"& input":{padding:"12px 0 !important"},"& button":{width:"12px",position:"relative",left:"7px",background:"rgb(240,240,240)",borderRadius:0,"&:hover":{background:"rgb(240,240,240)"}},"& div":{paddingRight:"0px !important"}},ad:{display:"flex",marginTop:"1.35em",marginBottom:"2em",justifyContent:"center",[e.breakpoints.up("md")]:{minWidth:"315px"}},TextFieldRoot:{width:"100%",padding:"2px 20px",marginTop:"4px","& input":{width:"calc(100% - 80px)",marginLeft:"80px"},background:"rgb(240,240,240)"},paddingControl:{'& .MuiIconButton-root, & [class*="MuiIconButton-root-"]':{padding:0},'& .MuiFormHelperText-root, & [class*="MuiFormHelperText-root-"]':{position:"absolute !important",top:"42px !important"}},helperText:{color:"#000000",fontSize:"11px",marginBottom:"30px"},inputRoot:{'&[class*="MuiOutlinedInput-root"][class*=MuiAutocomplete-input]':{padding:12},'&&[class*="MuiOutlinedInput-root"]':{padding:0},'&[class*="MuiOutlinedInput-root"][class*=MuiAutocomplete-inputRoot]':{paddingRight:"0 !important",paddingLeft:"0 !important"}},textFieldRoot:{backgroundColor:"rgb(240,240,240)",outline:"none",border:"none",borderRadius:"8px",width:"100%",padding:"0",boxShadow:"none",boxSizing:"border-box",fontFamily:"Roboto, sans-serif",fontSize:"15px",fontWeight:500,maxHeight:"12em",overflow:"auto","&::-webkit-scrollbar":{width:"4px"}},outerRow:{display:"flex",gap:"6px","&:last-child":{borderBottom:"none"}},outerCol:{display:"flex",height:"45px",width:"102px",justifyContent:"space-between",position:"relative",gap:"6px",boxSizing:"border-box"},innerCell:{height:"100%",width:"100%",background:"#eaf4fe",display:"flex",justifyContent:"space-between",alignItems:"center",position:"relative",borderRadius:"4px",boxSizing:"border-box","&:hover":{background:"#9cd5e5"}},indicator:{position:"absolute",width:"3px",height:"100%",backgroundColor:"#39afd5",borderRadius:"3px"},schedulerOuterDiv:{backgroundColor:"#F9F9FB",marginTop:"16px",borderRadius:"12px",overflowX:"hidden",paddingTop:"20px",paddingBottom:"20px",paddingRight:"20px",[e.breakpoints.down(1600)]:{overflowX:"scroll"}},schedulerInnerDiv:{maxWidth:"100%",justifyContent:"center",[e.breakpoints.down(1600)]:{maxWidth:"52vw",justifyContent:"normal"},[e.breakpoints.down(1300)]:{maxWidth:"43vw",justifyContent:"normal"}},displayNone_1200:{display:"flex",[e.breakpoints.down(1200)]:{display:"none"}},display_1200:{display:"none",[e.breakpoints.down(1200)]:{display:"flex"}},adBudgetFooter:{display:"flex",justifyContent:"space-between",alignItems:"center",flexDirection:"row",width:"100%",flexWrap:"wrap-reverse"}
1,timeSlotCountDiv:{display:"flex",alignItems:"center",justifyContent:"flex-end",[e.breakpoints.down(1100)]:{justifyContent:"space-between",width:"100%",marginBottom:"20px"}},noHoverBg:{"& [class*=MuiAutocomplete-option][aria-selected='true']":{backgroundColor:"transparent !important"}}})))(Yp),Kp={CONVERSATIONS:"Conversations",LEAD_GENERATION:"Leads",QUALITY_LEAD:"Leads",LINK_CLICKS:"Link Clicks",LANDING_PAGE_VIEWS:"Landing Page Views",OFFSITE_CONVERSIONS:"Conversions",POST_ENGAGEMENT:"Post Engagements",IMPRESSIONS:"Impressions",REACH:"Reach"};function Jp(e){let{adCaption:t,adHeadline:a,assistantDetails:n,currency:s,imageFile:i,thumbnailUrl:r,uploadType:l,videoFile:c,classes:p,adHeadlineDescription:u,adType:m,ctaButton:g,estimatedDailyResults:b,estimatedData:y,estimatedReachLoading:x,showPreview:f,websiteUrl:A,pageDetails:I,formatCompactCount:C,formatNumber:_,getEstimatedDeliveryUsers:S,adFormat:v,cards:E,activeCardIndex:T,onActiveCardChange:D}=e;return(0,h.jsx)(o.Grid,{style:{position:"sticky",top:"100px",alignSelf:"flex-start"},children:(0,h.jsxs)(o.Grid,{item:!0,xs:!0,style:{marginBottom:"160px",justifyContent:"center",width:"100%",display:"grid"},children:[(window.innerWidth>700||window.innerWidth<=700&&f)&&(0,h.jsx)(Mp,{ctaButton:g,websiteUrl:A,activeCardIndex:T,onActiveCardChange:D,payload:{adCaption:t,adHeadline:a,adHeadlineDescription:u,imageFile:i,videoFile:c,mediaType:"IMAGE_UPLOAD"===l?"IMAGE":"VIDEO",pageDetails:I,thumbnailUrl:r?.publicUrl||("string"==typeof r?r:""),adType:m,ctaButton:g,adFormat:v,cards:E},maxHeight:"800px"}),(0,h.jsx)(h.Fragment,{children:window.innerWidth>700||window.innerWidth<=700&&f?(0,h.jsx)(o.Grid,{style:{width:"310px",marginTop:"24px",background:"white",boxShadow:"0 0 11px rgb(230,230,230)",borderRadius:"8px"},children:(0,h.jsxs)(o.Box,{style:{padding:"8px 16px"},children:[(0,h.jsx)(o.Typography,{children:"Estimated reach"}),(0,h.jsx)(o.Box,{style:{display:"flex",justifyContent:"center",padding:"16px 0px"},children:x?(0,h.jsx)(o.CircularProgress,{size:28}):y?.estimate_mau_lower_bound||y?.estimate_mau_upper_bound?(0,h.jsx)(o.Typography,{variant:"h3",component:"div",children:_(((y?.estimate_mau_lower_bound||0)+(y?.estimate_mau_upper_bound||0))/2,n?.currency)}):(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",width:"100%"},children:[(0,h.jsx)(o.Typography,{variant:"h4",children:"Unable To Fetch"}),(0,h.jsx)(d.Replay,{onClick:()=>S(),style:{cursor:"pointer"}})]})}),!x&&b&&(0,h.jsxs)(o.Box,{style:{borderTop:"1px solid #eeeeee",padding:"8px 0px",marginBottom:"8px"},children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:"6px"},children:"Estimated daily results"}),[{label:"Reach",value:b.reach},{label:"Impressions",value:b.impressions},{label:Kp[b.optimizationGoal]||"Results",value:b.actions}].map((e=>(0,h.jsxs)(o.Box,{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"2px 0px"},children:[(0,h.jsx)(o.Typography,{variant:"body2",children:e.label}),(0,h.jsx)(o.Typography,{variant:"body2",style:{fontWeight:600},children:C(e.value)})]},e.label)))]}),(0,h.jsx)(o.Typography,{variant:"h6",color:"textSecondary",style:{fontSize:"11px"},children:"The accuracy of these estimates relies on factors like past campaign data, budget, market data, targeting, and ad placements. They provide an idea of potential performance but do not guarantee results."})]})}):(0,h.jsx)(h.Fragment,{})})]})})}function $p(e){let{classes:t,mobileScreen:a,adId:n,isDuplicateAd:s,assistantDetails:i,onBack:r,onShowCredit:l}=e;return(0,h.jsxs)(o.Grid,{container:!0,justify:"center",alignItems:"center",className:`${t.pageTitleContainer} ${t.fullWidth}  ginger-page-header`,children:[(0,h.jsx)(o.Grid,{item:!0,children:(0,h.jsx)(o.Box,{children:(0,h.jsx)(o.IconButton,{style:{padding:0,marginRight:"0.5em",paddingBottom:a?"10px":"0"},component:o.Link,onClick:()=>{r()},children:(0,h.jsx)(d.ArrowBack,{})})})}),(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsxs)(o.Typography,{variant:"h3",style:{whiteSpace:"nowrap",marginRight:"0.5em",paddingBottom:a?"10px":"0"},children:[n?s?"Duplicate ":"Edit ":"Create New "," ","Ad"]})}),(0,h.jsx)(o.Box,{style:{display:"flex",width:a?"100%":"auto"},children:(0,h.jsxs)(o.Typography,{onClick:l,variant:"h4",style:{marginRight:"1em",curs
1or:"pointer"},children:["Remaining Ad Credit:"," ","USD"===i.currency?"$":"₹"," ",(i.metaAdsCredit||0).toFixed(2)]})}),(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",children:(0,h.jsx)(B,{name:"gingerLauncher"})})]})}function qp(e){let{classes:t,snack:a,snackStatus:n,snackMessage:s,setState:i}=e;return(0,h.jsx)(o.Snackbar,{className:t.snackbar,open:a,onClose:()=>{i({snack:!1})},anchorOrigin:{vertical:"top",horizontal:"center"},autoHideDuration:3e3,children:(0,h.jsx)(O.Alert,{severity:n,onClose:()=>{i({snack:!1})},children:s})})}function Xp(e){let{errorAction:t,history:a,onClose:n}=e;return(0,h.jsx)(h.Fragment,{children:!(0,ts.isEmpty)(t)&&(0,h.jsxs)(o.Dialog,{open:!(0,ts.isEmpty)(t),onClose:n,maxWidth:"sm",children:[(0,h.jsx)(o.DialogTitle,{children:(0,h.jsx)(o.Typography,{variant:"h3",children:"Action Required"})}),(0,h.jsx)(o.DialogContent,{children:(0,h.jsx)(o.DialogContentText,{style:{color:"rgb(0,0,0,0.87)"},children:t.name})}),(0,h.jsxs)(o.DialogActions,{style:{padding:"16px 24px"},children:[(0,h.jsx)(o.Button,{variant:"outlined",onClick:n,children:"Close"}),t.isInternalLink?(0,h.jsx)(o.Button,{color:"primary",variant:"contained",onClick:()=>{n(),a.push(t.link)},children:"Reconnect Meta"}):(0,h.jsx)(o.Button,{color:"primary",variant:"contained",href:t.link,target:"_blank",rel:"noopener noreferrer",endIcon:(0,h.jsx)(d.OpenInNew,{}),children:"Open Link"})]})]})})}function Qp(e){let{classes:t,projectId:a,history:n,showDialog:s,isLoading:i,onClose:r,onSaveDraft:l,exitPath:c}=e;return(0,h.jsxs)(o.Dialog,{open:s,onClose:r,maxWidth:"xs",children:[(0,h.jsxs)(o.Box,{className:t.dialogWrapper,children:[(0,h.jsx)(o.DialogTitle,{className:t.dialogTitle,children:(0,h.jsx)(o.Typography,{variant:"h3",children:"Discard Ad"})}),(0,h.jsx)(d.Clear,{className:t.icon,onClick:r})]}),(0,h.jsx)(o.DialogContent,{children:(0,h.jsx)(o.DialogContentText,{style:{color:"rgb(0,0,0,0.67)",fontSize:"16px",fontWeight:"500"},children:"If you discard this ad then all changes made by you will be lost. You can also save this ad as a draft and modify it at a later point."})}),(0,h.jsxs)(o.DialogActions,{style:{paddingBottom:"16px",paddingRight:"24px"},children:[(0,h.jsx)(o.Button,{variant:"outlined",onClick:()=>{r(),n.push(c())},children:"Discard ad"}),(0,h.jsx)(o.Button,{color:"primary",variant:"contained",onClick:()=>{l()},disabled:i,autoFocus:!0,children:"Save to Draft"})]})]})}function eu(e){let{classes:t,showSaveAudienceModal:a,audienceName:n,savingAudience:s,saveAudienceError:i,selectedAudience:r,geoLocations:l,excludedGeoLocations:c,selectedAdvanceTargets:p,selectedPlatforms:u,advantageAudience:m,gender:g,FromAge:b,ToAge:y,setState:x,checkAudienceChanged:f,formatGeoLocationsSummary:A,handleSaveAudience:I}=e;return(0,h.jsxs)(o.Dialog,{open:a,onClose:()=>x({showSaveAudienceModal:!1,isUpdateMode:!1,audienceName:r?.audienceName||"",saveAudienceError:""}),children:[(0,h.jsxs)(o.Box,{className:t.saveAudienceDialogWrapper,style:{color:"#000000"},children:[(0,h.jsxs)(o.DialogTitle,{className:t.saveAudienceDialogTitle,children:[(0,h.jsx)(o.Typography,{variant:"h3",children:"Save Audience Changes"}),(0,h.jsx)(o.Typography,{variant:"h5",color:"textSecondary",style:{marginTop:"4px",wordBreak:"break-word"},children:"Update or rename your audience by entering a unique name below."})]}),(0,h.jsx)(d.Clear,{className:t.saveAudienceCloseIcon,onClick:()=>x({showSaveAudienceModal:!1,isUpdateMode:!1,audienceName:r?.audienceName||"",saveAudienceError:""})})]}),(0,h.jsx)(o.Divider,{}),(0,h.jsx)(o.DialogContent,{children:(0,h.jsxs)(o.Grid,{container:!0,spacing:1,py:1,style:{color:"#000000",marginTop:"0px"},children:[(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:3,children:(0,h.jsx)("label",{style:{fontWeight:"400"},htmlFor:"audienceName",children:"Audience Name:"})}),(0,h.jsxs)(o.Grid,{item:!0,xs:12,sm:9,children:[(0,h.jsx)("input",{id:"audienceName",type:"text",autoFocus:!0,value:n,onChange:e=>x({audienceName:e.target.value}),style:{width:"70%",border:i?"1px solid red":"none",padding:"8px",borderRadius:"4px",background:"#f0f0f0",outline:"none"}}),i&&(0,h.jsx)("div",{style:{color:"red",fontSize:"12px",marginTop:"4px"},children:i})]})]})}),(0,h.jsx)(o.Divider,{style:{marginBottom:"4px"}}),(0,h.jsx)(o.DialogContent,{style:{paddingTop:"0px",marginTop:"0px",color:"#000000"},children:(0,h.jsxs)(o.Box,{mt:3,children:[(0,h.jsx)(o.Typography,{variant:"h4",fontWeight:"500",gutterBottom:!0,children:"Details"}
1),(0,h.jsx)(o.Box,{className:t.audienceDetails,children:(0,h.jsxs)(o.Grid,{container:!0,spacing:1,children:[(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:3,style:{color:"#808080"},children:(0,h.jsx)(o.Typography,{children:"Locations:"})}),(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:9,className:t.audienceDetailValues,children:(0,h.jsx)(o.Typography,{children:A(l)})}),Object.entries(c||{}).some((e=>{let[t,a]=e;return"location_types"!==t&&(a||[]).length>0}))&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:3,style:{color:"#808080"},children:(0,h.jsx)(o.Typography,{children:"Excluded Locations:"})}),(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:9,className:t.audienceDetailValues,children:(0,h.jsx)(o.Typography,{children:A(c)})})]}),(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:3,style:{color:"#808080"},children:(0,h.jsx)(o.Typography,{children:"Gender:"})}),(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:9,className:t.audienceDetailValues,children:(0,h.jsx)(o.Typography,{children:g})}),(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:3,style:{color:"#808080"},children:(0,h.jsx)(o.Typography,{children:"Age Range:"})}),(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:9,className:t.audienceDetailValues,children:(0,h.jsxs)(o.Typography,{children:[b," - ",y]})}),!as().isEmpty(p)&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:3,style:{color:"#808080"},children:(0,h.jsx)(o.Typography,{children:"Advanced Targeting:"})}),(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:9,className:t.audienceDetailValues,children:(0,h.jsx)(o.Typography,{children:p.map((e=>e.label)).join(", ")})})]}),(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:3,style:{color:"#808080"},children:(0,h.jsx)(o.Typography,{children:"Audience expansion:"})}),(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:9,className:t.audienceDetailValues,children:(0,h.jsx)(o.Typography,{children:m?"Allow Meta to expand audience":"Use only my selected targeting"})}),!as().isEmpty(u)&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:3,style:{color:"#808080"},children:(0,h.jsx)(o.Typography,{children:"Platforms:"})}),(0,h.jsx)(o.Grid,{item:!0,xs:12,sm:9,className:t.audienceDetailValues,children:(0,h.jsx)(o.Typography,{children:u.map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(", ")})})]})]})})]})}),(0,h.jsx)(o.Divider,{style:{marginTop:"4px"}}),(0,h.jsx)(o.DialogActions,{children:r?._id?(0,h.jsxs)("div",{className:t.saveAudienceBtnContainer,children:[(0,h.jsx)(o.Button,{onClick:()=>{x({isUpdateMode:!1},(()=>{I()}))},className:t.dialogSaveBtn,color:"primary",variant:"outlined",disabled:s,children:"Save New Audience"}),f()&&(0,h.jsx)(o.Button,{onClick:()=>{x({isUpdateMode:!0},(()=>{I()}))},className:t.dialogSaveBtn,color:"primary",variant:"contained",disabled:s,children:"Update Audience"})]}):(0,h.jsx)(o.Button,{onClick:I,color:"primary",variant:"contained",disabled:s,className:t.dialogSaveBtn,children:s?"Saving...":"Save Audience"})})]})}function tu(e){let{classes:t,defaultDailyBudget:a,defaultLifetimeBudget:n,isIceBreakerNotEditable:s,isLiveAD:i,steps:r,activeStep:l,adType:c,isAdFetched:p,isLoading:u,showPreview:m,switchChecked:g,expandedSections:b,applyDefaultBudgets:y,changeState:x,checkAudienceChanged:f,createAd:A,editAd:I,isCreateAd:C,isDuplicateAd:_,isValidAd:S,nextSection:v,setState:E}=e;return(0,h.jsxs)(o.Grid,{container:!0,className:t.stepContainer,children:[!m&&r.map(((e,m)=>(0,h.jsxs)(o.Grid,{className:`${t.stepsContentBlock} ${b.has(m)?"":t.stepsContentBlockPaddingRemove}`,style:e.isCompleted?{}:{borderColor:"#28c153"},onClick:e=>{if(e.target.closest("button")||e.target.closest("input")||e.target.closest("textarea")||e.target.closest('[role="button"]')||e.target.closest('[role="combobox"]')||e.target.closest("[class*=MuiAutocomplete-root]")||e.target.closest("[class*=MuiAutocomplete-inputRoot]")||e.target.closest("[class*=MuiAutocomplete-input]")||e.target.closest("[class*=MuiPopover-root]")||e.target.closest("[class*=MuiPaper-root]")||e.target.closest('[role="listbox"]')||e.target.closest('[role="option"]')||e.target.closest("[class*=MuiTextField-root]")||e.target.closest("[class*=MuiFormControl-root]")||e.target.closest("[class*=MuiSelect-root]")||e.target.closest("[class*=MuiCheckbox-root]")||e.target.closest("[class*=MuiRa
1dio-root]")||e.target.closest("[class*=MuiSwitch-root]")||e.target.closest("a")||e.target.closest("label")||e.target.closest("[data-content-area]"))return;if(4===m&&("ctwa"===c?.value||"whatsapp_status"===c?.value)&&!g)return void(i&&!_&&E({snackStatus:"warning",snackMessage:"You can't edit icebreakers once the ad is live",snack:!0}));if(!p&&!C&&0!==m)return;let t=new Set;b.has(m)?t=new Set:t.add(m),v(m)?E({expandedSections:t}):(2!==m&&2===m&&f()?E({selectedAudience:null,audienceName:"",activeStep:m,expandedSections:t}):E({activeStep:m,expandedSections:t}),3===m&&y(a,n)),2===m&&y(a,n)},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",justifyContent:"space-between"},children:[(0,h.jsxs)(o.Box,{style:{display:"flex",alignItems:"top",gap:"20px"},children:[(0,h.jsxs)(o.Box,{style:{width:"26px",height:"26px",borderRadius:"8px",border:"1px solid #0a474c",color:"#0a474c",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",position:"relative"},children:[m+1,!e.isCompleted&&(0,h.jsx)(d.CheckCircle,{className:t.checked})]}),(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{children:e.title}),(0,h.jsx)(o.Typography,{variant:"h6",color:"textSecondary",style:{marginBottom:"24px"},children:e.description})]})]}),4===m&&("ctwa"===c?.value||"whatsapp_status"===c?.value)&&(0,h.jsx)(o.Tooltip,{title:i&&!_?"You can't change icebreaker status once the ad is live":"",children:(0,h.jsx)("span",{style:{display:"inline-block"},children:(0,h.jsx)(o.Switch,{color:"primary",checked:g,disabled:s,onChange:()=>{x("switchChecked",!g)}})})})]}),(0,h.jsx)("div",{"data-content-area":"true",onClick:e=>e.stopPropagation(),style:{transition:"all 0.2s",display:b.has(m)?"block":"none"},children:b.has(m)&&e.component}),b.has(m)&&(0,h.jsxs)(o.Box,{style:{display:"flex",justifyContent:"flex-end",gap:"16px"},children:["Ad Targeting & Audience"===e.title&&(0,h.jsx)(o.Button,{className:e.isCompleted||u?`${t.saveAudienceBtn} ${t.disabledBtn}`:t.saveAudienceBtn,variant:"outlined",color:"primary",onClick:()=>E({showSaveAudienceModal:!0}),disabled:e.isCompleted||u,children:"Save Audience"}),m!==r.length-1&&(0,h.jsx)(o.Box,{children:(0,h.jsxs)(o.Button,{className:t.actionBtn2,onClick:e=>{e.stopPropagation(),1!==m&&2!==m||y(a,n);const t=new Set([m+1]);2==l&&f()?E({selectedAudience:null,audienceName:"",activeStep:m+1,expandedSections:t}):E({activeStep:m+1,expandedSections:t})},startIcon:u&&(0,h.jsx)(d.Autorenew,{className:u?t.rotationIcon:""}),children:["Next",u?"":(0,h.jsx)(d.ArrowForward,{style:{fontSize:"16px"}})]})})]})]}))),(0,h.jsxs)(o.Box,{className:t.publishBtnContainer,children:[(0,h.jsx)(o.Button,{variant:"outlined",color:"primary",className:t.previewBtn,onClick:()=>x("showPreview",!m),children:(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"3px"},children:[(0,h.jsx)("span",{children:m?"Hide":"Preview"}),m?(0,h.jsx)(d.VisibilityOffOutlined,{style:{fontSize:"16px"}}):(0,h.jsx)(d.VisibilityOutlined,{style:{fontSize:"16px",marginTop:"2px"}})]})}),(0,h.jsxs)(o.Button,{variant:"contained",color:"primary",className:t.publishBtn,startIcon:u&&(0,h.jsx)(d.Autorenew,{className:u?t.rotationIcon:""}),onClick:()=>{i&&!_?S()&&I():S()&&A()},disabled:u,children:[(0,h.jsx)("span",{children:i&&!_?"Publish Changes":"Publish"}),!u&&(0,h.jsx)(d.Publish,{style:{fontSize:"16px",marginBottom:"2px"}})]})]})]})}class au extends n.Component{constructor(e){super(e),this.audienceFormRef=s().createRef(),this.debouncedGetEstimatedDeliveryUsers=as().debounce((()=>{this.getEstimatedDeliveryUsers()}),500),this.debouncedUpdateIceBreakers=as().debounce(this.props.updateIceBreakers,300),this.debouncedRecreateAllIceBreakers=as().debounce(this.props.recreateAllIceBreakerNodes,300),this.state={leadFormId:"",leadForm:null,adAccountData:{},lable:"Advertisement details",activeStep:0,expandedSections:new Set([0]),selectedAdType:"ctwa",websiteUrl:"",pixelId:"",error:null,status:null,snack:!1,snackMessage:"",snackStatus:"",isLoading:!1,hash:null,validatingLink:!1,errorAction:{},showDialog:!1,adName:"",adCaption:"",adHeadline:"",adHeadlineDescription:"",imageFile:null,thumbnailUrl:null,videoFile:null,uploadType:"IMAGE_UPLOAD",adFormat:"single",cards:[],carouselOptions:{multiShareOptimized:!0,multiShareEndCard:!1},selectedLocations:[],excludedSelectedLocations:[],customAndLookalikeAudiences:[],excludedCustomAndLookalikeAudiences:[],geoLocations:{countries:[],cities:[],regions:[],places:[],zips:[]},excludedGeoLocations:{countries:[],cities:[],regions:[],places:[],zips:[]},gender:"ALL",FromAge:"18",ToAge:"65",advanceTargets:{},selectedAdvanceTargets:[],advantageAudience:!1,advantageAudienceLocked:!1,dailyBudget:0,lifetimeBudget:0,duration:2,isEndDate:!1,fromDate:new Date,toDate:new Date((new Date).setDate((new Date).getDate()+2)),minDate:new Date((new Date).setDate((new Date).getDate()+2)),estimatedData:{},isLiveAD:!1,keyThird:new Date,selectedPlatforms:["facebook","instagram"],adPlacements:{facebookPositions:[],instagramPositions:[]},adEffectiveStatus:null,originalDuration:null,showSaveAudienceModal:!1,audienceName:"",saveAudienceError:"",savingAudience:!1,selectedAudience:null,isUpdateMode:!1,originalEndDate:null,originalStartDate:null,adStatus:null,isAdFetched:!1,greetingMessage:"",switchChecked:!1,iceBreakers:[{iceBreakerText:"",flowId:"",iceBreakerId:`${Date.now()}`,blockId:"",blockHandle:""}],iceBreakerNodeId:`${Date.now()}`,prevIceBreakerNodeId:"",defaultIceBreakers:[{iceBreakerText:"",flowId:""}],defaultGreetingMsg:"",isDefaultIceBreakerOn:!1,isIceBreakerStepOn:!1,currSelectedFlowId:"",estimatedReachLoading:!1,iceBreakerName:"",isIceBreakerSaving:!1,showSaveIceBreakerModal:!1,initialIceBreakerFlowIds:[],currSelectedSavedIceBreaker:null,totalAdsCount:20,savedIceBreakers:[],showPreview:!1,isScheduledAd:!1,selectedTimezone:{label:"Use Viewer's time zone",value:"viewer"},selectedBudget:{label:"Daily Budget",value:"daily_budget"},selectedCells:new Set,selectedSlotsCount:0,startDateError:"",endDateError:"",isStartDateNull:!1,isEndDateNull:!1,originalCreativeData:null,adType:ea.Kx[0],adObjective:ea.c8[0],optimizationGoal:"",conversionEvent:null,ctaButton:"APPLY_NOW",isGenerating:!1,isImageGenerating:!1,isVideoGenerating:!1,adDialogOpen:!1,deprecatedAdvanceTargets:[]}}isDuplicateAd=(()=>window.location.pathname.includes("duplicate"))();isEditAd=(()=>window.location.pathname.includes("edit"))();isCreateAd=(()=>window.location.pathname.includes("create"))();budgetOptions=[{label:"Lifetime Budget",value:"lifetime_budget"},{label:"Daily Budget",value:"daily_budget"}];timezoneOptions=[{label:"Use Viewer's time zone",value:"viewer"},{label:"Use this ad accnount's time zone",value:"ad_account"}];componentDidMount(){this.fetchAdAccount(),this.fetchMetaPage(),this.isCreateAd&&this.getEstimatedDeliveryUsers(),this.debouncedUpdateIceBreakers({iceBreakerNodeId:this.state.iceBreakerNodeId,iceBreakers:this.state.iceBreakers});const{currency:e,iceBreakers:t}=this.props.assistantDetails,{projectId:a}=this.props.match.params;this.props.getFlows(a),this.props.fetchTemplateMessages(a),this.props.assistantDetails?.flowConfiguration?.totalAdsCount&&this.setState({totalAdsCount:20+this.props.assistantDetails?.flowConfiguration?.totalAdsCount});const{rawMetaIceBreakers:n,isDefaultIceBreakerOn:s,iceBreakerFlowMapping:o}=t||{},i=n?.text||"",r=(n?.ice_breakers||[]).map((e=>{let{title:t}=e;return{iceBreakerText:t,flowId:(o||[]).find((e=>e.iceBreaker===t))?.flowId||""}}));this.setState({defaultIceBreakers:r,defaultGreetingMsg:i,isDefaultIceBreakerOn:s});const{projectId:l,adId:d}=this.props.match.params,{state:c}=this.props.location;if(l&&this.props.fetchPixels({assistantId:l}),c?.selectedAudience){const{name:e,audienceId:t,accountId:a,type:n}=c.selectedAudience;this.setState({customAndLookalikeAudiences:[{name:e,audienceId:t,accountId:a,type:n}]})}
1try{const e=this.props.location?.search||"",t=new URLSearchParams(e),a=t.get("selectedAdType"),n=t.get("pixelId");if(this.isCreateAd&&(a||n)){if(a){this.changeState("selectedAdType",a);const e=ea.Kx.find((e=>e.value===a));if(e){this.changeState("adType",e);const{objective:t,goal:a}=(0,ea.Nj)(e.type);t&&this.changeState("adObjective",t),a&&this.changeState("optimizationGoal",a)}}n&&this.changeState("pixelId",n)}}catch(e){}this.fetchAd({adId:d,projectId:l}),"USD"!==e&&this.fetchMetaAdAccount(l),this.isCreateAd&&c?.adTemplateVariant&&this.hydrateFromAdTemplate(c.adTemplateVariant)}geoToSelectedLocations=(()=>{var e=this;return async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(await Promise.all(["cities","countries","regions","places","zips"].map((a=>e.locationOptionValue(t[a]||[]))))).flat()}})();hydrateFromAdTemplate=async e=>{if(!e)return;const t=ea.Kx.find((t=>t.value===e.adType))||ea.Kx[0],a=(0,ea.Nj)(t.type),n=e.budgetType||"daily_budget",s=(0,ea.Ht)(ea.c8,e.adObjective)||a.objective,o=(0,ea.Ht)(s?.optimizationGoals,e.optimizationGoal)||a.goal,i=e.advanceTargets?.flexible_spec?.[0]||e.advanceTargets||{},r={selectedAdType:t.value,adType:t,adName:e.adName||`${t.label} - Template`,adHeadline:e.headline||"",adCaption:e.adDescription||"",adHeadlineDescription:e.headlineDescription||"",websiteUrl:e.websiteUrl||"",gender:e.gender||"ALL",FromAge:e.minAge?String(e.minAge):"18",ToAge:e.maxAge?String(e.maxAge):"65",selectedBudget:{label:"lifetime_budget"===n?"Lifetime Budget":"Daily Budget",value:n},advanceTargets:i,selectedAdvanceTargets:this.targetingOptionValue([i]),adPlacements:e.adPlacements||this.state.adPlacements,leadFormId:e.leadFormId||this.state.leadFormId,pixelId:e.pixelId||this.state.pixelId,customAndLookalikeAudiences:e.customAndLookalikeAudiences||this.state.customAndLookalikeAudiences,excludedCustomAndLookalikeAudiences:e.excludedCustomAndLookalikeAudiences||this.state.excludedCustomAndLookalikeAudiences,advantageAudience:!0===e.advantageAudience||1===Number(e.advantageAudience),duration:Number(e.duration)||this.state.duration,isScheduledAd:!!e.isScheduledAd};s&&(r.adObjective=s),o&&(r.optimizationGoal=o),e.pixelId&&(r.pixel=(0,ea.Ht)(this.props.pixels,e.pixelId,"pixelId")||{value:e.pixelId,label:e.pixelId}),e.conversionEvent&&(r.conversionEvent=(0,ea.Ht)(ea.rO,e.conversionEvent)||this.state.conversionEvent),e.iceBreakers&&"boolean"==typeof e.iceBreakers.status&&(r.switchChecked=e.iceBreakers.status);const l=e.callToAction||e.ctaButton;if(l&&"WHATSAPP_MESSAGE"!==l&&(r.ctaButton=l),e.geoLocation){const t=Ap(e.geoLocation,e.geoLocationDisplay);r.geoLocations={...this.state.geoLocations,...t},r.selectedLocations=await this.geoToSelectedLocations(t)}if(e.excludedGeoLocation){const t=Ap(e.excludedGeoLocation,e.geoLocationDisplay);r.excludedGeoLocations={...this.state.excludedGeoLocations,...t},r.excludedSelectedLocations=await this.geoToSelectedLocations(t)}Array.isArray(e.platforms)&&e.platforms.length&&(r.selectedPlatforms=e.platforms),"lifetime_budget"===n?r.lifetimeBudget=Number(e.lifetimeBudget)||this.state.lifetimeBudget:r.dailyBudget=Number(e.dailyBudget)||this.state.dailyBudget,e.adStartDate&&(r.fromDate=new Date(e.adStartDate)),e.adStopDate&&(r.toDate=new Date(e.adStopDate),r.isEndDate=!0),e.imageUrl&&(r.imageFile={publicUrl:e.imageUrl}),e.videoUrl&&(r.videoFile={publicUrl:e.videoUrl},r.thumbnailUrl=e.imageUrl?{publicUrl:e.imageUrl}:null),this.setState(r,(()=>{"function"==typeof this.getEstimatedDeliveryUsers&&this.getEstimatedDeliveryUsers()})),e.audienceId&&this.fetchSavedAudiences({audienceId:e.audienceId})};validateTimeSlotsAgainstDateRange(){const e=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],t=this.state.adAccountData?.timezone,{fromDate:a,toDate:n,selectedCells:s}=this.state;if(!n)return{invalidSlots:[]};const o=new Set;let i=Zr().tz(a,t).startOf("day");const r=Zr().tz(n,t).endOf("day");if(r.diff(i,"days")>=6)return{invalidSlots:[]};for(;i.isSameOrBefore(r);)o.add(i.day()),i.add(1,"day");const l=[],d=new Set;for(const e of s){const[t]=e.split("-");if("7"===t)continue;const a=parseInt(t,10);o.has(a)||(l.push(e),d.add(a))}if(l.length>0){const n=[...d].map((t=>e[t])).join(", "),s=[];for(i=Zr().tz(a,t);i.isSameOrBefore(r);)s.push(e[i.day()]),i.add(1,"day");const o=[...new Set(s)];
1return{invalidSlots:l,message:`You have scheduled this ad set to run on ${n}. But the selected date range only includes ${1===o.length?o[0]:`${o[0]} to ${o[o.length-1]}`}. Please change your date range or schedule.`}}return{invalidSlots:[]}}toggleAdCreditDialog=()=>{this.setState({adDialogOpen:!this.state.adDialogOpen})};syncIceBreakers=()=>{const e=[...this.state.iceBreakers];for(let t of e){const e=this.props.iceBreakers.iceBreakers.find((e=>e.iceBreakerId===t.iceBreakerId));e&&(t.blockId=e.blockId||"",t.blockHandle=e.blockHandle||"")}this.setState({iceBreakers:e})};componentDidUpdate(e,t){e.isFlowPopupOpen!==this.props.isFlowPopupOpen&&this.syncIceBreakers(),this.props.assistantDetails?.flowConfiguration?.totalAdsCount!==e.assistantDetails?.flowConfiguration?.totalAdsCount&&this.props.assistantDetails?.flowConfiguration?.totalAdsCount&&this.setState({totalAdsCount:20+this.props.assistantDetails?.flowConfiguration?.totalAdsCount}),t.gender!==this.state.gender&&this.getEstimatedDeliveryUsers(),t.FromAge!==this.state.FromAge&&this.getEstimatedDeliveryUsers(),t.ToAge!==this.state.ToAge&&this.getEstimatedDeliveryUsers(),t.selectedPlatforms.length!==this.state.selectedPlatforms.length&&this.getEstimatedDeliveryUsers(),t.adPlacements!==this.state.adPlacements&&this.getEstimatedDeliveryUsers(),t.dailyBudget===this.state.dailyBudget&&t.selectedBudget===this.state.selectedBudget&&t.optimizationGoal===this.state.optimizationGoal||this.debouncedGetEstimatedDeliveryUsers(),e.assistantDetails?.selectedMetaPageId===this.props.assistantDetails?.selectedMetaPageId&&e.assistantDetails?.fbConnected===this.props.assistantDetails?.fbConnected||this.fetchMetaPage()}shouldShowBudgetNextBtn=()=>this.state.activeStep<2||this.state.switchChecked;exitPath=()=>{const{projectId:e}=this.props.match.params,t=this.props.location?.state?.returnTo;return"string"==typeof t&&t.startsWith("/")?t:`${Xe(e)}`};toggleDialog=()=>{const{isLiveAD:e}=this.state;if(!up(this.state,this.props.assistantDetails,0)&&!e||this.isDuplicateAd){const{showDialog:e}=this.state;this.setState({showDialog:!e})}else this.props.history.push(this.exitPath())};getEstimatedDeliveryUsers=(()=>{var e=this;return function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;e.setState({estimatedReachLoading:!0});const{geoLocations:a,excludedGeoLocations:n,gender:s,FromAge:o,ToAge:i,advanceTargets:r,selectedPlatforms:l,adPlacements:d,customAndLookalikeAudiences:c,excludedCustomAndLookalikeAudiences:p}=e.state,{assistantId:u}=e.props.assistantDetails,m=e.resolveAdAccountId();e.props.getDeliveryEstimate({adAccountId:m,minAge:parseInt(o),maxAge:parseInt(i),gender:s,geoLocation:a,excludedGeoLocation:n,selectedPlatforms:l,advanceTargets:r,assistantId:u,adPlacements:d,advantageAudience:e.state.advantageAudience?1:0,customAudiences:(c||[]).map((e=>e.audienceId)).filter(Boolean),excludedCustomAudiences:(p||[]).map((e=>e.audienceId)).filter(Boolean),optimizationGoal:e.state.optimizationGoal?.value||"CONVERSATIONS",dailyBudget:"daily_budget"===e.state.selectedBudget?.value&&parseInt(e.state.dailyBudget)||0}).then((a=>{0===a?.data?.estimate_dau&&0===t?e.getEstimatedDeliveryUsers(t+1):e.setState({estimatedData:a?.data||{},estimatedDailyResults:a?.estimatedDailyResults||null,estimatedReachLoading:!1})})).catch((t=>{console.log({error:t}),e.setState({estimatedData:null,estimatedDailyResults:null,estimatedReachLoading:!1})}))}})();locationOptionValue=async e=>{const t={};return Nd.A.forEach((e=>{t[e.isoCode]=e.name})),e.map((e=>{if("string"==typeof e){const a=t[e];return{label:a?`${a}, ${a}`:e,value:{type:"country",key:e,name:a||e,country_name:a||e}}}const{name:a,country_name:n,region:s}=e;return{label:as().compact([a,s,n]).join(", "),value:e}})).filter((e=>!!e.label))};advanceTargetBucket=e=>"interests"===e?"Interests":"behaviors"===e?"Behaviors":"Demographics";targetingOptionValue=e=>{const t=[];return e.forEach((e=>{e?.custom_audiences||e?.excluded_custom_audiences||Object.keys(e).forEach((a=>{e[a]&&Array.isArray(e[a])&&e[a].forEach((e=>{e.name&&t.push({label:e.name,value:{...e,type:a,path:e.path||[this.advanceTargetBucket(a)]}})}))}))})),t};fetchSavedAudiences=e=>{let{audienceId:t}=e;const{projectId:a}=this.props.match.params;this.props.fetchAudienceById({audienceId:t,assistantId:a}).then((e=>
1{this.setState({selectedAudience:e,audienceName:e?.audienceName})})).catch((e=>{console.log({error:e})}))};fetchAd(e){let{adId:t,projectId:a}=e;t&&a&&this.props.loadAd({assistantId:a,adId:t}).then((async e=>{const t=e.adData;this.validateAdvancedTargets(t?.advanceTargets?.flexible_spec?.[0]||t?.advanceTargets||{},a);let n=this.state.iceBreakers;const{iceBreakers:s}=e.adData,o=s?.iceBreakerFlowMapping?.map((e=>e.flowId)).filter((e=>!!e)).filter(((e,t,a)=>t===a.findIndex((t=>t===e)))),{status:i,rawMetaIceBreakers:r}=s||{};let{iceBreakerNodeId:l}=s||{};const d=l;if(this.isDuplicateAd&&(l=`${Date.now()}`),r&&i&&r.ice_breakers&&t.iceBreakers&&t.iceBreakers.iceBreakerFlowMapping){const e=t.iceBreakers.iceBreakerFlowMapping;n=r.ice_breakers.map((t=>{let{title:a}=t;const n=e.find((e=>e.iceBreaker===a))||{},s=n?.flowId,o=n?.iceBreakerId,i=!!n?.blockId&&this.props.flows?.find((e=>e._id===s))?.flow?.nodes?.some((e=>e.id===n?.blockId)),r=!!n?.blockId&&this.props.flows?.find((e=>e._id===s))?.flow?.edges?.some((e=>!(!e.sourceHandle.includes("icebreaker_message-right")||e.sourceHandle.split("-").reverse()[0]!==o||e.target!==n?.blockId))),l=i&&r&&n?.blockId||"",d=i&&r&&n?.blockHandle||"",c=this.props.flows?.find((e=>e._id===s))?.flow?.nodes[0]?.data?.ads?.length||0;return{flowId:this.isEditAd||c<this.state.totalAdsCount?s:"",iceBreakerText:a,iceBreakerId:o,blockId:this.isEditAd||c<this.state.totalAdsCount?l:"",blockHandle:this.isEditAd||c<this.state.totalAdsCount?d:""}}))}this.debouncedUpdateIceBreakers({iceBreakerNodeId:l,iceBreakers:n}),this.setState({adName:t?.adName,adCaption:t?.adDescription,adHeadline:t?.headline||t?.headlineDescription,adHeadlineDescription:t?.headlineDescription||"",uploadType:t.videoUrl?"VIDEO_UPLOAD":"IMAGE_UPLOAD",selectedLocations:[...await this.locationOptionValue(t?.geoLocation?.cities||[]),...await this.locationOptionValue(t?.geoLocation?.countries||[]),...await this.locationOptionValue(t?.geoLocation?.regions||[]),...await this.locationOptionValue(t?.geoLocation?.places||[]),...await this.locationOptionValue(t?.geoLocation?.zips||[])],...t?.geoLocation&&{geoLocations:t?.geoLocation},excludedSelectedLocations:[...await this.locationOptionValue(t?.excludedGeoLocation?.cities||[]),...await this.locationOptionValue(t?.excludedGeoLocation?.countries||[]),...await this.locationOptionValue(t?.excludedGeoLocation?.regions||[]),...await this.locationOptionValue(t?.excludedGeoLocation?.places||[]),...await this.locationOptionValue(t?.excludedGeoLocation?.zips||[])],...t?.excludedGeoLocation&&{excludedGeoLocations:t?.excludedGeoLocation},gender:t?.gender,FromAge:t?.minAge,ToAge:t?.maxAge,selectedPlatforms:t?.platforms||[],websiteUrl:t?.websiteUrl||"",pixelId:t?.pixelId||this.state.pixelId||"",ctaButton:t?.ctaButton||this.state.ctaButton,advanceTargets:t?.advanceTargets?.flexible_spec?.[0]||t?.advanceTargets||{},selectedAdvanceTargets:this.targetingOptionValue([t?.advanceTargets?.flexible_spec?.[0]||t?.advanceTargets||{}]),dailyBudget:t?.dailyBudget/100,originalDuration:t?.duration,duration:this.getInitialDuration(t?.adStopDate,t?.adStatus,t?.adStartDate),isEndDate:!!t?.adStopDate,fromDate:t?.adStartDate,toDate:this.getValidAdStopDate(t?.adStopDate,t?.adStatus,t?.adStartDate),minDate:t?.adStopDate,isLiveAD:"DRAFT"!==t?.adStatus&&!this.isDuplicateAd,activeStep:0,expandedSections:new Set([0]),keyThird:new Date,originalEndDate:t?.adStopDate,originalStartDate:t?.adStartDate,adStatus:t?.adStatus,adEffectiveStatus:t?.adEffectiveStatus,originalDuration:t?.duration,isAdFetched:!0,switchChecked:i,greetingMessage:r?.text,iceBreakers:n,iceBreakerNodeId:l,prevIceBreakerNodeId:d,initialIceBreakerFlowIds:o,selectedCells:this.extractScheduledString(t?.adSetSchedule),selectedSlotsCount:this.getSelectedSlotsCount(this.extractScheduledString(t?.adSetSchedule)),isScheduledAd:t?.isScheduledAd,selectedBudget:!isNaN(parseInt(t.dailyBudget))&&parseInt(t.dailyBudget)?this.budgetOptions[1]:this.budgetOptions[0],lifetimeBudget:isNaN(parseInt(t?.lifetimeBudget))?0:parseInt(t?.lifetimeBudget)/100,selectedTimezone:"ADVERTISER"===t?.timezoneType?this.timezoneOptions[1]:this.timezoneOptions[0],adType:(0,ea.Ht)(ea.Kx,t?.adType)||"",adObjective:(0,ea.Ht)(ea.c8,t?.adCampaignObjective)||"",optimizationGoal:(0,ea.Ht)(ea.c8.find((e=>e?.value===t?.adCampaignObjective))?.optimizationGoals,t?.optimizationGoal)||"",pixel:(0,ea.Ht)(this.props.pixels,t?.pixelId,"pixelId")||(t?.pixelId?{value:t?.pixelId,label:t?.pixelId}:""),conversionEvent:(0,ea.Ht)(ea.rO,t?.conversionEvent)||"",adPlacements:t?.adPlacements||{},customAndLookalikeAudiences:t?.customAndLookalikeAudiences||[],excludedCustomAndLookalikeAudiences:t?.excludedCustomAndLookalikeAudiences||[],leadFormId:t?.leadFormId||"",adFormat:t?.adFormat||"single",cards:t?.cards||[],carouselOptions:t?.carouselOptions||{multiShareOptimized:!0,multiShareEndCard:!1},advantageAudience:1===Number(t?.advantageAudience??0),advantageAudienceLocked:1===Number(t?.advantageAudience??0)},(()=>{this.getEstimatedDeliveryUsers()})),"carousel"!==t?.adFormat&&(t.videoUrl?this.setState({videoFile:{publicUrl:t?.videoUrl},thumbnailUrl:t?.imageUrl?{publicUrl:t?.imageUrl}:null}):this.setState({imageFile:{publicUrl:t?.imageUrl}})),this.setState({originalCreativeData:{adName:t?.adName,adCaption:t?.adDescription,adHeadline:t?.headline||t?.headlineDescription,adHeadlineDescription:t?.headlineDescription||"",uploadType:t.videoUrl?"VIDEO_UPLOAD":"IMAGE_UPLOAD",videoUrl:t?.videoUrl,imageUrl:t?.imageUrl,adFormat:t?.adFormat||"single",cards:t?.cards||[],carouselOptions:t?.carouselOptions||{multiShareOptimized:!0,multiShareEndCard:!1},greetingMessage:r?.text,iceBreakers:n,switchChecked:i}}),""!==t?.audienceId&&this.fetchSavedAudiences({audienceId:t?.audienceId})})).catch((e=>{this.setState({isAdFetched:!0}),console.log(e)}))}getValidAdStopDate(e,t,a){const n=Zr()().startOf("day");e=e?Zr()(e).startOf("day"):e,a=a?Zr()(a).startOf("day"):a;const s=Zr()().startOf("day").add(1,"days"),o=Zr()().startOf("day").add(2,"days");if("DRAFT"===t){const t=Zr()().startOf("day").add(2,"days");if(!a)return a;
1if(e)return n.isSameOrBefore(a)||n.isBefore(e)&&e.diff(n)>2?e.toISOString():(n.isBefore(e)&&e.diff(n),t.toISOString());if(a.isSameOrBefore(n))return t.toISOString();if(a.isAfter(n))return a.add(2,"days").toISOString()}return e?e.isBefore(n)?s.toISOString():e.toISOString():n.isSame(a)?o.toISOString():s.toISOString()}getSelectedSlotsCount=e=>{let t=0;for(let a of e)"7"!==a[0]&&t++;return t};getInitialDuration(e,t,a){e=e?Zr()(e).startOf("day"):e;const n=Zr()().startOf("day");if(a=a?Zr()(a).startOf("day"):a,"DRAFT"===t){if(!a)return a;if(e)return n.isSameOrBefore(a)?e.diff(a,"days"):n.isBefore(e)&&e.diff(n)>2?e.diff(n,"days"):(n.isBefore(e)&&e.diff(n),2);if(a.isSameOrBefore(n))return 2;if(a.isAfter(n))return 2}return e?e.isBefore(n)?1:a.isAfter(n)?a.diff(n,"days"):e.diff(n,"days"):n.isSame(a)?2:1}fetchMetaAdAccount=async e=>{e&&(await this.props.fetchMetaAdSetup(e).then((e=>{let{isValid:t,pageId:a,adAccountId:n}=e;this.props.updateAssistantStore({fbConnected:t,selectedMetaPageId:t?a:"",selectedMetaAdAccountId:t?n:""}),this.props.updateAdSetupStore({fbConnected:t,selectedMetaPageId:t?a:"",selectedMetaAdAccountId:t?n:""})})).catch((e=>{console.log({error:e})})),this.fetchAdAccount(),this.fetchMetaPage())};handleToDateChange=e=>{if(!e)return void this.setState({isEndDateNull:!0});const t=new Date,a=new Date(e);a.setHours(t.getHours()),a.setMinutes(t.getMinutes()),a.setSeconds(t.getSeconds()),a.setMilliseconds(t.getMilliseconds()),this.setState({toDate:a,isEndDateNull:!1},(()=>{const{isEndDate:e,toDate:t,fromDate:a,originalEndDate:n,originalStartDate:s}=this.state;if(e&&t&&a){const e=Zr()().startOf("day"),o=Zr()(t).startOf("day"),i=Zr()(a).startOf("day"),r=n?Zr()(n).startOf("day"):null;s&&Zr()(s).startOf("day");r?e.isSameOrBefore(i)?this.changeState("duration",Zr()(o).diff(i,"days")):(e.isBefore(o)&&o.isSameOrBefore(r)||e.isSameOrBefore(r)&&o.isSameOrAfter(r)||e.isSameOrAfter(r)&&e.isBefore(o))&&this.changeState("duration",Zr()(o).diff(e,"days")):e.isSameOrBefore(i)?this.changeState("duration",Zr()(o).diff(i,"days")):this.changeState("duration",Zr()(o).diff(e,"days"))}}))};handleFromDateChange=e=>{(this.state.toDate||this.isDuplicateAd)&&this.state.fromDate&&e?this.setState({fromDate:e,minDate:new Date((new Date).setDate(e.getDate()+2)),isStartDateNull:!1},(()=>{const{toDate:t,fromDate:a}=this.state;if(t&&a){let n=Zr()(t).startOf("day");const s=Zr()(a).startOf("day");Zr()(n).diff(Zr()(s),"days")<2&&(n=Zr()(e).add(2,"days").toDate(),this.setState({toDate:n})),this.changeState("duration",Zr()(n).diff(Zr()(s),"days"))}})):e||this.setState({isStartDateNull:!0})};buildIceBreakersPayload=()=>{const e=[],t=this.state.iceBreakers.filter((e=>{let{iceBreakerText:t}=e;return!!t})).map((t=>{let{iceBreakerText:a,flowId:n,iceBreakerId:s,blockId:o,blockHandle:i}=t;return e.push({iceBreaker:a,flowId:n.toString(),iceBreakerId:s,blockId:o,blockHandle:i}),{title:a}}));return{status:!0,iceBreakerNodeId:this.state.iceBreakerNodeId,rawMetaIceBreakers:{text:this.state.greetingMessage,ice_breakers:t},iceBreakerFlowMapping:e}};resolveAdAccountId=()=>{const e=this.props.assistantDetails||{};return e.selectedMetaAdAccountId||(this.props.adSetupDetails||{}).selectedMetaAdAccountId||(e.adSetupDetails||{}).selectedMetaAdAccountId||""};resolveMetaPageId=()=>{const e=this.props.assistantDetails||{};return e.selectedMetaPageId||(this.props.adSetupDetails||{}).selectedMetaPageId||(e.adSetupDetails||{}).selectedMetaPageId||""};fetchAdAccount(){let{fbConnected:e,assistantId:t}=this.props.assistantDetails;const a=this.resolveAdAccountId();a&&t&&e&&(this.props.loadAdAccount({assistantId:t,adAccountId:a}).then((e=>{this.setState({adAccountData:e})})).catch((e=>{console.log(e)})),this.getEstimatedDeliveryUsers())}fetchMetaPage=()=>{const{fbConnected:e,selectedMetaPageId:t,assistantId:a}=this.props.assistantDetails;t&&e&&this.props.loadPage({assistantId:a,pageId:t}).then((e=>{this.props.updatePageDetails(e)})).catch((e=>console.log("error:",e)))};debounce=(e,t)=>{let a;return function(){for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];clearTimeout(a),a=setTimeout((()=>e(...s)),t)}};changeState=(e,t)=>
1{if("adType"===e){const e=this.state.adType?.value,a=t?.value;"whatsapp_status"===a&&"whatsapp_status"!==e?this.setState({preLockPlatforms:this.state.selectedPlatforms,preLockPlacements:this.state.adPlacements,selectedPlatforms:["instagram","whatsapp"],adPlacements:{instagramPositions:["story"],whatsappPositions:["status"]}}):"whatsapp_status"===e&&"whatsapp_status"!==a&&this.setState({selectedPlatforms:this.state.preLockPlatforms||["facebook","instagram"],adPlacements:this.state.preLockPlacements||{facebookPositions:[],instagramPositions:[]},preLockPlatforms:null,preLockPlacements:null}),_r(a)||"carousel"!==this.state.adFormat||this.setState({adFormat:"single",cards:[],carouselOptions:{multiShareOptimized:!0,multiShareEndCard:!1}})}"iceBreakers"===e&&(this.debouncedUpdateIceBreakers({iceBreakerNodeId:this.state.iceBreakerNodeId,iceBreakers:t}),this.debouncedRecreateAllIceBreakers(t,this.state.iceBreakerNodeId,this.state.prevIceBreakerNodeId,this.getAdDataPayload())),"switchChecked"===e&&!0===t?this.setState({activeStep:3}):"switchChecked"===e&&!1===t&&this.setState({activeStep:-1});const{ToAge:a}=this.state;"FromAge"===e&&t>a&&this.setState({ToAge:""}),this.setState({[e]:t},(()=>{["geoLocations","excludedGeoLocations","advanceTargets","advantageAudience","customAndLookalikeAudiences","excludedCustomAndLookalikeAudiences"].includes(e)&&this.debouncedGetEstimatedDeliveryUsers()})),"selectedPlatforms"==e&&this.setState({selectedPlatforms:t}),"adPlacements"==e&&this.setState({adPlacements:t}),"customAndLookalikeAudiences"==e&&this.setState({customAndLookalikeAudiences:t}),"excludedCustomAndLookalikeAudiences"==e&&this.setState({excludedCustomAndLookalikeAudiences:t});try{this.setState({[e]:t})}catch(e){console.log({error:e})}};handleGenerationStateChange=e=>{this.setState({isGenerating:e.isGenerating,isImageGenerating:e.isImageGenerating,isVideoGenerating:e.isVideoGenerating})};changeZLink=e=>{this.setState({zLink:e})};changeZage=(e,t)=>{"FromAge"===e&&this.state.ToAge<t?this.setState({[e]:t,ToAge:t}):this.setState({[e]:t})};changeZdetails=e=>{this.setState({zdetails:e})};changeZname=e=>{this.setState({Name:e})};updateFlows=async()=>{const e=this.state.iceBreakers.filter((e=>e.flowId)).map((e=>e.flowId)),t=[...new Set(e)];for(let e of t){const t=this.props.flows.find((t=>t._id===e)),a=this.state.iceBreakers.filter((t=>t.flowId===e));let n=t.flow.nodes.find((t=>t.id===`${this.state.iceBreakerNodeId}-${e}`)),s=[...t.flow.nodes],o=[...t.flow.edges];const i="iceBreaker";n||(n={id:`${this.state.iceBreakerNodeId}-${e}`,type:"masterComponent",data:{isDrag:!0,id:this.state.iceBreakerNodeId,content:[{id:`${Date.now()}-${i}`,type:`${i}`,data:{iceBreakersCount:0,iceBreakers:[]}}]},position:{x:s[0].position.x+300,y:s[0].position.y}},s.push(n)),s=s.filter(((e,t,a)=>t===a.findIndex((t=>t.id===e.id))));const r=[];for(let e of a||[]){const t=n.data.content[0].data.iceBreakers.find((t=>t.id.split("-").reverse()[0]===e.id));t?r.push({...t,iceBreakerText:e.iceBreakerText}):r.push({iceBreakerText:e.iceBreakerText,id:`icebreaker_message-right-${this.state.iceBreakerNodeId}-${e.iceBreakerId}`})}if(n.data.content[0].data.iceBreakers=r,n.data.content[0].data.iceBreakersCount=a?.length||0,this.isDuplicateAd||this.state.prevIceBreakerNodeId&&this.state.prevIceBreakerNodeId!==this.state.iceBreakerNodeId){for(let a of t.flow.edges)if(a.source===`${this.state.prevIceBreakerNodeId}-${e}`){const t=`${this.state.iceBreakerNodeId}-${e}`,n=a.sourceHandle.split("-").reverse()[0],s={...a,source:t,sourceHandle:`icebreaker_message-right-${this.state.iceBreakerNodeId}-${n}`};o.push(s)}o=o.filter(((e,t,a)=>t===a.findIndex((t=>t.sourceHandle===e.sourceHandle))))}for(let e of s){const{highlight:t,...a}=e.data;e.data={...a}}const l=this.props.assistantDetails?.assistantId,d=(s||[]).some((e=>{const t=e?.data?.content?.[0]?.data?.aiKeywords;return Array.isArray(t)&&t.length>0}));await this.props.updateFlow({assistantId:l,flowId:e,flowObject:{...t,flow:{nodes:s,edges:o},flowMessages:ap(s,o,e,{assistantDetails:this.props.assistantDetails,onError:e=>this.setState({snack:!0,snackMessage:e,snackStatus:"error"})}),hasAiKeyword:d}}).then((()=>{console.log("Success")})).catch((e=>{console.log("Error while updating flow",e)}))}for(let e of this.state.initialIceBreakerFlowIds){if(t.includes(e))continue;const a=this.props.flows.find((t=>t._id===e));let n=[...a.flow.nodes],s=[...a.flow.edges];const o=this.props.assistantDetails?.assistantId,i=(n||[]).some((e=>{const t=e?.data?.content?.[0]?.data?.aiKeywords;return Array.isArray(t)&&t.length>0}));await this.props.updateFlow({assistantId:o,flowId:e,flowObject:{...a,flow:{nodes:n,edges:s},flowMessages:ap(n,s,e,{assistantDetails:this.props.assistantDetails,onError:e=>this.setState({snack:!0,snackMessage:e,snackStatus:"error"})}),hasAiKeyword:i}}).then((()=>{console.log("Success")})).catch((e=>{console.log("Error while updating flow",e)}))}};updateFlowsNew=async e=>{const t=this.state.iceBreakers.filter((e=>e.flowId)).map((e=>e.flowId)),a=[...new Set(t)];for(let t of a){const a=this.props.flows.find((e=>e._id===t)),n=this.state.iceBreakers.filter((e=>e.flowId===t)),s=this.props.flows.find((e=>e._id===t))?.flow?.nodes,o=this.props.flows.find((e=>e._id===t))?.flow?.edges,i=s.find((e=>"keyword"===e.id));i.data.ads||(i.data.ads=[]);let r=[...s],l=[...o];const d=i.data.ads.filter((e=>!e.iceBreakers?.iceBreakerNodeId)),c=i.data.ads.filter((e=>e.iceBreakers?.iceBreakerNodeId));let p=c.findIndex((e=>e.iceBreakers?.iceBreakerNodeId===this.state.iceBreakerNodeId));const u=this.getAdDataPayload();u._id=e._id,u.adId=e.adId||e._id,-1===p?c.push(u):c[p]=u;const m=[...[u,...c].filter(((e,t,a)=>t===a.findIndex((t=>t.iceBreakers.iceBreakerNodeId===e.iceBreakers.iceBreakerNodeId)))),...d];if(i.data.ads=m,r=[i,...r],r=r.filter(((e,t,a)=>t===a.findIndex((t=>t.id===e.id)))),this.isDuplicateAd||this.state.prevIceBreakerNodeId&&this.state.prevIceBreakerNodeId!==this.state.iceBreakerNodeId){for(let e of a.flow.edges)if("keyword"===e.source){const t="keyword",a=e.sourceHandle.split("-").reverse()[0],n={...e,source:t,sourceHandle:`icebreaker_message-right-${this.state.iceBreakerNodeId}-${a}
1`};l.push(n)}l=l.filter(((e,t,a)=>t===a.findIndex((t=>t.sourceHandle===e.sourceHandle))))}const h=n.map((e=>e.iceBreakerId));l=l.filter((e=>{if(e.sourceHandle.startsWith(`icebreaker_message-right-${this.state.iceBreakerNodeId}`)){const t=e.sourceHandle.split("-").reverse()[0];if(!h.includes(t))return!1}return!0}));const g=this.props.assistantDetails?.assistantId,b=(r||[]).some((e=>{const t=e?.data?.content?.[0]?.data?.aiKeywords;return Array.isArray(t)&&t.length>0}));await this.props.updateFlow({assistantId:g,flowId:t,flowObject:{...a,flow:{nodes:r,edges:l},flowMessages:ap(r,l,t,{assistantDetails:this.props.assistantDetails,onError:e=>this.setState({snack:!0,snackMessage:e,snackStatus:"error"})}),hasAiKeyword:b}}).then((()=>{console.log("Success")})).catch((e=>{console.log("Error while updating flow",e)}))}for(let e of this.state.initialIceBreakerFlowIds){if(a.includes(e))continue;const t=this.props.flows.find((t=>t._id===e));let n=[...t.flow.nodes],s=[...t.flow.edges];const o=this.props.assistantDetails?.assistantId,i=(n||[]).some((e=>{const t=e?.data?.content?.[0]?.data?.aiKeywords;return Array.isArray(t)&&t.length>0}));await this.props.updateFlow({assistantId:o,flowId:e,flowObject:{...t,flow:{nodes:n,edges:s},flowMessages:ap(n,s,e,{assistantDetails:this.props.assistantDetails,onError:e=>this.setState({snack:!0,snackMessage:e,snackStatus:"error"})}),hasAiKeyword:i}}).then((()=>{console.log("Success")})).catch((e=>{console.log("Error while updating flow",e)}))}};createAd=()=>{this.setState({isLoading:!0});const{adName:e,adCaption:t,adHeadline:a,imageFile:n,thumbnailUrl:s,videoFile:o,uploadType:i,geoLocations:r,excludedGeoLocations:l,gender:d,FromAge:c,ToAge:p,advanceTargets:m,dailyBudget:h,duration:g,selectedPlatforms:b,selectedAudience:y,isEndDate:x,leadFormId:f}=this.state;let{fromDate:A,toDate:I}=this.state;const C=Zr()();A=Zr()(A).set({hour:C.hour(),minute:C.minute(),second:C.second(),millisecond:C.millisecond()}).toDate(),I=Zr()(I).set({hour:C.hour(),minute:C.minute(),second:C.second(),millisecond:C.millisecond()}).add(5,"seconds").toDate();let{assistantId:_,assistantName:S,partnerId:v,currency:E}=this.props.assistantDetails;const T=this.resolveAdAccountId(),D=this.resolveMetaPageId(),{adId:w}=this.props.match.params,N=kp({adId:w,assistantId:_,assistantName:S,adAccountId:T,metaPageId:D,adDescription:t,adName:e,budgetType:this.state.selectedBudget.value,dailyBudget:h,lifetimeBudget:this.state.lifetimeBudget,..."carousel"!==this.state.adFormat?{headline:a,headlineDescription:this.state.adHeadlineDescription}:{},gender:d,minAge:c,maxAge:p,geoLocation:r,excludedGeoLocation:l,adStartDate:A,adStopDate:I,isEndDate:x,duration:g,advanceTargets:m,selectedPlatforms:b,audienceId:y?._id||"",duplicateAd:this.isDuplicateAd,isScheduledAd:this.state.isScheduledAd,adType:this.state.adType?.value,adObjective:this.state.adObjective?.value,optimizationGoal:this.state.optimizationGoal?.value,conversionEvent:this.state.conversionEvent?.value,ctaButton:this.state.ctaButton,websiteUrl:this.state.websiteUrl,pixelId:this.state.pixel?.value,adPlacements:this.state.adPlacements,customAndLookalikeAudiences:this.state.customAndLookalikeAudiences,excludedCustomAndLookalikeAudiences:this.state.excludedCustomAndLookalikeAudiences,leadFormId:f,advantageAudience:this.state.advantageAudience,adSetSchedule:this.state.isScheduledAd?op(this.state.selectedCells,this.state.selectedTimezone):void 0,timezoneType:"viewer"===this.state.selectedTimezone.value?"USER":"ADVERTISER",iceBreakers:this.state.switchChecked?this.buildIceBreakersPayload():{status:!1},uploadType:i,imageUrl:"VIDEO_UPLOAD"===i?"string"==typeof s?s:s?.publicUrl:n?.publicUrl,videoUrl:o?.publicUrl});"carousel"===this.state.adFormat&&(N.adFormat="carousel",N.cards=this.state.cards,N.carouselOptions=this.state.carouselOptions,delete N.imageUrl,delete N.videoUrl),i&&this.props.publishAd(N).then((e=>{this.state.switchChecked&&this.updateFlowsNew(e),setTimeout((()=>{this.props.history.push(`${Xe(_)}/${e?._id}/personal-analytics/`),this.setState({isLoading:!1,snack:!this.state.snack,snackMessage:"Ad is created successfully",snackStatus:"success"})}),200),js.trackCustomEvent("ad_campaign_created",{budget:e?.amountSpent,ad_campaign_id:e?._id});const t=n?.fileName?.includes("Generated")||"Generated Image"===n?.fileName,a=o?.fileName?.includes("Generated")||"Generated Video"===o?.fileName;if(!(0,u.x)().isTenant&&!(0,u.x)().isPartner&&(t||a)&&_){const e=a?"video":"image";$d.track("ad_created_with_generated_media",{type:e,source:"generation",assistantId:_})}const s=this.props.adAccountInsights?.lastFetchParams;this.props.fetchAdAccountInsights({assistantId:_,adAccountId:T,page:s?.page||1,limit:s?.limit||_n.J6,nameQuery:s?.nameQuery||"",startDate:s?.startDate||null,endD
1ate:s?.endDate||null,selectedOption:s?.selectedOption||null})})).catch((e=>{console.log("error:",e),this.setState({isLoading:!1,snack:!0,snackMessage:e?.response?.data?.message||e?.response?.data?.errorMessage?.error_user_msg||e?.response?.data?.errorMessage?.message||"Something went wrong",snackStatus:"error"});const{action:t,assistant:a}=e?.response?.data||{};if("reconnect"===t&&a){const{fbConnected:e,fbUserId:t,fbGrantedScopes:n,selectedMetaPageId:s,selectedMetaAdAccountId:o,freezedMetaAdAccountId:i,freezedMetaPageId:r}=a||{};this.props.updateAssistantStore({fbConnected:e,fbUserId:t,fbGrantedScopes:n,selectedMetaPageId:s,selectedMetaAdAccountId:o,freezedMetaAdAccountId:i,freezedMetaPageId:r}),setTimeout((()=>{this.props.history.replace(Xe(_))}),2e3)}else if("accept_discrimination_policy"===t){const{link:e}=a||{};this.setState({errorAction:{link:e,name:"Follow the document to accept Facebook Non-Discrimination Policy"}})}else if("add_payment_method"===t){const{link:e}=a||{};this.setState({errorAction:{link:e,name:"Click to add Payment in your Ad Account"}})}else if("accept_lead_gen_tos"===t){const{link:e}=a||{};this.setState({errorAction:{link:e||"https://www.facebook.com/legal/leadgen/tos",name:"Accept Facebook's Lead Generation Terms of Service"}})}else"reconnect_meta_for_lead_ads"===t&&this.setState({errorAction:{link:`${Xe(this.props?.match?.params?.assistantId)}`,name:"Reconnect Meta Account for Lead Ads (pages_manage_ads permission required)",isInternalLink:!0}
1})}))};extractScheduledString(e){if(!e||!Array.isArray(e))return new Set;const t=new Set;for(let a of e){const e=a.start_minute/60,n=a.end_minute/60;for(let s=e;s<n;s++)for(let e of a.days)t.add(`${e}-${s}`)}for(let e=0;e<23;e++)for(let a=0;a<=7&&(7===a&&t.add(`${a}-${e}`),t.has(`${a}-${e}}`));a++);return t}getAdDataPayload=()=>{const{adName:e,adCaption:t,adHeadline:a,imageFile:n,thumbnailUrl:s,videoFile:o,uploadType:i,geoLocations:r,excludedGeoLocations:l,gender:d,FromAge:c,ToAge:p,advanceTargets:u,dailyBudget:m,duration:h,selectedPlatforms:g,selectedAudience:b,isEndDate:y}=this.state;let{fromDate:x,toDate:f}=this.state;const A=Zr()();x=Zr()(x).set({hour:A.hour(),minute:A.minute(),second:A.second(),millisecond:A.millisecond()}).toDate(),f=Zr()(f).set({hour:A.hour(),minute:A.minute(),second:A.second(),millisecond:A.millisecond()}).add(5,"seconds").toDate();let{assistantId:I,assistantName:C,partnerId:_,currency:S}=this.props.assistantDetails;const v=this.resolveAdAccountId(),E=this.resolveMetaPageId(),{adId:T}=this.props.match.params,D={adId:T,assistantId:I,assistantName:C,adAccountId:v,metaPageId:E,adDescription:t,adName:e,dailyBudget:"daily_budget"===this.state.selectedBudget.value?m:0,lifetimeBudget:"lifetime_budget"===this.state.selectedBudget.value?this.state.lifetimeBudget:0,..."carousel"!==this.state.adFormat?{headline:a,headlineDescription:this.state.adHeadlineDescription}:{},gender:d,minAge:parseInt(c),maxAge:parseInt(p),geoLocation:r,excludedGeoLocation:l,adStopDate:y?f:"",adStartDate:x,duration:h,advanceTargets:u,selectedPlatforms:g,audienceId:b?._id||"",duplicateAd:this.isDuplicateAd,pageDetails:this.props.pageDetails,iceBreakers:{status:!1},isScheduledAd:this.state.isScheduledAd,leadFormId:this.state.leadFormId||"",advantageAudience:this.state.advantageAudience?1:0};if(this.state.isScheduledAd){const e=op(this.state.selectedCells,this.state.selectedTimezone);D.adSetSchedule=e,D.timezoneType="viewer"===this.state.selectedTimezone.value?"USER":"ADVERTISER"}if(this.state.switchChecked){D.iceBreakers.status=!0,D.iceBreakers.iceBreakerNodeId=this.state.iceBreakerNodeId;const e=[],t=this.state.iceBreakers.filter((e=>{let{iceBreakerText:t}=e;return!!t})).map((t=>{let{iceBreakerText:a,flowId:n,iceBreakerId:s,blockId:o,blockHandle:i}=t;return e.push({iceBreaker:a,flowId:n.toString(),iceBreakerId:s,blockId:o,blockHandle:i}),{title:a}})),a={text:this.state.greetingMessage,ice_breakers:t};D.iceBreakers.rawMetaIceBreakers=a,D.iceBreakers.iceBreakerFlowMapping=e}return"carousel"===this.state.adFormat?(D.adFormat="carousel",D.cards=this.state.cards,D.carouselOptions=this.state.carouselOptions):"VIDEO_UPLOAD"===i?(D.videoUrl=o?.publicUrl,D.imageUrl="string"==typeof s?s:s?.publicUrl):"IMAGE_UPLOAD"===i&&(D.imageUrl=n?.publicUrl),D};handleSaveIceBreaker=async()=>{const e={iceBreakers:{status:!0,iceBreakerNodeId:this.state.iceBreakerNodeId}},t=[],a=this.state.iceBreakers.filter((e=>{let{iceBreakerText:t}=e;return!!t})).map((e=>{let{iceBreakerText:a,flowId:n,iceBreakerId:s,blockId:o,blockHandle:i}=e;return t.push({iceBreaker:a,flowId:n.toString(),iceBreakerId:s,blockId:o,blockHandle:i}),{title:a}})),n={text:this.state.greetingMessage,ice_breakers:a};e.iceBreakers.rawMetaIceBreakers=n,e.iceBreakers.iceBreakerFlowMapping=t;const{assistantId:s}=this.props.assistantDetails;try{this.setState({isIceBreakerSaving:!0});const t=await this.props.saveIceBreakersApi({assistantId:s,name:this.state.iceBreakerName,iceBreakers:e.iceBreakers});this.setState((e=>({snack:!0,snackMessage:"Ice Breakers Saved Successfully",snackStatus:"success",showSaveIceBreakerModal:!1,isIceBreakerSaving:!1,currSelectedSavedIceBreaker:t,savedIceBreakers:[t,...e.savedIceBreakers]})))}catch(e){console.log({error:e}),this.setState({snack:!0,snackMessage:e?.response?.data?.message||e?.response?.data?.errorMessage?.error_user_msg||"Something went wrong",snackStatus:"error",isIceBreakerSaving:!1})}};handleUpdateIceBreaker=async e=>{const t={iceBreakers:{status:!0,iceBreakerNodeId:this.state.iceBreakerNodeId}},a=[],n=this.state.iceBreakers.filter((e=>{let{iceBreakerText:t}=e;return!!t})).map((e=>{let{iceBreakerText:t,flowId:n,iceBreakerId:s,blockId:o,blockHandle:i}=e;return a.push({iceBreaker:t,flowId:n.toString(),iceBreakerId:s,blockId:o,blockHandle:i}),{title:t}})),s={text:this.state.greetingMessage,ice_breakers:n};t.iceBreakers.rawMetaIceBreakers=s,t.iceBreakers.iceBreakerFlowMapping=a;const{assistantId:o}=this.props.assistantDetails;try{this.setState({isIceBreakerSaving:!0});const a=await this.props.updateIceBreakersApi({_id:e,assistantId:o,name:this.state.iceBreakerName,iceBreakers:t.iceBreakers});this.setState({snack:!0,snackMessage:"Ice Breakers Updated Successfully",snackStatus:"success",showSaveIceBreakerModal:!1,isIceBreakerSaving:!1,currSelectedSavedIceBreaker:a})}catch(e){console.log({error:e}),this.setState({snack:!0,snackMessage:e?.response?.data?.message||e?.response?.data?.errorMessage?.error_user_msg||"Something went wrong",snackStatus:"error",isIceBreakerSaving:!1})}};hasCreativeChanges=()=>{const{originalCreativeData:e}=this.state;if(!e)return!1;const t={adName:this.state.adName,adCaption:this.state.adCaption,adHeadline:this.state.adHeadline,adHeadlineDescription:this.state.adHeadlineDescription,uploadType:this.state.uploadType,videoUrl:this.state.videoFile?.publicUrl,imageUrl:this.state.imageFile?.publicUrl||this.state.thumbnailUrl?.publicUrl,greetingMessage:this.state.greetingMessage,iceBreakers:this.state.iceBreakers,switchChecked:this.state.switchChecked,adFormat:this.state.adFormat,cards:this.state.cards,carouselOptions:this.state.carouselOptions},a=e=>null==e||""===e?null:e,n=(e,t)=>a(e)!==a(t),s=n(e.imageUrl,t.imageUrl),o=n(e.videoUrl,t.videoUrl);return e.adName!==t.adName||e.adCaption!==t.adCaption||e.adHeadline!==t.adHeadline||e.adHeadlineDescription!==t.adHeadlineDescription||e.uploadType!==t.uploadType||o||s||e.greetingMessage!==t.greetingMessage||e.switchChecked!==t.switchChecked||JSON.stringify(e.iceBreakers)!==JSON.stringify(t.iceBreakers)||(e.adFormat||"single")!==(t.adFormat||"single")||JSON.stringify(e.cards||[])!==JSON.stringify(t.cards||[])||JSON.stringify(e.carouselOptions||{})!==JSON.stringify(t.carouselOptions||{})};createDraftAd=()=>{this.setState({isLoading:!0});const{adName:e,adCaption:t,adHeadline:a,imageFile:n,thumbnailUrl:s,videoFile:o,uploadType:i,geoLocations:r,excludedGeoLocations:l,gender:d,FromAge:c,ToAge:p,advanceTargets:u,dailyBudget:m,duration:h,fromDate:g,toDate:b,selectedPlatforms:y,selectedAudience:x,isEndDate:f}=this.state;let{assistantId:A,assistantName:I,partnerId:C,currency:_}=this.props.assistantDetails;const S=this.resolveAdAccountId(),v=this.resolveMetaPageId(),{adId:E}=this.props.match.params,T={adId:E,assistantId:A,assistantName:I,adAccountId:S,metaPageId:v,adDescription:t,adName:e,dailyBudget:"daily_budget"===this.state.selectedBudget.value?m:0,..."carousel"!==this.state.adFormat?{headline:a,headlineDescription:this.state.adHeadlineDescription}:{},gender:d,minAge:parseInt(c),maxAge:parseInt(p),geoLocation:r,excludedGeoLocation:l,adStopDate:f?b:"",adStartDate:g,duration:h,advanceTargets:u,selectedPlatforms:y,audienceId:x?._id||"",duplicateAd:this.isDuplicateAd,iceBreakers:{status:!1},isScheduledAd:this.state.isScheduledAd,lifetimeBudget:"lifetime_budget"===this.state.selectedBudget.value?this.state.lifetimeBudget:0,ctaButton:this.state.ctaButton||"APPLY_NOW",websiteUrl:this.state.websiteUrl||"",adType:this.state.adType?.value||"",adObjective:this.state.adObjective?.value||"",optimizationGoal:this.state.optimizationGoal?.value||"",pixelId:this.state.pixel?.value||"",conversionEvent:this.state.conversionEvent?.value||"",adPlacements:this.state.adPlacements||{},customAndLookalikeAudiences:this.state.customAndLookalikeAudiences||[],excludedCustomAndLookalikeAudiences:this.state.excludedCustomAndLookalikeAudiences||[],leadFormId:this.state.leadFormId||"",leadFormAutomation:this.state.leadFormAutomation||null,advantageAudience:this.state.advantageAudience?1:0};if(this.state.isScheduledAd){const e=op(this.state.selectedCells,this.state.selectedTimezone);T.adSetSchedule=e,T.timezoneType="viewer"===this.state.selectedTimezone.value?"USER":"ADVERTISER"}if(this.state.switchChecked){T.iceBreakers.status=!0,T.iceBreakers.iceBreakerNodeId=this.state.iceBreakerNodeId;const e=[],t=this.state.iceBreakers.filter((e=>{let{iceBreakerText:t}=e;return!!t})).map((t=>{let{iceBreakerText:a,flowId:n,iceBreakerId:s,blockId:o,blockHandle:i}=t;return e.push({iceBreaker:a,flowId:n.toString(),iceBreakerId:s,blockId:o,blockHandle:i}),{title:a}})),a={text:this.state.greetingMessage,ice_breakers:t};T.iceBreakers.rawMetaIceBreakers=a,T.iceBreakers.iceBreakerFlowMapping=e}"carousel"===this.state.adFormat?(T.adFormat="carousel",T.cards=this.state.cards,T.carouselOptions=this.state.carouselOptions):"VIDEO_UPLOAD"===i?(T.videoUrl=o?.publicUrl,T.imageUrl="string"==typeof s?s:s?.publicUrl):"IMAGE_UPLOAD"===i&&(T.imageUrl=n?.publicUrl),i&&this.props.saveDraftAd(T).then((e=>{this.state.switchChecked&&this.updateFlowsNew(e),this.props.history.push(`${Xe(A)}`),this.setState({isLoading:!1,snack:!this.state.snack,snackMessage:"Ad saved  successfully",snackStatus:"success"})})).catch((e=>{console.log("error:",e),this.setState({isLoading:!1,snack:!0,snackMessage:e?.response?.data?.message||e?.response?.data?.errorMessage?.error_user_msg||"Something went wrong",snackStatus:"error"})}))};editAd=()=>{this.setState({isLoading:!0});const{adName:e,adCaption:t,adHeadline:a,imageFile:n,thumbnailUrl:s,videoFile:o,uploadType:i,geoLocations:r,excludedGeoLocations:l,gender:d,FromAge:c,ToAge:p,advanceTargets:u,dailyBudget:m,duration:h,fromDate:g,selectedPlatforms:b,selectedAudience:y,isEndDate:x}=this.state;let{toDate:f}=this.state,{assistantId:A,assistantName:I}=this.props.assistantDetails;const C=this.resolveAdAccountId(),_=this.resolveMetaPageId(),S=Zr()();f=Zr()(f).set({hour:S.hour(),minute:S.minute(),second:S.second(),millisecond:S.millisecond()}).add(5,"seconds").toDate();const{adId:v}=this.props.match.params,E={adId:v,assistantId:A,assistantName:I,adAccountId:C,metaPageId:_,adDescription:t,adName:e,dailyBudget:"daily_budget"===this.state.selectedBudget.value?m:0,..."carousel"!==this.state.adFormat?{headline:a,headlineDescription:this.state.adHeadlineDescription}:{},gender:d,minAge:parseInt(c),maxAge:parseInt(p),geoLocation:r,excludedGeoLocation:l,adStopDate:x?f:"",adStartDate:g,duration:h,advanceTargets:u,selectedPlatforms:b,audie
1nceId:y?._id||"",isScheduledAd:this.state.isScheduledAd,lifetimeBudget:this.state.lifetimeBudget,hasCreativeChanges:this.hasCreativeChanges(),websiteUrl:this.state.websiteUrl||"",ctaButton:this.state.ctaButton||"APPLY_NOW",adPlacements:this.state.adPlacements||{},customAndLookalikeAudiences:this.state.customAndLookalikeAudiences||[],excludedCustomAndLookalikeAudiences:this.state.excludedCustomAndLookalikeAudiences||[],adType:this.state.adType?.value||"",adObjective:this.state.adObjective?.value||"",optimizationGoal:this.state.optimizationGoal?.value||"",pixelId:this.state.pixel?.value||"",conversionEvent:this.state.conversionEvent?.value||"",leadFormId:this.state.leadFormId||"",leadFormAutomation:this.state.leadFormAutomation||null,advantageAudience:this.state.advantageAudience?1:0};if(this.state.isScheduledAd){const e=op(this.state.selectedCells,this.state.selectedTimezone);E.adSetSchedule=e,E.timezoneType="viewer"===this.state.selectedTimezone.value?"USER":"ADVERTISER"}if(this.state.switchChecked){E.iceBreakers={},E.iceBreakers.status=!0,E.iceBreakers.iceBreakerNodeId=this.state.iceBreakerNodeId;const e=[],t=this.state.iceBreakers.filter((e=>{let{iceBreakerText:t}=e;return!!t})).map((t=>{let{iceBreakerText:a,flowId:n,iceBreakerId:s,blockId:o,blockHandle:i}=t;return e.push({iceBreaker:a,flowId:n.toString(),iceBreakerId:s,blockId:o,blockHandle:i}),{title:a}})),a={text:this.state.greetingMessage,ice_breakers:t};E.iceBreakers.rawMetaIceBreakers=a,E.iceBreakers.iceBreakerFlowMapping=e}"carousel"===this.state.adFormat?(E.adFormat="carousel",E.cards=this.state.cards,E.carouselOptions=this.state.carouselOptions):"VIDEO_UPLOAD"===i?(E.videoUrl=o?.publicUrl,E.imageUrl="string"==typeof s?s:s?.publicUrl):"IMAGE_UPLOAD"===i&&(E.imageUrl=n?.publicUrl),i&&this.props.updateAd(E).then((e=>{this.state.switchChecked&&this.updateFlowsNew(e.newAdData),setTimeout((()=>{this.props.history.push(`${Xe(A)}/${v}/personal-analytics/`),this.setState({isLoading:!1,snack:!this.state.snack,snackMessage:"Ad saved  successfully",snackStatus:"success"})}),200)})).catch((e=>{console.log("error:",e),this.setState({isLoading:!1,snack:!0,snackMessage:e?.response?.data?.message||e?.response?.data?.errorMessage?.error_user_msg||"Something went wrong",snackStatus:"error"})}))};validateLinkChange=async e=>{const t=/^(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,10}\b([-a-zA-Z0-9()@:%_+.~#?&\/=]*)$/g,{value:a}=e.target;if(a){this.setState({validatingLink:!0});if(t.test(a))try{const{assistantId:e}=this.props.assistantDetails,t=await this.props.fetchWebMetaData({link:`https://${a}`,assistantId:e}),n=t?.documentDOC,s=(new DOMParser).parseFromString(n,"text/html"),o=s.querySelector("meta[property='og:description']")?.getAttribute("content"),i=s.querySelector("meta[property='og:image']")?.getAttribute("content");this.setState({errorLink:"",validatingLink:!1,linkMetaData:{linkTitle:s.title,linkDescription:o,linkImage:i}})}catch(e){console.log(e),this.setState({errorLink:"Invalid Website Link",validatingLink:!1,linkMetaData:{linkTitle:"",linkDescription:"",linkImage:""}})}else this.setState({errorLink:"Invalid Website Link",validatingLink:!1,linkMetaData:{linkTitle:"",linkDescription:"",linkImage:""}})}};nextSection=e=>{switch(e){case 0:return up(this.state,this.props.assistantDetails,0);case 1:return up(this.state,this.props.assistantDetails,1);case 2:return up(this.state,this.props.assistantDetails,2);default:return!1}};formatCompactCount=e=>{const t=this.props?.assistantDetails?.currency;return null==e||isNaN(e)?"—":"INR"===t?e>=1e7?(e/1e7).toFixed(1).replace(/\.0$/,"")+" Cr":e>=1e5?(e/1e5).toFixed(1).replace(/\.0$/,"")+" Lakh":e>=1e3?(e/1e3).toFixed(1).replace(/\.0$/,"")+" K":String(e):e>=1e6?(e/1e6).toFixed(1).replace(/\.0$/,"")+" Mn":e>=1e3?(e/1e3).toFixed(1).replace(/\.0$/,"")+" K":String(e)};formatNumber=(e,t)=>{const a="Monthly Active Users";return"INR"===t?e>=1e7?(e/1e7).toFixed(1).replace(/\.0$/,"")+" Cr "+a:e>=1e5?(e/1e5).toFixed(1).replace(/\.0$/,"")+" Lakh "+a:e>=1e3?(e/1e3).toFixed(1).replace(/\.0$/,"")+" K "+a:e+" "+a:"USD"===t?e>=1e6?(e/1e6).toFixed(1).replace(/\.0$/,"")+" Mn "+a:e>=1e3?(e/1e3).toFixed(1).replace(/\.0$/,"")+" K "+a:e+" "+a:e+" "+a};formatGeoLocationsSummary=e=>Object.entries(Object.entries(e||{}).reduce(((e,t)=>{let[a,n]=t;
1return"location_types"===a||(n||[]).forEach((t=>{const n={};Nd.A.forEach((e=>{n[e.isoCode]=e.name}));const s="string"==typeof t?n[t]||t:t.country_name;e[s]||(e[s]=[]),"countries"===a||e[s].push(`${t.name}${t.radius?` (${t.radius}km)`:""}${"zip"===t?.type?`, ${t?.region}`:""}`)})),e}),{})).map((e=>{let[t,a]=e;return a.length?`${t}${a.length?`${t?": ":""} ${a.join("; ")}`:""}`:t})).filter(Boolean).join(", ");handleSaveAudience=async()=>{const{audienceName:e,selectedAudience:t,isUpdateMode:a}=this.state,{gender:n,FromAge:s,ToAge:o,geoLocations:i,advanceTargets:r,selectedPlatforms:l,selectedLocations:d,excludedSelectedLocations:c}=this.state,{assistantId:p}=this.props.assistantDetails;if(e.trim())if(/[a-zA-Z]/.test(e)){this.setState({savingAudience:!0});try{const i={assistantId:p,audienceName:e.trim(),gender:n,minAge:parseInt(s),maxAge:parseInt(o),geoLocation:d,excludedGeoLocation:c,advanceTargets:r,selectedPlatforms:l};let u;u=a&&t._id?await this.props.updateAudience({audienceId:t._id,...i,assistantId:p}):await this.props.createAudience(i),this.setState({showSaveAudienceModal:!1,saveAudienceError:"",snack:!0,snackMessage:`Audience ${a?"updated":"saved"} successfully`,snackStatus:"success",savingAudience:!1,isUpdateMode:!1,keyThird:new Date,selectedAudience:u,audienceName:u.audienceName}),this.audienceFormRef.current&&this.audienceFormRef.current.loadLatestAudiences()}catch(e){this.setState({saveAudienceError:e?.response?.data?.errorMessage?.message||`Failed to ${a?"update":"save"} audience`,savingAudience:!1})}}else this.setState({saveAudienceError:"Audience name should contain at least one alphabet"});else this.setState({saveAudienceError:"Audience name is required"})};isValidUrl(e){let t;try{t=new window.URL(e)}catch(e){return!1}return"http:"===t.protocol||"https:"===t.protocol}checkAudienceChanged=()=>{const{selectedAudience:e}=this.state,{gender:t,FromAge:a,ToAge:n,selectedLocations:s,excludedSelectedLocations:o,advanceTargets:i,selectedPlatforms:r}=this.state;if(!e)return!1;const l=(e,t)=>{const a=e||[],n=t||[];if(a.length!==n.length)return!0;for(let e=0;e<n.length;e++)if(!a.some((t=>t.label===n[e].label&&t.value.radius===n[e].value.radius)))return!0;return!1},d=l(e.geoLocation,s)||l(e.excludedGeoLocation,o);let c=!as().isEqual((e.selectedPlatforms||[]).sort(),(r||[]).sort()),p=!1;const u=e.advanceTargets||{},m=i||{};for(const e of Object.keys(u)){const t=u[e]||[],a=m[e]||[],n=as().sortBy(t,"id"),s=as().sortBy(a,"id");if(!as().isEqual(n,s)){p=!0;break}}return e.gender!==t||e.minAge!==a||e.maxAge!==n||d||c||p};componentWillUnmount(){this.debouncedGetEstimatedDeliveryUsers&&this.debouncedGetEstimatedDeliveryUsers.cancel()}isValidAd=()=>{const e=mp(this.state,this.props.assistantDetails);return e?(this.setState({snackStatus:"warning",snackMessage:e,snack:!0}),!1):this.state.isLiveAD&&!this.isDuplicateAd||!Zr()(this.state.fromDate).startOf("day").isBefore(Zr()().startOf("day"))?!this.state.deprecatedAdvanceTargets?.length||!this.state.deprecatedAdvanceTargets.some((e=>!as().isEmpty(this.state.selectedAdvanceTargets)&&this.state.selectedAdvanceTargets.some((t=>t.value.id===e.id))))||(this.setState({snackStatus:"warning",snackMessage:"Some of your selected advanced targets are no longer supported by the platform. Please remove or replace them to ensure your Ad can be published.",snack:!0}),!1):(this.setState({snackStatus:"warning",snackMessage:"Invalid End Date",snack:!0}),!1)};validateTimeSlotsAgainstDateRange(){const e=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],t=this.state.adAccountData?.timezone,{fromDate:a,toDate:n,selectedCells:s}=this.state;if(!n)return{invalidSlots:[]};const o=new Set;let i=Zr().tz(a,t).startOf("day");const r=Zr().tz(n,t).endOf("day");if(r.diff(i,"days")>=6)return{invalidSlots:[]};for(;i.isSameOrBefore(r);)o.add(i.day()),i.add(1,"day");const l=[],d=new Set;for(const e of s){const[t]=e.split("-");if("7"===t)continue;const a=parseInt(t,10);o.has(a)||(l.push(e),d.add(a))}if(l.length>0){const n=[...d].map((t=>e[t])).join(", "),s=[];for(i=Zr().tz(a,t);i.isSameOrBefore(r);)s.push(e[i.day()]),i.add(1,"day");const o=[...new Set(s)];
1return{invalidSlots:l,message:`You have scheduled this ad set to run on ${n}. But the selected date range only includes ${1===o.length?o[0]:`${o[0]} to ${o[o.length-1]}`}. Please change your date range or schedule.`}}return{invalidSlots:[]}}validateAdvancedTargets=async(e,t)=>{try{if(!e||0===Object.keys(e).length)return;const a=await this.props.validateAdvancedTargeting({assistantId:t,advanceTargets:e});this.setState({deprecatedAdvanceTargets:a}),a&&Array.isArray(a)&&a.length>0&&this.setState({snackStatus:"warning",snackMessage:"Some of your selected advanced targets are no longer supported by the platform. Please remove or replace them to ensure your Ad can be published.",snack:!0})}catch(e){console.log("Error validating targets",e)}};carouselRequiresPerCardUrl=()=>ip(this.state);getCarouselFormatError=()=>rp(this.state);isValidCarouselUrl=e=>lp(e);getCardValidationError=(e,t,a)=>dp(e,t,a);isCarouselCreativeInvalid=()=>cp(this.state);getCarouselValidationError=()=>pp(this.state);nextBtnDisableStatus=e=>up(this.state,this.props.assistantDetails,e);getPublishTooltipMessage=()=>mp(this.state,this.props.assistantDetails);applyDefaultBudgets=(e,t)=>{const a={};this.state.dailyBudget||(a.dailyBudget=e),this.state.lifetimeBudget||(a.lifetimeBudget=t),Object.keys(a).length>0&&this.setState(a)};render(){var e=this;const{projectId:t}=this.props.match.params,{classes:a,history:n,assistantDetails:s}=this.props,{FromAge:i,ToAge:r,adAccountData:l,selectedPlatforms:d}=this.state,{accountId:c,accountName:p,currency:u}=l||{},m=window.innerWidth<532,g="INR"===(s?.adSetupDetails?.selectedMetaAdAccountId==c?s.currency:u),b=ea.xt[g?"INR":"USD"],y=g?500:b,x=ea.VO[g?"INR":"USD"],f=[{title:"Where should people go after clicking your ad?",description:"This choice determines the campaign setup and the results you can optimise for.",component:(0,h.jsx)(Dd,{parentState:this.state,changeState:this.changeState,isLiveAD:this.state.isLiveAD,isDuplicateAd:this.isDuplicateAd,isAdFetched:this.state.isAdFetched,isCreateAd:this.isCreateAd,isEditPage:this.isEditAd,assistantId:this.props?.assistantDetails?.assistantId}),isCompleted:up(this.state,this.props.assistantDetails,0)},{title:"Ad Targeting & Audience",description:"Select geo location in which you would like to ad. Select gender and age group of your audience",component:(0,h.jsx)(Zd,{parentState:this.state,changeAge:this.changeZage,changeState:this.changeState,FromAge:i,ToAge:r,heading:this.state.heading,geoLocations:this.state.geoLocations,excludedGeoLocations:this.state.excludedGeoLocations,selectedLocations:this.state.selectedLocations,excludedSelectedLocations:this.state.excludedSelectedLocations,linkMetaData:this.state.linkMetaData,selectedAdvanceTargets:this.state.selectedAdvanceTargets,getEstimatedDeliveryUsers:this.getEstimatedDeliveryUsers,selectedPlatforms:this.state.selectedPlatforms,isEditPage:this.isEditAd,deprecatedAdvanceTargets:this.state.deprecatedAdvanceTargets},this.state.keyThird),isCompleted:up(this.state,this.props.assistantDetails,2)},{title:"Ad Budget",description:"Select daily budget you would like to spend on an ad. Select the time period for which an ad will run",component:(0,h.jsx)(Zp,{parentState:this.state,adAccountData:this.state.adAccountData,handleToDateChange:this.handleToDateChange,handleFromDateChange:this.handleFromDateChange,changeState:this.changeState,isLiveAD:this.state.isLiveAD},this.state.keyThird),isCompleted:up(this.state,this.props.assistantDetails,3)},{title:"Ad Creative",description:"Provide details to create ad creative and preview. Ad will have similar as shown in preview",component:(0,h.jsx)(Sd,{parentState:this.state,changeState:this.changeState,isLiveAD:this.state?.isLiveAD,onGenerationStateChange:this.handleGenerationStateChange}),isCompleted:up(this.state,this.props.assistantDetails,1)}];"ctwa"!==this.state.adType?.value&&"whatsapp_status"!==this.state.adType?.value||f.push({title:"Icebreakers (Optional)",description:"Set actions like ad level icebreakers for your ads and connect flows with your icebreaker messages",component:(0,h.jsx)(Xc,{totalAdsCount:this.state.totalAdsCount,flows:this.props.flows,changeState:this.changeState,greetingMessage:this.state.greetingMessage,iceBreakers:this.state.iceBreakers,switchChecked:this.state.switchChecked,isDefaultIceBreakerOn:this.state.isDefaultIceBreakerOn,defaultGreetingMsg:this.state.defaultGreetingMsg,defaultIceBreakers:this.state.defaultIceBreakers,isLiveAD:this.state.isLiveAD,isAdFetched:this.state.isAdFetched,pageDetails:this.props.pageDetails,debouncedUpdateIceBreakers:this.debouncedUpdateIceBreakers,iceBreakerName:this.state.iceBreakerName,isIceBreakerSaving:this.state.isIceBreakerSaving,showSaveIceBreakerModal:this.state.showSaveIceBreakerModal,handleSaveIceBreaker:this.handleSaveIceBreaker,iceBreakerNodeId:this.state.iceBreakerNodeId,areIceBreakersModified:this.areIceBreakersModified,handleUpdateIceBreaker:this.handleUpdateIceBreaker,currSelectedSavedIceBreaker:this.state.currSelectedSavedIceBreaker,savedIceBreakers:this.state.savedIceBreakers}),isCompleted:up(this.state,this.props.assistantDetails,4)});const{adCaption:A,adHeadline:I,imageFile:C,videoFile:_,thumbnailUrl:S,uploadType:v}=this.state,{isLiveAD:E,isAdFetched:T}=this.state,D=!T&&this.isEditAd||this.isEditAd&&T&&E;return(0,h.jsxs)("div",{className:`${a.root} ginger-page-root`,children:[(0,h.jsx)($p,{classes:a,mobileScreen:m,adId:this.props.match.params.adId,isDuplicateAd:this.isDuplicateAd,assistantDetails:this.props.assistantDetails,onBack:this.toggleDialog,onShowCredit:this.toggleAdCreditDialog}),(0,h.jsxs)(o.Grid,{container:!0,justify:"center",children:[(0,h.jsxs)(o.Grid,{item:!0,className:a.formContainer,children:[(0,h.jsx)(tu,{classes:a,defaultDailyBudget:y,defaultLifetimeBudget:x,isIceBreakerNotEditable:D,isLiveAD:E,steps:f,activeStep:this.state.activeStep,adType:this.state.adType,isAdFetched:this.state.isAdFetched,isLoading:this.state.isLoading,showPreview:this.state.showPreview,switchChecked:this.state.switchChecked,exp
1andedSections:this.state.expandedSections,applyDefaultBudgets:this.applyDefaultBudgets,changeState:this.changeState,checkAudienceChanged:this.checkAudienceChanged,createAd:this.createAd,editAd:this.editAd,isCreateAd:this.isCreateAd,isDuplicateAd:this.isDuplicateAd,isValidAd:this.isValidAd,nextSection:this.nextSection,setState:function(){return e.setState(...arguments)}}),(0,h.jsx)(Jp,{adCaption:A,adHeadline:I,assistantDetails:s,currency:u,imageFile:C,thumbnailUrl:S,uploadType:v,videoFile:_,classes:a,adHeadlineDescription:this.state.adHeadlineDescription,adType:this.state.adType,ctaButton:this.state.ctaButton,estimatedDailyResults:this.state.estimatedDailyResults,estimatedData:this.state.estimatedData,estimatedReachLoading:this.state.estimatedReachLoading,showPreview:this.state.showPreview,websiteUrl:this.state.websiteUrl,pageDetails:this.props.pageDetails,formatCompactCount:this.formatCompactCount,formatNumber:this.formatNumber,getEstimatedDeliveryUsers:this.getEstimatedDeliveryUsers,adFormat:this.state.adFormat,cards:this.state.cards,activeCardIndex:this.state.previewCardIndex??0,onActiveCardChange:e=>this.changeState("previewCardIndex",e)})]}),this.state.currSelectedFlowId&&this.props.isFlowPopupOpen&&(0,h.jsx)("div",{style:{position:"absolute",width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",bottom:0,left:0,zIndex:1e3,backgroundColor:"rgba(0, 0, 0, 0.5)"},children:(0,h.jsx)("div",{style:{zIndex:100,border:"none",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)",overflow:"hidden"},className:a.flowPageContainer,children:(0,h.jsx)(ep,{flowId:this.state.currSelectedFlowId,projectId:this.props.assistantDetails?.assistantId,iceBreakerNodeId:this.state.iceBreakerNodeId,prevIceBreakerNodeId:this.state.prevIceBreakerNodeId,localIceBreakers:this.state.iceBreakers,currSelectedFlowId:this.state.currSelectedFlowId,adData:this.getAdDataPayload()})})})]}),(0,h.jsx)(Qp,{classes:a,projectId:t,history:n,showDialog:this.state.showDialog,isLoading:this.state.isLoading,onClose:this.toggleDialog,onSaveDraft:this.createDraftAd,exitPath:this.exitPath}),(0,h.jsx)(eu,{classes:a,showSaveAudienceModal:this.state.showSaveAudienceModal,audienceName:this.state.audienceName,savingAudience:this.state.savingAudience,saveAudienceError:this.state.saveAudienceError,selectedAudience:this.state.selectedAudience,geoLocations:this.state.geoLocations,excludedGeoLocations:this.state.excludedGeoLocations,selectedAdvanceTargets:this.state.selectedAdvanceTargets,selectedPlatforms:this.state.selectedPlatforms,advantageAudience:this.state.advantageAudience,gender:this.state.gender,FromAge:this.state.FromAge,ToAge:this.state.ToAge,setState:function(){return e.setState(...arguments)},checkAudienceChanged:this.checkAudienceChanged,formatGeoLocationsSummary:this.formatGeoLocationsSummary,handleSaveAudience:this.handleSaveAudience}),(0,h.jsx)(qp,{classes:a,snack:this.state.snack,snackStatus:this.state.snackStatus,snackMessage:this.state.snackMessage,setState:function(){return e.setState(...arguments)}}),(0,h.jsx)(Xp,{errorAction:this.state.errorAction,history:this.props.history,onClose:()=>this.setState({errorAction:{}})}),(0,h.jsx)(B,{name:"metaAdsCreditDialog",dialogOpen:this.state.adDialogOpen,toggleTemplateCreditDialog:this.toggleAdCreditDialog,assistantDetails:this.props.assistantDetails})]})}}const nu=(0,i.connect)((e=>({pageDetails:e.ads.pageDetails,assistantDetails:e.assistantDetails.data,iceBreakers:e.assistantDetails.iceBreakers,adSetupDetails:e.assistantDetails.adSetupDetails,flows:[...e.flow.flows],isFlowPopupOpen:e.assistantDetails.isFlowPopupOpen,pixels:e.audience.pixels,adAccountInsights:e.ads.adAccountInsights})),{updatePageDetails:_n.vW,updateAssistantStore:$.nt,updateAdSetupStore:$.jW,createnewAds:_n.lw,FetchBudget:_n.qV,FetchDetails:_n.$g,FetchNames:_n.TH,getFlows:Kc.Qj,fetchTemplateMessages:Qc.Nk,createNode:Kc.RM,createIceBreakerNode:Kc.Ux,updateIceBreakers:$.W$,recreateAllIceBreakerNodes:Kc.Jl,fetchPixels:z.aR,fetchAdAccountInsights:_n.Qd,loadAd:hp.s3,loadAdAccount:hp.bO,loadPage:hp.wu,publishAd:hp.RI,saveDraftAd:hp.ap,updateAd:hp.hI,fetchMetaAdSetup:M.cg,fetchWebMetaData:gi.SX,getDeliveryEstimate:gi.n3,fetchAudienceById:gi.xi,createAudience:gi.PS,updateAudience:gi.uF,validateAdvancedTargeting:gi.s9,saveIceBreakersApi:gi.JX,updateIceBreakersApi:gi.D,updateFlow:gi.NF})(au),su=(0,o.withStyles)((e=>({root:{height:"100%",overflowY:"scroll",background:"#f9f9f9"},formContainer:{width:"85%",minWidth:0,background:"transparent",display:"flex",padding:"20px 0px",justifyContent:"space-between",boxSizing:"border-box",gap:"20px",[e.breakpoints.down("sm")]:{flexDirection:"column",width:"100%",padding:"10px"}},stepContainer:{display:"flex",flexDirection:"column",gap:"16px",transition:"0.2s all",flex:1,minWidth:0},buttonContainer:{width:"100%"},pageTitleContainer:{position:"sticky",zIndex:101,top:0,boxSizing:"border-box",boxShadow:"0 0 11px rgb(230 230 230)",[e.breakpoints.down("md")]:{},[e.breakpoints.down("sm")]:{},background:"white",padding:"16px 24px"},pageTitleContainer2:{position:"sticky",zIndex:100,top:60,boxSizing:"border-box",paddingBottom:"1.2em",background:"rgb(251, 251, 251)"},stepLabel:{'& [class*="MuiStepLabel-label"]':{marginTop:"4px"}},accordianCompeted:{borderBottom:"4px solid #27c152"},accordian:{borderRadius:8,transition:"0.3s",boxShadow:"0 0 11px rgb(230,230,230)"}
1,accordianSummary:{paddingLeft:"0px","&.Mui-expanded":{minHeight:"48px"},'& [class*="MuiAccordionSummary-content"].Mui-expanded':{margin:"0px"},'& [class*="MuiAccordionSummary-content"]':{margin:"0px"}},accordianDetail:{padding:"20px 8px 8px 8px",display:"block"},stepIcon:{'& [class*="MuiSvgIcon-root"]':{fontSize:"25px"}},stepTitle:{color:"darkslategrey",fontWeight:"bolder"},checked:{position:"absolute",bottom:-6,left:16,color:"#27c152",background:"white",borderRadius:20,fontSize:"20px"},watsappCheck:{color:"#27c152",marginRight:8},templates:{border:"1px solid lightgrey",borderRadius:8,overflowX:"auto",[e.breakpoints.up("sm")]:{padding:20},[e.breakpoints.down("sm")]:{padding:12}},addTemplate:{float:"right"},dialogTitle:{padding:"24px 0 8px 32px"},dialogContent:{paddingTop:0},razorpayConnect:{backgroundColor:"#3295fe",color:"white",padding:"6px 25px","&:hover":{backgroundColor:"#3295fe"}},stepsContentBlock:{background:"white",borderBottom:"4px solid transparent",padding:"20px 20px 20px 20px",borderRadius:"8px",minWidth:0,"&:hover":{boxShadow:"0 0 11px rgb(230,230,230)"},[e.breakpoints.down("sm")]:{padding:"10px"}},stepsContentBlockPaddingRemove:{padding:"20px 20px 0px 20px",[e.breakpoints.down("sm")]:{padding:"10px 10px 0px 10px"}},actionBtn2:{fontSize:"14px",fontWeight:"500",borderRadius:"5px",border:`1px solid ${e.palette.primary.main}`,padding:"2px 12px",background:e.palette.primary.main,color:"white",height:"40px","&:hover":{cursor:"pointer",background:"#073135"}},disabledBtn:{background:"rgba(0, 0, 0, 0.12)",color:"rgba(0, 0, 0, 0.26)",border:"none"},dialogWrapper:{display:"flex",justifyContent:"space-between",alignItems:"center"},saveAudienceDialogWrapper:{display:"flex",justifyContent:"space-between",alignItems:"center",[e.breakpoints.down("xs")]:{alignItems:"flex-start",paddingRight:"24px",width:"100%",boxSizing:"border-box"}},icon:{marginRight:24,"&:hover":{cursor:"pointer"}},saveAudienceCloseIcon:{marginRight:24,"&:hover":{cursor:"pointer"},[e.breakpoints.down("xs")]:{display:"none"}},dialogTitle:{'& [class*="MuiTypography-h6"]':{fontSize:20,fontWeight:600,color:"rgb(0,0,0,0.87)"}},rotationIcon:{animation:"adsSpinnerRotation 2s infinite linear"},"@keyframes rotation":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(359deg)"}},snackbar:{zIndex:3e3,top:70},saveAudienceBtnContainer:{display:"flex",gap:"8px",[e.breakpoints.down("xs")]:{flexDirection:"column",width:"100%"}},dialogSaveBtn:{[e.breakpoints.down("xs")]:{width:"100%"}},saveAudienceBtn:{padding:"8px 16px",borderRadius:"8px",fontSize:"14px",fontWeight:"500"},audienceDetailValues:{[e.breakpoints.down("xs")]:{marginTop:"-8px"}},saveAudienceDialogTitle:{[e.breakpoints.down("xs")]:{maxWidth:"100%"}},flowPageContainer:{width:"calc(85% - 10px)",marginRight:"10px",height:"80%",borderRadius:"8px",[e.breakpoints.down("800")]:{width:"100vw",height:"100vh",marginRight:0,borderRadius:0}},rotationIcon:{animation:"adsSpinnerRotation 2s infinite linear"},publishBtnContainer:{display:"flex",justifyContent:"flex-end",[e.breakpoints.down(700)]:{justifyContent:"space-between",alignItems:"stretch",position:"absolute",bottom:"50px",width:"100%",right:0,gap:"10px",paddingTop:"10px",boxShadow:"0 -4px 6px -2px rgba(0, 0, 0, 0.05)",paddingBottom:"10px",background:"white",borderTop:"1px solid #e8e8e8",zIndex:99}},publishBtn:{display:"flex",maxWidth:"300px",paddingTop:"10px",paddingBottom:"10px",zIndex:100,alignItems:"center",[e.breakpoints.down(700)]:{width:"100%",maxWidth:"100%",marginRight:"10px"}},previewBtn:{display:"none",[e.breakpoints.down(700)]:{display:"flex",width:"100%",paddingTop:"10px",paddingBottom:"10px",zIndex:99,backgroundColor:"white",marginLeft:"10px",background:"white",gap:"5px",alignItems:"center"}}})))((0,r.withRouter)(nu));var ou=a(89600),iu=a(54185);const ru=ve()(),lu={All:{fromDate:"",toDate:ru},Today:{fromDate:ru.clone().startOf("day"),toDate:ru},Yesterday:{fromDate:ru.clone().subtract(1,"days").startOf("day"),toDate:ru.clone().subtract(1,"days").endOf("day")},"Last 7 days":{fromDate:ru.clone().subtract(7,"days").startOf("day"),toDate:ru},"Last 30 days":{fromDate:ru.clone().subtract(30,"days").endOf("day"),toDate:ru}}
1,du=[{field:"User Name",size:3,key:"userName"},{field:"User Number",size:3,key:"userNumber"},{field:"Messages",size:2,key:"messages"},{field:"Lead Type",size:2,key:"leadType"},{field:"Sent At",size:2,key:"sent"}];function cu(e){let{classes:t,item:a,field:n,sort:s,...i}=e;const r={new:"#28c152",existing:"#ff8400",default:"#ff453b"};switch(n){case"Loading":return(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsx)(o.Box,{py:2,pl:2,children:(0,h.jsx)(O.Skeleton,{variant:"rect",width:"100%",style:{borderRadius:"15px"}})})});case"sent":return(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsx)(o.Box,{py:2,pl:2,children:(0,h.jsx)(o.Typography,{variant:"body1",children:ve()(a.sentAt,"YYYY-MM-DD").format("DD MMM YYYY")})})});case"leadType":return(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsx)(o.Box,{py:2,pl:2,children:(0,h.jsx)(o.Chip,{size:"small",label:a[n]?(0,ts.startCase)(a[n]):"NA",className:t.qualityStatus,style:{background:a[n]?r[a[n]]:r.default}})})});default:return(0,h.jsx)(o.Grid,{item:!0,xs:!0,children:(0,h.jsx)(o.Box,{py:2,pl:2,children:(0,h.jsx)(o.Typography,{variant:"h5",children:a[n]})})})}}const pu=e=>{let{adId:t,adData:a,assistantId:r,classes:l,assistantDetails:c,dataRange:p}=e;const u=(0,i.useDispatch)(),[m,g]=(0,n.useState)(""),[b,y]=(0,n.useState)(0),[x,f]=(0,n.useState)(Array(10).fill(0).map((e=>({name:"Loading"}
1)))),[A,I]=(0,n.useState)("All"),[C,_]=(0,n.useState)(a?.adStartDate?ve()(a.adStartDate):lu.All.fromDate),[S,v]=(0,n.useState)(lu.All.toDate),[E,T]=(0,n.useState)(null),[D,w]=(0,n.useState)(0),[N,j]=(0,n.useState)(10),[k,L]=(0,n.useState)(!1),[R,P]=(0,n.useState)([]),[M,U]=(0,n.useState)([]),[F,W]=(0,n.useState)(!0),[z,G]=(0,n.useState)(!1),[H,V]=(0,n.useState)(!1),[Y,Z]=(0,n.useState)(!1),[K,J]=(0,n.useState)(!1),[$,q]=(0,n.useState)(-1),[X,Q]=(0,n.useState)(0),[ee,te]=(0,n.useState)(null),[ae,ne]=(0,n.useState)(null),[se,oe]=(0,n.useState)(0),[ie,re]=(0,n.useState)(0),le=(0,n.useCallback)(((e,t,a,n,s,o,i)=>{const l=r||c?.assistantId;e&&l&&(W(!0),u((0,uo.ic)({assistantId:l,adId:e,limit:void 0!==a?a:N,page:void 0!==t?t:D,leadType:void 0!==n?n:m,startDate:void 0!==o?o:C,endDate:void 0!==i?i:S,sort:void 0!==s?s:$})).then((e=>{f(e.mongoAdAnalyticsData||[]),y(e.count||0),W(!1)})).catch((e=>{console.log("error:",e),W(!1)})))}),[r,c,N,D,m,C,S,$,u]),de=(0,n.useCallback)(((e,a,n,s)=>{const o=r||c?.assistantId;u((0,uo.iI)({adId:e||t,assistantId:o,startDate:void 0!==a?a:C,endDate:void 0!==n?n:S,leadType:void 0!==s?s:m})).then((e=>{Q(e.optedCount||0)})).catch((e=>console.log("error:",e)))}),[t,r,c,C,S,m,u]),ce=(0,n.useCallback)((()=>{const e=r||c?.assistantId;e&&(0,_n.QO)(e).then((e=>{const{dailyTemplateLimit:t,consumedTemplateLimitQuota:a}=e;oe(t||0),re(a||0)})).catch((e=>{console.error(e)}))}),[r,c]),pe=(0,n.useCallback)((()=>{L((e=>!e)),P([]),U([])}),[]),ue=(0,n.useCallback)((e=>{P((t=>t.some((t=>t.userNumber===e.userNumber))?t.filter((t=>t.userNumber!==e.userNumber)):[...t,e]))}),[]),me=(0,n.useCallback)((e=>{U((t=>t.some((t=>t.userNumber===e.userNumber))?t.filter((t=>t.userNumber!==e.userNumber)):[...t,e]))}),[]),he=(0,n.useCallback)((()=>{const e=r||c?.assistantId;G(!0),u((0,uo.qM)({selectAll:k,adId:t,assistantId:e,selected:R.map((e=>e.userNumber)),unSelected:M.map((e=>e.userNumber)),startDate:C,endDate:S,leadType:m})).then((e=>{const{csv:t}=e;var a=document.createElement("a"),n=new Blob(["\ufeff",t]),s=window.URL.createObjectURL(n);a.href=s,a.download="META AUDIENCE.csv",document.body.appendChild(a),a.click(),document.body.removeChild(a),G(!1),Z(!1)})).catch((e=>{console.log(e),G(!1)}))}),[r,c,k,t,R,M,C,S,m,u]),ge=(0,n.useCallback)((()=>{if(!va("broadcastCampaign"))return;const e=r||c?.assistantId;R.length>0?(V(!0),u((0,uo.ZK)({assistantId:e,userNumberArray:R})).then((e=>{V(!1),te(e.optedoutLenght),J(!0)})).catch((e=>{V(!1)}))):M.length>0?(V(!0),u((0,uo.ZK)({assistantId:e,userNumberArray:M})).then((e=>{ne(e.optedoutLenght),V(!1),J(!0)})).catch((e=>{V(!1)}))):(V(!1),J(!0))}),[r,c,R,M,u]),be=(0,n.useCallback)(((e,a)=>{const n=a-D;-1!==n&&1!==n||(w(a),le(t,a))}),[D,t,le]),ye=(0,n.useCallback)((e=>{const a=parseInt(e.target.value);j(a),w(0),le(t,0,a)}),[t,le]);(0,n.useEffect)((()=>{le(t,0,N,m,$,p?.startDate,p?.endDate),de(t,p?.startDate,p?.endDate,m)}),[p,t,m,$,le,de]);const xe=(0,n.useCallback)((()=>{const e=-1===$?1:-1;q(e),le(t,D,N,m,e)}),[$,t,D,N,m,le]),fe=(0,n.useCallback)((()=>{J(!1)}),[]),Ae=(0,n.useCallback)((()=>{Z(!1)}),[]),Ie=(0,n.useCallback)((e=>{g(e),w(0),L(!1),P([]),U([]),le(t,0,N,e,$,C,S),de(t,C,S,e)}),[t,N,$,C,S,le,de]);if((0,n.useEffect)((()=>{t&&(a?.adStartDate&&_(ve()(a.adStartDate)),le(t),de(t),ce())}),[t]),"website_traffic"===a?.adType)return null;const Ce=k?b-M.length:R.length;return(0,h.jsxs)(o.Grid,{item:!0,xs:12,children:[(0,h.jsxs)(o.Grid,{container:!0,alignItems:"center",className:l.dateFilterContainer,children:[(0,h.jsx)(o.Box,{width:"100%",marginBottom:"1em",children:(0,h.jsxs)(o.Grid,{container:!0,spacing:1,item:!0,xs:12,md:6,alignItems:"center",children:[(0,h.jsx)(o.Grid,{item:!0,children:(0,h.jsx)(o.Typography,{color:"textPrimary",variant:"body1",style:{marginRight:"0.3em"},children:"Lead Type"})}),(0,h.jsx)(o.Grid,{item:!0,children:(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Checkbox,{checked:"new"===m,onChange:e=>{Ie(e.target.checked?"new":"")},color:"primary"}),label:"New Leads"})}),(0,h.jsx)(o.Grid,{item:!0,children:(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Checkbox,{checked:"existing"===m,onChange:e=>{Ie(e.target.checked?"existing":"")},color:"primary"}),label:"Existing Users"})})]})}),(0,h.jsxs)(o.Box,{className:l.exportContainer,children:[(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"h4",component:"span",children:"Audience"}),(0,h.jsx)(o.Typography,{color:"textSecondary",variant:"body1",children:`${b} user${b>1?"s have":" has"} send message on advertisement click`})]}),(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Button,{variant:"outlined",size:"medium",color:"primary",onClick:()=>{Z(!0)},endIcon:z?(0,h.jsx)(o.CircularProgress,{size:18}):"",style:{marginRight:8},disabled:z||F||!Ce,children:"Export"}),va("broadcastCampaign")&&(0,h.jsx)(o.Button,{color:"primary",onClick:ge,startIcon:(0,h.jsx)(d.Telegram,{}),endIcon:H?(0,h.jsx)(o.CircularProgress,{size:18}):(0,h.jsx)(h.Fragment,{}),variant:"contained",disabled:H||F||!Ce,children:"BROADCAST"})]})]}),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Box,{overflow:"auto hidden",zIndex:"1",width:"100%",border:"1px solid lightgrey",borderRadius:"8px",children:(0,h.jsxs)(o.Grid,{item:!0,container:!0,style:{width:"100%"},children:[(0,h.jsx)(o.Grid,{item:!0,style:{padding:"8px 16px",maxWidth:50},children:F?(0,h.jsx)(O.Skeleton,{variant:"rect",width:"24px",style:{borderRadius:"15p
1x",marginTop:12}}):(0,h.jsx)(o.Checkbox,{color:"primary",checked:k,disabled:!x?.length,onChange:pe})}),(0,h.jsx)(o.Grid,{item:!0,container:!0,className:l.tableHeader,children:du.map((e=>(0,h.jsxs)(o.Grid,{item:!0,xs:e.size,style:{display:"flex",alignItems:"center"},onClick:xe,children:[(0,h.jsx)(o.Box,{py:2,pl:2,children:(0,h.jsx)(o.Typography,{variant:"h5",color:"primary",children:e.field})}),"Sent At"==e.field?-1==$?(0,h.jsx)(ou.A,{className:l.sort}):(0,h.jsx)(iu.A,{className:l.sort}):(0,h.jsx)(h.Fragment,{})]},e.key)))}),x.length?x.map(((e,t)=>(0,h.jsxs)(s().Fragment,{children:[(0,h.jsx)(o.Grid,{item:!0,style:{background:t%2==0?"#f6f6f6":"white",padding:"11px 16px",maxWidth:50,margin:"auto"},children:F?(0,h.jsx)(O.Skeleton,{variant:"rect",width:"24px",style:{borderRadius:"15px",marginTop:12}}):(0,h.jsx)(o.Checkbox,{color:"primary",checked:k?!M.some((t=>t.userNumber===e.userNumber)):R.some((t=>t.userNumber===e.userNumber)),onChange:()=>{k?me(e):ue(e)}})}),(0,h.jsx)(o.Grid,{item:!0,container:!0,className:l.tableItem,style:{background:t%2==0?"#f6f6f6":"white"},children:du.map((t=>(0,h.jsx)(o.Grid,{item:!0,xs:t.size,style:{overflowWrap:"anywhere",margin:"auto"},children:(0,h.jsx)(cu,{classes:l,item:e,sort:$,field:F?"Loading":t.key})},t.key)))})]},e._id||t))):(0,h.jsx)(o.Box,{height:"400px",display:"flex",width:"100%",style:{justifyContent:"center",alignItems:"center"},children:(0,h.jsx)(o.Typography,{color:"textSecondary",variant:"h4",className:l.emptyMessage,children:"Audience not found"})})]})}),(0,h.jsx)("div",{className:l.fixedBottomContainer,children:(0,h.jsx)(o.TablePagination,{component:"div",count:b,page:D,onChangePage:be,rowsPerPage:N,onChangeRowsPerPage:ye})})]})]}),(0,h.jsx)(o.Dialog,{open:K,maxWidth:"md",fullWidth:!0,children:(0,h.jsx)(B,{name:"broadcastCampaign",closeDialog:fe,totalSelected:Ce,selected:R,unSelected:M,selectAll:k,adId:t,leadType:m,dailyTemplateLimit:se,consumedQuota:ie,metaAudienceCampaign:!0,optedCount:X,selectedOptNo:ee,unSelectedOptNo:ae,audienceFromDate:C,audienceToDate:S})}),(0,h.jsx)(o.Dialog,{open:Y,onClose:Ae,maxWidth:"md",fullWidth:!0,disableBackdropClick:!0,children:(0,h.jsx)(o.Box,{display:"flex",flexDirection:"column",p:3,justifyContent:"center",children:(0,h.jsxs)(o.Grid,{container:!0,justify:"center",children:[(0,h.jsx)(o.Grid,{item:!0,xs:12,children:(0,h.jsxs)(o.Typography,{variant:"h5",align:"center",children:["Total contacts selected: ",Ce]})}),(0,h.jsx)(o.Box,{width:"100%",height:"1em"}),(0,h.jsxs)(o.Grid,{item:!0,container:!0,justify:"center",children:[(0,h.jsx)(o.Box,{p:"0em 1em",children:(0,h.jsx)(o.Button,{variant:"outlined",size:"medium",color:"primary",onClick:Ae,children:"Cancel"})}),(0,h.jsx)(o.Button,{variant:"contained",size:"medium",color:"primary",onClick:he,children:"Export"})]})]})})})]})},uu=(0,_e.makeStyles)((e=>({listRoot:{border:"1px solid lightgrey",borderRadius:10,background:"white",overflow:"hidden",marginTop:e.spacing(2)},scrollContainer:{width:"100%",overflowX:"auto",overflowY:"hidden"},table:{width:"100%",minWidth:900,borderCollapse:"collapse",borderSpacing:0},headRow:{"& th":{position:"sticky",top:0,zIndex:2,textAlign:"left",height:50,boxSizing:"border-box",color:e.palette.text.secondary,backgroundColor:"rgb(252,252,252)",padding:e.spacing(2),whiteSpace:"nowrap"}},loadingState:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},emptyState:{padding:"48px 24px",textAlign:"center",color:e.palette.text.secondary},footer:{display:"flex",alignItems:"center",justifyContent:"center",borderTop:"1px solid lightgrey",padding:e.spacing(1,0)},toolbar:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:e.spacing(2),flexWrap:"wrap",marginTop:e.spacing(2)},openInLeads:{textTransform:"none",fontSize:"13px",whiteSpace:"nowrap"},alert:{marginTop:e.spacing(2),borderRadius:8}}))),mu=dn.filter((e=>"interactions"!==e.key)),hu=e=>{let{assistantId:t,adId:a}=e;const s=uu(),o=(0,i.useDispatch)(),[l,d]=(0,n.useState)([]),[c,p]=(0,n.useState)(0),[u,m]=(0,n.useState)(!1),[g,b]=(0,n.useState)(null),[y,x]=(0,n.useState)(0),[f,A]=(0,n.useState)(10),[I,C]=(0,n.use
1State)(-1),[_,S]=(0,n.useState)(!1),[v,E]=(0,n.useState)([]),[T,D]=(0,n.useState)([]),[w,N]=(0,n.useState)(!1),[j,k]=(0,n.useState)(0),[L,R]=(0,n.useState)(0),[O,P]=(0,n.useState)(!1),[M,U]=(0,n.useState)({dailyTemplateLimit:null,consumedQuota:null}),F=(0,n.useRef)(0);(0,n.useEffect)((()=>{if(!t)return;let e=!1;return(0,_n.QO)(t).then((t=>{!e&&t&&U({dailyTemplateLimit:t.dailyTemplateLimit,consumedQuota:t.consumedTemplateLimitQuota})})).catch((()=>{})),()=>{e=!0}}),[t]),(0,n.useEffect)((()=>{if(!t||!a)return;let e=!1;m(!0),b(null);const n=++F.current;return Sn({assistantId:t,type:"form",adId:a,page:y+1,limit:f}).then((t=>{e||n!==F.current||(t?.status?(d(t.data||[]),p(t.pagination?.total||0)):b(t?.message||"Failed to fetch leads"))})).catch((t=>{e||n!==F.current||b(t?.response?.data?.message||"Failed to fetch leads")})).finally((()=>{e||n!==F.current||m(!1)})),()=>{e=!0}}),[t,a,y,f]);const W=(0,n.useCallback)(((e,t)=>{C(t)}),[]),z=I>=0?l[I]:null,G=e=>{const t=Ja(e);return t&&t.startsWith("+")?t.slice(1):t},H=e=>{const t=G(e);return _?!T.includes(t):v.includes(t)},V=_?Math.max(0,c-T.length):v.length,Y=_&&0===T.length,Z=_?T.length>0:v.length>0,K=(e,t)=>{const a=G(e);a&&(_?D((e=>t?e.filter((e=>e!==a)):e.includes(a)?e:[...e,a])):E((e=>t?e.includes(a)?e:[...e,a]:e.filter((e=>e!==a)))))};return a?(0,h.jsxs)(ia.A,{children:[g&&(0,h.jsx)(Aa.A,{severity:"error",className:s.alert,children:g}),(0,h.jsx)(ia.A,{className:s.toolbar,children:(0,h.jsxs)(ia.A,{display:"flex",alignItems:"center",style:{gap:8},children:[va("broadcastCampaign")&&(0,h.jsx)(da.A,{size:"small",variant:"outlined",color:"primary",className:s.openInLeads,disabled:0===V,onClick:async()=>{if(0===V)return;const e=(e,a)=>o((0,_n.az)(t,e,a));!_&&v.length>0?(k(await e(v,!1)),R(0)):_&&T.length>0?(R(await e(T,!0)),k(0)):(k(0),R(0)),N(!0)},children:V>0?`Broadcast (${V.toLocaleString()})`:"Broadcast"}),(0,h.jsx)(da.A,{size:"small",variant:"outlined",color:"primary",className:s.openInLeads,disabled:O||0===c,onClick:async()=>{if(t&&!O){P(!0);try{await(0,_n.ie)(t,{type:"form",adId:a})}catch(e){b(e?.message||"Failed to export CSV")}finally{P(!1)}}},children:O?"Exporting…":"Export CSV"}),(0,h.jsx)(da.A,{component:r.Link,to:`${Xe(t)}/lead-gen-preview?adId=${a}`,size:"small",color:"primary",className:s.openInLeads,children:"Open in Leads →"})]})}),(0,h.jsx)(ia.A,{className:s.listRoot,children:u?(0,h.jsx)(ia.A,{className:s.loadingState,children:(0,h.jsx)(ba.A,{})}):0===l.length?(0,h.jsxs)(ia.A,{className:s.emptyState,children:[(0,h.jsx)(la.A,{variant:"body1",children:"No leads captured by this ad yet"}),(0,h.jsx)(la.A,{variant:"body2",style:{marginTop:4},children:"Leads submitted through this ad's instant form will show up here."})]}):(0,h.jsx)(ia.A,{className:s.scrollContainer,children:(0,h.jsxs)("table",{className:s.table,children:[(0,h.jsx)("thead",{children:(0,h.jsx)("tr",{className:s.headRow,children:mu.map((e=>"checkbox"===e.key?(0,h.jsx)("th",{style:{width:e.width},children:(0,h.jsx)(ha.A,{size:"small",color:"primary",checked:Y,indeterminate:Z&&!Y,onChange:e=>{return t=e.target.checked,E([]),D([]),void S(t);var t}})},e.key):(0,h.jsx)("th",{style:{width:e.width},children:e.label?(0,h.jsx)(la.A,{variant:"h5",color:"primary",children:e.label}):null},e.key)))})}),(0,h.jsx)("tbody",{children:l.map(((e,t)=>(0,h.jsx)(cn,{lead:e,index:t,selectable:!0,selected:H(e),onSelect:K,hideInteractions:!0,onClick:()=>W(e,t)},e._id||e.leadgenId||t)))})]})})}),!u&&l.length>0&&(0,h.jsx)(ia.A,{className:s.footer,children:(0,h.jsx)(fa,{limit:f,page:y,total:c,loadPrev:()=>x((e=>Math.max(0,e-1))),loadNext:()=>x((e=>e+1)),setLimit:e=>{A(parseInt(e.target.value,10)),x(0)}})}),(0,h.jsx)(ya.A,{open:w,onClose:()=>N(!1),"aria-labelledby":"ad-lead-broadcast-dialog",maxWidth:"md",fullWidth:!0,disableBackdropClick:!0,children:w&&(0,h.jsx)(B,{name:"broadcastCampaign",closeDialog:()=>N(!1),totalSelected:V,selectAll:_,unSelected:_?T:[],selected:_?[]:v,dailyTemplateLimit:M.dailyTemplateLimit,consumedQuota:M.consumedQuota,allFilters:void 0,optedCount:0,selectedOptNo:j,unSelectedOptNo:L,groupedContacts:[],scheduledCampaigns:[],leadAudienceCampaign:!0,leadSourceType:"form",leadAdId:a})}),(0,h.jsx)(Ze,{open:!!z,onClose:()=>C(-1),title:"Lead detail",width:"600px",children:z&&(0,h.jsx)(wn,{lead:z,assistantId:t,index:I,total:l.length,onPrev:()=>C((e=>Math.max(0,e-1))),onNext:()=>C((e=>Math.min(l.length-1,e+1)))},z._id||z.leadgenId)})]}):(0,h.jsxs)(ia.A,{className:s.emptyState,children:[(0,h.jsx)(la.A,{variant:"body1",children:"Leads are not available yet"}),(0,h.jsx)(la.A,{variant:"body2",style:{marginTop:4},children:"This ad's Meta ad ID hasn't loaded yet — try again in a moment."})]})},gu=e=>{let{children:t,value:a,index:n,...s}=e;return(0,h.jsx)("div",{role:"tabpanel",hidden:a!==n,id:`ad-tabpanel-${n}`,"aria-labelledby":`ad-tab-${n}`,...s,children:a===n&&(0,h.jsx)(o.Box,{children:t})})},bu=e=>
1{let{adData:t,adInsights:a,assistantDetails:s,assistantId:r,mongoAdId:l,classes:d,metrics:c,clicks:p,spend:u,adCostPerClick:m,currencySymbol:g,highlight:b,setHighlight:y,interval:x,setInterval:f,insightsHook:A,summaryDateRange:I,adDates:C,setAdDates:_,selectedPlacement:S,AdSummarySection:v,ActionsBreakdown:E,BreakdownInsights:T}=e;const D=(0,i.useDispatch)(),[w,N]=(0,n.useState)(0),j=(0,o.useMediaQuery)("(max-width: 768px)"),k=(0,n.useMemo)((()=>t?.adStartDate?ve()(t.adStartDate).startOf("day"):null),[t?.adStartDate]),L=(0,n.useMemo)((()=>C?.startDate?ve().isMoment(C.startDate)?C.startDate:ve()(C.startDate):null),[C?.startDate]),R=(0,n.useMemo)((()=>C?.endDate?ve().isMoment(C.endDate)?C.endDate:ve()(C.endDate):null),[C?.endDate]),B=(0,n.useCallback)((e=>{let{startDate:t,endDate:a}=e;_((e=>{const n=e.startDate?.format("YYYY-MM-DD"),s=e.endDate?.format("YYYY-MM-DD"),o=t?.format("YYYY-MM-DD"),i=a?.format("YYYY-MM-DD");return n!==o||s!==i?(D((0,_n.FZ)(r,l,S,t,a)),{startDate:t,endDate:a}):e}))}),[D,r,l,S,_]),O="WHATSAPP"==t?.destinationType,P=O||("lead_form"===t?.adType||!!t?.leadFormId),M=(0,n.useMemo)((()=>{const e=a?.insights?.bifurcatedInsightsData?.tables;return[...e?.actionsBreakdown||[],...(e?.videoBreakdown||[]).map((e=>({...e,isVideoMetric:!0})))]}),[a?.insights?.bifurcatedInsightsData?.tables]),U=(0,n.useMemo)((()=>[{label:"Impressions",value:c.formattedImpressions,tooltip:"Total views received on advertisement"},{label:"Reach",value:c.formattedReach,tooltip:"Unique views received on advertisement"},{label:"Clicks",value:p?p.toLocaleString():"--",tooltip:"Total clicks received on advertisement"},{label:"Amount spent",value:u?`${g}${parseFloat(u).toLocaleString()}`:"--",tooltip:"Total ad budget used",highlight:!0},{label:"CPC",value:m?`${g}${m}`:"--",tooltip:"Cost per click (Ad budget used for 1 click)"},{label:"CTR",value:`${c.ctr}%`,tooltip:"Click-through rate (Percentage of impressions that resulted in clicks)"},{label:"CPM",value:c.cpm||"--",tooltip:"Cost per mille (Cost per 1,000 impressions)"}].filter(Boolean)),[c,p,u,m,g]);return(0,h.jsx)(o.Grid,{item:!0,xs:12,md:9,style:{display:"flex",justifyContent:"flex-start",alignItems:"stretch",flexDirection:"column",height:"100%",width:"100%",padding:"16px 24px",overflowY:"auto",overflowX:"hidden",maxHeight:"100%"},children:(0,h.jsxs)(o.Grid,{item:!0,xs:12,className:d.summaryPanel,children:[(0,h.jsx)("div",{style:{backgroundColor:"white",marginBottom:"16px",position:"sticky",top:0,zIndex:10,padding:"16px 24px 0px 24px",overflow:"hidden",width:"100%",boxSizing:"border-box"},children:(0,h.jsxs)("div",{style:{display:"flex",flexDirection:j?"column":"row",alignItems:j?"flex-start":"flex-end",gap:"8px",width:"100%",boxSizing:"border-box"},children:[(0,h.jsx)("div",{style:{flex:1,minWidth:0,overflow:"hidden",width:"100%"},children:(0,h.jsxs)(o.Tabs,{value:w,onChange:(e,t)=>
1N(t),className:d.adTabs,indicatorColor:"primary",textColor:"primary",variant:"scrollable",scrollButtons:"on",children:[(0,h.jsx)(o.Tab,{label:"Ad Summary",value:0}),(0,h.jsx)(o.Tab,{label:"Metrics",value:1}),(0,h.jsx)(o.Tab,{label:"Conversions",value:2}),(0,h.jsx)(o.Tab,{label:"Insights",value:3}),P&&(0,h.jsx)(o.Tab,{label:"Leads",value:5})]})}),(0,h.jsx)("div",{style:{flexShrink:0,paddingBottom:j?"8px":"10px"},children:(0,h.jsx)(Ga,{startDate:L,endDate:R,onDatesChange:B,onFocusChange:I.setFocus,focusedInput:I.focusedInput,constraintStartDate:k})})]})}),(0,h.jsxs)(o.Box,{style:{padding:"0px 16px"},children:[(0,h.jsx)(gu,{value:w,index:0,children:(0,h.jsx)(v,{isProcessing:!1,assistantDetails:s,mongoAdId:l,metrics:U,timeRange:x,onTimeRangeChange:e=>f(e),onCustomize:()=>{},classes:d,graphData:null,highlight:b,onHighlightChange:e=>{y(e)},insightsData:A.insights?.data||[],dateRangeStartDate:ve()(t?.adStartDate||I.startDate),dateRangeEndDate:ve()(t?.adEndDate||I.endDate),onDateRangeChange:e=>{let{startDate:t,endDate:a}=e;I.setDates(t,a)},dateRangeFocusedInput:I.focusedInput,onDateRangeFocusChange:I.setFocus,adInsights:a,adData:t})}),(0,h.jsx)(gu,{value:w,index:1,children:(0,h.jsx)(o.Grid,{item:!0,xs:12,children:(0,h.jsx)(E,{tableName:"actionsBreakdown",adInsights:a,classes:d,tables:M,currencySymbol:g})})}),(0,h.jsx)(gu,{value:w,index:2,children:(0,h.jsx)(E,{tableName:"conversionsBreakdown",adInsights:a,classes:d,tables:a?.insights?.bifurcatedInsightsData?.tables?.conversionsBreakdown||[],currencySymbol:g})}),(0,h.jsx)(gu,{value:w,index:3,children:(0,h.jsx)(T,{mongoAdId:l,assistantId:r,adDates:C,currencySymbol:g})}),P&&(0,h.jsx)(gu,{value:w,index:5,children:O?(0,h.jsx)(pu,{adId:t?.adId,adData:t,assistantId:t?.assistantId||r,classes:d,assistantDetails:s,dataRange:C}):(0,h.jsx)(hu,{assistantId:t?.assistantId||r,adId:t?.adId})})]})]})})};var yu=a(58941);const xu={impressions:{label:"Impressions",desc:"Total number of times your ad was displayed"},reach:{label:"Reach",desc:"Number of unique people who saw your ad at least once"},frequency:{label:"Frequency",desc:"Frequency\nAverage number of times each person saw your ad\nImpressions / Reach"},spend:{label:"Spend",desc:"Total amount of budget used for your ad during the selected period"},clicks:{label:"Clicks",desc:"Total number of clicks on your ad"},unique_clicks:{label:"Unique Clicks",desc:"Number of distinct people who clicked your ad — each person counted once regardless of how many times they clicked"},ctr:{label:"CTR",desc:"Click-Through Rate (CTR)\nPercentage of impressions that resulted in a click\nClicks / Impressions × 100"},unique_ctr:{label:"Unique CTR",desc:"Unique Click-Through Rate\nCTR calculated using unique people reached instead of total impressions"},cpc:{label:"CPC",desc:"Cost Per Click (CPC)\nAverage amount spent for each click\nTotal Spend / Clicks"},cpm:{label:"CPM",desc:"Cost Per Mille (CPM)\nCost for every 1,000 impressions\nTotal Spend / Impressions × 1,000"},cpp:{label:"CPP",desc:"Cost Per 1,000 People Reached (CPP)\nAverage cost to reach 1,000 unique users"},inline_link_clicks:{label:"Inline Link Clicks",desc:"Clicks on links embedded within the ad unit itself, as opposed to outbound destination links"},outbound_clicks__outbound_click:{label:"Outbound Clicks",desc:"Clicks that take people off Facebook or Instagram to an external destination"},objective:{label:"Objective"},optimization_goal:{label:"Optimization Goal"},actions__link_click:{label:"Link Click Actions",desc:"Number of times people clicked a link in your ad to visit a destination on or off Facebook"},actions__page_engagement:{label:"Page Engagement",desc:"Total actions taken on your Facebook Page as a result of your ad (likes, visits, posts, check-ins)"},actions__post_engagement:{label:"Post Engagement",desc:"Total actions taken on your ad's post — likes, comments, shares, and clicks"},actions__post_reaction:{label:"Post Reactions",desc:"Number of reactions (like, love, haha, wow, sad, angry) on your ad's post"},actions__post_interaction_gross:{label:"Post Interactions (Gross)",desc:"Total post interactions including repeated actions by the same person"},actions__post_interaction_net:{label:"Post Interactions (Net)",desc:"Unique post interactions — each person counted once regardless of how many times they interacted"},actions__landing_page_view:{label:"Landing Page Views",desc:"Times someone clicked an ad link and the destination page successfully loaded in their browser"},actions__omni_landing_page_view:{label:"Omni Landing Page Views",desc:"Landing page views tracked across Facebook, Instagram, and Audience Network"},actions__view_content:{label:"View Content",desc:"Times people viewed a key page on your website (e.g. a product page) after clicking your ad"},actions__omni_view_content:{label:"Omni View Content",desc:"View Content events tracked across all Meta surfaces (web, app, and onsite)"},actions__onsite_web_view_content:{label:"Onsite Web View Content",desc:"View Content events from people who viewed content on your website via Meta's onsite tracking tools"},actions__onsite_web_app_view_content:{label:"Onsite Web App View Content",desc:"View Content events from your website or app tracked via Meta's onsite measurement tools"},actions__lead:{label:"Leads",desc:"Number of lead events — form submissions, calls, or other lead-generation actions driven by your ad"},actions__onsite_web_lead:{label:"Onsite Web Leads",desc:"Leads captured on your website and tracked via Meta's Pixel or SDK"},actions__offsite_lead_add_20_s_calls:{label:"Offsite Leads (20s Calls)",desc:"Lead events from phone calls lasting at least 20 seconds, tracked offsite"},actions__offsite_content_view_add_meta_leads:{label:"Offsite Content Views (Meta Leads)",desc:"Offsite View Content events attributed to Meta Leads campaigns"},actions__offsite_conversion__fb_pixel_view_content:{label:"Pixel View Content",desc:"View Content events recorded by your Meta Pixel on your website"},actions__offsite_conversion__fb_pixel_lead:{label:"Pixel Leads",desc:"Lead events recorded by your Meta Pixel on your website"},actions__initiate_checkout:{label:"Initiate Checkout",desc:"Number of times people started the checkout process after seeing your ad"},actions__onsite_web_initiate_checkout:{label:"Onsite Web Initiate Checkout",desc:"Checkout initiations tracked on your website via Meta's onsite tools"},actions__omni_initiated_checkout:{label:"Omni Initiated Checkout",desc:"Checkout initiations tracked across all Meta surfaces"},actions__offsite_conversion__fb_pixel_initiate_checkout:{label:"Pixel Initiate Checkout",desc:"Checkout initiations recorded by your Meta Pixel"},actions__video_view:{label:"Video Views",desc:"Number of times your video was watched for at least 3 seconds"}
1,actions__onsite_conversion__post_net_like:{label:"Net Likes (Onsite Conversion)",desc:"New Page likes minus unlikes driven by your ad"},actions__onsite_conversion__messaging_block:{label:"Messaging Blocked",desc:"Number of times people blocked your ad's messaging thread"},actions__onsite_conversion__post_save:{label:"Post Saves",desc:"Number of times people saved your ad post to revisit later"},actions__onsite_conversion__post_net_save:{label:"Post Saves (Net)",desc:"Net saves — total saves minus unsaves driven by your ad"},actions__onsite_conversion__post_unlike:{label:"Post Unlikes",desc:"Number of times people unliked your Page after seeing your ad"},actions__post:{label:"Posts",desc:"Number of posts made to your Page as a result of your ad"},action_values__initiate_checkout:{label:"Value - Initiate Checkout",desc:"Total purchase value from checkout initiations attributed to your ad"},action_values__onsite_web_initiate_checkout:{label:"Value - Onsite Web Initiate Checkout",desc:"Purchase value from onsite web checkout initiations"},action_values__omni_initiated_checkout:{label:"Value - Omni Initiated Checkout",desc:"Purchase value from checkout initiations across all Meta surfaces"},action_values__offsite_conversion__fb_pixel_initiate_checkout:{label:"Value - Pixel Initiate Checkout",desc:"Purchase value from Pixel-tracked checkout initiations"},cost_per_action_type__link_click:{label:"Cost per Link Click",desc:"Average spend for each link click\nTotal Spend / Link Clicks"},cost_per_action_type__page_engagement:{label:"Cost per Page Engagement",desc:"Average spend for each Page engagement action\nTotal Spend / Page Engagements"},cost_per_action_type__post_engagement:{label:"Cost per Post Engagement",desc:"Average spend for each post engagement\nTotal Spend / Post Engagements"},cost_per_action_type__post_interaction_gross:{label:"Cost per Post Interaction (Gross)",desc:"Average spend per gross post interaction — includes repeated actions by the same person"},cost_per_action_type__landing_page_view:{label:"Cost per Landing Page View",desc:"Average spend for each landing page view\nTotal Spend / Landing Page Views"},cost_per_action_type__omni_landing_page_view:{label:"Cost per Omni Landing Page View",desc:"Average spend per landing page view across all Meta surfaces"},cost_per_action_type__view_content:{label:"Cost per View Content",desc:"Average spend per View Content event\nTotal Spend / View Content Events"},cost_per_action_type__omni_view_content:{label:"Cost per Omni View Content",desc:"Average spend per View Content event across all Meta surfaces"},cost_per_action_type__offsite_content_view_add_meta_leads:{label:"Cost per Offsite Content View (Meta Leads)",desc:"Average spend per offsite content view in Meta Leads campaigns"},cost_per_action_type__lead:{label:"Cost per Lead",desc:"Average spend for each lead generated\nTotal Spend / Leads"},cost_per_action_type__onsite_web_lead:{label:"Cost per Onsite Web Lead",desc:"Average spend per onsite web lead\nTotal Spend / Onsite Web Leads"},cost_per_action_type__offsite_lead_add_20_s_calls:{label:"Cost per Offsite Lead (20s Calls)",desc:"Average spend per qualifying phone call lead (≥20 seconds)"},cost_per_action_type__initiate_checkout:{label:"Cost per Initiate Checkout",desc:"Average spend per checkout initiation\nTotal Spend / Checkout Initiations"},cost_per_action_type__onsite_web_initiate_checkout:{label:"Cost per Onsite Web Initiate Checkout",desc:"Average spend per onsite web checkout initiation"},cost_per_action_type__omni_initiated_checkout:{label:"Cost per Omni Initiated Checkout",desc:"Average spend per checkout initiation across all Meta surfaces"},cost_per_action_type__video_view:{label:"Cost per Video View",desc:"Average spend for each 3-second video view\nTotal Spend / Video Views"},video_play_actions__video_view:{label:"Video Plays",desc:"Number of times your video started playing (auto-play or user-initiated)"},video_p25_watched_actions__video_view:{label:"Video Watched 25%",desc:"Number of times your video was watched to at least 25% of its length"},video_p50_watched_actions__video_view:{label:"Video Watched 50%",desc:"Number of times your video was watched to at least 50% of its length"},video_p75_watched_actions__video_view:{label:"Video Watched 75%",desc:"Number of times your video was watched to at least 75% of its length"},video_p100_watched_actions__video_view:{label:"Video Watched 100%",desc:"Number of times your video was watched all the way to completion"},video_avg_time_watched_actions__video_view:{label:"Avg Video Watch Time (sec)",desc:"Average number of seconds people watched your video per view"}},fu={facebook:"Facebook",instagram:"Instagram",messenger:"Messenger",whatsapp:"WhatsApp",audience_network:"Audience Network"},Au={feed:"Feed",facebook_reels:"Reels",facebook_reels_overlay:"Reels Overlay",instagram_reels:"Reels",facebook_stories:"Stories",instagram_stories:"Stories",instream_video:"Instream 
1Video",marketplace:"Marketplace",search:"Search",right_hand_column:"Right Column",instant_article:"Instant Article",video_feeds:"Video Feeds",rewarded_video:"Rewarded Video",biz_disco_feed:"Business Discover",an_classic:"Audience Network Classic",suggested_video:"Suggested Video"},Iu={male:"Male",female:"Female",unknown:"Uncategorised"},Cu={unknown:"Uncategorised"},_u=["#F2C14E","#BDBF00","#F78154","#5FAD56","#D95F7E","#a48ed2","#4babda"],Su=[["publisher_platform"],["platform_position","publisher_platform"],["age","gender"],["age"],["gender"]],vu=[{key:"publisher_platform",label:"Platform"},{key:"platform_position",label:"Placement"},{key:"age",label:"Age"},{key:"gender",label:"Gender"}],Eu=[{key:"platform",label:"Platform",dimensions:["publisher_platform","platform_position"]},{key:"demographics",label:"Demographics",dimensions:["age","gender"]}],Tu=["date_start","date_stop"],Du=e=>Eu.find((t=>t.dimensions.includes(e))),wu=e=>{const t=new Set(e);return Su.some((e=>e.length===t.size&&e.every((e=>t.has(e)))))},Nu=e=>{if("number"==typeof e)return e;const t=parseFloat(e);return isNaN(t)?0:t},ju=(e,t,a)=>{const n=Nu(e);return"ctr"===t||"unique_ctr"===t||"result_rate"===t?`${n.toLocaleString()}%`:"spend"===t||"cpc"===t||"cpm"===t||"cpp"===t||t.includes("cost_per")?`${a}${n.toLocaleString()}`:n.toLocaleString()},ku=(e,t)=>t.map((t=>e[t]??"unknown")).join(" / "),Lu=e=>e.replace(/[_.]/g," ").replace(/\b\w/g,(e=>e.toUpperCase())),Ru=e=>{const t=e.split("\n");return 1===t.length?(0,h.jsx)("span",{children:t[0]}):(0,h.jsxs)("span",{children:[(0,h.jsx)("span",{style:{fontWeight:600,display:"block",marginBottom:2},children:t[0]}),t.slice(1).map(((e,t)=>(0,h.jsx)("span",{style:{display:"block",opacity:t>=1?.75:1,fontSize:t>=1?"0.85em":void 0},children:e},t)))]})},Bu=e=>xu[e]?.label??Lu(e),Ou=(e,t)=>null==t||""===t?"—":"publisher_platform"===e?fu[t]??Lu(t):"platform_position"===e?Au[t]??Lu(t):"gender"===e?Iu[t]??Lu(t):"age"===e?Cu[t]??Lu(t):Lu(String(t)),Pu=(0,_e.makeStyles)({root:{display:"flex",flexDirection:"column",gap:16,padding:"16px 0"},controlsCard:{padding:"14px 16px",borderRadius:8,boxShadow:"none"},controlsRow:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},controlLabel:{fontSize:12,color:"#666",fontWeight:500},card:{padding:16,borderRadius:8,boxShadow:"none"},cardHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:14,flexWrap:"wrap",gap:8},cardTitle:{fontSize:16,fontWeight:600,color:"#333"},cardHeaderRight:{display:"flex",alignItems:"center",gap:8},metricSelect:{fontSize:12,'& .MuiOutlinedInput-notchedOutline, & [class*="MuiOutlinedInput-notchedOutline-"]':{borderColor:"#ddd"},'& .MuiSelect-select, & [class*="MuiSelect-select-"]':{padding:"4px 32px 4px 10px",color:"#333",fontSize:12}},metricLabel:{fontSize:12,color:"#666"},emptyState:{textAlign:"center",padding:"40px 0",color:"#999",fontSize:13},customizeButton:{textTransform:"none",borderColor:"#ddd",color:"#666",fontSize:12},popoverContent:{padding:16,minWidth:260,maxWidth:360},popoverTitle:{fontWeight:600,color:"#333",fontSize:14,marginBottom:12},checkboxList:{maxHeight:300,overflowY:"auto",display:"flex",flexDirection:"column",gap:4},errorAlert:{marginBottom:8},tableWrapper:{overflowX:"auto",borderRadius:8},table:{width:"100%",borderCollapse:"collapse",fontSize:13},th:{padding:"10px 14px",textAlign:"center",fontWeight:600,color:"#444",background:"#f5f5f5",borderBottom:"1px solid #e0e0e0",whiteSpace:"nowrap"},tdBreakdown:{padding:"10px 14px",fontWeight:500,color:"#0a474c",borderBottom:"1px solid #f0f0f0",whiteSpace:"nowrap",textAlign:"center"},td:{padding:"10px 14px",color:"#333",borderBottom:"1px solid #f0f0f0",whiteSpace:"nowrap",textAlign:"center"}}),Mu=e=>{let{mongoAdId:t,assistantId:a,adDates:r,currencySymbol:l}=e;const c=Pu(),p=(0,i.useDispatch)(),[u,m]=(0,n.useState)(["publisher_platform"]),[g,b]=(0,n.useState)(null),[y,x]=(0,n.useState)(!1),[f,A]=(0,n.useState)(null),[I,C]=(0,n.useState)("spend"),[_,S]=(0,n.useState)((()=>{try{const e=localStorage.getItem("adBreakdown_visibleMetrics");if(e){const t=JSON.parse(e);if(Array.isArray(t)&&t.length>0)return new Set(t)}}catch(e){}return new Set(["impressions","spend","clicks","ctr","cpc"])}
1)),[v,E]=(0,n.useState)(null),[T,D]=(0,n.useState)(new Set),[w,N]=(0,n.useState)(window.innerWidth),j=(0,n.useRef)(!1);(0,n.useEffect)((()=>{localStorage.setItem("adBreakdown_visibleMetrics",JSON.stringify([..._]))}),[_]),(0,n.useEffect)((()=>{const e=new AbortController;if(!wu(u))return()=>e.abort();const n=r.startDate?.format("YYYY-MM-DD"),s=r.endDate?.format("YYYY-MM-DD");return(async()=>{x(!0),A(null);try{const o={data:await p((0,uo.CV)({adId:t,assistantId:a,startDate:n,endDate:s,breakdowns:u},{signal:e.signal}))},i=o.data.dailyData??[],r=o.data.aggregatedData??[];if(b({dailyData:i,aggregatedData:r,currency:o.data.currency,breakdowns:o.data.breakdowns??[],metricKeys:o.data.metricKeys??[]}),!j.current){const e=(o.data.metricKeys??[]).filter((e=>!Tu.includes(e)));e.length>0&&(j.current=!0,S((t=>{const a=new Set([...t].filter((t=>e.includes(t))));return a.size>0?a:new Set(e.slice(0,5))})))}const l=(o.data.metricKeys?.length?o.data.metricKeys:Object.keys(i[0]?.insightsData??{})).filter((e=>!Tu.includes(e)));if(l.length>0){const e=l.includes(I)?I:Object.keys(xu).find((e=>l.includes(e)))??l[0];e&&e!==I&&C(e)}}catch(e){if((0,io.F)(e))return;A(e.response?.data?.message||e.message||"Failed to fetch breakdown data")}finally{e.signal.aborted||x(!1)}})(),()=>e.abort()}),[t,a,JSON.stringify(u),r.startDate?.format("YYYY-MM-DD"),r.endDate?.format("YYYY-MM-DD")]),(0,n.useEffect)((()=>{const e=()=>N(window.innerWidth);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[]);const k=w<768,L=g?.dailyData,R=g?.aggregatedData,B=(0,n.useMemo)((()=>vu.map((e=>e.key)).filter((e=>g?.breakdowns?.includes(e)))),[g]),{chartData:P,uniqueLabels:M,labelDisplayNames:U}=(0,n.useMemo)((()=>{if(!L?.length)return{chartData:[],uniqueLabels:[],labelDisplayNames:new Map};const e=new Map,t=[],a=new Set,n=new Map;for(const s of L){e.has(s.date)||e.set(s.date,{date:s.date});const o=ku(s.breakdownValues,B);if(!a.has(o)){a.add(o),t.push(o);const e=B.map((e=>Ou(e,s.breakdownValues[e]))).join(" · ");n.set(o,e)}const i=s.insightsData[I];null!=i&&(e.get(s.date)[o]=Nu(i))}for(const a of e.values())for(const e of t)e in a||(a[e]=0);let s=[...e.values()];if(1===s.length){const e=e=>t.reduce(((e,t)=>({...e,[t]:0})),{date:e}),a=s[0].date;s=[e(ve()(a).subtract(1,"day").format("YYYY-MM-DD")),s[0]]}return{chartData:s,uniqueLabels:t,labelDisplayNames:n}}),[L,I,B]);(0,n.useEffect)((()=>{if(M.length)if(M.length<=7)D(new Set);else{const e=new Set(function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:7;const n=t.map((t=>({label:t,total:e.reduce(((e,a)=>e+(a[t]??0)),0)})));return n.sort(((e,a)=>a.total-e.total||t.indexOf(e.label)-t.indexOf(a.label))),n.slice(0,a).map((e=>e.label))}(P,M));D(new Set(M.filter((t=>!e.has(t)))))}}),[JSON.stringify(M),P]);const F=(0,n.useMemo)((()=>{const e=g?.metricKeys;if(null==e)return Object.keys(xu);
1if(!e.length)return[];const t=new Set(e);return Object.keys(xu).filter((e=>t.has(e)))}),[g?.metricKeys]),W=F,z=W.filter((e=>_.has(e))),G=wu(u);return(0,h.jsxs)("div",{className:c.root,children:[f&&(0,h.jsx)(O.Alert,{severity:"error",className:c.errorAlert,children:f}),(0,h.jsx)(o.Paper,{className:c.controlsCard,children:(0,h.jsxs)("div",{className:c.controlsRow,children:[(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[(0,h.jsx)("span",{style:{fontSize:9,visibility:"hidden"},children:"_"}),(0,h.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[(0,h.jsx)(o.Typography,{component:"span",className:c.controlLabel,children:"Group by"}),(0,h.jsx)(o.Tooltip,{title:"Insights can only be grouped by one category at a time",placement:"top",children:(0,h.jsx)(d.InfoOutlined,{style:{fontSize:14,color:"#aaa",cursor:"default"}})})]})]}),Eu.map(((e,t)=>{const a=0===u.length||u.some((t=>e.dimensions.includes(t)));return(0,h.jsxs)(s().Fragment,{children:[t>0&&(0,h.jsx)("div",{style:{width:1,height:36,background:"#e0e0e0",flexShrink:0}}),(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:2,opacity:a?1:.45,transition:"opacity 0.2s"},children:[(0,h.jsx)("span",{style:{fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",color:a?"#555":"#999"},children:e.label}),(0,h.jsx)("div",{style:{display:"flex",gap:4},children:e.dimensions.map((e=>{const{label:t}=vu.find((t=>t.key===e)),a="platform_position"===e&&!u.includes("publisher_platform");return(0,h.jsx)(o.Tooltip,{title:a?"Select Platform first":"",placement:"top",children:(0,h.jsx)("span",{children:(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Checkbox,{checked:u.includes(e),onChange:()=>(e=>{m((t=>{if(t.includes(e)){const a=t.filter((t=>t!==e));return"publisher_platform"===e?a.filter((e=>"platform_position"!==e)):a}const a=Du(e),n=t.length>0?Du(t[0]):null;return n&&a?.key!==n.key?[e]:[...t,e]}))})(e),color:"primary",size:"small",disabled:a}),label:(0,h.jsx)(o.Typography,{style:{fontSize:12},children:t})})})},e)}))})]})]},e.key)}))]})}),0===u.length&&(0,h.jsx)(o.Paper,{className:c.card,children:(0,h.jsx)(o.Typography,{className:c.emptyState,children:"Select at least one group above to see insights."})}),y&&!g&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(O.Skeleton,{variant:"rect",width:"100%",height:380,style:{borderRadius:8}}),(0,h.jsx)(O.Skeleton,{variant:"rect",width:"100%",height:200,style:{borderRadius:8}})]}),!f&&g&&G&&(0,h.jsxs)(o.Paper,{className:c.card,children:[(0,h.jsxs)("div",{className:c.cardHeader,children:[(0,h.jsx)(o.Typography,{className:c.cardTitle,children:"Performance Over Time"}),(0,h.jsxs)("div",{className:c.cardHeaderRight,children:[y&&(0,h.jsx)(o.CircularProgress,{size:18}),(0,h.jsx)(o.Typography,{component:"span",className:c.metricLabel,children:"Metric:"}),(0,h.jsx)(o.Select,{value:F.includes(I)?I:F[0]||"spend",onChange:e=>C(e.target.value),variant:"outlined",className:c.metricSelect,SelectDisplayProps:{style:{padding:"4px 32px 4px 10px",fontSize:12,color:"#333"}},children:F.map((e=>(0,h.jsx)(o.MenuItem,{value:e,children:(0,h.jsx)(o.Tooltip,{title:xu[e]?.desc?Ru(xu[e].desc):"",placement:"left",children:(0,h.jsx)("span",{style:{display:"block",width:"100%"},children:Bu(e)})})},e)))})]})]}),L?.length?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Typography,{style:{fontSize:11,color:"#999",marginBottom:12},children:"click labels to show/hide"}),(0,h.jsx)(yu.uf,{width:"100%",height:300,children:(0,h.jsxs)(yu.QF,{data:P,margin:{top:5,right:30,left:0,bottom:0},children:[(0,h.jsx)("defs",{children:_u.map(((e,t)=>(0,h.jsxs)("linearGradient",{id:`breakdown-gradient-${t}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,h.jsx)("stop",{offset:"0%",stopColor:e,stopOpacity:.8}),(0,h.jsx)("stop",{offset:"95%",stopColor:e,stopOpacity:0})]},`breakdown-gradient-${t}`)))}),(0,h.jsx)(yu.dC,{strokeDasharray:"3 3",stroke:"#f0f0f0"}),(0,h.jsx)(yu.WX,{dataKey:"date",tickFormatter:e=>ve()(e).format("MMM D"),interval:P.length>10?Math.floor(P.length/10):0,angle:k?-35:0,textAnchor:k?"end":"middle",height:k?50:30}),(0,h.jsx)(yu.h8,{tickFormatter:e=>ju(e,I,l),width:70}),(0,h.jsx)(yu.m_,{formatter:(e,t)=>[ju(e,I,l),t],labelFormatter:e=>ve()(e).format("MMM D, YYYY")}),(0,h.jsx)(yu.s$,{onClick:e=>{let{dataKey:t}=e;D((e=>{const a=new Set(e);return a.has(t)?a.delete(t):a.add(t),a}))},formatter:(e,t)=>T.has(t.dataKey)?(0,h.jsx)(o.Tooltip,{title:"Click to show",placement:"top",children:(0,h.jsx)("span",{style:{color:"#bbb",textDecoration:"line-through"},children:e})}):(0,h.jsx)(o.Tooltip,{title:"Click to hide",placement:"top",children:(0,h.jsx)("span",{style:{color:"#555"},children:e})}),wrapperStyle:{fontSize:13,paddingTop:8,cursor:"pointer"}}),M.map(((e,t)=>(0,h.jsx)(yu.Gk,{type:"monotone",dataKey:e,name:U.get(e)??e,hide:T.has(e),stroke:_u[t%_u.length],strokeWidth:2,dot:!1,connectNulls:!1,fillOpacity:1,fill:`url(#breakdown-gradient-${t%_u.length})`},e)))]})})]}):(0,h.jsx)(o.Typography,{className:c.emptyState,children:"No data available for the selected breakdown and date range"})]}),!f&&g&&G&&(0,h.jsxs)(o.Paper,{className:c.card,children:[(0,h.jsxs)("div",{className:c.cardHeader,children:[(0,h.jsx)(o.Typography,{className:c.cardTitle,children:"Summary (Full Perio
1d)"}),(0,h.jsxs)("div",{className:c.cardHeaderRight,children:[y&&(0,h.jsx)(o.CircularProgress,{size:18}),(0,h.jsx)(o.Button,{variant:"outlined",size:"small",onClick:e=>E(e.currentTarget),className:c.customizeButton,children:"Customize Columns"})]})]}),(0,h.jsx)(o.Popover,{open:Boolean(v),anchorEl:v,onClose:()=>E(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:(0,h.jsxs)(o.Box,{className:c.popoverContent,children:[(0,h.jsx)(o.Typography,{className:c.popoverTitle,children:"Select Columns"}),(0,h.jsx)(o.Box,{className:c.checkboxList,children:W.map((e=>(0,h.jsx)(o.Tooltip,{title:xu[e]?.desc?Ru(xu[e].desc):"",placement:"left",children:(0,h.jsx)("span",{children:(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Checkbox,{checked:_.has(e),onChange:()=>(e=>{S((t=>{if(t.has(e)&&1===t.size)return t;const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a}))})(e),color:"primary",disabled:_.has(e)&&1===_.size}),label:Bu(e)})})},e)))}),(0,h.jsx)(o.Box,{display:"flex",justifyContent:"flex-end",mt:2,children:(0,h.jsx)(o.Button,{size:"small",variant:"contained",color:"primary",onClick:()=>E(null),children:"Done"})})]})}),R?.length?(0,h.jsx)("div",{className:c.tableWrapper,children:(0,h.jsxs)("table",{className:c.table,children:[(0,h.jsx)("thead",{children:(0,h.jsxs)("tr",{children:[B.map((e=>(0,h.jsx)("th",{className:c.th,children:vu.find((t=>t.key===e))?.label??Lu(e)},e))),z.map((e=>(0,h.jsx)("th",{className:c.th,children:(0,h.jsx)(o.Tooltip,{title:xu[e]?.desc?Ru(xu[e].desc):"",placement:"top",children:(0,h.jsx)("span",{children:Bu(e)})})},e)))]})}),(0,h.jsx)("tbody",{children:R.map(((e,t)=>(0,h.jsxs)("tr",{style:{background:t%2==0?"white":"#fafafa"},children:[B.map((t=>(0,h.jsx)("td",{className:c.tdBreakdown,children:Ou(t,e.breakdownValues[t])},t))),z.map((t=>(0,h.jsx)("td",{className:c.td,children:ju(e.insightsData[t],t,l)},t)))]},t)))})]})}):(0,h.jsx)(o.Typography,{className:c.emptyState,children:"No data available"})]})]})},Uu=e=>{let{tables:t,tableName:a,classes:s,currencySymbol:i}=e;const r="undefined"!=typeof window&&window.innerWidth>=960,l=t||[],[c,p]=(0,n.useState)(""),[u,m]=(0,n.useState)(null),g=(0,n.useMemo)((()=>{const e=new Set;return l.forEach((t=>{t.label&&e.add(t.label)})),Array.from(e).sort()}),[l]),[b,y]=(0,n.useState)((()=>{try{const e=localStorage.getItem("adAnalytics_visibleActionTypes");if(e){const t=JSON.parse(e).filter((e=>g.includes(e)));if(t.length>0)return new Set(t)}}catch(e){console.error("Error loading saved action types:",e)}return new Set(g)}));(0,n.useEffect)((()=>{if(g.length>0){try{const e=localStorage.getItem("adAnalytics_visibleActionTypes");if(e){const t=JSON.parse(e).filter((e=>g.includes(e))),a=new Set(t);return g.forEach((e=>{a.has(e)||a.add(e)})),void y(a)}}catch(e){console.error("Error loading saved action types:",e)}y(new Set(g))}}),[g]),(0,n.useEffect)((()=>{if(b.size>0)try{localStorage.setItem("adAnalytics_visibleActionTypes",JSON.stringify(Array.from(b)))}catch(e){console.error("Error saving action types to localStorage:",e)}}),[b]);const x="actionsBreakdown"===a||"conversionsBreakdown"===a?[{label:"Action Type"},{label:"Total Actions"},{label:"Cost Per Action"},..."conversionsBreakdown"!=a?[{label:"Conversion Value"}]:[]]:[{label:"Action Type"},{label:"Total Views"}],f=()=>{m(null)},A=(0,n.useMemo)((()=>{let e=l.filter((e=>b.has(e.label)));if(c.trim()){const t=c.toLowerCase();e=e.filter((e=>{const a=(e.label||"").toLowerCase(),n=String(e.totalValue||"").toLowerCase(),s=String(e.costPerValue||"").toLowerCase(),o=String(e.actionValue||"").toLowerCase();return a.includes(t)||n.includes(t)||s.includes(t)||o.includes(t)}))}return e}),[l,c,b]),I=Boolean(u),C=I?"actions-customize-popover":void 0;return(0,h.jsxs)(o.Box,{className:s.adSummarySection,children:[(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1,children:[(0,h.jsx)(o.TextField,{placeholder:"Search actions...",variant:"outlined",size:"small",value:c,onChange:e=>p(e.target.value),className:s.actionsSearchField,style:{padding:"0px"},InputProps:{startAdornment:(0,h.jsx)(o.InputAdornment,{position:"start",children:(0,h.jsx)(d.Search,{})})}}),(0,h.jsx)(o.Button,{variant:"outlined",size:"small",startIcon:(0,h.jsx)(d.FilterList,{}),onClick:e=>{m(e.currentTarget)},className:s.adSummaryCustomizeButton,children:"Customize"}),(0,h.jsx)(o.Popover,{id:C,open:I,anchorEl:u,onClose:f,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:(0,h.jsxs)(o.Box,{className:s.customizePopoverContent,children:[(0,h.jsx)(o.Typography,{variant:"h6",className:s.customizePopoverTitle,children:"Select Action Types to Display"}),(0,h.jsx)(o.Box,{className:s.customizeCheckboxList,children:g.length>0?g.map((e=>
1(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Checkbox,{checked:b.has(e),onChange:()=>(e=>{y((t=>{const a=new Set(t);return a.has(e)?a.size>1&&a.delete(e):a.add(e),a}))})(e),color:"primary"}),label:e},e))):(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:"No action types available"})}),(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"flex-end",mt:2,className:s.customizeActions,children:[(0,h.jsx)(o.Button,{size:"small",onClick:()=>{y(new Set(g))},disabled:0===g.length,children:"Select All"}),(0,h.jsx)(o.Button,{size:"small",onClick:()=>{g.length>0?y(new Set([g[0]])):y(new Set)},style:{marginLeft:"8px"},disabled:0===g.length,children:"Deselect All"}),(0,h.jsx)(o.Button,{size:"small",variant:"contained",color:"primary",onClick:f,style:{marginLeft:"8px"},children:"Done"})]})]})})]}),(0,h.jsx)("div",{className:s.root,children:A&&A.length>0?(0,h.jsx)("div",{className:{...s.contentGrid,...r?s.contentGridLarge:{}},children:(0,h.jsx)("div",{children:(0,h.jsx)("div",{className:s.tableContainer,children:(0,h.jsxs)("table",{className:s.table,children:[(0,h.jsx)("thead",{className:s.tableHeader,children:(0,h.jsx)("tr",{children:x.map(((e,t)=>(0,h.jsx)("th",{className:s.tableHeaderCell,style:{...0===t?{textAlign:"left"}:{textAlign:"center"}},children:e.label},t)))})}),(0,h.jsx)("tbody",{children:A.map(((e,t)=>"actionsBreakdown"===a||"conversionsBreakdown"===a?(0,h.jsxs)("tr",{className:s.tableRow,style:{backgroundColor:t%2==0?"white":"#f5f5f5"},children:[(0,h.jsx)("td",{className:s.tableCell,children:e.label}),(0,h.jsx)("td",{className:`${s.tableCell} ${s.tableCellCenter}`,children:e.isVideoMetric?`${e.totalValue} views`:e.totalValue}),(0,h.jsx)("td",{className:`${s.tableCell} ${s.tableCellCenter}`,children:e.costPerValue?`${i}${e.costPerValue}`:""}),"conversionsBreakdown"!=a&&(0,h.jsx)("td",{className:`${s.tableCell} ${s.tableCellCenter}`,children:e.actionValue})]},t):(0,h.jsxs)("tr",{className:s.tableRow,children:[(0,h.jsx)("td",{className:`${s.tableCell} ${s.tableCellLeft}`,children:e.label}),(0,h.jsx)("td",{className:`${s.tableCell} ${s.tableCellCenter}`,children:e.totalValue})]},t)))})]})})})}):(0,h.jsx)(o.Box,{display:"flex",justifyContent:"center",alignItems:"center",p:4,style:{minHeight:"200px"},children:(0,h.jsx)(o.Typography,{variant:"body1",color:"textSecondary",children:c?"No results found matching your search":"No conversions event found for this ad"})})})]})},Fu=[{id:"av",color:"#F2C14E"},{id:"bv",color:"#BDBF00"},{id:"cv",color:"#F78154"},{id:"dv",color:"#5FAD56"},{id:"ev",color:"#F70054"},{id:"gv",color:"#a48ed2"},{id:"wv",color:"#4babda"},{id:"av1",color:"#F2C14E"},{id:"bv1",color:"#BDBF00"},{id:"cv1",color:"#F78154"},{id:"dv1",color:"#5FAD56"},{id:"ev1",color:"#F70054"},{id:"gv1",color:"#a48ed2"},{id:"wv1",color:"#4babda"},{id:"av2",color:"#F2C14E"},{id:"bv2",color:"#BDBF00"},{id:"cv2",color:"#F78154"},{id:"dv2",color:"#5FAD56"},{id:"ev2",color:"#F70054"},{id:"gv2",color:"#a48ed2"},{id:"wv2",color:"#4babda"}];class Wu extends n.PureComponent{constructor(e){super(e),this.rootRef=(0,n.createRef)(null),this.state={containerWidth:0}}componentDidMount(){this.measure(),"undefined"!=typeof ResizeObserver&&this.rootRef.current?(this.resizeObserver=new ResizeObserver(this.measure),this.resizeObserver.observe(this.rootRef.current)):window.addEventListener("resize",this.measure)}componentWillUnmount(){this.resizeObserver?this.resizeObserver.disconnect():window.removeEventListener("resize",this.measure)}measure=()=>{const e=this.rootRef.current;if(!e)return;const t=e.clientWidth;t!==this.state.containerWidth&&this.setState({containerWidth:t})};render(){const{data:e,keys:t,title:a,isLoading:n,Subheading:i,Options:r,fixed_strokes:l,type:d,maxHeight:c=300,dense:p=!1}=this.props,u=this.props.classes,m=l||Fu,{containerWidth:g}=this.state,b=Math.max(320,g-40),y=Math.min(c,Math.max(180,b/3));let x=[];if(1===e.length&&e[0].date){const t=e[0],a={};let n=new Date(t.date);n.setDate(n.getDate()-1),n=n.toDateString().split(" "),Object.keys(t).forEach((e=>{a[e]=0})),x=[{...a,date:`${n[2]} ${n[1]}`},t]}return(0,h.jsxs)("div",{ref:this.rootRef,className:u.root,style:{backgroundColor:"white",...p?{margin:0,paddingTop:0}:{}},children:[(0,h.jsxs)(o.Grid,{container:!0,children:[a&&(0,h.jsx)(o.Grid,{item:!0,xs:12,md:6,children:(0,h.jsxs)(o.Box,{m:"1em 0em",className:u.header,children:[(0,h.jsx)(o.Typography,{variant:"h3",component:"span",children:a}),(0,h.jsxs)(o.Typography,{variant:"body2",component:"span",children:[" ","(per day)"]})]})}),r&&(0,h.jsx)(o.Grid,{item:!0,xs:12,md:6,children:(0,h.jsx)(o.Box,{m:"1em 0em",className:u.header,textAlign:{xs:"left",md:"right"},children:(0,h.jsx)(r,{})})})]}),i&&(0,h.jsx)(i,{}
1),n||!g?(0,h.jsx)(o.Box,{display:"flex",justifyContent:"center",width:"100%",children:(0,h.jsx)(O.Skeleton,{width:"90%",height:c})}):(0,h.jsx)(s().Fragment,{children:e.length>0?(0,h.jsx)(o.Box,{p:"1em 1%",className:u.chartScroll,children:(0,h.jsxs)(yu.X,{width:b,height:y,margin:p?{top:8,right:12,left:-16,bottom:0}:void 0,data:1===e.length?x:e,children:[(0,h.jsx)("defs",{children:m.map((e=>(0,h.jsxs)("linearGradient",{id:e.id,x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,h.jsx)("stop",{offset:"0%",stopColor:e.color,stopOpacity:.8}),(0,h.jsx)("stop",{offset:"95%",stopColor:e.color,stopOpacity:0})]},e.id)))}),(0,h.jsx)(yu.dC,{strokeDasharray:"3 3"}),(0,h.jsx)(yu.WX,{dataKey:"date",axisLine:!1,scale:"point",tick:p?{fontSize:10}:void 0}),(0,h.jsx)(yu.h8,{axisLine:!1,width:p?34:void 0,tick:p?{fontSize:10}:void 0,allowDecimals:!1,tickFormatter:e=>this.props.currency?e>1e9?"₹"+(e/1e9).toFixed(0).toString()+"B":e>1e6?"₹"+(e/1e6).toFixed(0).toString()+"M":e>1e3?"₹"+(e/1e3).toFixed(0).toString()+"K":"₹"+e.toString():e>1e9?(e/1e9).toFixed(0).toString()+"B":e>1e6?(e/1e6).toFixed(0).toString()+"M":e>1e3?(e/1e3).toFixed(0).toString()+"K":e.toString()}),(0,h.jsx)(yu.m_,{}),(0,h.jsx)(yu.s$,{wrapperStyle:p?{fontSize:11}:void 0}),t.map(((e,t)=>(0,h.jsx)(yu.Gk,{strokeWidth:2,type:"monotone",dataKey:e,stroke:m[t].color,isAnimationActive:!0,fillOpacity:1,fill:`url(#${m[t].id})`},e)))]})}):(0,h.jsx)(o.Box,{py:1,display:"flex",justifyContent:"center",width:"100%",height:300,alignItems:"center",children:"SCAN-QR"==d?(0,h.jsxs)(o.Typography,{variant:"h6",color:"textSecondary",children:[" ","Start your QR Campaign and Analyse the analytics here."]}):(0,h.jsxs)(o.Typography,{variant:"h6",color:"textSecondary",children:[" ","Nothing to show for now ;)"]})})})]})}}const zu=(0,o.withStyles)((e=>({root:{display:"flex",margin:"3% 0em",paddingTop:"1em",width:"100%",justifyContent:"left",flexDirection:"column",alignItems:"start",backgroundColor:"white",borderRadius:"1em",boxSizing:"border-box",minWidth:0,maxWidth:"100%"},chartScroll:{width:"100%",maxWidth:"100%",boxSizing:"border-box",overflowX:"auto"},heading:{margin:"0.5em"},header:{[e.breakpoints.down("md")]:{padding:"0 20px"},[e.breakpoints.up("sm")]:{padding:"0 30px"}}})))(Wu),Gu=(0,n.memo)((e=>{let{title:t="Performance Over Time",isLoading:a=!1,color:s="hsl(200deg 100% 50%)",highlight:i="",insightsData:r=[],adInsights:l={}}=e;const d=(0,n.useMemo)((()=>{if(!r||0===r.length)return[];const e=(()=>{const e={},t=l?.insights?.bifurcatedInsightsData?.sections||[],a=r[0];if(!a)return e;const n=Object.keys(a);return t.forEach((t=>{if(!t.label)return;const a=t.label.toLowerCase();if(t.key)return void(e[a]=t.key);if(t.dataKey)return void(e[a]=t.dataKey);if(t.field)return void(e[a]=t.field);const s=a.replace(/\s+/g,"_").replace(/[^a-z0-9_]/g,"");if(n.includes(a))return void(e[a]=a);if(n.includes(s))return void(e[a]=s);const o=n.find((e=>{const t=e.toLowerCase();return t===a||t===s||t.includes(a)||a.includes(t)||t.replace(/_/g,"")===s.replace(/_/g,"")}));o&&(e[a]=o)})),e})(),t=i?.toLowerCase()||"impressions",a=e[t]||t;return r.map((e=>{const t=ve()(e.date_start||e.date_stop);let n=parseFloat(e[a]||0);return"ctr"===a&&"string"==typeof e[a]&&(n=parseFloat(e[a])||0),{date:t.format("DD MMM"),fullDate:t.format("YYYY-MM-DD"),[a]:n,key:a}})).sort(((e,t)=>new Date(e.fullDate)-new Date(t.fullDate)))}),[r,i,l]),c=d.length>0?d:[];let p=["total"];return void 0!==c[0]?.key&&(p=[c[0]?.key]),(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"h5",style:{fontWeight:"bold",color:"#333",fontSize:"20px",marginBottom:"24px"},children:t}),a?(0,h.jsx)(O.Skeleton,{variant:"rectangular",width:"100%",height:300,style:{borderRadius:"8px"}}):(0,h.jsx)(zu,{data:c,keys:p,color:s})]})})),Hu=(0,n.memo)((e=>{let{metric:t,key:a,label:n,value:s,tooltip:i,xs:r=6,md:l=1,minWidth:c="20%",highlight:p=!1,onHighlightChange:u,classes:m,isLoading:g=!1,currencySymbol:b}=e,y=s?"number"==typeof s?s.toLocaleString():s:"--";["spend","cpc","cpm","cpp","purchase_roas"].includes(t?.key)&&(y=`${b}${y}`);const x=p===n;return(0,h.jsx)(o.Grid,{item:!0,xs:r,md:l,className:m.metricCardContainer,style:{minWidth:c},children:g?(0,h.jsx)(O.Skeleton,{variant:"rect",width:"100%",height:"100%",className:m.metricCard}):(0,h.jsxs)(o.Box,{className:`${m.metricCard} ${x?m.metricCardHighlighted:""}`,onClick:()=>u&&u(n),children:[(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1,children:[(0,h.jsx)(o.Typography,{variant:"body2",className:x?m.metricCardLabelHighlighted:m.metricCardLabel,children:n}),i&&(0,h.jsx)(o.Tooltip,{enterTouchDelay:0,className:m.tooltipIcon,placement:"top",title:i,children:(0,h.jsx)(d.Info,{className:x?m.metricCardInfoIconHighlighted:m.metricCardInfoIcon})})]}),(0,h.jsx)(o.Typography,{variant:"h4",className:`${m.metricCardValue} ${x?m.metricCardValueHighlighted:""}`,children:y})]})})})),Vu=(0,n.memo)((e=>{let{title:t="Ad Summary",classes:a,graphData:s,isProcessing:i,highlight:r,onHighlightChange:l,adInsights:c,adData:p,assistantDetails:u,mongoAdId:m}=e;const g=c.insights?.bifurcatedInsightsData?.sections||[],b=(0,n.useMemo)((()=>
1{if(0===g.length)return[];const e=new Map(g.map((e=>[String(e.label).toLowerCase(),e]))),t=ea.t4.map((t=>e.get(t.label.toLowerCase())||{...t,key:t.label,value:"--"})),a=new Set(ea.t4.map((e=>e.label.toLowerCase())));return[...t,...g.filter((e=>!a.has(String(e.label).toLowerCase())))]}),[g]),y="USD"===c?.insights?.currency?"$":"₹",[x,f]=(0,n.useState)(null),[A,I]=(0,n.useState)((()=>new Set(b.map(((e,t)=>t)))));(0,n.useEffect)((()=>{b.length>0&&I(new Set(b.map(((e,t)=>t))))}),[b.length]);const C=()=>{f(null)},_=Boolean(x),S=_?"customize-popover":void 0;return(0,h.jsx)(h.Fragment,{children:(0,h.jsxs)(o.Box,{className:a.adSummarySection,children:[(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3,children:[(0,h.jsx)(o.Typography,{variant:"h5",className:a.adSummaryTitle}),(0,h.jsx)(o.Button,{variant:"outlined",size:"small",startIcon:(0,h.jsx)(d.FilterList,{}),onClick:e=>{f(e.currentTarget)},className:a.adSummaryCustomizeButton,children:"Customize"}),(0,h.jsx)(o.Popover,{id:S,open:_,anchorEl:x,onClose:C,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:(0,h.jsxs)(o.Box,{className:a.customizePopoverContent,children:[(0,h.jsx)(o.Typography,{variant:"h6",className:a.customizePopoverTitle,children:"Select Metrics to Display"}),(0,h.jsx)(o.Box,{className:a.customizeCheckboxList,children:b.map(((e,t)=>(0,h.jsx)(o.FormControlLabel,{control:(0,h.jsx)(o.Checkbox,{checked:A.has(t),onChange:()=>(e=>{I((t=>{const a=new Set(t);return a.has(e)?a.size>1&&a.delete(e):a.add(e),a}))})(t),color:"primary"}),label:e.label},t)))}),(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"flex-end",mt:2,className:a.customizeActions,children:[(0,h.jsx)(o.Button,{size:"small",onClick:()=>{I(new Set(b.map(((e,t)=>t))))},children:"Select All"}),(0,h.jsx)(o.Button,{size:"small",onClick:()=>{b.length>0?I(new Set([0])):I(new Set)},style:{marginLeft:"8px"},children:"Deselect All"}),(0,h.jsx)(o.Button,{size:"small",variant:"contained",color:"primary",onClick:C,style:{marginLeft:"8px"},children:"Done"})]})]})})]}),(0,h.jsx)(o.Grid,{container:!0,spacing:2,className:a.adSummaryMetricsGrid,children:b.length>1?b.map(((e,t)=>({...e,originalIndex:t}))).filter((e=>A.has(e.originalIndex))).map((e=>(0,h.jsx)(Hu,{label:e.label,value:e.value,tooltip:e.tooltip,xs:6,md:3,highlight:r,onHighlightChange:l,classes:a,metric:e,currencySymbol:y},e.key))):ea.t4.map(((e,t)=>({...e,originalIndex:t}))).map((e=>(0,h.jsx)(Hu,{label:e.label,value:e.value,tooltip:e.tooltip,xs:6,md:3,highlight:r,onHighlightChange:l,classes:a,currencySymbol:y},e.originalIndex)))}),(0,h.jsx)(Gu,{graphData:s,isLoading:i,keys:[r],color:"hsl(200deg 100% 50%)",highlight:r,insightsData:c.insights?.data||[],adInsights:c})]})})})),Yu=Vu,Zu=a.p+"35ec5d5e2efc020935e13e06b2758637.png",Ku=JSON.parse('{"_meta":{"purpose":"Best-effort, human-curated placement media requirements for AiSensy\'s supported Meta ad platforms/placements. Used ONLY by the offline ADS-200 investigation scripts (verify_undeliverables.js, fetch_outliers.js) to flag CANDIDATE outlier ads for manual review — this is not a live customer-facing feature and is not a substitute for Meta\'s own delivery decision, which no public API exposes for an already-created ad (see /Users/prathamsharma/.claude/plans/no-so-the-issue-sunny-teacup.md for the research trail).","sourcedFrom":["AiSensy whatsapp-rest-api src/config/metaAdsConfig.js (facebookPositions, instagramPositions, whatsappPositions, *_AD_FORMATS tables) — authoritative list of placements AiSensy\'s platform actually validates/sends to Meta","Meta Ads Guide (facebook.com/business/ads-guide), per-placement pages, best available knowledge as of curation date","2026-09-08 audit pass: every canonical entry re-checked via live fetches of Meta\'s current Ads Guide/Help Center/Marketing API docs (real citations added per corrected entry\'s \\"note\\" field, not re-derived from memory). Fixed several stale/incorrect entries (notably: Instagram Reels and Facebook Reels images were wrongly marked unsupported; Instagram Explore is fully retired by Meta as of API v26.0;
1 several min-dimension/aspect-ratio/duration values were copy-pasted from Feed or otherwise stale). Entries left unchanged after this pass either matched Meta\'s current docs, or a dedicated spec page could not be found/accessed — those still carry \\"confidence\\": \\"verify\\" rather than being guessed at."],"lastVerified":"2026-09-08","confidence":"Entries marked \\"confidence\\": \\"verify\\" are approximate and should be re-checked against Meta\'s current Ads Guide page for that placement before being trusted. Entries with \\"adFormat\\": null and \\"confidence\\": \\"unknown\\" have no rule data at all — verify_undeliverables.js must report these as UNKNOWN, never as deliverable or undeliverable.","structure":"Each platform is a map of positionKey -> rule. A rule is either canonical (has mediaRequirements), an alias (\\"aliasOf\\": \\"<canonical key on the same platform>\\"), or unmapped/unknown (\\"confidence\\": \\"unknown\\"). Deprecated positions carry \\"deprecated\\": true. Resolve aliasOf chains before evaluating."},"facebook":{"feed":{"label":"Feed","adFormat":"MOBILE_FEED_STANDARD","confidence":"verify","mediaRequirements":{"image":{"minAspectRatio":0.8,"maxAspectRatio":1.91,"minWidth":600,"minHeight":600},"video":{"minAspectRatio":0.8,"maxAspectRatio":1.91,"minWidth":600,"minHeight":600,"minDurationSec":1,"maxDurationSec":null}}},"notification":{"aliasOf":"feed","note":"AiSensy config reuses MOBILE_FEED_STANDARD for this position (metaAdsConfig.js FACEBOOK_POSITIONS_AD_FORMATS)."},"right_hand_column":{"label":"Right Column","adFormat":"RIGHT_COLUMN_STANDARD","confidence":"verify","note":"Audited 2026-09-08: the file previously locked minAspectRatio/maxAspectRatio to 1.0, which contradicted its own 254x133 (1.91:1) minimum dimensions. Meta\'s supported-ratios help page lists 1.91:1 and 1:1 for this placement (https://www.facebook.com/business/help/682655495435254); range corrected to 1.0-1.91.","mediaRequirements":{"image":{"minAspectRatio":1,"maxAspectRatio":1.91,"minWidth":254,"minHeight":133},"video":{"supported":false}}},"marketplace":{"label":"Marketplace","adFormat":"MARKETPLACE_MOBILE","confidence":"verify","note":"Audited 2026-09-08: previous entry was a copy of Feed\'s requirements. Meta\'s Marketplace ads guide (https://www.facebook.com/business/ads-guide/update/image/facebook-marketplace, .../video/facebook-marketplace) documents 9:16-16:9 (not Feed\'s 4:5-1.91:1) with 1:1 recommended, and a higher recommended minimum resolution (~1080x1080).","mediaRequirements":{"image":{"minAspectRatio":0.5625,"maxAspectRatio":1.7778,"minWidth":1080,"minHeight":1080},"video":{"minAspectRatio":0.5625,"maxAspectRatio":1.7778,"minWidth":1080,"minHeight":1080,"minDurationSec":1,"maxDurationSec":null}}},"story":{"label":"Stories","adFormat":"FACEBOOK_STORY_MOBILE","confidence":"verify","note":"Audited 2026-09-08: video maxDurationSec corrected from a stale 120s to Meta\'s documented 180s (3 min) cap (https://www.facebook.com/business/ads-guide/update/video/facebook-story).","mediaRequirements":{"image":{"minAspectRatio":0.5625,"maxAspectRatio":1.91,"minWidth":500,"minHeight":889},"video":{"minAspectRatio":0.5625,"maxAspectRatio":1.91,"minWidth":500,"minHeight":889,"minDurationSec":1,"maxDurationSec":180}}},"stories":{"aliasOf":"story"},"search":{"label":"Search","adFormat":"INSTAGRAM_SEARCH_CHAIN","confidence":"verify","note":"AiSensy config maps Facebook \'search\' to Meta\'s INSTAGRAM_SEARCH_CHAIN ad_format (metaAdsConfig.js:83) — kept as-is from AiSensy\'s own mapping, not re-derived here. Audited 2026-09-08: this ad_format naming looks like a real mislabel worth a second look in AiSensy\'s own config (search is a distinct, current Facebook placement per Meta\'s Marketing API placement-targeting reference), but that\'s outside this file\'s scope. Dimensions corrected — Meta\'s aspect-ratio help page lists 9:16 as a supported ratio here too (https://www.facebook.com/business/help/682655495435254), and its ads-guide image page documents a 600x600 minimum, not 500x500 (https://www.facebook.com/business/ads-guide/update/image/facebook-search).","mediaRequirements":{"image":{"minAspectRatio":0.5625,"maxAspectRatio":1.91,"minWidth":600,"minHeight":600},"video":{"minAspectRatio":0.5625,"maxAspectRatio":1.91,"minWidth":600,"minHeight":600,"minDurationSec":1,"maxDurationSec":null}}}
1,"instream_video":{"label":"In-Stream Video","adFormat":"INSTREAM_VIDEO_MOBILE","confidence":"verify","note":"Audited 2026-09-08: image was wrongly marked unsupported — Meta\'s Help Center explicitly documents photo ads on Facebook In-Stream Video, 1.91:1-1:1, min 1080x1080 (https://www.facebook.com/business/help/1199881793491951, https://www.facebook.com/business/ads-guide/update/image/facebook-instream-video). Video AR tightened to the documented 16:9-1:1 set; maxDurationSec widened from a desktop-only 15s to the documented mobile cap of 600s (10 min) — Meta\'s actual limit differs by surface (desktop 5-15s, mobile 5s-10min), which this schema can\'t express, so the wider/more permissive bound was chosen to avoid false undeliverable flags.","mediaRequirements":{"image":{"minAspectRatio":1,"maxAspectRatio":1.91,"minWidth":1080,"minHeight":1080},"video":{"minAspectRatio":1,"maxAspectRatio":1.7778,"minWidth":1080,"minHeight":1080,"minDurationSec":5,"maxDurationSec":600}}},"in_stream_video":{"aliasOf":"instream_video"},"in_feed_video":{"aliasOf":"feed","note":"In-feed video follows standard Feed media requirements."},"facebook_reels":{"label":"Reels","adFormat":"FACEBOOK_REELS_MOBILE","confidence":"verify","note":"Audited 2026-09-08: image was wrongly marked unsupported. Meta\'s Ads Guide has a dedicated image spec page for this placement stating \'you can use photo format in Reels ads\' — 9:16, min 600x600, JPG/PNG (https://www.facebook.com/business/ads-guide/update/image/facebook-facebook-reels). Video aspect-ratio range widened from a locked 9:16 to Meta\'s documented supported set (1.91:1 down to 9:16) (https://www.facebook.com/business/ads-guide/update/video/facebook-facebook-reels). maxDurationSec (90s) could not be pinned to an unambiguous primary source and was left unchanged.","mediaRequirements":{"image":{"minAspectRatio":0.5625,"maxAspectRatio":1.91,"minWidth":600,"minHeight":600},"video":{"minAspectRatio":0.5625,"maxAspectRatio":1.91,"minWidth":500,"minHeight":889,"minDurationSec":1,"maxDurationSec":90}}},"reels":{"aliasOf":"facebook_reels"},"in_reels_video":{"aliasOf":"facebook_reels"},"facebook_reels_overlay":{"label":"Reels Overlay","adFormat":"FACEBOOK_REELS_BANNER","confidence":"unknown","note":"Overlay banner format on top of organic Reels content — dimensions unconfirmed, needs verification against Meta\'s current Ads Guide before use."},"reels_overlay":{"aliasOf":"facebook_reels_overlay"},"profile_feed":{"label":"Profile Feed","adFormat":"FACEBOOK_PROFILE_FEED_MOBILE","confidence":"verify","mediaRequirements":{"image":{"minAspectRatio":0.8,"maxAspectRatio":1.91,"minWidth":600,"minHeight":600},"video":{"minAspectRatio":0.8,"maxAspectRatio":1.91,"minWidth":600,"minHeight":600,"minDurationSec":1,"maxDurationSec":null}}},"facebook_profile_feed":{"aliasOf":"profile_feed"},"facebook_profile_reels":{"aliasOf":"facebook_reels","note":"Reels surfaced on a profile use the same Reels media requirements."},"video_feeds":{"label":"Suggested Videos (deprecated)","adFormat":null,"deprecated":true,"confidence":"unknown","note":"Listed in AiSensy\'s DEPRECATED_FACEBOOK_POSITIONS (metaAdsConfig.js:201) — stripped before reaching the Graph API. Should never appear in live targeting; treat as N/A, not undeliverable."},"instant_article":{"adFormat":null,"confidence":"unknown","note":"Not present in AiSensy\'s FACEBOOK_POSITIONS_AD_FORMATS mapping; no verified spec."},"in_article":{"aliasOf":"instant_article"},"groups_feed":{"aliasOf":"feed","note":"Not present in AiSensy\'s FACEBOOK_POSITIONS_AD_FORMATS mapping; approximated as standard Feed requirements pending verification."},"facebook_groups":{"aliasOf":"groups_feed"},"ar_ads":{"adFormat":null,"confidence":"unknown","note":"Requires an AR effect asset, not a plain image/video — out of scope for dimension-based checks."},"rewarded_video":{"label":"Rewarded Video (Audience Network)","adFormat":null,"confidence":"unknown","note":"Not present in AiSensy\'s FACEBOOK_POSITIONS_AD_FORMATS mapping; no verified spec. Audited 2026-09-08: confirmed as a real, current Meta placement, but it lives under audience_network_positions in Meta\'s own schema, not facebook_positions — mis-filed under this platform\'s section (https://developers.facebook.com/docs/marketing-api/audiences
1/reference/placement-targeting/)."},"external":{"adFormat":null,"confidence":"unknown","note":"Audience Network-style placement key; not present in AiSensy\'s FACEBOOK_POSITIONS_AD_FORMATS mapping, no verified spec. Audited 2026-09-08: does not appear in Meta\'s current live facebook_positions or audience_network_positions enums — likely a legacy/deprecated identifier."}},"instagram":{"stream":{"label":"Feed","adFormat":"INSTAGRAM_STANDARD","confidence":"verify","note":"Audited 2026-09-08: minWidth/minHeight corrected from 600 to Meta\'s documented 500px minimum (https://www.facebook.com/business/ads-guide/update/image/instagram-feed).","mediaRequirements":{"image":{"minAspectRatio":0.8,"maxAspectRatio":1.91,"minWidth":500,"minHeight":500},"video":{"minAspectRatio":0.8,"maxAspectRatio":1.91,"minWidth":500,"minHeight":500,"minDurationSec":1,"maxDurationSec":null}}},"instagram_stream":{"aliasOf":"stream"},"story":{"label":"Stories","adFormat":"INSTAGRAM_STORY","confidence":"verify","note":"Audited 2026-09-08: video maxDurationSec corrected — Meta documents up to 60 minutes with automatic splitting into multiple Story cards, not a 120s hard cap (https://www.facebook.com/business/ads-guide/update/video/instagram-story), so the cap was removed rather than guessing a new fixed number.","mediaRequirements":{"image":{"minAspectRatio":0.5625,"maxAspectRatio":1.91,"minWidth":500,"minHeight":889},"video":{"minAspectRatio":0.5625,"maxAspectRatio":1.91,"minWidth":500,"minHeight":889,"minDurationSec":1,"maxDurationSec":null}}},"instagram_story":{"aliasOf":"story"},"explore":{"label":"Explore","adFormat":"INSTAGRAM_EXPLORE_CONTEXTUAL","confidence":"verify","deprecated":true,"note":"Audited 2026-09-08: RETIRED by Meta. Graph/Marketing API v26.0 changelog states the Instagram Explore Feed placement is no longer available — delivery shifts to other eligible placements, and requests explicitly specifying Explore return an error (https://developers.facebook.com/docs/graph-api/changelog/version26.0/). Media requirements below are kept only as historical reference; treat this placement as unavailable regardless of creative.","mediaRequirements":{"image":{"minAspectRatio":0.8,"maxAspectRatio":1.91,"minWidth":500,"minHeight":500},"video":{"minAspectRatio":0.8,"maxAspectRatio":1.91,"minWidth":500,"minHeight":500,"minDurationSec":1,"maxDurationSec":null}}},"instagram_explore":{"aliasOf":"explore"},"explore_home":{"label":"Explore Home","adFormat":"INSTAGRAM_EXPLORE_GRID_HOME","confidence":"verify","note":"Audited 2026-09-08: maxAspectRatio corrected from 1.0 to 1.91 — Meta documents the same 0.8-1.91 range as standard Feed, not a strict-square clamp (https://www.facebook.com/business/ads-guide/update/image/instagram-explore-home). Still a live, current placement, unaffected by the separate Explore-feed retirement above.","mediaRequirements":{"image":{"minAspectRatio":0.8,"maxAspectRatio":1.91,"minWidth":500,"minHeight":500},"video":{"minAspectRatio":0.8,"maxAspectRatio":1.91,"minWidth":500,"minHeight":500,"minDurationSec":1,"maxDurationSec":null}}},"reels":{"label":"Reels","adFormat":"INSTAGRAM_REELS","confidence":"verify","note":"Audited 2026-09-08: image was wrongly marked unsupported. Meta\'s Ads Guide has a dedicated, current image spec page for this placement — JPG/PNG, 9:16, min 1440x2560 (min width 500px), max 30MB (https://www.facebook.com/business/ads-guide/update/image/instagram-reels). Video maxDurationSec corrected from 90s to Meta\'s documented 15 min (900s) cap (https://www.facebook.com/business/ads-guide/update/video/instagram-reels).","mediaRequirements":{"image":{"minAspectRatio":0.5625,"maxAspectRatio":0.5625,"minWidth":500,"minHeight":889},"video":{"minAspectRatio":0.5625,"maxAspectRatio":0.5625,"minWidth":500,"minHeight":889,"minDurationSec":1,"maxDurationSec":900}}},"instagram_reels":{"aliasOf":"reels"},"reels_overlay":{"label":"Reels Overlay","adFormat":null,"confidence":"unknown","note":"Not present in AiSensy\'s INSTAGRAM_POSITIONS_AD_FORMATS mapping; overlay banner dimensions unconfirmed."},"instagram_reels_overlay":{"aliasOf":"reels_overlay"},"profile_feed":{"label":"Profile Feed","adFormat":"INSTAGRAM_PROFILE_FEED","confidence":"verify","mediaRequirements":{"image":{"minAspectRatio":0.8,"maxAspectRatio":1.91,"minWidth":600,"minHeight":600},"video":{"minAspectRatio":0.8,"maxAspectRatio":1.91,"minWidth":600,"minHeight":600,"minDurationSec":1,"maxDurationSec":null}}},"instagram_profile_feed":{"aliasOf":"profile_feed"},"profile_reels":{"aliasOf":"reels","note":"Reels surfaced on a profile use the same Reels media requirements."},"ig_search":{"label":"Search","adFormat":"INSTAGRAM_SEARCH_GRID","confidence":"verify","note":"Grid layout similar to Explore Home per Meta\'s Ads Guide.","mediaRequirements":{"image":{"minAspectRatio":0.8,"maxAspectRatio":1,"minWidth":500,"minHeight":500},"video":{"minAspectRatio":0.8,"maxAspectRatio":1,"minWidth":500,"minHeight":500,"minDurationSec":1,"maxDurationSec":null}}},"instagram_shop":{"adFormat":null,"confidence":"unknown","note":"Shopping-tag placement; not present in AiSensy\'s INSTAGRAM_POSITIONS_AD_FORMATS mapping, requires product-tag setup rather than plain dimension checks."},"igtv":{"adFormat":null,"deprecated":true,"confidence":"unknown","note":"Meta folded IGTV into the general video experience; not present in AiSensy\'s INSTAGRAM_POSITIONS_AD_FORMATS mapping. Treat as legacy/should not appear in current targeting."}},"whatsapp":{"status":{"label":"Status","adFormat":"INSTAGRAM_STORY","confidence":"verify","note":"Meta has no dedicated ad_format for WhatsApp Status — AiSensy\'s config (metaAdsConfig.js:184-196) reuses INSTAGRAM_STORY and always pairs this placement with Instagram Story targeting (see validateMetaAdPlacements\'s superRefine check in metaAdsValidators.js). Media requirements mirror Instagram/Facebook Stories. Audited 2026-09-08: confirmed as a genuine Meta API requirement, not just an AiSensy convention — Meta\'s Marketing API placement-targeting reference states verbatim that WhatsApp Status requires Instagram Story to also be selected (https://developers.facebook.com/documentation/ads-commerce/marketing-api/audiences
1/reference/placement-targeting). No separate WhatsApp Status creative spec is documented anywhere; maxDurationSec cap removed to match the Instagram Story correction above (some secondary, non-Meta sources claim a distinct 30s cap for Click-to-WhatsApp Status specifically, but that could not be confirmed against any primary Meta page).","mediaRequirements":{"image":{"minAspectRatio":0.5625,"maxAspectRatio":1.91,"minWidth":500,"minHeight":889},"video":{"minAspectRatio":0.5625,"maxAspectRatio":1.91,"minWidth":500,"minHeight":889,"minDurationSec":1,"maxDurationSec":null}}}}}');const Ju=(0,n.memo)((e=>{let{label:t,value:a,tooltip:n,badgeColor:s,showBadge:i=!1,classes:r}=e;const l=a?(0,ea.v7)(a):"--",c=s||(0,ea.br)(a);return(0,h.jsx)(o.Grid,{container:!0,className:r.performanceMetricRow,children:(0,h.jsxs)(o.Grid,{item:!0,xs:12,container:!0,className:r.performanceMetricRowContainer,children:[(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",children:[(0,h.jsx)(o.Typography,{variant:"h5",className:r.performanceMetricLabel,children:t}),n&&(0,h.jsx)(o.Box,{mt:"4px",ml:1,children:(0,h.jsx)(o.Tooltip,{enterTouchDelay:0,className:r.tooltipIcon,placement:"top",title:n,children:(0,h.jsx)(d.Info,{color:"disabled"})})})]}),(0,h.jsx)(o.Box,{children:i?(0,h.jsx)(o.Chip,{label:l,size:"small",style:{backgroundColor:(0,ea.j5)(c,.08),color:c,fontWeight:"bold",borderRadius:"12px",padding:"4px 8px"}}):(0,h.jsx)(o.Typography,{variant:"body1",className:r.performanceMetricValue,children:l})})]})})})),$u=e=>{if(!e)return"";const t={};Nd.A.forEach((e=>{t[e.isoCode]=e.name}));const a=[];return["countries","regions","cities","places","zips"].forEach((n=>{(e[n]||[]).forEach((e=>{if("string"==typeof e)a.push(t[e]||e);else if(e?.name){const t=e.country_name&&e.country_name!==e.name?`, ${e.country_name}`:"";a.push(`${e.name}${t}`)}}))})),a.join(" · ")},qu=e=>{if(!e||"object"!=typeof e)return"";const t=e.flexible_spec?.[0]||e,a=[];return Object.values(t).forEach((e=>{Array.isArray(e)&&e.forEach((e=>{e?.name&&a.push(e.name)}))})),a.join(" · ")},Xu=(0,n.memo)((e=>{let{metrics:t=[],title:a="CREATIVE PERFORMANCE",classes:n}=e;return(0,h.jsxs)(o.Box,{className:n.creativePerformanceSection,children:[(0,h.jsx)(o.Typography,{variant:"h5",className:n.creativePerformanceTitle,children:a}),t.map(((e,t)=>(0,h.jsx)(Ju,{label:e.label,value:e.value,tooltip:e.tooltip,badgeColor:e.badgeColor,showBadge:!1!==e.showBadge,classes:n},t)))]})})),Qu=(0,n.memo)((e=>{let{details:t=[],title:a="DETAILS",classes:n}=e;const s=e=>{let{label:t,value:a,tooltip:s}=e;return(0,h.jsxs)(o.Grid,{container:!0,className:n.performanceMetricRow,children:[(0,h.jsxs)(o.Grid,{item:!0,xs:12,container:!0,alignItems:"center",children:[(0,h.jsx)(o.Typography,{variant:"h6",gutterBottom:!0,children:t}),s&&(0,h.jsx)(o.Box,{mb:"4px",ml:1,children:(0,h.jsx)(o.Tooltip,{enterTouchDelay:0,className:n.tooltipIcon,placement:"top",title:s,children:(0,h.jsx)(d.Info,{color:"disabled"})})})]}),(0,h.jsx)(o.Grid,{item:!0,xs:12,container:!0,alignItems:"center",children:(0,h.jsx)(o.Typography,{variant:"h5",paragraph:!0,children:a})})]})};return(0,h.jsxs)(o.Box,{className:n.detailsSection,children:[(0,h.jsx)(o.Typography,{variant:"h5",className:n.detailsTitle,children:a}),t.map(((e,t)=>e&&(0,h.jsx)(s,{label:e.label,value:e.value,tooltip:e.tooltip},t)))]})})),em=(0,n.memo)((e=>{let{adInsights:t}=e;const a=(0,n.useRef)(null),s=(0,n.useRef)(null),[o,i]=(0,n.useState)(1),r=t?.insights?.previewData?.[0]?.body||null,l=(0,n.useMemo)((()=>r?r.replace(/scrolling="yes"/g,'scrolling="no"'):null),[r]);return(0,n.useEffect)((()=>{if(!s.current)return;const e=s.current.querySelector("iframe");if(!e)return;const t=()=>{const t=parseFloat(e.getAttribute("width")||""),a=parseFloat(e.getAttribute("height")||""),n=e.getBoundingClientRect(),s=Number.isFinite(t)&&t>0?t:n.width,o=Number.isFinite(a)&&a>0?a:n.height;if(!s||!o)return;const r=Math.min(318/s,620/o);i(r)};e.addEventListener("load",t);const n=setTimeout(t,50),o=new ResizeObserver(t);return a.current&&o.observe(a.current),()=>{e.removeEventListener("load",t),clearTimeout(n),o.disconnect()}}),[l]),l?(0,h.jsx)("div",{ref:a,style:{width:318,height:620,margin:"0 auto",overflow:"hidden",position:"relative",borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"16
1px"},children:(0,h.jsx)("div",{style:{transform:`scale(${o})`,transformOrigin:"center center",willChange:"transform"},children:(0,h.jsx)("div",{ref:s,style:{display:"inline-block",pointerEvents:"auto"},dangerouslySetInnerHTML:{__html:l}})})}):(0,h.jsx)(O.Skeleton,{variant:"rectangular",width:318,height:"540px",style:{borderRadius:"8px",margin:"0 auto",marginBottom:"16px"}})})),tm=(0,n.memo)((e=>{let{classes:t,accountName:a,accountId:s,adData:i,isDailyBudgetAd:r,currencySymbol:l,createdAt:d,adStartDate:c,adStopDate:p,fetchAdInsights:u,adInsights:m,qualityRanking:g,engagementRateRanking:b,selectedPlacement:y,setSelectedPlacement:x}=e;const f="carousel"===i?.adFormat,A=(0,n.useMemo)((()=>{const e={facebook:new Set,instagram:new Set};return[{adKey:"facebookPositions",targetKey:"facebook_positions",resultKey:"facebook"},{adKey:"instagramPositions",targetKey:"instagram_positions",resultKey:"instagram"}].forEach((t=>{let{adKey:a,targetKey:n,resultKey:s}=t;const o=i?.adPlacements?.[a],r=i?.placementTargets?.[n];Array.isArray(o)&&o.length>0&&Array.isArray(r)&&o.forEach((t=>{const a=t?.value||t;r.includes(a)||e[s].add(a)}))})),e}),[i?.adPlacements,i?.placementTargets]),I=(0,n.useMemo)((()=>{const e={};return["facebook","instagram"].forEach((t=>{A[t].forEach((a=>{const n=function(e,t,a){const n=e[t];if(!n)return null;let s=a,o=n[s];const i=new Set;for(;o&&o.aliasOf;){if(i.has(o.aliasOf))return null;i.add(o.aliasOf),s=o.aliasOf,o=n[s]}return o?{key:s,rule:o}:null}(Ku,t,a);if(!n||"unknown"===n.rule.confidence)return;const s=function(e){if(e.deprecated)return"This placement has been retired by Meta and no longer delivers, regardless of creative";const t=e.mediaRequirements;if(!t)return null;const a=t.image,n=t.video;
1if(!1===a?.supported&&n)return"Use a video for this placement — it doesn't support images";if(!1===n?.supported&&a)return"Use an image for this placement — it doesn't support videos";const s=!1!==a?.supported?a:n;if(!s)return null;const o=[];return null!=s.minHeight&&o.push(`height = ${s.minHeight}px`),null!=s.minWidth&&o.push(`width = ${s.minWidth}px`),o.length?`Use media with minimum ${o.join(" & ")} for this placement`:null}(n.rule);s&&(e[`${t}:${a}`]=s)}))})),e}),[A]),C=(e,t,a)=>{const n=I[`${e}:${t}`];return n?`Ad undeliverable to ${a}. ${n}.`:`Ad undeliverable to ${a} — the ad creative doesn't meet Meta's size/format requirements for this placement.`},_=(0,n.useMemo)((()=>[...(!i.adPlacements?.facebookPositions&&i?.platforms?.includes("facebook")?ea._R:i?.adPlacements?.facebookPositions)?.map((e=>{const t=e?.value||e;if(f&&"story"===t)return null;const a=ea._R.find((e=>e.value===t));if(a){const e=A.facebook.has(t),n=`Facebook ${a.label}`;return{...a,label:n,value:a.adFormat,disabled:e,disabledReason:e?C("facebook",t,n):void 0}}return null})).filter(Boolean)||[],...(!i.adPlacements?.instagramPositions&&i?.platforms?.includes("instagram")?ea.s3:i?.adPlacements?.instagramPositions)?.map((e=>{const t=e?.value||e,a=ea.s3.find((e=>e.value===t));if(a){const e=A.instagram.has(t),n=`Instagram ${a.label}`;return{...a,label:n,value:a.adFormat,disabled:e,disabledReason:e?C("instagram",t,n):void 0}}return null})).filter(Boolean)||[],...(!i.adPlacements?.whatsappPositions&&i?.platforms?.includes("whatsapp")?ea.y:i?.adPlacements?.whatsappPositions)?.map((e=>{const t=e?.value||e;if(f&&"status"===t)return null;const a=ea.y.find((e=>e.value===t));return a?{...a,label:`WhatsApp ${a.label}`,value:a.adFormat}:null})).filter(Boolean)||[]]),[i?.adPlacements,i?.platforms,f,A,I]),S=(0,n.useMemo)((()=>y&&_.find((e=>e.value===y))||null),[y,_]),v=(0,n.useMemo)((()=>_.some((e=>e.disabled))),[_]);return(0,h.jsx)(o.Grid,{item:!0,xs:12,md:3,className:t.adPreviewContainer,children:(0,h.jsxs)("div",{className:t.noRoundedBoxhead,style:{height:"100%"},children:[(0,h.jsxs)(o.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",className:t.adPreviewHeader,children:[(0,h.jsx)(o.Typography,{variant:"h4",className:t.adPreviewTitle,gutterBottom:!0,children:"AD Creative Preview"}),i?.previewLink&&(0,h.jsx)("img",{src:Zu,onClick:()=>window.open(i?.previewLink,"_blank"),className:t.adPreviewShareIcon})]}),(0,h.jsxs)(o.Box,{className:t.adPreviewContent,children:[(0,h.jsx)(o.Box,{className:t.adPreviewInnerContent,children:(0,h.jsx)(X,{options:_,value:S,onChange:async(e,t)=>{t&&(e=>{x(e.target.value),u(e.target.value)})({target:{value:t.value}})},placeholder:"Select Preview",classes:t,label:"",description:"Choose the preview format to view your ad",marginBottom:"8px",getOptionDisabled:e=>e.disabled,getOptionTooltip:e=>e.disabledReason,hasError:v,errorTooltip:"Ad undeliverable to one or more placements — the ad creative doesn't meet Meta's size/format requirements."})}),(0,h.jsx)(em,{adInsights:m}),(0,h.jsx)(Xu,{classes:t,metrics:[g&&{label:"Quality Ranking",value:g,tooltip:"A ranking of your ad's perceived quality. Quality is measured using feedback on your ads and the post-click experience. Your ad is ranked against ads that competed for the same audience.",showBadge:!0},b&&{label:"Engagement Ranking",value:b,tooltip:"A ranking of your ad's expected engagement rate. Engagement includes all clicks, likes, comments and shares. Your ad is ranked against ads that competed for the same audience.",showBadge:!0}].filter(Boolean)})]}),(0,h.jsx)(Qu,{classes:t,details:[{label:"Ad Account",value:i?.adAccountId?`${i?.adAccountId.split("_")[1]}`:"--",tooltip:"Ad account used for advertisement"},{label:"Gender",value:i?.gender||"--",tooltip:"Audience selection for advertisement"},{label:r?"Daily Budget":"Lifetime Budget",value:r?`${l} ${i?.dailyBudget&&!isNaN(i.dailyBudget/100)?(i.dailyBudget/100).toLocaleString():"--"}`:`${l} ${i?.lifetimeBudget&&!isNaN(i.lifetimeBudget/100)?(i.lifetimeBudget/100).toLocaleString():"--"}`,tooltip:`Selected ${r?"daily budget":"lifetime budget"} for advertisement`},{label:"Age Group",value:`${i?.minAge||"--"} ~ ${i?.maxAge||"--"}`,tooltip:"Audience age group selected for advertisement"},{label:"Locations",value:$u(i?.geoLocation)||"--",tooltip:"Locations targeted by the advertisement"},!!$u(i?.excludedGeoLocation)&&{label:"Excluded Locations",value:$u(i?.excludedGeoLocation),tooltip:"Locations excluded from the advertisement"},!!qu(i?.advanceTargets)&&{label:"Detailed Targeting",value:qu(i?.advanceTargets),tooltip:"Interests, behaviours and demographics targeted by the advertisement"},(i?.customAndLookalikeAudiences||[]).length>0&&{label:"Custom Audiences",value:(i?.customAndLookalikeAudiences||[]).map((e=>
1e?.name||e?.audienceId)).filter(Boolean).join(" · "),tooltip:"Custom and lookalike audiences included in the advertisement"},1===i?.advantageAudience&&{label:"Advantage+ Audience",value:"Enabled",tooltip:"Meta expands your audience beyond your selections when it's likely to improve results"},{label:"Created At",value:d?new Date(d).toLocaleDateString(["en"],{day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"numeric"}):"--",tooltip:"Time of advertisement creation"},c&&{label:"Ad Start Date",value:new Date(c).toLocaleDateString(["en"],{day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"numeric"}),tooltip:"The ads started running on this date."},p&&{label:"Ad Stop Date",value:new Date(p).toLocaleDateString(["en"],{day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"numeric"}),tooltip:"The ads will stop running on this date."}].filter(Boolean)})]})})})),am=tm,nm=(0,o.styled)(o.Switch)((e=>{let{theme:t}=e;return{width:48,height:24,padding:0,display:"flex","&:active":{'& [class*="MuiSwitch-thumb"]':{width:22},'& [class*="MuiSwitch-switchBase"].Mui-checked':{transform:"translateX(18px)"}},'& [class*="MuiSwitch-switchBase"]':{padding:3,"&.Mui-checked":{transform:"translateX(24px)",color:"#fff",'& + [class*="MuiSwitch-track"]':{opacity:1,backgroundColor:"#2ECA45"}}},'& [class*="MuiSwitch-thumb"]':{boxShadow:"0 2px 4px 0 rgb(0 35 11 / 20%)",width:18,height:18,borderRadius:9,transition:t.transitions.create(["width"],{duration:200})},'& [class*="MuiSwitch-track"]':{borderRadius:12,opacity:1,backgroundColor:"rgba(0,0,0,.25)",boxSizing:"border-box"}}})),sm=e=>{const{clicks:t,spend:a}=e||{},n=t?+t:0,s=a?+a:0;let o=n>0?s:0;return n&&s&&(o=(s/n).toFixed(2).toLocaleString()),o.toString()},om=(e,t,a)=>(0,n.useMemo)((()=>{if(!e)return{ctr:"0",cpm:null,costPerClick:"0",formattedImpressions:"--",formattedReach:"--"};const{clicks:t,impressions:n,reach:s,spend:o,actions:i=[]}=e,r=((e,t)=>{const a=e?parseFloat(e):0,n=t?parseFloat(t):0;return n>0?(a/n*100).toFixed(2):"0"})(t,n),l=((e,t,a)=>{const n=e?parseFloat(e):0,s=t?parseFloat(t):0;if(s>0)return`${a}${(n/s*1e3).toFixed(2)}`;return null})(o,n,a),d=sm(e),c=(p=parseFloat(n||0))?p>=1e3?`${(p/1e3).toFixed(1)}K`:p.toString():"0";var p;const u=(e=>e?e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString():"0")(parseFloat(s||0)),m=i.find((e=>"link_click"===e.action_type)),h=m&&parseFloat(m.value)||0,g=i.find((e=>"landing_page_view"===e.action_type)),b=i.find((e=>"omni_landing_page_view"===e.action_type)),y=(g&&parseFloat(g.value)||0)+(b&&parseFloat(b.value)||0),x=i.filter((e=>e.action_type&&e.action_type.startsWith("offsite"))).reduce(((e,t)=>e+(parseFloat(t.value)||0)),0),f=t?parseFloat(t):0;return{ctr:r,cpm:l,costPerClick:d,formattedImpressions:c,formattedReach:u,linkClicks:h,landingPageViews:y,outboundClicks:x,landingPageViewRate:f>0?(y/f*100).toFixed(2):"0",linkClickRate:n&&parseFloat(n)>0?(h/parseFloat(n)*100).toFixed(2):"0"}}),[e,a]),im=(e,t,a,s,o)=>{const[i,r]=(0,n.useState)({}),[l,d]=(0,n.useState)({}),[c,p]=(0,n.useState)(!0),[u,m]=(0,n.useState)(null),[h,g]=(0,n.useState)({}),b=(0,n.useCallback)((async e=>{if(e&&t){p(!0),m(null);try{const n=await o(a(t,e)),s=sm(n?.adData),i={...n?.adData,costPerClick:s};r(i),d(n?.adAccount||{})}catch(e){console.error("Error syncing ad:",e),m(e?.response?.data?.message||e?.message||"Something went wrong");const{action:a,assistant:n}=e?.response?.data||{};"reconnect"===a&&n&&s&&setTimeout((()=>{s.replace(`${Xe(t)}`)}
1),1500)}finally{p(!1)}}}),[t,a,s]);return(0,n.useEffect)((()=>{e&&t&&b(e)}),[e,t,b]),{adData:i,adAccount:l,pageDetails:h,isLoading:c,error:u,fetchAd:b}};class rm extends n.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("Ad Analytics Error:",e,t)}render(){return this.state.hasError?(0,h.jsxs)(o.Box,{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",style:{padding:"48px",minHeight:"400px"},children:[(0,h.jsx)(o.Typography,{variant:"h5",color:"error",gutterBottom:!0,children:"Something went wrong"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:this.state.error?.message||"An unexpected error occurred"}),(0,h.jsx)(o.Button,{variant:"contained",color:"primary",onClick:()=>window.location.reload(),style:{marginTop:"16px"},children:"Reload Page"})]}):this.props.children}}const lm=e=>e.assistantDetails.data,dm=e=>e.ads?.adInsights||{isLoading:!1,iframePreview:null,insights:null,error:null},cm=e=>e.ads?.syncAd||{isLoading:!1,adData:null,adAccount:null,error:null},pm=(0,o.withStyles)((e=>({root:{width:"100%",flex:1,minHeight:0,background:"rgb(249,249,249)",boxSizing:"border-box",overflowX:"hidden",overflowY:"hidden",position:"relative"},overlay:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(255, 255, 255, 0.8)",backdropFilter:"blur(2px)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center"},summaryPanel:{width:"100%",position:"relative",backgroundColor:"white",borderRadius:"8px",overflowX:"hidden",scrollbarWidth:"thin",scrollbarColor:"transparent transparent","&:hover":{scrollbarColor:"#c1c1c1 transparent"},"&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{backgroundColor:"transparent",borderRadius:"3px"},"&:hover::-webkit-scrollbar-thumb":{backgroundColor:"#c1c1c1","&:hover":{backgroundColor:"#a8a8a8"}}},tableHeader:{justifyContent:"center",background:"white",padding:4,width:"calc(100% - 50px)"},cells:{padding:24,color:"grey",borderBottom:"1px solid #ecebeb"},pageTitleContainer:{position:"sticky",zIndex:100,top:0,boxSizing:"border-box",boxShadow:"0 0 11px rgb(230 230 230)",[e.breakpoints.down("md")]:{},[e.breakpoints.down("sm")]:{}},tableWrapper:{overflowX:"auto",width:"100%",margin:"0em 1em",height:"100%"},tableItem:{justifyContent:"center",background:"white",padding:4,width:"calc(100% - 50px)"},fixedBottomContainer:{display:"flex",width:"100%",alignItems:"center",justifyContent:"center",background:"white",overflow:"hidden",padding:"0.5em 0"},fullWidth:{width:"100%",background:"white"},roundedBox:{display:"flex",flexDirection:"column",borderRadius:"12px",backgroundColor:"white",border:"1px black",margin:"1em",padding:"1.2em",paddingLeft:"2em"},noRoundedBoxhead:{display:"flex",flexDirection:"column",backgroundColor:"white",border:"1px black",overflowY:"auto",paddingTop:"16px","&:hover":{scrollbarWidth:"thin",scrollbarColor:"#c1c1c1 transparent"},"&:hover::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar":{width:"3px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{borderRadius:"3px",width:"6px"},"&:hover::-webkit-scrollbar-thumb":{backgroundColor:"#c1c1c1","&:hover":{backgroundColor:"#a8a8a8"}}},editbox:{background:"white",display:"flex",flexDirection:"column",margin:"1em 1em",[e.breakpoints.down("sm")]:{width:"100%",borderRadius:"12px"},[e.breakpoints.up("sm")]:{width:"35%",borderRadius:"12px"}},editboxload:{display:"flex",flexDirection:"column",margin:"1em 1em",justifyContent:"center",width:"90%",borderRadius:"12px",height:"300px"},roundedBox2:{[e.breakpoints.down("sm")]:{height:"auto",borderRadius:"12px"},[e.breakpoints.up("sm")]:{height:"350px",borderRadius:"12px"},height:"350px",backgroundColor:"white",border:"1px black",padding:"1.5em 1.5em 0em 1.5em"},graphData:{background:"white",width:"65%",margin:"1em 1em",[e.breakpoints.down("sm")]:{width:"100%",borderRadius:"12px"},[e.breakpoints.up("sm")]:{width:"60%",borderRadius:"12px"}}
1,graphDataload:{display:"flex",margin:"1em 1em",justifyContent:"center",width:"95%",height:"300px"},roundedBoxload:{width:"100%",height:"200px",borderRadius:"12px"},dateFilterContainer:{padding:"0.5em",backgroundColor:"white",borderRadius:"8px",marginTop:"1em",marginBottom:"30px",width:"auto"},dateFilterContainer1:{padding:"1em 0em",backgroundColor:"white",width:"auto"},messageCountContainer:{display:"flex",flexDirection:"column",borderRadius:"12px",backgroundColor:"white",border:"1px black",margin:"1em",padding:"1.2em",paddingLeft:"2em",paddingBottom:"10px"},attachTooltipPopper:{zIndex:3002},textField:{width:200,padding:"2px 16px"},dataContainer:{padding:"2em",minWidth:"10vw"},previewBox:{marginTop:"32px",margin:"1em","& > div":{margin:"auto",minWidth:"auto",maxWidth:"none",width:"auto"}},emptyMessage:{width:"100%",textAlign:"center",position:"relative",bottom:"70px",height:0},exportContainer:{marginBottom:"1em",display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",[e.breakpoints.down("xs")]:{flexDirection:"column",alignItems:"unset"}},qualityStatus:{padding:"4px",color:"white",fontWeight:"600"},sort:{height:"15px",width:"27px",padding:"2px",color:e.palette.primary.main,cursor:"pointer"},rotationIcon:{animation:"adsSpinnerRotation 2s infinite linear"},display_500:{display:"none",[e.breakpoints.up(500)]:{display:"inline-flex"}},displayNone_500:{display:"none",[e.breakpoints.down(500)]:{display:"inline-flex"}},"@keyframes rotation":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(359deg)"}},dateRangeButton:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",backgroundColor:"#f5f5f5",borderRadius:"8px",border:"1px solid #e0e0e0",cursor:"pointer",minWidth:"280px"},dateRangeIcon:{fontSize:"18px",color:"#666"},dateRangeText:{flex:1,color:"#333",fontSize:"14px"},dateRangeArrow:{fontSize:"20px",color:"#666"},dateRangePopover:{padding:0,minWidth:"700px",borderRadius:"8px",maxHeight:"90vh",overflow:"hidden"},dateRangeSidebar:{borderRight:"1px solid #e0e0e0",padding:"16px",overflowY:"auto",backgroundColor:"#fafafa",scrollbarWidth:"thin","&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{backgroundColor:"#c1c1c1",borderRadius:"3px","&:hover":{backgroundColor:"#a8a8a8"}}},dateRangeRadioLabel:{marginLeft:0,marginRight:0,'& .MuiFormControlLabel-label, & [class*="MuiFormControlLabel-label-"]':{fontSize:"14px",paddingLeft:"8px"}},dateRangeCalendarContainer:{flex:1,padding:"16px",paddingLeft:"24px",display:"flex",flexDirection:"column",backgroundColor:"#ffffff",alignItems:"flex-start",justifyContent:"flex-start","& .DateRangePicker":{width:"100%"},"& .DateRangePickerInput":{width:"100%",display:"flex",justifyContent:"flex-start",marginBottom:"8px"},"& .DateInput":{display:"none"},"& .DateRangePicker_picker":{left:"0 !important",top:"auto !important",position:"relative !important",marginTop:"8px"}},dateRangePickerWrapper:{width:"100%",maxWidth:"100%"},dateRangeSectionTitle:{fontWeight:"bold",marginBottom:"12px",fontSize:"14px",color:"#333"},dateRangeQuickSelectButton:{justifyContent:"flex-start",textTransform:"none",padding:"8px 12px",fontSize:"14px",color:"#333",minHeight:"36px","&:hover":{backgroundColor:"#f5f5f5"}},dateRangeCustomSection:{borderTop:"1px solid #e0e0e0",paddingTop:"16px",marginTop:"16px"},dateRangePickerContainer:{width:"100%",overflow:"visible"},metricCardContainer:{minWidth:"20%",padding:"8px"},metricCard:{backgroundColor:"#ffffff",borderRadius:"8px",padding:"16px",display:"flex",flexDirection:"column",border:"1px solid #E0E0E0",cursor:"pointer",transition:"all 0.2s ease","&:hover":{boxShadow:"0 2px 8px rgba(0,0,0,0.1)"}},metricCardHighlighted:{backgroundColor:"#ebf5f3"},metricCardLabel:{color:"#666",fontSize:"14px"},metricCardLabelHighlighted:{color:"#0A474C"},metricCardValue:{fontWeight:"bold",color:"#333",fontSize:"24px"},metricCardValueHighlighted:{color:"#0A474C"},metricCardInfoIcon:{fontSize:"16px",color:"#999"},metricCardInfoIconHighlighted:{color:"#0A474C"},performanceMetricRow:{marginBottom:"0.4em"},performanceMetricRowContainer:{display:"flex",justifyContent:"space-between"},performanceMetricLabel:{color:"#666"},performanceMetricValue:{fontWeight:"bold",color:"#333"},performanceBadge:{backgroundColor:"rgba(25, 118, 210, 0.08)",color:"#1976d2",fontWeight:"bold",borderRadius:"12px",padding:"4px 8px"},creativePerformanceSection:{padding:"0px 16px"},creativePerformanceTitle:{fontWeight:"bold",color:"#333",marginBottom:"16
1px",textTransform:"uppercase",fontSize:"14px",letterSpacing:"0.5px"},detailsSection:{padding:"16px"},detailsTitle:{fontWeight:"bold",color:"#333",marginBottom:"16px",textTransform:"uppercase",fontSize:"14px",letterSpacing:"0.5px"},adSummarySection:{backgroundColor:"#ffffff",borderRadius:"8px",padding:"16px 0px"},adSummaryTitle:{fontWeight:"bold",color:"#333",fontSize:"20px"},adTabs:{borderBottom:"1px solid #e0e0e0",'& .MuiTab-root, & [class*="MuiTab-root-"]':{textTransform:"none",fontWeight:500,fontSize:"14px",minWidth:"120px",color:"#666","&.Mui-selected":{color:"#0a474c",fontWeight:600}},'& .MuiTabs-indicator, & [class*="MuiTabs-indicator-"]':{backgroundColor:"#0a474c"}},statusToggleContainer:{display:"flex",alignItems:"center",gap:"12px",marginRight:"8px"},statusLabel:{color:"#6b6b6b",fontSize:"14px",fontWeight:400},statusPill:{padding:"4px 12px",borderRadius:"9999px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap"},statusSeparator:{width:"1px",height:"20px",backgroundColor:"#e0e0e0"},segmentedToggle:{display:"flex",borderRadius:"8px",backgroundColor:"#ffffff",border:"1px solid #e0e0e0",overflow:"hidden"},segmentButton:{padding:"6px 16px",backgroundColor:"transparent",fontSize:"14px",fontWeight:600,transition:"all 0.2s ease"},segmentButtonActive:{backgroundColor:"#0a474c",color:"#ffffff"},segmentButtonInactive:{backgroundColor:"#ffffff",color:"#0a474c"},adSummaryCustomizeButton:{textTransform:"none",borderColor:"#ddd",color:"#666","&:hover":{borderColor:"#0a474c",color:"#0a474c"}},customizePopoverContent:{padding:"16px",minWidth:"300px",maxWidth:"400px"},customizePopoverTitle:{fontWeight:"bold",color:"#333",fontSize:"16px",marginBottom:"16px"},customizeCheckboxList:{maxHeight:"300px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"8px","&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{background:"#ccc",borderRadius:"3px"},"&::-webkit-scrollbar-thumb:hover":{background:"#999"}},customizeActions:{borderTop:"1px solid #e0e0e0",paddingTop:"12px"},adSummaryMetricsGrid:{marginBottom:"24px"},performanceGraphSection:{marginTop:"24px"},performanceGraphTitle:{fontWeight:"bold",color:"#333",marginBottom:"16px",fontSize:"16px"},adPreviewContainer:{height:"100%"},adPreviewHeader:{padding:"16px",borderBottom:"1px solid lightgrey"},adPreviewTitle:{fontWeight:"bold"},adPreviewShareIcon:{width:"16px",cursor:"pointer"},adPreviewContent:{padding:"16px 0px",borderBottom:"1px solid lightgrey"},adPreviewInnerContent:{padding:"0px 16px"},adDetailsPanelContainer:{padding:"16px"},adDetailsPanelBorder:{border:"2px solid #E0E0E0",marginBottom:"16px"},tooltipIcon:{fontSize:"1.2em"},contentGrid:{display:"grid",gap:"16px"},actionsSearchField:{'& .MuiOutlinedInput-root, & [class*="MuiOutlinedInput-root-"]':{borderRadius:"8px"}},tableContainer:{overflowX:"auto",border:"1px solid #e0e0e0",borderRadius:"8px"},table:{width:"100%",borderCollapse:"collapse"},tableHeader:{backgroundColor:"#f5f5f5"},tableHeaderCell:{padding:"12px 16px",textAlign:"center",fontSize:14,fontWeight:600,borderBottom:"1px solid #e0e0e0"},tableHeaderCellRight:{textAlign:"center"},tableRow:{borderBottom:"1px solid rgba(0, 0, 0, 0.08)",transition:"background-color 0.2s ease",backgroundColor:"white"},tableRowHover:{backgroundColor:"#f5f5f5"},tableCell:{padding:"12px 16px",fontSize:14,color:"#333"},tableCellCenter:{textAlign:"center"},tableCellBold:{fontWeight:600}})))((0,r.withRouter)((e=>{let{classes:t,match:a,history:s,assistantDetails:l,adInsights:c}=e;const p=(0,i.useDispatch)(),u=(0,i.useSelector)(lm)||l,m=(0,i.useSelector)(dm)||c,g=(0,i.useSelector)((e=>e.ads?.updateAdStatus||{isLoading:!1,error:null})),b=(0,i.useSelector)(cm),{id:y,projectId:x}=a.params,f=u?.assistantId||x,A=im(y,f,_n.hr,s,p),{adData:I,adAccount:C,pageDetails:_,isLoading:S}=A,v=(()=>{const[e,t]=(0,n.useState)({open:!1,message:"",severity:"info"});return{snackbar:e,showSnackbar:(0,n.useCallback)((function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info";t({open:!0,message:"string"==typeof e||"number"==typeof e?e:e?.message||"Something went wrong",severity:a})}),[]),hideSnackbar:(0,n.useCallback)((()=>{t((e=>({...e,open:!1})))}),[])}})(),E=(()=>
1{const[e,t]=(0,n.useState)({export:!1,pauseWarning:!1,broadcast:!1});return{dialogs:e,openDialog:(0,n.useCallback)((e=>{t((t=>({...t,[e]:!0})))}),[]),closeDialog:(0,n.useCallback)((e=>{t((t=>({...t,[e]:!1})))}),[])}})(),[T,D]=(0,n.useState)((()=>({startDate:I?.adStartDate?ve()(I.adStartDate).startOf("day"):ve()().subtract(29,"days").startOf("day"),endDate:I?.adEndDate?ve()(I.adEndDate).endOf("day"):ve()().endOf("day")})));(0,n.useEffect)((()=>{if(I?.adStartDate&&I?.adEndDate){const e=ve()(I.adStartDate).startOf("day"),t=ve()(I.adEndDate).endOf("day");D((a=>{const n=a.startDate?.format("YYYY-MM-DD"),s=a.endDate?.format("YYYY-MM-DD"),o=e.format("YYYY-MM-DD"),i=t.format("YYYY-MM-DD");return n!==o||s!==i?{startDate:e,endDate:t}:a}))}}),[I?.adStartDate,I?.adEndDate]);const w=((e,t)=>{const[a,s]=(0,n.useState)(e),[o,i]=(0,n.useState)(t),[r,l]=(0,n.useState)(null);return(0,n.useEffect)((()=>{if(e){const t=ve().isMoment(e)?e:ve()(e);s((e=>{const a=e?.format("YYYY-MM-DD");return a!==t.format("YYYY-MM-DD")?t:e}))}}),[e]),(0,n.useEffect)((()=>{if(t){const e=ve().isMoment(t)?t:ve()(t);i((t=>{const a=t?.format("YYYY-MM-DD");return a!==e.format("YYYY-MM-DD")?e:t}))}}),[t]),{startDate:a,endDate:o,focusedInput:r,setDates:(0,n.useCallback)(((e,t)=>{e&&s(e),t&&i(t)}),[]),setFocus:(0,n.useCallback)((e=>{l(e)}),[])}})(T.startDate||ve()().subtract(29,"days").startOf("day"),T.endDate||ve()().endOf("day")),[N,j]=(0,n.useState)(""),[k,L]=(0,n.useState)("Impressions"),[R,P]=(0,n.useState)("All"),[M,U]=(0,n.useState)(null),F=im(y,f,_n.FZ,s,p),W="USD"===m?.insights?.currency?"$":"₹",z=om(I,0,W),G=(0,n.useMemo)((()=>({type:I?.metaVideoId?"VIDEO":"IMAGE",caption:I?.adDescription,url:I?.videoUrl||I?.imageUrl,thumbnail:I?.metaVideoId?I?.imageUrl:null,previewLink:I?.previewLink,pageDetails:_,headline:I?.headline,linkMetaData:{linkTitle:I?.linkTitle,linkDescription:I?.linkDescription,linkImage:I?.linkImage},cta:I?.ctaButton,selectedAdType:I?.adType,websiteUrl:I?.websiteUrl,adType:I?.adType})),[I,_]),{clicks:H,spend:V,adStopDate:Y,adStartDate:Z,adName:K,createdAt:J,costPerClick:q,engagementRateRanking:X,qualityRanking:Q}=I||{},ee=(e=>{const{isChildBMAd:t}=e||{};return!t||!(!e?.dailyBudget||isNaN(parseInt(e?.dailyBudget))||!parseInt(e?.dailyBudget))})(I),{accountId:te,accountName:ae}=C||{},ne=null!==M?M:I?.adStatus,se="ACTIVE"===ne&&!ea.$y.includes(I?.adEffectiveStatus);return(0,n.useEffect)((()=>{m?.error&&v.showSnackbar(m.error||"Failed to fetch ad insights","error")}),[m?.error,v.showSnackbar]),(0,n.useEffect)((()=>{b?.error&&v.showSnackbar(b.error||"Failed to sync ad","error")}),[b?.error,v.showSnackbar]),(0,h.jsx)(rm,{children:(0,h.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,h.jsxs)(o.Grid,{container:!0,justify:"flex-start",alignItems:"center",style:{padding:"8px 0px",flexShrink:0},className:`${t.pageTitleContainer} ${t.fullWidth} ginger-page-header`,children:[(0,h.jsx)(o.Grid,{item:!0,children:(0,h.jsx)(o.Box,{pl:{xs:2,md:2},children:(0,h.jsx)(o.IconButton,{component:r.Link,to:`${Xe(x)}`,name:"backButton",id:"backButton",children:(0,h.jsx)(d.ArrowBack,{})})})}),(0,h.jsx)(o.Grid,{item:!0,style:{maxWidth:"80%"},children:(0,h.jsx)(o.Typography,{variant:"h3",noWrap:!0,children:K||"AD"})}),(0,h.jsxs)(o.Grid,{item:!0,style:{flexGrow:1,textAlign:"right",paddingRight:12,display:"flex",justifyContent:"flex-end",alignItems:"center"},children:[(0,h.jsx)(o.Box,{mr:4,display:"flex",alignItems:"center",children:(0,h.jsx)(B,{name:"gingerLauncher"})}),Z&&I?.isChildBMAd&&(0,h.jsxs)("div",{style:{marginRight:"32px",display:"flex",alignItems:"center",gap:"10px"},children:[(0,h.jsx)(o.Typography,{variant:"h4",className:t.statusLabel,children:`Status: ${I?.pausedDueToInsufficientCredit?"INSUFFICIENT CREDIT":"ACTIVE"!==I?.adEffectiveStatus||"ACTIVE"!==I?.adStatus||Number(I?.impressions)>0?I?.adEffectiveStatus:"PREPARING"} | `}),(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[(0,h.jsx)("span",{style:{opacity:se?.25:1,fontFamily:"Roboto",fontWeight:500,fontSize:"16px",lineHeight:"24px"},children:"Paused"}),(0,h.jsx)(nm,{checked:se,disabled:g.isLoading,onChange:async()=>{const e=se?"PAUSED":"ACTIVE",t=ne;U(e);try{await p((0,_n.DA)(f,y,I?.adId,I?.adAccountId,e)),p((0,_n.yN)({adId:y,newStatus:e})),v.showSnackbar("Your Status Has Been Updated","success"),y&&f&&A.fetchAd(y)}catch(e){U(t);const a=e?.response?.data?.message||g.error||"Failed To Update Status";v.showSnackbar(a,"error");const{action:n,assistant:o}=e?.response?.data||{};if("reconnect"===n&&o){const{fbConnected:e,fbUserId:t,fbGrantedScopes:a,selectedMetaPageId:n,selectedMetaAdAccountId:i,freezedMetaAdAccountId:r,freezedMetaPageId:l}=o||{};(0,$.nt)({fbConnected:e,fbUserId:t,fbGrantedScopes:a,selectedMetaPageId:n,selectedMetaAdAccountId:i,freezedMetaAdAccountId:r,freezedMetaPageId:l}),setTimeout((()=>{s.replace(`${Xe(f)}`)}),1500)}}},color:"primary"}),(0,h.jsx)("span",{style:{opacity:se?1:.25,fontFamily:"Roboto",fontWeight:500,fontSize:"16px",lineHeight:"24px"},children:"Active"})]})]}),I.isChildBMAd&&(0,h.jsx)(o.Button,{size:"small",color:"primary",variant:"outlined",className:t.display_500,style:{marginLeft:"8px"},name:"editAd",id:"editAd",startIcon:(0,h.jsx)(d.EditOutlined,{}),onClick:()=>{s.push({pathname:`${Xe(x)}/edit/${y}`,state:{isLiveAD:!0}
1})},children:"Edit Ad"}),I.isChildBMAd&&(0,h.jsx)(o.Button,{size:"small",color:"primary",variant:"outlined",style:{marginLeft:"8px"},className:t.display_500,name:"duplicateAd",id:"duplicateAd",startIcon:(0,h.jsx)(Do,{style:{fill:"#0A474C",height:"18px"}}),onClick:()=>{s.push({pathname:`${Xe(x)}/duplicate/${y}`,state:{isLiveAD:!0}})},children:"Duplicate Ad"}),(0,h.jsx)(o.Button,{size:"small",variant:"contained",style:{marginLeft:"8px"},color:"primary",name:"syncAd",id:"syncAd",startIcon:(0,h.jsx)(d.Autorenew,{className:S?t.rotationIcon:""}),disabled:S,onClick:()=>{y&&f&&A.fetchAd(y)},children:"Sync Ad"})]})]}),I?.adIssues?.[0]?.error_message&&(0,h.jsx)(O.Alert,{severity:"error",style:{justifyContent:"center"},children:I.adIssues?.[0]?.error_message}),I?.adReviewFeedback&&(0,h.jsxs)(h.Fragment,{children:[I.adReviewFeedback.global&&Object.entries(I.adReviewFeedback.global).map(((e,t)=>{let[a,n]=e;return(0,h.jsxs)(O.Alert,{severity:"error",style:{justifyContent:"center",marginTop:t>0?"8px":"0"},children:[(0,h.jsx)(o.Typography,{variant:"body1",style:{fontWeight:"bold",marginBottom:"4px"},children:a}),(0,h.jsx)(o.Typography,{variant:"body2",children:n})]},`global-${t}`)})),I?.adReviewFeedback?.categories&&Object.entries(I?.adReviewFeedback?.categories).map(((e,t)=>{let[a,n]=e;return(0,h.jsxs)(O.Alert,{severity:"warning",style:{justifyContent:"center",marginTop:"8px"},children:[(0,h.jsx)(o.Typography,{variant:"body1",style:{fontWeight:"bold",marginBottom:"4px"},children:a}),(0,h.jsx)(o.Typography,{variant:"body2",children:"string"==typeof n?n:JSON.stringify(n)})]},`category-${t}`)}))]}),(0,h.jsxs)("div",{className:`${t.root} ginger-page-root`,style:{position:"relative"},children:[m?.isLoading&&(0,h.jsx)(o.Box,{className:t.overlay,children:(0,h.jsxs)(o.Box,{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},children:[(0,h.jsx)(o.CircularProgress,{size:48}),(0,h.jsx)(o.Typography,{variant:"h6",style:{color:"#666"},children:"Loading ad insights..."})]})}),(0,h.jsx)(o.Grid,{container:!0,justify:"center",style:{height:"100%"},children:(0,h.jsxs)(o.Grid,{item:!0,xs:12,container:!0,style:{height:"100%"},children:[(0,h.jsx)(bu,{adData:I,adInsights:m,assistantDetails:u,assistantId:f,mongoAdId:y,classes:t,metrics:z,clicks:H,spend:V,adCostPerClick:q,currencySymbol:W,highlight:k,setHighlight:L,interval:R,setInterval:P,insightsHook:F,summaryDateRange:w,adDates:T,setAdDates:D,selectedPlacement:N,AdSummarySection:Yu,ActionsBreakdown:Uu,BreakdownInsights:Mu}),(0,h.jsx)(am,{adInsights:m,classes:t,accountName:ae,accountId:te,adData:I,isDailyBudgetAd:ee,currencySymbol:W,createdAt:J,adStartDate:Z,adStopDate:Y,isLoading:S,previewPayload:G,assistantId:f,qualityRanking:Q,engagementRateRanking:X,fetchAdInsights:e=>p((0,_n.FZ)(f,y,e)),selectedPlacement:N,setSelectedPlacement:j})]})})]}),(0,h.jsx)(o.Snackbar,{open:v.snackbar.open,anchorOrigin:{vertical:"top",horizontal:"center"},autoHideDuration:6e3,onClose:v.hideSnackbar,children:(0,h.jsx)(O.Alert,{onClose:v.hideSnackbar,severity:v.snackbar.severity,children:v.snackbar.message})}),(0,h.jsxs)(o.Dialog,{open:E.dialogs.export,onClose:()=>E.closeDialog("export"),maxWidth:"sm",fullWidth:!0,children:[(0,h.jsx)(o.DialogTitle,{children:"Export Audience"}),(0,h.jsx)(o.DialogContent,{children:(0,h.jsx)(o.Typography,{variant:"body1",children:"Are you sure you want to export the selected audience?"})}),(0,h.jsxs)(o.DialogActions,{children:[(0,h.jsx)(o.Button,{onClick:()=>E.closeDialog("export"),children:"Cancel"}),(0,h.jsx)(o.Button,{onClick:()=>{E.closeDialog("export")},color:"primary",variant:"contained",children:"Export"})]})]})]})})})));function um(e){let{classes:t,dialogStep:a,creatingPixel:n,createdPixel:s,createPixelLoading:i,pixelName:r,pixelDescription:l,pixelNameError:c,onClose:p,onSubmit:u,onPixelNameChange:m,onPixelDescriptionChange:g,onCopyCode:b}=e;if("create"===a)return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.DialogTitle,{className:t.dialogTitle,children:[(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",gap:5,children:(0,h.jsx)(o.Typography,{variant:"h5",className:t.dialogTitleText,color:"textPrimary",children:"Create Event"})}),(0,h.jsx)(o.IconButton,{onClick:p,className:t.closeButton,size:"small",children:(0,h.jsx)(d.Close,{})})]}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",className:t.dialogSubtitle,children:"Set up a new Meta Event to track conversions and optimize your ad performance"})]}),(0,h.jsx)(o.DialogContent,{className:t.dialogContent,children:(0,h.jsxs)(o.Box,{className:t.contentCard,children:[(0,h.jsxs)(o.Box,{mb:2,children:[(0,h.jsx)(o.Typography,{variant:"body2",className:t.inputLabel,children:"Event Name"}
1),(0,h.jsx)(o.Paper,{className:t.inputCard,elevation:0,children:(0,h.jsx)(o.TextField,{variant:"outlined",fullWidth:!0,placeholder:"Enter event name",value:r,onChange:m,error:!!c,helperText:c,classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding},endAdornment:(0,h.jsx)(o.InputAdornment,{position:"end",children:(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",className:t.charCount,children:`${(r||"").length}/100`})})},FormHelperTextProps:{className:t.helperText}})})]}),(0,h.jsxs)(o.Box,{mb:2,children:[(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",gap:1,style:{marginBottom:"8px"},children:(0,h.jsx)(o.Typography,{variant:"body2",className:t.inputLabel,children:"Description"})}),(0,h.jsx)(o.Paper,{className:t.inputCard,elevation:0,children:(0,h.jsxs)(o.Box,{position:"relative",children:[(0,h.jsx)(o.TextField,{variant:"outlined",fullWidth:!0,multiline:!0,rows:4,placeholder:"Describe this event for future reference",value:l,onChange:g,classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}}}),(0,h.jsx)(o.Box,{position:"absolute",bottom:"12px",right:"14px",style:{pointerEvents:"none"},children:(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",className:t.charCount,children:`${(l||"").length}/1024`})})]})})]})]})}),(0,h.jsxs)(o.DialogActions,{className:t.dialogActions,children:[(0,h.jsx)(o.Button,{onClick:p,variant:"outlined",className:t.cancelButton,children:"Cancel"}),(0,h.jsx)(o.Button,{onClick:u,variant:"contained",color:"primary",disabled:!r||""===r.trim()||!!c||n,startIcon:n||i?(0,h.jsx)(o.CircularProgress,{size:16,color:"inherit"}):null,children:n||i?"Creating...":"Create Event"})]})]});if("code"===a){const e=s?.code||"";return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.DialogTitle,{className:t.dialogTitle,children:[(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",gap:5,children:(0,h.jsx)(o.Typography,{variant:"h5",className:t.dialogTitleText,color:"textPrimary",children:"Event Created Successfully!"})}),(0,h.jsx)(o.IconButton,{onClick:p,className:t.closeButton,size:"small",children:(0,h.jsx)(d.Close,{})})]}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",className:t.dialogSubtitle,children:"Copy and install the event code on your website to start tracking events"})]}),(0,h.jsx)(o.DialogContent,{className:t.dialogContent,children:(0,h.jsx)(o.Box,{className:t.contentCard,children:(0,h.jsxs)(o.Box,{mb:2,children:[(0,h.jsx)(o.Typography,{variant:"body2",className:t.inputLabel,style:{marginBottom:"12px"},children:"Install Event Code"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:"16px",fontSize:"0.875rem"},children:"Copy the code below and paste it into the <head> section of your website."}),(0,h.jsxs)(o.Paper,{className:t.codeContainer,elevation:0,style:{backgroundColor:"#F5F5F5",padding:"16px",borderRadius:"8px",position:"relative"},children:[(0,h.jsx)("pre",{style:{margin:0,fontSize:"12px",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-all",color:"#333",maxHeight:"300px",overflow:"auto"},children:e}),(0,h.jsx)(o.IconButton,{onClick:b,size:"small",style:{position:"absolute",top:"8px",right:"8px",backgroundColor:"white"},children:(0,h.jsx)(Do,{style:{width:"18px",height:"18px",fill:"#0a474c"}})})]})]})})}),(0,h.jsx)(o.DialogActions,{className:t.dialogActions,children:(0,h.jsx)(o.Button,{onClick:p,variant:"outlined",className:t.nextButton,children:"Close"})})]})}return null}function mm(e){let{classes:t,theme:a,assistantDetails:n,pixelsLoading:s,searchQuery:i,allDatasets:r,loading:l,isLoadingMore:c,selectedEventId:p,hasMore:u,isSyncingPixels:m,sidebarScrollRef:g,fetchDatasets:b,handleCreatePixel:y,handleSearchChange:x,handleSidebarScroll:f,selectEvent:A,syncPixels:I,setState:C}=e;const _=Boolean(n?.fbConnected&&n?.selectedMetaPageId&&n?.selectedMetaAdAccountId),S={Active:"#28C152","Pending Review":"#8859E7",Inactive:"#FF8400",Error:"#F25D55"};return(0,h.jsxs)(o.Box,{className:t.eventsSidebar,children:[(0,h.jsxs)(o.Box,{className:t.
1sidebarHeader,children:[(0,h.jsx)(o.Typography,{variant:"h6",className:t.sidebarTitle,children:"Events"}),(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",gap:.5,children:[(0,h.jsx)(o.Tooltip,{title:"Sync Pixels from Meta",children:(0,h.jsx)(o.IconButton,{size:"small",onClick:I,disabled:!_||m,className:t.syncPixelsButton,children:(0,h.jsx)(d.Autorenew,{className:m?t.rotationIcon:""})})}),(0,h.jsx)(o.Tooltip,{title:"Create Event",children:(0,h.jsx)(o.IconButton,{size:"small",onClick:y,disabled:!_,className:t.addButton,children:(0,h.jsx)(d.Add,{})})})]})]}),(0,h.jsx)(o.Box,{className:t.sidebarSearch,children:(0,h.jsx)(o.TextField,{placeholder:"Search by event name",color:"primary",className:t.textFieldRoot,value:i,onChange:x,variant:"outlined",size:"small",style:{backgroundColor:"#e6e6e6"},disabled:!_,InputProps:{startAdornment:(0,h.jsx)(o.InputAdornment,{position:"start",children:(0,h.jsx)(d.Search,{})}),endAdornment:i?(0,h.jsx)(o.InputAdornment,{position:"end",children:(0,h.jsx)(o.IconButton,{style:{padding:"4px",marginRight:"-4px"},color:"primary",size:"small",onClick:()=>{C({searchQuery:""},(()=>b(!0)))},children:(0,h.jsx)(d.Close,{style:{fontSize:18}})})}):""}})}),(0,h.jsx)(o.Box,{className:t.sidebarList,onScroll:f,ref:g,children:(l||s)&&0===r.length?(0,h.jsx)(o.Box,{display:"flex",justifyContent:"center",alignItems:"center",p:4,children:(0,h.jsx)(o.CircularProgress,{})}):0===r.length?(0,h.jsxs)(o.Box,{p:3,textAlign:"center",children:[(0,h.jsx)("img",{src:tt,alt:"No events",style:{width:"120px",marginBottom:"16px"}}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginBottom:"16px"},children:i?"No events found":"No events yet"}),!i&&(0,h.jsx)(o.Button,{variant:"contained",color:"primary",size:"small",startIcon:(0,h.jsx)(d.AddOutlined,{}),onClick:y,disabled:!_,style:{marginTop:"8px"},children:"Create Event"})]}):(0,h.jsxs)(h.Fragment,{children:[r.map((e=>(0,h.jsxs)(o.ListItem,{button:!0,selected:p===e.pixelId||p===e._id,onClick:()=>A(e),className:t.eventListItem,disabled:!_,children:[(0,h.jsx)(o.ListItemIcon,{children:(0,h.jsx)(o.Box,{style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:S[e.status]||"#ccc",boxShadow:`0 0 0 2px ${S[e.status]||"#ccc"}20`}})}),(0,h.jsx)(o.ListItemText,{primary:(0,h.jsx)(o.Typography,{variant:"body2",className:t.eventName,children:e.name}),secondary:(0,h.jsxs)(o.Typography,{variant:"caption",color:"textSecondary",className:t.eventId,children:["ID ",e.pixelId]})})]},e.pixelId))),c&&(0,h.jsx)(o.Box,{display:"flex",justifyContent:"center",p:2,children:(0,h.jsx)(o.CircularProgress,{size:24})})]})})]})}function hm(e){let{classes:t,theme:a,selectedEvent:n,expandedAccordionIndex:s,onCopyPixelCode:i}=e;const r=!!n?.code,l=[{title:"Copy the Event Script",icon:(0,h.jsx)(d.Code,{style:{fontSize:"20px",color:"#6E6E6E"}}),completed:r,stepNumber:1,content:(0,h.jsxs)(o.Box,{className:t.setupStepContent,children:[(0,h.jsx)(o.Typography,{variant:"body1",className:t.setupStepDescription,children:"Copy the event code below to install it on your website. Click the copy button to copy the complete script to your clipboard."}),n?.code?(0,h.jsx)(o.Box,{className:t.setupCodeWrapper,children:(0,h.jsxs)(o.Box,{className:t.setupCodeContainer,children:[(0,h.jsxs)(o.Box,{className:t.setupCodeHeader,children:[(0,h.jsx)(o.Typography,{variant:"caption",className:t.codeLabel,children:"Event Code"}),(0,h.jsx)(o.IconButton,{onClick:()=>i(n.pixelId),size:"small",className:t.setupCopyButton,title:"Copy code",children:(0,h.jsx)(Do,{style:{width:"18px",height:"18px",fill:"#0a474c"}})})]}),(0,h.jsx)("pre",{className:t.setupCodeDisplay,children:n.code})]})}):(0,h.jsx)(o.Box,{className:t.noCodeMessage,children:(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",children:"No event code available. Please create a event first."})})]})},{title:"Install on Your Website",icon:(0,h.jsx)(d.Info,{style:{fontSize:"20px",color:"#6E6E6E"}}),completed:!1,stepNumber:2,content:(0,h.jsxs)(o.Box,{className:t.setupStepContent,children:[(0,h.jsx)(o.Typography,{variant:"body1",className:t.setupStepDescription,children:"Install the below event code on your website:"}),(0,h.jsx)(o.Box,{className:t.installationOptions,children:(0,h.jsxs)(o.Box,{children:[(0,h.jsxs)(o.Typography,{variant:"body2",className:t.optionText,children:["Paste the copied event code just before the closing"," ",(0,h.jsx)("code",{className:t.inlineCode,children:"</head>"})," tag on ",(0,h.jsx)("strong",{children:"every page"})," of your website."]}),(0,h.jsxs)(o.Box,{className:t.codeExample,children:[(0,h.jsx)(o.Typography,{variant:"caption",className:t.exampleLabel,children:"Example:"}),(0,h.jsx)("pre",{className:t.exampleCode,children:"<head>\n\x3c!-- Your existing head content --\x3e\n\x3c!-- Paste your event code here --\x3e\n</head>"})]})]})})]})},{title:"Verify the Installation",icon:(0,h.jsx)(d.CheckCircleOutline,{style:{fontSize:"20px",color:"#6E6E6E"}}),completed:!1,stepNumber:3,content:(0,h.jsxs)(o.Box,{className:t.
1setupStepContent,children:[(0,h.jsx)(o.Typography,{variant:"body1",className:t.setupStepDescription,children:"After installing the code, verify that your event is working correctly:"}),(0,h.jsxs)(o.Box,{className:t.verificationSteps,children:[(0,h.jsx)(o.Box,{className:t.verificationStep,children:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"body2",className:t.verificationStepTitle,children:"Visit your website"}),(0,h.jsxs)(o.Typography,{variant:"body2",color:"textSecondary",className:t.verificationStepText,children:["Navigate to any page to trigger the initial"," ",(0,h.jsx)("strong",{children:"PageView"})," event"]})]})}),(0,h.jsx)(o.Box,{className:t.verificationStep,children:(0,h.jsxs)(o.Box,{children:[(0,h.jsx)(o.Typography,{variant:"body2",className:t.verificationStepTitle,children:"Test the event"}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",className:t.verificationStepText,children:"Use the Test Events tool to confirm the event is active and receiving data"})]})})]})]})}];if(!1===s||null==s)return l.map((e=>({...e,completed:!0})));const c=s;return l.map(((e,t)=>{const a=c>=t;return{...e,completed:e.completed||a}}))}function gm(e){let{classes:t,theme:a,assistantDetails:n,history:s,match:i,selectedEvent:r,activeTab:l,startDate:c,endDate:p,focusedInput:u,isSyncingEvents:m,expandedAccordionIndex:g,allDatasets:b,loading:y,pixelStatsLoading:x,getEventIcon:f,getEventIconColor:A,getEventTableData:I,getStatusColor:C,handleAccordionChange:_,handleContinueSetup:S,handleCopyPixelCode:v,handleCreatePixel:E,handleDateChange:T,handleFocusChange:D,handleTabChange:w,syncEvents:N,setState:j}=e;const{projectId:k}=i.params,L=Boolean(n?.fbConnected&&n?.selectedMetaPageId&&n?.selectedMetaAdAccountId),R=L?"":"Complete your Ads setup (connect Facebook, select a Page and Ad Account) to create an Ad",O=0===b.length&&!y;if(!r||O){const e=window.innerWidth<768;return(0,h.jsxs)(o.Box,{className:t.detailsPanel,children:[(0,h.jsxs)(o.Box,{className:t.detailsHeader,children:[(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",gap:1,flex:1,minWidth:0,children:(0,h.jsx)(o.Typography,{variant:"h5",className:t.detailsTitle,noWrap:!0,children:O?"No Events":"Select an Event"})}),(0,h.jsx)(o.Box,{mr:3,display:"flex",alignItems:"center",children:(0,h.jsx)(B,{name:"gingerLauncher"})}),(0,h.jsx)(o.Tooltip,{title:R,children:(0,h.jsx)("span",{children:(0,h.jsx)(o.Button,{variant:"contained",color:"primary",size:e?"small":"medium",startIcon:(0,h.jsx)(d.AddOutlined,{}),className:t.createAdButton,disabled:!L,onClick:()=>{r?.pixelId?s.push(`${Xe(k)}/create?pixelId=${r.pixelId}&selectedAdType=website_traffic`):s.push(`${Xe(k)}/create?selectedAdType=website_traffic`)},children:e?"Create":"Create Ad"})})})]}),(0,h.jsxs)(o.Box,{className:t.detailsContent,children:[(0,h.jsx)(o.Box,{className:t.tabsRow,children:(0,h.jsxs)(o.Tabs,{value:l,onChange:w,indicatorColor:"primary",textColor:"primary",className:t.tabs,children:[(0,h.jsx)(o.Tab,{label:"Overview"}),(0,h.jsx)(o.Tab,{label:"Setup"})]})}),(0,h.jsx)(o.Box,{className:t.tabContent,children:(0,h.jsx)(o.Box,{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",minHeight:"calc(100vh - 300px)",p:4,children:(0,h.jsxs)(o.Box,{textAlign:"center",className:t.emptyStateContainer,children:[(0,h.jsx)("img",{src:tt,alt:O?"No events":"No event selected",className:t.emptyStateImage}),(0,h.jsx)(o.Typography,{variant:"h6",color:"textSecondary",className:t.emptyStateText,children:O?"No events yet":"Select an event to view details"}),O&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginTop:"8px",marginBottom:"16px"},children:"Create your first event to start tracking events and conversions."}),(0,h.jsx)(o.Button,{variant:"contained",color:"primary",startIcon:(0,h.jsx)(d.AddOutlined,{}),onClick:E,disabled:!L,children:"Create Event"})]})]})})})]})]})}const P=window.innerWidth<768;return(0,h.jsxs)(o.Box,{className:t.detailsPanel,children:[(0,h.jsxs)(o.Box,{className:t.detailsHeader,children:[(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",gap:1,flex:1,minWidth:0,children:(0,h.jsx)(o.Typography,{variant:"h5",className:t.detailsTitle,noWrap:!0,children:r.name})}),(0,h.jsx)(o.Box,{mr:3,display:"flex",alignItems:"center",children:(0,h.jsx)(B,{name:"gingerLauncher"})}),(0,h.jsx)(o.Tooltip,{title:R,children:(0,h.jsx)("span",{children:(0,h.jsx)(o.Button,{variant:"contained",color:"primary",size:P?"small":"medium",startIcon:(0,h.jsx)(d.AddOutlined,{}),className:t.createAdButton,disabled:!L,onClick:()=>{s.push(`${Xe(k)}/create?pixelId=${r.pixelId}&selectedAdType=website_traffic`)},children:P?"Create":"Create Ad"})})})]}),(0,h.jsxs)(o.Box,{className:t.detailsContent,children:[(0,h.jsxs)(o.Box,{className:t.tabsRow,children:[(0,h.jsxs)(o.Tabs,{value:l,onCh
1ange:w,indicatorColor:"primary",textColor:"primary",className:t.tabs,children:[(0,h.jsx)(o.Tab,{label:"Overview"}),(0,h.jsx)(o.Tab,{label:"Setup"})]}),0===l&&(0,h.jsxs)(o.Box,{className:t.tabsRowControls,children:[(0,h.jsx)(o.Box,{className:t.datePickerContainer,children:(0,h.jsx)(Fa.DateRangePicker,{startDatePlaceholderText:"From",endDatePlaceholderText:"To",startDateId:"overviewStartDate",endDateId:"overviewEndDate",startDate:c,endDate:p,onDatesChange:T,focusedInput:u,onFocusChange:D,navPosition:"navPositionTop",numberOfMonths:1,navPrev:(0,h.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:(0,h.jsx)(o.IconButton,{size:"small",children:(0,h.jsx)(d.NavigateBefore,{})})}),navNext:(0,h.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:(0,h.jsx)(o.IconButton,{size:"small",children:(0,h.jsx)(d.NavigateNext,{})})}),hideKeyboardShortcutsPanel:!0,customArrowIcon:null,screenReaderInputMessage:" ",small:!0,readOnly:!0,displayFormat:"DD MMM YYYY",isOutsideRange:e=>e.isAfter(ve()(),"day"),minimumNights:0})}),(0,h.jsx)(o.Tooltip,{title:"Sync Events",children:(0,h.jsx)(o.Button,{variant:"outlined",size:"small",className:t.syncButton,startIcon:(0,h.jsx)(d.Autorenew,{className:m?t.rotationIcon:""}),onClick:N,disabled:m||x,children:m||x?"Syncing...":"Sync"})})]})]}),0===l&&(0,h.jsx)(o.Box,{className:t.tabContent,children:(0,h.jsx)(o.TableContainer,{component:o.Paper,className:t.tableContainer,children:(0,h.jsxs)(o.Table,{children:[(0,h.jsx)(o.TableHead,{style:{borderBottom:"none"},children:(0,h.jsxs)(o.TableRow,{style:{borderBottom:"none"},children:[(0,h.jsx)(o.TableCell,{style:{border:"none"},children:"Events"}),(0,h.jsx)(o.TableCell,{style:{border:"none"},children:"Connection Method"}),(0,h.jsx)(o.TableCell,{style:{border:"none"},children:"Status"}),(0,h.jsx)(o.TableCell,{align:"right",style:{border:"none"},children:"Total Events"})]})}),(0,h.jsx)(o.TableBody,{children:x||x?(0,h.jsx)(o.TableRow,{children:(0,h.jsx)(o.TableCell,{colSpan:4,align:"center",className:t.tableLoadingCell,children:(0,h.jsx)(o.Box,{className:t.tableLoadingBox,children:(0,h.jsx)(o.CircularProgress,{size:24})})})}):I().length>0?I().map(((e,t)=>{const a=f(e.eventName),n=A(e.eventName),s=C(e.status);return(0,h.jsxs)(o.TableRow,{children:[(0,h.jsx)(o.TableCell,{style:{borderBottom:"none"},children:(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",gap:1,children:[(0,h.jsx)(a,{style:{fontSize:"18px",color:n,marginRight:"8px"}}),(0,h.jsx)(o.Typography,{children:e.eventName})]})}),(0,h.jsx)(o.TableCell,{style:{borderBottom:"none"},children:(0,h.jsx)(o.Chip,{label:"Browser",size:"small",style:{backgroundColor:"#f5f5f5",border:"none"}})}),(0,h.jsx)(o.TableCell,{style:{borderBottom:"none"},children:(0,h.jsx)(o.Chip,{label:e.status?.toUpperCase()||"SUCCESS",size:"small",style:{backgroundColor:s,color:"white",fontWeight:500}})}),(0,h.jsx)(o.TableCell,{align:"right",style:{borderBottom:"none"},children:e.totalEvents})]},t)})):(0,h.jsx)(o.TableRow,{children:(0,h.jsx)(o.TableCell,{colSpan:4,style:{padding:0},children:(0,h.jsx)(o.Box,{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",py:6,className:t.emptyStateBox,children:(0,h.jsxs)(o.Box,{textAlign:"center",maxWidth:"500px",width:"100%",children:[(0,h.jsx)("img",{src:tt,alt:"No activity",style:{width:"200px",marginBottom:"16px",display:"block",marginLeft:"auto",marginRight:"auto"}}),(0,h.jsx)(o.Typography,{variant:"h6",children:"Your event hasn't received any activity."}),(0,h.jsx)(o.Typography,{variant:"body2",color:"textSecondary",style:{marginTop:"8px",marginBottom:"16px"},children:"Finish the event setup on your website to start seeing activity."}),(0,h.jsx)(o.Button,{variant:"contained",color:"primary",onClick:S,children:"Continue Event Setup"})]})})})})})]})})}),1===l&&(0,h.jsx)(o.Box,{className:t.tabContent,children:hm({classes:t,theme:a,selectedEvent:r,expandedAccordionIndex:g,onCopyPixelCode:v}).map(((e,a)=>(0,h.jsxs)(o.Accordion,{elevation:0,className:(0,gn.A)(t.accordian,{[t.accordianCompeted]:e.completed}),style:e.completed?{borderColor:"#28c153",borderBottom:"4px solid #28c153"}:{},expanded:g===a,onChange:_(a),children:[(0,h.jsx)(o.AccordionSummary,{className:t.accordianSummary,children:(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",children:[(0,h.jsxs)(o.Box,{display:"flex",alignItems:"center",gap:1,children:[(0,h.jsx)(o.Box,{className:t.
1stepNumberBadge,children:(0,h.jsx)(o.Typography,{variant:"body2",className:t.stepNumberText,children:e.icon})}),(0,h.jsx)(o.Typography,{variant:"body1",className:t.pixelStepTitle,children:e.title})]}),(0,h.jsx)(d.ExpandMore,{className:(0,gn.A)(t.accordionArrow,{[t.accordionArrowExpanded]:g===a})})]})}),(0,h.jsx)(o.AccordionDetails,{className:t.accordianDetail,children:e.content})]},a)))})]})]})}var bm=a(90935);class ym extends n.Component{constructor(e){super(e),this.state={searchQuery:"",templatedialogOpen:!1,createPixelDialogOpen:!1,pixelName:"",pixelDescription:"",pixelNameError:"",creatingPixel:!1,dialogStep:"create",createdPixel:null,allDatasets:[],loading:!1,isLoadingMore:!1,hasMore:!0,currentPage:1,rowsPerPage:20,selectedEventId:null,selectedEvent:null,activeTab:0,eventLog:[],eventTypeFilter:"all",startDate:ve()().subtract(7,"days"),endDate:ve()(),focusedInput:null,isSyncingEvents:!1,isSyncingPixels:!1,expandedAccordionIndex:0,pagination:{currentPage:1,totalPages:1,totalItems:0,itemsPerPage:20,hasNextPage:!1,hasPreviousPage:!1},snackbar:{open:!1,message:"",severity:"success"},drawerOpen:!1,pixelStats:[],pixelStatsLoading:!1,pixelStatsSummary:null}}sidebarScrollRef=(()=>s().createRef())();componentDidMount(){const{assistantDetails:e,match:t}=this.props,a=Boolean(e?.fbConnected&&e?.selectedMetaPageId&&e?.selectedMetaAdAccountId),n=t?.params?.eventId;a&&(this.fetchDatasets(!0),n&&setTimeout((()=>{this.selectEventById(n)}),1e3)),this.handleResize=()=>{window.innerWidth>=768&&this.state.drawerOpen&&this.setState({drawerOpen:!1})},window.addEventListener("resize",this.handleResize)}componentWillUnmount(){this.searchTimeout&&clearTimeout(this.searchTimeout),this.handleResize&&window.removeEventListener("resize",this.handleResize)}componentDidUpdate(e){const{assistantDetails:t,match:a}=this.props,n=e.assistantDetails?.assistantId,s=t?.assistantId,o=Boolean(t?.fbConnected&&t?.selectedMetaPageId&&t?.selectedMetaAdAccountId),i=e.match?.params?.eventId,r=a?.params?.eventId;s&&s!==n&&o&&this.setState({allDatasets:[],currentPage:1,hasMore:!0},(()=>{this.fetchDatasets(!0)})),r&&r!==i&&this.selectEventById(r)}fetchDatasets=(()=>{var e=this;return async function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{assistantDetails:a,fetchPixels:n}=e.props,s=a?.assistantId,o=Boolean(a?.fbConnected&&a?.selectedMetaPageId&&a?.selectedMetaAdAccountId);if(s&&o){t?e.setState({loading:!0,allDatasets:[],currentPage:1,hasMore:!0,isLoadingMore:!1}):e.setState({isLoadingMore:!0});try{const{currentPage:a,rowsPerPage:o,searchQuery:i}=e.state,r=t?1:a,l=o,d=await n({assistantId:s,page:r,limit:l,search:i?.trim()||""}),{data:c,pagination:p}=d||{},u=(c||[]).map((e=>({_id:e._id,name:e.name||e.description||`Pixel ${e.pixelId}`,pixelId:e.pixelId,status:"ACTIVE"===e.status?"Active":e.status||"Inactive",dateCreated:e.createdAt?new Date(e.createdAt).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"",description:e.description||"",code:e.code||""}))),m=t?u:[...e.state.allDatasets,...u],h=p?.hasNextPage||!1;e.setState({allDatasets:m,currentPage:r+1,hasMore:h,pagination:p||e.state.pagination,loading:!1,isLoadingMore:!1},(()=>{t&&m.length>0&&!e.state.selectedEventId&&!e.props.match?.params?.eventId&&setTimeout((()=>{e.selectEvent(m[0])}),100)}))}catch(t){console.error("Error fetching datasets:",t),e.setState({loading:!1,isLoadingMore:!1,snackbar:{open:!0,message:e.props.pixelsError||t?.response?.data?.message||"Failed to fetch pixels. Please try again.",severity:"error"}})}}}})();loadNextBatch=()=>{!this.state.hasMore||this.state.isLoadingMore||this.state.loading||this.fetchDatasets(!1)};handleSidebarScroll=e=>{const{scrollTop:t,scrollHeight:a,clientHeight:n}=e.target;(t+n)/a>.8&&this.state.hasMore&&!this.state.isLoadingMore&&this.loadNextBatch()};toggleTemplateCreditDialog=()=>{this.setState({templatedialogOpen:!this.state.templatedialogOpen})};handleSearchChange=e=>{const t=e.target.value;this.setState({searchQuery:t},(()=>{this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((()=>{this.fetchDatasets(!0)}),500)}))};handleDrawerOpen=()=>{this.setState({drawerOpen:!0})};handleDrawerClose=()=>{this.setState({drawerOpen:!1})};selectEvent=e=>{const{projectId:t}=this.props.match.params,a=window.innerWidth<768;this.setState({selectedEventId:e._id,selectedEvent:e},(()=>{this.props.history.replace(`${Xe(t)}/events/${e._id}`),this.fetchEventDetails(e.pixelId),this.setState({activeTab:0}),(e.pixelId||e._id)&&this.fetchPixelStats(),a&&this.handleDrawerOpen()}))};selectEventById=e=>{const t=this.state.allDatasets.find((t=>t._id===e));t?this.selectEvent(t):this.fetchEventDetails(e)};fetchEventDetails=async e=>{const{assistantDetails:t}=this.props,a=t?.assistantId;if(a&&e)try{const t=await this.props.fetchPixelDetailsThunk(e,a),n={_id:t._id,name:t.name||this.state.selectedEvent?.name||t.description||`Event ${t.pixelId}`,pixelId:t.pixelId,status:this.mapStatusToDisplay(t.status),dateCreated:ve()(t.createdAt).format("DD MMM YYYY"),description:t.description||"",creator:t.creator||"N/A",owner:t.owner||"N/A",code:t.code||""};this.setState({selectedEvent:n,selectedEventId:e},(()=>{n.pixelId&&this.fetchPixelStats()}))}catch(e){console.error("Error fetching event details:",e),this.setState({snackbar:{open:!0,message:e?.response?.data?.message||"Failed to fetch event details. Please try again.",severity:"error"}})}};mapStatusToDisplay=e=>{if(!e)return"Inactive";return{ACTIVE:"Active",INACTIVE:"Inactive",PENDING:"Pending Review"}[e.toUpperCase()]||e};initializePixel=()=>{var e,t,a,n,s,o;window.fbq||(e=window,t=document,a="script",e.fbq||(n=e.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)},e._fbq||(e._fbq=n),n.push=n,n.loaded=!0,n.version="2.0",n.queue=[],(s=t.createElement(a)).async=!0,s.src="https://connect.facebook.net/en_US/fbevents.js",(o=t.getElementsByTagName(a)[0]).parentNode.insertBefore(s,o)))};initializePixelWithId=e=>{if(window.fbq||this.initializePixel(),window.fbq&&e)try{window.fbq("init",e)}catch(e){console.log("Pixel initialization:",e)}};handleCreatePixel=()=>{this.setState({createPixelDialogOpen:!0,dialogStep:"create",createdPixel:null})};handleOpenSetupDialog=e=>{const t=e.code||"";this.setState({createPixelDialogOpen:!0,dialogStep:"code",createdPixel:{_id:e._id,id:e._id,pixelId:e.pixelId,code:t,name:e.name}})};handleCloseCreatePixelDialog=()=>{this.setState({createPixelDialogOpen:!1,pixelName:"",pixelDescription:"",pixelNameError:"",dialogStep:"create",createdPixel:null})};handlePixelNameChange=e=>{const t=e.target.value;t.length<=100&&this.setState({pixelName:t,pixelNameError:""===t.trim()?"Pixel name is required":""})};handlePixelDescriptionChange=e=>{const t=e.target.value;t.length<=1024&&this.setState({pixelDescription:t})};handleCreatePixelSubmit=async()=>{const{pixelName:e,pixelDescription:t}=this.state,{assistantDetails:a}=this.props,n=a?.assistantId;if(e&&""!==e.trim())if(n){this.setState({creatingPixel:!0});try{const a=await this.props.createPixelThunk({assistantId:n,pixelName:e.trim(),pixelDescription:t.trim()||""}),s=a?.data,o=s?.code||"";if(!s)throw new Error("Failed to create event. No data received.");this.setState({creatingPixel:!1,dialogStep:"code",createdPixel:{...s,code:o}},(()=>{this.fetchDatasets(!0),s?._id&&setTimeout((()=>{this.selectEventById(s._id)}),1e3)})),a?.success&&this.setState({snackbar:{open:!0,message:a?.message||"Pixel created successfully",severity:"success"}})}catch(e){const t=e?.response?.data?.message||e?.message||"Failed to create event. Please try again.";this.setState({creatingPixel:!1,snackbar:{open:!0,message:t,severity:"error"}})}}else this.setState({snackbar:{open:!0,message:"Assistant ID is missing. Please try again.",severity:"error"}});else this.setState({pixelNameError:"Pixel name is required"})};syncPixels=async()=>{const{assistantDetails:e,syncPixels:t}=this.props,a=e?.assistantId;if(a){this.setState({isSyncingPixels:!0});try{const e=await t({assistantId:a});if(!1===e?.success)return void this.setState({isSyncingPixels:!1,snackbar:{open:!0,message:e?.message||"Failed to sync events",severity:"error"}});this.fetchDatasets(!0),this.setState({isSyncingPixels:!1,snackbar:{open:!0,message:e?.message||"Events synced successfully",severity:"success"}})}catch(e){console.error("Error syncing events:",e),this.setState({isSyncingPixels:!1,snackbar:{open:!0,message:this.props.syncPixelsError||e?.response?.data?.message||e?.message||"Failed to sync events. Please try again.",severity:"error"}})}}else this.setState({snackbar:{open:!0,message:"Unable to sync events. Assistant ID is missing.",severity:"error"}})};handleTabChange=(e,t)=>
1{this.setState({activeTab:t})};handleDateChange=e=>{let{startDate:t,endDate:a}=e;this.setState({startDate:t,endDate:a},(()=>{this.state.selectedEvent?.pixelId&&this.fetchPixelStats()}))};handleFocusChange=e=>{this.setState({focusedInput:e})};fetchPixelStats=async()=>{const{selectedEvent:e,startDate:t,endDate:a}=this.state,{assistantDetails:n,fetchPixelStats:s}=this.props,o=n?.assistantId;if(o&&e?.pixelId){this.setState({pixelStatsLoading:!0});try{const n=t?t.unix():"",i=a?a.unix():"",r=await s({assistantId:o,pixelId:e.pixelId,start_time:n||void 0,end_time:i||void 0}),{data:l,summary:d}=r||{};this.setState({pixelStats:l||[],pixelStatsSummary:d||null,pixelStatsLoading:!1},(()=>{const e=this.getEventTableData();(0===e.length||e.every((e=>0===(e.totalEvents||0))))&&0===this.state.activeTab&&this.setState({activeTab:1})}))}catch(e){console.error("Error fetching event stats:",e),this.setState({pixelStats:[],pixelStatsSummary:null,pixelStatsLoading:!1,snackbar:{open:!0,message:this.props.pixelStatsError||e?.response?.data?.message||"Failed to fetch event stats. Please try again.",severity:"error"}},(()=>{const e=this.getEventTableData();(0===e.length||e.every((e=>0===(e.totalEvents||0))))&&0===this.state.activeTab&&this.setState({activeTab:0})}))}}};syncEvents=async()=>{const{selectedEvent:e}=this.state,{assistantDetails:t}=this.props,a=t?.assistantId;if(a&&e?._id){this.setState({isSyncingEvents:!0});try{await this.fetchEventDetails(e.pixelId),await this.fetchPixelStats(),this.setState({eventLog:[]}),this.setState({isSyncingEvents:!1,snackbar:{open:!0,message:"Events synced successfully",severity:"success"}})}catch(e){console.error("Error syncing events:",e),this.setState({isSyncingEvents:!1,snackbar:{open:!0,message:"Failed to sync events. Please try again.",severity:"error"}})}}else this.setState({snackbar:{open:!0,message:"Unable to sync events. Please try again.",severity:"error"}})};getEventIcon=e=>({Purchase:d.PaymentOutlined,AddToCart:d.ShoppingCartOutlined,PageView:d.VisibilityOutlined,ViewContent:d.VisibilityOutlined,Lead:d.PersonAddOutlined,CompleteRegistration:d.HowToRegOutlined,Search:d.Search,ViewCategory:d.CategoryOutlined,AddToWishlist:d.FavoriteBorder,FindLocation:d.LocationOnOutlined,Schedule:d.EventOutlined,Contact:d.ContactMailOutlined,Subscribe:d.SubscriptionsOutlined,StartTrial:d.PlayArrowOutlined,AddPaymentInfo:d.CreditCardOutlined,InitiateCheckout:d.ShoppingCartOutlined}[e]||d.CloudUpload);getEventIconColor=e=>{const{theme:t}=this.props;return t.palette.primary.main};getStatusColor=e=>({success:"#28C152",warning:"#FF8400",error:"#F25D55"}[e?.toLowerCase()]||"#28C152");getEventTableData=()=>{const{eventLog:e,eventTypeFilter:t}=this.state,{pixelStats:a}=this.props,n=a&&a.length>0?a:this.state.pixelStats;if(n&&n.length>0)return n.map((e=>({eventName:e.event_name||e.eventName,connectionMethod:e.connection_method||e.connectionMethod||"event",totalEvents:e.total_count||e.totalEvents||0,status:"success"})));const s=["Purchase","AddToCart","ViewContent","InitiateCheckout","Lead","CompleteRegistration","Search","ViewCategory","AddToWishlist","FindLocation","Schedule","Contact","Subscribe","StartTrial","AddPaymentInfo","Subscribe"];let o=e;"standard"===t&&(o=e.filter((e=>s.includes(e.eventName))));const i={};o.forEach((e=>{const t=`${e.eventName}_${e.source}`;i[t]||(i[t]={eventName:e.eventName,connectionMethod:e.source,totalEvents:0,statusCounts:{success:0,warning:0,error:0}}),i[t].totalEvents+=1,e.status&&void 0!==i[t].statusCounts[e.status]&&(i[t].statusCounts[e.status]+=1)}));return Object.values(i).map((e=>{const{statusCounts:t}=e;let a="success";return t.error>0?a="error":t.warning>0&&(a="warning"),{...e,status:a}})).sort(((e,t)=>t.totalEvents-e.totalEvents))};handleAccordionChange=e=>(t,a)=>{this.setState({expandedAccordionIndex:!!a&&e})};handleContinueSetup=()=>{this.setState({activeTab:1})};handleCopyCode=()=>{const{createdPixel:e}=this.state,t=e?.code||"";navigator.clipboard.writeText(t).then((()=>{this.setState({snackbar:{open:!0,message:"Event code copied to clipboard!",severity:"success"}})})).catch((()=>{const e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e),this.setState({snackbar:{open:!0,message:"Event code copied to clipboard!",severity:"success"}})}))};handleCopyPixelCode=e=>{const{selectedEvent:t}=this.state,a=t?.code||"";navigator.clipboard.writeText(a).then((()=>{this.setState({snackbar:{open:!0,message:"Event code copied to clipboard!",severity:"success"}})})).catch((()=>{const e=document.createElement("textarea");e.value=a,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e),this.setState({snackbar:{open:!0,message:"Event code copied to clipboard!",severity:"success"}})}))};handleSnackbarClose=(e,t)=>{"clickaway"!==t&&this.setState({snackbar:{open:!1,message:"",severity:"success"}})};render(){var e=this;const{classes:t,assistantDetails:a,theme:n}=this.props,s=Boolean(a?.fbConnected&&a?.selectedMetaPageId&&a?.selectedMetaAdAccountId),{projectId:i}=this.props.match.params,r=window.innerWidth<768;return(0,h.jsxs)("div",{className:`${t.root} ginger-page-root`,children:[!s&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("div",{className:t.overlay}),(0,h.jsx)(o.Box,{className:t.overlayMessageContainer,children:(0,h.jsx)("div",{onClick:()=>this.props.history.push(`${Xe(i)}/setup`),style:{cursor:"pointer"},children:(0,h.jsxs)(o.Typography,{variant:"h4",color:"primary",align:"center",className:t.message,children:["Complete Meta Ad Account Setup to continue!",(0,h.jsx)(o.IconButton,{children:(0,h.jsx)(d.ArrowForward,{})})]})})})]}),(0,h.jsxs)(o.Grid,{container:!0,className:t.threePanelLayout,children:[(0,h.jsx)(o.Grid,{item:!0,className:t.eventsSidebarContainer,children:(0,h.jsx)(mm,{classes:this.props.classes,theme:this.props.theme,assistantDetails:this.props.assistantDetails,pixelsLoading:this.props.pixelsLoading,searchQuery:this.state.searchQuery,allDatasets:this.state.allDatasets,loading:this.state.loading,isLoadingMore:this.state.isLoadingMore,selectedEventId:this.state.selectedEventId,hasMore:this.state.hasMore,isSyncingPixels:this.state.isSyncingPixels,sidebarScrollRef:this.sidebarScrollRef,fetchDatasets:this.fetchDatasets,handleCreatePixel:this.handleCreatePixel,handleSearchChange:this.handleSearchChange,handleSidebarScroll:this.handleSidebarScroll,selectEvent:this.selectEvent,syncPixels:this.syncPixels,setState:function(){return e.setState(...arguments)}})}),!r&&(0,h.jsx)(o.Grid,{item:!0,xs:!0,className:t.detailsPanelContainer,children:(0,h.jsx)(gm,{classes:this.props.classes,theme:this.props.theme,assistantDetails:this.props.assistantDetails,history:this.props.history,match:this.props.match,selectedEvent:this.state.selectedEvent,activeTab:this.state.activeTab,startDate:this.state.startDate,endD
1ate:this.state.endDate,focusedInput:this.state.focusedInput,isSyncingEvents:this.state.isSyncingEvents,expandedAccordionIndex:this.state.expandedAccordionIndex,allDatasets:this.state.allDatasets,loading:this.state.loading,pixelStatsLoading:this.state.pixelStatsLoading,getEventIcon:this.getEventIcon,getEventIconColor:this.getEventIconColor,getEventTableData:this.getEventTableData,getStatusColor:this.getStatusColor,handleAccordionChange:this.handleAccordionChange,handleContinueSetup:this.handleContinueSetup,handleCopyPixelCode:this.handleCopyPixelCode,handleCreatePixel:this.handleCreatePixel,handleDateChange:this.handleDateChange,handleFocusChange:this.handleFocusChange,handleTabChange:this.handleTabChange,syncEvents:this.syncEvents,setState:function(){return e.setState(...arguments)}})})]}),r&&this.state.selectedEvent&&(0,h.jsxs)(o.Drawer,{anchor:"bottom",open:this.state.drawerOpen,onClose:this.handleDrawerClose,className:t.mobileDrawer,PaperProps:{className:t.drawerPaper},children:[(0,h.jsxs)(o.Box,{className:t.drawerHeader,children:[(0,h.jsx)(o.Typography,{variant:"h6",className:t.drawerTitle,children:this.state.selectedEvent?.name||"Event Details"}),(0,h.jsx)(o.IconButton,{onClick:this.handleDrawerClose,className:t.drawerCloseButton,size:"small",children:(0,h.jsx)(d.Close,{})})]}),(0,h.jsx)(o.Box,{className:t.drawerContent,children:(0,h.jsx)(gm,{classes:this.props.classes,theme:this.props.theme,assistantDetails:this.props.assistantDetails,history:this.props.history,match:this.props.match,selectedEvent:this.state.selectedEvent,activeTab:this.state.activeTab,startDate:this.state.startDate,endDate:this.state.endDate,focusedInput:this.state.focusedInput,isSyncingEvents:this.state.isSyncingEvents,expandedAccordionIndex:this.state.expandedAccordionIndex,allDatasets:this.state.allDatasets,loading:this.state.loading,pixelStatsLoading:this.state.pixelStatsLoading,getEventIcon:this.getEventIcon,getEventIconColor:this.getEventIconColor,getEventTableData:this.getEventTableData,getStatusColor:this.getStatusColor,handleAccordionChange:this.handleAccordionChange,handleContinueSetup:this.handleContinueSetup,handleCopyPixelCode:this.handleCopyPixelCode,handleCreatePixel:this.handleCreatePixel,handleDateChange:this.handleDateChange,handleFocusChange:this.handleFocusChange,handleTabChange:this.handleTabChange,syncEvents:this.syncEvents,setState:function(){return e.setState(...arguments)}})})]}),(0,h.jsx)(B,{name:"metaAdsCreditDialog",dialogOpen:this.state.templatedialogOpen,toggleTemplateCreditDialog:this.toggleTemplateCreditDialog,assistantDetails:this.props.assistantDetails}),(0,h.jsx)(o.Dialog,{open:this.state.createPixelDialogOpen,onClose:(e,t)=>{"backdropClick"!==t&&this.handleCloseCreatePixelDialog()},maxWidth:"sm",fullWidth:!0,className:t.createPixelDialog,children:(0,h.jsx)(um,{classes:t,dialogStep:this.state.dialogStep,creatingPixel:this.state.creatingPixel,createdPixel:this.state.createdPixel,createPixelLoading:this.props.createPixelLoading,pixelName:this.state.pixelName,pixelDescription:this.state.pixelDescription,pixelNameError:this.state.pixelNameError,onClose:this.handleCloseCreatePixelDialog,onSubmit:this.handleCreatePixelSubmit,onPixelNameChange:this.handlePixelNameChange,onPixelDescriptionChange:this.handlePixelDescriptionChange,onCopyCode:this.handleCopyCode})}),(0,h.jsx)(o.Snackbar,{open:this.state.snackbar.open,autoHideDuration:3e3,onClose:this.handleSnackbarClose,anchorOrigin:{vertical:"top",horizontal:"center"},children:(0,h.jsx)(O.Alert,{onClose:this.handleSnackbarClose,severity:this.state.snackbar.severity,children:this.state.snackbar.message})})]})}}const xm=(0,i.connect)((e=>({assistantDetails:e.assistantDetails.data,agent:e.login.user,pixels:e.audience.pixels,pixelsLoading:e.audience.pixelsLoading,pixelsError:e.audience.pixelsError,pixelsPagination:e.audience.pixelsPagination,pixelDetails:e.audience.pixelDetails,pixelDetailsLoading:e.audience.pixelDetailsLoading,pixelDetailsError:e.audience.pixelDetailsError,pixelStats:e.audience.pixelStats,pixelStatsSummary:e.audience.pixelStatsSummary,pixelStatsLoading:e.audience.pixelStatsLoading,pixelStatsError:e.audience.pixelStatsError,syncPixelsLoading:e.audience.syncPixelsLoading,syncPixelsError:e.audience.syncPixelsError,createPixelLoading:e.audience.createPixelLoading,createPixelError:e.audience.createPixelError})),{fetchPixels:z.aR,fetchPixelDetails:z.X3,fetchPixelStats:z.cT,syncPixels:z.rg,createPixel:z.Vn,clearError:z.ET,fetchPixelDetailsThunk:bm.X3,createPixelThunk:bm.Vn})(ym),fm=(0,o.withTheme)((0,o.withStyles)((e=>({root:{width:"100%",height:"100vh",background:"rgb(247, 247, 247)",overflow:"hidden",position:"relative",display:"flex",flexDirection:"column",[e.breakpoints.down("sm")]:{height:"auto",minHeight:"100vh",overflow:"visible"}},threePanelLayout:{height:"100%",overflow:"hidden",[e.breakpoints.down("sm")]:{flexDirection:"column"}},eventsSidebarContainer:{width:"280px",minWidth:"280px",height:"100%",borderRight:`1px solid ${e.palette.grey[200]}`,backgroundColor:"white",display:"flex",flexDirection:"column",[e.breakpoints.down("md")]:{width:"280px",minWidth:"280px"},[e.breakpoints.down("sm")]:{width:"100%",minWidth:"100%",height:"100vh",maxHeight:"none",borderRight:"none",borderBottom:`1px solid ${e.palette.grey[200]}`}},detailsPanelContainer:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column",[e.breakpoints.down("sm")]:{height:"auto",minHeight:"60vh"}},eventsSidebar:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",backgroundColor:"rgb(247, 247, 247)"},sidebarHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:e.spacing(1.5),[e.breakpoints.down("xs")]:{padding:e.spacing(1,1.5)}},sidebarTitle:{fontWeight:500,fontSize:"1rem",[e.breakpoints.down("xs")]:{fontSize:"0.875rem"}},addButton:{padding:e.spacing(.5),[e.breakpoints.down("xs")]:{padding:e.spacing(.75),minWidth:"44px",minHeight:"44px"}},syncPixelsButton:{padding:e.spacing(.5),[e.breakpoints.down("xs")]:{padding:e.spacing(.75),minWidth:"44px",minHeight:"44px"}},sidebarSearch:{padding:e.spacing(.5,.5),[e.breakpoints.down("xs")]:{padding:e.spacing(.5,1)}},textFieldRoot:{height:"42px",padding:"0px",width:"100%",backgroundColor:e.palette.grey[100],[e.breakpoints.down("xs")]:{height:"38px"}},sidebarList:{flex:1,overflowY:"auto",overflowX:"hidden",marginTop:e.spacing(1),padding:e.spacing(1,.5),maxHeight:"calc(100vh - 200px)",[e.breakpoints.down("sm")]:{maxHeight:"calc(100vh - 180px)"},[e.breakpoints.down("xs")]:{maxHeight:"calc(100vh - 160px)",padding:e.spacing(.75,.5),marginTop:e.spacing(.75)},"&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:e.palette.grey[100],borderRadius:"3px"},"&::-webkit-scrollbar-thumb":{background:e.palette.grey[400],borderRadius:"3px","&:hover":{background:e.palette.grey[500]}}},eventListItem:{height:"auto",borderRadius:"8px",cursor:"pointer",marginLeft:"auto",marginRight:"auto",transition:"all 0.2s ease","&:hover":{backgroundColor:e.palette.grey[50]},"&.Mui-selected":{backgroundColor:e.palette.primary.light,"&:hover":{backgroundColor:e.palette.primary.light}},"&.Mui-disabled":{opacity:.6},"& [class*=MuiListItemIcon-root]":{minWidth:"40px",marginRight:e.spacing(1.5)},"& [class*=MuiListItemText-root]":{margin:0},"& [class*=MuiListItemText-primary]":{marginBottom:e.spacing(.5)},[e.breakpoints.down("xs")]:{minHeight:"56px",padding:e.spacing(1,1.25),width:"98%",marginBottom:e.spacing(.75),"& [class*=MuiListItemIcon-root]":{minWidth:"36px",marginRight:e.spacing(1.25)}}},eventName:{fontWeight:500,fontSize:"14px",lineHeight:1.5,color:e.palette.text.primary,letterSpacing:"0.01em",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",[e.breakpoints.down("xs")]:{fontSize:"13px",lineHeight:1.4}},eventId:{fontSize:"12px",lineHeight:1.4,color:e.palette.text.secondary,fontWeight:400,letterSpacing:"0.01em",[e.breakpoints.down("xs")]:{fontSize:"11px",lineHeight:1.3}},detailsPanel:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",backgroundColor:"white"},detailsHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",position:"sticky",zIndex:100,top:0,height:57,boxSizing:"border-box",padding:e.spacing(2,3),gap:e.spacing(1),[e.breakpoints.down("sm")]:{padding:e.spacing(1.5,2),height:52},[e.breakpoints.down("xs")]:{padding:e.spacing(1,1.5),height:48}},detailsTitle:{overflow:"hidden",textOverflow:"ellipsis",[e.breakpoints.down("xs")]:{fontSize:"1rem"}},createAdButton:{flexShrink:0,[e.breakpoints.down("xs")]:{minWidth:"auto",padding:e.spacing(.5,1),fontSize:"0.8125rem"}},detailsContent:{flex:1,overflow:"auto",padding:"24px 25px",[e.breakpoints.down("sm")]:{padding:e.spacing(1,1)},[e.breakpoints.down("xs")]:{padding:e.spacing(.75,1)}},tabsRow:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid rgb(240,240,240)",marginBottom:e.spacing(2),gap:e.spacing(2),[e.breakpoints.down("sm")]:{flexDirection:"column",alignItems:"stretch",gap:e.spacing(1.5),marginBottom:e.spacing(1.5)},[e.breakpoints.down("xs")]:{gap:e.spacing(1),marginBottom:e.spacing(1),padding:e.spacing(0,.5)}},tabsRowControls:{display:"flex",alignItems:"center",gap:e.spacing(2),flexShrink:0,[e.breakpoints.down("sm")]:{width:"100%",justifyContent:"flex-end",paddingRight:e.spacing(2),gap:e.spacing(1.5)},[e.breakpoints.down("xs")]:{flexDirection:"column",alignItems:"stretch",width:"100%",gap:e.spacing(1),paddingRight:0,"& > *":{width:"100%"}}},tabs:{flex:1,borderBottom:"none","& [class*=MuiTab-root]":{textTransform:"none",minWidth:"auto"},[e.breakpoints.down("sm")]:{width:"100%","& [class*=MuiTab-root]":{flex:1}},[e.breakpoints.down("xs")]:{"& [class*=MuiTab-root]":{fontSize:"0.8125rem",padding:e.spacing(1,1),minHeight:"44px",flex:1}}},tabContent:{marginTop:e.spacing(3),[e.breakpoints.down("xs")]:{marginTop:e.spacing(1.5)}},syncButton:{flexShrink:0,backgroundColor:"white",color:e.palette.text.primary,border:"none",textTransform:"none",boxShadow:"none","&:hover":{backgroundColor:e.palette.grey[50],boxSh
1adow:"none"},"&:disabled":{backgroundColor:"white",border:"none"},[e.breakpoints.down("sm")]:{minHeight:"40px"},[e.breakpoints.down("xs")]:{minHeight:"44px",width:"100%"}},datePickerContainer:{display:"flex",alignItems:"center",position:"relative",[e.breakpoints.down("sm")]:{flex:1,"& .DateRangePicker":{width:"100%"},"& .DateRangePickerInput":{width:"100%"}},[e.breakpoints.down("xs")]:{width:"100%","& .DateRangePicker":{width:"100%"},"& .DateRangePickerInput":{width:"100%"},"& .DateInput":{flex:1,minWidth:"0","& .DateInput_input":{fontSize:"0.8125rem",padding:"8px 6px",paddingLeft:"28px",width:"100%"}}},"& .DateRangePicker":{display:"flex"},"& .DateRangePickerInput":{borderRadius:"4px",border:"none"},"& .DateInput":{borderRadius:"4px",backgroundColor:"white",border:"none","&:hover":{border:"none"},"&:focus":{border:"none",outline:"none"},"&.DateInput__focused":{outline:"none",boxShadow:`0 0 0 2px ${e.palette.primary.main}20`}},"& .DateInput_input":{borderRadius:"8px","&:focus":{outline:"none"}},"& .DateRangePicker_picker":{zIndex:1300,position:"absolute",left:0,top:"100%",marginTop:"8px",[e.breakpoints.down("md")]:{left:0,right:"auto",transform:"none"}},"& .DateRangePicker_picker__directionLeft":{left:0,right:"auto !important"},"& .DateRangePicker_picker__directionRight":{left:0,right:"auto !important"}},rotationIcon:{animation:"adsSpinnerRotation 2s infinite linear",display:"inline-block"},"@keyframes rotation":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}},accordianCompeted:{borderBottom:"4px solid #27c152"},accordian:{borderRadius:8,border:"none",marginBottom:e.spacing(2),"&:before":{display:"none"},"&.Mui-expanded":{minHeight:"48px",marginTop:"0px"},[e.breakpoints.up("sm")]:{padding:"8px 0 8px 16px"},[e.breakpoints.down("sm")]:{padding:"6px 0 6px 12px"}},nextStepAccordion:{background:e.palette.primary.light,border:"none","& [class*=MuiAccordionSummary-content] svg":{padding:6,borderRadius:"50%",background:"#FFCC1D",color:e.palette.primary.main}},noBorder:{border:"1px solid transparent",transition:"all 0.4s"},accordianSummary:{paddingLeft:"0px","&.Mui-expanded":{minHeight:"48px"},"& [class*=MuiAccordionSummary-content].Mui-expanded":{margin:"0px"},"& [class*=MuiAccordionSummary-content]":{margin:"0px",overflow:"hidden",whiteSpace:"nowrap"}},accordianDetail:{padding:"20px 8px 8px 8px",display:"block"},stepNumberBadge:{width:"20px",height:"20px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"6px",[e.breakpoints.down("xs")]:{width:"18px",height:"18px",marginRight:"4px"}},stepNumberText:{color:"white",fontWeight:400,fontSize:"0.6rem",paddingTop:"4px",[e.breakpoints.down("xs")]:{fontSize:"0.5rem"}},stepIconContainer:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},accordionArrow:{transition:"transform 0.2s ease, color 0.2s ease",transform:"rotate(0deg)",color:e.palette.text.secondary},accordionArrowExpanded:{transform:"rotate(180deg)",color:e.palette.primary.main},pixelStepTitle:{fontWeight:600,fontSize:"0.9375rem",color:e.palette.primary.main,flex:1,[e.breakpoints.down("xs")]:{fontSize:"0.8125rem"}},pixelChecked:{position:"absolute",top:"-4px",right:"-4px",fontSize:"16px",color:"#0a474c",backgroundColor:"white",borderRadius:"50%"},setupStepContent:{width:"100%"},setupStepDescription:{marginBottom:e.spacing(1.5),color:e.palette.text.secondary,lineHeight:1.5,fontSize:"0.875rem",[e.breakpoints.down("xs")]:{marginBottom:e.spacing(1),fontSize:"0.8125rem",lineHeight:1.4}},setupCodeWrapper:{marginTop:e.spacing(1.5),[e.breakpoints.down("xs")]:{marginTop:e.spacing(1)}},setupCodeContainer:{position:"relative",backgroundColor:e.palette.grey[50],borderRadius:"6px",overflow:"hidden",[e.breakpoints.down("xs")]:{borderRadius:"4px"}},setupCodeHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:e.spacing(.75,1.8),backgroundColor:e.palette.grey[300],[e.breakpoints.down("xs")]:{padding:e.spacing(.5,.75)}},codeLabel:{color:e.palette.text.primary,fontWeight:500,fontSize:"0.75rem",[e.breakpoints.down("xs")]:{fontSize:"0.6875rem"}},setupCodeDisplay:{margin:0,fontSize:"12px",fontFamily:"'Fira Code', 'Consolas', 'Monaco', monospace",whiteSpace:"pre-wrap",wordBreak:"break-all",backgroundColor:e.palette.grey[200],padding:e.spacing(2.3),maxHeight:"300px",overflow:"auto",lineHeight:1.5,[e.breakpoints.down("xs")]:{fontSize:"11px",padding:e.spacing(1),maxHeight:"250px",lineHeight:1.4}},setupCopyButton:{backgroundColor:"transparent",color:e.palette.text.secondary,padding:e.spacing(.5),"&:hover":{backgroundColor:e.palette.grey[300]},[e.breakpoints.down("xs")]:{padding:e.spacing(.75),minWidth:"44px",minHeight:"44px"}},noCodeMessage:{padding:e.spacing(2),textAlign:"center",backgroundColor:e.palette.grey[50],borderRadius:"6px",[e.breakpoints.down("xs")]:{padding:e.spacing(1.5),borderRadius:"4px"}},installationOptions:{marginTop:e.spacing(1.5),[e.breakpoints.down("xs")]:{marginTop:e.spacing(1)}},installationOption:{marginBottom:e.spacing(2),[e.breakpoints.down("xs")]:{marginBottom:e.spacing(1.5)}},optionHeader:{display:"flex",alignItems:"center",gap:e.spacing(1),marginBottom:e.spacing(1),[e.breakpoints.down("xs")]:{gap:e.spacing(.75),marginBottom:e.spacing(.75)}},optionNumber:{width:"20px",height:"20px",borderRadius:"50%",backgroundColor:e.palette.grey[400],color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:500,fontSize:"0.75rem",flexShrink:0,[e.breakpoints.down("xs")]:{width:"18px",height:"18px",fontSize:"0.6875rem"}},optionTitle:{fontSize:"0.9375rem",fontWeight:500,color:e.palette.text.primary,margin:0,[e.breakpoints.down("xs")]:{fontSize:"0.8125rem"}},optionContent:{marginLeft:e.spacing(3.5),[e.breakpoints.down("xs")]:{marginLeft:e.spacing(2.5)}},optionText:{color:e.palette.text.secondary,lineHeight:1.5,marginBottom:e.spacing(1),fontSize:"0.875rem",[e.breakpoints.down("xs")]:{fontSize:"0.8125rem",lineHeight:1.4,marginBottom:e.spacing(.75)}},codeExample:{marginTop:e.spacing(1),backgroundColor:e.palette.grey[200],borderRadius:"4px",padding:e.spacing(2),[e.breakpoints.down("xs")]:{padding:e.spacing(.75),borderRadius:"3px"}},exampleLabel:{color:e.palette.text.secondary,fontWeight:500,fontSize:"0.75rem",marginBottom:e.spacing(.5),display:"block",[e.breakpoints.down("xs")]:{fontSize:"0.6875rem",marginBottom:e.spacing(.25)}},exampleCode:{margin:0,fontSize:"11px",fontFamily:"'Fira Code', 'Consolas', 'Monaco', monospace",color:e.palette.text.primary,whiteSpace:"pre-wrap",lineHeight:1.5,[e.breakpoints.down("xs")]:{fontSize:"10px",lineHeight:1.4}},stepsList:{margin:e.spacing(.5,0),paddingLeft:e.spacing(2.5),"& li":{marginBottom:e.spacing(.75),"&:last-child":{marginBottom:0}},[e.breakpoints.down("xs")]:{paddingLeft:e.spacing(2),margin:e.spacing(.25,0),"& li":{marginBottom:e.spacing(.5)}}},stepText:{color:e.palette.text.secondary,lineHeight:1.5,fontSize:"0.875rem",[e.breakpoints.down("xs")]:{fontSize:"0.8125rem",lineHeight:1.4}},verificationSteps:{marginTop:e.spacing(1.5),marginBottom:e.spacing(2),[e.breakpoints.down("xs")]:{marginTop:e.spacing(1),marginBottom:e.spacing(1.5)}},verificationStep:{display:"flex",alignItems:"flex-start",marginBottom:e.spacing(1.5),padding:e.spacing(2),backgroundColor:e.palette.grey[200],borderRadius:"6px","&:last-child":{marginBottom:0},[e.breakpoints.down("xs")]:{padding:e.spacing(.75),marginBottom:e.spacing(1),borderRadius:"4px"}},verificationStepTitle:{fontWeight:500,color:e.palette.text.primary,marginBottom:e.spacing(.25),fontSize:"0.875rem",[e.breakpoints.down("xs")]:{fontSize:"0.8125rem",marginBottom:e.spacing(.125)}},verificationStepText:{lineHeight:1.5,fontSize:"0.8125rem",[e.breakpoints.down("xs")]:{fontSize:"0.75rem",lineHeight:1.4}},inlineCode:{fontSize:"0.8125rem",backgroundColor:e.palette.grey[300],color:e.palette.text.primary,padding:"2px 6px",borderRadius:"4px",fontFamily:"'Fira Code', 'Consolas', 'Monaco', monospace",fontWeight:500,[e.breakpoints.down("xs")]:{fontSize:"0.75rem",padding:"2px 4px"}},testEventButton:{textTransform:"none",borderRadius:"6px",marginTop:e.spacing(1.5),padding:e.spacing(.75,2),fontWeight:500,fontSize:"0.875rem",[e.breakpoints.down("xs")]:{marginTop:e.spacing(1),padding:e.spacing(.75,1.5),fontSize:"0.8125rem",minHeight:"44px",width:"100%"}},pageTitleContainer:{position:"sticky",zIndex:100,top:0,height:60,[e.breakpoints.down("sm")]:{height:"auto",minHeight:60,padding:e.spacing(1.5,0)},[e.breakpoints.down("xs")]:{height:"auto",minHeight:"auto",padding:e.spacing(1,0)}},titleGridItem:{display:"flex",alignItems:"center",[e.breakpoints.down("xs")]:{justifyContent:"center"}},titleBox:{[e.breakpoints.down("xs")]:{paddingLeft:e.spacing(2),paddingRight:e.spacing(2),width:"100%",textAlign:"center"}},fullWidth:{width:"100%",background:"white"},pageTitle:{[e.breakpoints.down("sm")]:{fontSize:"1.5rem"},[e.breakpoints.down("xs")]:{fontSize:"1.25rem",textAlign:"center",width:"100%"}},buttonContainer:{display:"flex",justifyContent:"flex-end",gap:"1em",alignItems:"center",paddingRight:e.spacing(3),[e.breakpoints.down("md")]:{paddingRight:e.spacing(2)},[e.breakpoints.down("sm")]:{paddingRight:e.spacing(2),paddingLeft:e.spacing(2),justifyContent:"flex-end"},[e.breakpoints.down("xs")]:{marginTop:e.spacing(1),marginBottom:0,width:"100%",justifyContent:"stretch",paddingRight:e.spacing(2),paddingLeft:e.spacing(2)}}
1,buttonTextDesktop:{[e.breakpoints.down("xs")]:{display:"none"}},buttonTextMobile:{display:"none",[e.breakpoints.down("xs")]:{display:"inline"}},content:{flex:1,padding:0,overflowY:"auto",marginTop:e.spacing(3),[e.breakpoints.down("sm")]:{marginTop:e.spacing(2),padding:e.spacing(0,2)},[e.breakpoints.down("xs")]:{marginTop:e.spacing(1.5),padding:e.spacing(0,1)}},controlsContainer:{display:"flex",flexDirection:"row",alignItems:"center",gap:e.spacing(2),marginBottom:e.spacing(3),[e.breakpoints.down("md")]:{flexDirection:"column",alignItems:"stretch"}},searchInput:{flex:1,backgroundColor:"white",borderRadius:"8px","& [class*=MuiOutlinedInput-root]":{borderRadius:"8px","& fieldset":{borderColor:e.palette.divider},"&:hover fieldset":{borderColor:e.palette.text.secondary},"&.Mui-focused fieldset":{borderColor:e.palette.primary.main}},[e.breakpoints.down("md")]:{width:"100%"}},searchIcon:{color:e.palette.text.secondary},tablePagination:{"& [class*=MuiTablePagination-toolbar]":{paddingLeft:e.spacing(2),paddingRight:e.spacing(2),[e.breakpoints.down("sm")]:{paddingLeft:e.spacing(1),paddingRight:e.spacing(1)},[e.breakpoints.down("xs")]:{paddingLeft:e.spacing(.5),paddingRight:e.spacing(.5),flexWrap:"wrap"}},"& [class*=MuiTablePagination-selectLabel]":{marginBottom:0,[e.breakpoints.down("xs")]:{fontSize:"0.75rem"}},"& [class*=MuiTablePagination-displayedRows]":{marginBottom:0,[e.breakpoints.down("xs")]:{fontSize:"0.75rem"}},"& [class*=MuiTablePagination-selectRoot]":{[e.breakpoints.down("xs")]:{marginRight:e.spacing(.5),marginLeft:e.spacing(.5)}},"& [class*=MuiTablePagination-actions]":{[e.breakpoints.down("xs")]:{marginLeft:e.spacing(.5)}}},tableContainer:{backgroundColor:"white",boxShadow:"none",overflow:"visible",minHeight:"calc(100vh - 200px)",display:"flex",flexDirection:"column",[e.breakpoints.down("sm")]:{borderRadius:"8px",overflowX:"auto",overflowY:"visible",minHeight:"calc(100vh - 180px)","& [class*=MuiTable-root]":{minWidth:"600px"}},[e.breakpoints.down("xs")]:{borderRadius:"8px",overflowX:"auto",overflowY:"visible",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",minHeight:"calc(100vh - 160px)","& [class*=MuiTable-root]":{minWidth:"500px"},"& [class*=MuiTableCell-root]":{padding:e.spacing(.75,.75),fontSize:"0.75rem"},"& [class*=MuiTableCell-head]":{fontSize:"0.6875rem",fontWeight:600,padding:e.spacing(.75,.75),whiteSpace:"nowrap"}}},tableContainerWithData:{maxHeight:"calc(100vh - 280px)",overflowY:"auto",overflowX:"hidden","&::-webkit-scrollbar":{width:"8px"},"&::-webkit-scrollbar-track":{background:"#f1f1f1",borderRadius:"4px"},"&::-webkit-scrollbar-thumb":{background:"#888",borderRadius:"4px"},"&::-webkit-scrollbar-thumb:hover":{background:"#555"},[e.breakpoints.down("md")]:{maxHeight:"calc(100vh - 260px)"},[e.breakpoints.down("sm")]:{maxHeight:"calc(100vh - 240px)"},[e.breakpoints.down("xs")]:{maxHeight:"calc(100vh - 300px)"}},tableLoadingCell:{borderBottom:"none",padding:0,height:"100%",minHeight:"calc(100vh - 150px)",[e.breakpoints.down("sm")]:{minHeight:"calc(100vh - 180px)"},[e.breakpoints.down("xs")]:{minHeight:"calc(100vh - 160px)"}},tableLoadingBox:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",minHeight:"inherit"},table:{minWidth:650,borderCollapse:"collapse","& [class*=MuiTableCell-root]":{borderBottom:"none",border:"none"},"& [class*=MuiTableRow-root]":{"& td":{border:"none"}},[e.breakpoints.down("md")]:{minWidth:600},[e.breakpoints.down("sm")]:{minWidth:550},[e.breakpoints.down("xs")]:{minWidth:500}},tableHeadSticky:{position:"sticky",top:0,zIndex:10,backgroundColor:"rgb(252,252,252)"},tableHeader:{backgroundColor:"rgb(252,252,252)",borderBottom:"none",padding:e.spacing(2),fontWeight:"normal",whiteSpace:"nowrap",[e.breakpoints.down("md")]:{padding:e.spacing(1.5,1)},[e.breakpoints.down("sm")]:{padding:e.spacing(1.5,.75),"& [class*=MuiTypography-h5]":{fontSize:"0.875rem"}},[e.breakpoints.down("xs")]:{padding:e.spacing(1,.5),"& [class*=MuiTypography-h5]":{fontSize:"0.75rem",fontWeight:600}}},tableRow:{"&:nth-of-type(even)":{backgroundColor:"rgb(245,245,245)"},"&:hover":{backgroundColor:e.palette.primary.light},"& td":{padding:e.spacing(1.5,2),borderBottom:"none",[e.breakpoints.down("md")]:{padding:e.spacing(1.25,1)},[e.breakpoints.down("sm")]:{padding:e.spacing(1,.75),"& [class*=MuiTypography-body2]":{fontSize:"0.8125rem"}},[e.breakpoints.down("xs")]:{padding:e.spacing(.75,.5),"& [class*=MuiTypography-body2]":{fontSize:"0.75rem"}}}},datasetName:{fontWeight:500,fontSize:"0.875rem",[e.breakpoints.down("sm")]:{fontSize:"0.8125rem"},[e.breakpoints.down("xs")]:{fontSize:"0.75rem",wordBreak:"break-word"}},statusChip:{padding:"4px",color:"white",fontWeight:"600",fontSize:"0.75rem",he
1ight:"24px",[e.breakpoints.down("xs")]:{fontSize:"0.6875rem",height:"20px",padding:"2px 6px"}},copyButton:{padding:e.spacing(.5),"&:hover":{backgroundColor:"transparent"},"&:focus":{outline:"none"},[e.breakpoints.down("xs")]:{padding:e.spacing(.25),"& svg":{fontSize:"16px"}}},clickablePixelId:{cursor:"pointer",wordBreak:"break-all",[e.breakpoints.down("xs")]:{fontSize:"0.6875rem",maxWidth:"120px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},fixedBottomContainer:{marginTop:"20px",position:"fixed",height:"60px",borderTop:"1px solid lightgrey",background:"white",bottom:"0",left:70,right:"0",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,[e.breakpoints.down("md")]:{left:"0px"},[e.breakpoints.down("sm")]:{left:"0px",height:"50px",padding:e.spacing(0,1)},[e.breakpoints.down("xs")]:{height:"auto",minHeight:"50px",padding:e.spacing(.5,1),"& [class*=MuiTablePagination-root]":{overflow:"auto"}}},scrollToHeight:{height:"70px",width:"100%",[e.breakpoints.down("md")]:{height:"60px"},[e.breakpoints.down("sm")]:{height:"50px"},[e.breakpoints.down("xs")]:{height:"60px"}},createPixelDialog:{"& [class*=MuiDialog-paper]":{borderRadius:"12px",overflow:"hidden",[e.breakpoints.down("xs")]:{borderRadius:"8px",margin:e.spacing(1),maxWidth:"calc(100% - 16px)"}}},dialogTitle:{padding:e.spacing(3,3,2),backgroundColor:"#F5F5F5",borderBottom:"none",[e.breakpoints.down("sm")]:{padding:e.spacing(2.5,2.5,1.5)},[e.breakpoints.down("xs")]:{padding:e.spacing(1.5,1.5,1)}},dialogTitleText:{fontWeight:600,fontSize:"1.25rem",lineHeight:1.5,color:e.palette.text.primary,"&[class*=MuiTypography-h5]":{color:e.palette.text.primary},[e.breakpoints.down("xs")]:{fontSize:"1rem"}},dialogSubtitle:{marginTop:e.spacing(1),fontSize:"0.875rem",lineHeight:1.5,[e.breakpoints.down("xs")]:{fontSize:"0.8125rem",marginTop:e.spacing(.75)}},infoIcon:{fontSize:"20px",color:e.palette.primary.main,flexShrink:0},closeButton:{padding:e.spacing(.5),marginLeft:"auto",[e.breakpoints.down("xs")]:{padding:e.spacing(.75),minWidth:"44px",minHeight:"44px"}},dialogContent:{backgroundColor:"#F5F5F5",[e.breakpoints.down("xs")]:{padding:e.spacing(1.5)}},contentCard:{backgroundColor:"white",padding:e.spacing(2.5),borderRadius:"8px",[e.breakpoints.down("sm")]:{padding:e.spacing(2)},[e.breakpoints.down("xs")]:{padding:e.spacing(1.5)}},sectionTitle:{fontWeight:600,fontSize:"1rem",marginBottom:0,lineHeight:1.5,[e.breakpoints.down("xs")]:{fontSize:"0.9375rem"}},inputLabel:{marginBottom:e.spacing(1),fontWeight:500,fontSize:"0.875rem",[e.breakpoints.down("xs")]:{fontSize:"0.8125rem",marginBottom:e.spacing(.75)}},inputCard:{backgroundColor:"transparent",padding:0,borderRadius:"8px",border:"none",boxShadow:"none",overflow:"visible","& [class*=MuiOutlinedInput-root]":{backgroundColor:"#F9F9FB","& fieldset":{border:"none"},"&:hover fieldset":{border:"none"},"&.Mui-focused fieldset":{border:"none"}},"& [class*=MuiOutlinedInput-root].Mui-error":{borderRadius:"8px 8px 0 0"},"& [class*=MuiOutlinedInput-root]:not(.Mui-error)":{borderRadius:"8px"},"& [class*=MuiInputBase-root]":{backgroundColor:"#F9F9FB"},"& [class*=MuiFormHelperText-root]":{marginLeft:0,marginRight:0}},charCount:{fontSize:"12px",marginRight:"10px"},textFieldInput:{backgroundColor:"white","& [class*=MuiOutlinedInput-root]":{"& fieldset":{borderColor:e.palette.divider},"&:hover fieldset":{borderColor:e.palette.text.secondary},"&.Mui-focused fieldset":{borderColor:e.palette.primary.main}}},dialogActions:{padding:e.spacing(2,3),justifyContent:"flex-end",gap:e.spacing(1),backgroundColor:"#F5F5F5",borderTop:"none",[e.breakpoints.down("sm")]:{padding:e.spacing(1.5,2.5)},[e.breakpoints.down("xs")]:{padding:e.spacing(1.5,2),flexDirection:"column-reverse","& button":{width:"100%"}}},cancelButton:{textTransform:"none",[e.breakpoints.down("xs")]:{minHeight:"44px"}},inputPadding:{padding:"12px 10px"},codeContainer:{position:"relative","& pre":{fontFamily:"monospace",fontSize:"12px",lineHeight:1.5}},emptyStateBox:{minHeight:"calc(100vh - 200px)",height:"calc(100vh - 200px)",[e.breakpoints.down("sm")]:{minHeight:"calc(100vh - 180px)",height:"calc(100vh - 180px)"},[e.breakpoints.down("xs")]:{minHeight:"calc(100vh - 160px)",height:"calc(100vh - 160px)"}},emptyStateContainer:{padding:e.spacing(4),[e.breakpoints.down("xs")]:{padding:e.spacing(2)}},emptyStateImage:{width:"200px",height:"auto",marginBottom:e.spacing(2),maxWidth:"100%",[e.breakpoints.down("sm")]:{width:"180px",marginBottom:e.spacing(1.5)},[e.breakpoints.down("xs")]:{width:"150px",marginBottom:e.spacing(1)}},emptyStateText:{[e.breakpoints.down("xs")]:{fontSize:"1rem"}},tableContainerScrollable:{maxHeight:"calc(100vh - 280px)",overflowY:"auto",overflowX:"hidden",[e.breakpoints.down("sm")]:{maxHeight:"calc(100vh - 320px)",overflowX:"auto"},[e.breakpoints.down("xs")]:{maxHeight:"calc(100vh - 340px)",overflowX:"auto"}},overlay:{alignItems:"centre",background:"#fff",boxShadow:"3px 3px 30px rgb(255 255 255)",display:"flex",height:"100%",
1justifyContent:"centre",opacity:"0.6",width:"100%",position:"absolute",zIndex:20,top:0,left:0},overlayMessageContainer:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:21,width:"100%",display:"flex",justifyContent:"center",alignItems:"center",padding:e.spacing(2),[e.breakpoints.down("xs")]:{padding:e.spacing(1.5)}},higherzIndex:{zIndex:21,position:"relative"},message:{fontWeight:500,[e.breakpoints.down("sm")]:{fontSize:"1.5rem"},[e.breakpoints.down("xs")]:{fontSize:"1.25rem",display:"flex",flexDirection:"column",alignItems:"center",gap:e.spacing(1)}},TextFieldRoot:{padding:"0px",width:"100%"},helperText:{marginTop:"4px",fontSize:"12px",padding:"6px 10px",borderRadius:"0 0 8px 8px",marginLeft:0,marginRight:0,marginBottom:0,width:"100%",boxSizing:"border-box"},mobileDrawer:{[e.breakpoints.down("sm")]:{"& [class*=MuiDrawer-paper]":{maxHeight:"90vh",borderTopLeftRadius:"16px",borderTopRightRadius:"16px",overflow:"hidden"}}},drawerPaper:{width:"100%",maxHeight:"90vh"},drawerHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:e.spacing(1.5,1.5,1),backgroundColor:"white",position:"sticky",top:0,zIndex:1,[e.breakpoints.down("xs")]:{padding:e.spacing(1,1.25,.75)}},drawerTitle:{fontWeight:600,fontSize:"1.125rem",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[e.breakpoints.down("xs")]:{fontSize:"1rem"}},drawerCloseButton:{flexShrink:0,[e.breakpoints.down("xs")]:{minWidth:"44px",minHeight:"44px"}},drawerContent:{flex:1,overflowY:"auto",overflowX:"hidden",backgroundColor:"rgb(247, 247, 247)",padding:0,"&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-track":{background:e.palette.grey[100],borderRadius:"3px"},"&::-webkit-scrollbar-thumb":{background:e.palette.grey[400],borderRadius:"3px","&:hover":{background:e.palette.grey[500]}}}})))((0,r.withRouter)(xm)));var Am=a(79626),Im=a(65816),Cm=a(68016),_m=a(5696),Sm=a(48672),vm=a(3148),Em=a(93948),Tm=a(66265);function Dm(e){let{activeTab:t,broadcastDialogOpen:a,endDate:n,handleCloseBroadcastDialog:s,search:o,selectAll:i,selected:r,selectedAdId:l,selectedFormId:d,selectedOptNo:c,startDate:p,totalLeads:u,unSelected:m,unSelectedOptNo:g}=e;return(0,h.jsx)(ya.A,{open:a,onClose:s,"aria-labelledby":"form-dialog-title",maxWidth:"md",fullWidth:!0,disableBackdropClick:!0,children:a&&(()=>{let e=0;return e=i?u-m.length:r.length,(0,h.jsx)(B,{name:"broadcastCampaign",closeDialog:s,totalSelected:u,selectAll:i,unSelected:m,selected:r,allFilters:void 0,optedCount:0,selectedOptNo:c,unSelectedOptNo:g,groupedContacts:[],scheduledCampaigns:[],leadAudienceCampaign:!0,leadSourceType:t,leadSearch:o,leadStartDate:p,leadEndDate:n,leadAdId:l,leadFormId:d})})()})}function wm(e){let{classes:t,error:a,fetchHistoricalDialogOpen:n,fetchHistoricalEndDate:s,fetchHistoricalFormId:o,fetchHistoricalResult:i,fetchHistoricalStartDate:r,fetchingHistorical:l,forms:d,handleCloseFetchHistoricalDialog:c,handleFetchHistoricalLeads:p,leads:u,updateLeadsFilters:m}=e;return(0,h.jsxs)(ya.A,{open:n,onClose:c,maxWidth:"sm",fullWidth:!0,children:[(0,h.jsx)(_m.A,{children:(0,h.jsxs)(ia.A,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,h.jsx)(la.A,{variant:"h6",children:"Import Historical Leads"}),(0,h.jsx)(pn.A,{size:"small",onClick:c,children:(0,h.jsx)(et.A,{})})]})}),(0,h.jsxs)(Cm.A,{dividers:!0,children:[(0,h.jsx)(ia.A,{mb:2,children:(0,h.jsx)(la.A,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:"Fetch leads from Meta that were collected before webhook setup. These leads may be up to 90 days old."})}),(0,h.jsxs)(ia.A,{mb:3,children:[(0,h.jsx)(la.A,{variant:"body2",color:"textSecondary",style:{marginBottom:4},children:"Select Lead Form *"}),(0,h.jsxs)(ca.A,{select:!0,fullWidth:!0,variant:"outlined",size:"small",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},value:o||"",onChange:e=>m({fetchHistoricalFormId:e.target.value}),children:[(0,h.jsx)(kn.A,{value:"",children:"Select a form"}),d.map((e=>(0,h.jsx)(kn.A,{value:e.formId,children:e.name},e.formId)))]})]}),(0,h.jsxs)(ia.A,{mb:3,children:[(0,h.jsx)(la.A,{variant:"body2",color:"textSecondary",style:{marginBottom:4},children:"Date Range (optional)"}),(0,h.jsxs)(ra.A,{container:!0,spacing:2,children:[(0,h.jsx)(ra.A,{item:!0,xs:6,children:(0,h.jsx)(ca.A,{fullWidth:!0,variant:"outlined",size:"small",type:"date",label:"Start Date",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},InputLabelProps:{shrink:!0}
1,value:r?ve()(r).format("YYYY-MM-DD"):"",onChange:e=>m({fetchHistoricalStartDate:e.target.value?new Date(e.target.value):null})})}),(0,h.jsx)(ra.A,{item:!0,xs:6,children:(0,h.jsx)(ca.A,{fullWidth:!0,variant:"outlined",size:"small",type:"date",label:"End Date",classes:{root:t.TextFieldRoot},InputProps:{classes:{input:t.inputPadding}},InputLabelProps:{shrink:!0},value:s?ve()(s).format("YYYY-MM-DD"):"",onChange:e=>m({fetchHistoricalEndDate:e.target.value?new Date(e.target.value):null})})})]})]}),i&&(0,h.jsxs)(Aa.A,{severity:i.success?"success":"error",style:{marginBottom:16},children:[i.message,i.data&&(0,h.jsxs)(ia.A,{mt:1,children:[(0,h.jsxs)(la.A,{variant:"body2",children:["Total fetched: ",i.data.totalFetched]}),(0,h.jsxs)(la.A,{variant:"body2",children:["New leads: ",i.data.newLeads]}),(0,h.jsxs)(la.A,{variant:"body2",children:["Already existed: ",i.data.existingLeads]})]})]})]}),(0,h.jsxs)(Im.A,{children:[(0,h.jsx)(da.A,{onClick:c,children:"Cancel"}),(0,h.jsx)(da.A,{variant:"contained",color:"primary",onClick:p,disabled:l||!o,startIcon:l?(0,h.jsx)(ba.A,{size:16,color:"inherit"}):null,children:l?"Fetching...":"Fetch Leads"})]})]})}function Nm(e){let{activeTab:t,ads:a,classes:n,detailDialogOpen:s,handleCloseLead:o,handleNextLead:i,handlePrevLead:r,leads:l,selectedLead:d,selectedLeadIndex:c}=e;return(0,h.jsx)(Ze,{open:s,onClose:o,title:"ctwa"===d?._leadType||"ctwa"===t?"CTWA Lead Details":"Submission Details",width:"450px",children:d&&(0,h.jsxs)(ia.A,{children:[(0,h.jsxs)(ia.A,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3,pb:2,borderBottom:"1px solid #E8E8E8",children:[(0,h.jsx)(pn.A,{disabled:0===c,onClick:r,size:"small",children:(0,h.jsx)(un.A,{})}),(0,h.jsxs)(la.A,{variant:"body2",color:"textSecondary",children:[c+1," of ",l.length]}),(0,h.jsx)(pn.A,{disabled:c>=l.length-1,onClick:i,size:"small",children:(0,h.jsx)(mn.A,{})})]}),"ctwa"===d._leadType||"ctwa"===t?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(la.A,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:["User Name: ",d.userName||"-"]}),(0,h.jsxs)(la.A,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:["User Number: ",d.userNumber||"-"]}),(0,h.jsxs)(la.A,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:["Messages: ",d.messages||0]}),(0,h.jsxs)(la.A,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:["Lead Type: ","new"===d.leadType?"New":"existing"===d.leadType?"Existing":"-"]}),(0,h.jsxs)(la.A,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:["Ad: ",a.find((e=>e.adId===d.adId))?.adName||"Unknown"]}),(0,h.jsxs)(la.A,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:["Sent At:"," ",d.sentAt?ve()(d.sentAt).format("MMMM DD, YYYY HH:mm:ss"):"-"]}),d.adUrl&&(0,h.jsxs)(la.A,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:["Ad URL: ",d.adUrl]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(la.A,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:["Lead ID: ",d.leadgenId]}),(0,h.jsxs)(la.A,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:["Submitted At:"," ",d.createdTime||d.created_time?ve()(d.createdTime||d.created_time).format("MMMM DD, YYYY HH:mm:ss"):"-"]}),(0,h.jsxs)(la.A,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:["Form: ",d.formName||"Unknown"]}),(0,h.jsxs)(la.A,{variant:"body2",color:"textSecondary",style:{marginBottom:16},children:["Ad: ",d.adName||"Unknown"]})]}),"ctwa"!==d._leadType&&"ctwa"!==t&&d.mappedParams&&Object.keys(d.mappedParams).length>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(la.A,{variant:"subtitle1",gutterBottom:!0,style:{marginTop:16,fontWeight:600},children:"Mapped Parameters"}),(0,h.jsx)(la.A,{variant:"caption",color:"textSecondary",style:{marginBottom:12,display:"block"},children:"Standardized parameter values from form submission"}),Object.entries(d.mappedParams).map((e=>{let[t,a]=e,s=t.replace(/_/g," ").toUpperCase();if(d.questionAnswers&&d.questionAnswers.length>0){let e=d.questionAnswers.find((e=>e.parameterKey&&(e.parameterKey===t||e.parameterKey.toUpperCase()===t.toUpperCase())));e||(e=d.questionAnswers.find((e=>e.key&&(e.key===t||e.key.toUpperCase()===t.toUpperCase()||e.key.replace(/_/g,"").toUpperCase()===t.replace(/_/g,"").toUpperCase())))),e&&e.question&&(s=e.question)}return(0,h.jsxs)(ia.A,{className:n.fieldRow,children:[(0,h.jsx)(la.A,{variant:"body2",className:n.fieldLabel,children:s}),(0,h.jsx)(la.A,{variant:"body1",children:Array.isArray(a)?a.join(", "):String(a||"-")})]},t)})),(0,h.jsx)(ia.A,{my:2,children:(0,h.jsx)(Sm.A,{})})]}),"ctwa"!==d._leadType&&"ctwa"!==t&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(la.A,{variant:"subtitle1",gutterBottom:!0,style:{marginTop:16,fontWeight:600},children:"Questions & Answers"}),(0,h.jsx)(la.A,{variant:"caption",color:"textSecondary",style:{marginBottom:12,display:"block"},children:"Complete form submission with question labels and answers"}),d.questionAnswers&&d.questionAnswers.length>0?d.questionAnswers.map(((e,t)=>{const a=e.question||e.key?.replace(/_/g," ").toUpperCase()||"Question",s=e.answer||"-";return(0,h.jsxs)(ia.A,{className:n.fieldRow,children:[(0,h.jsx)(la.A,{variant:"body2",className:n.fieldLabel,children:a}),(0,h.jsx)(la.A,{variant:"body1",children:s})]},t)})):(d.field_data||[]).map(((e,t)=>(0,h.jsxs)(ia.A,{className:n.fieldRow,children:[(0,h.jsx)(la.A,{variant:"body2",className:n.fieldLabel,children:e.name.replace(/_/g," ").toUpperCase()}),(0,h.jsx)(la.A,{variant:"body1",children:(e.values||[]).join(", ")||"-"})]},t)))]})]})})}function jm(e){let{activeTab:t,ads:a,classes:n,endDate:s,forms:o,handleAdFilterChange:i,handleDateRangeChange:r,handleFilterChange:l,handleSearchChange:d,search:c,selectedAdId:p,selectedFormId:u,startDate:m}=e;return(0,h.jsx)(vm.A,{className:n.filterContainer,children:(0,h.jsxs)(ra.A,{container:!0,spacing:2,alignItems:"center",children:[(0,h.jsx)(ra.A,{item:!0,xs:12,md:3,children:(0,h.jsx)(ca.A,{fullWidth:!0,variant:"outlined",size:"small",classes:{root:n.TextFieldRoot},InputProps:{classes:{input:n.searchInputPadding},startAdornment:(0,h.jsx)(pa.A,{position:"start",style:{margin:0},children:(0,h.jsx)(Ia.A,{})})},placeholder:"Search by name, email, phone...",value:c,onChange:d})}),"ctwa"!==t&&(0,h.jsx)(ra.A,{item:!0,xs:12,md:2,children:(0,h.jsxs)(ia.A,{display:"flex",alignItems:"center",style:{gap:8},children:[(0,h.jsx)(la.A,{variant:"body1",color:"textSecondary",style:{whiteSpace:"nowrap",fontSize:"14px",fontWeight:500},children:"Form:"}),(0,h.jsxs)(ca.A,{select:!0,fullWidth:!0,variant:"outlined",size:"small",classes:{root:n.TextFieldRoot},InputProps:{classes:{input:n.inputPadding}},value:u,onChange:e=>{l("selectedFormId",e.target.value)},SelectProps:{displayEmpty:!0,renderValue:e=>{if(!e)return"All Forms";const t=o.find((t=>t.formId===e));return t?t.name:e}},children:[(0,h.jsx)(kn.A,{value:"",children:"All Forms"}),o.map((e=>(0,h.jsx)(kn.A,{value:e.formId,children:e.name},e.formId)))]})]})}),(0,h.jsx)(ra.A,{item:!0,xs:12,md:2,children:(0,h.jsxs)(ia.A,{display:"flex",alignItems:"center",style:{gap:8},children:[(0,h.jsx)(la.A,{variant:"body1",color:"textSecondary",style:{whiteSpace:"nowrap",fontSize:"14px",fontWeight:500},children:"Ad:"}),(0,h.jsxs)(ca.A,{select:!0,fullWidth:!0,variant:"outlined",size:"small",classes:{root:n.TextFieldRoot},InputProps:{classes:{input:n.inputPadding}},value:p,onChange:e=>{i(e)},SelectProps:{displayEmpty:!0,renderValue:e=>{if(!e)return"All Ads";let t=null;return t=a.find((t=>t.adId===e))?.adName||e,t||e}},children:[(0,h.jsx)(kn.A,{value:"",children:"All Ads"}),(()=>{let e=[];const n=a;"all"===t?e=[...n]:"form"===t?e=n.filter((e=>"ON_AD"==e.destinationType)):"ctwa"===t&&(e=n.filter((e=>"WHATSAPP"==e.destinationType)));const s=new Map;return e.forEach((e=>{e.adId&&!s.has(e.adId)&&s.set(e.adId,e)})),Array.from(s.values()).map((e=>(0,h.jsx)(kn.A,{value:e.adId,children:e.adName||e.adId},e.adId)))})()]})]})}),(0,h.jsx)(ra.A,{item:!0,xs:12,md:"ctwa"===t?4:3,children:(0,h.jsxs)(ia.A,{display:"flex",alignItems:"center",style:{gap:8},children:[(0,h.jsx)(la.A,{variant:"body1",color:"textSecondary",style:{whiteSpace:"nowrap",fontSize:"14px",fontWeight:500},children:"Date Range:"}),(0,h.jsx)(Yi,{startDate:m,endDate:s,onChange:r})]})})]})})}function km(e){let{activeTab:t,classes:a,forms:n,totalLeads:s}=e;return(0,h.jsxs)(ia.A,{className:a.statsContainer,children:[(0,h.jsxs)(vm.A,{className:a.statCard,children:[(0,h.jsx)(la.A,{variant:"h4",color:"primary",children:s}),(0,h.jsx)(la.A,{variant:"body2",color:"textSecondary",children:"all"===t?"Total Leads":"form"===t?"Total Submissions":"Total CTWA Leads"})]}),"ctwa"!==t&&(0,h.jsxs)(vm.A,{className:a.statCard,children:[(0,h.jsx)(la.A,{variant:"h4",color:"primary",children:n.length}),(0,h.jsx)(la.A,{variant:"body2",color:"textSecondary",children:"Active Forms"})]})]})}function Lm(e){let{parentLoading:t,activeTab:a,ads:n,agent:s,classes:o,currentTableHeaders:i,forms:r,getCurrentLoading:l,handlePageChange:d,handleRowsPerPageChange:c,handleSelectAll:p,handleSelectLead:u,handleViewLead:m,leads:g,page:b,rowsPerPage:y,selectAll:x,selected:f,setState:A,totalLeads:I,unSelected:C}=e;return(0,h.jsx)("div",{className:o.tableRoot,children:l()||t?(0,h.jsx)(ia.A,{display:"flex",justifyContent:"center",alignItems:"center",minHeight:200,children:(0,h.jsx)(ba.A,{})}):0===g.length?(0,h.jsxs)(ia.A,{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",minHeight:200,children:[(0,h.jsx)(la.A,{variant:"body1",color:"textSecondary",gutterBottom:!0,children:"all"===a?"No leads found":"form"===a?"No submissions foun
1d":"No CTWA leads found"}),(0,h.jsx)(la.A,{variant:"body2",color:"textSecondary",children:"all"===a?"Leads from both forms and CTWA ads will appear here":"form"===a?"Lead form submissions will appear here when users submit your forms":"CTWA leads will appear here when users click on your ads"})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("table",{children:(0,h.jsxs)("tbody",{children:[(0,h.jsxs)("tr",{className:`${o.row} ${o.topbar}`,children:[(0,h.jsx)("th",{className:(0,gn.A)(o.column,o.checkboxColumn),children:(0,h.jsx)(ha.A,{color:"primary",checked:x,onChange:p})}),i.map((e=>(0,h.jsx)("th",{className:(0,gn.A)(o.column,o.dataColumn),children:(0,h.jsx)(la.A,{variant:"h5",color:"primary",children:e.label})})))]}),g.map(((e,t)=>{const r=e._id||e.leadgenId||e.userNumber,l=e?.phoneNumber||e?.userNumber,d=s?.specialAccess?.enableMasking,c=d?e.conversationId:l;return(0,h.jsxs)("tr",{className:(0,gn.A)(o.row,o.onHoverEffect,{[o.alterRow]:t%2==0}),onClick:n=>{"checkbox"!==n.target.type&&"form"==a&&"ctwa"!==e.leadType&&m(e,t)},children:[(0,h.jsx)("th",{className:(0,gn.A)(o.column,o.checkboxColumn),children:(0,h.jsx)(ha.A,{color:"primary",checked:x?!C.includes(c):f.includes(c),onChange:e=>{A({isCheckboxClicked:!0}),e.stopPropagation(),u(c)}})}),i.map((t=>(0,h.jsx)("th",{className:(0,gn.A)(o.column,o.dataColumn),children:(0,h.jsx)(la.A,{variant:"h5",color:"primary",children:"adId"===t.key?e?.lastAdName?e.lastAdName:n.find((t=>t.adId===e.adId||e.lastAdId))?.adName||e.adId||e.lastAdId:"leadType"===t.key?"ctwa"===e.leadType?"CTWA":"FORM":"createdAt"===t.key?ve()(e[t.key]).format("MMM DD, YYYY HH:mm"):e[t.key]||"-"})})))]},r)}))]})}),(0,h.jsx)("div",{className:o.fixedBottomContainer,children:l()?(0,h.jsx)(ia.A,{xs:12,md:11,lg:11,children:(0,h.jsx)(ba.A,{size:24})}):(0,h.jsx)(Em.A,{rowsPerPageOptions:[5,10,25,50],component:"div",count:I,rowsPerPage:y,page:b,onChangePage:d,onChangeRowsPerPage:c})})]})})}function Rm(e){let{activeTab:t,assistantId:a,classes:n,exportToCSVServer:s,fetchLeads:o,fetchStats:i,handleBroadcast:r,handleSyncLeads:l,isExporting:d,isSyncing:c,leads:p,page:u,pageId:m,selectedCount:g}=e;return(0,h.jsx)(ia.A,{className:n.toolbarRow,children:(0,h.jsxs)(ia.A,{display:"flex",alignItems:"center",gap:16,children:[(0,h.jsx)(da.A,{variant:"outlined",size:"small",startIcon:(0,h.jsx)(Tm.A,{}),onClick:()=>{o(),i()},style:{textTransform:"none"},children:"Refresh"}),(0,h.jsx)(ga.Ay,{title:m?"Fetch any leads missed by the webhook from Meta":"Connect a page to sync leads",children:(0,h.jsx)("span",{children:(0,h.jsx)(da.A,{variant:"outlined",size:"small",startIcon:c?(0,h.jsx)(ba.A,{size:16,color:"inherit"}):(0,h.jsx)(Ca.A,{}),onClick:l,disabled:c||!m,style:{textTransform:"none"},children:c?"Syncing...":"Sync Leads"})})}),va("broadcastCampaign")&&(0,h.jsx)(ga.Ay,{title:0===g?"Select at least one submission":"",children:(0,h.jsx)("span",{children:(0,h.jsx)(da.A,{variant:"contained",color:"primary",size:"small",onClick:r,disabled:0===g,style:{textTransform:"none"},children:"BROADCAST"})})}),(0,h.jsx)(ga.Ay,{title:d?"Exporting...":0===p.length?"No leads to export":"ctwa"===t?"Server export is only available for Lead Form Submissions":a?"":"Assistant ID is required",children:(0,h.jsx)("span",{children:(0,h.jsx)(da.A,{variant:"contained",color:"primary",size:"small",startIcon:d?(0,h.jsx)(ba.A,{size:16,color:"inherit"}):(0,h.jsx)(_a.A,{}),onClick:s,disabled:d||0===p.length||!a,style:{textTransform:"none"},children:d?"Exporting...":"Export CSV"})})})]})})}const Bm={all:[{label:"Lead Source",key:"leadType"},{label:"Name",key:"name"},{label:"Phone Number",key:"phoneNumber"},{label:"Last Ad Name",key:"adId"},{label:"Interaction Count",key:"submissionCount"},{label:"Created At",key:"createdAt"}],form:[{label:"Name",key:"name"},{label:"Phone Number",key:"phoneNumber"},{label:"Ad Name",key:"adName"},{label:"Form Name",key:"formName"},{label:"Created At",key:"createdAt"}],ctwa:[{label:"Name",key:"name"},{label:"Phone Number",key:"phoneNumber"},{label:"Ad Name",key:"adId"},{label:"Created At",key:"createdAt"}]};class Om extends n.Component{static contextType=(()=>ls.$t)();constructor(e){super(e),this.state={selectedLead:null,selectedLeadIndex:-1,detailDialogOpen:!1,selectedLeadForm:null,fetchHistoricalDialogOpen:!1,broadcastDialogOpen:!1,isCheckboxClicked:!1,isSyncing:!1},this.searchTimeout=null}componentDidMount(){const{assistantId:e,pageId:t,fetchAdsList:a,fetchLeadForms:n,fetchLeadSubmissions:s,activeTab:o}=this.props;e&&(a(e),t&&(s(e,t,{page:0,rowsPerPage:10,search:"",selectedFormId:"",selectedAdId:"",startDate:null,endD
1ate:null,activeTab:o||"all"}),n(e,t)))}componentDidUpdate(e){const{assistantId:t,pageId:a,activeTab:n,fetchLeadSubmissions:s,fetchLeadForms:o,fetchAdsList:i}=this.props,r=e.assistantId!==t,l=e.pageId!==a,d=!e.pageId&&a,c=e.activeTab!==n;if((r||l||d)&&t&&(i(t),a)){s(t,a,this.getCurrentFilters()),o(t,a)}if(c&&t){s(t,a,this.getCurrentFilters())}}componentWillUnmount(){this.searchTimeout&&clearTimeout(this.searchTimeout)}getCurrentFilters=()=>{const{page:e,rowsPerPage:t,search:a,selectedFormId:n,selectedAdId:s,selectedAdIdCTWA:o,startDate:i,endDate:r,activeTab:l}=this.props;return{page:e,rowsPerPage:t,search:a,selectedFormId:n,selectedAdId:"ctwa"===l?o:s,selectedAdIdCTWA:o,startDate:i,endDate:r,activeTab:l||"all"}};fetchLeads=()=>{const{assistantId:e,pageId:t,fetchLeadSubmissions:a,activeTab:n,clearLeadsSelection:s}=this.props;if(!e||!t)return;a(e,t,this.getCurrentFilters()),s()};fetchStats=()=>{const{assistantId:e,pageId:t}=this.props};notify=(()=>{var e=this;return function(t){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info";const{showSnackbar:n}=e.context||{};n&&n(t,a)}})();handleSyncLeads=async()=>{const{assistantId:e,pageId:t,selectedFormId:a}=this.props;if(e&&t&&!this.state.isSyncing){this.setState({isSyncing:!0});try{const n=await(0,_n.kR)(e,t,a||void 0);if(!1===n?.status)return void this.notify(n?.message||"Nothing to sync","info");this.notify("Lead sync started. This may take a few minutes.","info"),this.fetchLeads()}catch(e){const t=e?.response?.data,a=t?.errorCode??t?.error?.code;let n=t?.message||t?.error?.message||("string"==typeof t?t:"")||e?.message||"Failed to start lead sync";"190"===String(a)?n="Access token expired — please reconnect your Facebook account.":"200"===String(a)&&(n="Missing page permissions — please reconnect Facebook and grant pages_manage_ads and leads_retrieval."),this.notify(n,"error")}finally{this.setState({isSyncing:!1})}}};handleSelectAll=e=>{const{leads:t}=this.props,a=e.target.checked,{updateLeadsSelection:n}=this.props;n({selectAll:a,selected:[],unSelected:[],selectedCount:a?t.length:0})};handleSelectLead=e=>{const{selected:t,selectAll:a,unSelected:n,updateLeadsSelection:s}=this.props,{leads:o}=this.props;if(a)if(n.includes(e)){const t=n.filter((t=>t!==e));s({unSelected:t,selectedCount:o.length-t.length})}else{const t=[...n,e];s({unSelected:t,selectedCount:o.length-t.length})}else if(t.includes(e)){const a=t.filter((t=>t!==e));s({selected:a,selectedCount:a.length})}else{const a=[...t,e];s({selected:a,selectedCount:a.length})}};clearSelection=()=>{const{clearLeadsSelection:e}=this.props;e()};extractPhoneNumber=e=>{const{activeTab:t}=this.props;if("ctwa"===e._leadType||"ctwa"===t)return e.userNumber||"";if(e.mappedParams&&e.mappedParams.PHONE_NUMBER){const t=e.mappedParams.PHONE_NUMBER;return Array.isArray(t)?t[0]:t}if(e.phoneNumber)return e.phoneNumber;{const t=(e.field_data||[]).find((e=>{const t=(e.name||"").toUpperCase();return("PHONE_NUMBER"===t||"PHONE"===t)&&!t.includes("WORK")}));if(t&&t.values&&t.values.length>0)return t.values[0]}return""};normalizePhoneNumber=e=>e?e.startsWith("+")?e.substring(1):e:"";getAllBroadcastLeads=()=>{const{leads:e}=this.props;return e.map((e=>{const t=this.extractPhoneNumber(e);return{userNumber:this.normalizePhoneNumber(t),_originalLead:e}})).filter((e=>e.userNumber))};handleBroadcast=async()=>{if(!va("broadcastCampaign"))return;const{selectedCount:e,fetchOptedOutCount:t,assistantId:a}=this.props;if(0===e)return;const n=this.getAllBroadcastLeads(),{selected:s,unSelected:o,selectAll:i}=this.props,r=i?n.filter((e=>{const t=e._originalLead?._id||e._originalLead?.leadgenId||e._originalLead?.userNumber;return!o.includes(t)})).map((e=>e.userNumber)):n.filter((e=>{const t=e._originalLead?._id||e._originalLead?.leadgenId||e._originalLead?.userNumber;return s.includes(t)||s.includes(e.userNumber)})).map((e=>e.userNumber));if(r.length>0)await t(a,r,!1),this.setState({broadcastDialogOpen:!0});else if(o.length>0){const e=n.filter((e=>{const t=e._originalLead?._id||e._originalLead?.leadgenId||e._originalLead?.userNumber;return o.includes(t)})).map((e=>e.userNumber));await t(a,e,!0),this.setState({broadcastDialogOpen:!0})}else this.setState({broadcastDialogOpen:!0})};handleCloseBroadcastDialog=()=>{this.setState({broadcastDialogOpen:!1})};fetchForms=()=>{const{assistantId:e,pageId:t,fetchLeadForms:a}=this.props;e&&t&&a(e,t)};fetchAds=()=>{const{assistantId:e,fetchAdsList:t}=this.props;e&&t(e)};handleTabChange=(e,t)=>
1{const{setLeadsActiveTab:a,assistantId:n,pageId:s,fetchLeadSubmissions:o,updateLeadsFilters:i,clearLeadsSelection:r}=this.props;if(r(),i({search:"",selectedFormId:"",selectedAdId:"",selectedAdIdCTWA:"",startDate:null,endDate:null,page:0,ctwaPage:0}),n&&s){o(n,s,{page:0,rowsPerPage:this.props.rowsPerPage,search:"",selectedFormId:"",selectedAdId:"",selectedAdIdCTWA:"",startDate:null,endDate:null,activeTab:t})}a(t)};handleLeadContactsPageChange=(e,t)=>{this.setState({leadContactsPage:t},this.fetchLeadContacts)};handleLeadContactsRowsPerPageChange=e=>{this.setState({leadContactsRowsPerPage:parseInt(e.target.value,10),leadContactsPage:0},this.fetchLeadContacts)};handleSearchChange=e=>{const t=e.target.value,{updateLeadsFilters:a,assistantId:n,pageId:s,fetchLeadSubmissions:o}=this.props;a({search:t,page:0,ctwaPage:0}),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((()=>{if(n&&s){const e=this.getCurrentFilters();e.search=t,o(n,s,e)}}),500)};handlePageChange=(e,t)=>{const{activeTab:a,updateLeadsPagination:n,assistantId:s,pageId:o,fetchLeadSubmissions:i}=this.props;if(n({page:t}),s&&o){const e=this.getCurrentFilters();e.page=t,i(s,o,e)}};handleRowsPerPageChange=e=>{const t=parseInt(e.target.value,10);console.log(e.target.value,{newRowsPerPage:t});const{activeTab:a,updateLeadsPagination:n,assistantId:s,pageId:o,fetchLeadSubmissions:i}=this.props;if(n({rowsPerPage:t,page:0}),s){const e=this.getCurrentFilters();e.rowsPerPage=t,e.page=0,i(s,o,e)}};handleFilterChange=(e,t)=>
1{const{updateLeadsFilters:a,assistantId:n,pageId:s,fetchLeadSubmissions:o}=this.props;if(a({[e]:t,page:0}),n&&s){const a=this.getCurrentFilters();a[e]=t,a.page=0,o(n,s,a)}};handleAdFilterChange=e=>{const t=e.target.value,{updateLeadsFilters:a,assistantId:n,pageId:s,fetchLeadSubmissions:o}=this.props;if(a({selectedAdId:t,page:0}),n&&s){const e=this.getCurrentFilters();e.selectedAdId=t,e.page=0,o(n,s,e)}};handleDateRangeChange=(e,t)=>{const{updateLeadsFilters:a,assistantId:n,pageId:s,fetchLeadSubmissions:o}=this.props;if(a({startDate:e,endDate:t,page:0,ctwaPage:0}),n){const a=this.getCurrentFilters();a.startDate=e,a.endDate=t,a.page=0,o(n,s,a)}};convertOptionKeysToValues=(e,t)=>e&&t?e.map((e=>{const a=t.find((t=>t.key===e.key||t.key?.toLowerCase()===e.key?.toLowerCase()));if(a&&a.options&&a.options.length>0){const t=a.options.find((t=>t.key===e.answer||t.key?.toLowerCase()===e.answer?.toLowerCase()||String(t.key).toLowerCase()===String(e.answer).toLowerCase()));if(t&&t.value)return{...e,answer:t.value}}return e})):e;convertMappedParamValue=(e,t,a,n)=>{if(!t||!a||0===a.length)return t;let s=null;if(n&&n.length>0){const t=n.find((t=>t.parameterKey&&(t.parameterKey===e||t.parameterKey.toUpperCase()===e.toUpperCase()||t.parameterKey.toLowerCase()===e.toLowerCase())));t&&t.key&&(s=a.find((e=>e.key===t.key||e.key?.toLowerCase()===t.key?.toLowerCase())))}if(s||(s=a.find((t=>t.mappedParameter===e||t.mappedParameter&&t.mappedParameter.toUpperCase()===e.toUpperCase()||t.mappedParameter&&t.mappedParameter.toLowerCase()===e.toLowerCase()))),s||(s=a.find((t=>t.key===e||t.key?.toLowerCase()===e?.toLowerCase()))),s&&s.options&&s.options.length>0){const e=(Array.isArray(t)?t:[t]).map((e=>{if(!e||""===e)return e;const t=String(e),a=s.options.find((e=>{if(!e||!e.key)return!1;const a=String(e.key);return a===t||a.toLowerCase()===t.toLowerCase()}));if(a&&a.value)return a.value;s.options.find((e=>e.value===t||e.value&&e.value.toLowerCase()===t.toLowerCase()));return e}));return Array.isArray(t)?e:e[0]||t}return t};fetchFormForLead=async e=>{const{assistantId:t,fetchLeadFormDetails:a}=this.props;return e&&t?await a(t,e):null};handleViewLead=async(e,t)=>{if(this.state.isCheckboxClicked)return void this.setState({isCheckboxClicked:!1});const a=void 0!==t?t:this.state.leads.findIndex((t=>t._id===e._id));let n={...e},s=null;if(e.formId&&(s=await this.fetchFormForLead(e.formId),s&&s.questions&&(e.questionAnswers&&e.questionAnswers.length>0&&(n={...n,questionAnswers:this.convertOptionKeysToValues(e.questionAnswers,s.questions)}),e.mappedParams&&Object.keys(e.mappedParams).length>0))){const t={};Object.entries(e.mappedParams).forEach((a=>{let[n,o]=a;t[n]=this.convertMappedParamValue(n,o,s.questions,e.questionAnswers)})),n={...n,mappedParams:t}}this.setState({selectedLead:n,selectedLeadIndex:a>=0?a:0,detailDialogOpen:!0,selectedLeadForm:s})};handleCloseLead=()=>{this.setState({selectedLead:null,selectedLeadIndex:-1,detailDialogOpen:!1,selectedLeadForm:null})};handleNextLead=async()=>{const{selectedLeadIndex:e}=this.state,{leads:t}=this.props;if(e<t.length-1){const a=e+1,n=t[a];let s={...n},o=null;if(n.formId&&(o=await this.fetchFormForLead(n.formId),o&&o.questions&&(n.questionAnswers&&n.questionAnswers.length>0&&(s={...s,questionAnswers:this.convertOptionKeysToValues(n.questionAnswers,o.questions)}),n.mappedParams&&Object.keys(n.mappedParams).length>0))){const e={};Object.entries(n.mappedParams).forEach((t=>{let[a,s]=t;e[a]=this.convertMappedParamValue(a,s,o.questions,n.questionAnswers)})),s={...s,mappedParams:e}}this.setState({selectedLead:s,selectedLeadIndex:a,selectedLeadForm:o})}};handlePrevLead=async()=>{const{selectedLeadIndex:e}=this.state,{leads:t}=this.props;if(e>0){const a=e-1,n=t[a];let s={...n},o=null;if(n.formId&&(o=await this.fetchFormForLead(n.formId),o&&o.questions&&(n.questionAnswers&&n.questionAnswers.length>0&&(s={...s,questionAnswers:this.convertOptionKeysToValues(n.questionAnswers,o.questions)}),n.mappedParams&&Object.keys(n.mappedParams).length>0))){const e={};Object.entries(n.mappedParams).forEach((t=>{let[a,s]=t;e[a]=this.convertMappedParamValue(a,s,o.questions,n.questionAnswers)})),s={...s,mappedParams:e}}this.setState({selectedLead:s,selectedLeadIndex:a,selectedLeadForm:o})}};handleOpenFetchHistoricalDialog=()=>{const{updateLeadsFilters:e}=this.props;this.setState({fetchHistoricalDialogOpen:!0}),e({fetchHistoricalFormId:"",fetchHistoricalStartDate:null,fetchHistoricalEndDate:null,fetchHistoricalResult:null})};handleCloseFetchHistoricalDialog=()=>{const{updateLeadsFilters:e}=this.props;this.setState({fetchHistoricalDialogOpen:!1}),e({fetchHistoricalResult:null})};handleFetchHistoricalLeads=async()=>{const{assistantId:e,pageId:t,fetchHistoricalLeads:a,fetchHistoricalFormId:n,fetchHistoricalStartDate:s,fetchHistoricalEndDate:o,fetchLeadSubmissions:i}=this.props;if(!e||!t)return;if(!n)return;await a(e,t,n,s,o);i(e,t,this.getCurrentFilters())};exportToCSVServer=async()=>{const{assistantId:e,pageId:t,exportLeadsToCSV:a,activeTab:n,selectedFormId:s,selectedAdId:o,selectedAdIdCTWA:i,startDate:r,endDate:l}=this.props;if(e)if("form"!==n||t)try{await a(e,t,{selectedFormId:s,selectedAdId:o,selectedAdIdCTWA:i,startDate:r,endDate:l,activeTab:n})}catch(e){alert(`Export failed: ${e.message||"Please try again."}`)}else alert("Page ID is required for exporting lead form submissions");else alert("Assistant ID is required for export")};extractName=e=>{const{activeTab:t}=this.props;if("ctwa"===e._leadType||"ctwa"===t)return e.userName||"";if(e.mappedParams&&e.mappedParams.FULL_NAME){const t=e.mappedParams.FULL_NAME;return Array.isArray(t)?t[0]:t}if(e.mappedParams&&e.mappedParams.FIRST_NAME){const t=e.mappedParams.FIRST_NAME,a=e.mappedParams.LAST_NAME;return`${Array.isArray(t)?t[0]:t} ${a?Array.isArray(a)?a[0]:a:""}`.trim()}{const t=(e.field_data||[]).find((e=>"full_name"===e.name||"FULL_NAME"===e.name||"first_name"===e.name||"FIRST_NAME"===e.name));if(t&&t.values&&t.values.length>0)return t.values[0]}return""};extractEmail=e=>{if(e.email)return e.email;if(e.mappedParams&&e.mappedParams.EMAIL){const t=e.mappedParams.EMAIL;return Array.isArray(t)?t[0]:t}{const t=(e.field_data||[]).find((e=>"email"===e.name||"EMAIL"===e.name));if(t&&t.values&&t.values.length>0)return t.values[0]}return""};leadMatchesSearch=(e,t)=>{if(!t||""===t.trim())return!0;const a=t.toLowerCase().trim(),n=this.extractName(e).toLowerCase(),s=this.extractEmail(e).toLowerCase(),o=this.extractPhoneNumber(e).toLowerCase();return n.includes(a)||s.includes(a)||o.includes(a)};getCurrentLoading=()=>{const{activeTab:e,loading:t,ctwaLoading:a}=this.props;return"all"===e?t||a:"form"===e?t:a};render(){var e=this;const{classes:t,isLoading:a}=this.props,{leads:n,loading:s,error:o,page:i,rowsPerPage:r,totalLeads:l,search:d,selectedFormId:c,stats:p,forms:u,activeTab:m,selected:g,selectAll:b,unSelected:y,selectedCount:x,selectedOptNo:f,unSelectedOptNo:A,isExporting:I,fetchHistoricalFormId:C,fetchHistoricalStartDate:_,fetchHistoricalEndDate:S,fetchHistoricalResult:v,fetchingHistorical:E,ads:T}=this.props,{selectedLead:D,selectedLeadIndex:w,detailDialogOpen:N,fetchHistoricalDialogOpen:j,broadcastDialogOpen:k,isSyncing:L}=this.state,R="all"===m?Bm.all:"form"===m?Bm.form:Bm.ctwa;return(0,h.jsxs)(ia.A,{className:`${t.pageRoot} ginger-page-root`,children:[(0,h.jsxs)(ra.A,{container:!0,alignItems:"center",justify:"space-between",className:`${t.pageTitleContainer} ${t.fullWidth} ginger-page-header`,children:[(0,h.jsx)(ra.A,{item:!0,children:(0,h.jsx)(la.A,{variant:"h3",children:"Lead Submissions"})}),(0,h.jsx)(ra.A,{item:!0,children:(0,h.jsx)(ia.A,{pr:2,display:"flex",alignItems:"center",children:(0,h.jsx)(B,{name:"gingerLauncher"})})})]}),(0,h.jsx)(ia.A,{className:t.tabsContainer,children:(0,h.jsxs)(ua.A,{value:m,onChange:this.handleTabChange,indicatorColor:"primary",textColor:"primary",children:[(0,h.jsx)(ma.A,{label:"All Leads",value:"all"}),(0,h.jsx)(ma.A,{label:"Lead Form Submissions",value:"form"}),(0,h.jsx)(ma.A,{label:"CTWA Leads",value:"ctwa"})]})}),(0,h.jsxs)(ia.A,{className:t.innerContainer,children:[(0,h.jsx)(Aa.A,{severity:"info",className:t.alert,style:{marginBottom:16},children:"all"===m?"This tab shows all unique leads from both Lead Form Submissions and CTWA ads. Each lead appears only once, regardless of how many times they interacted.":"form"===m?"This tab shows leads created from Lead Form submissions. Each lead displays which form it was submitted through.":"This tab shows leads created from Click-to-WhatsApp (CTWA) ads. Each lead displays which CTWA ad they interacted with."}),(0,h.jsx)(km,{activeTab:m,classes:t,forms:u,totalLeads:l}),(0,h.jsx)(jm,{activeTab:m,ads:T,classes:t,endDate:this.props.endDate,forms:u,handleAdFilterChange:this.handleAdFilterChange,handleDateRangeChange:this.handleDateRangeChange,handleFilterChange:this.handleFilterChange,handleSearchChange:this.handleSearchChange,search:d,selectedAdId:this.props.selectedAdId,selectedFormId:c,startDate:this.props.startDate}),(0,h.jsx)(Rm,{activeTab:m,assistantId:this.props.assistantId,classes:t,exportToCSVServer:this.exportToCSVServer,fetchLeads:this.fetchLeads,fetchStats:this.fetchStats,handleBroadcast:this.handleBroadcast,handleSyncLeads:this.handleSyncLeads,isExporting:I,isSyncing:L,leads:n,page:i,pageId:this.props.pageId,selectedCount:x}),o&&(0,h.jsx)(Aa.A,{severity:"error",className:t.alert,children:o}),(0,h.jsx)(Lm,{parentLoading:a,activeTab:m,ads:T,agent:this.props.agent,classes:t,currentTableHeaders:R,forms:u,getCurrentLoading:this.getCurrentLoading,handlePageChange:this.handlePageChange,handleRowsPerPageChange:this.handleRowsPerPageChange,handleSelectAll:this.handleSelectAll,handleSelectLead:this.handleSelectLead,handleViewLead:this.handleViewLead,leads:n,page:i,rowsPerPage:r,selectAll:b,selected:g,setState:function(){return e.setState(...arguments)},totalLeads:l,unSelected:y}),(0,h.jsx)(Nm,{activeTab:m,ads:T,classes:t,detailDialogOpen:N,handleCloseLead:this.handleCloseLead,handleNextLead:this.handleNextLead,handlePrevLead:this.handlePrevLead,leads:n,selectedLead:D,selectedLeadIndex:w}),(0,h.jsx)(wm,{classes:t,error:o,fetchHistoricalDialogOpen:j,fetchHistoricalEndDate:S,fetchHistoricalFormId:C,fetchHistoricalResult:v,fetchHistoricalStartDate:_,fetchingHistorical:E,forms:u,handleCloseFetchHistoricalDialog:this.handleCloseFetchHistoricalDialog,handleFetchHistoricalLeads:this.handleFetchHistoricalLeads,leads:n,updateLeadsFilters:this.props.updateLeadsFilters}),(0,h.jsx)(Dm,{activeTab:m,broadcastDialogOpen:k,endDate:this.props.endDate,handleCloseBroadcastDialog:this.handleCloseBroadcastDialog,search:d,selectAll:b,selected:g,selectedAdId:this.props.selectedAdId,selectedFormId:c,selectedOptNo:f,
1startDate:this.props.startDate,totalLeads:l,unSelected:y,unSelectedOptNo:A})]})]})}}const Pm={fetchLeadSubmissions:_n.cq,fetchLeadForms:_n.s$,fetchAdsList:_n.Tu,fetchHistoricalLeads:_n._r,exportLeadsToCSV:_n.XF,fetchOptedOutCount:_n.az,fetchLeadFormDetails:_n.nK,updateLeadsFilters:_n.UW,updateLeadsPagination:_n.TC,updateLeadsSelection:_n.F5,clearLeadsSelection:_n.Dz,setLeadsActiveTab:_n.Br},Mm=(0,i.connect)((e=>({totalLeads:e.ads.leads.total,leads:e.ads.leads.leads,forms:e.ads.leads.forms,ads:e.ads.leads.ads,leadsAds:e.ads.leads.leadsAds,ctwaAds:e.ads.leads.ctwaAds,loading:e.ads.leads.loading,ctwaLoading:e.ads.leads.ctwaLoading,statsLoading:e.ads.leads.statsLoading,fetchingHistorical:e.ads.leads.fetchingHistorical,isExporting:e.ads.leads.isExporting,error:e.ads.leads.error,page:e.ads.leads.page,rowsPerPage:e.ads.leads.rowsPerPage,total:e.ads.leads.total,search:e.ads.leads.search,selectedFormId:e.ads.leads.selectedFormId,selectedAdId:e.ads.leads.selectedAdId,selectedAdIdCTWA:e.ads.leads.selectedAdIdCTWA,startDate:e.ads.leads.startDate,endDate:e.ads.leads.endDate,stats:e.ads.leads.stats,selected:e.ads.leads.selected,selectAll:e.ads.leads.selectAll,unSelected:e.ads.leads.unSelected,selectedCount:e.ads.leads.selectedCount,selectedOptNo:e.ads.leads.selectedOptNo,unSelectedOptNo:e.ads.leads.unSelectedOptNo,activeTab:e.ads.leads.activeTab,fetchHistoricalFormId:e.ads.leads.fetchHistoricalFormId,fetchHistoricalStartDate:e.ads.leads.fetchHistoricalStartDate,fetchHistoricalEndDate:e.ads.leads.fetchHistoricalEndDate,fetchHistoricalResult:e.ads.leads.fetchHistoricalResult,agent:e.login.user})),Pm)(Om),Um=(0,r.withRouter)((0,Am.A)((e=>({pageRoot:{height:"100%",width:"100%",background:"rgb(247, 247, 247)",boxSizing:"border-box",overflowX:"hidden",position:"relative"},pageTitleContainer:{position:"sticky",top:0,zIndex:100,background:"#fff",boxShadow:"0 0 11px rgb(230 230 230)",minHeight:60,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 24px",boxSizing:"border-box",[e.breakpoints.down("sm")]:{padding:"0 16px"}},fullWidth:{width:"100%",background:"white"},innerContainer:{padding:"24px 40px",width:"100%",boxSizing:"border-box",[e.breakpoints.down("md")]:{padding:"20px 24px"},[e.breakpoints.down("sm")]:{padding:"16px"}},tabsContainer:{background:"white",borderBottom:"1px solid #e0e0e0","& [class*=MuiTabs-root]":{minHeight:48},"& [class*=MuiTab-root]":{textTransform:"none",fontSize:"14px",fontWeight:500,minHeight:48,padding:"12px 24px"}},statsContainer:{marginBottom:24,display:"flex",gap:20,flexWrap:"nowrap",width:"100%",[e.breakpoints.down("sm")]:{flexDirection:"column",gap:16}},statCard:{padding:"20px 24px",textAlign:"center",borderRadius:8,flex:1,boxShadow:"0 1px 3px rgba(0,0,0,0.08)",minHeight:80,display:"flex",flexDirection:"column",justifyContent:"center",background:"white"},filterContainer:{padding:"16px 20px",marginBottom:24,borderRadius:8,boxShadow:"0 1px 3px rgba(0,0,0,0.08)",background:"white",[e.breakpoints.down("sm")]:{padding:"12px 16px"}},toolbarRow:{display:"flex",alignItems:"center",justifyContent:"flex-end",marginBottom:16,width:"100%","& > div":{gap:"12px"}},alert:{marginBottom:16,borderRadius:8},tableContainer:{width:"100%",overflow:"hidden",backgroundColor:"white",borderRadius:"8px"},scrollContainer:{overflowX:"auto",overflowY:"auto",maxHeight:"calc(100vh - 350px)",minHeight:400,"&::-webkit-scrollbar":{height:3,width:3},"&::-webkit-scrollbar-track":{backgroundColor:"#f1f1f1",borderRadius:3},"&::-webkit-scrollbar-thumb":{backgroundColor:"#c1c1c1",borderRadius:3,"&:hover":{backgroundColor:"#a8a8a8"}}},table:{minWidth:1200},stickyHeader:{backgroundColor:"white",position:"sticky",height:"52px",top:0,zIndex:12,"& th":{position:"sticky",top:0,fontWeight:600,fontSize:"12px",color:e.palette.text.secondary,borderBottom:`1px solid ${e.palette.divider}`,backgroundColor:"white"}},tableRow:{"&:hover":{backgroundColor:"#f5f5f5"}},tableRoot:{border:"1px solid #e0e0e0",borderRadius:8,overflowX:"auto",overflowY:"auto",boxSizing:"border-box",position:"relative",background:"white",cursor:"pointer",paddingBottom:"80px","& table":{borderCollapse:"collapse",borderSpacing:0,width:"100%",cursor:"pointer"}},row:{background:"white",display:"flex"},alterRow:{background:"#FAFAFA"},onHoverEffect:{transition:"0.2s","&:hover":{background:"#EBF5F3"}},topbar:{background:"#FAFAFA",position:"sticky",top:0,zIndex:100,borderBottom:"1px solid #e0e0e0"},column:{fontWeight:"normal",height:"52px",display:"flex",alignItems:"center",textAlign:"left",padding:"12px 16px",boxSizing:"border-box"}
1,dataColumn:{width:"250px","& p":{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}},typeColumn:{width:"100px","& p":{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}},checkboxColumn:{width:"56px",padding:"12px"},fieldRow:{padding:"12px 0",borderBottom:"1px solid #eee","&:last-child":{borderBottom:"none"}},fieldLabel:{fontWeight:500,color:"#666",textTransform:"capitalize",marginBottom:4},TextFieldRoot:{width:"100%",padding:"2px",background:"rgb(240,240,240)"},inputPadding:{padding:"12px 10px"},searchInputPadding:{padding:"12px 10px 12px 8px"},fixedBottomContainer:{zIndex:15,marginTop:"20px",position:"fixed",height:"60px",borderTop:"1px solid lightgrey",background:"white",bottom:"0",left:70,right:"0",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",[e.breakpoints.down("sm")]:{left:"0px",height:"50px"}}})))(Mm)),Fm=(0,o.withStyles)((e=>({root:{width:"100%",height:"100%",background:"rgb(247, 247, 247)",boxSizing:"border-box",overflowX:"hidden",position:"relative"},overlay:{alignItems:"center",background:"#fff",display:"flex",height:"100%",justifyContent:"center",opacity:"0.6",width:"100%",position:"absolute",top:0,left:0,zIndex:20},higherzIndex:{zIndex:21},message:{cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",justifyContent:"center",width:"100%",[e.breakpoints.down("sm")]:{flexDirection:"column",gap:"16px",textAlign:"center"}}})))((e=>{let{classes:t}=e;const a=(0,o.useTheme)(),s=(0,o.useMediaQuery)(a.breakpoints.down("sm")),l=(0,r.useHistory)(),c=(0,i.useDispatch)(),p=(0,i.useSelector)((e=>e.assistantDetails.data)),u=(0,i.useSelector)((e=>e.ads?.pageDetails)),[m,g]=(0,n.useState)(null),[b,y]=(0,n.useState)(!0),x=(0,n.useCallback)((async()=>{if(p?.assistantId)try{y(!0);const{isValid:e,pageId:t}=await c((0,M.cg)(p.assistantId));e&&t&&g(t)}catch(e){console.error("Error fetching meta ad setup:",e)}finally{y(!1)}}),[p?.assistantId]);return(0,n.useEffect)((()=>{u?.pageId?(g(u.pageId),y(!1)):p?.selectedMetaPageId?(g(p.selectedMetaPageId),y(!1)):x()}),[u?.pageId,p?.selectedMetaPageId,x]),p?.fbConnected?(0,h.jsx)("div",{className:t.root,children:(0,h.jsx)(Um,{assistantId:p?.assistantId,pageId:m,isLoading:b})}):(0,h.jsxs)("div",{className:t.root,children:[(0,h.jsx)("div",{className:t.overlay}),(0,h.jsx)(o.Box,{display:"flex",alignItems:"center",justifyContent:"center",className:t.higherzIndex,style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"100%",padding:s?"16px":"0"},children:(0,h.jsx)("div",{onClick:()=>l.push(Xe(p?.assistantId)+"/setup"),style:{cursor:"pointer"},children:(0,h.jsxs)(o.Typography,{variant:s?"h5":"h4",color:"primary",align:"center",className:t.message,children:["Connect and Setup Meta Ad Account to view leads!",(0,h.jsx)(o.IconButton,{children:(0,h.jsx)(d.ArrowForward,{})})]})})})]})}));var Wm=a(33615),zm=a(22488),Gm=a(42038),Hm=a(69440),Vm=a(65936),Ym=a(39608),Zm=a(42561);const Km=(0,_e.makeStyles)((e=>({optionRow:{display:"flex",alignItems:"center",marginBottom:e.spacing(1),"&:last-child":{marginBottom:0}},optionRowClickable:{cursor:"pointer",borderRadius:6,margin:e.spacing(0,-1),padding:e.spacing(.5,1),transition:"background-color .15s ease","&:hover":{backgroundColor:"#EBF5F3"},"&:hover $optionLabel":{color:e.palette.primary.main}},optionLabel:{width:140,flexShrink:0,fontSize:13,color:e.palette.text.primary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",paddingRight:e.spacing(1.5)},barTrack:{flex:1,height:16,borderRadius:4,backgroundColor:"#F0F0F0",overflow:"hidden"},barFill:{height:"100%",borderRadius:4,backgroundColor:e.palette.primary.main,minWidth:2,transition:"width 0.4s ease"},optionMeta:{width:92,flexShrink:0,textAlign:"right",fontSize:12,color:e.palette.text.secondary,whiteSpace:"nowrap"},optionMetaCount:{fontWeight:600,color:e.palette.text.primary}}))),Jm=e=>{let{options:t=[],answered:a=0,onSelectOption:n}=e;const s=Km(),o=Math.max(a,...t.map((e=>e.count)),1);return(0,h.jsx)(ia.A,{children:t.map((e=>{const t=!!n&&(e.count||0)>0,i=(0,h.jsxs)(ia.A,{className:`${s.optionRow} ${t?s.optionRowClickable:""}`,onClick:t?()=>n(e.label):void 0,children:[(0,h.jsx)(la.A,{className:s.optionLabel,title:e.label,children:e.label}),(0,h.jsx)(ia.A,{className:s.barTrack,children:(0,h.jsx)(ia.A,{className:s.barFill,style:{width:e.count/o*100+"%"}})}),(0,h.jsxs)(la.A,{className:s.optionMeta,children:[(0,h.jsx)("span",{className:s.optionMetaCount,children:e.count})," ","(",(r=e.count,l=a,l>0?Math.round(r/l*100):0),"%)"]})]},e.label);var r,l;return t?(0,h.jsx)(ga.Ay,{title:"View these responses",placement:"top-start",enterDelay:300,children:i},e.label):i}))})};var $m=a(36936),qm=a(71158),Xm=a(11760),Qm=a(19008),eh=a(61466),th=a(47201),ah=a(17098),nh=a(98874),sh=a(85836),oh=a(83609);const ih={choice:["is"],text:["contains","is"]},rh=(0,_e.makeStyles)((e=>
1({filterGroup:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:6,minHeight:32},filterChip:{backgroundColor:"#fff",border:"1px solid #E5E7EB",borderRadius:6,height:30,fontSize:13,maxWidth:320,"&:hover, &:focus":{backgroundColor:"#fff"},'& .MuiChip-deleteIcon, & [class*="MuiChip-deleteIcon-"]':{fontSize:16,color:"#9CA3AF","&:hover":{color:"#6B7280"}}},filterChipEditing:{backgroundColor:"#fff",border:`1.5px solid ${e.palette.primary.main}`,borderRadius:6,height:30,fontSize:13,maxWidth:320,"&:hover, &:focus":{backgroundColor:"#fff"},'& .MuiChip-deleteIcon, & [class*="MuiChip-deleteIcon-"]':{fontSize:16,color:"#9CA3AF","&:hover":{color:"#6B7280"}}},connector:{fontWeight:600,fontSize:11,color:e.palette.primary.main,cursor:"pointer",padding:"2px 6px",height:22,display:"inline-flex",alignItems:"center",borderRadius:4,"&:hover":{backgroundColor:e.palette.primary.light}},connectorPopoverItem:{display:"flex",alignItems:"center",padding:"6px 16px",cursor:"pointer",fontSize:13,color:"#374151",minWidth:100,"&:hover":{backgroundColor:"#F3F4F6"}},connectorPopoverItemActive:{display:"flex",alignItems:"center",padding:"6px 16px",cursor:"pointer",fontSize:13,color:e.palette.primary.main,fontWeight:500,minWidth:100,backgroundColor:e.palette.primary.light,"&:hover":{backgroundColor:e.palette.primary.light}},actionsRow:{display:"flex",alignItems:"center",gap:12,marginTop:10,"&:first-child":{marginTop:0}},actionLink:{fontSize:13,textTransform:"none",color:"#6B7280",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",borderRadius:4,background:"none",border:"none",whiteSpace:"nowrap",fontFamily:"inherit","&:hover":{color:e.palette.primary.main,backgroundColor:e.palette.primary.light}},popoverPaper:{borderRadius:8,boxShadow:"0 4px 20px rgba(0,0,0,0.12)",maxHeight:400,minWidth:240,paddingTop:8},popoverSearch:{padding:"8px 12px"},popoverGroupLabel:{fontSize:11,fontWeight:600,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:.8,padding:"8px 16px 4px"},popoverItem:{fontSize:13,padding:"6px 16px",gap:8,'& .MuiListItemIcon-root, & [class*="MuiListItemIcon-root-"]':{minWidth:28}},editPopoverHeader:{fontSize:12,fontWeight:600,color:"#6B7280",padding:"12px 16px 8px"},operatorItem:{display:"flex",alignItems:"center",padding:"6px 16px",cursor:"pointer",fontSize:13,color:"#374151","&:hover":{backgroundColor:"#F3F4F6"}},operatorItemActive:{display:"flex",alignItems:"center",padding:"6px 16px",cursor:"pointer",fontSize:13,color:e.palette.primary.main,fontWeight:500,backgroundColor:e.palette.primary.light,"&:hover":{backgroundColor:e.palette.primary.light}},editValueSection:{padding:"8px 16px 12px"}}))),lh=e=>{let{questions:t=[],value:a=[],onChange:o}=e;const i=rh(),r=(0,_e.useTheme)(),[l,d]=(0,n.useState)(a),[c,p]=(0,n.useState)(!1);(0,n.useEffect)((()=>{d(a),p(!1)}),[a]);const[u,m]=(0,n.useState)(null),[g,b]=(0,n.useState)(""),[y,x]=(0,n.useState)(null),[f,A]=(0,n.useState)(null),[I,C]=(0,n.useState)(null),[_,S]=(0,n.useState)(null),v=new Set(l.map((e=>e.key))),E=t.filter((e=>!v.has(e.key)&&e.label.toLowerCase().includes(g.toLowerCase()))),T=E.filter((e=>"choice"===e.type)),D=E.filter((e=>"text"===e.type)),w=e=>{const t={key:e.key,question:e.label,type:e.type,operator:ih[e.type][0],condition:"and",values:[]},a=[...l,t];d(a),p(!0),m(null),b(""),setTimeout((()=>{const e=document.querySelector(`[data-response-filter-chip="${a.length-1}"]`);e&&(A(a.length-1),x(e))}),50)},N=(e,t)=>{d((a=>a.map(((a,n)=>n===e?{...a,...t}:a)))),p(!0)},j=()=>{x(null),A(null)},k=e=>{const t=e.question.length>28?`${e.question.slice(0,28).trim()}…`:e.question,a=(e.values||[]).filter((e=>""!==String(e).trim()));return a.length?1===a.length?`${t} ${e.operator} ${a[0]}`:`${t} ${e.operator} ${a[0]} +${a.length-1}`:`${t} ${e.operator} ...`},L=null!==f?l[f]:null,R=L?(B=L.key,t.find((e=>e.key===B))):null;var B;return(0,h.jsxs)(ia.A,{children:[l.length>0&&(0,h.jsx)(ia.A,{className:i.filterGroup,children:l.map(((e,t)=>(0,h.jsxs)(s().Fragment,{children:[(0,h.jsx)(Wm.A,{"data-response-filter-chip":t,className:f===t?i.filterChipEditing:i.filterChip,label:k(e),onDelete:()=>(e=>{d((t=>t.filter(((t,a)=>a!==e)))),p(!0),f===e&&(x(null),A(null))})(t),onClick:e=>{A(t),x(e.currentTarget)},icon:"choice"===e.type?(0,h.jsx)(ah.A,{style:{fontSize:16,color:r.palette.primary.main}}):(0,h.jsx)(nh.A,{style:{fontSize:16,color:r.palette.primary.main}})}),t<l.length-1&&(0,h.jsx)(ia.A,{className:i.connector,onClick:e=>{S(t),C(e.currentTarget)},children:"or"===e.condition?"or":"and"})]},`${e.key}-${t}`)))}),t.length>v.size&&(0,h.jsx)(ia.A,{className:i.actionsRow,children:(0,h.jsxs)(ia.A,{component:"span",className:i.actionLink,onClick:e=>m(e.currentTarget),children:[(0,h.jsx)(th.A,{style:{fontSize:15}}
1),"Add filter"]})}),(l.length>0||c)&&(0,h.jsxs)(ia.A,{className:i.actionsRow,children:[(0,h.jsx)(da.A,{size:"small",disableElevation:!0,variant:"contained",disabled:!c,onClick:()=>{x(null),A(null),o&&o(l),p(!1)},style:{backgroundColor:c?r.palette.primary.main:"#D1D5DB",color:"#fff",textTransform:"none",fontSize:12,borderRadius:6,padding:"3px 14px",height:28,minWidth:0},children:"Apply Filters"}),(0,h.jsx)(ia.A,{component:"span",className:i.actionLink,onClick:()=>{d([]),x(null),A(null),p(!1),o&&o([])},style:{color:"#EF4444"},children:"Discard"})]}),(0,h.jsxs)(Xm.Ay,{open:Boolean(u),anchorEl:u,onClose:()=>{m(null),b("")},anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{className:i.popoverPaper},children:[t.length>6&&(0,h.jsx)(ia.A,{className:i.popoverSearch,children:(0,h.jsx)(ca.A,{fullWidth:!0,autoFocus:!0,variant:"standard",placeholder:"Search questions...",value:g,onChange:e=>b(e.target.value),InputProps:{style:{fontSize:13}}})}),T.length>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(la.A,{className:i.popoverGroupLabel,children:"Choice questions"}),(0,h.jsx)(Qm.A,{dense:!0,children:T.map((e=>(0,h.jsxs)(kn.A,{className:i.popoverItem,onClick:()=>w(e),children:[(0,h.jsx)(eh.A,{children:(0,h.jsx)(ah.A,{style:{fontSize:18,color:"#6B7280"}})}),(0,h.jsx)(Ln.A,{primary:e.label,primaryTypographyProps:{style:{fontSize:13}}})]},e.key)))})]}),D.length>0&&(0,h.jsxs)(h.Fragment,{children:[T.length>0&&(0,h.jsx)(Sm.A,{}),(0,h.jsx)(la.A,{className:i.popoverGroupLabel,children:"Input questions"}),(0,h.jsx)(Qm.A,{dense:!0,children:D.map((e=>(0,h.jsxs)(kn.A,{className:i.popoverItem,onClick:()=>w(e),children:[(0,h.jsx)(eh.A,{children:(0,h.jsx)(nh.A,{style:{fontSize:18,color:"#6B7280"}})}),(0,h.jsx)(Ln.A,{primary:e.label,primaryTypographyProps:{style:{fontSize:13}}})]},e.key)))})]}),0===T.length&&0===D.length&&(0,h.jsx)(la.A,{style:{fontSize:13,color:"#9CA3AF",padding:"12px 16px"},children:"No matching questions"})]}),(0,h.jsx)(Xm.Ay,{open:Boolean(I)&&null!==_,anchorEl:I,onClose:()=>{C(null),S(null)},anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},PaperProps:{style:{borderRadius:8,boxShadow:"0 4px 16px rgba(0,0,0,0.12)",padding:"4px 0"}},children:null!==_&&["and","or"].map((e=>{const t=("or"===l[_]?.condition?"or":"and")===e;return(0,h.jsxs)(ia.A,{className:t?i.connectorPopoverItemActive:i.connectorPopoverItem,onClick:()=>{return t=_,a=e,d((e=>e.map(((e,n)=>n===t?{...e,condition:a}:e)))),p(!0),C(null),void S(null);var t,a},children:[t?(0,h.jsx)(sh.A,{style:{fontSize:16,color:r.palette.primary.main,marginRight:8}}):(0,h.jsx)(oh.A,{style:{fontSize:16,color:"#D1D5DB",marginRight:8}}),(0,h.jsx)("span",{children:e})]},e)}))}),(0,h.jsx)(Xm.Ay,{open:Boolean(y)&&null!==f,anchorEl:y,onClose:j,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"}
1,PaperProps:{style:{borderRadius:8,minWidth:280,boxShadow:"0 4px 20px rgba(0,0,0,0.12)"}},children:L&&(0,h.jsxs)(ia.A,{children:[(0,h.jsx)(la.A,{className:i.editPopoverHeader,children:L.question}),(0,h.jsx)(Sm.A,{}),(ih[L.type]||[]).length>1&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(ia.A,{style:{padding:"4px 0"},children:ih[L.type].map((e=>{const t=L.operator===e;return(0,h.jsxs)(ia.A,{className:t?i.operatorItemActive:i.operatorItem,onClick:()=>N(f,{operator:e}),children:[t?(0,h.jsx)(sh.A,{style:{fontSize:16,color:r.palette.primary.main,marginRight:8}}):(0,h.jsx)(oh.A,{style:{fontSize:16,color:"#D1D5DB",marginRight:8}}),(0,h.jsx)("span",{children:e})]},e)}))}),(0,h.jsx)(Sm.A,{})]}),(0,h.jsxs)(ia.A,{className:i.editValueSection,children:["choice"===L.type?(0,h.jsx)(wd.Ay,{multiple:!0,disableCloseOnSelect:!0,size:"small",options:R?.options||[],value:L.values,onChange:(e,t)=>N(f,{values:t}),ListboxProps:{style:{maxHeight:200,overflowX:"hidden"}},renderInput:e=>(0,h.jsx)(ca.A,{...e,variant:"standard",placeholder:L.values.length?"":"Select answers...",InputProps:{...e.InputProps,style:{...e.InputProps?.style,fontSize:13}}})}):(0,h.jsx)(ca.A,{fullWidth:!0,autoFocus:!0,variant:"standard",placeholder:"Enter value...",value:L.values[0]||"",onChange:e=>N(f,{values:e.target.value?[e.target.value]:[]}),onKeyDown:e=>{"Enter"===e.key&&j()},InputProps:{style:{fontSize:13}}}),(0,h.jsx)(ia.A,{style:{display:"flex",justifyContent:"flex-end",marginTop:10},children:(0,h.jsx)(da.A,{size:"small",variant:"contained",disableElevation:!0,onClick:j,style:{backgroundColor:r.palette.primary.main,color:"#fff",textTransform:"none",fontSize:12,borderRadius:6,padding:"3px 14px",height:28},children:"Done"})})]})]})})]})},dh=(0,_e.makeStyles)((e=>({countRow:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8,flexWrap:"wrap"},searchField:{width:300,padding:"2px 6px 2px 15px",background:"#f0f0f0",borderRadius:8,"&:focus-within":{background:"white"},[e.breakpoints.down("sm")]:{width:"100%"}},searchInput:{fontSize:14},searchIconButton:{padding:6,background:"#d6ede9","& svg":{fontSize:15},"&:hover":{background:"#d6ede9"}},filterToggle:{textTransform:"none",fontWeight:600},filterPanel:{background:"#F4F4F5",borderRadius:8,padding:e.spacing(1.5,2),marginBottom:8},countGroup:{display:"flex",alignItems:"center",gap:12,marginLeft:"auto"},count:{fontSize:13,color:e.palette.text.secondary},checkboxCell:{width:56},listRoot:{border:"1px solid lightgrey",borderRadius:10,background:"white",overflow:"hidden"},scrollContainer:{width:"100%",overflowX:"auto",overflowY:"hidden"},table:{width:"100%",borderCollapse:"collapse",borderSpacing:0},headRow:{"& th":{textAlign:"left",height:50,boxSizing:"border-box",color:e.palette.text.secondary,backgroundColor:"rgb(252,252,252)",padding:e.spacing(2),whiteSpace:"nowrap"}},tr:{cursor:"pointer",transition:"0.3s",background:"white","&:hover":{backgroundColor:"#EBF5F3"},"& > td":{padding:e.spacing(2),verticalAlign:"middle",height:50,boxSizing:"border-box",fontSize:14,color:e.palette.text.primary}},striped:{background:"rgb(245,245,245)"},name:{fontSize:14,color:e.palette.text.primary},subtle:{fontSize:12,color:e.palette.text.secondary,marginTop:2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:220},phone:{fontSize:13,whiteSpace:"nowrap"},answer:{fontSize:13,maxWidth:240,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},unanswered:{color:e.palette.text.hint},time:{fontSize:12,color:e.palette.text.secondary,whiteSpace:"nowrap"},emptyState:{padding:"40px 24px",textAlign:"center",color:e.palette.text.secondary},footer:{position:"fixed",height:60,borderTop:"1px solid lightgrey",background:"white",bottom:0,left:70,right:0,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2,[e.breakpoints.down("sm")]:{left:0,height:50}},footerSpacer:{height:72}}))),ch=e=>{let{form:t,analytics:a,assistantId:s,reloadToken:o=0,syncReloadToken:i=0,actionsRef:r,onMeta:l,answerFilters:d=[],onAnswerFiltersChange:c}=e;const p=dh(),u=t?.formId,[m,g]=(0,n.useState)([]),[b,y]=(0,n.use
1State)(0),[x,f]=(0,n.useState)(0),[A,I]=(0,n.useState)(25),[C,_]=(0,n.useState)(""),[S,v]=(0,n.useState)(""),[E,T]=(0,n.useState)((()=>(d||[]).length>0)),[D,w]=(0,n.useState)(!1),[N,j]=(0,n.useState)(-1),[k,L]=(0,n.useState)(!1),[R,O]=(0,n.useState)(!1),[P,M]=(0,n.useState)({dailyTemplateLimit:null,consumedQuota:null});(0,n.useEffect)((()=>{if(!s)return;let e=!1;return(0,_n.QO)(s).then((t=>{!e&&t&&M({dailyTemplateLimit:t.dailyTemplateLimit,consumedQuota:t.consumedTemplateLimitQuota})})).catch((()=>{})),()=>{e=!0}}),[s]);const[U,F]=(0,n.useState)(!1),[W,z]=(0,n.useState)([]),[G,H]=(0,n.useState)([]),V=(0,n.useRef)(new Map),Y=e=>{const t=$a(e);return!!t&&(U?!G.includes(t):W.includes(t))},Z=U?Math.max(0,b-G.length):W.length,K=e=>e.map((e=>(e=>{const t=Ja(e);return t&&t.startsWith("+")?t.slice(1):t})(V.current.get(e)))).filter(Boolean),J=U?[]:K(W),$=U?K(G):[],q=m.length>0&&m.every(Y),X=!q&&m.some(Y),Q=async()=>{if(s&&u&&!k){L(!0);try{await(0,_n.tY)(s,{formId:u,answers:ne,search:S,hasSelection:U||W.length>0,selectAll:U,selectedNums:J,unselectedNums:$})}catch(e){}finally{L(!1)}}},ee=()=>{va("broadcastCampaign")&&0!==Z&&O(!0)};r&&(r.current={broadcast:ee,doExport:Q}),(0,n.useEffect)((()=>{l&&l({total:b,selectedCount:Z,isExporting:k})}),[l,b,Z,k]);const te=(0,n.useMemo)((()=>(t?.questions||[]).filter((e=>!en(e))).map((e=>({key:e.key,label:e.label||e.question||e.key})))),[t]),ae=(0,n.useMemo)((()=>(a?.questions||[]).filter((e=>!en(e))).map((e=>{const t=Array.isArray(e.options)&&e.options.length>0;return{key:e.key,label:e.label||e.question||e.key,type:t?"choice":"text",rawOptions:e.options||[],options:t?e.options.map((e=>String(null!=e.label?e.label:e.key))):[]}}))),[a]),ne=(0,n.useMemo)((()=>(d||[]).map((e=>{const t=(e.values||[]).filter((e=>""!==String(e).trim()));if(!e.key||!t.length)return null;const a="or"===e.condition?"or":"and";return"text"===e.type?{key:e.key,question:e.question,operator:"is"===e.operator?"is":"contains",condition:a,values:t.map(String)}:{key:e.key,question:e.question,condition:a,values:t.map(String)}})).filter(Boolean)),[d]),se=ne.length>0,oe=se||!!S;(0,n.useEffect)((()=>{const e=setTimeout((()=>{v((e=>{const t=C.trim();return t===e?e:(f(0),F(!1),z([]),H([]),t)}))}),500);return()=>clearTimeout(e)}),[C]);const ie=(0,n.useCallback)((async function(){let{silent:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(u){e||w(!0);try{const t=await Sn({assistantId:s,type:"form",formId:u,page:x+1,limit:A,answers:ne,search:S});if(t?.status){const e=t.data||[];e.forEach((e=>{const t=$a(e);t&&V.current.set(t,e)})),g(e),y(t.pagination?.total||0)}else e||(g([]),y(0))}catch(t){e||(g([]),y(0))}finally{e||w(!1)}}}),[s,u,x,A,o,ne,S]);(0,n.useEffect)((()=>{ie()}),[ie]);const re=(0,n.useRef)(ie);re.current=ie,(0,n.useEffect)((()=>{i&&re.current({silent:!0})}),[i]);const le=N>=0?m[N]:null;return(0,h.jsxs)(ia.A,{children:[(0,h.jsxs)(ia.A,{className:p.countRow,children:[(0,h.jsxs)(ia.A,{display:"flex",alignItems:"center",style:{gap:8},children:[(0,h.jsx)(ca.A,{classes:{root:p.searchField},placeholder:"Search name, phone or answers",value:C,onChange:e=>_(e.target.value),InputProps:{disableUnderline:!0,classes:{input:p.searchInput},endAdornment:(0,h.jsx)(pa.A,{position:"end",children:(0,h.jsx)(pn.A,{color:"primary",className:p.searchIconButton,children:(0,h.jsx)(Ia.A,{})})})}}),ae.length>0&&(0,h.jsx)($m.A,{color:"primary",variant:"dot",invisible:!se,children:(0,h.jsx)(da.A,{startIcon:(0,h.jsx)(qm.A,{}),color:"primary",className:p.filterToggle,onClick:()=>T((e=>!e)),children:"Filter"})})]}),(0,h.jsxs)(ia.A,{className:p.countGroup,children:[Z>0&&(0,h.jsxs)(la.A,{className:p.count,children:[Z.toLocaleString()," selected"]}),oe&&!D&&(0,h.jsxs)(la.A,{className:p.count,children:[b.toLocaleString()," matching response",1===b?"":"s"]})]})]}),ae.length>0&&(0,h.jsx)(Hm.A,{in:E,timeout:250,unmountOnExit:!0,children:(0,h.jsx)(ia.A,{className:p.filterPanel,children:(0,h.jsx)(lh,{questions:ae,value:d,onChange:e=>{c&&(c(e),f(0),F(!1),z([]),H([]))}})})}),(0,h.jsx)(ia.A,{className:p.listRoot,children:D||0!==m.length?(0,h.jsx)(ia.A,{className:p.scrollContainer,children:(0,h.jsxs)("table",{className:p.table,children:[(0,h.jsx)("thead",{children:(0,h.jsxs)("tr",{className:p.headRow,children:[(0,h.jsx)("th",{className:p.checkboxCell,children:(0,h.jsx)(ha.A,{size:"small",color:"primary",checked:q,indeterminate:X,disabled:0===m.length,onChange:()=>{var e;X?(F(!1),z([]),H([])):(e=!q,z([]),H([]),F(e))}})}),(0,h.jsx)("th",{style:{minWidth:200},children:(0,h.jsx)(la.A,{variant:"h5",color:"primary",children:"Name"})}),(0,h.jsx)("th",{style:{minWidth:150},children:(0,h.jsx)(la.A,{variant:"h5",color:"primary",children:"Phone Number"})}),te.map(((e,t)=>(0,h.jsx)("th",{style:{minWidth:180},children:(0,h.jsx)(la.A,{variant:"h5",color:"primary",children:e.label})},e.key||t))),(0,h.jsx)("th",{style:{minWidth:170},children:(0,h.jsx)(la.A,{variant:"h5",color:"primary",children:"Created At"})})]})}),(0,h.jsxs)("tbody",{children:[D&&Array.from({length:Math.min(b>0?Math.max(1,Math.min(A,b-x*A)):A,25)}).map(((e,t)=>(0,h.jsxs)("tr",{className:t%2==0?`${p.tr} ${p.striped}`:p.tr,children:[(0,h.jsx)("td",{className:p.checkboxCell,children:(0,h.jsx)(zm.A,{variant:"rect",width:16,height:16})}),(0,h.jsx)("td",{children:(0,h.jsx)(zm.A,{width:"65%"})}),(0,h.jsx)("td",{children:(0,h.jsx)(zm.A,{width:"55%"})}),te.map(((e,t)=>(0,h.jsx)("td",{children:(0,h.jsx)(zm.A,{width:"70%"})},e.key||t))),(0,h.jsx)("td",{children:(0,h.jsx)(zm.A,{width:"80%"})})]},`skeleton-${t}`))),!D&&m.map(((e,a)=>{const n=((e,t)=>{const a=rn(e,t),n={};return[...a.contact,...a.qualifying,...a.additional].forEach((e=>{null!=e.key&&(n[e.key]=e)})),n})(t,e),s=Ja(e),o=Xa(e);return(0,h.jsxs)("tr",{className:a%2==0?`${p.tr} ${p.striped}`:p.tr,onClick:()=>j(a),children:[(0,h.jsx)("td",{className:p.checkboxCell,onClick:e=>e.stopPropagation(),children:(0,h.jsx)(ha.A,{size:"small",color:"primary",checked:Y(e),onChange:t=>((e,t)=>{const a=$a(e);a&&(V.current.set(a,e),U?H((e=>t?e.filter((e=>e!==a)):e.includes(a)?e:[...e,a])):z((e=>t?e.includes(a)?e:[...e,a]:e.filter((e=>e!==a)))))})(e,t.target.checked)})}),(0,h.jsxs)("td",{children:[(0,h.jsx)(la.A,{className:p.name,children:Ka(e)||"(Unknown)"}),e.email&&(0,h.jsx)(la.A,{className:p.subtle,children:e.email})]}),(0,h.jsx)("td",{children:(0,h.jsx)("span",{className:p.phone,children:s?qa(s):"—"})}),te.map(((e,t)=>{const a=n[e.key],s=a&&a.answered&&""!==a.value;return(0,h.jsx)("td",{children:(0,h.jsx)("span",{className:`${p.answer} ${s?"":p.unanswered}`,title:s?String(a.value):"",children:s?a.value:"—"})},e.key||t)})),(0,h.jsx)("td",{children:(0,h.jsx)("span",{className:p.time,children:o?ve()(o).format("MMM DD, YYYY HH:mm"):"—"})})]},e._id||e.leadgenId||a)}))]})]})}):(0,h.jsxs)(ia.A,{className:p.emptyState,children:[(0,h.jsx)(la.A,{variant:"body1",children:oe?"No responses match your search or filters":"No responses yet"}),(0,h.jsx)(la.A,{variant:"body2",style:{marginTop:4},children:oe?"Try a different search or remove some filter conditions.":"Submissions to this form will appear here."})]})}),b>0&&(0,h.jsx)(ia.A,{className:p.footerSpacer}),b>0&&(0,h.jsx)(ia.A,{className:p.footer,children:(0,h.jsx)(fa,{limit:A,page:x,total:b,loadPrev:()=>f((e=>Math.max(0,e-1))),loadNext:()=>f((e=>e+1)),setLimit:e=>{I(parseInt(e.target.value,10)),f(0)}})}),(0,h.jsx)(Ze,{open:!!le,onClose:()=>j(-1),title:"Lead detail",width:"600px",children:le&&(0,h.jsx)(wn,{lead:le,assistantId:s,index:N,total:m.length,onPrev:()=>j((e=>Math.max(0,e-1))),onNext:()=>j((e=>Math.min(m.length-1,e+1)))},le._id||le.leadgenId)}),(0,h.jsx)(ya.A,{open:R,onClose:()=>O(!1),"aria-labelledby":"form-broadcast-dialog",maxWidth:"md",fullWidth:!0,disableBackdropClick:!0,children:R&&(0,h.jsx)(B,{name:"broadcastCampaign",closeDialog:()=>O(!1),totalSelected:Z,selectAll:U,unSelected:$,selected:J,allFilters:void 0,optedCount:0,selectedOptNo:0,unSelectedOptNo:0,groupedContacts:[],scheduledCampaigns:[],dailyTemplateLimit:P.dailyTemplateLimit,consumedQuota:P.consumedQuota,leadAudienceCampaign:!0,leadSourceType:"form",leadSearch:S,leadStartDate:null,leadEndDate:null,leadAdId:"",leadFormId:u,leadAnswers:ne})})]})},ph=(0,_e.makeStyles)((e=>({backArrow:{marginLeft:e.spacing(-.5),marginRight:e.spacing(1),color:e.palette.text.primary,"&:hover":{color:e.palette.primary.main}},headRow:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:e.spacing(1)},title:{fontFamily:"Inter",fontSize:20,fontWeight:700,color:e.palette.text.primary},statusDot:{display:"inline-flex",alignItems:"center",fontSize:11,fontWeight:600,letterSpacing:.5,marginLeft:e.spacing(1.5)},dot:{width:8,height:8,borderRadius:"50%",marginRight:5},tabs:{marginBottom:e.spacing(2),'& [class*="MuiTab-root"]':{textTransform:"none",fontSize:14,fontWeight:500,minHeight:44,borderBottom:"2px s
1olid #f0f0f0"}},statRow:{display:"flex",gap:16,flexWrap:"wrap",marginBottom:e.spacing(2.5)},panel:{padding:e.spacing(2.5),borderRadius:12,border:"1px solid rgba(0,0,0,0.08)",background:"white",marginBottom:e.spacing(2.5)},panelHead:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:e.spacing(1.5)},panelTitle:{fontFamily:"Inter",fontSize:15,fontWeight:700,color:e.palette.text.primary},panelHint:{fontSize:12,color:e.palette.text.secondary},chartWrap:{width:"100%",marginTop:e.spacing(.5)},chartEmpty:{height:300,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,color:e.palette.text.secondary},sectionHead:{display:"flex",alignItems:"center",justifyContent:"space-between",margin:e.spacing(.5,0,1.5)},sectionTitle:{fontFamily:"Inter",fontSize:15,fontWeight:700,color:e.palette.text.primary},expandAll:{textTransform:"none",fontSize:12,color:e.palette.primary.main},qCard:{borderRadius:10,border:"1px solid #e6e6e6",background:"white",marginBottom:e.spacing(1.5),transition:"box-shadow .2s ease, border-color .2s ease",overflow:"hidden","&:hover":{boxShadow:"0 2px 10px rgba(0,0,0,0.07)",borderColor:"#d6d6d6"}},qConditional:{borderLeft:`3px solid ${e.palette.primary.light}`},qHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:e.spacing(2),padding:e.spacing(1.75,2),cursor:"pointer",userSelect:"none"},qHeaderLeft:{minWidth:0},qTitle:{fontFamily:"Inter",fontSize:14,fontWeight:600,color:e.palette.text.primary,display:"flex",alignItems:"center",gap:e.spacing(1),flexWrap:"wrap"},qMeta:{fontSize:12,color:e.palette.text.secondary,marginTop:3},typeChip:{height:20,fontSize:11,fontWeight:600,background:"#ebf5f3",color:"#0a474c",textTransform:"capitalize"},qHeaderRight:{display:"flex",alignItems:"center",gap:e.spacing(1.5),flexShrink:0},answered:{fontSize:12,fontWeight:600,color:e.palette.text.secondary,whiteSpace:"nowrap"},chevron:{transition:"transform .2s ease",color:e.palette.text.secondary},chevronOpen:{transform:"rotate(180deg)"},qBody:{padding:e.spacing(0,2,2),borderTop:"1px solid #f2f2f2",paddingTop:e.spacing(1.75)},sampleGrid:{display:"flex",flexWrap:"wrap",gap:8},sampleAnswer:{fontSize:13,color:e.palette.text.primary,background:"rgb(240,240,240)",borderRadius:8,padding:"6px 12px",maxWidth:320,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},pendingHint:{fontSize:12,color:e.palette.text.hint},kv:{display:"flex",justifyContent:"space-between",padding:e.spacing(1.25,0),borderBottom:"1px solid #F0F0F0","&:last-child":{borderBottom:"none"}},kvLabel:{fontSize:13,color:e.palette.text.secondary},kvValue:{fontSize:14,fontWeight:500,color:e.palette.text.primary},emptyState:{padding:e.spacing(4),textAlign:"center",color:e.palette.text.secondary}}))),uh=[{key:"overview",label:"Overview"},{key:"responses",label:"Responses"},{key:"automation",label:"Automation"}],mh=e=>{let{form:t,assistantId:a,onBack:s}=e;const o=ph(),i=(0,_e.useTheme)(),[r,l]=(0,n.useState)("overview"),[d,c]=(0,n.useState)({startDate:null,endDate:null,focusedInput:null}
1),[p,u]=(0,n.useState)(null),[m,g]=(0,n.useState)({}),[b,y]=(0,n.useState)(!1),[x,f]=(0,n.useState)(!1),[A,I]=(0,n.useState)(!1),[C,_]=(0,n.useState)(null),[S,v]=(0,n.useState)(0),[E,T]=(0,n.useState)(0),[D,w]=(0,n.useState)(null),N=(0,n.useRef)({}),[j,k]=(0,n.useState)({total:0,selectedCount:0,isExporting:!1}),[L,R]=(0,n.useState)([]),B=(0,n.useCallback)((async()=>{if(t?.formId){y(!0);try{const e=await((e,t,a)=>(0,_n.SS)(e,t,a))(t.formId,a);u(e?.data||null)}catch(e){u(null)}finally{f(!0),y(!1)}}}),[t?.formId,a]);(0,n.useEffect)((()=>{B()}),[B,E]);const O=p?.form||t,P=p?.analytics||null,M=P?.totals||null,U="ACTIVE"===O.status,F=O.questions||[],W=(0,n.useMemo)((()=>{const e=new Map;return(P?.questions||[]).forEach((t=>e.set(t.key,t))),e}),[P]),z=M?[{key:"sub",label:"Submissions",value:(M.submissions||0).toLocaleString(),icon:"description",color:"#9013FE"},{key:"uniq",label:"Unique leads",value:(M.uniqueLeads||0).toLocaleString(),icon:"groups",color:"#0a474c"},{key:"new",label:"New contacts",value:(M.newContacts||0).toLocaleString(),sub:`${(M.returningContacts||0).toLocaleString()} returning`,icon:"person_add",color:"#1769d4"},{key:"auto",label:"Automation sent",value:(M.automationSent||0).toLocaleString(),sub:`${(M.automationFailed||0).toLocaleString()} failed`,icon:"send",color:"#b07b00"}]:[],G=F.length>0&&F.every((e=>m[e.key])),H=(0,n.useMemo)((()=>P?.timeSeries||[]),[P]),V=(0,n.useMemo)((()=>{if(!H.length)return null;const e=H.map((e=>ve()(e.date)));return{min:ve().min(e).startOf("day"),max:ve().max(e).endOf("day")}}),[H]);(0,n.useEffect)((()=>{V&&!d.startDate&&c((e=>({...e,startDate:V.min,endDate:V.max})))}),[V,d.startDate]);const Y=(0,n.useMemo)((()=>{const{startDate:e,endDate:t}=d,a=H.filter((a=>{if(!e||!t)return!0;const n=ve()(a.date);return n.isSameOrAfter(e,"day")&&n.isSameOrBefore(t,"day")})),n=a.map((e=>({label:ve()(e.date).format("MMM DD"),submissions:e.count})));return 1===n.length?[{label:ve()(a[0].date).subtract(1,"day").format("MMM DD"),submissions:0},...n]:n}),[H,d]),Z=i.palette.primary.main,K=A||!!C,J=(0,n.useRef)(B);return J.current=B,(0,n.useEffect)((()=>{if(!C)return;let e=!1,t=0;const n=async()=>{t+=1;try{const t=await((e,t)=>(0,_n.y4)(e,t))(a,{syncBatchId:C});if(e)return;const n=t?.summary;if(v((e=>e+1)),n?.isComplete)return _(null),w(n.failed>0?{severity:"warning",message:"Lead sync finished with errors — some leads may be missing. Try syncing again."}:{severity:"success",message:"Lead sync completed. Responses are up to date."}),void J.current()}catch(e){}!e&&t>=60&&(_(null),w({severity:"info",message:"Lead sync is still running in the background. Refresh in a bit to see new responses."}))},s=setInterval(n,5e3);return n(),()=>{e=!0,clearInterval(s)}}),[C,a]),(0,h.jsxs)(ia.A,{children:[(0,h.jsxs)(ia.A,{className:o.headRow,children:[(0,h.jsxs)(ia.A,{display:"flex",alignItems:"center",children:[(0,h.jsx)(pn.A,{onClick:s,size:"small",className:o.backArrow,"aria-label":"Back to forms",children:(0,h.jsx)(Ym.A,{})}),(0,h.jsx)(la.A,{className:o.title,children:O.name}),(0,h.jsxs)("span",{className:o.statusDot,style:{color:U?"#4caf50":"#9e9e9e"},children:[(0,h.jsx)("span",{className:o.dot,style:{backgroundColor:U?"#4caf50":"#9e9e9e"}}),U?"ACTIVE":"ARCHIVED"]})]}),(0,h.jsxs)(ia.A,{display:"flex",alignItems:"center",style:{gap:8},children:[(0,h.jsx)(ga.Ay,{title:"Reload this form's overview and responses",children:(0,h.jsx)("span",{children:(0,h.jsx)(da.A,{variant:"text",size:"small",startIcon:b?(0,h.jsx)(ba.A,{size:14}):(0,h.jsx)(Tm.A,{}),onClick:()=>T((e=>e+1)),disabled:b,style:{textTransform:"none"},children:"Refresh"})})}),"responses"===r&&(0,h.jsxs)(h.Fragment,{children:[va("broadcastCampaign")&&(0,h.jsx)(ga.Ay,{title:0===j.selectedCount?"Select at least one response to broadcast":"",children:(0,h.jsx)("span",{children:(0,h.jsxs)(da.A,{variant:"contained",color:"primary",size:"small",startIcon:(0,h.jsx)(Sa.A,{style:{fontSize:16}}),disabled:0===j.selectedCount,onClick:()=>N.current.broadcast?.(),style:{textTransform:"none"},children:["Broadcast",j.selectedCount>0?` (${j.selectedCount})`:""]})})}),(0,h.jsx)(ga.Ay,{title:0===j.total?"No responses to export":"",children:(0,h.jsx)("span",{children:(0,h.jsx)(da.A,{variant:"outlined",size:"small",startIcon:j.isExporting?(0,h.jsx)(ba.A,{size:14}):(0,h.jsx)(_a.A,{style:{fontSize:16}}),disabled:0===j.total||j.isExporting,onClick:()=>N.current.doExport?.(),style:{textTransform:"none"},children:j.isExporting?"Exporting…":"Export CSV"})})})]}),(0,h.jsx)(ga.Ay,{title:O.pageId?"Fetch any leads missed by the webhook from Meta":"Connect a page to sync leads",children:(0,h.jsx)("span",{children:(0,h.jsx)(da.A,{variant:"outlined",size:"small",startIcon:K?(0,h.jsx)(ba.A,{size:14}):(0,h.jsx)(Ca.A,{}),onClick:async()=>{const e=O.pageId;if(a&&e&&O.formId&&!A&&!C){I(!0);try{const t=await(0,_n.kR)(a,e,O.formId);!1===t?.status?w({severity:"info",message:t?.message||"Nothing to sync"}):(t?.syncBatchId&&0!==t?.queuedForms&&_(t.syncBatchId),w({severity:"success",message:"Lead sync started. New responses will appear shortly."}),v((e=>e+1)))}catch(e){w({severity:"error",message:e?.response?.data?.message||"Failed to start lead sync"})}finally{I(!1)}}},disabled:K||!O.pageId,style:{textTransform:"none"},children:K?"Syncing…":"Sync from Meta"})})})]})]}),(0,h.jsx)(ua.A,{value:r,onChange:(e,t)=>
1l(t),indicatorColor:"primary",textColor:"primary",className:o.tabs,children:uh.map((e=>(0,h.jsx)(ma.A,{value:e.key,label:e.label},e.key)))}),K&&(0,h.jsx)(Aa.A,{severity:"info",icon:(0,h.jsx)(ba.A,{size:16}),style:{marginBottom:16,borderRadius:8},children:"Syncing leads from Meta — new responses will appear here automatically once the sync completes."}),"overview"===r&&!x&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(ia.A,{className:o.statRow,children:[0,1,2,3].map((e=>(0,h.jsx)(zm.A,{variant:"rect",height:84,style:{flex:"1 1 0",minWidth:150,borderRadius:12}},e)))}),(0,h.jsx)(zm.A,{variant:"rect",height:300,style:{borderRadius:12,marginBottom:20}}),(0,h.jsx)(ia.A,{className:o.sectionHead,children:(0,h.jsx)(la.A,{className:o.sectionTitle,children:"Questions & answers"})}),[0,1,2].map((e=>(0,h.jsx)(zm.A,{variant:"rect",height:56,style:{borderRadius:10,marginBottom:12}},e)))]}),"overview"===r&&x&&(0,h.jsxs)(h.Fragment,{children:[z.length>0&&(0,h.jsx)(ia.A,{className:o.statRow,children:z.map((e=>(0,h.jsx)(zn,{...e},e.key)))}),H.length>0&&(0,h.jsxs)(vm.A,{elevation:0,className:o.panel,children:[(0,h.jsxs)(ia.A,{className:o.panelHead,children:[(0,h.jsx)(la.A,{className:o.panelTitle,children:"Daily submissions"}),(0,h.jsx)(Ga,{startDate:d.startDate,endDate:d.endDate,focusedInput:d.focusedInput,onDatesChange:e=>{let{startDate:t,endDate:a}=e;return c((e=>({...e,startDate:t,endDate:a})))},onFocusChange:e=>c((t=>({...t,focusedInput:e}))),constraintStartDate:V?.min?.toDate()})]}),Y.length>0?(0,h.jsx)(ia.A,{className:o.chartWrap,children:(0,h.jsx)(yu.uf,{width:"100%",height:300,children:(0,h.jsxs)(yu.QF,{data:Y,margin:{top:10,right:16,left:-12,bottom:0},children:[(0,h.jsx)("defs",{children:(0,h.jsxs)("linearGradient",{id:"leadDailyFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,h.jsx)("stop",{offset:"0%",stopColor:Z,stopOpacity:.35}),(0,h.jsx)("stop",{offset:"95%",stopColor:Z,stopOpacity:0})]})}),(0,h.jsx)(yu.dC,{strokeDasharray:"3 3",vertical:!1,stroke:"#eeeeee"}),(0,h.jsx)(yu.WX,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#888"}}),(0,h.jsx)(yu.h8,{axisLine:!1,tickLine:!1,allowDecimals:!1,width:36,tick:{fontSize:12,fill:"#888"}}),(0,h.jsx)(yu.m_,{cursor:{stroke:Z,strokeOpacity:.2}}),(0,h.jsx)(yu.Gk,{type:"monotone",dataKey:"submissions",name:"Submissions",stroke:Z,strokeWidth:2,fill:"url(#leadDailyFill)",dot:Y.length<=2&&(e=>(0,h.jsx)("circle",{cx:e.cx,cy:e.cy,r:e.index===Y.length-1?4:0,fill:Z},`dot-${e.index}`)),isAnimationActive:!0})]})})}):(0,h.jsx)(ia.A,{className:o.chartEmpty,children:"No submissions in the selected range."})]}),(0,h.jsxs)(ia.A,{className:o.sectionHead,children:[(0,h.jsx)(la.A,{className:o.sectionTitle,children:"Questions & answers"}),F.length>0&&(0,h.jsx)(da.A,{size:"small",className:o.expandAll,onClick:()=>{if(G)g({});else{const e={};F.forEach((t=>{e[t.key]=!0})),g(e)}},children:G?"Expand all":"Collapse all"})]}),0===F.length?(0,h.jsx)(ia.A,{className:o.emptyState,children:"No questions stored for this form."}):F.map(((e,t)=>{const a=W.get(e.key),n=a&&"choice"===a.type||Array.isArray(e.options)&&e.options.length>0,s=!m[e.key];return(0,h.jsxs)(ia.A,{className:`${o.qCard} ${e.parentId?o.qConditional:""}`,children:[(0,h.jsxs)(ia.A,{className:o.qHeader,onClick:()=>{return t=e.key,g((e=>({...e,[t]:!e[t]})));var t},children:[(0,h.jsxs)(ia.A,{className:o.qHeaderLeft,children:[(0,h.jsxs)(la.A,{className:o.qTitle,children:[e.label||e.question||e.key,(0,h.jsx)(Wm.A,{size:"small",className:o.typeChip,label:(i=a?.type||e.type,String(i||"question").replace(/_/g," ").toLowerCase())}),e.parentId&&(0,h.jsx)(Wm.A,{size:"small",className:o.typeChip,label:"conditional"})]}),e.mappedParameter&&(0,h.jsxs)(la.A,{className:o.qMeta,children:["maps to ",e.mappedParameter]})]}),(0,h.jsxs)(ia.A,{className:o.qHeaderRight,children:[a&&(0,h.jsxs)("span",{className:o.answered,children:[(a.totalAnswered||0).toLocaleString()," answered"]}),(0,h.jsx)(Zm.A,{className:`${o.chevron} ${s?o.chevronOpen:""}`})]})]}),(0,h.jsx)(Hm.A,{in:s,timeout:"auto",unmountOnExit:!0,children:(0,h.jsx)(ia.A,{className:o.qBody,children:a&&n?(0,h.jsx)(Jm,{options:a.options||[],answered:a.totalAnswered||0,onSelectOption:t=>{return n=t,R([{key:(a=e).key,question:a.label||a.question||a.key,type:"choice",operator:"is",condition:"and",values:[String(n)]}]),void l("responses");var a,n}}):a&&!n?(a.freeTextSamples||[]).length>0?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(ia.A,{className:o.sampleGrid,children:a.freeTextSamples.map(((e,t)=>(0,h.jsxs)(la.A,{className:o.sampleAnswer,title:e,children:["“",e,"”"]},t)))}
1),(0,h.jsx)(la.A,{className:o.pendingHint,style:{marginTop:8},children:"Free-text answers can't be charted — showing recent samples."})]}):(0,h.jsx)(la.A,{className:o.pendingHint,children:"No answers yet."}):(0,h.jsx)(la.A,{className:o.pendingHint,children:"Answer breakdown appears once this form receives submissions."})})})]},e.key||t);var i}))]}),"responses"===r&&(0,h.jsx)(ch,{form:O,assistantId:a,reloadToken:E,syncReloadToken:S,actionsRef:N,onMeta:k,answerFilters:L,onAnswerFiltersChange:R,analytics:P}),"automation"===r&&(0,h.jsx)(vm.A,{elevation:0,className:o.panel,children:O.automation?.enabled?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(ia.A,{className:o.kv,children:[(0,h.jsx)("span",{className:o.kvLabel,children:"Status"}),(0,h.jsx)("span",{className:o.kvValue,style:{color:"#4caf50"},children:"Enabled"})]}),(0,h.jsxs)(ia.A,{className:o.kv,children:[(0,h.jsx)("span",{className:o.kvLabel,children:"WhatsApp template"}),(0,h.jsx)("span",{className:o.kvValue,children:O.automation.templateName||"—"})]}),O.automation.campaignName&&(0,h.jsxs)(ia.A,{className:o.kv,children:[(0,h.jsx)("span",{className:o.kvLabel,children:"Campaign"}),(0,h.jsx)("span",{className:o.kvValue,children:O.automation.campaignName})]}),(0,h.jsxs)(ia.A,{className:o.kv,children:[(0,h.jsx)("span",{className:o.kvLabel,children:"Trigger"}),(0,h.jsx)("span",{className:o.kvValue,children:"On every new lead"})]}),(0,h.jsx)(la.A,{className:o.pendingHint,style:{marginTop:12},children:"When a lead submits this form, the template is sent automatically to their WhatsApp number."})]}):(0,h.jsxs)(ia.A,{className:o.emptyState,children:[(0,h.jsx)(la.A,{variant:"body1",children:"Automation is off"}),(0,h.jsx)(la.A,{variant:"body2",style:{marginTop:4},children:"Leads from this form aren't messaged automatically. Turn on automation to send a WhatsApp template on each new submission."})]})}),(0,h.jsx)(Vm.A,{open:!!D,autoHideDuration:5e3,onClose:()=>w(null),anchorOrigin:{vertical:"bottom",horizontal:"center"},children:D&&(0,h.jsx)(Aa.A,{severity:D.severity,onClose:()=>w(null),variant:"filled",children:D.message})})]})},hh=e=>(0,h.jsx)(Rn.A,{...e}),gh=(0,_e.makeStyles)((e=>({headerBar:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"1em",flexWrap:"wrap",gap:8},headerTitle:{fontFamily:"Inter",fontWeight:700},searchField:{width:"35%",padding:"2px",background:"rgb(240,240,240)",[e.breakpoints.down("sm")]:{width:"100%"}},searchInputPadding:{padding:"12px 10px 12px 8px"},pillSelect:{width:185,fontSize:"0.8125rem",color:"black",backgroundColor:"rgb(240,240,240)",borderRadius:8,padding:"4px 10px",[e.breakpoints.down("sm")]:{width:"auto",flex:1}},pillSelectIcon:{width:20,height:20,marginRight:6},headerActions:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},tableHeader:{background:"white",padding:4,borderRadius:8,marginBottom:"1em",alignItems:"center"},tableItem:{background:"white",marginBottom:"1em",alignItems:"center",padding:4,borderRadius:8,cursor:"pointer",transition:"background 0.15s","&:hover":{background:"#efefef"}},cell:{padding:"16px 0 16px 16px",minWidth:0},formIcon:{width:38,height:38,borderRadius:8,background:e.palette.primary.light||"#ebf5f3",display:"grid",placeItems:"center",flexShrink:0},formName:{fontFamily:"Inter",fontWeight:400,color:e.palette.text.primary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},statusChip:{padding:"4px",color:"white",fontWeight:600},automationChip:{height:22,fontSize:12,fontWeight:600},emptyState:{width:"100%",height:360,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:e.palette.text.secondary},paginationBar:{position:"fixed",height:60,borderTop:"1px solid lightgrey",background:"white",bottom:0,left:70,right:0,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2,[e.breakpoints.down("sm")]:{left:0,height:50}},footerSpacer:{height:72}}))),bh=[{value:"createdAt:desc",label:"Newest first"},{value:"createdAt:asc",label:"Oldest first"},{value:"leadCounts:desc",label:"Most leads"},{value:"leadCounts:asc",label:"Fewest leads"}],yh=[{value:"all",label:"All"},{value:"on",label:"On"},{value:"off",label:"Off"}],xh=[{key:"icon",label:"",size:1},{key:"form",label:"Form",size:3},{key:"status",label:"Status",size:2},{key:"questions",label:"Questions",size:2},{key:"leads",label:"Leads",size:2},{key:"automation",label:"Automation",size:2}],fh=e=>{let{forms:t=[],assistantId:a,pageId:s,pageIdResolved:o=!0,mockMode:i=!1,totalResponses:r=0,onFormsSynced:l}=e;
1const d=gh(),[c,p]=(0,n.useState)(null),[u,m]=(0,n.useState)(0),[g,b]=(0,n.useState)(10),[y,x]=(0,n.useState)(!1),[f,A]=(0,n.useState)(""),[I,C]=(0,n.useState)(""),[_,S]=(0,n.useState)("createdAt:desc"),[v,E]=(0,n.useState)("all"),[T,D]=(0,n.useState)([]),[w,N]=(0,n.useState)(0),[j,k]=(0,n.useState)(!1),[L,R]=(0,n.useState)(0),[B,O]=(0,n.useState)(0),[P,M]=(0,n.useState)(!1);(0,n.useEffect)((()=>{const e=setTimeout((()=>{C(f.trim()),m(0)}),350);return()=>clearTimeout(e)}),[f]);const U=(0,n.useCallback)((()=>{if(i||!a||!s)return;const e=Zn("lead-forms-count",{assistantId:a,pageId:s}),t=Zn("lead-forms-count",{assistantId:a,pageId:s,status:"ACTIVE"}),n=Kn(e),o=Kn(t);void 0!==n&&(R(n),M(!0)),void 0!==o&&O(o),En(a,s,void 0,void 0,1,1).then((t=>{const a=t?.pagination?.total||0;Jn(e,a),R(a)})).catch((()=>{})).finally((()=>M(!0))),En(a,s,"ACTIVE",void 0,1,1).then((e=>{const a=e?.pagination?.total||0;Jn(t,a),O(a)})).catch((()=>{}))}),[a,s,i]),F=(0,n.useRef)(0),W=(0,n.useCallback)((()=>{if(i||!a||!s)return;const[e,t]=_.split(":"),n="all"===v?void 0:"on"===v,o=Zn("lead-forms",{assistantId:a,pageId:s,search:I||void 0,page:u+1,limit:g,sortBy:e,sortOrder:t,automationEnabled:n}),r=Kn(o);r?(D(r.rows),N(r.total),k(!1)):k(!0);const l=++F.current;En(a,s,void 0,I||void 0,u+1,g,{sortBy:e,sortOrder:t,automationEnabled:n}).then((e=>{const t={rows:e?.data||[],total:e?.pagination?.total||0};Jn(o,t),l===F.current&&(D(t.rows),N(t.total))})).catch((()=>{l!==F.current||r||(D([]),N(0))})).finally((()=>{l===F.current&&k(!1)}))}),[a,s,i,I,u,g,_,v]);(0,n.useEffect)((()=>{U()}),[U]),(0,n.useEffect)((()=>{W()}),[W]);const z=(0,n.useMemo)((()=>{if(!i)return[];const e=I.toLowerCase();let a=e?t.filter((t=>(t.name||"").toLowerCase().includes(e))):[...t];if("all"!==v){const e="on"===v;a=a.filter((t=>!!t.automation?.enabled===e))}const[n,s]=_.split(":"),o="asc"===s?1:-1;return a.sort(((e,t)=>(("leadCounts"===n?Number(e.leadCounts??e.leadsCount??0)||0:new Date(e.createdAt||0).getTime())-("leadCounts"===n?Number(t.leadCounts??t.leadsCount??0)||0:new Date(t.createdAt||0).getTime()))*o)),a}),[i,t,I,v,_]),G=i?z.slice(u*g,u*g+g):T,H=i?z.length:w,V=i?t.length:L,Y=i?t.filter((e=>"ACTIVE"===e.status)).length:B,Z=i?t.length>0:L>0;if(c)return(0,h.jsx)(mh,{form:c,assistantId:a,onBack:()=>p(null)});const K=e=>Number(e.leadCounts??e.leadsCount??0)||0,J=!i&&o&&!s,$=!i&&!P&&!J,q=e=>Array.from({length:e}).map(((e,t)=>(0,h.jsx)(zm.A,{variant:"rect",height:62,style:{borderRadius:8,marginBottom:"1em"}},t)));return(0,h.jsxs)(h.Fragment,{children:[$?(0,h.jsx)(ia.A,{style:{display:"flex",gap:16,marginBottom:18},children:[0,1,2].map((e=>(0,h.jsx)(zm.A,{variant:"rect",height:92,style:{flex:"1 1 0",minWidth:150,borderRadius:12}},e)))}):(0,h.jsx)(Vn,{totalForms:V,activeForms:Y,totalResponses:r}),(0,h.jsxs)(ia.A,{className:d.headerBar,children:[(0,h.jsx)(ca.A,{classes:{root:d.searchField},variant:"outlined",size:"small",placeholder:"Search by form name",value:f,onChange:e=>A(e.target.value),InputProps:{classes:{input:d.searchInputPadding},startAdornment:(0,h.jsx)(pa.A,{position:"start",style:{margin:0},children:(0,h.jsx)(Ia.A,{})})}}),(0,h.jsxs)(ia.A,{className:d.headerActions,children:[(0,h.jsx)(jn.A,{disableUnderline:!0,className:d.pillSelect,value:_,onChange:e=>{S(e.target.value),m(0)},renderValue:e=>`Sort: ${bh.find((t=>t.value===e))?.label||""}`,classes:{icon:d.pillSelectIcon},IconComponent:hh,MenuProps:{getContentAnchorEl:null,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},style:{marginTop:5}},children:bh.map((e=>(0,h.jsx)(kn.A,{value:e.value,children:e.label},e.value)))}),(0,h.jsx)(jn.A,{disableUnderline:!0,className:d.pillSelect,value:v,onChange:e=>{E(e.target.value),m(0)},renderValue:e=>`Automation: ${yh.find((t=>t.value===e))?.label||""}`,classes:{icon:d.pillSelectIcon},IconComponent:hh,MenuProps:{getContentAnchorEl:null,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},style:{marginTop:5}},children:yh.map((e=>(0,h.jsx)(kn.A,{value:e.value,children:e.label},e.value)))}),(0,h.jsx)(ga.Ay,{title:i?"Disabled in demo mode":s?"Fetch the latest forms from Meta (does not sync leads)":"Connect a page to sync forms",children:(0,h.jsx)("span",{children:(0,h.jsx)(da.A,{variant:"outlined",size:"small",startIcon:y?(0,h.jsx)(ba.A,{size:14}):(0,h.jsx)(Ca.A,{}),disabled:y||i||!s,onClick:async()=>
1{if(a&&s&&!y){x(!0);try{await(0,_n.a4)(a,s),$n("lead-forms"),$n("lead-forms-count"),l&&await l(),U(),W()}catch(e){}finally{x(!1)}}},style:{textTransform:"none"},children:y?"Syncing…":"Sync forms"})})})]})]}),$?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(zm.A,{variant:"rect",height:54,style:{borderRadius:8,marginBottom:"1em"}}),q(6)]}):Z?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(ra.A,{container:!0,className:d.tableHeader,children:xh.map((e=>"icon"===e.key?(0,h.jsx)(ra.A,{item:!0,xs:e.size,className:d.cell,children:(0,h.jsx)(Gm.A,{style:{fontSize:20,color:"#0a474c"}})},e.key):(0,h.jsx)(ra.A,{item:!0,xs:e.size,className:d.cell,children:(0,h.jsx)(la.A,{variant:"h5",color:"primary",children:e.label})},e.key)))}),j&&q(Math.min(g,6)),!j&&0===G.length&&(0,h.jsx)(ia.A,{className:d.emptyState,style:{height:200},children:(0,h.jsx)(la.A,{variant:"body1",color:"textSecondary",children:I?`No forms match “${I}”`:"No forms to show"})}),!j&&G.map((e=>{const t="ACTIVE"===e.status,a=(e=>e.questions?.length??e.questionCount??0)(e),n=!!e.automation?.enabled;return(0,h.jsxs)(ra.A,{container:!0,className:d.tableItem,onClick:()=>p(e),children:[(0,h.jsx)(ra.A,{item:!0,xs:1,className:d.cell,children:(0,h.jsx)(Gm.A,{style:{fontSize:20,color:"#0a474c"}})}),(0,h.jsx)(ra.A,{item:!0,xs:3,className:d.cell,children:(0,h.jsxs)(ia.A,{minWidth:0,children:[(0,h.jsx)(la.A,{className:d.formName,children:e.name}),n&&e.automation?.templateName&&(0,h.jsx)(la.A,{variant:"caption",color:"textSecondary",children:e.automation.templateName})]})}),(0,h.jsx)(ra.A,{item:!0,xs:2,className:d.cell,children:(0,h.jsx)(Wm.A,{size:"small",label:t?"Active":"Archived",className:d.statusChip,style:{background:t?"rgb(40 193 82 / 89%)":"rgb(173 173 173 / 85%)"}})}),(0,h.jsx)(ra.A,{item:!0,xs:2,className:d.cell,children:(0,h.jsxs)(la.A,{variant:"body1",children:[a," question",1===a?"":"s"]})}),(0,h.jsx)(ra.A,{item:!0,xs:2,className:d.cell,children:(0,h.jsx)(la.A,{variant:"body1",children:K(e).toLocaleString()})}),(0,h.jsx)(ra.A,{item:!0,xs:2,className:d.cell,children:(0,h.jsx)(Wm.A,{size:"small",variant:"outlined",className:d.automationChip,label:n?"ON":"OFF",style:{color:n?"#357a38":"#9e9e9e",borderColor:n?"#4caf50":"#d0d0d0",background:n?"rgba(76,175,80,0.08)":"transparent"}})})]},e.formId)})),(0,h.jsx)(ia.A,{className:d.footerSpacer}),(0,h.jsx)(ia.A,{className:d.paginationBar,children:(0,h.jsx)(Em.A,{component:"div",count:H,page:u,rowsPerPage:g,rowsPerPageOptions:[5,10,25,50],onChangePage:(e,t)=>m(t),onChangeRowsPerPage:e=>{b(parseInt(e.target.value,10)),m(0)}})})]}):(0,h.jsxs)(ia.A,{className:d.emptyState,children:[(0,h.jsx)(la.A,{variant:"h5",color:"textSecondary",children:J?"No Meta page linked":"No lead forms yet !"}),(0,h.jsx)(la.A,{variant:"body2",style:{marginTop:6},children:J?"No Meta page is linked to this project yet — complete the Meta ad setup to load your lead forms.":"Forms you create on Meta (or from ad creation) will appear here."})]})]})},Ah=(0,_e.makeStyles)((e=>({pageRoot:{height:"100%",width:"100%",background:"rgb(247, 247, 247)",boxSizing:"border-box",overflowX:"hidden",overflowY:"auto",scrollbarGutter:"stable",position:"relative",minHeight:"100vh"},pageTitleContainer:{position:"sticky",top:0,zIndex:100,background:"#fff",boxShadow:"0 0 11px rgb(230 230 230)",minHeight:60,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 24px",boxSizing:"border-box",width:"100%",[e.breakpoints.down("sm")]:{padding:"0 16px"}},innerContainer:{padding:"24px 40px",width:"100%",boxSizing:"border-box",[e.breakpoints.down("md")]:{padding:"20px 24px"},[e.breakpoints.down("sm")]:{padding:"16px"}},connectMessage:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"60vh",padding:24,textAlign:"center"}}))),Ih=()=>{const e=Ah(),t=(0,r.useHistory)(),a=(0,i.useDispatch)(),s=(0,i.useSelector)((e=>e.assistantDetails.data)),o=(0,i.useSelector)((e=>e.ads?.pageDetails)),l=s?.assistantId,[d,c]=(0,n.useState)(null),[p,u]=(0,n.use
1State)(!1),[m,g]=(0,n.useState)(0),b=(0,n.useCallback)((async()=>{if(!l)return;const e=Zn("meta-ad-setup-page",{assistantId:l}),t=Kn(e);t&&c(t);try{const{isValid:t,pageId:n}=await a((0,M.cg)(l));t&&n&&(Jn(e,n),c(n))}catch(e){console.error("Error fetching meta ad setup:",e)}finally{u(!0)}}),[l]);(0,n.useEffect)((()=>{o?.pageId?(c(o.pageId),u(!0)):s?.selectedMetaPageId?(c(s.selectedMetaPageId),u(!0)):b()}),[o?.pageId,s?.selectedMetaPageId,b]);const y=(0,n.useCallback)((async()=>{if(!l)return;const e=Zn("lead-gen-stats",{assistantId:l}),t=Kn(e);t&&g(t.formSubmissions||0);try{const t=await vn(l),a=t?.data||{};Jn(e,a),g(a.formSubmissions||0)}catch{}}),[l]);return(0,n.useEffect)((()=>{y()}),[y]),s&&!s.fbConnected?(0,h.jsx)("div",{className:`${e.pageRoot} ginger-page-root`,children:(0,h.jsx)(ia.A,{className:e.connectMessage,children:(0,h.jsx)(la.A,{variant:"h4",color:"primary",style:{cursor:"pointer"},onClick:()=>t.push(`${Xe(l)}/setup`),children:"Connect and Setup Meta Ad Account to view lead forms! →"})})}):(0,h.jsxs)("div",{className:e.pageRoot,children:[(0,h.jsxs)(ra.A,{container:!0,className:`${e.pageTitleContainer} ginger-page-header`,children:[(0,h.jsx)(ra.A,{item:!0,children:(0,h.jsx)(ia.A,{display:"flex",alignItems:"center",children:(0,h.jsx)(la.A,{variant:"h3",children:"Forms"})})}),(0,h.jsx)(ia.A,{display:"flex",alignItems:"center",ml:"auto",pr:2,children:(0,h.jsx)(B,{name:"gingerLauncher"})})]}),(0,h.jsx)(ia.A,{className:e.innerContainer,children:(0,h.jsx)(fh,{assistantId:l,pageId:d,pageIdResolved:p,totalResponses:m,onFormsSynced:y})})]})},Ch={primary:"#0a474c",primarySoft:"#ebf5f3",accent:"#fec000",text:"#4A4A4A",textMuted:"#6E6E6E",textHint:"#B9B9B9",onPrimary:"#fff",surface:"#fff",surfaceSubtle:"#fafafa",surfaceSunken:"#f5f5f5",canvas:"#F6F7FF",border:"#e0e0e0",borderSubtle:"#f0f0f0",success:"#4caf50",warning:"#FFC260",warningStrong:"#e65100",warningSoft:"#FFF8E1",error:"#f44336",pending:"#e65100",backdropSolid:"#000",decorStrong:"#0a474c",decorAccent:"#fec000",decorSoft:"#7BA8A3",decorTint:"#A9C9C4",radius:6,radiusLg:8,radiusPill:999,shadowNone:"none",shadowCard:"0 1px 3px rgba(0,0,0,0.06)",controlHeight:36,controlHeightSm:28,controlPadX:14};var _h=a(86012);const Sh=["ctwa","website_to_whatsapp"],vh="Getting your ads ready…",Eh="Personalizing your ads…",Th={Queued:vh,"Reading your prompt":Eh,"Looking up your business":Eh,"Building audience":Eh,"Choosing the ad types":"Planning your ad formats…","Designing the creative":"Designing your creatives…","Putting it together":"Putting the finishing touches…",complete:"Your ads are ready to review"},Dh=e=>Th[String((e||{}).stage||"").trim()]||vh,wh={budgetType:"budgetType",dailyBudget:"dailyBudget",lifetimeBudget:"lifetimeBudget",durationDays:"duration"},Nh=["geoLocation","geoLocationDisplay","advanceTargets","excludedGeoLocation","minAge","maxAge"],jh=(e,t)=>Object.keys(t).reduce(((a,n)=>void 0===e[n]?a:{...a,[t[n]]:e[n]}),{}),kh=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=(arguments.length>2?arguments[2]:void 0)||{};return{...t,...jh(a,wh),...jh(a,(n=Nh,n.reduce(((e,t)=>({...e,[t]:t})),{}))),websiteUrl:t.websiteUrl||Sp(e||{})};var n},Lh=["headline","adDescription","adType","geoLocation","minAge","maxAge","imageUrl"],Rh={ctwa:[],whatsapp_status:[],website_traffic:["websiteUrl","ctaButton"],website_to_whatsapp:["websiteUrl"],lead_form:["leadFormId"]},Bh=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=[...Lh,...Rh[e.adType]||[]].filter((t=>{return null==(a=e[t])||""===a||Array.isArray(a)&&0===a.length||"object"==typeof a&&!Array.isArray(a)&&0===Object.keys(a).length;var a}));var a;return a=e,Number(a.dailyBudget)>0||Number(a.lifetimeBudget)>0||t.push("budget"),t},Oh=e=>{try{const t=new window.URL(String(e));return"http:"===t.protocol||"https:"===t.protocol}catch(e){return!1}},Ph=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=Bh(e);if(a.length)return`Missing ${a.join(", ")}`;const n=(e.customAndLookalikeAudiences||[]).length>0;if(!(s=e.geoLocation,bp.some((e=>Array.isArray((s||{})[e])&&s[e].length>0))||n))return"Select at least one location";var s;const o=e.platforms;if(Array.isArray(o)&&0===o.length)return"Select at least one platform";const i="USD"===t.currency?"USD":"INR",r="lifetime_budget"===e.budgetType,l=Number(r?e.lifetimeBudget:e.dailyBudget),d=r?(0,ea.FO)(i):(0,ea.h8)(i);if(!(l>=d))return`${r?"Lifetime":"Daily"} budget must be at least ${d} ${i}`;if(e.videoUrl){if(!Oh(e.videoUrl))return"Invalid video URL"}else if(!Oh(e.imageUrl))return"Invalid image URL";if(e.adStartDate){const t=new Date(e.adStartDate),a=new Date;if(a.setHours(0,0,0,0),!isNaN(t.getTime())&&t<a)return"Start date is in the past"}const c=t.metaAdsCredit;if("number"==typeof c){if(c-(r?l:2*l)<0)return"Not enough Meta ads credit"}return""};var Mh=a(21767),Uh=a(39543);function Fh(e){return`<span data-chip="${e}" class="prompt-chip" role="textbox" aria-label="${e}"></span>`}const[Wh,zh,Gh]=["business name","website URL","target audience"],Hh=`Create a high-converting ad for ${Fh(Wh)} . This is my website URL ${Fh(zh)} . My target audience are ${Fh(Gh)} .`;const Vh=(0,o.makeStyles)((e=>({card:{background:Ch.surface,borderRadius:8,boxShadow:"0 1px 3px rgba(0,0,0,0.06)",boxSizing:"border-box",overflow:"hidden"},promptArea:{padding:"22px 28px 18px",fontSize:14,color:Ch.text,fontWeight:400,lineHeight:2.2,outline:"none",cursor:"text",minHeight:48,wordBreak:"break-word",whiteSpace:"pre-wrap","&:empty::before":{content:"'Describe your product, service or campaign… or paste a link to your website'",color:Ch.textHint,pointerEvents:"none"},"& .prompt-chip":{display:"inline-block",padding:"2px 12px",borderRadius:10,background:Ch.primarySoft,fontSize:13.5,color:Ch.primary,fontWeight:500,lineHeight:"26px",verticalAlign:"baseline",minWidth:60,outline:"none",cursor:"text",transition:"box-shadow 120ms, background 120ms"},"& .prompt-chip:empty::before":{content:"attr(data-chip)",color:Ch.textHint,pointerEvents:"none"},"& .prompt-chip:focus":{background:Ch.surface,boxShadow:`0 0 0 1px ${Ch.primary}`},"& .prompt-chip:not(:empty)":{background:Ch.primarySoft}}
1,sep:{height:1,background:Ch.borderSubtle},optionsRow:{display:"flex",alignItems:"center",padding:"9px 15px",gap:24},sizeControl:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",userSelect:"none"},optLabel:{fontSize:11,fontWeight:700,letterSpacing:"0.8px",color:Ch.textHint},sizeValue:{fontSize:14,fontWeight:600,color:Ch.text},adsControl:{display:"flex",alignItems:"center",gap:12},stepBtn:{width:Ch.controlHeightSm,height:Ch.controlHeightSm,borderRadius:"50%",border:`1px solid ${Ch.border}`,background:Ch.surface,color:Ch.textMuted,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,transition:"border-color 120ms, color 120ms, background 120ms","&:hover:not(:disabled)":{borderColor:Ch.primary,color:Ch.primary,background:Ch.primarySoft},"&:disabled":{opacity:.35,cursor:"default"}},stepValue:{fontSize:15,fontWeight:600,color:Ch.text,minWidth:20,textAlign:"center",userSelect:"none"},spacer:{flex:1},quotaPill:{display:"inline-flex",alignItems:"center",gap:6,flexShrink:0,padding:"5px 11px 5px 9px",boxSizing:"border-box",borderRadius:Ch.radiusPill,background:Ch.surfaceSunken,color:Ch.textMuted,fontSize:11.5,fontWeight:600,lineHeight:1.4,whiteSpace:"nowrap"},quotaPillFree:{background:Ch.primarySoft,color:Ch.primary},quotaIcon:{display:"inline-flex",flexShrink:0},"@keyframes adShimmer":{"0%":{transform:"translateX(-100%)"},"100%":{transform:"translateX(100%)"}},arrowBtn:{position:"relative",overflow:"hidden",height:Ch.controlHeight,minWidth:128,gap:8,padding:`0 ${Ch.controlPadX+4}px`,borderRadius:Ch.radius,background:Ch.primary,border:"none",boxShadow:Ch.shadowNone,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"opacity 150ms","&:hover:not(:disabled)":{opacity:.9},"&:disabled":{background:Ch.border,cursor:"default"},"&::after":{content:'""',position:"absolute",top:0,left:0,width:"100%",height:"100%",background:"linear-gradient(100deg, transparent 20%, rgba(255,255,255,0.28) 50%, transparent 80%)",animation:"$adShimmer 2.2s ease-in-out infinite",pointerEvents:"none"},"&:disabled::after":{animation:"none",background:"none"},"@media (prefers-reduced-motion: reduce)":{"&::after":{animation:"none"}}},arrowBtnBusy:{background:Ch.primary,"&:disabled":{background:Ch.primary,cursor:"default"},"&:disabled::after":{animation:"$adShimmer 2.2s ease-in-out infinite",background:"linear-gradient(100deg, transparent 20%, rgba(255,255,255,0.28) 50%, transparent 80%)"}},arrowBtnLabel:{fontSize:13,fontWeight:600,color:Ch.onPrimary,whiteSpace:"nowrap",position:"relative",zIndex:1},arrowBtnIcon:{display:"inline-flex",position:"relative",zIndex:1}})));function Yh(e){let{submitting:t,disabled:a,progressLabel:s,aspectRatio:i,templateCount:r,minCount:l,maxCount:d,showCount:c=!0,quotaLabel:p="",quotaFree:u=!1,onAspectRatioChange:m,onTemplateCountChange:g,onSubmit:b}=e;const y=Vh(),{showSnackbar:x}=(0,ls.dh)(),f=(0,n.useRef)(null),[A,I]=(0,n.useState)(!0),C=(0,n.useCallback)((()=>{const e=f.current;return e?Array.from(e.querySelectorAll(".prompt-chip")).filter((e=>!e.textContent.trim())).map((e=>e.dataset.chip)):[]}),[]),_=(0,n.useCallback)((()=>{const e=f.current;if(!e)return;const t=e.innerText.replace(/\n/g,"").trim();0===t.length&&(e.innerHTML=""),I(t.length>0)}),[]),S=t||a,v=!S&&A,E=s||vh,T=S;(0,n.useEffect)((()=>{f.current&&!f.current.dataset.seeded&&(f.current.innerHTML=Hh,f.current.dataset.seeded="1")}),[]);const D=(0,n.useCallback)((()=>{_()}),[_]),w=(0,n.useCallback)((()=>{if(S||!f.current)return;const e=C();if(e.length)return void x(`Add your ${t=e,t.length<=1?t[0]||"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}`,"error");var t;const a=f.current.innerText.trim();a.length<3?x("Please describe your business to generate ads","error"):b(a)}),[S,C,x,b]),N=(0,n.useCallback)((()=>{const e=window.getSelection(),t=e&&e.anchorNode;if(!t||!f.current)return null;const a=1===t.nodeType?t:t.parentElement;return a&&f.current.contains(a)?a.closest(".prompt-chip"):null}),[]),j=(0,n.useCallback)((e=>{const t=document.createRange();t.selectNodeContents(e),t.collapse(!1);const a=window.getSelection();a.removeAllRanges(),a.addRange(t)}
1),[]),k=(0,n.useCallback)((e=>{if("Enter"===e.key)return e.preventDefault(),void w();if("Tab"===e.key){const t=Array.from(f.current?f.current.querySelectorAll(".prompt-chip"):[]);if(!t.length)return;const a=N(),n=a?t.indexOf(a):-1,s=e.shiftKey?n-1:n+1;if(s<0||s>=t.length)return;e.preventDefault(),j(t[s])}}),[w,N,j]),L=(0,n.useCallback)((e=>{e.preventDefault();const t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)}),[]);return(0,h.jsxs)("div",{className:y.card,children:[(0,h.jsx)("div",{ref:f,className:y.promptArea,contentEditable:!S,suppressContentEditableWarning:!0,onInput:D,onKeyDown:k,onPaste:L,role:"textbox","aria-label":"Ad prompt","aria-placeholder":"Describe your product, service or campaign…",spellCheck:!0}),(0,h.jsx)("div",{className:y.sep}),(0,h.jsxs)("div",{className:y.optionsRow,children:[(0,h.jsx)(qi,{currentRatio:i,onRatioChange:m,children:(0,h.jsxs)("div",{className:y.sizeControl,role:"button","aria-label":`Image size: ${i}`,children:[(0,h.jsx)("span",{className:y.optLabel,children:"Size"}),(0,h.jsx)("span",{className:y.sizeValue,children:i}),(0,h.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:Ch.textMuted,strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,h.jsx)("path",{d:"M2 4l4 4 4-4"})})]})}),c?(0,h.jsxs)("div",{className:y.adsControl,children:[(0,h.jsx)("span",{className:y.optLabel,children:"Ads"}),(0,h.jsx)("button",{className:y.stepBtn,disabled:S||r<=l,onClick:e=>{e.stopPropagation(),g(Math.max(l,r-1))},type:"button","aria-label":"Decrease ad count",children:(0,h.jsx)("svg",{width:"10",height:"2",viewBox:"0 0 10 2",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:(0,h.jsx)("line",{x1:"1",y1:"1",x2:"9",y2:"1"})})}),(0,h.jsx)("span",{className:y.stepValue,children:r}),(0,h.jsx)("button",{className:y.stepBtn,disabled:S||r>=d,onClick:e=>{e.stopPropagation(),g(Math.min(d,r+1))},type:"button","aria-label":"Increase ad count",children:(0,h.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,h.jsx)("line",{x1:"5",y1:"1",x2:"5",y2:"9"}),(0,h.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})]})})]}):null,p?(0,h.jsxs)("span",{className:`${y.quotaPill} ${u?y.quotaPillFree:""}`,children:[(0,h.jsx)("span",{className:y.quotaIcon,children:u?(0,h.jsx)(Mh.A,{size:14}):(0,h.jsx)(Uh.A,{size:14})}),p]}):null,(0,h.jsx)("div",{className:y.spacer}),(0,h.jsx)("button",{className:`${y.arrowBtn} ${T?y.arrowBtnBusy:""}`,disabled:!v,onClick:w,type:"button","aria-label":T?E:"Generate ad","aria-live":T?"polite":void 0,children:T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("span",{className:y.arrowBtnIcon,children:(0,h.jsx)(o.CircularProgress,{size:15,style:{color:Ch.onPrimary}})}),(0,h.jsx)("span",{className:y.arrowBtnLabel,children:E})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("span",{className:y.arrowBtnIcon,children:(0,h.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",stroke:Ch.onPrimary,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,h.jsx)("path",{d:"M4 10h12M11 5l5 5-5 5"})})}),(0,h.jsx)("span",{className:y.arrowBtnLabel,children:"Generate Ad"})]})})]})]})}const Zh=[{x:"4%",y:52,size:14,color:Ch.decorSoft,glyph:"+"},{x:"8%",y:28,size:11,color:Ch.decorAccent,glyph:"✦"},{x:"11%",y:90,size:9,color:Ch.decorTint,glyph:"+"},{x:"16%",y:48,size:8,color:Ch.decorAccent,glyph:"✦"},{x:"2%",y:110,size:7,color:Ch.decorTint,glyph:"+"},{x:"88%",y:30,size:14,color:Ch.decorTint,glyph:"+"},{x:"93%",y:70,size:11,color:Ch.decorAccent,glyph:"✦"},{x:"97%",y:50,size:9,color:Ch.decorSoft,glyph:"+"},{x:"84%",y:100,size:8,color:Ch.decorTint,glyph:"✦"},{x:"96%",y:110,size:7,color:Ch.decorAccent,glyph:"+"},{x:"38%",y:18,size:8,color:Ch.decorAccent,glyph:"+"},{x:"62%",y:22,size:7,color:Ch.decorTint,glyph:"✦"}],Kh=(0,o.makeStyles)((e=>({"@keyframes sparklePulse":{"0%, 100%":{opacity:.35},"50%":{opacity:.85}},"@keyframes sparkleDrift":{"0%":{transform:"translate(0, 0) rotate(0deg) scale(1)"},"25%":{transform:"translate(4px, -6px) rotate(45deg) scale(1.12)"},"50%":{transform:"translate(-3px, -10px) rotate(90deg) scale(0.92)"},"75%":{transform:"translate(-5px, -4px) rotate(135deg) scale(1.08)"},"100%":{transform:"translate(0, 0) rotate(180deg) scale(1)"}},"@keyframes sparkleBlink":{"0%, 100%":{opacity:.25},"40%":{opacity:1}
1,"55%":{opacity:.45},"70%":{opacity:.95}},"@keyframes badgeStarSpin":{"0%":{transform:"rotate(0deg) scale(1)",opacity:.55},"50%":{transform:"rotate(180deg) scale(1.25)",opacity:1},"100%":{transform:"rotate(360deg) scale(1)",opacity:.55}},root:{position:"relative",width:"100%",padding:"25px 25px 25px",background:Ch.surfaceSubtle,overflow:"hidden",boxSizing:"border-box",[e.breakpoints.down("xs")]:{padding:"28px 16px 24px"}},sparkle:{position:"absolute",userSelect:"none",pointerEvents:"none",lineHeight:1,fontStyle:"normal",willChange:"transform, opacity",animationName:"$sparkleBlink, $sparkleDrift",animationTimingFunction:"ease-in-out",animationIterationCount:"infinite",animationDirection:"normal, alternate","@media (prefers-reduced-motion: reduce)":{animationName:"$sparklePulse",animationDuration:"3s"}},badge:{display:"flex",alignItems:"center",justifyContent:"center",marginBottom:18},badgePill:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 14px",borderRadius:Ch.radiusLg,fontSize:15,fontWeight:700,color:Ch.primary,textTransform:"uppercase"},badgeStar:{fontSize:11,color:`${Ch.primary}`,display:"inline-block",willChange:"transform, opacity",animation:"$badgeStarSpin 4.5s ease-in-out infinite","@media (prefers-reduced-motion: reduce)":{animation:"$sparklePulse 3s ease-in-out infinite"}},heading:{textAlign:"center",fontSize:36,fontWeight:800,color:Ch.text,lineHeight:1.15,marginBottom:12,[e.breakpoints.down("xs")]:{fontSize:24}},sub:{textAlign:"center",fontSize:14,color:Ch.textMuted,marginBottom:12},cardWrap:{maxWidth:860,margin:"0 auto"},note:{maxWidth:860,margin:"8px auto 0",fontSize:12,color:Ch.error,minHeight:16,textAlign:"left"}}))),Jh=function(e){let{isFree:t,freeLeft:a,symbol:n,cost:s}=e,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(t)return`${a} free generation${1===a?"":"s"} left`;const i=Math.max(1,Number(o)||1),r=String(Number(Number(s*i).toFixed(2)));return 1===i?`${n} ${r} Ad Credits`:`${n} ${r} Ad Credits for ${i} ads`};function $h(e){let{submitting:t,disabled:a,progressLabel:s,quota:o,onSubmit:i}=e;const r=Kh(),[l,d]=(0,n.useState)(""),[c,p]=(0,n.useState)("9:16"),[u,m]=(0,n.useState)(1),g=(0,n.useMemo)((()=>Zh.map(((e,t)=>{const a=2.4+t%4*.5,n=7+t%5*1.6,s=.37*t;return{...e,key:t,animDelay:`${s.toFixed(2)}s, ${(.6*s).toFixed(2)}s`,animDuration:`${a.toFixed(2)}s, ${n.toFixed(2)}s`}}))),[]),b=t||a,y=(e=>{const t=e?Number(e.freeGenerationsLeft)||0:J.Vx,a="USD"===e?.currency?"USD":"INR";return{freeLeft:t,isFree:t>0,perFree:Number(e?.variantsPerFreeGeneration)||J.ZG,minCount:Number(e?.minCount)||1,maxCount:Number(e?.maxCount)||5,cost:Number(e?.costPerVariant)||J.mB[a],symbol:e?.symbol||("USD"===a?"$":"₹")}})(o),x=l;return(0,h.jsxs)("div",{className:r.root,children:[g.map((e=>(0,h.jsx)("span",{className:r.sparkle,style:{left:e.x,top:e.y,fontSize:e.size,color:e.color,animationDelay:e.animDelay,animationDuration:e.animDuration},children:e.glyph},e.key))),(0,h.jsx)("div",{className:r.badge,children:(0,h.jsxs)("span",{className:r.badgePill,children:[(0,h.jsx)("span",{className:r.badgeStar,children:"✦"}),"AI-POWERED"]})}),(0,h.jsx)("h2",{className:r.heading,children:"Ready-to-run ads in minutes"}),(0,h.jsx)("p",{className:r.sub,children:"Describe your product or add a link to generate ad templates with AI."}),"      ",(0,h.jsx)("div",{className:r.cardWrap,children:(0,h.jsx)(Yh,{submitting:t,disabled:b,progressLabel:a?s:"",aspectRatio:c,templateCount:u,minCount:y.minCount,maxCount:y.maxCount,showCount:!y.isFree,quotaLabel:Jh(y,u),quotaFree:y.isFree,onAspectRatioChange:p,onTemplateCountChange:m,onSubmit:async e=>{b||(!e||e.trim().length<3?d("Please fill in at least one field to describe your business"):(d(""),await i(e.trim(),y.isFree?y.perFree:u,c,"image")))}})}),x&&(0,h.jsx)("p",{className:r.note,children:x})]})}var qh=a(65892),Xh=a(3160),Qh=a(76069),eg=a(48686),tg=a(23345);const ag=(0,o.makeStyles)((e=>({paper:{background:"transparent",boxShadow:"none",overflow:"visible",margin:e.spacing(2)},backdrop:{backgroundColor:"rgba(0,0,0,0.82)"},wrap:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",gap:e.spacing(1)},close:{position:"absolute",top:-8,right:-8,zIndex:1,background:Ch.surface,padding:6,"&:hover":{background:Ch.primarySoft}},image:{maxHeight:"88vh",maxWidth:"100%",borderRadius:Ch.radiusLg,display:"block",background:Ch.backdropSolid},caption:{color:"rgba(255,255,255,0.82)",fontSize:12.5,textAlign:"center"}})));function ng(e){let{open:t,imageUrl:a,videoUrl:n,title:s,onClose:i}=e;const r=ag();return a||n?(0,h.jsx)(o.Dialog,{open:!!t,onClose:i,maxWidth:!1,classes:{paper:r.paper},BackdropProps:{classes:{root:r.backdrop}},children:(0,h.jsxs)(o.Box,{className:r.wrap,children:[(0,h.jsx)(o.IconButton,{className:r.close,size:"small",onClick:i,"aria-label":"Close preview",children:(0,h.jsx)(Ei.A,{size:20})}),n?(0,h.jsx)("video",{className:r.image,src:n,poster:a||void 0,controls:!0,autoPlay:!0,loop:!0,playsInl
1ine:!0}):(0,h.jsx)("img",{className:r.image,src:a,alt:s||"Ad creative"}),s&&(0,h.jsx)(o.Typography,{className:r.caption,children:s})]})}):null}var sg=a(86241);const og="lifetime_budget",ig={INR:{step:500,min:500,max:5e4},USD:{step:10,min:10,max:1e3}},rg=e=>ig["USD"===e?"USD":"INR"],lg=e=>rg(e).min,dg=e=>{const t=Number(e);return Number.isFinite(t)&&t>0?t:0},cg=e=>e>=10?Math.round(e):Math.round(100*e)/100,pg=(e,t)=>dg((e||{}).stepBudget)||(e=>rg(e).step)(t),ug=(e,t)=>t?Math.ceil(e/t)*t:e,mg=(e,t)=>t?Math.floor(e/t)*t:e,hg=(e,t,a,n)=>{const s=pg(e,t);return n===og?((e,t,a,n)=>{const s=Math.max(1,Number(a)||1),o=dg(n)||pg(e,t),i=Math.max(lg(t),dg((e||{}).minBudget)),r=Math.max((0,ea.FO)(t),i*s),l=dg((e||{}).maxBudget)?dg((e||{}).maxBudget)*s:20*r,d=ug(r,o);return{min:d,max:Math.max(d,mg(l,o))}})(e,t,a,s):((e,t,a)=>{const n=dg(a)||pg(e,t),s=Math.max(lg(t),dg((e||{}).minBudget)),o=dg((e||{}).maxBudget)||rg(t).max,i=ug(s,n);return{min:i,max:Math.max(i,mg(o,n))}})(e,t,s)},gg=e=>{const t=e||{};return{budgetType:t.budgetType===og?og:"daily_budget",dailyBudget:dg(t.dailyBudget),lifetimeBudget:dg(t.lifetimeBudget),durationDays:Tp(t)||0,currency:Ep(t)}},bg=(e,t,a)=>({...a,totalSpend:e,currency:t,cpmRange:null,reachRange:null,resultsRange:null,cprRange:null,resultUnit:null,saturated:!1,saturationTotalSpend:null}),yg=(e,t)=>{const a=gg(e),n={...a,...t||{}},{currency:s}=a,o=Math.max(1,Number(n.durationDays)||1),i={...n,durationDays:o},r=i.budgetType===og?dg(i.lifetimeBudget):dg(i.dailyBudget)*o;if(!r)return bg(0,s,i);const l=((e,t)=>{const a=dg(e.stepBudget);if(!a)return null;const n=dg(e.saturationTotalSpend),s=Boolean(n&&t>n),o=(s?n:t)/a,i=e=>dg(e)?Math.round(Number(e)*o):null;return{reachMin:i(e.reachPerStepMin),reachMax:i(e.reachPerStepMax),resultsMin:i(e.resultsPerStepMin),resultsMax:i(e.resultsPerStepMax),resultUnit:e.resultUnit||null,saturated:s,saturationTotalSpend:n||null}})((e||{}).estimateUnit||{},r);if(!l)return bg(r,s,i);const{reachMin:d,reachMax:c}=l,p=d?{min:cg(r/(c||d)*1e3),max:cg(r/d*1e3),currency:s}:null,u=l.resultsMin?{min:l.resultsMin,max:l.resultsMax||l.resultsMin}:null,m=u?{min:cg(r/u.max),max:cg(r/u.min),currency:s}:null;return{...i,totalSpend:r,currency:s,cpmRange:p,reachRange:d?{min:d,max:c||d}:null,resultsRange:u,cprRange:m,resultUnit:l.resultUnit,saturated:l.saturated,saturationTotalSpend:l.saturationTotalSpend}},xg=(0,o.makeStyles)((e=>({root:{display:"flex",alignItems:"center",gap:4,flex:"1 1 auto",minWidth:0,boxSizing:"border-box",padding:"8px 6px",borderRadius:Ch.radius,background:"#f5f5f5"},body:{minWidth:0,flex:1,textAlign:"left",paddingLeft:3},label:{fontSize:9.5,color:Ch.textMuted,lineHeight:1.2},valueRow:{display:"flex",alignItems:"baseline",justifyContent:"flex-start",gap:3,minWidth:0},input:{width:"100%",minWidth:0,padding:0,border:"none",borderBottom:"1px dashed transparent",background:"transparent",font:"inherit",fontSize:12.5,fontWeight:700,color:Ch.text,lineHeight:1.25,textAlign:"left",textOverflow:"ellipsis","&:hover:not(:disabled)":{borderBottomColor:Ch.border,cursor:"text"},"&:focus":{outline:"none",borderBottom:`1px solid ${e.palette.primary.main}`},"&:disabled":{color:Ch.text}},unit:{fontSize:9.5,fontWeight:400,color:Ch.textMuted,flexShrink:0},button:{width:18,height:18,padding:0,boxSizing:"border-box",borderRadius:Ch.radiusPill,background:Ch.surface,color:e.palette.primary.main,flexShrink:0,"&:hover":{background:Ch.surface,boxShadow:Ch.shadowCard},"&.Mui-disabled":{background:Ch.surface,color:Ch.textHint}}})));function fg(e){let{label:t,value:a,unit:s,min:i,max:r,step:l,onChange:d,disabled:c=!1,format:p=e=>e}=e;const u=xg(),m=Number(a)||0,[g,b]=(0,n.useState)(null),y=(0,n.useRef)(!1),x=e=>{const t=((e,t,a)=>Math.min(Math.max(e,t),a))(e,i,r);t!==m&&d(t)},f=e=>x(Math.round(m/l)*l+e*l),A=null===g?String(p(m)):g;return(0,h.jsxs)(o.Box,{className:u.root,children:[(0,h.jsx)(o.IconButton,{className:u.button,size:"small",disabled:c||m<=i,onClick:()=>f(-1),"aria-label":`Decrease ${t}`,children:(0,h.jsx)(sg.A,{size:12})}),(0,h.jsxs)(o.Box,{className:u.body,children:[(0,h.jsx)(o.Typography,{className:u.label,children:t}),(0,h.jsxs)(o.Box,{className:u.valueRow,children:[(0,h.jsx)("input",{className:u.input,type:"text",inputMode:"numeric","aria-label":t,disabled:c,size:Math.max(1,A.length),value:A,onFocus:e=>{b(String(m)),e.target.select()},onChange:e=>b(e.target.value),onBlur:()=>{if(b(null),y.current)return void(y.current=!1);const e=Number(String(g??"").replace(/[^\d.]/g,""));Number.isFinite(e)&&e>0&&x(Math.round(e))},onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur(),"Escape"===e.key&&(y.current=!0,e.currentTarget.blur())}}),s?(0,h.jsx)("span",{className:u.unit,children:s}):null]})]}),(0,h.jsx)(o.IconButton,{className:u.button,size:"small",disabled:c||m>=r,onClick:()=>f(1),"aria-label":`Increase ${t}`,children:(0,h.jsx)(Qe.A,{size:12})})]})}const Ag=function(){return((arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).retryCount||0)<3},Ig=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)>
1=3?"We couldn't create this after 3 tries. Please contact support":""},Cg=function(){return Ig((arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).retryCount)},_g={creative:"The ad image couldn’t be created.",targeting:"We couldn’t work out who to show this ad to.",estimate:"We couldn’t estimate reach and budget for this ad.",payload:"The ad was built but couldn’t be finished."},Sg=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=Cg(e);return t||(_g[e.failedStage]||"We ran into an issue while creating this ad.")};var vg=a(90232);const Eg=2;const Tg=65,Dg=(e,t)=>{const a=Math.round(Number(e));return!Number.isFinite(a)||a<=0?t:Math.min(Math.max(a,13),Tg)},wg=e=>({geoLocation:_p(e),geoLocationDisplay:[],advanceTargets:Ip((e||{}).advanceTargets),minAge:Dg((e||{}).minAge,18),maxAge:Dg((e||{}).maxAge,Tg)}),Ng=e=>String((e||{}).id??""),jg=e=>{const t=e||yp;return Object.keys(t).flatMap((e=>(t[e]||[]).map((t=>{const a="object"!=typeof t||null===t,n=(0,kd.k2)(t),s=a?"country":t.type||"city",o=a?(0,kd.GL)(n):t.name||n;return{id:`geo:${s}:${n}`,kind:"geo",key:n,type:s,bucket:e,name:o,meta:(0,kd.Cm)(s),radius:a?null:t.radius||null,distanceUnit:a?null:t.distance_unit||null,raw:t}}))))},kg=e=>Boolean(e&&e.type&&e.key),Lg=e=>Boolean(e&&e.type&&e.entityId),Rg=e=>{const t=(e||{}).type,a=(e||{}).key;return{id:`geo:${t}:${a}`,kind:"geo",key:a,type:t,name:(0,kd.GE)(e)||(e||{}).name||a,meta:(0,kd.Cm)(t),raw:e}},Bg=e=>({id:`int:${(e||{}).type}:${Ng(e)}`,kind:"interest",entityId:Ng(e),type:(e||{}).type,name:(e||{}).name||"",meta:Array.isArray((e||{}).path)&&e.path[0]||Cp((e||{}).type),raw:e}),Og=e=>e.radius&&(0,kd.bQ)(e.type)?`${e.name} (+${e.radius}${"mile"===e.distanceUnit?"mi":"km"})`:e.name,Pg="geo",Mg="interest",Ug="age",Fg=[],Wg=e=>({[Pg]:{label:"Locations",placeholder:"Search cities, regions, countries",emptyHint:"No locations yet. This ad can't run without one.",fetcher:t=>e((0,_h.X8)(t)),delay:500,toOption:Rg,canAdd:kg,toItems:e=>jg(e.geoLocation),chipLabel:Og},[Mg]:{label:"Interests",placeholder:"Search interests and behaviours",emptyHint:"No interests yet. Search above to add one.",fetcher:t=>e((0,_h.jf)(t)),delay:700,toOption:Bg,canAdd:Lg,toItems:e=>(e=>{const t=Ip(e);return Object.keys(t).flatMap((e=>{const a=t[e];return Array.isArray(a)?a.map((t=>({id:`int:${e}:${Ng(t)}`,kind:"interest",entityId:Ng(t),type:e,name:t&&(t.name||t.id)||"",meta:Array.isArray(t&&t.path)&&t.path[0]||Cp(e),raw:t}))):[]}))})(e.advanceTargets),chipLabel:e=>e.name},[Ug]:{label:"Age",placeholder:"",emptyHint:"",fetcher:t=>e((0,_h.jf)(t)),delay:700,toOption:Bg,canAdd:Lg,toItems:()=>[],chipLabel:e=>e.name}}),zg=Array.from({length:53},((e,t)=>13+t)),Gg=e=>e>=Tg?"65+":String(e),Hg={getContentAnchorEl:null,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{style:{maxHeight:200,minWidth:84}}},Vg=e=>(0,h.jsx)(_i.A,{size:14,...e}),Yg=(0,o.makeStyles)((e=>({panel:{position:"absolute",top:0,right:0,bottom:0,left:0,zIndex:2,boxSizing:"border-box",display:"flex",flexDirection:"column",padding:"8px 10px",background:"#ffffff",borderTop:`1px solid ${Ch.border}`,overflow:"hidden"},head:{display:"flex",alignItems:"center",gap:6,height:26,flexShrink:0},headTitle:{flex:1,minWidth:0,fontSize:12.5,fontWeight:700,color:Ch.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},back:{width:20,height:20,padding:0,flexShrink:0,color:Ch.textMuted,"&:hover":{color:e.palette.primary.main,background:Ch.primarySoft}},combo:{marginTop:12,flexShrink:0,display:"flex",flexDirection:"column",minHeight:0},inputWrap:{display:"flex",alignItems:"center",gap:6,height:Ch.controlHeightSm,padding:"0 8px",boxSizing:"border-box",borderRadius:Ch.radius,background:"#f5f5f5",flexShrink:0,"&:focus-within":{borderColor:e.palette.primary.main}},inputIcon:{color:Ch.textHint,flexShrink:0},input:{flex:1,minWidth:0,padding:0,border:"none",outline:"none",background:"transparent",font:"inherit",fontSize:11,color:Ch.text,"&::placeholder":{color:Ch.textHint}},status:{height:25,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"space-between",gap:6}
1,statusText:{minWidth:0,fontSize:10,color:Ch.textMuted,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},statusError:{color:Ch.error},resetLink:{flexShrink:0,padding:0,border:"none",background:"transparent",font:"inherit",fontSize:10,color:e.palette.primary.main,cursor:"pointer","&:hover":{textDecoration:"underline"}},listbox:{flex:"1 1 auto",minHeight:72,maxHeight:180,margin:"4px 0 0",padding:0,listStyle:"none",overflowY:"auto",overscrollBehavior:"contain",border:`1px solid ${Ch.borderSubtle}`,borderRadius:Ch.radius,background:Ch.surfaceSubtle},option:{display:"flex",alignItems:"center",gap:6,padding:"5px 8px",cursor:"pointer","&[data-focus='true']":{background:Ch.primarySoft}},optionName:{flex:1,minWidth:0,fontSize:10.5,color:Ch.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},optionMeta:{flexShrink:0,maxWidth:56,fontSize:9,color:Ch.textHint,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},selected:{display:"flex",flexDirection:"column",minHeight:0,marginTop:6},selectedRoomy:{flex:"1 1 auto"},selectedCompact:{flex:"0 0 auto",maxHeight:58,marginTop:"auto"},selectedLabel:{height:14,fontSize:9.5,fontWeight:700,color:Ch.textMuted,flexShrink:0},selectedScroll:{flex:"1 1 auto",minHeight:0,paddingTop:6,overflowY:"auto",overscrollBehavior:"contain",display:"flex",flexWrap:"wrap",gap:6,alignContent:"flex-start"},empty:{fontSize:10,color:Ch.textHint,lineHeight:1.4},chip:{display:"inline-flex",alignItems:"center",gap:2,boxSizing:"border-box",maxWidth:"100%",minWidth:0,padding:"7px 7px 7px 9px",borderRadius:Ch.radiusPill,background:"#f5f5f5",fontSize:11,lineHeight:1,color:Ch.text},chipText:{minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},chipX:{width:13,height:13,padding:0,flexShrink:0,color:Ch.textMuted,"&:hover":{color:e.palette.primary.main,background:"transparent"}},age:{display:"flex",flexDirection:"column",flex:"1 1 auto",marginTop:8,minHeight:0},ageFields:{display:"flex",alignItems:"flex-end",gap:8,flexShrink:0},ageField:{flex:1,minWidth:0},ageFieldLabel:{display:"block",marginBottom:5,fontSize:10,color:Ch.textMuted},ageSelect:{width:"100%",height:Ch.controlHeightSm,boxSizing:"border-box",borderRadius:Ch.radius,background:Ch.surfaceSunken,"&:hover":{background:Ch.borderSubtle},"&.Mui-focused":{boxShadow:`0 0 0 2px ${Ch.primarySoft}`}},ageSelectValue:{display:"flex",alignItems:"center",height:"100%",boxSizing:"border-box",padding:"0 24px 0 9px",fontSize:12,color:Ch.text,"&:focus":{background:"transparent",borderRadius:Ch.radius}},ageSelectIcon:{right:6,top:"calc(50% - 7px)",color:Ch.textMuted},ageOption:{fontSize:12,minHeight:30,paddingTop:6,paddingBottom:4},ageHint:{marginTop:10,fontSize:10,color:Ch.textMuted,lineHeight:1.4},ageFoot:{marginTop:"auto",display:"flex",justifyContent:"flex-end",flexShrink:0}}))),Zg=e=>{let{canSearch:t,error:a,loading:n,query:s,count:o}=e;if(!t)return"Connect a Meta ad account to search";if(a)return a;if(n)return"Searching…";const i=s.trim();return i.length<Eg?`Type ${Eg}+ characters to search`:o?`${o} match${1===o?"":"es"}`:`No matches for "${i}"`};function Kg(e){let{kind:t,targeting:a,onAdd:s,onRemove:r,onAgeChange:l,onReset:d,onClose:c,assistantId:p,adAccountId:u,edited:m=!1}=e;const g=Yg(),b=(0,i.useDispatch)(),y=(0,n.useMemo)((()=>Wg(b)),[b]),x=y[t]||y[Pg],f=(0,n.useRef)(null),A=t===Ug,I=(0,n.useMemo)((()=>x.toItems(a)),[x,a]),C=Boolean(p&&u)&&!A,_=(0,n.useMemo)((()=>(0,ea.oj)(a.geoLocation)),[a.geoLocation]),S=(0,n.useMemo)((()=>({assistantId:p,adAccountId:u,countries:_})),[p,u,_]),{options:v,loading:E,error:T,search:D,reset:w}=function(e){let{fetcher:t,args:a,delay:s=500,minChars:o=Eg,enabled:i=!0}=e;const[r,l]=(0,n.useState)([]),[d,c]=(0,n.useState)(!1),[p,u]=(0,n.use
1State)(null),m=(0,n.useRef)(a);m.current=a;const h=(0,n.useRef)(t);h.current=t;const g=(0,n.useRef)(i);g.current=i;const b=(0,n.useRef)(0),y=(0,n.useRef)(null),x=(0,n.useRef)(!0),f=(0,n.useRef)(""),A=(0,n.useCallback)((e=>{const t=++b.current;y.current&&y.current.abort();const a="function"==typeof AbortController?new AbortController:null;y.current=a,Promise.resolve().then((()=>h.current({...m.current,text:e,signal:a?a.signal:void 0}))).then((a=>{x.current&&t===b.current&&(f.current=e,l(Array.isArray(a)?a:[]),c(!1))})).catch((e=>{x.current&&t===b.current&&"CanceledError"!==as().get(e,"name")&&"AbortError"!==as().get(e,"name")&&(console.error("targeting search failed",e),l([]),c(!1),u("Couldn't search right now"))}))}),[]),I=(0,n.useMemo)((()=>as().debounce(A,s)),[A,s]),C=(0,n.useCallback)((()=>{I.cancel(),y.current&&y.current.abort(),b.current+=1,f.current="",l([]),c(!1),u(null)}),[I]),_=(0,n.useCallback)((e=>{const t=String(e||"").trim();t.length<o||!g.current?C():t!==f.current&&(u(null),c(!0),I(t))}),[I,o,C]);return(0,n.useEffect)((()=>()=>{x.current=!1,I.cancel(),y.current&&y.current.abort()}),[I]),{options:r,loading:d,error:p,search:_,reset:C}}({fetcher:x.fetcher,args:S,delay:x.delay,enabled:C}),N=(0,n.useMemo)((()=>new Set(I.map((e=>e.id)))),[I]),j=(0,n.useMemo)((()=>(v||[]).map(x.toOption).filter((e=>e.id&&x.canAdd(e)&&!N.has(e.id)))),[v,x,N]),{getRootProps:k,getInputProps:L,getListboxProps:R,getOptionProps:B,groupedOptions:P,popupOpen:M,inputValue:U}=(0,O.useAutocomplete)({id:`targeting-${t}`,options:j,getOptionLabel:e=>e.name||"",filterOptions:e=>e,multiple:!0,value:Fg,onInputChange:(e,t,a)=>{"reset"!==a&&D(t)},onChange:(e,a,n,o)=>{const i=o&&o.option;"select-option"===n&&i&&s(t,i.raw)},blurOnSelect:!1,clearOnBlur:!1,componentName:"TargetingEditor"});(0,n.useEffect)((()=>{w();const e=window.requestAnimationFrame((()=>{f.current&&f.current.focus()}));return()=>window.cancelAnimationFrame(e)}),[t,w]);const F=M&&P.length>0,W=L();return(0,h.jsxs)(o.Box,{className:g.panel,role:"group","aria-label":`Edit ${x.label.toLowerCase()}`,onKeyDown:e=>{"Escape"===e.key&&c()},children:[(0,h.jsxs)(o.Box,{className:g.head,children:[(0,h.jsx)(o.Tooltip,{title:"Back to targeting summary",children:(0,h.jsx)(o.IconButton,{className:g.back,size:"small",onClick:c,"aria-label":"Back to targeting summary",children:(0,h.jsx)(vg.A,{size:16})})}),(0,h.jsx)(o.Typography,{className:g.headTitle,children:x.label})]}),A?(0,h.jsxs)(o.Box,{className:g.age,children:[(0,h.jsxs)(o.Box,{className:g.ageFields,children:[(0,h.jsxs)(o.Box,{className:g.ageField,children:[(0,h.jsx)("span",{className:g.ageFieldLabel,children:"Minimum age"}),(0,h.jsx)(o.Select,{className:g.ageSelect,classes:{select:g.ageSelectValue,icon:g.ageSelectIcon},IconComponent:Vg,value:a.minAge,onChange:e=>l({minAge:Number(e.target.value)}),disableUnderline:!0,MenuProps:Hg,SelectDisplayProps:{"aria-label":"Minimum age"},children:zg.map((e=>(0,h.jsx)(o.MenuItem,{value:e,className:g.ageOption,children:e},e)))})]}),(0,h.jsxs)(o.Box,{className:g.ageField,children:[(0,h.jsx)("span",{className:g.ageFieldLabel,children:"Maximum age"}),(0,h.jsx)(o.Select,{className:g.ageSelect,classes:{select:g.ageSelectValue,icon:g.ageSelectIcon},IconComponent:Vg,value:a.maxAge,onChange:e=>l({maxAge:Number(e.target.value)}),disableUnderline:!0,MenuProps:Hg,SelectDisplayProps:{"aria-label":"Maximum age"},children:zg.map((e=>(0,h.jsx)(o.MenuItem,{value:e,className:g.ageOption,children:Gg(e)},e)))})]})]}),(0,h.jsx)(o.Typography,{component:"p",className:g.ageHint,children:"Select an age between 13 and 65. 65+ includes everyone older."}),m&&d?(0,h.jsx)(o.Box,{className:g.ageFoot,children:(0,h.jsx)("button",{type:"button",className:g.resetLink,onClick:d,children:"Reset"})}):null]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(o.Box,{className:g.combo,...k(),children:[(0,h.jsx)(o.Tooltip,{title:C?"":"Connect a Meta ad account in Setup to search",children:(0,h.jsxs)(o.Box,{className:g.inputWrap,children:[(0,h.jsx)(Ni.A,{className:g.inputIcon,size:14}),(0,h.jsx)("input",{className:g.input,placeholder:x.placeholder,disabled:!C,...W,ref:e=>{f.current=e,"function"==typeof W.ref?W.ref(e):W.ref&&(W.ref.current=e)}}),E?(0,h.jsx)(o.CircularProgress,{size:12}):null]})}),(0,h.jsxs)(o.Box,{className:g.status,children:[(0,h.jsx)(o.Typography,{component:"span",className:`${g.statusText} ${T?g.statusError:""}`,"aria-live":"polite",children:Zg({canSearch:C,error:T,loading:E,query:U||"",count:P.length})}),m&&d?(0,h.jsx)("button",{type:"button",className:g.resetLink,onClick:d,children:"Reset"}):null]}),F?(0,h.jsx)("ul",{className:g.listbox,...R(),children:P.map(((e,t)=>(0,n.createElement)("li",{className:g.option,...B({option:e,index:t}),key:e.id},(0,h.jsx)("span",{className:g.optionName,children:e.name}),(0,h.jsx)("span",{className:g.optionMeta,children:e.meta}))))}):null]}),(0,h.jsxs)(o.Box,{className:`${g.selected} ${F?g.selectedCompact:g.selectedRoomy}`,children:[(0,h.jsx)(o.Typography,{component:"span",className:g.selectedLabel,children:I.length?`${I.length} selected`:""}),(0,h.jsx)(o.Box,{className:g.selectedScroll,children:0===I.length?(0,h.jsx)(o.Typography,{component:"span",className:g.empty,children:x.emptyHint}):I.map((e=>(0,h.jsx)(o.Tooltip,{title:x.chipLabel(e),children:(0,h.jsxs)("span",{className:g.chip,children:[(0,h.jsx)("span",{className:g.chipText,children:x.chipLabel(e)}
1),(0,h.jsx)(o.IconButton,{className:g.chipX,size:"small","aria-label":`Remove ${e.name}`,onClick:()=>r(t,e),children:(0,h.jsx)(Ei.A,{size:11})})]})},e.id)))})]})]})]})}const Jg=["budgetType","dailyBudget","lifetimeBudget","durationDays","minAge","maxAge","geoLocation","geoLocationDisplay","excludedGeoLocation","advanceTargets"],$g=e=>({...gg(e),...wg(e)}),qg=e=>{const t=(e=>{const t=e||{},a=Number(t.minAge)||0,n=Number(t.maxAge)||0;return a||n?`${a||18}–${n>=65?"65+":n}`:gp})(e);return t&&t!==gp?t:""},Xg=(0,o.makeStyles)((e=>({root:{height:"100%",display:"flex",flexDirection:"column",boxShadow:Ch.shadowCard,borderRadius:Ch.radiusLg,overflow:"hidden",background:Ch.surface,position:"relative"},media:{position:"relative",width:"100%",height:300,overflow:"hidden",flexShrink:0,[e.breakpoints.down(1400)]:{height:380},[e.breakpoints.down(1050)]:{height:420}},mediaBackdrop:{position:"absolute",top:0,right:0,bottom:0,left:0,backgroundSize:"cover",backgroundPosition:"center",transform:"scale(1.2)",filter:"blur(18px) brightness(0.9)"},image:{position:"relative",width:"100%",height:"100%",objectFit:"contain",display:"block",cursor:"zoom-in"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:4,padding:"2px 2px 6px 8px",background:Ch.surface,borderBottom:`1px solid ${Ch.border}`,flexShrink:0},typeLabelBox:{display:"flex",alignItems:"center",gap:5,minWidth:0},typeLabelText:{fontSize:11,fontWeight:700,color:Ch.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},cardActions:{display:"flex",alignItems:"center",flexShrink:0},body:{flex:1,display:"flex",flexDirection:"column",position:"relative",overflow:"hidden"},tile:{width:30,height:30,borderRadius:Ch.radiusLg,color:e.palette.primary.main,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},section:{padding:"13px 14px 0"},sectionHead:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:8,marginBottom:13},sectionTitle:{fontSize:14,fontWeight:700,color:Ch.text,lineHeight:1.25},sectionSubtitle:{fontSize:10.5,color:Ch.textMuted,lineHeight:1.35,marginTop:2},row:{display:"flex",gap:10,alignItems:"flex-start","& + &":{marginTop:13}},rowBody:{minWidth:0,flex:1,paddingTop:1},rowEdit:{alignSelf:"flex-start",width:22,height:22,padding:0,flexShrink:0,color:Ch.textMuted,"&:hover":{color:e.palette.primary.main,background:Ch.primarySoft}},rowLabel:{fontSize:12.5,fontWeight:700,color:Ch.text,lineHeight:1.3,marginBottom:3},rowValue:{fontSize:13,color:Ch.textMuted,lineHeight:1.45},rowValueClamp:{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:1,overflow:"hidden"},moreLink:{display:"inline-block",marginTop:4,fontSize:11,fontWeight:700,color:e.palette.primary.main,cursor:"pointer",whiteSpace:"nowrap","&:hover":{textDecoration:"underline"}},footer:{padding:"11px 14px 14px"},statRow:{display:"flex",alignItems:"stretch",gap:8,marginBottom:10},runButton:{width:"100%",background:e.palette.primary.main,color:Ch.surface,borderRadius:Ch.radiusLg,textTransform:"none",fontWeight:700,fontSize:12.5,padding:"9px 10px",whiteSpace:"nowrap","&:hover":{background:(0,_e.darken)(e.palette.primary.main,.15)},"&.Mui-disabled":{background:Ch.surfaceSunken,color:Ch.textMuted,boxShadow:`inset 0 0 0 1px ${Ch.border}`}},failedMedia:{display:"flex",alignItems:"center",justifyContent:"center",background:`linear-gradient(150deg, ${Ch.surfaceSubtle} 0%, ${Ch.borderSubtle} 55%, ${Ch.surfaceSubtle} 100%)`,height:200,[e.breakpoints.down(1400)]:{height:220},[e.breakpoints.down(1050)]:{height:240}},failedArt:{width:88,height:88,borderRadius:"50%",background:Ch.surface,boxShadow:Ch.shadowCard,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},failedTitle:{fontSize:15,fontWeight:700,color:Ch.text,lineHeight:1.3},failedReason:{marginTop:5,fontSize:12.5,color:Ch.textMuted,lineHeight:1.45}}))),Qg=e=>{let{color:t=Ch.primary,size:a=17}=e;return(0,h.jsxs)("svg",{width:a,height:a,viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[(0,h.jsx)("path",{d:"M3 10a7 7 0 0 1 11.9-5M17 10A7 7 0 0 1 5.1 15",stroke:t,strokeWidth:"1.7",strokeLinecap:"round"}),(0,h.jsx)("path",{d:"M14.6 1.9v3.4h-3.4M5.4 18.1v-3.4h3.4",stroke:t,strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})]})},eb=()=>
1(0,h.jsxs)("svg",{width:"72",height:"72",viewBox:"0 0 72 72",fill:"none","aria-hidden":"true",children:[(0,h.jsx)("path",{d:"M22 13h18l11 11v35a3 3 0 0 1-3 3H22a3 3 0 0 1-3-3V16a3 3 0 0 1 3-3Z",fill:Ch.surface,stroke:Ch.textHint,strokeWidth:"1.6"}),(0,h.jsx)("path",{d:"M40 13v11h11",fill:"none",stroke:Ch.textHint,strokeWidth:"1.6"}),(0,h.jsx)("circle",{cx:"45",cy:"47",r:"12",fill:Ch.decorStrong}),(0,h.jsx)("path",{d:"m40.8 42.8 8.4 8.4m0-8.4-8.4 8.4",stroke:Ch.surface,strokeWidth:"2.2",strokeLinecap:"round"}),(0,h.jsxs)("g",{fill:Ch.decorTint,children:[(0,h.jsx)("path",{d:"M14 25.5l1.1 2.4 2.4 1.1-2.4 1.1L14 32.5l-1.1-2.4-2.4-1.1 2.4-1.1L14 25.5Z"}),(0,h.jsx)("path",{d:"M57 20l.9 2 2 .9-2 .9-.9 2-.9-2-2-.9 2-.9.9-2Z"}),(0,h.jsx)("path",{d:"M53 33.5l.7 1.5 1.5.7-1.5.7-.7 1.5-.7-1.5-1.5-.7 1.5-.7.7-1.5Z"})]})]}),tb=e=>{let{classes:t,icon:a,label:n,onEdit:s,children:i}=e;return(0,h.jsxs)(o.Box,{className:t.row,children:[(0,h.jsx)(o.Box,{className:t.tile,children:a}),(0,h.jsxs)(o.Box,{className:t.rowBody,children:[(0,h.jsx)(o.Typography,{className:t.rowLabel,children:n}),i]}),s?(0,h.jsx)(o.Tooltip,{title:`Edit ${n.toLowerCase()}`,children:(0,h.jsx)(o.IconButton,{className:t.rowEdit,size:"small",onClick:s,"aria-label":`Edit ${n.toLowerCase()}`,children:(0,h.jsx)(qh.A,{size:14})})}):null]})},ab=e=>{let{classes:t,labels:a,open:s=!1,onToggle:i}=e;const r=(0,n.useRef)(null),[l,d]=(0,n.useState)(!1),c=a.join(", ");return(0,n.useEffect)((()=>{if(s)return;const e=()=>{const e=r.current;e&&d(e.scrollHeight-e.clientHeight>1)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[c,s]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Typography,{ref:r,className:`${t.rowValue} ${s?"":t.rowValueClamp}`,children:c}),l&&i?(0,h.jsx)("span",{className:t.moreLink,role:"button",tabIndex:0,onClick:i,onKeyDown:e=>"Enter"===e.key&&i(),children:s?"See less":"See more"}):null]})};function nb(e){let{template:t,variant:a,gate:s={disabled:!1,reason:""},publishing:i=!1,searchCtx:r={},onRunAd:l,onEditVariant:d,onRetry:c,onGateClick:p,onSaveVariant:u}=e;const m=Xg(),[g,b]=(0,n.useState)(!1),[y,x]=(0,n.useState)(!1),[f,A]=(0,n.useState)(1),[I,C]=(0,n.useState)(null),[_,S]=(0,n.useState)(!1),[v,E]=(0,n.useState)(!1),[T,D]=(0,n.useState)(null),[w,N]=(0,n.useState)(null);(0,n.useEffect)((()=>{if(!y)return;const e=()=>{const e=Math.min(1100,.94*window.innerWidth)-32,t=.9*window.innerHeight-56;A(Math.min(e/300,t/720))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[y]);const j=(0,n.useMemo)((()=>gg(a)),[a]),k=(0,n.useMemo)((()=>yg(a,I)),[a,I]),{durationDays:L,currency:R}=k,B=(e=>"USD"===e?"$":"₹")(R),O="lifetime_budget"===k.budgetType,P=O?k.lifetimeBudget:k.dailyBudget,M=hg(a.estimateUnit,R,L,k.budgetType),U=pg(a.estimateUnit,R),F=e=>{const t={...j,...I,...e},n=hg(a.estimateUnit,R,t.durationDays,t.budgetType),s="lifetime_budget"===t.budgetType?"lifetimeBudget":"dailyBudget";t[s]=Math.min(Math.max(t[s],n.min),n.max),C(t)},W=(0,n.useMemo)((()=>((e,t)=>t?{...e,...t}:e)(a,w)),[a,w]),z=e=>N((t=>e(t||wg(a)))),G=e=>{N((e=>e||wg(a))),D(e)},H=(0,n.useMemo)((()=>I||w?{...I||{},...w||{}}:null),[I,w]),V=(0,n.useRef)(""),Y=(0,n.useMemo)((()=>$g(a)),[a]),Z=(0,n.useCallback)((async e=>{if(!u)return;const n={...Y,...I||{},...w||{}},s=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=(arguments.length>2?arguments[2]:void 0)||$g(e),n={variantIndex:e.variantIndex??0};for(const e of Jg)void 0!==t[e]&&(s=t[e],o=a[e],JSON.stringify(s??null)!==JSON.stringify(o??null)&&(n[e]=t[e]));var s,o;return void 0!==n.geoLocation&&(n.geoLocationDisplay=[]),"lifetime_budget"===(n.budgetType||t.budgetType)&&void 0!==n.lifetimeBudget&&e.adStopDate&&(n.adStopDate=e.adStopDate),n}(a,n,Y);if(!function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.keys(e).some((e=>"variantIndex"!==e))}(s))return;const o=JSON.stringify(s);if(o===V.current)return;V.current=o;const i=await u(t,a,s);i&&"targeting"===e&&N(null),i&&"budget"===e&&C(null),i||(V.current="")}),[u,Y,I,w,a,t]);(0,n.useEffect)((()=>
1{if(!I)return;const e=setTimeout((()=>Z("budget")),800);return()=>clearTimeout(e)}),[I,Z]);const K=(0,n.useCallback)((()=>{D(null),Z("targeting")}),[Z]),J=qg(W),$=wp(W),q=Np(W),X=Boolean(w)&&(Q=W.geoLocation,!(jg(Q).length>0));var Q;const ee=a.imageUrl,te=a.videoUrl,ae={adCaption:a.adDescription||a.primaryText||a.adCaption||"",adHeadline:a.headline||a.adHeadline||"",adHeadlineDescription:a.headlineDescription||a.adHeadlineDescription||"",mediaType:te?"VIDEO":"IMAGE",imageFile:ee?{publicUrl:ee}:null,videoFile:te?{publicUrl:te}:null,thumbnailUrl:ee||null,ctaButton:a.callToAction||a.ctaButton||"LEARN_MORE",adType:a.adType?{value:a.adType}:{value:"click_to_whatsapp"},pageDetails:{picture:"",pageName:a.pageName||"Your Business",whatsappNumber:""},previewLink:null},ne="failed"===a.variantStatus,se=(0,h.jsxs)(o.Box,{className:m.header,children:[(0,h.jsxs)(o.Box,{className:m.typeLabelBox,children:[Ut[a.adType],(0,h.jsx)("span",{className:m.typeLabelText,children:(oe=a.adType,(ea.Kx.find((e=>e.value===oe))||{}).label||"Ad")})]}),(0,h.jsxs)(o.Box,{className:m.cardActions,children:[(0,h.jsx)(o.Tooltip,{title:"Preview this ad",children:(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>x(!0),children:(0,h.jsx)(Xh.A,{size:16})})}),!ne&&d?(0,h.jsx)(o.Tooltip,{title:"Edit this ad",children:(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>d(t,a,H),children:(0,h.jsx)(qh.A,{size:16})})}):null]})]});var oe;if(ne){const e=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return"failed"===e.variantStatus&&(e.retryCount||0)<3}(a),n=Cg(a);return(0,h.jsxs)(o.Card,{className:m.root,children:[se,(0,h.jsx)(o.Box,{className:`${m.media} ${m.failedMedia}`,children:(0,h.jsx)(o.Box,{className:m.failedArt,children:(0,h.jsx)(eb,{})})}),(0,h.jsxs)(o.Box,{className:m.body,children:[(0,h.jsxs)(o.Box,{className:m.section,children:[(0,h.jsx)(o.Typography,{className:m.failedTitle,children:"Couldn’t generate this ad"}),(0,h.jsx)(o.Typography,{className:m.failedReason,children:Sg(a)})]}),(0,h.jsx)(o.Box,{className:m.footer,style:{marginTop:"auto"},children:c?(0,h.jsx)(o.Tooltip,{title:n,children:(0,h.jsx)("span",{style:{display:"block"},children:(0,h.jsx)(o.Button,{className:m.runButton,disabled:!e,onClick:()=>c(t,a),startIcon:(0,h.jsx)(Qg,{color:"currentColor",size:15}),children:"Try again"})})}):null})]})]})}return(0,h.jsxs)(o.Card,{className:m.root,children:[se,(0,h.jsx)(o.Box,{className:m.media,children:(ee||te)&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Box,{className:m.mediaBackdrop,style:{backgroundImage:`url(${ee||""})`}}),te?(0,h.jsx)("video",{className:m.image,src:te,poster:ee||void 0,muted:!0,loop:!0,playsInline:!0,preload:"metadata",onMouseEnter:e=>e.currentTarget.play(),onMouseLeave:e=>{e.currentTarget.pause(),e.currentTarget.currentTime=0},onClick:()=>b(!0)}):(0,h.jsx)("img",{className:m.image,src:ee,alt:a.adName||a.headline||"Ad creative",onClick:()=>b(!0)})]})}),(0,h.jsxs)(o.Box,{className:m.body,children:[T&&w?(0,h.jsx)(Kg,{kind:T,targeting:w,onAdd:(e,t)=>z((a=>e===Pg?((e,t)=>{const a=(t||{}).type;if(!a)return e;const n=(0,kd.Qv)(a,t);return{...e,geoLocation:(0,kd.FE)(e.geoLocation,a,n)}})(a,t):((e,t)=>{const a=(t||{}).type,n=Ng(t);if(!a||!n)return e;const s=e.advanceTargets[a]||[];return s.some((e=>Ng(e)===n))?e:{...e,advanceTargets:{...e.advanceTargets,[a]:[...s,t]}}})(a,t))),onRemove:(e,t)=>z((a=>e===Pg?((e,t,a)=>({...e,geoLocation:(0,kd.z1)(e.geoLocation,t,a)}))(a,t.type,t.key):((e,t,a)=>{const n=(e.advanceTargets[t]||[]).filter((e=>Ng(e)!==String(a))),s={...e.advanceTargets};return n.length?s[t]=n:delete s[t],{...e,advanceTargets:s}})(a,t.type,t.entityId))),onAgeChange:e=>z((t=>function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=Dg(t.minAge??e.minAge,18),n=Dg(t.maxAge??e.maxAge,Tg);return a>n&&(void 0!==t.minAge?n=a:a=n),{...e,minAge:a,maxAge:n}}(t,e))),onReset:()=>N(null),onClose:K,assistantId:r.assistantId,adAccountId:r.adAccountId,edited:Boolean(w)}):null,(0,h.jsxs)(o.Box,{className:m.section,children:[(0,h.jsx)(o.Box,{className:m.sectionHead,children:(0,h.jsx)(o.Box,{minWidth:0,children:(0,h.jsx)(o.Typography,{className:m.sectionTitle,children:"Targeting Summary"})})}),(0,h.jsx)(tb,{classes:m,icon:(0,h.jsx)(Qh.A,{size:17}),label:"Locations",onEdit:()=>G(Pg),children:$.labels.length?(0,h.jsx)(ab,{classes:m,labels:$.labels,open:_,onToggle:()=>S((e=>!e))}):(0,h.jsx)(o.Typography,{className:m.rowValue,children:gp})}),(0,h.jsx)(tb,{classes:m,icon:(0,h.jsx)(eg.A,{size:17}),label:"Age",onEdit:()=>G(Ug),children:(0,h.jsx)(o.Typography,{className:m.rowValue,children:J?`${J} years`:gp})}),(0,h.jsx)(tb,{classes:m,icon:(0,h.jsx)(tg.A,{size:17}),label:"Interests",onEdit:()=>G(Mg),children:q.labels.length?(0,h.jsx)(ab,{classes:m,labels:q.labels,open:v,onToggle:()=>E((e=>!e))}):(0,h.jsx)(o.Typography,{className:m.rowValue,children:gp})})]}),(0,h.jsxs)(o.Box,{className:m.footer,style:{marginTop:"auto"},children:[(0,h.jsxs)(o.Box,{className:m.statRow,children:[(0,h.jsx)(fg,{label:"Budget",value:P,unit:O?"total":"/ day",min:M.min,max:M.max,step:U,format:e=>`${B}
1${e.toLocaleString("en-IN")}`,onChange:e=>F(O?{lifetimeBudget:e}:{dailyBudget:e})}),(0,h.jsx)(fg,{label:"Duration",value:L,unit:"Days",min:1,max:30,step:1,disabled:O,onChange:e=>F({durationDays:e})})]}),s.disabled?(0,h.jsx)(o.Tooltip,{title:s.reason,children:(0,h.jsx)("span",{style:{display:"block"},onClick:()=>!s.pending&&p&&p(t,a),children:(0,h.jsx)(o.Button,{className:m.runButton,disabled:!0,children:"Run Ad"})})}):(0,h.jsx)(o.Tooltip,{title:X?"Select at least one location":"",children:(0,h.jsx)("span",{style:{display:"block"},children:(0,h.jsx)(o.Button,{className:m.runButton,disabled:i||X,endIcon:i&&(0,h.jsx)(o.CircularProgress,{size:16,color:"inherit"}),onClick:()=>{i||X||l(t,a,H)},children:i?"Launching…":"Run Ad"})})})]})]}),(0,h.jsx)(ng,{open:g,imageUrl:ee,videoUrl:te,onClose:()=>b(!1)}),(0,h.jsxs)(o.Dialog,{open:y,onClose:()=>x(!1),maxWidth:!1,PaperProps:{style:{width:1100,maxWidth:"94vw",height:"90vh",borderRadius:Ch.radiusLg,background:Ch.borderSubtle,display:"flex",flexDirection:"column",overflow:"hidden"}},children:[(0,h.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",background:Ch.surface,borderBottom:`1px solid ${Ch.border}`,flexShrink:0},children:[(0,h.jsx)(o.Typography,{style:{fontSize:14,fontWeight:700,color:Ch.text},children:"Ad Preview"}),(0,h.jsx)(o.IconButton,{size:"small",onClick:()=>x(!1),children:(0,h.jsx)(Ei.A,{size:20})})]}),(0,h.jsx)("div",{style:{flex:1,overflowY:"auto",overflowX:"hidden",display:"flex",justifyContent:"center",alignItems:"flex-start",padding:"20px 16px 16px",background:Ch.borderSubtle},children:(0,h.jsx)("div",{style:{zoom:f},children:(0,h.jsx)(Mp,{payload:ae,websiteUrl:a.websiteUrl||t&&(t.websiteUrl||"")||"",isFromFlowKeyword:!1,hideInAppBrowserNote:!0})})})]})]})}const sb=(0,o.makeStyles)((e=>({"@keyframes adSheen":{"0%":{transform:"translateX(-70%) skewX(-12deg)"},"100%":{transform:"translateX(220%) skewX(-12deg)"}},"@keyframes adTwinkle":{"0%, 100%":{opacity:.2,transform:"scale(0.7)"},"50%":{opacity:1,transform:"scale(1)"}},"@keyframes adFloat":{"0%, 100%":{transform:"translateY(0)"},"50%":{transform:"translateY(-5px)"}},root:{height:"100%",display:"flex",flexDirection:"column",boxShadow:Ch.shadowCard,borderRadius:Ch.radiusLg,overflow:"hidden",background:Ch.surface,'& .MuiSkeleton-root, & [class*="MuiSkeleton-root-"]':{backgroundColor:(0,_e.fade)(Ch.primary,.07)}},header:{display:"flex",alignItems:"center",gap:4,padding:"2px 2px 2px 8px",borderBottom:`1px solid ${Ch.border}`,flexShrink:0,height:31,boxSizing:"border-box"},media:{position:"relative",width:"100%",height:300,flexShrink:0,overflow:"hidden",background:`linear-gradient(150deg, ${Ch.primarySoft} 0%, ${Ch.surfaceSubtle} 55%, ${Ch.primarySoft} 100%)`,[e.breakpoints.down(1400)]:{height:380},[e.breakpoints.down(1050)]:{height:420}},sheen:{position:"absolute",top:0,bottom:0,left:0,width:"45%",background:`linear-gradient(90deg, transparent, ${Ch.surface}, transparent)`,opacity:.55,animation:"$adSheen 2.4s ease-in-out infinite"},stage:{position:"absolute",top:0,right:0,bottom:0,left:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:14,padding:"0 22px",textAlign:"center"},sparkles:{position:"relative",width:76,height:60,color:e.palette.primary.main,animation:"$adFloat 3.4s ease-in-out infinite"},star:{position:"absolute",display:"block",animation:"$adTwinkle 1.9s ease-in-out infinite"},starLead:{top:8,left:22,color:e.palette.primary.main},starUp:{top:0,left:4,color:Ch.decorSoft,animationDelay:"0.5s"},starLow:{bottom:2,right:4,color:Ch.decorTint,animationDelay:"1s"},starTiny:{bottom:12,left:12,color:Ch.accent,animationDelay:"1.4s"},stageText:{fontSize:13,fontWeight:700,color:Ch.text,lineHeight:1.35},percent:{fontSize:11,fontWeight:700,color:e.palette.primary.main,lineHeight:1},track:{width:"72%",maxWidth:190,height:5,borderRadius:Ch.radiusPill,background:(0,_e.fade)(Ch.primary,.12),overflow:"hidden"},fill:{height:"100%",borderRadius:Ch.radiusPill,background:`linear-gradient(90deg, ${Ch.decorSoft}, ${e.palette.primary.main})`,transition:"width 600ms ease"},body:{flex:1,display:"flex",flexDirection:"column"},section:{padding:"13px 14px 0"}
1,sectionHead:{display:"flex",alignItems:"flex-start",gap:8,marginBottom:13},row:{display:"flex",gap:10,alignItems:"flex-start","& + &":{marginTop:13}},tile:{borderRadius:Ch.radiusLg,flexShrink:0},pill:{borderRadius:Ch.radius,flexShrink:0},footer:{padding:"11px 14px 14px"},statRow:{display:"flex",alignItems:"center",marginBottom:10},stat:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},statDivider:{width:1,alignSelf:"stretch",background:Ch.border,margin:"0 8px"},button:{borderRadius:Ch.radiusLg}}))),ob=e=>{let{size:t=18}=e;return(0,h.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:(0,h.jsx)("path",{d:"M12 0c.7 6.3 5 10.6 11.3 11.3v1.4C17 13.4 12.7 17.7 12 24c-.7-6.3-5-10.6-11.3-11.3v-1.4C7 10.6 11.3 6.3 12 0Z"})})},ib=e=>{let{classes:t,valueWidths:a}=e;return(0,h.jsxs)(o.Box,{className:t.row,children:[(0,h.jsx)(zm.A,{variant:"rect",width:30,height:30,className:t.tile,animation:"wave"}),(0,h.jsxs)(o.Box,{flex:1,minWidth:0,children:[(0,h.jsx)(zm.A,{variant:"text",width:66,height:13,animation:"wave"}),a.map(((e,t)=>(0,h.jsx)(zm.A,{variant:"text",width:e,height:10,animation:"wave"},t)))]})]})},rb=e=>{let{classes:t}=e;return(0,h.jsxs)(o.Box,{className:t.stat,children:[(0,h.jsx)(zm.A,{variant:"rect",width:24,height:24,className:t.tile,animation:"wave"}),(0,h.jsxs)(o.Box,{flex:1,minWidth:0,children:[(0,h.jsx)(zm.A,{variant:"text",width:"55%",height:12,animation:"wave"}),(0,h.jsx)(zm.A,{variant:"text",width:"80%",height:16,animation:"wave"})]})]})};function lb(e){let{progress:t}=e;const a=sb(),n=Math.min(100,Math.max(0,Number((t||{}).percent)||0)),s=Dh(t);return(0,h.jsxs)(o.Card,{className:a.root,"aria-busy":"true","aria-label":"Generating ad template",children:[(0,h.jsxs)(o.Box,{className:a.header,children:[(0,h.jsx)(zm.A,{variant:"circle",width:22,height:22,animation:"wave"}),(0,h.jsx)(zm.A,{variant:"text",width:92,height:14,animation:"wave"})]}),(0,h.jsxs)(o.Box,{className:a.media,children:[(0,h.jsx)(o.Box,{className:a.sheen}),(0,h.jsxs)(o.Box,{className:a.stage,children:[(0,h.jsxs)(o.Box,{className:a.sparkles,"aria-hidden":"true",children:[(0,h.jsx)("span",{className:`${a.star} ${a.starLead}`,children:(0,h.jsx)(ob,{size:26})}),(0,h.jsx)("span",{className:`${a.star} ${a.starUp}`,children:(0,h.jsx)(ob,{size:14})}),(0,h.jsx)("span",{className:`${a.star} ${a.starLow}`,children:(0,h.jsx)(ob,{size:17})}),(0,h.jsx)("span",{className:`${a.star} ${a.starTiny}`,children:(0,h.jsx)(ob,{size:9})})]}),(0,h.jsx)(o.Typography,{className:a.stageText,children:s}),(0,h.jsx)(o.Box,{className:a.track,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s,children:(0,h.jsx)(o.Box,{className:a.fill,style:{width:`${n}%`}})}),(0,h.jsxs)(o.Typography,{className:a.percent,children:[n,"%"]})]})]}),(0,h.jsxs)(o.Box,{className:a.body,children:[(0,h.jsxs)(o.Box,{className:a.section,children:[(0,h.jsxs)(o.Box,{className:a.sectionHead,children:[(0,h.jsxs)(o.Box,{flex:1,minWidth:0,children:[(0,h.jsx)(zm.A,{variant:"text",width:118,height:16,animation:"wave"}),(0,h.jsx)(zm.A,{variant:"text",width:"72%",height:11,animation:"wave"})]}),(0,h.jsx)(zm.A,{variant:"rect",width:38,height:15,className:a.pill,animation:"wave"})]}),(0,h.jsx)(ib,{classes:a,valueWidths:["96%","70%"]}),(0,h.jsx)(ib,{classes:a,valueWidths:["42%"]}),(0,h.jsx)(ib,{classes:a,valueWidths:["92%","63%"]})]}),(0,h.jsxs)(o.Box,{className:a.footer,style:{marginTop:"auto"},children:[(0,h.jsxs)(o.Box,{className:a.statRow,children:[(0,h.jsx)(rb,{classes:a}),(0,h.jsx)(o.Box,{className:a.statDivider}),(0,h.jsx)(rb,{classes:a})]}),(0,h.jsx)(zm.A,{variant:"rect",width:"100%",height:34,className:a.button,animation:"wave"})]})]})]})}const db={pending:{label:"Pending",color:"default"},processing:{label:"Processing",color:"primary"},completed:{label:"Completed",color:"primary"},partial:{label:"Partial",color:"default"},failed:{label:"Failed",color:"secondary"}};function cb(e){let{status:t}=e;const a=db[t]||db.pending;return(0,h.jsx)(o.Chip,{size:"small",label:a.label,color:a.color})}const pb=(0,o.makeStyles)((()=>({root:{display:"flex",flexDirection:"column",minHeight:"220px",boxShadow:Ch.shadowCard,borderRadius:Ch.radiusLg},header:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",borderBottom:`1px solid ${Ch.borderSubtle}`},source:{fontSize:"13px",fontWeight:600,wordBreak:"break-all"},body:{flexGrow:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",color:Ch.textMuted,padding:"16px"},actions:{display:"flex",justifyContent:"flex-end",gap:"8px",padding:"12px 16px"}})));function ub(e){let{template:t,onRetry:a}=e;const n=pb(),{status:s,retryCount:i=0,progress:r}=t,l=Sp(t)||function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.prompt||e.generation&&e.generation.normalizedInput&&e.generation.normalizedInput.description||e.description||""}(t),d=Dh(r);return(0,h.jsxs)(o.Card,{className:n.root,children:[(0,h.jsxs)(o.Box,{className:n.header,children:[(0,h.jsx)(o.Typography,{className:n.source,children:l}),(0,h.jsx)(cb,{status:s})]}),(0,h.jsx)(o.Box,{className:n.body,children:"failed"===s?(0,h.jsx)(o.Typography,{color:"error",children:"Generation failed"}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.CircularProgress,{size:28}),(0,h.jsx)(o.Typography,{variant:"body2",children:d})]})}),"failed"===s&&(0,h.jsx)(o.Box,{className:n.actions,children:(0,h.jsx)(o.Tooltip,{title:Ig(i),children:(0,h.jsx)("span",{children:(0,h.jsx)(o.Button,{size:"small",color:"primary",variant:"contained",disabled:!Ag(t),onClick:()=>a(t),children:"Retry"})})})})]})}const mb=(0,o.makeStyles)((e=>({grid:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:"16px",alignItems:"stretch",[e.breakpoints.down(1400)]:{gridTemplateColumns:"repeat(3,1fr)"},[e.breakpoints.down(1050)]:{gridTemplateColumns:"repeat(2,1fr)"},[e.breakpoints.down(700)]:{gridTemplateColumns:"repeat(1,1fr)"}},center:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"240px"},noData:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:Ch.surface,minHeight:500,borderRadius:Ch.radiusLg,padding:40,textAlign:"center"},noDataImage:{width:200,height:200,marginBottom:20,borderRadius:Ch.radiusLg},noDataTitle:{fontSize:18,fontWeight:600,color:Ch.text,marginBottom:8},noDataSubtitle:{fontSize:14,color:Ch.textMuted,maxWidth:400,lineHeight:1.5},noDataAction:{marginTop:20,padding:"8px 18px",borderRadius:Ch.radius,background:e.palette.primary.main,color:Ch.onPrimary,textTransform:"none",fontWeight:700,fontSize:13,"&:hover":{background:e.palette.primary.dark}}}))),hb=e=>{let{classes:t,title:a,subtitle:n,actionLabel:s,onAction:i}=e;return(0,h.jsxs)(o.Box,{className:t.noData,children:[(0,h.jsx)("img",{src:tt,alt:"",className:t.noDataImage}),(0,h.jsx)(o.Typography,{className:t.noDataTitle,children:a}),(0,h.jsx)(o.Typography,{className:t.noDataSubtitle,children:n}),s&&i?(0,h.jsx)(o.Button,{className:t.noDataAction,onClick:i,children:s}):null]})},gb=["pending","processing","partial"];function bb(e){let{templates:t=[],loading:a=!1,loadFailed:n=!1,onReload:s,filter:i="all",gateFor:r,runningKeys:l=[],searchCtx:d,onRunAd:c,onEditVariant:p,onRetry:u,onGateClick:m,onSaveVariant:g}=e;const b=mb();if(a)return(0,h.jsx)(o.Box,{className:b.center,children:(0,h.jsx)(o.CircularProgress,{size:50})});if(n)return(0,h.jsx)(hb,{classes:b,title:"Couldn't load your ad templates",subtitle:"Something went wrong on our side.",actionLabel:s?"Try again":void 0,onAction:s});const y=((e,t)=>e.flatMap((e=>{const a=e.variants||[],n=a.filter((e=>e.isArchived)).length,s=a.filter((e=>!e.isArchived)),o=gb.includes(e.status);if(!(s.length||o&&e.templateCount))return"all"===t?[{key:e._id,kind:"status",template:e}]:[];const i=o?Math.max((Number(e.templateCount)||0)-n,s.length):s.length;return Array.from({length:i},((a,n)=>{const o=s[n];return o&&"pending"!==o.variantStatus&&"generating"!==o.variantStatus?"all"!==t&&o.adType!==t?null:{key:`${e._id}:${o.variantIndex??n}`,kind:"variant",template:e,variant:o}:"all"===t?{key:`${e._id}:skeleton:${n}`,kind:"skeleton",template:e}:null}
1)).filter(Boolean)})))(t,i);return y.length?(0,h.jsx)(o.Box,{className:b.grid,children:y.map((e=>"skeleton"===e.kind?(0,h.jsx)(lb,{progress:e.template.progress},e.key):"variant"===e.kind?(0,h.jsx)(nb,{template:e.template,variant:e.variant,gate:r?r(e.variant):void 0,publishing:l.includes(e.key),searchCtx:d,onRunAd:c,onEditVariant:p,onSaveVariant:g,onRetry:u,onGateClick:m},e.key):(0,h.jsx)(ub,{template:e.template,onRetry:u},e.key)))}):t.length?(0,h.jsx)(hb,{classes:b,title:"No ads for this filter",subtitle:"Pick a different ad type, or switch back to All to see everything you've created."}):(0,h.jsx)(hb,{classes:b,title:"No ad templates yet",subtitle:"Describe your product above, or paste a link, and we'll generate ready-to-run ad templates for you."})}const yb={ctwa:(0,h.jsx)(d.WhatsApp,{style:{fontSize:20}}),whatsapp_status:(0,h.jsx)(d.DonutLargeOutlined,{style:{fontSize:20}}),website_to_whatsapp:(0,h.jsx)(d.LanguageOutlined,{style:{fontSize:20}}),website_traffic:(0,h.jsx)(d.PublicOutlined,{style:{fontSize:20}}),lead_form:(0,h.jsx)(d.AssignmentOutlined,{style:{fontSize:20}})},xb=["lead_form"],fb=[{value:"all",label:"All",icon:(0,h.jsx)(d.AppsOutlined,{style:{fontSize:20}})},...ea.Kx.filter((e=>!xb.includes(e.value))).map((e=>({value:e.value,label:e.label,icon:yb[e.value]})))],Ab=(0,o.makeStyles)((e=>({root:{background:Ch.surface,padding:"0 24px",[e.breakpoints.down("xs")]:{padding:"0 4px"}},inner:{maxWidth:1100,margin:"0 auto"},indicator:{borderRadius:"3px 3px 0 0",height:3},tab:{textTransform:"none",fontSize:13,minHeight:60},label:{display:"flex",alignItems:"center"},gap:{padding:"3px"}})));function Ib(e){let{value:t,onChange:a}=e;const n=Ab();return(0,h.jsx)(o.Box,{className:n.root,children:(0,h.jsx)(o.Tabs,{className:n.inner,value:t,onChange:(e,t)=>
1a(t),indicatorColor:"primary",textColor:"primary",variant:"scrollable",scrollButtons:"auto",TabIndicatorProps:{className:n.indicator},children:fb.map((e=>(0,h.jsx)(o.Tab,{value:e.value,className:n.tab,label:(0,h.jsxs)("span",{className:n.label,children:[e.icon,(0,h.jsx)("span",{className:n.gap}),e.label]})},e.value)))})})}const Cb=e=>"pending"===e.status||"processing"===e.status,_b=e=>{const t=e.find(Cb);return t?Dh(t.progress):""},Sb=(0,o.makeStyles)((e=>({root:{height:"100%",display:"flex",flexDirection:"column",background:Ch.surface,overflow:"hidden",boxSizing:"border-box"},header:{height:60,flexShrink:0,boxSizing:"border-box",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12,padding:"0 24px",background:Ch.surface,boxShadow:Ch.shadowCard,zIndex:100,[e.breakpoints.down("xs")]:{padding:"0 16px"}},creditBox:{display:"flex",alignItems:"center",gap:4,flexShrink:0},walletIcon:{width:24,height:24},body:{flex:1,overflowY:"auto",padding:"24px",boxSizing:"border-box",[e.breakpoints.down("xs")]:{padding:"16px 12px"}},panel:{borderRadius:Ch.radiusLg,overflow:"hidden",marginBottom:24},sentinel:{display:"flex",alignItems:"center",justifyContent:"center",height:48}})));const vb={adsManagerMainPage:hi,adTemplates:function(e){const t=Sb(),a=(0,i.useDispatch)(),s=e.match.params.projectId,{showSnackbar:r}=(0,ls.dh)(),[l,d]=(0,n.useState)([]),[c,p]=(0,n.useState)(null),[u,m]=(0,n.useState)(1),[g,b]=(0,n.useState)(!1),[y,x]=(0,n.useState)(!1),f=(0,n.useRef)(null),A=(0,n.useRef)(null),[I,C]=(0,n.useState)(!1),[_,S]=(0,n.useState)(!0),[v,E]=(0,n.useState)(!1),[T,D]=(0,n.useState)("all"),[w,N]=(0,n.useState)({}),[j,k]=(0,n.useState)(!1),[L,R]=(0,n.useState)({}),[B,O]=(0,n.useState)([]),P=(0,n.useRef)(null),M=(0,i.useSelector)((e=>e.assistantDetails&&e.assistantDetails.data))||{},U=(0,i.useSelector)((e=>e.assistantDetails&&e.assistantDetails.adSetupDetails))||{},F=M.adSetupDetails||{},W=w.adAccountId||U.selectedMetaAdAccountId||F.selectedMetaAdAccountId||M.selectedMetaAdAccountId,z=w.pageId||U.selectedMetaPageId||F.selectedMetaPageId||M.selectedMetaPageId||M.metaPageId,G={setupResolved:Boolean(W)||j,fbConnected:M.fbConnected,adAccountId:W,metaAdsCredit:M.metaAdsCredit,whatsappNumberLinked:w.whatsappNumberLinked,hasLeadFormPermissions:L.hasLeadFormPermissions,leadFormTosAccepted:L.leadFormTosAccepted},H=(0,n.useMemo)((()=>({assistantId:s,adAccountId:W})),[s,W]),V=(0,n.useCallback)((async()=>{try{const e=await a((0,_h.eG)(s));d(e&&e.data?e.data:[]),p(e&&e.quota?e.quota:null),m(1),b(Boolean(e&&e.hasNextPage)),C(!1)}catch(e){d([]),b(!1),C(!0)}finally{S(!1)}}),[s,a]),Y=(0,n.useCallback)((async()=>{try{const e=await a((0,_h.eG)(s)),t=e&&e.data?e.data:[];d((e=>((e,t)=>{const a=new Set(t.map((e=>String(e._id))));return[...t,...e.filter((e=>!a.has(String(e._id))))]})(e,t))),e&&e.quota&&p(e.quota),C(!1);(t.some(Cb)||Number(e?.pendingPromotional)>0)&&(P.current=setTimeout(Y,3e3))}catch(e){}}),[s,a]);(0,n.useEffect)((()=>(V(),()=>P.current&&clearTimeout(P.current))),[V]),(0,n.useEffect)((()=>{let e=!0;return a((0,_h.Ap)(s)).then((async t=>{if(!e)return;const n=t||{};N(n),k(!0);const o=n.pageId||F.selectedMetaPageId||M.selectedMetaPageId||M.metaPageId;if(o){const t=await a((0,_h.xS)(s,o));e&&R(t||{})}})),()=>{e=!1}}),[s]);const Z=(0,n.useCallback)((()=>{P.current&&clearTimeout(P.current),P.current=setTimeout(Y,3e3)}),[Y]),K=(0,n.useCallback)((async()=>{if(y||!g)return;x(!0);const e=u+1;try{const t=await a((0,_h.eG)(s,{page:e})),n=t&&t.data?t.data:[];d((e=>{const t=new Set(e.map((e=>String(e._id))));return[...e,...n.filter((e=>!t.has(String(e._id))))]})),m(e),b(Boolean(t&&t.hasNextPage))}catch(e){}finally{x(!1)}}),[s,u,g,y,a]);return(0,n.useEffect)((()=>{const e=f.current,t=A.current;if(!e||!t||!g)return;const a=new IntersectionObserver((e=>{e.some((e=>e.isIntersecting))&&K()}),{root:e,rootMargin:"240px"});return a.observe(t),()=>a.disconnect()}),[g,K]),(0,h.jsxs)(o.Box,{className:t.root,children:[(0,h.jsxs)(o.Box,{className:t.header,children:[(0,h.jsx)(o.Typography,{variant:"h3",children:"Ad Templates"}),(0,h.jsxs)(o.Box,{className:t.creditBox,children:[(0,h.jsx)("img",{src:Zs,alt:"",className:t.walletIcon}),(0,h.jsxs)(o.Typography,{color:"primary",variant:"h4",children:["Ad Credit: ","USD"===M.currency?"$":"₹"," ",(M.metaAdsCredit||0).toFixed(2)]})]})]}),(0,h.jsxs)(o.Box,{className:t.body,ref:f,children:[(0,h.jsxs)(o.Box,{className:t.panel,children:[(0,h.jsx)($h,{submitting:v,progressLabel:_b(l),quota:c,onSubmit:async(e,t,n,o)=>{E(!0);try{const i=await a((0,_h.Xu)(s,e,t,n,o)),l={_id:i?._id,prompt:e,templateCount:t,as
1pectRatio:n,creativeFormat:o,status:i?.status||"pending",retryCount:0,variants:[]};return d((e=>[l,...e])),r("Your ad templates are being created","success"),Z(),!0}catch(e){return r(e?.response?.data?.message||"Couldn't start generation. Please try again","error"),!1}finally{E(!1)}}}),(0,h.jsx)(Ib,{value:T,onChange:D})]}),(0,h.jsx)(bb,{templates:l,loading:_,loadFailed:I,onReload:V,filter:T,gateFor:e=>function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{setupResolved:a=!0,fbConnected:n,adAccountId:s,metaAdsCredit:o,whatsappNumberLinked:i,hasLeadFormPermissions:r,leadFormTosAccepted:l}=t;if(!a)return{disabled:!0,reason:"",pending:!0};if(!1===n)return{disabled:!0,reason:"Connect your Facebook account in Setup"};if(!s)return{disabled:!0,reason:"Select an ad account in Setup"};if("number"==typeof o&&o<=0)return{disabled:!0,reason:"Add Meta ads credit in Setup"};const d=e.adType;if(Sh.includes(d)&&!1===i)return{disabled:!0,reason:"Link your WhatsApp number in Setup"};if("lead_form"===d){if(!1===r)return{disabled:!0,reason:"Reconnect Meta with the 'pages_manage_ads' permission in Setup"};if(!1===l)return{disabled:!0,reason:"Accept the Lead Form Terms of Service in Setup"}}return{disabled:!1,reason:""}}(e,G),runningKeys:B,searchCtx:H,onRunAd:async(t,n,o)=>{const i=((e,t)=>`${e._id}:${t.variantIndex??0}`)(t,n);if(B.includes(i))return;if(B.length)return void r("Another ad is launching. Give it a moment.","error");const l=kh(t,n,o),d=Ph(l,{currency:M.currency,metaAdsCredit:M.metaAdsCredit});if(d)r(d,"error");else{O((e=>[...e,i]));try{const n=kp(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=ea.Kx.find((t=>t.value===e.adType))||ea.Kx[0],n=(0,ea.Nj)(a.type),s=e.budgetType||"daily_budget",o=(0,ea.Ht)(ea.c8,e.adObjective)||n.objective,i=(0,ea.Ht)(o?.optimizationGoals,e.optimizationGoal)||n.goal,r=(0,ea.Ht)(ea.c8,"OUTCOME_TRAFFIC"),l=(0,ea.Ht)(r?.optimizationGoals,"LINK_CLICKS"),d="OFFSITE_CONVERSIONS"===i?.value&&!e.pixelId&&r&&l,c=d?r:o,p=d?l:i,u=Ip(e.advanceTargets),m=_p(e),h=e.excludedGeoLocation?{...yp,...Ap(e.excludedGeoLocation,e.geoLocationDisplay)}:{...yp},g=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).videoUrl?"VIDEO_UPLOAD":"IMAGE_UPLOAD"}(e),b=e.callToAction||e.ctaButton,y=!!e.adStopDate;return{assistantId:t.assistantId,assistantName:t.assistantName,adAccountId:t.adAccountId,metaPageId:t.metaPageId,adName:e.adName||`${a.label} - Template`,headline:e.headline||"",adDescription:e.adDescription||"",headlineDescription:e.headlineDescription||"",websiteUrl:e.websiteUrl||"",gender:e.gender||"ALL",minAge:e.minAge?String(e.minAge):"18",maxAge:e.maxAge?String(e.maxAge):"65",budgetType:s,dailyBudget:Number(e.dailyBudget)||0,lifetimeBudget:Number(e.lifetimeBudget)||0,geoLocation:m,excludedGeoLocation:h,advanceTargets:u,selectedPlatforms:Array.isArray(e.platforms)&&e.platforms.length?e.platforms:["facebook","instagram"],adPlacements:e.adPlacements||{facebookPositions:[],instagramPositions:[]},adStartDate:jp(e.adStartDate||new Date),adStopDate:y?jp(e.adStopDate,5):"",isEndDate:y,duration:Number(e.duration)||2,adType:a.value,adObjective:c?.value||"",optimizationGoal:p?.value||"",conversionEvent:e.conversionEvent||"",ctaButton:b&&"WHATSAPP_MESSAGE"!==b?b:"APPLY_NOW",pixelId:e.pixelId||"",leadFormId:e.leadFormId||"",customAndLookalikeAudiences:e.customAndLookalikeAudiences||[],excludedCustomAndLookalikeAudiences:e.excludedCustomAndLookalikeAudiences||[],audienceId:"",advantageAudience:!0===e.advantageAudience||1===Number(e.advantageAudience),duplicateAd:!1,isScheduledAd:!1,iceBreakers:{status:!1},uploadType:g,imageUrl:e.imageUrl||"",videoUrl:e.videoUrl||"",adTemplate:t.adTemplateId?{templateId:t.adTemplateId,variantIndex:e.variantIndex??0}:void 0}}(l,{assistantId:s,assistantName:M.assistantName,adAccountId:W,metaPageId:z,adTemplateId:t._id})),o=await a((0,_h.R_)(n));if(!o||!o._id)throw new Error("Ad was created without an id");e.history.push(`${Xe(s)}/edit/${o._id}`,{isLiveAD:!0})}catch(e){r(e?.response?.data?.message||e?.message||"Couldn't launch this ad","error"),O((e=>e.filter((e=>e!==i))))}}},onEditVariant:(t,a,n)=>{const{pathname:o,search:i}=e.location;e.history.push({pathname:`${Xe(s)}/create`,state:{adTemplateVariant:kh(t,a,n),returnTo:`${o}${i||""}`}})},onSaveVariant:async(e,t,n)=>{try{const t=await a((0,_h.d3)(e._id,s,n));return t&&t._id&&d((e=>e.map((e=>e._id===t._id?t:e)))),!0}catch(e){return r(e?.response?.data?.message||"Couldn't save your changes","error"),!1}},onRetry:async(e,t)=>{try{const n=t&&Number.isInteger(t.variantIndex)?[t.variantIndex]:void 0,s=await a((0,_h.vm)(e._id,n));d((t=>t.map((t=>t._id===e._id?{...t,status:s?.status||"pending",retryCount:s?.retryCount??t.retryCount}:t)))),r("Retrying generation","success"),Z()}catch(e){r("Failed to retry","error")}},onGateClick:()=>e.history.push((e=>`${Xe(e)}/setup`)(s))}
1),g?(0,h.jsx)("div",{ref:A,className:t.sentinel,children:y?(0,h.jsx)(o.CircularProgress,{size:18,style:{color:Ch.primary}}):null}):null]})]})},setup:po,createAds:su,editAds:su,duplicateAds:su,analytics:pm,leadForms:Ih,leads:Fm,Event:fm,EventDetails:fm,audiences:sa,leadGenPreview:es},Eb=vb,Tb=/\/projects\/([^/]+)/,Db=(e,t)=>{const a="string"==typeof e?e.match(Tb):null;return a&&a[1]||t||void 0},wb=(e,t)=>({...e,params:{...e&&e.params,projectId:t}});class Nb extends n.Component{state={dialog:!1,alert:"",alertMessage:""};onSnackbarClose=()=>this.setState({alert:"",alertMessage:""});showSnackBar=(e,t)=>this.setState({alert:e,alertMessage:t});render(){const{classes:e,agent:t,isCollapse:a,switchCollapse:n,adSetupDetails:s,assistantDetails:i,basename:l}=this.props,d=Db(l,t?.assistantId),c=(e=>"string"==typeof e?e.replace(Tb,"/projects/:projectId"):e)(l),p=s?.isSetupCompleted||s?.selectedMetaAdAccountId?`${l}/ads-manager`:`${l}/setup`,u=L()?"horizontal":"vertical";return(0,h.jsxs)("div",{style:{position:"relative"},children:[(0,h.jsxs)(o.Grid,{container:!0,className:e.root,children:["vertical"===u&&(0,h.jsx)(o.Grid,{item:!0,className:e.navBar,children:(0,h.jsx)(D,{basename:l,isCollapse:a,collapse:()=>n(!a)})}),(0,h.jsxs)(o.Grid,{item:!0,xs:!0,className:e.routeWrapper,children:["horizontal"===u&&(0,h.jsx)(N,{basename:l}),(0,h.jsx)("div",{id:"route-container",className:e.routeContainer,children:(0,h.jsxs)(r.Switch,{children:[(0,h.jsx)(r.Route,{exact:!0,path:c,render:e=>(0,h.jsx)(r.Redirect,{to:p,...e})}),x(t,i).map((e=>{const t=Eb[e.id];return t?(0,h.jsx)(r.Route,{path:c+e.to,render:e=>(0,h.jsx)(t,{...e,match:wb(e.match,d)})},e.id):null})),(0,h.jsx)(r.Route,{render:()=>(0,h.jsx)(r.Redirect,{to:p})})]})})]})]}),(0,h.jsx)(B,{name:"upgradePlanDialog",purchaseNew:!1,dialogOpen:this.state.dialog,toggleUpgradeDialog:()=>this.setState({dialog:!1})}),(0,h.jsx)(B,{name:"gingerPanel"}),(0,h.jsx)(P,{open:!!this.state.alert,message:this.state.alertMessage,severity:this.state.alert,onClose:this.onSnackbarClose})]})}}const jb=(0,i.connect)((e=>({agent:e.login.user,isCollapse:e.cartPlus.isCollapse,assistantDetails:e.assistantDetails.data,adSetupDetails:e.assistantDetails.adSetupDetails})),{switchCollapse:R.Oj})(Nb),kb=(0,o.withStyles)((()=>({root:{width:"100%",height:"100vh",overflow:"hidden",boxSizing:"border-box"},navBar:{zIndex:1},routeWrapper:{height:"100vh",overflow:"hidden",boxSizing:"border-box",background:"white"},routeContainer:{width:"100%",height:"100vh",transition:"1s",overflow:"hidden"}})))(jb)},2915:(e,t,a)=>{"use strict";a.d(t,{Em:()=>y,Fz:()=>A,HN:()=>c,Hv:()=>w,JI:()=>n,NT:()=>b,Tj:()=>p,VY:()=>l,Vx:()=>_,XI:()=>C,ZF:()=>I,ZG:()=>S,ZP:()=>h,_T:()=>u,ak:()=>i,as:()=>s,k:()=>o,kA:()=>m,lO:()=>N,mB:()=>v,md:()=>d,qJ:()=>f,sZ:()=>g,xt:()=>x});let n={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_SOCKET_URL||"https://backend.aisensy.com/agents",s={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_SOCKET_NO_LABEL_URL||"https://backend.api-wa.co/agents";let o={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_WHATSAPP_REST_API_URL||"https://backend.aisensy.com/client/t1",i={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_CAMPAIGN_SERVER_URL||"https://backend.aisensy.com/campaign/t1",r={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_INTEGRATIONS_SERVER_URL||"https://backend.aisensy.com/apps",l={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_URL||"https://www.app.aisensy.com";let d={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_PARTNER_REST_API_URL||"https://backend.aisensy.com/partner/t1";const c="rzp_live_CJlj8hXIU2IDOM",p="https://www.aiads.aisensy.com",u={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_TIMEOUT_FEATURED_ASSISTANTIDS||"64e60ac3b582c60e76a1ad78,64492da5a994dc3465ffdc4a,6337cc42be7532606c705fce,64fae938704e3b7ebe144760,6576a7c258cf8b725eec323e,6576a7c258cf8b725eec323e,663097e46867475e0f985940,6530e2d773d4c50bcfce3b77,6597af8210a82b59ad57a8c8,663cd45609605e5be5a69874,65fad5fe8820532cfe7ee26f,6665e4ea5aad6a5363342f22,637381953fb79b0eb1d6770c,6633972cc8dbb90c00b4da1e,65d880e2366e106d42289c23,66717d85c770257dc2622790,666bde5e6b2a592ebbcdd84b,66603e59d35ed343e2180978,665f09d8cbce7e0b6e19ec7e,664c7162f28ecd1a9902ac8a,6555ceec130b0e0be4c6d1a3,6353da2e153a147b991dd812,667146770950b40b73175d4a,66b35928893321075c285346,66b35851a0436007548619bc",m={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_AISENSY_PARTNER_ID||"627ea4876340e14cf7081778",h={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_TENANT_ID,g={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_APP_ID||"799369954601524",b="https://d1fviw7lxswn81.cloudfront.net/FILE/Audience+Sample+Sheet+.csv",y={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_INTERCOM_APP_ID||"d6hsxi8e",x={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_INTERCOM_DOMAIN||"widget.intercom.io",f={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.AI_AD_CREATIVE_FREE_GENERATIONS||3,A={IMAGE:{INR:{NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.AI_AD_CREATIVE_VIDEO_GENERATOR_COST_INR||30,USD:{NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.AI_AD_CREATIVE_VIDEO_GENERATOR_COST_USD||.4},VIDEO_PER_SECOND:{INR:{NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.AI_AD_CREATIVE_VIDEO_PER_SECOND_COST_INR||25,USD:{NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.AI_AD_CREATIVE_VIDEO_PER_SECOND_COST_USD||.27}},I={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_MIXPANEL_TOKEN||"5da62af320d74ebbf67b5faeaa86a3af",C={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.FLOW_LIBRARY_ASSISTANTS?.split(",")?.filter((e=>!!e))?.map((e=>e.trim()))||["676150e1c5570d001e30c96f","690c4acc57f5420c42a68590","68a5781183
16d5e0c2fef27ce"],_=Number({NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces
1/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_AI_AD_TEMPLATE_FREE_GENERATIONS)||5,S=Number({NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_AD_TEMPLATE_FREE_VARIANTS)||2,v={INR:Number({NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_AI_AD_TEMPLATE_COST_INR)||50,USD:Number({NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_AI_AD_TEMPLATE_COST_USD)||.6};Number({NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_FREE_AD_CREDIT_INR),Number({NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_FREE_AD_CREDIT_USD);let E={NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_GINGER_TENANT_DOMAIN||"www.app.aisensy.com";const T={URL:{NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_WHATSAPP_REST_API_URL,CampaignURL:{NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_CAMPAIGN_SERVER_URL,appURL:{NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_INTEGRATIONS_SERVER_URL,baseURL:{NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_URL,partnerURL:{NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_PARTNER_REST_API_URL,SocketURL:{NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_SOCKET_URL,SocketNoLabelURL:{NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_SOCKET_NO_LABEL_URL,gingerTenantDomain:{NODE_ENV:"production",npm_command:"run-script",npm_config_userconfig:"/root/.npmrc",CODEBUILD_INITIATOR:"AemiliaWebhookProcessorLambda-UnifiedWebhookRole-KRtHzKRJOWcA/AemiliaWebhookProcessorLambd-UnifiedWebhookHandler-BLVR1pzKdFTv",PYENV_SHELL:"bash",REACT_APP_HOST_URL:"https://www.aiads.aisensy.com",npm_config_cache:"/root/.npm",AWS_AMPLIFY_WEB_DYNAMIC_RUNTIME:"nodejs16.x",NVM_INC:"/root/.nvm/versions/node/v22.18.0/include/node",HISTCONTROL:"ignoredups",AWS_EXECUTION_ENV:"AWS_ECS_EC2",CODEBUILD_SRC_DIR:"/codebuild/output/src1199317249/src",COMPUTE_SERVICE_IS_ENABLED:"true",rvm_prefix:"/root",AWS_CONTAINER_CREDENTIALS_RELATIVE_URI:"/v2/credentials/f3ef5937-65ba-412c-94a6-af33c7e674f0",SYSTEMD_COLORS:"false",AWS_AMPLIFY_AL2023_DEFAULT_BUILD_IMAGE:"true",HOSTNAME:"",HISTSIZE:"1000",NODE:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_STEP_NAME:"BUILD",AWS_BRANCH:"main",RVM_ROOT:"/root/.rvm",rvm_stored_umask:"0022",AWS_JOB_ID:"0000000062",AWS_DEFAULT_REGION:"ap-south-1",MY_RUBY_HOME:"/root/.rvm/rubies/ruby-3.2.2",COLOR:"0",AWS_CUSTOM_HTTP_SPEC_CONTENT:"W3sicGF0dGVybiI6IioqLyoiLCJoZWFkZXJzIjpbeyJrZXkiOiJDYWNoZS1Db250cm9sIiwidmFsdWUiOiJwdWJsaWMsIG1heC1hZ2U9MCJ9LHsia2V5IjoiWC1YU1MtUHJvdGVjdGlvbiIsInZhbHVlIjoiMTsgbW9kZT1ibG9jayJ9LHsia2V5IjoiWC1Db250ZW50LVR5cGUtT3B0aW9ucyIsInZhbHVlIjoibm9zbmlmZiJ9LHsia2V5IjoiWC1GcmFtZS1PcHRpb25zIiwidmFsdWUiOiJTQU1FT1JJR0lOIn0seyJrZXkiOiJTdHJpY3QtVHJhbnNwb3J0LVNlY3VyaXR5IiwidmFsdWUiOiJtYXgtYWdlPTMxNTM2MDAwOyBpbmNsdWRlU3ViRG9tYWluczsgcHJlbG9hZCJ9XX1d",npm_config_local_prefix:"/codebuild/output/src1199317249/src/meta-ads-manager",npm_config_globalconfig:"/root/.nvm/versions/node/v22.18.0/etc/npmrc",AWS_GITHUB_SSH_PUBLIC_KEYS:"github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/
1BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n",EDITOR:"/usr/bin/nano",AWS_REGION:"ap-south-1",RUBY_VERSION:"ruby-3.2.2",CODEBUILD_BUILD_IMAGE:"801187164913.dkr.ecr.ap-south-1.amazonaws.com/aemilia-build-image:al2023",PWD:"/codebuild/output/src1199317249/src/meta-ads-manager",AWS_AMPLIFY_SKEW_PROTECTION_ENABLED:"false",ECS_CONTAINER_METADATA_URI_V4:"http://169.254.170.2/v4/33d5a697-e75f-42fd-8a78-37efef08ae39",AWS_APP_ID:"d1ya7vjzd83v9e",LOGNAME:"amplify",CODEBUILD_KMS_KEY_ID:"arn:aws:kms:ap-south-1:801187164913:alias/aws/s3",CODEBUILD_GOPATH:"/codebuild/output/src1199317249",rvm_version:"1.29.12 (latest)",rvm_user_install_flag:"1",npm_config_init_module:"/root/.npm-init.js",AWS_PREVIOUS_COMMIT_ID:"a9ab0b1f1c7813cab607278bfc60b13447e2c199",CODEBUILD_ACTION_RUNNER_URL:"https://codefactory-ap-south-1-prod-default-build-agent-executor.s3.ap-south-1.amazonaws.com/cawsrunner.zip",AWS_FRAMEWORK:"React",CODEBUILD_PROJECT_UUID:"1807b868-7be5-46a6-bc26-406848389dd0",AWS_PLATFORM:"WEB",CODEBUILD_BUILD_ID:"d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",CODEBUILD_CTS_ENDPOINT:"https://codebuild-builds.ap-south-1.amazonaws.com",HOME:"/root",CODEBUILD_CI:"true",npm_package_version:"0.1.0",REMOTE_BACKEND_EXISTS:"false",AWS_AMPLIFY_BUILD_IMAGE_VERSION:"2025-09",CODEBUILD_AGENT_ENDPOINT:"http://127.0.0.1:7831",PKG_EXECPATH:"/codebuild/output/src1199317249/src/pio__exc__",CODEBUILD_LAST_EXIT:"0",AWS_BRANCH_ARN:"arn:aws:amplify:ap-south-1:526559284429:apps/d1ya7vjzd83v9e/branches/main",INIT_CWD:"/codebuild/output/src1199317249/src/meta-ads-manager",CODEBUILD_BUILD_ARN:"arn:aws:codebuild:ap-south-1:801187164913:build/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab",npm_lifecycle_script:"npm run test:scripts && node scripts/check-entry-isolation.js && node scripts/check-react-in-scope.js && node scripts/check-jsx-imports.js && node scripts/check-no-axios-in-features.js && node scripts/check-no-dev-bypass.js && node scripts/check-no-foreign-domain-imports.js && node scripts/check-services-only-in-stores.js && NODE_ENV=production webpack",COMPUTE_SERVICE_IS_OPTED_IN:"true",NVM_DIR:"/root/.nvm",ECS_AGENT_URI:"http://169.254.170.2/api/33d5a697-e75f-42fd-8a78-37efef08ae39",rvm_bin_path:"/root/.rvm/bin",GEM_PATH:"/root/.rvm/gems/ruby-3.2.2:/root/.rvm/gems/ruby-3.2.2@global",npm_config_npm_version:"10.9.3",GEM_HOME:"/root/.rvm/gems/ruby-3.2.2",AWS_AMPLIFY_INTERNAL_IMAGE_OPTIMIZATION:"true",npm_package_name:"whatsapp-dashboard",npm_config_prefix:"/root/.nvm/versions/node/v22.18.0",REACT_APP_WHITE_LABEL_RAZORPAY_KEY_ID:"rzp_live_CJlj8hXIU2IDOM",LESSOPEN:"||/usr/bin/lesspipe.sh %s",PROCESS_FRONTEND_ONLY_APP:"true",USER:"amplify",CODEBUILD_BUILD_NUMBER:"183",rvm_loaded_flag:"1",ECS_CONTAINER_METADATA_URI:"http://169.254.170.2/v3/33d5a697-e75f-42fd-8a78-37efef08ae39",npm_lifecycle_event:"build",SHLVL:"3",NVM_CD_FLAGS:"",AWS_BUILDSPEC_CONTENT:"dmVyc2lvbjogMQpmcm9udGVuZDoKICBwaGFzZXM6CiAgICBwcmVCdWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBudm0gaW5zdGFsbCAxOAogICAgICAgIC0gbnZtIHVzZSAxOAogICAgICAgIC0gbnBtIGNpCiAgICBidWlsZDoKICAgICAgY29tbWFuZHM6CiAgICAgICAgLSBucG0gcnVuIGJ1aWxkCiAgYXJ0aWZhY3RzOgogICAgYmFzZURpcmVjdG9yeTogZGlzdAogICAgZmlsZXM6CiAgICAgIC0gJyoqLyonCiAgY2FjaGU6CiAgICBwYXRoczoKICAgICAgLSAubnBtLyoqLyoK",SSR_IS_ENABLED:"true",CUSTOMER_ACCOUNTID:"526559284429",CODEBUILD_LOG_PATH:"d1ya7vjzd83v9e/35356496-9986-43e3-912d-513f4afe77ab",AWS_COMMIT_ID:"fe4a929a80e052b7ff8dee8d69b44bbad9d11212",npm_config_user_agent:"npm/10.9.3 node/v22.18.0 linux x64 workspaces/false ci/aws-codebuild",AWS_CLONE_URL:"[email protected]:trinybotio/meta-ads-manager.git",CODEBUILD_EXECUTION_ROLE_BUILD:"",npm_execpath:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/bin/npm-cli.js",CODEBUILD_SCRIPT_DIR:"/codebuild/output/tmp",REACT_APP_MODE:"production",PYENV_ROOT:"/root/.pyenv",AWS_AMPLIFY_DEPLOYMENT_ID:"14cd486a-04f1-4484-af05-ba1aafc5ae9a",npm_package_json:"/codebuild/output/src1199317249/src/meta-ads-manager/
1package.json",CODEBUILD_BUILD_URL:"https://ap-south-1.console.aws.amazon.com/codebuild/home?region=ap-south-1#/builds/d1ya7vjzd83v9e:35356496-9986-43e3-912d-513f4afe77ab/view/new",CODEBUILD_FE_REPORT_ENDPOINT:"https://codebuild.ap-south-1.amazonaws.com/",CODEBUILD_BUILD_SUCCEEDING:"1",which_declare:"declare -f",CODEBUILD_BMR_URL:"https://CODEBUILD_AGENT:3000",CODEBUILD_AUTH_TOKEN:"1d05de36-2fea-4a17-94d5-496a41b7c530",MAVEN_OPTS:"-Dmaven.wagon.httpconnectionManager.maxPerRoute=2",npm_config_noproxy:"",PATH:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin:/codebuild/output/src1199317249/src/node_modules/.bin:/codebuild/output/src1199317249/node_modules/.bin:/codebuild/output/node_modules/.bin:/codebuild/node_modules/.bin:/node_modules/.bin:/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/root/.pyenv/shims:/root/.rvm/gems/ruby-3.2.2/bin:/root/.rvm/gems/ruby-3.2.2@global/bin:/root/.rvm/rubies/ruby-3.2.2/bin:/root/.nvm/versions/node/v22.18.0/bin:/root/bin:/root/.rvm/bin:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin:/root/.rvm/bin:/root/.rvm/bin:/root/.rvm/bin",npm_config_node_gyp:"/root/.nvm/versions/node/v22.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",IS_SSR:"false",AWS_REQUEST_ID:"77fe71a1-9995-49cb-8262-a52370bb9d19",CODEBUILD_CONTAINER_NAME:"default",npm_config_global_prefix:"/root/.nvm/versions/node/v22.18.0",AMPLIFY_STATIC_FIRST_ROUTING:"true",NVM_BIN:"/root/.nvm/versions/node/v22.18.0/bin",MAIL:"/var/spool/mail/amplify",IS_FIRST_BUILD:"false",IRBRC:"/root/.rvm/rubies/ruby-3.2.2/.irbrc",CODEBUILD_START_TIME:"1789818305165",npm_node_execpath:"/root/.nvm/versions/node/v22.18.0/bin/node",AWS_AMPLIFY_BUILD_COMPUTE_TYPE:"STANDARD_8GB",rvm_path:"/root/.rvm",OLDPWD:"/codebuild/readonly",GOPATH:"/codebuild/output/src1199317249",CODEBUILD_PROJECT_ARN:"arn:aws:codebuild:ap-south-1:801187164913:project/d1ya7vjzd83v9e","BASH_FUNC_which%%":'() {  ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"\n}',_:"/codebuild/output/src1199317249/src/meta-ads-manager/node_modules/.bin/webpack"}.REACT_APP_GINGER_TENANT_DOMAIN};let D=!1;const w=e=>{if(!e)return;const t=Object.keys(T).filter((e=>T[e]));t.length&&!D&&(D=!0,console.info("[adsMfe] API base(s) pinned by environment, ignoring the host for: "+t.join(", ")+". URL = "+o)),e.URL&&!T.URL&&(o=e.URL),e.CampaignURL&&!T.CampaignURL&&(i=e.CampaignURL),e.appURL&&!T.appURL&&(r=e.appURL),e.baseURL&&!T.baseURL&&(l=e.baseURL),e.partnerURL&&!T.partnerURL&&(d=e.partnerURL),e.SocketURL&&!T.SocketURL&&(n=e.SocketURL),e.SocketNoLabelURL&&!T.SocketNoLabelURL&&(s=e.SocketNoLabelURL),e.gingerTenantDomain&&!T.gingerTenantDomain&&(E=e.gingerTenantDomain)},N=()=>({URL:o,CampaignURL:i,appURL:r,baseURL:l,partnerURL:d,SocketURL:n,SocketNoLabelURL:s,gingerTenantDomain:E})},5825:(e,t,a)=>{"use strict";a.d(t,{A:()=>n});const n=[{name:"Afghanistan",dialCode:"+93",isoCode:"AF"},{name:"Aland Islands",dialCode:"+358",isoCode:"AX"},{name:"Albania",dialCode:"+355",isoCode:"AL"},{name:"Algeria",dialCode:"+213",isoCode:"DZ"},{name:"AmericanSamoa",dialCode:"+1684",isoCode:"AS"},{name:"Andorra",dialCode:"+376",isoCode:"AD"},{name:"Angola",dialCode:"+244",isoCode:"AO"},{name:"Anguilla",dialCode:"+1264",isoCode:"AI"},{name:"Antarctica",dialCode:"+672",isoCode:"AQ"},{name:"Antigua and Barbuda",dialCode:"+1268",isoCode:"AG"},{name:"Argentina",dialCode:"+54",isoCode:"AR"},{name:"Armenia",dialCode:"+374",isoCode:"AM"},{name:"Aruba",dialCode:"+297",isoCode:"AW"},{name:"Ascension Island",dialCode:"+247",isoCode:"AC"},{name:"Australia",dialCode:"+61",isoCode:"AU"},{name:"Austria",dialCode:"+43",isoCode:"AT"},{name:"Azerbaijan",dialCode:"+994",isoCode:"AZ"},{name:"Bahamas",dialCode:"+1242",isoCode:"BS"},{name:"Bahrain",dialCode:"+973",isoCode:"BH"},{name:"Bangladesh",dialCode:"+880",isoCode:"BD"},{name:"Barbados",dialCode:"+1246",isoCode:"BB"},{name:"Belarus",dialCode:"+375",isoCode:"BY"},{name:"Belgium",dialCode:"+32",isoCode:"BE"},{name:"Belize",dialCode:"+501",isoCode:"BZ"},{name:"Benin",dialCode:"+229",isoCode:"BJ"},{name:"Bermuda",dialCode:"+1441",isoCode:"BM"},{name:"Bhutan",dialCode:"+975",isoCode:"BT"},{name:"Bolivia",dialCode:"+591",isoCode:"BO"},{name:"Bosnia and Herzegovina",dialCode:"+387",isoCode:"BA"},{name:"Botswana",dialCode:"+267",isoCode:"BW"},{name:"Brazil",dialCode:"+55",isoCode:"BR"},{name:"British Indian Ocean Territory",dialCode:"+246",isoCode:"IO"},{name:"Brunei Darussalam",dialCode:"+673",isoCode:"BN"},{name:"Bulgaria",dialCode:"+359",isoCode:"BG"},{name:"Burkina Faso",dialCode:"+226",isoCode:"BF"},{name:"Burundi",dialCode:"+257",isoCode:"BI"},{name:"Cambodia",dialCode:"+855",isoCode:"KH"},{name:"Cameroon",dialCode:"+237",isoCode:"CM"},{name:"Canada",dialCode:"+1",isoCode:"CA"},{name:"Cape Verde",dialCode:"+238",isoCode:"CV"},{name:"Cayman Islands",dialCode:"+1345",isoCode:"KY"},{name:"Central African Republic",dialCode:"+236",isoCode:"CF"},{name:"Chad",dialCode:"+235",isoCode:"TD"},{name:"Chile",dialCode:"+56",isoCode:"CL"},{name:"China",dialCode:"+86",isoCode:"CN"},{name:"Christmas Island",dialCode:"+61",isoCode:"CX"},{name:"Cocos (Keeling) Islands",dialCode:"+61",isoCode:"CC"},{name:"Colombia",dialCode:"+57",isoCode:"CO"},{name:"Comoros",dialCode:"+269",isoCode:"KM"},{name:"Congo",dialCode:"+242",isoCode:"CG"},{name:"Cook Islands",dialCode:"+682",isoCode:"CK"},{name:"Costa Rica",dialCode:"+506",isoCode:"CR"},{name:"Croatia",dialCode:"+385",isoCode:"HR"},{name:"Cuba",dialCode:"+53",isoCode:"CU"},{name:"Cyprus",dialCode:"+357",isoCode:"CY"},{name:"Czech Republic",dialCode:"+420",isoCode:"CZ"},{name:"Democratic Republic of the Congo",dialCode:"+243",isoCode:"CD"},{name:"Denmark",dialCode:"+45",isoCode:"DK"},{name:"Djibouti",dialCode:"+253",isoCode:"DJ"}
1,{name:"Dominica",dialCode:"+1767",isoCode:"DM"},{name:"Dominican Republic",dialCode:"+1849",isoCode:"DO"},{name:"Ecuador",dialCode:"+593",isoCode:"EC"},{name:"Egypt",dialCode:"+20",isoCode:"EG"},{name:"El Salvador",dialCode:"+503",isoCode:"SV"},{name:"Equatorial Guinea",dialCode:"+240",isoCode:"GQ"},{name:"Eritrea",dialCode:"+291",isoCode:"ER"},{name:"Estonia",dialCode:"+372",isoCode:"EE"},{name:"Eswatini",dialCode:"+268",isoCode:"SZ"},{name:"Ethiopia",dialCode:"+251",isoCode:"ET"},{name:"Falkland Islands (Malvinas)",dialCode:"+500",isoCode:"FK"},{name:"Faroe Islands",dialCode:"+298",isoCode:"FO"},{name:"Fiji",dialCode:"+679",isoCode:"FJ"},{name:"Finland",dialCode:"+358",isoCode:"FI"},{name:"France",dialCode:"+33",isoCode:"FR"},{name:"French Guiana",dialCode:"+594",isoCode:"GF"},{name:"French Polynesia",dialCode:"+689",isoCode:"PF"},{name:"Gabon",dialCode:"+241",isoCode:"GA"},{name:"Gambia",dialCode:"+220",isoCode:"GM"},{name:"Georgia",dialCode:"+995",isoCode:"GE"},{name:"Germany",dialCode:"+49",isoCode:"DE"},{name:"Ghana",dialCode:"+233",isoCode:"GH"},{name:"Gibraltar",dialCode:"+350",isoCode:"GI"},{name:"Greece",dialCode:"+30",isoCode:"GR"},{name:"Greenland",dialCode:"+299",isoCode:"GL"},{name:"Grenada",dialCode:"+1473",isoCode:"GD"},{name:"Guadeloupe",dialCode:"+590",isoCode:"GP"},{name:"Guam",dialCode:"+1671",isoCode:"GU"},{name:"Guatemala",dialCode:"+502",isoCode:"GT"},{name:"Guernsey",dialCode:"+44",isoCode:"GG"},{name:"Guinea",dialCode:"+224",isoCode:"GN"},{name:"Guinea-Bissau",dialCode:"+245",isoCode:"GW"},{name:"Guyana",dialCode:"+592",isoCode:"GY"},{name:"Haiti",dialCode:"+509",isoCode:"HT"},{name:"Holy See (Vatican City State)",dialCode:"+379",isoCode:"VA"},{name:"Honduras",dialCode:"+504",isoCode:"HN"},{name:"Hong Kong",dialCode:"+852",isoCode:"HK"},{name:"Hungary",dialCode:"+36",isoCode:"HU"},{name:"Iceland",dialCode:"+354",isoCode:"IS"},{name:"India",dialCode:"+91",isoCode:"IN"},{name:"Indonesia",dialCode:"+62",isoCode:"ID"},{name:"Iran",dialCode:"+98",isoCode:"IR"},{name:"Iraq",dialCode:"+964",isoCode:"IQ"},{name:"Ireland",dialCode:"+353",isoCode:"IE"},{name:"Isle of Man",dialCode:"+44",isoCode:"IM"},{name:"Israel",dialCode:"+972",isoCode:"IL"},{name:"Italy",dialCode:"+39",isoCode:"IT"},{name:"Ivory Coast / Cote d'Ivoire",dialCode:"+225",isoCode:"CI"},{name:"Jamaica",dialCode:"+1876",isoCode:"JM"},{name:"Japan",dialCode:"+81",isoCode:"JP"},{name:"Jersey",dialCode:"+44",isoCode:"JE"},{name:"Jordan",dialCode:"+962",isoCode:"JO"},{name:"Kazakhstan",dialCode:"+77",isoCode:"KZ"},{name:"Kenya",dialCode:"+254",isoCode:"KE"},{name:"Kiribati",dialCode:"+686",isoCode:"KI"},{name:"Korea, Democratic People's Republic of Korea",dialCode:"+850",isoCode:"KP"},{name:"Korea, Republic of South Korea",dialCode:"+82",isoCode:"KR"},{name:"Kosovo",dialCode:"+383",isoCode:"XK"},{name:"Kuwait",dialCode:"+965",isoCode:"KW"},{name:"Kyrgyzstan",dialCode:"+996",isoCode:"KG"},{name:"Laos",dialCode:"+856",isoCode:"LA"},{name:"Latvia",dialCode:"+371",isoCode:"LV"},{name:"Lebanon",dialCode:"+961",isoCode:"LB"},{name:"Lesotho",dialCode:"+266",isoCode:"LS"},{name:"Liberia",dialCode:"+231",isoCode:"LR"},{name:"Libya",dialCode:"+218",isoCode:"LY"},{name:"Liechtenstein",dialCode:"+423",isoCode:"LI"},{name:"Lithuania",dialCode:"+370",isoCode:"LT"},{name:"Luxembourg",dialCode:"+352",isoCode:"LU"},{name:"Macau",dialCode:"+853",isoCode:"MO"},{name:"Madagascar",dialCode:"+261",isoCode:"MG"},{name:"Malawi",dialCode:"+265",isoCode:"MW"},{name:"Malaysia",dialCode:"+60",isoCode:"MY"},{name:"Maldives",dialCode:"+960",isoCode:"MV"},{name:"Mali",dialCode:"+223",isoCode:"ML"},{name:"Malta",dialCode:"+356",isoCode:"MT"},{name:"Marshall Islands",dialCode:"+692",isoCode:"MH"},{name:"Martinique",dialCode:"+596",isoCode:"MQ"},{name:"Mauritania",dialCode:"+222",isoCode:"MR"},{name:"Mauritius",dialCode:"+230",isoCode:"MU"},{name:"Mayotte",dialCode:"+262",isoCode:"YT"},{name:"Mexico",dialCode:"+52",isoCode:"MX"},{name:"Micronesia, Federated States of Micronesia",dialCode:"+691",isoCode:"FM"},{name:"Moldova",dialCode:"+373",isoCode:"MD"},{name:"Monaco",dialCode:"+377",isoCode:"MC"},{name:"Mongolia",dialCode:"+976",isoCode:"MN"},{name:"Montenegro",dialCode:"+382",isoCode:"ME"},{name:"Montserrat",dialCode:"+1664",isoCode:"MS"},{name:"Morocco",dialCode:"+212",isoCode:"MA"},{name:"Mozambique",dialCode:"+258",isoCode:"MZ"},{name:"Myanmar",dialCode:"+95",isoCode:"MM"},{name:"Namibia",dialCode:"+264",isoCode:"NA"},{name:"Nauru",dialCode:"+674",isoCode:"NR"},{name:"Nepal",dialCode:"+977",isoCode:"NP"},{name:"Netherlands",dialCode:"+31",isoCode:"NL"},{name:"Netherlands Antilles",dialCode:"+599",isoCode:"AN"},{name:"New Caledonia",dialCode:"+687",isoCode:"NC"},{name:"New Zealand",dialCode:"+64",isoCode:"NZ"},{name:"Nicaragua",dialCode:"+505",isoCode:"NI"},{name:"Niger",dialCode:"+227",isoCode:"NE"},{name:"Nigeria",dialCode:"+234",isoCode:"NG"},{name:"Niue",dialCode:"+683",isoCode:"NU"},{name:"Norfolk Island",dialCode:"+672",isoCode:"NF"},{name:"North Macedonia",dialCode:"+389",isoCode:"MK"},{name:"Northern Mariana Islands",dialCode:"+1670",isoCode:"MP"},{name:"Norway",dialCode:"+47",isoCode:"NO"},{name:"Oman",dialCode:"+968",isoCode:"OM"},{name:"Pakistan",dialCode:"+92",isoCode:"PK"},{name:"Palau",dialCode:"+680",isoCode:"PW"},{name:"Palestine",dialCode:"+970",isoCode:"PS"}
1,{name:"Panama",dialCode:"+507",isoCode:"PA"},{name:"Papua New Guinea",dialCode:"+675",isoCode:"PG"},{name:"Paraguay",dialCode:"+595",isoCode:"PY"},{name:"Peru",dialCode:"+51",isoCode:"PE"},{name:"Philippines",dialCode:"+63",isoCode:"PH"},{name:"Pitcairn",dialCode:"+872",isoCode:"PN"},{name:"Poland",dialCode:"+48",isoCode:"PL"},{name:"Portugal",dialCode:"+351",isoCode:"PT"},{name:"Puerto Rico",dialCode:"+1939",isoCode:"PR"},{name:"Qatar",dialCode:"+974",isoCode:"QA"},{name:"Reunion",dialCode:"+262",isoCode:"RE"},{name:"Romania",dialCode:"+40",isoCode:"RO"},{name:"Russia",dialCode:"+7",isoCode:"RU"},{name:"Rwanda",dialCode:"+250",isoCode:"RW"},{name:"Saint Barthelemy",dialCode:"+590",isoCode:"BL"},{name:"Saint Helena, Ascension and Tristan Da Cunha",dialCode:"+290",isoCode:"SH"},{name:"Saint Kitts and Nevis",dialCode:"+1869",isoCode:"KN"},{name:"Saint Lucia",dialCode:"+1758",isoCode:"LC"},{name:"Saint Martin",dialCode:"+590",isoCode:"MF"},{name:"Saint Pierre and Miquelon",dialCode:"+508",isoCode:"PM"},{name:"Saint Vincent and the Grenadines",dialCode:"+1784",isoCode:"VC"},{name:"Samoa",dialCode:"+685",isoCode:"WS"},{name:"San Marino",dialCode:"+378",isoCode:"SM"},{name:"Sao Tome and Principe",dialCode:"+239",isoCode:"ST"},{name:"Saudi Arabia",dialCode:"+966",isoCode:"SA"},{name:"Senegal",dialCode:"+221",isoCode:"SN"},{name:"Serbia",dialCode:"+381",isoCode:"RS"},{name:"Seychelles",dialCode:"+248",isoCode:"SC"},{name:"Sierra Leone",dialCode:"+232",isoCode:"SL"},{name:"Singapore",dialCode:"+65",isoCode:"SG"},{name:"Sint Maarten",dialCode:"+1721",isoCode:"SX"},{name:"Slovakia",dialCode:"+421",isoCode:"SK"},{name:"Slovenia",dialCode:"+386",isoCode:"SI"},{name:"Solomon Islands",dialCode:"+677",isoCode:"SB"},{name:"Somalia",dialCode:"+252",isoCode:"SO"},{name:"South Africa",dialCode:"+27",isoCode:"ZA"},{name:"South Georgia and the South Sandwich Islands",dialCode:"+500",isoCode:"GS"},{name:"South Sudan",dialCode:"+211",isoCode:"SS"},{name:"Spain",dialCode:"+34",isoCode:"ES"},{name:"Sri Lanka",dialCode:"+94",isoCode:"LK"},{name:"Sudan",dialCode:"+249",isoCode:"SD"},{name:"Suriname",dialCode:"+597",isoCode:"SR"},{name:"Svalbard and Jan Mayen",dialCode:"+47",isoCode:"SJ"},{name:"Sweden",dialCode:"+46",isoCode:"SE"},{name:"Switzerland",dialCode:"+41",isoCode:"CH"},{name:"Syrian Arab Republic",dialCode:"+963",isoCode:"SY"},{name:"Taiwan",dialCode:"+886",isoCode:"TW"},{name:"Tajikistan",dialCode:"+992",isoCode:"TJ"},{name:"Tanzania, United Republic of Tanzania",dialCode:"+255",isoCode:"TZ"},{name:"Thailand",dialCode:"+66",isoCode:"TH"},{name:"Timor-Leste",dialCode:"+670",isoCode:"TL"},{name:"Togo",dialCode:"+228",isoCode:"TG"},{name:"Tokelau",dialCode:"+690",isoCode:"TK"},{name:"Tonga",dialCode:"+676",isoCode:"TO"},{name:"Trinidad and Tobago",dialCode:"+1868",isoCode:"TT"},{name:"Tunisia",dialCode:"+216",isoCode:"TN"},{name:"Turkey",dialCode:"+90",isoCode:"TR"},{name:"Turkmenistan",dialCode:"+993",isoCode:"TM"},{name:"Turks and Caicos Islands",dialCode:"+1649",isoCode:"TC"},{name:"Tuvalu",dialCode:"+688",isoCode:"TV"},{name:"Uganda",dialCode:"+256",isoCode:"UG"},{name:"Ukraine",dialCode:"+380",isoCode:"UA"},{name:"United Arab Emirates",dialCode:"+971",isoCode:"AE"},{name:"United Kingdom",dialCode:"+44",isoCode:"GB"},{name:"United States",dialCode:"+1",isoCode:"US"},{name:"Uruguay",dialCode:"+598",isoCode:"UY"},{name:"Uzbekistan",dialCode:"+998",isoCode:"UZ"},{name:"Vanuatu",dialCode:"+678",isoCode:"VU"},{name:"Venezuela, Bolivarian Republic of Venezuela",dialCode:"+58",isoCode:"VE"},{name:"Vietnam",dialCode:"+84",isoCode:"VN"},{name:"Virgin Islands, British",dialCode:"+1284",isoCode:"VG"},{name:"Virgin Islands, U.S.",dialCode:"+1340",isoCode:"VI"},{name:"Wallis and Futuna",dialCode:"+681",isoCode:"WF"},{name:"Yemen",dialCode:"+967",isoCode:"YE"},{name:"Zambia",dialCode:"+260",isoCode:"ZM"},{name:"Zimbabwe",dialCode:"+263",isoCode:"ZW"}]},802:e=>{e.exports={timeZones:[{label:"International Date Line West (Etc/GMT+12)",value:"-12:00"},{label:"Midway Island, Samoa (Pacific/Midway)",value:"-11:00"},{label:"Hawaii (Pacific/Honolulu)",value:"-10:00"},{label:"Alaska (US/Alaska)",value:"-09:00"},{label:"Pacific Time (US & Canada) (America/Los_Angeles)",value:"-08:00"},{label:"Tijuana, Baja California (America/Tijuana)",value:"-08:00"},{label:"Arizona (US/Arizona)",value:"-07:00"},{label:"Chihuahua, La Paz, Mazatlan (America/Chihuahua)",value:"-07:00"},{label:"Mountain Time (US & Canada) (US/Mountain)",value:"-07:00"},{label:"Central America (America/Managua)",value:"-06:00"},{label:"Central Time (US & Canada) (US/Central)",value:"-06:00"},{label:"Guadalajara, Mexico City, Monterrey (America/Mexico_City)",value:"-06:00"},{label:"Saskatchewan (Canada/Saskatchewan)",value:"-06:00"},{label:"Bogota, Lima, Quito, Rio Branco (America/Bogota)",value:"-05:00"},{label:"Eastern Time (US & Canada) (US/Eastern)",value:"-05:00"},{label:"Indiana (East) (US/East-Indiana)",value:"-05:00"}
1,{label:"Atlantic Time (Canada) (Canada/Atlantic)",value:"-04:00"},{label:"Caracas, La Paz (America/Caracas)",value:"-04:00"},{label:"Manaus (America/Manaus)",value:"-04:00"},{label:"Santiago (America/Santiago)",value:"-04:00"},{label:"Newfoundland (Canada/Newfoundland)",value:"-03:30"},{label:"Brasilia (America/Sao_Paulo)",value:"-03:00"},{label:"Buenos Aires, Georgetown (America/Argentina/Buenos_Aires)",value:"-03:00"},{label:"Greenland (America/Godthab)",value:"-03:00"},{label:"Montevideo (America/Montevideo)",value:"-03:00"},{label:"Mid-Atlantic (America/Noronha)",value:"-02:00"},{label:"Cape Verde Is. (Atlantic/Cape_Verde)",value:"-01:00"},{label:"Azores (Atlantic/Azores)",value:"-01:00"},{label:"Casablanca, Monrovia, Reykjavik (Africa/Casablanca)",value:"+00:00"},{label:"Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London (Etc/Greenwich)",value:"+00:00"},{label:"Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna (Europe/Amsterdam)",value:"+01:00"},{label:"Belgrade, Bratislava, Budapest, Ljubljana, Prague (Europe/Belgrade)",value:"+01:00"},{label:"Brussels, Copenhagen, Madrid, Paris (Europe/Brussels)",value:"+01:00"},{label:"Sarajevo, Skopje, Warsaw, Zagreb (Europe/Sarajevo)",value:"+01:00"},{label:"West Central Africa (Africa/Lagos)",value:"+01:00"},{label:"Amman (Asia/Amman)",value:"+02:00"},{label:"Athens, Bucharest, Istanbul (Europe/Athens)",value:"+02:00"},{label:"Beirut (Asia/Beirut)",value:"+02:00"},{label:"Cairo (Africa/Cairo)",value:"+02:00"},{label:"Harare, Pretoria (Africa/Harare)",value:"+02:00"},{label:"Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius (Europe/Helsinki)",value:"+02:00"},{label:"Jerusalem (Asia/Jerusalem)",value:"+02:00"},{label:"Minsk (Europe/Minsk)",value:"+02:00"},{label:"Windhoek (Africa/Windhoek)",value:"+02:00"},{label:"Kuwait, Riyadh, Baghdad (Asia/Kuwait)",value:"+03:00"},{label:"Moscow, St. Petersburg, Volgograd (Europe/Moscow)",value:"+03:00"},{label:"Nairobi (Africa/Nairobi)",value:"+03:00"},{label:"Tbilisi (Asia/Tbilisi)",value:"+03:00"},{label:"Tehran (Asia/Tehran)",value:"+03:30"},{label:"Abu Dhabi, Muscat (Asia/Muscat)",value:"+04:00"},{label:"Baku (Asia/Baku)",value:"+04:00"},{label:"Yerevan (Asia/Yerevan)",value:"+04:00"},{label:"Kabul (Asia/Kabul)",value:"+04:30"},{label:"Yekaterinburg (Asia/Yekaterinburg)",value:"+05:00"},{label:"Islamabad, Karachi, Tashkent (Asia/Karachi)",value:"+05:00"},{label:"Chennai, Kolkata, Mumbai, New Delhi (Asia/Calcutta)",value:"+05:30"},{label:"Kathmandu (Asia/Katmandu)",value:"+05:45"},{label:"Almaty, Novosibirsk (Asia/Almaty)",value:"+06:00"},{label:"Astana, Dhaka (Asia/Dhaka)",value:"+06:00"},{label:"Yangon (Rangoon) (Asia/Rangoon)",value:"+06:30"},{label:"Bangkok, Hanoi, Jakarta (Asia/Bangkok)",value:"+07:00"},{label:"Krasnoyarsk (Asia/Krasnoyarsk)",value:"+07:00"},{label:"Beijing, Chongqing, Hong Kong, Urumqi (Asia/Hong_Kong)",value:"+08:00"},{label:"Kuala Lumpur, Singapore (Asia/Kuala_Lumpur)",value:"+08:00"},{label:"Irkutsk, Ulaan Bataar (Asia/Irkutsk)",value:"+08:00"},{label:"Perth (Australia/Perth)",value:"+08:00"},{label:"Taipei (Asia/Taipei)",value:"+08:00"},{label:"Osaka, Sapporo, Tokyo (Asia/Tokyo)",value:"+09:00"},{label:"Seoul (Asia/Seoul)",value:"+09:00"},{label:"Yakutsk (Asia/Yakutsk)",value:"+09:00"},{label:"Adelaide (Australia/Adelaide)",value:"+09:30"},{label:"Darwin (Australia/Darwin)",value:"+09:30"},{label:"Brisbane (Australia/Brisbane)",value:"+10:00"},{label:"Canberra, Melbourne, Sydney (Australia/Canberra)",value:"+10:00"},{label:"Hobart (Australia/Hobart)",value:"+10:00"},{label:"Guam, Port Moresby (Pacific/Guam)",value:"+10:00"},{label:"Vladivostok (Asia/Vladivostok)",value:"+10:00"},{label:"Magadan, Solomon Is., New Caledonia (Asia/Magadan)",value:"+11:00"},{label:"Auckland, Wellington (Pacific/Auckland)",value:"+12:00"},{label:"Fiji, Kamchatka, Marshall Is. (Pacific/Fiji)",value:"+12:00"},{label:"Nuku'alofa (Pacific/Tongatapu)",value:"+13:00"}]}},64128:e=>{e.exports={V3_PLANS:{BASIC_TRIAL:{displayName:"FREE TRIAL",frequency:"two-weekly",totalContact:2e3,templateCredit:{INR:5e6,USD:1e5},planPrice:{INR:0,USD:0},pricePerContact:{INR:0,USD:0},chargebeeId:{INR:"Basic-Trial-INR-Every-2-weeks",USD:"Basic-Trial-USD-Every-2-weeks"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_MONTHLY_TIER_1:{displayName:"BASIC",frequency:"monthly",totalContact:2e3,planPrice:{INR:999e5,USD:2e6},pricePerContact:{INR:37500,USD:0},chargebeeId:{INR:"Basic-v1-INR-Monthly",USD:"Basic-v1-USD-Monthly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_MONTHLY_TIER_2:{displayName:"BASIC",frequency:"monthly",totalContact:5e3,planPrice:{INR:275e6,USD:55e5},pricePerContact:{INR:55e3,USD:0},chargebeeId:{INR:"Basic-v1-INR-Monthly",USD:"Basic-v1-USD-Monthly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_MONTHLY_TIER_3:{displayName:"BASIC",frequency:"monthly",totalContact:1e4,planPrice:{INR:55e7,USD:11e6},pricePerContact:{INR:55e3,USD:0},chargebeeId:{INR:"Basic-v1-INR-Monthly",USD:"Basic-v1-USD-Monthly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_MONTHLY_TIER_4:{displayName:"BASIC",frequency:"monthly",totalContact:2e4,planPrice:{INR:1e9,USD:2e7},pricePerContact:{INR:5e4,USD:0},chargebeeId:{INR:"Basic-v1-INR-Monthly",USD:"Basic-v1-USD-Monthly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_MONTHLY_TIER_5:{displayName:"BASIC",frequency:"monthly",totalContact:3e4,planPrice:{INR:15e8,USD:3e7},pricePerContact:{INR:5e4,USD:0},chargebeeId:{INR:"Basic-v1-INR-Monthly",USD:"Basic-v1-USD-Monthly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_MONTHLY_TIER_6:{displayName:"BASIC",frequency:"monthly",totalContact:4e4,planPrice:{INR:18e8,USD:36e6},pricePerContact:{INR:45e3,USD:0},chargebeeId:{INR:"Basic-v1-INR-Monthly",USD:"Basic-v1-USD-Monthly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_MONTHLY_TIER_7:{displayName:"BASIC",frequency:"monthly",totalContact:5e4,planPrice:{INR:225e7,USD:45e6},pricePerContact:{INR:45e3,USD:0},chargebeeId:{INR:"Basic-v1-INR-Monthly",USD:"Basic-v1-USD-Monthly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_MONTHLY_TIER_8:{displayName:"BASIC",frequency:"monthly",totalContact:75e3,planPrice:{INR:3375e6,USD:675e5},pricePerContact:{INR:45e3,USD:0},chargebeeId:{INR:"Basic-v1-INR-Monthly",USD:"Basic-v1-USD-Monthly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_MONTHLY_TIER_9:{displayName:"BASIC",frequency:"monthly",totalContact:1e5,planPrice:{INR:45e8,USD:9e7},pricePerContact:{INR:45e3,USD:0},chargebeeId:{INR:"Basic-v1-INR-Monthly",USD:"Basic-v1-USD-Monthly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_YEARLY_TIER_1:{displayName:"BASIC",frequency:"yearly",totalContact:24e3,monthlyContact:2e3,planPrice:{INR:10789e5,USD:216e5},pricePerContact:{INR:539450,USD:0},chargebeeId:{INR:"Basic-Yr-INR-Yearly",USD:"Basic-Yr-USD-Yearly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_YEARLY_TIER_2:{displayName:"BASIC",frequency:"yearly",totalContact:6e4,monthlyContact:5e3,planPrice:{INR:297e7,USD:594e5},pricePerContact:{INR:594e3,USD:0},chargebeeId:{INR:"Basic-Yr-INR-Yearly",USD:"Basic-Yr-USD-Yearly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_YEARLY_TIER_3:{displayName:"BASIC",frequency:"yearly",totalContact:12e4,monthlyContact:1e4,planPrice:{INR:594e7,USD:1188e5},pricePerContact:{INR:594e3,USD:0},chargebeeId:{INR:"Basic-Yr-INR-Yearly",USD:"Basic-Yr-USD-Yearly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_YEARLY_TIER_4:{displayName:"BASIC",frequency:"yearly",totalContact:24e4,monthlyContact:2e4,planPrice:{INR:108e8,USD:216e6},pricePerContact:{INR:54e4,USD:0},chargebeeId:{INR:"Basic-Yr-INR-Yearly",USD:"Basic-Yr-USD-Yearly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_YEARLY_TIER_5:{displayName:"BASIC",frequency:"yearly",totalContact:36e4,monthlyContact:3e4,planPrice:{INR:162e8,USD:324e6},pricePerContact:{INR:54e4,USD:0},chargebeeId:{INR:"Basic-Yr-INR-Yearly",USD:"Basic-Yr-USD-Yearly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_YEARLY_TIER_6:{displayName:"BASIC",frequency:"yearly",totalContact:48e4,monthlyContact:4e4,planPrice:{INR:1944e7,USD:3888e5},pricePerContact:{INR:54e4,USD:0},chargebeeId:{INR:"Basic-Yr-INR-Yearly",USD:"Basic-Yr-USD-Yearly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_YEARLY_TIER_7:{displayName:"BASIC",frequency:"yearly",totalContact:6e5,monthlyContact:5e4,planPrice:{INR:243e8,USD:486e6},pricePerContact:{INR:54e4,USD:0},chargebeeId:{INR:"Basic-Yr-INR-Yearly",USD:"Basic-Yr-USD-Yearly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_YEARLY_TIER_8:{displayName:"BASIC",frequency:"yearly",totalContact:9e5,monthlyContact:75e3,planPrice:{INR:3645e7,USD:729e6},pricePerContact:{INR:54e4,USD:0},chargebeeId:{INR:"Basic-Yr-INR-Yearly",USD:"Basic-Yr-USD-Yearly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}},BASIC_YEARLY_TIER_9:{displayName:"BASIC",frequency:"yearly",totalContact:12e5,monthlyContact:1e5,planPrice:{INR:486e8,USD:972e6},pricePerContact:{INR:54e4,USD:0},chargebeeId:{INR:"Basic-Yr-INR-Yearly",USD:"Basic-Yr-USD-Yearly"},surchargeBlockCost:{INR:75e6,USD:15e5},waSessionMargin:{INR:0,USD:0}}},ADDITIONAL_MAC:{INR:{chargebeeId:"Additional-MAC-v3-INR-Monthly",perBlockCost:75e6,MAU:1e3},USD:{chargebeeId:"Additional-MAC-v3-USD-Monthly",perBlockCost:15e5,MAU:1e3}},TEMPLATE_CREDITS:{INR:{chargebeeId:"Template-Credits-INR",perUnitCost:1e5},USD:{chargebeeId:"Template-Credits-USD",perUnitCost:1e5}}}},90175:e=>{const t={"AI-Messages-3.5k":3500,"AI-Messages-100k":1e5,"AI-Messages-10k":1e4,"AI-Messages-25k":25e3,"AI-Messages-50k":5e4,"AI-Messages-7k":7e3,"AI-Messages-15k":15e3,"AI-Messages-30k":3e4},a=["PREMIUM_MONTHLY","PREMIUM_QUARTERLY","PREMIUM_YEARLY"],n=["UNLIMITED_MONTHLY","UNLIMITED_QUART
1ERLY","UNLIMITED_YEARLY"];e.exports={V4_PLANS:{BASIC_TRIAL:{displayName:"BASIC TRIAL",frequency:"monthly",planPrice:{INR:15e7,USD:45e5},chargebeeId:{INR:"Basic-Unlimited-INR-Monthly",USD:"Basic-Unlimited-USD-Monthly"},totalContact:1},BASIC_MONTHLY:{displayName:"BASIC",frequency:"monthly",planPrice:{INR:15e7,USD:45e5},chargebeeId:{INR:"Basic-Unlimited-INR-Monthly",USD:"Basic-Unlimited-USD-Monthly"},totalContact:1},BASIC_DIWALI_MONTHLY:{displayName:"BASIC DIWALI",frequency:"monthly",planPrice:{INR:849e5,USD:18e5},chargebeeId:{INR:"Basic-Diwali-Unlimited-INR-Monthly",USD:"Basic-Diwali-Unlimited-USD-Monthly"},totalContact:1},PRO_MONTHLY:{displayName:"PRO",frequency:"monthly",planPrice:{INR:32e7,USD:99e5},chargebeeId:{INR:"Pro-Unlimited-INR-Monthly",USD:"Pro-Unlimited-USD-Monthly"},totalContact:1},ENTERPRISE_MONTHLY:{displayName:"ENTERPRISE",frequency:"monthly",planPrice:{INR:999e5,USD:2e6},chargebeeId:{INR:"Enterprise-Unlimited-INR-Monthly",USD:"Enterprise-Unlimited-USD-Monthly"},totalContact:1},BASIC_QUARTERLY:{displayName:"BASIC",frequency:"quarterly",planPrice:{INR:4275e5,USD:12825e3},chargebeeId:{INR:"Basic-Unlimited-INR-Every-3-months",USD:"Basic-Unlimited-USD-Every-3-months"},totalContact:1},BASIC_DIWALI_QUARTERLY:{displayName:"BASIC DIWALI",frequency:"quarterly",planPrice:{INR:241965e3,USD:513e4},chargebeeId:{INR:"Basic-Diwali-Unlimited-INR-Every-3-months",USD:"Basic-Diwali-Unlimited-USD-Every-3-months"},totalContact:1},PRO_QUARTERLY:{displayName:"PRO",frequency:"quarterly",planPrice:{INR:912e6,USD:28215e3},chargebeeId:{INR:"Pro-Unlimited-INR-Every-3-months",USD:"Pro-Unlimited-USD-Every-3-months"},totalContact:1},ENTERPRISE_QUARTERLY:{displayName:"ENTERPRISE",frequency:"quarterly",planPrice:{INR:999e5,USD:2e6},chargebeeId:{INR:"Enterprise-Unlimited-INR-Every-3-months",USD:"Enterprise-Unlimited-USD-Every-3-months"},totalContact:1},BASIC_YEARLY:{displayName:"BASIC",frequency:"yearly",planPrice:{INR:162e7,USD:486e5},chargebeeId:{INR:"Basic-Unlimited-INR-Yearly",USD:"Basic-Unlimited-USD-Yearly"},totalContact:1},BASIC_DIWALI_YEARLY:{displayName:"BASIC DIWALI",frequency:"yearly",planPrice:{INR:8991e5,USD:2e7},chargebeeId:{INR:"Basic-Diwali-Unlimited-INR-Yearly",USD:"Basic-Diwali-Unlimited-USD-Yearly"},totalContact:1},PRO_YEARLY:{displayName:"PRO",frequency:"yearly",planPrice:{INR:3456e6,USD:10692e4},chargebeeId:{INR:"Pro-Unlimited-INR-Yearly",USD:"Pro-Unlimited-USD-Yearly"},totalContact:1},ENTERPRISE_YEARLY:{displayName:"ENTERPRISE",frequency:"yearly",planPrice:{INR:10789e5,USD:216e5},chargebeeId:{INR:"Enterprise-Unlimited-INR-Yearly",USD:"Enterprise-Unlimited-USD-Yearly"},totalContact:1},PREMIUM_MONTHLY:{displayName:"PREMIUM",frequency:"monthly",planPrice:{INR:91e7,USD:299e5},chargebeeId:{INR:"Premium-INR-Monthly",USD:"Premium-USD-Monthly"},totalContact:1},PREMIUM_QUARTERLY:{displayName:"PREMIUM",frequency:"quarterly",planPrice:{INR:25935e5,USD:85215e3},chargebeeId:{INR:"Premium-INR-Every-3-months",USD:"Premium-USD-Every-3-months"},totalContact:1},PREMIUM_YEARLY:{displayName:"PREMIUM",frequency:"yearly",planPrice:{INR:9828e6,USD:32292e4},chargebeeId:{INR:"Premium-INR-Yearly",USD:"Premium-USD-Yearly"},totalContact:1},UNLIMITED_MONTHLY:{displayName:"UNLIMITED",frequency:"monthly",planPrice:{INR:45e8,USD:899e5},chargebeeId:{INR:"Unlimited-INR-Monthly",USD:"Unlimited-USD-Monthly"},totalContact:1},UNLIMITED_QUARTERLY:{displayName:"UNLIMITED",frequency:"quarterly",planPrice:{INR:12825e6,USD:256215e3},chargebeeId:{INR:"Unlimited-INR-Every-3-months",USD:"Unlimited-USD-Every-3-months"},totalContact:1},UNLIMITED_YEARLY:{displayName:"UNLIMITED",frequency:"yearly",planPrice:{INR:486e8,USD:97092e4},chargebeeId:{INR:"Unlimited-INR-Yearly",USD:"Unlimited-USD-Yearly"},totalContact:1},CHAT_BOT_BUILDER_MONTHLY:{displayName:"CHAT BOT BUILDER",frequency:"month",planPrice:{INR:25e7,USD:8e6},chargebeeId:{INR:"Flows-Add-On-5-Flows-INR-Monthly",USD:"Flows-Add-On-5-Flows-USD-Monthly"},minimumFlowCount:5},CHAT_BOT_BUILDER_QUARTERLY:{displayName:"CHAT BOT BUILDER",frequency:"quarter",planPrice:{INR:7125e5,USD:228e5},chargebeeId:{INR:"Flows-Add-On-5-Flows-INR-Every-3-months",USD:"Flows-Add-On-5-Flows-USD-Every-3-months"},minimumFlowCount:5},CHAT_BOT_BUILDER_YEARLY:{displayName:"CHAT BOT BUILDER",frequency:"year",planPrice:{INR:27e8,USD:864e5},chargebeeId:{INR:"Flows-Add-On-5-Flows-INR-Yearly",USD:"Flows-Add-On-5-Flows-USD-Yearly"},minimumFlowCount:5},DISCOUNT_CHAT_BOT_BUILDER_MONTHLY:{displayName:"CHAT BOT BUILDER",frequency:"month",planPrice:{INR:25e7,USD:8e6},chargebeeId:{INR:"Discount-Flows-Add-On-10-Flows-INR-Monthly",USD:"Discount-Flows-Add-On-10-Flows-USD-Monthly"},minimumFlowCount:10},DISCOUNT_CHAT_BOT_BUILDER_QUARTERLY:{displayName:"CHAT BOT BUILDER",frequency:"quarter",planPrice:{INR:7125e5,USD:228e5},chargebeeId:{INR:"Discount-Flows-Add-On-10-Flows-INR-Every-3-months",USD:"Discount-Flows-Add-On-10-Flows-USD-Every-3-months"},minimumFlowCount:10},DISCOUNT_CHAT_BOT_BUILDER_YEARLY:{displayName:"CHAT BOT BUILDER",frequency:"year",planPrice:{INR:27e8,USD:864e5},chargebeeId:{INR:"Discount-Flows-Add-On-10-Flows-INR-Yearly",USD:"Discount-Flows-Add-On-10-Flows-USD-Yearly"},minimumFlowCount:10},FREE_FOREVER:{displayName:"FREE FOREVER",frequency:"monthly",planPrice:{INR:0,USD:0},chargebeeId:{INR:"Free-Forever-INR-Monthly",USD:"Free-Forever-USD-Monthly"},totalContact:1},BUY_AGENTS_MONTHLY:{displayName:"Buy Agent",frequency:"monthly",planPrice:{INR:75e6,USD:2e6},chargebeeId:{INR:"Buy-Agent-INR-Monthly",USD:"Buy-Agent-USD-Monthly"},minimumAgentCount:1}
1,BUY_AGENTS_QUARTERLY:{displayName:"Buy Agent",frequency:"quarter",planPrice:{INR:21375e4,USD:57e5},chargebeeId:{INR:"Buy-Agent-INR-Every-3-months",USD:"Buy-Agent-USD-Every-3-months"},minimumAgentCount:1},BUY_AGENTS_YEARLY:{displayName:"Buy Agent",frequency:"year",planPrice:{INR:81e7,USD:216e5},chargebeeId:{INR:"Buy-Agent-INR-Yearly",USD:"Buy-Agent-USD-Yearly"},minimumAgentCount:1},AI_CONVERSATIONS_MONTHLY:{displayName:"AI CONVERSATIONS",frequency:"monthly",planPrice:{INR:35e4,USD:9900},chargebeeId:{INR:"AI-conversations-add-on-INR-Monthly",USD:"AI-conversations-add-on-USD-Monthly"},totalContact:1},AI_CONVERSATIONS_QUARTERLY:{displayName:"AI CONVERSATIONS",frequency:"quarterly",planPrice:{INR:105e4,USD:29700},chargebeeId:{INR:"AI-conversations-add-on-INR-Every-3-months",USD:"AI-conversations-add-on-USD-Every-3-months"},totalContact:1},AI_CONVERSATIONS_YEARLY:{displayName:"AI CONVERSATIONS",frequency:"yearly",planPrice:{INR:42e5,USD:118800},chargebeeId:{INR:"AI-conversations-add-on-INR-Yearly",USD:"AI-conversations-add-on-USD-Yearly"},totalContact:1},AUTOMATION_LITE_MONTHLY:{displayName:"AUTOMATION LITE",frequency:"monthly",planPrice:{INR:59238},chargebeeId:{INR:"Automation-Lite-INR-Monthly"},totalContact:1},AUTOMATION_LITE_QUARTERLY:{displayName:"AUTOMATION LITE",frequency:"quarterly",planPrice:{INR:169068},chargebeeId:{INR:"Automation-Lite-INR-Every-3-months"},totalContact:1},AUTOMATION_LITE_YEARLY:{displayName:"AUTOMATION LITE",frequency:"yearly",planPrice:{INR:639915},chargebeeId:{INR:"Automation-Lite-INR-Yearly"},totalContact:1},"AI_MESSAGES_3.5K_MONTHLY":{displayName:"AI MESSAGES 3.5K",frequency:"monthly",planPrice:{INR:35e7,USD:99e5},chargebeeId:{INR:"AI-Messages-3.5k-INR-Monthly",USD:"AI-Messages-3.5k-USD-Monthly"},totalContact:1},"AI_MESSAGES_3.5K_QUARTERLY":{displayName:"AI MESSAGES 3.5K",frequency:"quarterly",planPrice:{INR:9975e5,USD:28215e3},chargebeeId:{INR:"AI-Messages-3.5k-INR-Every-3-months",USD:"AI-Messages-3.5k-USD-Every-3-months"},totalContact:1},"AI_MESSAGES_3.5K_YEARLY":{displayName:"AI MESSAGES 3.5K",frequency:"yearly",planPrice:{INR:378e7,USD:10692e4},chargebeeId:{INR:"AI-Messages-3.5k-INR-Yearly",USD:"AI-Messages-3.5k-USD-Yearly"},totalContact:1},AI_MESSAGES_10K_MONTHLY:{displayName:"AI MESSAGES 10K",frequency:"monthly",planPrice:{INR:97e7,USD:275e5},chargebeeId:{INR:"AI-Messages-10k-INR-Monthly",USD:"AI-Messages-10k-USD-Monthly"},totalContact:1},AI_MESSAGES_10K_QUARTERLY:{displayName:"AI MESSAGES 10K",frequency:"quarterly",planPrice:{INR:27645e5,USD:78375e3},chargebeeId:{INR:"AI-Messages-10k-INR-Every-3-months",USD:"AI-Messages-10k-USD-Every-3-months"},totalContact:1},AI_MESSAGES_10K_YEARLY:{displayName:"AI MESSAGES 10K",frequency:"yearly",planPrice:{INR:10476e6,USD:297e6},chargebeeId:{INR:"AI-Messages-10k-INR-Yearly",USD:"AI-Messages-10k-USD-Yearly"},totalContact:1},AI_MESSAGES_25K_MONTHLY:{displayName:"AI MESSAGES 25K",frequency:"monthly",planPrice:{INR:2375e6,USD:669e5},chargebeeId:{INR:"AI-Messages-25k-INR-Monthly",USD:"AI-Messages-25k-USD-Monthly"},totalContact:1},AI_MESSAGES_25K_QUARTERLY:{displayName:"AI MESSAGES 25K",frequency:"quarterly",planPrice:{INR:676875e4,USD:190665e3},chargebeeId:{INR:"AI-Messages-25k-INR-Every-3-months",USD:"AI-Messages-25k-USD-Every-3-months"},totalContact:1},AI_MESSAGES_25K_YEARLY:{displayName:"AI MESSAGES 25K",frequency:"yearly",planPrice:{INR:2565e7,USD:72252e4},chargebeeId:{INR:"AI-Messages-25k-INR-Yearly",USD:"AI-Messages-25k-USD-Yearly"},totalContact:1},AI_MESSAGES_7K_MONTHLY:{displayName:"AI MESSAGES 7K",frequency:"monthly",planPrice:{INR:35e7,USD:99e5},chargebeeId:{INR:"AI-Messages-7k-INR-Monthly",USD:"AI-Messages-7k-USD-Monthly"},totalContact:1},AI_MESSAGES_7K_QUARTERLY:{displayName:"AI MESSAGES 7K",frequency:"quarterly",planPrice:{INR:9975e5,USD:28215e3},chargebeeId:{INR:"AI-Messages-7k-INR-Every-3-months",USD:"AI-Messages-7k-USD-Every-3-months"},totalContact:1},AI_MESSAGES_7K_YEARLY:{displayName:"AI MESSAGES 7K",frequency:"yearly",planPrice:{INR:378e7,USD:10692e4},chargebeeId:{INR:"AI-Messages-7k-INR-Yearly",USD:"AI-Messages-7k-USD-Yearly"},totalContact:1},AI_MESSAGES_15K_MONTHLY:{displayName:"AI MESSAGES 15K",frequency:"monthly",planPrice:{INR:675e6,USD:19e6},chargebeeId:{INR:"AI-Messages-15k-INR-Monthly",USD:"AI-Messages-15k-USD-Monthly"},totalContact:1},AI_MESSAGES_15K_QUARTERLY:{displayName:"AI MESSAGES 15K",frequency:"quarterly",planPrice:{INR:192375e4,USD:5415e4},chargebeeId:{INR:"AI-Messages-15k-INR-Every-3-months",USD:"AI-Messages-15k-USD-Every-3-months"},totalContact:1},AI_MESSAGES_15K_YEARLY:{displayName:"AI MESSAGES 15K",frequency:"yearly",planPrice:{INR:729e7,USD:2052e5},chargebeeId:{INR:"AI-Messages-15k-INR-Yearly",USD:"AI-Messages-15k-USD-Yearly"},totalContact:1},AI_MESSAGES_30K_MONTHLY:{displayName:"AI MESSAGES 30K",frequency:"monthly",planPrice:{INR:126e7,USD:339e5},chargebeeId:{INR:"AI-Messages-30k-INR-Monthly",USD:"AI-Messages-30k-USD-Monthly"},totalContact:1},AI_MESSAGES_30K_QUARTERLY:{displayName:"AI MESSAGES 30K",frequency:"quarterly",planPrice:{INR:3591e6,USD:96615e3},chargebeeId:{INR:"AI-Messages-30k-INR-Every-3-months",USD:"AI-Messages-30k-USD-Every-3-months"},totalContact:1},AI_MESSAGES_30K_YEARLY:{displayName:"AI MESSAGES 30K",frequency:"yearly",planPrice:{INR:13608e6,USD:36612e4},chargebeeId:{INR:"AI-Messages-30k-INR-Yearly",USD:"AI-Messages-30k-USD-Yearly"},totalContact:1},AI_MESSAGES_50K_MONTHLY:{displayName:"AI MESSAGES 50K",frequency:"monthly",planPrice:{INR:46e8,USD:1299e5},chargebeeId:{INR:"AI-Messages-50k-INR-Monthly",USD:"AI-Messages-50k-USD-Monthly"},totalContact:1},AI_MESSAGES_50K_QUARTERLY:{displayName:"AI MESSAGES 50K",frequency:"quarterly",planPrice:{INR:1311e7,USD:370215e3},chargebeeId:{INR:"AI-Messages-50k-INR-Every-3-months",USD:"AI-Messages-50k-USD-Every-3-months"},totalContact:1},AI_MESSAGES_50K_YEARLY:{displayName:"AI MESSAGES 50K",frequency:"yearly",planPrice:{INR:4968e7,USD:140292e4},chargebeeId:{INR:"AI-Messages-50k-INR-Yearly",USD:"AI-Messages-50k-USD-Yearly"},totalContact:1},AI_MESSAGES_100K_MONTHLY:{displayName:"AI MESSAGES 100K",frequency:"monthly",planPrice:{INR:9e9,USD:2549e5},chargebeeId:{INR:"AI-Messages-100k-INR-Monthly",USD:"AI-Messages-100k-USD-Monthly"},totalContact:1},AI_MESSAGES_100K_QUARTERLY:{displayName:"AI MESSAGES 100K",frequency:"quarterly",planPrice:{INR:2565e7,USD:726465e3},chargebeeId:{INR:"AI-Messages-100k-INR-Every-3-months",USD:"AI-Messages-100k-USD-Every-3-months"},totalContact:1},AI_MESSAGES_100K_YEARLY:{displayName:"AI MESSAGES 100K",frequency:"yearly",planPrice:{INR:972e8,USD:275292e4},chargebeeId:{INR:"AI-Messages-100k-INR-Yearly",USD:"AI-Messages-100k-USD-Yearly"},totalContact:1}},PLAN_TIERS:{FREE:"FREE",BASIC:"BASIC",PRO:"PRO",PREMIUM:"PREMIUM",UNLIMITED:"UNLIMITED",ENTERPRISE:"ENTERPRISE"}
1,V4_TIER_ORDER:["BASIC","PRO","PREMIUM","UNLIMITED","ENTERPRISE"],PLAN_PRESENTATION:{BASIC:{displayName:"BASIC",usp:"Get started fast",ribbon:null,priceMode:"amount",inherit:null,features:["Upto 10 Tags","Upto 5 Custom Attributes","Upto 2 Segments","Upto 10 Lists","Unlimited Contacts","Messaging Speed - 40 messages/second","Multi-Agent Live Chat","Broadcasting & Retargeting","Smart Campaign Manager","Smart Audience Segregation","Upto 1GB cloud storage","1 Owner + 5 Team members included","Agent Transfer & Manager Monitoring","AiSensy Marketplace Integrations","Click-to-WhatsApp Ads Manager","Shopify & WooCommerce Integrations","Upload & Manage Contacts"],addons:[{label:"AI Chat Agent",priceINR:"₹ 3500 /month",priceUSD:"$99 /month",note:"charged separately"},{label:"Chatbot Flows",priceINR:"₹ 2500 /month",priceUSD:"$80 /month",note:"charged separately"},{label:"Team Members",priceINR:"₹ 750 /Seat",priceUSD:"$20 /seat /month",note:"charged separately"}]},PRO:{displayName:"PRO",usp:"Growth Marketer",ribbon:null,priceMode:"amount",inherit:"Basic",features:["Upto 100 Tags","Upto 20 Custom Attributes","Upto 10 Segments","Upto 25 Lists","Campaign Scheduler","Messaging Speed - 40 messages/second","Campaign Click Tracking","Campaign Budget & Analytics","Project APIs","Upto 5GB cloud storage","Add Time Delay in Chatflow","Add Timeout in Chatflow","Custom Agent Rules","Read Receipts & Typing Indicators","Carousel Template Click Tracking","CSV Campaign Scheduler","Automatic Failed Message Retry"],addons:[{label:"AI Chat Agent",priceINR:"₹ 3500 /month",priceUSD:"$99 /month",note:"charged separately"},{label:"Chatbot Flows",priceINR:"₹ 2500 /month",priceUSD:"$80 /month",note:"charged separately"},{label:"Team Members",priceINR:"₹ 750 /Seat",priceUSD:"$20 /seat /month",note:"charged separately"}]},PREMIUM:{displayName:"PREMIUM",usp:"Expert Marketer",ribbon:{label:"✦ New",kind:"new"},priceMode:"amount",inherit:"Pro",features:["Priority Support",{label:"Higher Messaging Speed – 250 messages/second",value:5e3},{label:"1 Owner + 9 Team members included",value:6750},{label:"Number Masking",value:5e3},{label:"250 Tags",value:3e3},{label:"50 Attributes",value:3e3},{label:"50 Segments",value:5e3},{label:"100 Lists",value:5e3},{label:"Download Reports",value:5e3},{label:"Template TTL",value:2e3},{label:"Turbo Onboarding",value:5e3},{label:"1 Webhook",value:2e3},{label:"Multiple Meta-Ad Chatflow Trigger",value:5e3},{label:"Message Duplicate Contacts in CSV Broadcast",value:2e3}],valueAnchor:43750,addons:[{label:"AI Chat Agent",priceINR:"₹ 3500 /month",priceUSD:"$99 /month",note:"charged separately"},{label:"Chatbot Flows",priceINR:"₹ 2500 /month",priceUSD:"$80 /month",note:"charged separately"},{label:"Team Members",priceINR:"₹ 750 /Seat",priceUSD:"$20 /seat /month",note:"charged separately"}]},ENTERPRISE:{displayName:"ENTERPRISE",usp:"Built for enterprise scale",ribbon:null,priceMode:"custom",inherit:"Unlimited",features:["Custom Segment Limits","Custom List Limits","Dedicated 1:1 Onboarding & Setup","Solution Architect & Dedicated Success Team","Custom Integrations","SLA-Backed Priority Support","SSO & Audit logs","Custom Messaging Throughput","Custom Contracts & Invoicing"]},UNLIMITED:{displayName:"UNLIMITED",usp:"Everything, no limits",ribbon:{label:"✦ New",kind:"new"},priceMode:"amount",inherit:"Premium",features:[{label:"Unlimited Team Member *",value:15e4},{label:"Highest Messaging Speed – 1000 messages/second",value:1e4},{label:"Unlimited Tags **",value:7e3},{label:"Unlimited Attributes ***",value:7e3},{label:"250 Lists",value:12500},{label:"Dedicated Account Manager",value:15e3},{label:"3 Webhooks",value:6e3}],footnotes:["*Upto 200 Team Members","**Upto 500 Tags","***Upto 100 Attributes"],valueAnchor:2e5,valueAnchorUsd:2100,addons:[{label:"AI Chat Agent",priceINR:"₹ 3500 /month",priceUSD:"$99 /month",note:"charged separately"},{label:"Chatbot Flows",priceINR:"₹ 2500 /month",priceUSD:"$80 /month",note:"charged separately"},{label:"Team Members",priceINR:"₹ 750 /Seat",priceUSD:"$20 /seat /month",note:"charged separately"}]}},ADDON_TIERS:{NONE:"none",BASIC_FLOW:"basic_flow",AI_MESSAGES:"ai_messages"},AI_MESSAGE_PACKS:["3.5k","10k","25k","50k","100k"],AI_MESSAGE_PACK_QUOTAS:t,getAiMessagePackKey:e=>e&&e.includes("AI-Messages")&&Object.keys(t).find((t=>e.includes(t)))||null,addonClassifier:e=>e?e.includes("AI-Messages")?"ai_messages":e.includes("Discount-Flows-Add-On")?"flow_10_pack":e.includes("Flows-Add-On-5-Flows")||e.includes("Chatbot-Flows")?"flow_5_pack":e.includes("Virtual-Number")?"virtual_number":e.includes("Agent")?"agent":"plan":"unknown",isPremiumOrAbove:e=>a.includes(e)||n.includes(e),isUnlimited:e=>n.includes(e)}},5243:(e,t,a)=>{"use strict";a.d(t,{AX:()=>g,Ig:()=>u,fv:()=>c,kK:()=>m});var n=a(95093),s=a.n(n);const o="ad_account_insights_db",i="ad_account_insights_store",r=1,l=18e5;function d(){return new Promise((e=>{if(!window.indexedDB)return e(null);const t=indexedDB.open(o,r);t.onupgradeneeded=()=>{const e=t.result;e.objectStoreNames.contains(i)||e.createObjectStore(i)},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null)}))}function c(e){let{assistantId:t,adAccountId:a,page:n=1,limit:s=10,nameQuery:o="",startDate:i=null,endD
1ate:r=null,selectedOption:l=null}=e;return`ad_account_insights_${t}_${a}_${n}_${s}_${o}_${i?i.format("YYYY-MM-DD"):""}_${r?r.format("YYYY-MM-DD"):""}_${l||""}`}function p(e){if(!e)return!0;const t=new Date(e).getTime();return(new Date).getTime()-t>l}async function u(e){try{const t=await d();return t?new Promise((a=>{const n=t.transaction(i,"readonly").objectStore(i).get(e);n.onsuccess=()=>{const e=n.result;if(e&&p(e.cachedAt))a(null);else{if(e&&e.lastFetchParams){const{startDate:t,endDate:a}=e.lastFetchParams;t&&"string"==typeof t&&(e.lastFetchParams.startDate=s()(t)),a&&"string"==typeof a&&(e.lastFetchParams.endDate=s()(a))}a(e||null)}},n.onerror=()=>a(null)})):null}catch(e){return console.error("Error getting cached ad account insights:",e),null}}async function m(e,t){try{const a=await d();if(!a)return;const n={...t,lastFetchParams:{...t.lastFetchParams,startDate:t.lastFetchParams?.startDate?.format("YYYY-MM-DD")||t.lastFetchParams?.startDate||null,endDate:t.lastFetchParams?.endDate?.format("YYYY-MM-DD")||t.lastFetchParams?.endDate||null},cachedAt:(new Date).toISOString()};return new Promise((t=>{const s=a.transaction(i,"readwrite");s.objectStore(i).put(n,e),s.oncomplete=()=>t(),s.onerror=()=>t()}))}catch(e){console.error("Error setting cached ad account insights:",e)}}function h(e,t){return`account_data_${e}_${t}`}async function g(e,t,a){try{if(!e||!t)return;const n=await d();if(!n)return;const s=h(e,t),o={accountValue:a.accountValue||null,assistantDetails:a.assistantDetails||null,adAccountInsights:a.adAccountInsights||null,cachedAt:(new Date).toISOString()};return new Promise((e=>{const t=n.transaction(i,"readwrite");t.objectStore(i).put(o,s),t.oncomplete=()=>e(),t.onerror=()=>e()}))}catch(e){console.error("Error setting cached account data:",e)}}},23800:e=>{const t=e=>{if("string"==typeof e){let t=e;return t.includes("https://whatsapp-media-library.s3.ap-south-1.amazonaws.com")&&(t=t.replace("https://whatsapp-media-library.s3.ap-south-1.amazonaws.com","https://d3jt6ku4g6z5l8.cloudfront.net")),t.includes("https://whatsapp-media-incoming.s3.ap-south-1.amazonaws.com")&&(t=t.replace("https://whatsapp-media-incoming.s3.ap-south-1.amazonaws.com","https://dnw6l5n94jgqf.cloudfront.net")),t.includes("https://d2npdtryso7wvr.cloudfront.net")&&(t=t.replace("https://d2npdtryso7wvr.cloudfront.net","https://dnw6l5n94jgqf.cloudfront.net")),t.includes("https://whatsapp-media-library-1.s3.ap-south-1.amazonaws.com")&&(t=t.replace("https://whatsapp-media-library-1.s3.ap-south-1.amazonaws.com","https://dc4ardkuedwlq.cloudfront.net")),t.includes("https://whatsapp-media-library-stg.s3.ap-south-1.amazonaws.com")&&(t=t.replace("https://whatsapp-media-library-stg.s3.ap-south-1.amazonaws.com","https://dwbb9b4enii6a.cloudfront.net")),t.includes("https://whatsapp-media-library-pre-stg.s3.ap-south-1.amazonaws.com")&&(t=t.replace("https://whatsapp-media-library-pre-stg.s3.ap-south-1.amazonaws.com","https://d1fviw7lxswn81.cloudfront.net")),t}if(Array.isArray(e))return e.map((e=>t(e)));if(e&&"object"==typeof e){const a={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(a[n]=t(e[n]));return a}return e};e.exports={replaceDomainInData:t}},19458:(e,t,a)=>{"use strict";a.d(t,{x:()=>o});var n=a(2915),s=a(1842);const o=()=>{const e=(0,s._E)();if(e&&e.hostInfo){const{isTenant:t=!1,isPartner:a=!1,isAiSensy:n=!1}=e.hostInfo;return{isTenant:t,isPartner:a,isAiSensy:n}}const t=window.location.origin!==n.Tj,a=n.ZP&&n.ZP!==n.kA;return{isTenant:a,isPartner:t,isAiSensy:!a&&!t}}},1842:(e,t,a)=>{"use strict";a.d(t,{BR:()=>o,Uj:()=>l,_E:()=>i,nq:()=>r,sF:()=>s});let n=null;const s=e=>{n=e},o=()=>{n=null},i=()=>n,r=()=>Boolean(n),l=(e,t)=>{if(n&&"function"==typeof n.onEvent)try{n.onEvent(e,t)}catch(e){console.error("[adsMfe] host onEvent handler threw",e)}}},18680:(e,t,a)=>{"use strict";a.d(t,{cQ:()=>n});const n=function(e,t){let{assistantId:a}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||!t)return!1;const{data:n,adSetupDetails:s,user:o,isCollapse:i}=(e=>({data:e?.assistantDetails?.data,adSetupDetails:e?.assistantDetails?.adSetupDetails,user:e?.login?.user,isCollapse:e?.cartPlus?.isCollapse}))(t);return o&&e.dispatch({type:"Login/LOGIN_SUCCESS",payload:{...o,assistantId:a||o.assistantId||o.firstProjectId}}),n&&Object.keys(n).length&&e.dispatch({type:"AssistantDetails/UPDATE_ASSISTANT_STORE",payload:n}),s&&Object.keys(s).length&&e.dispatch({type:"AssistantDetails/UPDATE_AD_SETUP_STORE",payload:s}),"boolean"==typeof i&&e.dispatch({type:"Cart/SWITCH_COLLAPSE",payload:i}),Boolean(n&&n.assistantId)}},14507:(e,t,a)=>{"use strict";a.d(t,{$y:()=>i,FO:()=>S,Ht:()=>v,Kx:()=>p,Nj:()=>m,O2:()=>x,Oi:()=>r,Ty:()=>b,VO:()=>C,Xc:()=>N,_R:()=>l,br:()=>T,c8:()=>h,h8:()=>_,iP:()=>w,j5:()=>D,mf:()=>y,oj:()=>j,p1:()=>k,qN:()=>f,rO:()=>g,s3:()=>c,t4:()=>A,um:()=>L,v7:()=>E,xt:()=>I,y:()=>d});var n=a(23664),s=a(52305),o=(a(23441),a(18526));const i=["CAMPAIGN_PAUSED","ADSET_PAUSED","PAUSED"];function r(e,t,a){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const{tag:r,pageId:l,tasks:d,accountId:c,pageName:p,accountName:u,freezed:m}=e||{},h=c?`${u} - ${c.split("_")[1]}`:l?`${p} - ${l}`:"NA",g=""+(l?"Page":"Ad Account"),b={Limited:`${g} is not assigned`,Personal:`Cannnot Access Personal ${g}'s`};return(0,o.jsx)(n.Tooltip,{placement:"right",title:(0,o.jsxs)(n.Box,{p:1.5,children:[(0,o.jsxs)(n.Typography,{variant:"body2",gutterBottom:!0,children:[(0,o.jsx)("b",{children:""+(l?"Page : ":"Account : ")}),h]}),m&&(0,o.jsxs)(n.Typography,{variant:"body2",gutterBottom:!0,children:[(0,o.jsx)("b",{children:"Freezed : "}),`Other Agents will only be able to access this ${g}`]}),"Personal"===r&&i?"":"Assigned"!==r&&(0,o.jsxs)(n.Typography,{variant:"body2",gutterBottom:!0,children:[(0,o.jsx)("b",{children:"Reason : "}),b[r]||""]})]}),arrow:!0,classes:{arrow:a.arrow},children:(0,o.jsxs)(n.Box,{width:"100%",style:{display:"flex"},children:[(0,o.jsx)(n.Box,{width:m?"95%":"100%",children:(0,o.jsx)(n.Typography,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:h})}),m&&(0,o.jsx)(n.Box,{style:{display:"flex",justifyContent:"end"},children:(0,o.jsx)(s.Lock,{fontSize:"small",color:"primary"})})]})})}const l=[{value:"feed",label:"Feed",description:"Show ads in users' main Facebook News Feed alongside organic posts",adFormat:"MOBILE_FEED_STANDARD"},{value:"right_hand_column",label:"Right Column",description:"Display ads in the right sidebar on desktop Facebook",adFormat:"RIGHT_COLUMN_STANDARD"},{value:"marketplace",label:"Marketplace",description:"Show ads in Facebook Marketplace where users shop and browse",adFormat:"MARKETPLACE_MOBILE"},{value:"video_feeds",label:"Video Feeds",description:"Place ads in Facebook video feeds for video content discovery",adFormat:"WATCH_FEED_MOBILE"},{value:"story",label:"Stories",description:"Display ads between Stories for full-screen, immersive viewing experience",adFormat:"FACEBOOK_STORY_MOBILE"},{value:"search",label:"Search",description:"Show ads in Facebook search results when users search for content",adFormat:"INSTAGRAM_SEARCH_CHAIN"}
1,{value:"instream_video",label:"In-Stream Video",description:"Place ads within Facebook video content as mid-roll or pre-roll",adFormat:"INSTREAM_VIDEO_MOBILE"},{value:"facebook_reels",label:"Reels",description:"Show ads in Facebook Reels feed for short-form video",adFormat:"FACEBOOK_REELS_MOBILE"},{value:"facebook_reels_overlay",label:"Reels Overlay",description:"Display overlay ads on Facebook Reels videos",adFormat:"FACEBOOK_REELS_BANNER"},{value:"profile_feed",label:"Profile Feed",description:"Display ads on user profile feeds for targeted visibility and reach",adFormat:"FACEBOOK_PROFILE_FEED_MOBILE"},{value:"notification",label:"Notification",description:"Display ads in Facebook notifications for high visibility",adFormat:"MOBILE_FEED_STANDARD"}],d=[{value:"status",label:"Status",description:"Show your ad as a WhatsApp Status update in the Updates tab",adFormat:"WHATSAPP_STATUS_MEDIA"}],c=[{value:"stream",label:"Feed",description:"Show ads in users' main Instagram feed as they scroll through posts",adFormat:"INSTAGRAM_STANDARD"},{value:"story",label:"Stories",description:"Display ads between Stories for full-screen, immersive viewing experience",adFormat:"INSTAGRAM_STORY"},{value:"explore",label:"Explore",description:"Reach users browsing the Explore tab where they discover new content",adFormat:"INSTAGRAM_EXPLORE_CONTEXTUAL"},{value:"explore_home",label:"Explore Home",description:"Show ads on the Explore home page to capture discovery intent",adFormat:"INSTAGRAM_EXPLORE_GRID_HOME"},{value:"reels",label:"Reels",description:"Place ads in Instagram Reels feed for short-form video content",adFormat:"INSTAGRAM_REELS"},{value:"profile_feed",label:"Profile Feed",description:"Display ads on user profile feeds for targeted visibility and reach",adFormat:"INSTAGRAM_PROFILE_FEED"},{value:"ig_search",label:"Search",description:"Show ads in Instagram search results when users look for content",adFormat:"INSTAGRAM_SEARCH_GRID"},{value:"profile_reels",label:"Profile Reels",description:"Place ads in Reels shown on user profiles",adFormat:"INSTAGRAM_PROFILE_REELS"}],p=[{value:"ctwa",label:"Click to WhatsApp Ad",type:"WHATSAPP",description:"Start a WhatsApp conversation from your ad",benefit:"Sales & qualified conversations",tag:"RECOMMENDED"},{value:"whatsapp_status",label:"WhatsApp Status Ad",type:"WHATSAPP_STATUS",description:"Reach customers inside WhatsApp Status",benefit:"Reach & product discovery",tag:"BETA"},{value:"website_to_whatsapp",label:"Website to WhatsApp Ad",type:"WEBSITE",description:"Website visits with a WhatsApp button",benefit:"Website visits & WhatsApp conversations",tag:"NEW"},{value:"website_traffic",label:"Website Ad",type:"WEBSITE",description:"Send people to a product or landing page",benefit:"Purchases & website conversions"}
1,{value:"lead_form",label:"Lead Form Ads",type:"LEAD",description:"Capture lead details without leaving Meta",benefit:"Lead generation & enquiries"}],u={WHATSAPP:{objective:"OUTCOME_ENGAGEMENT",goal:"CONVERSATIONS"},WHATSAPP_STATUS:{objective:"OUTCOME_ENGAGEMENT",goal:"CONVERSATIONS"},WEBSITE:{objective:"OUTCOME_SALES",goal:"OFFSITE_CONVERSIONS"},LEAD:{objective:"OUTCOME_LEADS",goal:"LEAD_GENERATION"}},m=e=>{const t=u[e];if(!t)return{objective:null,goal:null};const a=h.find((e=>e.value===t.objective))||null,n=a?.optimizationGoals?.find((e=>e.value===t.goal))||null;return{objective:a,goal:n}},h=[{value:"OUTCOME_TRAFFIC",label:"Traffic",description:"Drive people to a destination like a website, app, or conversation (includes LINK_CLICKS)",optimizationGoals:[{value:"LANDING_PAGE_VIEWS",label:"Maximise number of landing page views",description:"We'll try to show your ads to the people most likely to open the app or website linked in your ad.",conversionLocations:["WEBSITE"],header:"Traffic goals"},{value:"LINK_CLICKS",label:"Maximise number of link clicks",description:"We'll try to show your ads to the people most likely to click on them.",conversionLocations:["WEBSITE","WHATSAPP","WHATSAPP_STATUS"],header:"Traffic goals"},{value:"REACH",label:"Maximise daily unique reach",description:"We'll try to show your ads to people up to once per day.",conversionLocations:["WEBSITE","WHATSAPP","WHATSAPP_STATUS"],header:"Other goals"},{value:"CONVERSATIONS",label:"Maximise number of conversations",description:"We'll try to show your ads to most likely to have a conversation with you through messaging.",conversionLocations:["WEBSITE","WHATSAPP","WHATSAPP_STATUS"],header:"Other goals"},{value:"IMPRESSIONS",label:"Maximise number of impressions",description:"We'll try to show your ads to people as many times as possible.",conversionLocations:["WEBSITE","WHATSAPP","WHATSAPP_STATUS"],header:"Other goals"}]},{value:"OUTCOME_ENGAGEMENT",label:"Engagement",description:"Increase post engagement, page likes, event responses, or messages (includes POST_ENGAGEMENT, PAGE_LIKES, EVENT_RESPONSES, MESSAGES)",optimizationGoals:[{value:"OFFSITE_CONVERSIONS",label:"Maximise number of conversions",description:"We'll try to show your ads to the people most likely to take a specific action on your website.",conversionLocations:["WEBSITE"],header:"Engagement goals"},{value:"CONVERSATIONS",label:"Maximise number of conversations",description:"We'll try to show your ads to most likely to have a conversation with you through messaging.",conversionLocations:["WHATSAPP","WHATSAPP_STATUS"],header:"Engagement goals"},{value:"LANDING_PAGE_VIEWS",label:"Maximise number of landing page views",description:"We'll try to show your ads to the people most likely to open the app or website linked in your ad.",conversionLocations:["WEBSITE"],header:"Other goals"},{value:"LINK_CLICKS",label:"Maximise number of link clicks",description:"We'll try to show your ads to the people most likely to click on them.",conversionLocations:["WEBSITE","WHATSAPP","WHATSAPP_STATUS"],header:"Other goals"},{value:"REACH",label:"Maximise daily unique reach",description:"We'll try to show your ads to people up to once per day.",conversionLocations:["WEBSITE"],header:"Other goals"},{value:"IMPRESSIONS",label:"Maximise number of impressions",description:"We'll try to show your ads to people as many times as possible.",conversionLocations:["WEBSITE"],header:"Other goals"}]},{value:"OUTCOME_SALES",label:"Sales",description:"Drive purchases, e-commerce, or other high-value conversions (includes CONVERSIONS, PRODUCT_CATALOG_SALES)",optimizationGoals:[{value:"OFFSITE_CONVERSIONS",label:"Maximise number of conversions",description:"We'll try to deliver your ads to the right people to help you get the most website conversions.",conversionLocations:["WHATSAPP","WEBSITE","WHATSAPP_STATUS"],header:"Conversion goals"},{value:"VALUE",label:"Maximise value of conversions",description:"We'll try to show your ads to the people most likely to generate higher value for your business.",conversionLocations:["WEBSITE"],header:"Conversion goals"},{value:"CONVERSATIONS",label:"Maximise number of conversations",description:"We'll try to show your ads to people most likely to have a conversation with you through messaging.",conversionLocations:["WHATSAPP","WHATSAPP_STATUS"],header:"Conversion goals"}
1,{value:"LANDING_PAGE_VIEWS",label:"Maximise number of landing page views",description:"We'll try to show your ads to the people most likely to open the app or website linked in your ad.",conversionLocations:["WEBSITE"],header:"Other goals"},{value:"LINK_CLICKS",label:"Maximise number of link clicks",description:"We'll try to show your ads to the people most likely to click on them.",conversionLocations:["WEBSITE","WHATSAPP","WHATSAPP_STATUS"],header:"Other goals"},{value:"REACH",label:"Maximise daily unique reach",description:"We'll try to show your ads to as many people as possible.",conversionLocations:["WEBSITE","WHATSAPP","WHATSAPP_STATUS"],header:"Other goals"},{value:"IMPRESSIONS",label:"Maximise number of impressions",description:"We'll try to show your ads to people as many times as possible.",conversionLocations:["WEBSITE","WHATSAPP","WHATSAPP_STATUS"],header:"Other goals"}]},{value:"OUTCOME_LEADS",label:"Leads",description:"Collect leads for your business using instant forms, calls, or messages",optimizationGoals:[{value:"LEAD_GENERATION",label:"Maximise number of leads",description:"We'll try to show your ads to the people most likely to share their contact information with your business.",conversionLocations:["LEAD"],header:"Lead goals"},{value:"QUALITY_LEAD",label:"Maximise number of conversion leads",description:"We'll try to show your ads to people most likely to become high-quality leads for your business. Requires your CRM to be connected to Meta via the Conversions API for CRM.",conversionLocations:["LEAD"],header:"Lead goals"}]}],g=[{value:"CONTENT_VIEW",label:"Content View",supportedTypes:["OUTCOME_ENGAGEMENT","OUTCOME_SALES"]},{value:"SEARCH",label:"Search",supportedTypes:["OUTCOME_ENGAGEMENT","OUTCOME_SALES"]},{value:"ADD_TO_WISHLIST",label:"Add to Wishlist",supportedTypes:["OUTCOME_ENGAGEMENT","OUTCOME_SALES"]},{value:"CONTACT",label:"Contact",supportedTypes:["OUTCOME_ENGAGEMENT"]},{value:"SCHEDULE",label:"Schedule",supportedTypes:["OUTCOME_ENGAGEMENT"]},{value:"CUSTOMIZE_PRODUCT",label:"Customize Product",supportedTypes:["OUTCOME_ENGAGEMENT"]},{value:"FIND_LOCATION",label:"Find Location",supportedTypes:["OUTCOME_ENGAGEMENT"]},{value:"DONATE",label:"Donate",supportedTypes:["OUTCOME_ENGAGEMENT","OUTCOME_SALES"]},{value:"START_TRIAL",label:"Start Trial",supportedTypes:["OUTCOME_ENGAGEMENT","OUTCOME_SALES"]},{value:"SUBMIT_APPLICATION",label:"Submit Application",supportedTypes:["OUTCOME_ENGAGEMENT"]},{value:"SUBSCRIBE",label:"Subscribe",supportedTypes:["OUTCOME_ENGAGEMENT","OUTCOME_SALES"]},{value:"ADD_TO_CART",label:"Add to Cart",supportedTypes:["OUTCOME_SALES"]},{value:"INITIATED_CHECKOUT",label:"Initiated Checkout",supportedTypes:["OUTCOME_SALES"]},{value:"ADD_PAYMENT_INFO",label:"Add Payment Info",supportedTypes:["OUTCOME_SALES"]},{value:"PURCHASE",label:"Purchase",supportedTypes:["OUTCOME_SALES"]},{value:"COMPLETE_REGISTRATION",label:"Complete Registration",supportedTypes:["OUTCOME_SALES"]}],b=[{value:"FULL_NAME",label:"Full Name",description:"User's full name",isPrefill:!0,locked:!0},{value:"PHONE",label:"Phone Number",description:"User's phone number",isPrefill:!0,locked:!0},{value:"FIRST_NAME",label:"First Name",description:"User's first name",isPrefill:!1},{value:"LAST_NAME",label:"Last Name",description:"User's last name",isPrefill:!1},{value:"EMAIL",label:"Email",description:"User's email address",isPrefill:!1},{value:"STREET_ADDRESS",label:"Street Address",description:"User's street address",isPrefill:!1},{value:"CITY",label:"City",description:"User's city",isPrefill:!1},{value:"STATE",label:"State/Province",description:"User's state or province",isPrefill:!1},{value:"ZIP",label:"Zip/Postal Code",description:"User's zip or postal code",isPrefill:!1},{value:"COUNTRY",label:"Country",description:"User's country",isPrefill:!1},{value:"COMPANY_NAME",label:"Company Name",description:"User's company name",isPrefill:!1},{value:"JOB_TITLE",label:"Job Title",description:"User's job title",isPrefill:!1},{value:"WORK_EMAIL",label:"Work Email",description:"User's work email address",isPrefill:!1},{value:"WORK_PHONE_NUMBER",label:"Work Phone",description:"User's work phone number",isPrefill:!1},{value:"DOB",label:"Date of Birth",description:"User's date of birth",isPrefill:!1},{value:"GENDER",label:"Gender",description:"User's gender",isPrefill:!1},{value:"MARITIAL_STATUS",label:"Marital Status",description:"User's marital status",isPrefill:!1},{value:"RELATIONSHIP_STATUS",label:"Relationship Status",description:"User's relationship status",isPrefill:!1},{value:"MILITARY_STATUS",label:"Military Status",description:"User's military status",isPrefill:!1}],y=[{id:"contact",label:"Contact fields",types:["FULL_NAME","PHONE","EMAIL"]},{id:"user",label:"User information",types:["FIRST_NAME","LAST_NAME"]},{id:"demographic",label:"Demographic questions",types:["DOB","GENDER","MARITIAL_STATUS","RELATIONSHIP_STATUS","MILITARY_STATUS"]},{id:"work",label:"Work information",types:["COMPANY_NAME","JOB_TITLE","WORK_EMAIL","WORK_PHONE_NUMBER"]},{id:"location",label:"Location",types:["STREET_ADDRESS","CITY","STATE","ZIP","COUNTRY"]}],x=([{value:"SHORT_ANSWER",label:"Short Answer",description:"Open text field for brief responses",needsLabel:!0,needsKey:!0,needsOptions:!1,canTriggerConditional:!1},{value:"MULTIPLE_CHOICE",label:"Multiple Choice",description:"Dropdown or radio options for users to select",needsLabel:!0,needsKey:!0,needsOptions:!0,canTriggerConditional:!0},{value:"CONDITIONAL",label:"Conditional Question",description:"Question that appears based on previous answer",needsLabel:!0,needsKey:!0,needsOptions:!1,requiresParent:!0}].map((e=>({...e,value:"SHORT_ANSWER"===e.value||"MULTIPLE_CHOICE"===e.value||"CONDITIONAL"===e.value?"CUSTOM":e.value,isPrefill:!1}))),[{value:"VIEW_WEBSITE",label:"View Website",description:"Redirect users to your website after form submission"},{value:"CALL_BUSINESS",label:"Call Business",description:"Let users call your business directly"}]),f=[{value:"APPLY_NOW",label:"Apply Now"},{value:"BOOK_NOW",label:"Book Now"},{value:"DOWNLOAD",label:"Download"},{value:"GET_QUOTE",label:"Get Quote"},{value:"LEARN_MORE",label:"Learn More"},{value:"SIGN_UP",label:"Sign Up"},{value:"SUBSCRIBE",label:"Subscribe"},{value:"GET_OFFER",label:"Get Offer"},{value:"CONTACT_US",label:"Contact Us"}],A=[{label:"Impressions",value:0},{label:"Reach",value:0},{label:"Frequency",value:0},{label:"Clicks",value:0},{label:"Unique Clicks",value:0},{label:"Inline Link Clicks",value:0},{label:"CTR (%)",value:0},{label:"Spend",value:0}],I={INR:250,USD:5},C={INR:2500,USD:25},_=e=>I[e]||I.INR,S=e=>C[e]||C.INR,v=(e,t,a)=>{if(!Array.isArray(e)||0===e.length||!t)return;if(a){if(Array.isArray(a)){for(const n of a){const a=e.find((e=>e[n]===t));if(a)return a}return}{const n=e.find((e=>e[a]===t));return"pixelId"===a?{label:n?.name?`${n?.name||""} (${n?.pixelId||""})`:t,value:n?.pixelId?n?.pixelId:t}:n}}const n=["id","value","label","name","_id"];for(const a of n){const n=e.find((e=>e[a]===t));if(n)return n}},E=e=>e?"string"==typeof e?e.split("_").map((e=>e.charAt(0)+e.slice(1).toLowerCase())).join(" "):e:"-",T=e=>{const t=String(e||"").toUpperCase();return t.includes("ABOVE")||t.includes("HIGH")?"#28c152":t.includes("BELOW")||t.includes("LOW")?"#ea0037":"#1976d2"},D=(e,t)=>{const a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!a)return e;return`rgba(${parseInt(a[1],16)}, ${parseInt(a[2],16)}, ${parseInt(a[3],16)}, ${t})`},w=e=>{if(!e||"string"!=typeof e)return"";const t=e.trim();return t?/^https?:\/\//i.test(t)?t:`https://${t}`:""},N=e=>{if(!e||"string"!=typeof e)return!1;let t;try{t=new URL(e.trim())}catch(e){return!1}return"http:"===t.protocol||"https:"===t.protocol},j=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=new Set;
1return(e?.countries||[]).forEach((e=>{"string"==typeof e&&e&&t.add(e)})),["regions","cities","places","zips"].forEach((a=>{(e?.[a]||[]).forEach((e=>{const a=e?.country_code||e?.country;a&&t.add(a)}))})),Array.from(t)},k=(e,t)=>{if(!Array.isArray(e))return[];return Array.isArray(t)&&t.length>0&&t.every((e=>"US"===e))?e:e.filter((e=>"income"!==e?.type))},L=e=>{let{value:t,badgeColor:a}=e;if(!t)return(0,o.jsx)(n.Typography,{variant:"h5",children:"-"});const s=E(t),i=a||T(t);return(0,o.jsx)(n.Chip,{label:s,size:"small",style:{backgroundColor:D(i,.08),color:i,fontWeight:"bold",borderRadius:"12px",padding:"4px 8px"}})}},46758:(e,t,a)=>{"use strict";a.d(t,{CL:()=>A,Cm:()=>h,DV:()=>r,FE:()=>_,GE:()=>f,GL:()=>y,MU:()=>d,PG:()=>p,Px:()=>l,Qv:()=>I,SM:()=>c,bQ:()=>b,cL:()=>C,k2:()=>x,w7:()=>i,z1:()=>S});var n=a(2543),s=a.n(n),o=a(5825);const i={country:"countries",region:"regions",place:"places",city:"cities",zip:"zips"},r=["city","place"],l={city:40,place:2},d={city:17,place:1},c={city:80,place:80},p="kilometer",u=["geo_market","electoral_district","small_geo_area","medium_geo_area","large_geo_area","country_group"],m={zip:"Pin Code"},h=e=>m[e]||s().startCase(e),g=e=>i[e]||"cities",b=e=>r.includes(e),y=e=>(o.A.find((t=>t.isoCode===e))||{}).name||e,x=e=>e&&e.key||e,f=function(){let{name:e,region:t,country_name:a}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s().compact([e,t,a]).join(", ")},A=e=>Array.isArray(e)?e.filter((e=>!u.includes(e&&e.type))):[],I=(e,t)=>{const{country_code:a,region_id:n,key:s,name:o,region:i,country_name:r}=t;switch(e){case"city":return{type:e,country_code:a,region_id:n,key:s,name:o,region:i,country_name:r,radius:t.radius||l.city,distance_unit:t.distance_unit||p};case"country":return s;case"place":return{country:a,region_id:n,key:s,name:o,radius:t.radius||l.place,distance_unit:t.distance_unit||p,type:e,country_name:r||y(a)};case"zip":return{key:s,name:o,type:e,country_code:a,country_name:r,region_id:n,region:i};default:return{type:e,country_code:a,region_id:n,key:s,name:o,region:i,country_name:r}}},C=(e,t,a)=>(a&&a[g(e)]||[]).some((e=>x(e)===t)),_=(e,t,a)=>{const n=g(t),s=e&&e[n]||[];return s.some((e=>x(e)===x(a)))?e:{...e,[n]:[...s,a]}},S=(e,t,a)=>{const n=g(t),s=e&&e[n]||[];return{...e,[n]:s.filter((e=>x(e)!==a))}}},97915:(e,t,a)=>{"use strict";a.d(t,{$3:()=>d,LZ:()=>p,eF:()=>c,eP:()=>l,f1:()=>r});var n=a(72505),s=a.n(n),o=a(2915);const i=async(e,t,a)=>(await s().post(`${o.k}/meta-ads${e}`,t,a?{cancelToken:a}:void 0)).data,r=function(e){let{cancelToken:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return i("/fetch-pages",{assistantId:e},t)},l=function(e){let{cancelToken:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return i("/fetch-ad-accounts",{assistantId:e},t)},d=e=>{let{assistantId:t,selectedMetaAdAccountId:a,selectedMetaPageId:n}=e;return i("/select-ad-profile",{assistantId:t,selectedMetaAdAccountId:a,selectedMetaPageId:n})},c=e=>{let{assistantId:t,adAccountId:a,mode:n}=e;return i("fetchCTWAds"===n?"/fetch-ctw-ads":"/sync-meta-ad-account",{assistantId:t,adAccountId:a})},p=e=>{let{assistantId:t,adAccountId:a}=e;return i("/new-fetch-ctw-ads",{assistantId:t,adAccountId:a})}},49525:(e,t,a)=>{"use strict";a.d(t,{DA:()=>g,R_:()=>p,SX:()=>h,ae:()=>c,gD:()=>u,hr:()=>r,jc:()=>l,xo:()=>d,zB:()=>m});var n=a(72505),s=a.n(n),o=a(2915);const i=(e,t)=>s().post(`${o.k}/meta-ads${e}`,t).then((e=>
1e.data)),r=e=>{let{assistantId:t,adId:a,isFromEdit:n=!0}=e;return i("/sync-ad",{assistantId:t,_id:a,isFromEdit:n})},l=e=>{let{assistantId:t,text:a=""}=e;return i("/fetch-icebreakers",{assistantId:t,text:a})},d=e=>{let{assistantId:t,adAccountId:a}=e;return i("/fetch-ad-account",{assistantId:t,adAccountId:a})},c=e=>{let{assistantId:t,pageId:a}=e;return i("/fetch-page",{assistantId:t,pageId:a})},p=e=>i("/create-meta-ad",e),u=e=>i("/create-draft-meta-ad",e),m=e=>i("/edit-meta-ad",e),h=e=>{let{link:t,assistantId:a}=e;return i("/fetch-web-meta-data",{link:t,assistantId:a})},g=e=>{let{assistantId:t,status:a,adId:n,mongoAdId:s,adAccountId:o}=e;return i("/update-ad-status",{assistantId:t,status:a,adId:n,_id:s,adAccountId:o})}},24113:(e,t,a)=>{"use strict";a.d(t,{BF:()=>g,DN:()=>u,Nn:()=>i,Os:()=>d,WO:()=>p,_L:()=>l,r4:()=>m,s7:()=>c,ze:()=>r,zq:()=>h});var n=a(72505),s=a.n(n),o=a(2915);const i=e=>{let{assistantId:t,allFilters:a}=e;return s().post(`${o.k}/meta-ads/audiences/convoCount`,{assistantId:t,allFilters:a}).then((e=>e.data))},r=e=>{let{assistantId:t,audienceId:a,page:n,limit:i}=e;return s().get(`${o.k}/meta-ads/custom-audience-upload-logs`,{params:{assistantId:t,audienceId:a,page:n,limit:i}}).then((e=>e.data))},l=e=>s().get(`${o.k}/meta-ads/custom-audience`,{params:e}).then((e=>e.data)),d=e=>s().post(`${o.k}/meta-ads/create-custom-audience`,e).then((e=>e.data)),c=e=>s().post(`${o.k}/meta-ads/audiences/lookalike`,e).then((e=>e.data)),p=e=>{let{audienceId:t,assistantId:a}=e;return s().put(`${o.k}/meta-ads/audiences/custom/${t}`,{assistantId:a}).then((e=>e.data))},u=e=>{let{assistantId:t,fileName:a}=e;return s().post(`${o.k}/api/get-upload-url`,{assistantId:t,fileName:a,contentType:"text/csv",fileType:"CONTACT"}).then((e=>e.data))},m=(e,t)=>s().post(e,t,{withCredentials:!1,transformRequest:(e,t)=>(delete t.Authorization,delete t["x-tenant-id"],delete t["x-ais-fp-id"],e)}),h=e=>s().post(`${o.k}/meta-ads/upload-audience`,e).then((e=>e.data)),g=e=>{let{assistantId:t,adAccountId:a}=e;return s().post(`${o.k}/meta-ads/sync-custom-audience`,{assistantId:t,adAccountId:a}).then((e=>e.data))}},14272:(e,t,a)=>{"use strict";a.d(t,{QK:()=>l,Se:()=>r,ge:()=>i,qM:()=>d});var n=a(72505),s=a.n(n),o=a(2915);const i=async e=>(await s().post(`${o.k}/api/fetch-campaigns`,{assistantId:e})).data,r=async e=>(await s().post(`${o.k}/api/fetch-api-campaigns`,{assistantId:e})).data,l=async e=>{const t=await s().post(`${o.k}/api/templates`,{assistantId:e},{responseType:"text"}),a="string"==typeof t.data?t.data.trim():"";if(!a)return[];const n=a.endsWith(",")?a.slice(0,-1):a;return JSON.parse(`[${n}]`)},d=e=>s().post(`${o.ak}/contacts/meta-export-audience`,e).then((e=>e.data))},42094:(e,t,a)=>{"use strict";a.d(t,{Mo:()=>l,az:()=>i,u5:()=>r});var n=a(72505),s=a.n(n),o=a(2915);const i=e=>{let{assistantId:t,userNumberArray:a}=e;return s().post(`${o.k}/api/get-contact-segregated-opted`,{userNumberArray:a,assistantId:t}).then((e=>e.data))},r=e=>{let{assistantId:t,userNumberArray:a}=e;return s().post(`${o.k}/meta-ads/get-segregated-opted`,{userNumberArray:a,assistantId:t}).then((e=>e.data))},l=e=>{let{assistantId:t,skip:a,rowsPerPage:n,allFilters:i}=e;return s().post(`${o.k}/api/contacts`,{assistantId:t,skip:a,rowsPerPage:n,allFilters:i}).then((e=>e.data))}},86920:(e,t,a)=>{"use strict";a.d(t,{M0:()=>r,PH:()=>l,a3:()=>c,fc:()=>u,ls:()=>p,sJ:()=>m,vy:()=>d});var n=a(72505),s=a.n(n),o=a(2915);const i=(e,t)=>s().post(`${o.k}/meta-ads${e}`,t).then((e=>
1e.data)),r=e=>{let{assistantId:t,partnerId:a,agentId:n}=e;return s().post(`${o.md}/api/generate-connect-ads-link`,{assistantId:t,partnerId:a,agentId:n}).then((e=>e.data))},l=e=>{let{assistantId:t,authResponse:a,status:n,partnerId:s}=e;return i("/fb-connect",{assistantId:t,authResponse:a,status:n,partnerId:s})},d=e=>{let{assistantId:t,fbUserId:a,partnerId:n}=e;return i("/fb-disconnect",{assistantId:t,fbUserId:a,partnerId:n})},c=e=>i("/create-page",e),p=e=>i("/link-whatsapp-number-with-page",e),u=e=>i("/setup-business-account",e),m=e=>s().post(`${o.k}/api/get-fb-token-info`,e).then((e=>e.data))},42834:(e,t,a)=>{"use strict";a.d(t,{A:()=>i,Y:()=>r});var n=a(72505),s=a.n(n),o=a(2915);const i=e=>{let{assistantId:t,flowId:a,flowObject:n}=e;return s().post(`${o.k}/meta-catalogue/update-flow`,{assistantId:t,flowId:a,flowObject:n}).then((e=>e.data))},r=function(e){let{useLibrary:t=!1,cancelToken:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s().post(`${o.k}/meta-catalogue/${t?"get-flow-library":"get-flow"}`,{assistantId:e},a?{cancelToken:a}:void 0).then((e=>e.data))}},90336:(e,t,a)=>{"use strict";a.d(t,{u:()=>d,v:()=>c});var n=a(72505),s=a.n(n),o=a(2915),i=a(37200),r=a(1842);let l=null;const d=async()=>(l||(l=s().post(o.k+"/auth/get-new-agent-token",{}).finally((()=>{l=null}))),l),c=async()=>{try{if((0,r.nq)())return(0,i.v)()?.dispatch({type:"Login/SIGN_OUT_SUCCESS"}),void(0,r.Uj)("SESSION_INVALID");const e=localStorage.getItem("session");if(localStorage.removeItem("session"),e){const{_id:t}=JSON.parse(atob(e)||"{}");await s().post(o.k+"/auth/logOut",{_id:t}).catch((e=>{console.log("Logout failed",e)}))}(0,i.v)()?.dispatch({type:"Login/SIGN_OUT_SUCCESS"}),window.location.href="/login"}catch(e){console.error("Error in handleSessionInvalidation",e)}}},56834:(e,t,a)=>{"use strict";a.d(t,{T:()=>c});var n=a(72505),s=a.n(n),o=a(2915),i=a(19458),r=a(90336),l=a(1842);let d=!1;const c=()=>{d||(d=!0,s().defaults.withCredentials=!0,s().interceptors.request.use((function(e){const t=(0,l._E)();t?.apiHeaders&&(e.headers={...t.apiHeaders,...e.headers||{}});const{isPartner:a}=(0,i.x)(),{primaryURL:n,noLabelURL:s}=(()=>{const e=["/","http://","https://"];let t,a;const n=(e,t)=>{const a="/"===e,n=t.split(e);return(a?"":e)+(a?n[0]:n[1]).split("/")[0]};for(const s of e)o.as.includes(s)&&(a=n(s,o.as)),o.JI.includes(s)&&(t=n(s,o.JI));return{primaryURL:t,noLabelURL:a}})();if(a){const t=e.url.replace(n,s);e.url=t}return e}),(function(e){return Promise.reject(e)})),s().interceptors.response.use((e=>e),(async e=>{if(401===e.response?.status)try{if("Token expired."===e.response.data?.message)return await(0,r.u)(),s()(e.config);if(e.response?.data?.logout)throw Error("Session invalidated")}catch(e){return await(0,r.v)(),Promise.reject(e)}return Promise.reject(e)})))}},3633:(e,t,a)=>{"use strict";a.d(t,{A:()=>o,F:()=>i});var n=a(72505),s=a.n(n);const o=()=>s().CancelToken.source(),i=e=>s().isCancel(e)},48900:(e,t,a)=>{"use strict";a.d(t,{W6:()=>m,zz:()=>u});var n=a(2915),s=a(19458),o=a(90336),i=a(1842);const r={credentials:"include",headers:{},baseURL:void 0};let l=null,d=null,c=null,p=null;const u=()=>{r.credentials="include",l=e=>{const{primaryURL:t,noLabelURL:a}=(()=>{const e=["/","http://","https://"];let t,a;const s=(e,t)=>{const a="/"===e,n=t.split(e);return(a?"":e)+(a?n[0]:n[1]).split("/")[0]};for(const o of e)n.as.includes(o)&&(a=s(o,n.as)),n.JI.includes(o)&&(t=s(o,n.JI));return{primaryURL:t,noLabelURL:a}})();if((0,s.x)().isPartner){const n=e.url.replace(t,a);e.url=n}return e},d=async e=>{if(200===e.status){if("Request field missing!"===await e.clone().text())return(0,i.nq)()||(window.location.href="/"),e}if(401===e.status)try{const t=await e.clone().json().catch((()=>({})));if("Token expired."===t?.message){p||(p=(0,o.u)());try{return await p,p=null,{__retry:!0,originalResponse:e}}catch(e){throw p=null,await(0,o.v)(),e}}if(t?.logout)throw Error("Session invalidated")}catch(e){throw p=null,await(0,o.v)(),e}return e},c=async e=>Promise.reject(e)};async function m(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{retry:a=!0,skipAuth:s=!1,skipContentType:o=!1,baseURL:p=r.baseURL||n.k,...u}=t,h=s?null:localStorage.getItem("token"),g=new Headers;
1Object.entries(r.headers).forEach((e=>{let[t,a]=e;g.set(t,a)}));const b=(0,i._E)();b?.apiHeaders&&Object.entries(b.apiHeaders).forEach((e=>{let[t,a]=e;g.set(t,String(a))})),o||g.set("Content-Type","application/json"),h&&g.set("Authorization",`Bearer ${h}`),t.headers&&(t.headers instanceof Headers?t.headers.forEach(((e,t)=>{g.set(t,e)})):Array.isArray(t.headers)?t.headers.forEach((e=>{let[t,a]=e;g.set(t,a)})):Object.entries(t.headers).forEach((e=>{let[t,a]=e;g.set(t,a)})));let y=e.startsWith("http")?e:`${p}${e}`,x={...u,headers:g,credentials:u.credentials||r.credentials};if(l){const e=l({url:y,options:x});y=e.url,x=e.options}try{let n=await fetch(y,x);if(d)try{const o=await d(n);if(o&&!0===o.__retry){if(a&&!s)return m(e,{...t,retry:!1});n=o.originalResponse}else n=o}catch(e){throw e}return n}catch(e){if(c)return c(e);throw e instanceof TypeError&&e.message.includes("fetch")?console.error("Network error:",e):console.error("Fetch error:",e),e}}},94558:(e,t,a)=>{"use strict";a.d(t,{AV:()=>h,IH:()=>i,QX:()=>r,Qd:()=>m,S1:()=>l,Tu:()=>p,gi:()=>c,qZ:()=>d,tN:()=>u});var n=a(72505),s=a.n(n),o=a(2915);const i=e=>{let{assistantId:t,clientId:a}=e;return s().post(`${o.k}/meta-ads/fetch-draft-meta-ad`,{assistantId:t,clientId:a}).then((e=>e.data))},r=function(e){let{adId:t,assistantId:a,startDate:n,endDate:i,breakdowns:r}=e,{signal:l}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s().post(`${o.k}/meta-ads/get-ad-breakdown-insights`,{adId:t,assistantId:a,startDate:n,endDate:i,breakdowns:r},l?{signal:l}:void 0).then((e=>e.data))},l=e=>s().post(`${o.k}/meta-ads/fetch-ad-analytics`,e).then((e=>e.data)),d=e=>s().post(`${o.k}/meta-ads/opt-meta-audience-count`,e).then((e=>e.data)),c=e=>s().post(`${o.k}/api/get-daily-template-quota`,{assistantId:e}).then((e=>e.data)),p=e=>s().get(`${o.k}/meta-ads/ads-list`,{params:{assistantId:e}}).then((e=>e.data)),u=e=>{let{assistantId:t,adId:a,previewFormat:n,startDate:i,endDate:r}=e;return s().post(`${o.k}/meta-ads/get-ad-insights`,{assistantId:t,adId:a,previewFormat:n,startDate:i,endDate:r}).then((e=>e.data))},m=function(e){let{cancelToken:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s().post(`${o.k}/meta-ads/get-ad-account-insights`,e,t?{cancelToken:t}:void 0).then((e=>e.data))},h=e=>s().post(`${o.k}/meta-ads/export-ad-account-insights`,e,{responseType:"blob"}).then((e=>e.data))},36175:(e,t,a)=>{"use strict";a.d(t,{$b:()=>I,A7:()=>f,AO:()=>x,BQ:()=>c,CG:()=>y,DX:()=>r,JZ:()=>d,N$:()=>S,Q:()=>A,TE:()=>h,_r:()=>v,aM:()=>m,b0:()=>C,cJ:()=>g,fW:()=>u,s$:()=>l,sz:()=>_,ug:()=>b,x3:()=>p,xS:()=>i});var n=a(72505),s=a.n(n),o=a(2915);const i=async e=>{let{assistantId:t,pageId:a}=e;return(await s().get(`${o.k}/meta-ads/check-lead-form-permissions`,{params:{assistantId:t,pageId:a}})).data},r=async e=>{let{assistantId:t,pageId:a}=e;return(await s().post(`${o.k}/meta-ads/accept-lead-form-tos`,{assistantId:t,pageId:a})).data},l=async e=>{let{assistantId:t,pageId:a,status:n="ACTIVE",limit:i=50}=e;return(await s().get(`${o.k}/meta-ads/lead-forms`,{params:{assistantId:t,pageId:a,status:n,limit:i}})).data},d=async e=>{let{assistantId:t,pageId:a}=e;return(await s().post(`${o.k}/meta-ads/sync-lead-forms`,{assistantId:t,pageId:a})).data},c=async e=>(await s().post(`${o.k}/meta-ads/create-lead-form`,e)).data,p=async e=>{let{assistantId:t,formId:a,automation:n}=e;return(await s().put(`${o.k}/meta-ads/update-lead-form-automation`,{assistantId:t,formId:a,automation:n})).data},u=async e=>(await s().get(`${o.k}/meta-ads/lead-form-parameters`,{params:{assistantId:e}})).data,m=async e=>{let{assistantId:t,parameters:a}=e;return(await s().post(`${o.k}/meta-ads/lead-form-parameters`,{assistantId:t,parameters:a})).data},h=async e=>{let{assistantId:t,pageId:a,formId:n,...i}=e;return(await s().post(`${o.k}/meta-ads/sync-form-leads`,{assistantId:t,pageId:a,formId:n,...i})).data},g=async e=>{let{assistantId:t,syncBatchId:a,formId:n}=e;const i={assistantId:t};a&&(i.syncBatchId=a),n&&(i.formId=n);return(await s().get(`${o.k}/meta-ads/lead-sync-status`,{params:i})).data},b=async e=>(await s().get(`${o.k}/meta-ads/lead-contacts`,{params:e})).data,y=async e=>(await s().get(`${o.k}/meta-ads/lead-gen-stats`,{params:e})).data,x=async(e,t)=>(await s().get(`${o.k}/meta-ads/lead-contact/${e}/lead-submissions`,{params:t}
1)).data,f=async e=>(await s().get(`${o.k}/meta-ads/lead-forms`,{params:e})).data,A=async(e,t)=>(await s().get(`${o.k}/meta-ads/lead-form/${e}`,{params:{assistantId:t}})).data,I=async(e,t)=>(await s().get(`${o.k}/meta-ads/lead-form/${e}/overview`,{params:t})).data,C=async e=>(await s().get(`${o.k}/meta-ads/lead-analytics`,{params:e})).data,_=e=>s().get(`${o.k}/meta-ads/export-lead-contacts`,{params:e,responseType:"blob"}),S=e=>s().get(`${o.k}/meta-ads/export-form-responses`,{params:e,responseType:"blob"}),v=async e=>(await s().post(`${o.k}/meta-ads/fetch-historical-leads`,e)).data},5282:(e,t,a)=>{"use strict";a.d(t,{Ep:()=>i,tu:()=>r});var n=a(72505),s=a.n(n),o=a(2915);const i=e=>{let{assistantId:t,search:a,page:n,limit:i}=e;return s().get(`${o.k}/api/lists`,{params:{assistantId:t,...a?{search:a}:{},page:n,limit:i}}).then((e=>e.data))},r=e=>{let{assistantId:t,allFilters:a}=e;return s().post(`${o.k}/api/contacts-count`,{assistantId:t,allFilters:a}).then((e=>e.data))}},44665:(e,t,a)=>{"use strict";a.d(t,{k_:()=>o});var n=a(72505),s=a.n(n);a(2915);const o=e=>s().get(`${e}?not-from-cache-please`,{responseType:"blob",headers:{Authorization:""}})},56954:(e,t,a)=>{"use strict";a.d(t,{Vn:()=>r,X3:()=>i,aR:()=>l,cT:()=>d,rg:()=>c});var n=a(72505),s=a.n(n),o=a(2915);const i=async(e,t,a)=>(await s().get(`${o.k}/meta-ads/pixel/details`,{params:{pixelId:e,assistantId:t,event:a}})).data,r=async e=>{let{assistantId:t,pixelName:a,pixelDescription:n}=e;return(await s().post(`${o.k}/meta-ads/pixel`,{assistantId:t,pixelName:a,pixelDescription:n})).data},l=async e=>{let{assistantId:t,page:a,limit:n,search:i}=e;const r={page:a,limit:n,assistantId:t};i&&i.trim()&&(r.search=i.trim());return(await s().get(`${o.k}/meta-ads/pixel`,{params:r})).data},d=async e=>{let{assistantId:t,pixelId:a,start_time:n,end_time:i}=e;const r={assistantId:t,pixelId:a,...n&&{start_time:n},...i&&{end_time:i}};return(await s().get(`${o.k}/meta-ads/pixel/stats`,{params:r})).data},c=async e=>{let{assistantId:t}=e;return(await s().post(`${o.k}/meta-ads/sync-pixels`,{assistantId:t})).data}},39356:(e,t,a)=>{"use strict";a.d(t,{PS:()=>u,X8:()=>r,cx:()=>d,hv:()=>c,jf:()=>l,n3:()=>h,s9:()=>g,uF:()=>m,xi:()=>p});var n=a(72505),s=a.n(n),o=a(2915);const i=function(e,t){let{signal:a}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s().post(`${o.k}/meta-ads${e}`,t,a?{signal:a}:void 0).then((e=>e.data))},r=e=>{let{assistantId:t,adAccountId:a,text:n,signal:s}=e;return i("/location-search",{assistantId:t,adAccountId:a,text:n},{signal:s})},l=e=>{let{assistantId:t,adAccountId:a,text:n,countries:s,signal:o}=e;return i("/target-search",{assistantId:t,adAccountId:a,text:n,countries:s},{signal:o})},d=e=>{let{assistantId:t,text:a}=e;return i("/search-audience",{assistantId:t,text:a})},c=e=>s().get(`${o.k}/meta-ads/get-latest-audiences`,{params:{assistantId:e}}).then((e=>e.data)),p=e=>{let{audienceId:t,assistantId:a}=e;return s().get(`${o.k}/meta-ads/get-audience-by-id?audienceId=${t}&assistantId=${a}`).then((e=>e.data))},u=e=>i("/create-audience",e),m=e=>i("/update-audience",e),h=e=>i("/get-delivery-estimate-result",e),g=e=>i("/validate-advanced-targeting",e)},70727:(e,t,a)=>{"use strict";a.d(t,{p:()=>x});var n=a(33297),s=a(65613),o=a(37200);const i={};var r=a(18880),l=a(55248),d=a(85301),c=a(90935),p=a(60427),u=a(86012),m=a(58416),h=a(27671),g=a(21047),b=a(83560);const y={[r.$9]:r.Ay,[l.$9]:l.Ay,[d.$9]:d.Ay,[c.$9]:c.Ay,[p.$9]:p.Ay,[u.$9]:u.Ay,[m.$9]:m.Ay,[h.$9]:h.Ay,[g.$9]:g.Ay,[b.$9]:b.Ay},x=()=>(e=>{const t=Object.keys(e).filter((e=>!i[e]));if(0===t.length)return;t.forEach((t=>{i[t]=e[t]}));const a=(0,o.v)();a&&a.replaceReducer((0,n.combineReducers)({...s.E,...i}))})(y)},65613:(e,t,a)=>{"use strict";a.d(t,{A:()=>k,E:()=>j});var n=a(33297);const s={users:{all:{},open:[],resolved:[],pending:[]},selectedUser:null,isLoading:!1};var o=a(29390);const i={allFilters:null};const r={isLoading:!1,isAuthenticated:!1,user:{},error:null,errmsg:""},l="Login/START_LOGIN",d="Login/LOGIN_SUCCESS",c="Login/LOGIN_FAILURE",p="Login/RESET_ERROR",u="Login/SIGN_OUT_SUCCESS",m="Login/USER_DATA_UPDATE";var h=a(95454),g=a(6379),b=a(36412),y=a(9928);a(72505),a(2915);const x={isLoading:!1,installedApps:[],error:null},f="InstalledApps/START_FETCH",A="InstalledApps/FETCH_SUCCESS",I="InstalledApps/FETCH_FAILURE",C="InstalledApps/RESET_ERROR";const _={arePublicAppsLoading:!1,publicApps:null,publicAppsError:null,isAppLoading:!1,apps:{},appError:null};var S=a(47766),v=a(68049);const E={isLoading:!1,isChatSearch:!1,searchText:"",selectedMessage:null,chats:[],selectedUserData:null,firstLoadedMessageOfUser:[]};var T=a(66289),D=a(5795),w=a(11859),N=a(20345);const j={user:function(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:s},lists:o.Ay,audience:N.Ay,tags:h.A,filters:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i,{type:t,payload:a}=arguments.length>1?arguments[1]:void 0;switch(t){case"FILTERS/SET_FILTERS":return{allFilters:a};case"FILTERS/RESET_FILTERS":return{...i};default:return e}},agents:g.Ay,campaignsList:y.Ay,installedApps:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:x,{type:t,payload:a}=arguments.length>1?arguments[1]:void 0;switch(t){case f:return{...e,isLoading:!0};case A:return{...e,isLoading:!1,error:null,installedApps:[...a]};case I:return{...e,isLoading:!1,error:a};case C:return{...e,error:null};case"InstalledApps/ADD_INSTALLED_APP":return{...e,installedApps:[...e.installedApps,a]};case"InstalledApps/REMOVE_INSTALLED_APP":return{...e,installedApps:e.installedApps.filter((e=>e.appName!==a))};case"InstalledApps/RESET_FETCH":return{...x};default:return e}},appStore:function(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:_},media:S.Ay,templates:v.Ay,chatsSearch:function(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:E},ads:D.Ay,assistantDetails:T.Ay,cartPlus:b.Ay,flow:w.Ay,login:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:r,{type:t,payload:a}=arguments.length>1?arguments[1]:void 0;switch(t){case l:return{...e,isLoading:!0};case d:return{...e,isLoading:!1,isAuthenticated:!0,error:null,user:{...a}};case m:return{...e,user:{...a}};case"UPDATE_USER_FIELD":return{...e,user:{...e.user,[a.field]:a.value}};case c:return{...e,isLoading:!1,error:!0,errmsg:a.errmsg};case p:return{...e,error:!1};case u:return{...e,isAuthenticated:!1};case"Login/FIRST_PROJECT_ADDED":return{...e,user:{...e.user,firstProjectId:a}};default:return e}}},k=(0,n.combineReducers)(j)},18880:(e,t,a)=>{"use strict";a.d(t,{$9:()=>d,xS:()=>F,Ay:()=>W,PH:()=>P,vy:()=>M,M0:()=>U,ae:()=>L,cg:()=>R,VJ:()=>k,KT:()=>B,ZM:()=>O});var n=a(97915),s=a(72505),o=a.n(s),i=a(2915);var r=a(86920),l=a(36175);const d="adSetup",c="AdSetup/PAGES_START",p="AdSetup/PAGES_SUCCESS",u="AdSetup/PAGES_FAILURE",m="AdSetup/ACCOUNTS_START",h="AdSetup/ACCOUNTS_SUCCESS",g="AdSetup/ACCOUNTS_FAILURE",b="AdSetup/SETUP_SUCCESS",y="AdSetup/SYNC_START",x="AdSetup/SYNC_SETTLED",f="AdSetup/FB_CONNECT_START",A="AdSetup/FB_CONNECT_SUCCESS",I="AdSetup/FB_CONNECT_FAILURE",C="AdSetup/FB_DISCONNECT_START",_="AdSetup/FB_DISCONNECT_SUCCESS",S="AdSetup/FB_DISCONNECT_FAILURE",v="AdSetup/CONNECT_ADS_LINK_START",E="AdSetup/CONNECT_ADS_LINK_SUCCESS",T="AdSetup/CONNECT_ADS_LINK_FAILURE",D="AdSetup/LEAD_FORM_PERMISSIONS_START",w="AdSetup/LEAD_FORM_PERMISSIONS_SUCCESS",N="AdSetup/LEAD_FORM_PERMISSIONS_FAILURE",j={pages:[],accounts:[],isLoadingPages:!1,isLoadingAccounts:!1,isSyncing:!1,setup:null,isConnectingFb:!1,isDisconnectingFb:!1,isGeneratingConnectAdsLink:!1,leadFormPermissions:null,isCheckingLeadFormPermissions:!1,error:null},k=(e,t)=>async a=>{if(!e)return[];a({type:c});try{const s=await(0,n.f1)(e,t);return a({type:p,payload:s}),s}catch(e){throw a({type:u,payload:e}),e}},L=(e,t)=>async a=>{if(!e)return[];a({type:m});try{const s=await(0,n.eP)(e,t);return a({type:h,payload:s}),s}catch(e){throw a({type:g,payload:e}),e}},R=(e,t)=>async a=>{const n=await async function(e){let{cancelToken:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=await o().post(`${i.k}/meta-ads/fetch-meta-ad-setup`,{assistantId:e},t?{cancelToken:t}:void 0),n=a?.data||{},{isValid:s,userId:r,pageId:l,adAccountId:d}=n;return{isValid:s,userId:r,pageId:l,adAccountId:d,adAccountSetupCompleted:"boolean"==typeof n.isAdAccountSetupCompleted?n.isAdAccountSetupCompleted:Boolean(s&&l&&d),raw:n}}(e,t);return a({type:b,payload:n}),n},B=e=>{let{assistantId:t,selectedMetaAdAccountId:a,selectedMetaPageId:s}=e;return async()=>(0,n.$3)({assistantId:t,selectedMetaAdAccountId:a,selectedMetaPageId:s}
1)},O=e=>{let{assistantId:t,adAccountId:a,mode:s}=e;return async e=>{e({type:y});try{return await(0,n.eF)({assistantId:t,adAccountId:a,mode:s})}finally{e({type:x})}}},P=e=>async t=>{t({type:f});try{const a=await(0,r.PH)(e);return t({type:A,payload:a}),a}catch(e){throw t({type:I,payload:e}),e}},M=e=>async t=>{t({type:C});try{const a=await(0,r.vy)(e);return t({type:_,payload:a}),a}catch(e){throw t({type:S,payload:e}),e}},U=e=>async t=>{t({type:v});try{const a=await(0,r.M0)(e);return t({type:E,payload:a}),a}catch(e){throw t({type:T,payload:e}),e}},F=e=>async t=>{t({type:D});try{const a=await(0,l.xS)(e);return t({type:w,payload:a}),a}catch(e){throw t({type:N,payload:e}),e}};function W(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:j,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case c:return{...e,isLoadingPages:!0,error:null};case p:return{...e,isLoadingPages:!1,pages:t.payload||[]};case u:return{...e,isLoadingPages:!1,error:t.payload};case m:return{...e,isLoadingAccounts:!0,error:null};case h:return{...e,isLoadingAccounts:!1,accounts:t.payload||[]};case g:return{...e,isLoadingAccounts:!1,error:t.payload};case b:return{...e,setup:t.payload};case y:return{...e,isSyncing:!0};case x:return{...e,isSyncing:!1};case f:return{...e,isConnectingFb:!0,error:null};case A:return{...e,isConnectingFb:!1};case I:return{...e,isConnectingFb:!1,error:t.payload};case C:return{...e,isDisconnectingFb:!0,error:null};case _:return{...e,isDisconnectingFb:!1};case S:return{...e,isDisconnectingFb:!1,error:t.payload};case v:return{...e,isGeneratingConnectAdsLink:!0,error:null};case E:return{...e,isGeneratingConnectAdsLink:!1};case T:return{...e,isGeneratingConnectAdsLink:!1,error:t.payload};case D:return{...e,isCheckingLeadFormPermissions:!0,error:null};case w:return{...e,isCheckingLeadFormPermissions:!1,leadFormPermissions:t.payload};case N:return{...e,isCheckingLeadFormPermissions:!1,error:t.payload};default:return e}}},86012:(e,t,a)=>{"use strict";a.d(t,{$9:()=>d,xS:()=>V,R_:()=>Y,Xu:()=>W,Ay:()=>Z,Ap:()=>H,eG:()=>F,vm:()=>z,X8:()=>M,jf:()=>U,d3:()=>G});var n=a(39356),s=a(46758),o=a(14507);var i=a(2915);a(23800),a(47766),a(44665);var r=a(72505),l=a.n(r);const d="adTemplates",c="AdTemplates/SEARCH_LOCATIONS_START",p="AdTemplates/SEARCH_LOCATIONS_SUCCESS",u="AdTemplates/SEARCH_LOCATIONS_FAILURE",m="AdTemplates/SEARCH_TARGETS_START",h="AdTemplates/SEARCH_TARGETS_SUCCESS",g="AdTemplates/SEARCH_TARGETS_FAILURE",b="AdTemplates/LOAD_TEMPLATES_START",y="AdTemplates/LOAD_TEMPLATES_SUCCESS",x="AdTemplates/LOAD_TEMPLATES_FAILURE",f="AdTemplates/CREATE_TEMPLATE_START",A="AdTemplates/CREATE_TEMPLATE_SUCCESS",I="AdTemplates/CREATE_TEMPLATE_FAILURE",C="AdTemplates/RETRY_TEMPLATE_START",_="AdTemplates/RETRY_TEMPLATE_SUCCESS",S="AdTemplates/RETRY_TEMPLATE_FAILURE",v="AdTemplates/UPDATE_TEMPLATE_VARIANT_START",E="AdTemplates/UPDATE_TEMPLATE_VARIANT_SUCCESS",T="AdTemplates/UPDATE_TEMPLATE_VARIANT_FAILURE",D="AdTemplates/LOAD_META_AD_SETUP_START",w="AdTemplates/LOAD_META_AD_SETUP_SUCCESS",N="AdTemplates/LOAD_META_AD_SETUP_FAILURE",j="AdTemplates/CHECK_LEAD_FORM_PERMISSIONS_START",k="AdTemplates/CHECK_LEAD_FORM_PERMISSIONS_SUCCESS",L="AdTemplates/CHECK_LEAD_FORM_PERMISSIONS_FAILURE",R="AdTemplates/CREATE_META_AD_START",B="AdTemplates/CREATE_META_AD_SUCCESS",O="AdTemplates/CREATE_META_AD_FAILURE",P={locationResults:[],isSearchingLocations:!1,targetResults:[],isSearchingTargets:!1,templates:null,isLoadingTemplates:!1,metaAdSetup:null,leadFormPermissions:null,error:null},M=e=>async t=>{t({type:c});try{const a=await(e=>{let{assistantId:t,adAccountId:a,text:o,signal:i}=e;return(0,n.X8)({assistantId:t,adAccountId:a,text:o,signal:i}).then((e=>(0,s.CL)(e?.data)))})(e);return t({type:p,payload:a}),a}catch(e){throw t({type:u,payload:e}),e}},U=e=>async t=>{t({type:m});try{const a=await(e=>{let{assistantId:t,adAccountId:a,text:s,countries:i=[],signal:r}=e;return(0,n.jf)({assistantId:t,adAccountId:a,text:s,countries:i,signal:r}).then((e=>(0,o.p1)(Array.isArray(e?.data)?e.data:[],i)))})(e);return t({type:h,payload:a}),a}catch(e){throw t({type:g,payload:e}),e}},F=(e,t)=>async a=>{a({type:b});try{const n=await function(e){let{page:t=1,status:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l().get(`${i.k}/ad-templates`,{params:{assistantId:e,page:t,limit:10,...a?{status:a}:{}}}).then((e=>e.data))}(e,t);return a({type:y,payload:n}),n}catch(e){throw a({type:x,payload:e}),e}},W=(e,t,a,n,s)=>async o=>{o({type:f});try{const r=await((e,t,a,n,s)=>l().post(`${i.k}/ad-templates`,{assistantId:e,prompt:t,templateCount:a,...n?{aspectRatio:n}:{},...s?{creativeFormat:s}:{}}).then((e=>e.data?.data)))(e,t,a,n,s);return o({type:A,payload:r}),r}catch(e){throw o({type:I,payload:e}),e}},z=(e,t)=>async a=>{a({type:C});try{const n=await((e,t)=>l().post(`${i.k}/ad-templates/${e}
1/retry`,t&&t.length?{variantIndexes:t}:{}).then((e=>e.data?.data)))(e,t);return a({type:_,payload:n}),n}catch(e){throw a({type:S,payload:e}),e}},G=(e,t,a)=>async n=>{n({type:v});try{const s=await((e,t,a)=>l().patch(`${i.k}/ad-templates/${e}`,{assistantId:t,variants:[a]}).then((e=>e.data?.data)))(e,t,a);return n({type:E,payload:s}),s}catch(e){throw n({type:T,payload:e}),e}},H=e=>async t=>{t({type:D});try{const a=await(e=>l().post(`${i.k}/meta-ads/fetch-meta-ad-setup`,{assistantId:e}).then((e=>e.data||{})).catch((()=>({}))))(e);return t({type:w,payload:a}),a}catch(e){throw t({type:N,payload:e}),e}},V=(e,t)=>async a=>{a({type:j});try{const n=await((e,t)=>l().get(`${i.k}/meta-ads/check-lead-form-permissions`,{params:{assistantId:e,pageId:t}}).then((e=>e.data||{})).catch((()=>({}))))(e,t);return a({type:k,payload:n}),n}catch(e){throw a({type:L,payload:e}),e}},Y=e=>async t=>{t({type:R});try{const a=await(e=>l().post(`${i.k}/meta-ads/create-meta-ad`,e).then((e=>e.data)))(e);return t({type:B,payload:a}),a}catch(e){throw t({type:O,payload:e}),e}};function Z(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:P,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(t.type){case c:return{...e,isSearchingLocations:!0,error:null};case p:return{...e,isSearchingLocations:!1,locationResults:t.payload};case u:return{...e,isSearchingLocations:!1,error:t.payload};case m:return{...e,isSearchingTargets:!0,error:null};case h:return{...e,isSearchingTargets:!1,targetResults:t.payload};case g:return{...e,isSearchingTargets:!1,error:t.payload};case b:return{...e,isLoadingTemplates:!0,error:null};case y:return{...e,isLoadingTemplates:!1,templates:t.payload};case x:return{...e,isLoadingTemplates:!1,error:t.payload};case f:return{...e,error:null};case A:return e;case I:return{...e,error:t.payload};case C:return{...e,error:null};case _:return e;case S:return{...e,error:t.payload};case v:return{...e,error:null};case E:return e;case T:return{...e,error:t.payload};case D:return{...e,error:null};case w:return{...e,metaAdSetup:t.payload};case N:return{...e,error:t.payload};case j:return{...e,error:null};case k:return{...e,leadFormPermissions:t.payload};case L:return{...e,error:t.payload};case R:return{...e,error:null};case B:return e;case O:return{...e,error:t.payload};default:return e}}},27671:(e,t,a)=>{"use strict";a.d(t,{$9:()=>l,Ay:()=>$,C$:()=>K,CV:()=>J,ZK:()=>Z,iI:()=>V,ic:()=>H,qM:()=>Y,xx:()=>G});var n=a(97915),s=(a(86920),a(94558)),o=a(14272),i=a(42094),r=a(3633);const l="adsManager",d="AdsManager/NEW_CTW_ADS_START",c="AdsManager/NEW_CTW_ADS_SUCCESS",p="AdsManager/NEW_CTW_ADS_FAILURE",u="AdsManager/FREEZE_ASSET_START",m="AdsManager/FREEZE_ASSET_SUCCESS",h="AdsManager/FREEZE_ASSET_FAILURE",g="AdsManager/UNFREEZE_ASSETS_START",b="AdsManager/UNFREEZE_ASSETS_SUCCESS",y="AdsManager/UNFREEZE_ASSETS_FAILURE",x="AdsManager/UPDATE_META_WHATSAPP_NUMBER_START",f="AdsManager/UPDATE_META_WHATSAPP_NUMBER_SUCCESS",A="AdsManager/UPDATE_META_WHATSAPP_NUMBER_FAILURE",I="AdsManager/AD_ANALYTICS_START",C="AdsManager/AD_ANALYTICS_SUCCESS",_="AdsManager/AD_ANALYTICS_FAILURE",S="AdsManager/OPTED_AUDIENCE_COUNT_START",v="AdsManager/OPTED_AUDIENCE_COUNT_SUCCESS",E="AdsManager/OPTED_AUDIENCE_COUNT_FAILURE",T="AdsManager/EXPORT_META_AUDIENCE_START",D="AdsManager/EXPORT_META_AUDIENCE_SUCCESS",w="AdsManager/EXPORT_META_AUDIENCE_FAILURE",N="AdsManager/SEGREGATED_OPTED_START",j="AdsManager/SEGREGATED_OPTED_SUCCESS",k="AdsManager/SEGREGATED_OPTED_FAILURE",L="AdsManager/DRAFT_ADS_START",R="AdsManager/DRAFT_ADS_SUCCESS",B="AdsManager/DRAFT_ADS_FAILURE",O="AdsManager/ADS_START",P="AdsManager/ADS_SUCCESS",M="AdsManager/ADS_FAILURE",U="AdsManager/AD_BREAKDOWN_INSIGHTS_START",F="AdsManager/AD_BREAKDOWN_INSIGHTS_SUCCESS",W="AdsManager/AD_BREAKDOWN_INSIGHTS_FAILURE",z={newCtwAds:null,isLoadingNewCtwAds:!1,isFreezingAsset:!1,isUnfreezingAssets:!1,isUpdatingMetaWhatsappNumber:!1,adAnalytics:null,isLoadingAdAnalytics:!1,optedAudienceCount:null,isLoadingOptedAudienceCount:!1,isExportingMetaAudience:!1,segregatedOpted:null,isLoadingSegregatedOpted:!1,draftAds:null,isLoadingDraftAds:!1,ads:null,isLoadingAds:!1,adBreakdownInsights:null,isLoadingAdBreakdownInsights:!1,error:null},G=e=>async t=>{t({type:d});try{const a=await(0,n.LZ)(e);return t({type:c,payload:a}),a}catch(e){throw t({type:p,payload:e}),e}}
1,H=e=>async t=>{t({type:I});try{const a=await(0,s.S1)(e);return t({type:C,payload:a}),a}catch(e){throw t({type:_,payload:e}),e}},V=e=>async t=>{t({type:S});try{const a=await(0,s.qZ)(e);return t({type:v,payload:a}),a}catch(e){throw t({type:E,payload:e}),e}},Y=e=>async t=>{t({type:T});try{const a=await(0,o.qM)(e);return t({type:D,payload:a}),a}catch(e){throw t({type:w,payload:e}),e}},Z=e=>async t=>{t({type:N});try{const a=await(0,i.u5)(e);return t({type:j,payload:a}),a}catch(e){throw t({type:k,payload:e}),e}},K=e=>async t=>{t({type:L});try{const a=await(0,s.IH)(e);return t({type:R,payload:a}),a}catch(e){throw t({type:B,payload:e}),e}},J=(e,t)=>async a=>{a({type:U});try{const n=await(0,s.QX)(e,t);return a({type:F,payload:n}),n}catch(e){throw(0,r.F)(e)||a({type:W,payload:e}),e}};function $(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:z,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(t.type){case d:return{...e,isLoadingNewCtwAds:!0,error:null};case c:return{...e,isLoadingNewCtwAds:!1,newCtwAds:t.payload};case p:return{...e,isLoadingNewCtwAds:!1,error:t.payload};case u:return{...e,isFreezingAsset:!0,error:null};case m:return{...e,isFreezingAsset:!1};case h:return{...e,isFreezingAsset:!1,error:t.payload};case g:return{...e,isUnfreezingAssets:!0,error:null};case b:return{...e,isUnfreezingAssets:!1};case y:return{...e,isUnfreezingAssets:!1,error:t.payload};case x:return{...e,isUpdatingMetaWhatsappNumber:!0,error:null};case f:return{...e,isUpdatingMetaWhatsappNumber:!1};case A:return{...e,isUpdatingMetaWhatsappNumber:!1,error:t.payload};case I:return{...e,isLoadingAdAnalytics:!0,error:null};case C:return{...e,isLoadingAdAnalytics:!1,adAnalytics:t.payload};case _:return{...e,isLoadingAdAnalytics:!1,error:t.payload};case S:return{...e,isLoadingOptedAudienceCount:!0,error:null};case v:return{...e,isLoadingOptedAudienceCount:!1,optedAudienceCount:t.payload};case E:return{...e,isLoadingOptedAudienceCount:!1,error:t.payload};case T:return{...e,isExportingMetaAudience:!0,error:null};case D:return{...e,isExportingMetaAudience:!1};case w:return{...e,isExportingMetaAudience:!1,error:t.payload};case N:return{...e,isLoadingSegregatedOpted:!0,error:null};case j:return{...e,isLoadingSegregatedOpted:!1,segregatedOpted:t.payload};case k:return{...e,isLoadingSegregatedOpted:!1,error:t.payload};case L:return{...e,isLoadingDraftAds:!0,error:null};case R:return{...e,isLoadingDraftAds:!1,draftAds:t.payload};case B:return{...e,isLoadingDraftAds:!1,error:t.payload};case O:return{...e,isLoadingAds:!0,error:null};case P:return{...e,isLoadingAds:!1,ads:t.payload};case M:return{...e,isLoadingAds:!1,error:t.payload};case U:return{...e,isLoadingAdBreakdownInsights:!0,error:null};case F:return{...e,isLoadingAdBreakdownInsights:!1,adBreakdownInsights:t.payload};case W:return{...e,isLoadingAdBreakdownInsights:!1,error:t.payload};default:return e}}},5795:(e,t,a)=>{"use strict";a.d(t,{$g:()=>ye,Ay:()=>pt,Br:()=>ct,DA:()=>Be,Dz:()=>dt,F5:()=>lt,FZ:()=>fe,J6:()=>m,QO:()=>Se,Qd:()=>Ze,Rp:()=>ze,SS:()=>Ne,TC:()=>rt,TH:()=>be,Tu:()=>tt,UW:()=>it,WW:()=>De,XF:()=>nt,_Z:()=>we,_r:()=>at,a4:()=>Ce,ak:()=>Ke,am:()=>Ee,az:()=>st,bk:()=>je,cq:()=>Qe,e7:()=>Te,ep:()=>Ye,hr:()=>Ae,ie:()=>Le,jc:()=>ut,kR:()=>Ie,lw:()=>he,mO:()=>ve,nK:()=>ot,qV:()=>ge,s$:()=>et,tY:()=>Re,vW:()=>xe,y4:()=>_e,yN:()=>Oe});var n=a(95093),s=a.n(n),o=a(2915),i=a(5243),r=a(48900),l=a(3633),d=a(49525),c=a(94558),p=a(42094),u=a(36175);const m=25,h=()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}},g={selectedMedia:{},selectedFile:null,details:"",previewImageUrl:null,filename:"",adName:"",budget:null,gender:"ALL",time:0,fileSection:"IMAGE",thumbnailUrl:null,thumbnailMedia:{},pageDetails:{},heading:"",adInsights:{isLoading:!1,iframePreview:null,insights:null,error:null},syncAd:{isLoading:!1,adData:null,adAccount:null,error:null},updateAdStatus:{isLoading:!1,error:null},adAccountInsights:{isLoading:!1,isLoadingAds:!1,isLoadingAggregated:!1,data:null,headerColumns:[],pagination:null,aggregated:null,error:null,lastFetchParams:null,streamController:null},exportAdInsights:{isLoading:!1,error:null},leads:{leads:[],ctwaLeads:[],forms:[],ads:[],leadsAds:[],ctwaAds:[],loading:!1,ctwaLoading:!1,statsLoading:!1,fetchingHistorical:!1,isExporting:!1,error:null,page:0,rowsPerPage:10,ctwaPage:0,ctwaRowsPerPage:10,total:0,search:"",selectedFormId:"",selectedAdId:"",selectedAdIdCTWA:"",startDate:null,endD
1ate:null,stats:{total:0},selected:[],selectAll:!1,unSelected:[],selectedCount:0,selectedOptNo:0,unSelectedOptNo:0,activeTab:"all",fetchHistoricalFormId:"",fetchHistoricalStartDate:null,fetchHistoricalEndDate:null,fetchHistoricalResult:null}},b="ADS/CREATE_ADS",y="ADS/DETAILS",x="ADS/BUDGET",f="ADS/GENDER",A="ADS/NAME",I="ADS/PAGE_DETAILS",C="ADS/FETCH_AD_INSIGHTS_START",_="ADS/FETCH_AD_INSIGHTS_SUCCESS",S="ADS/FETCH_AD_INSIGHTS_FAILURE",v="ADS/SYNC_AD_START",E="ADS/SYNC_AD_SUCCESS",T="ADS/SYNC_AD_FAILURE",D="ADS/UPDATE_AD_STATUS_START",w="ADS/UPDATE_AD_STATUS_SUCCESS",N="ADS/UPDATE_AD_STATUS_FAILURE",j="ADS/PATCH_AD_STATUSES",k="ADS/FETCH_AD_ACCOUNT_INSIGHTS_START",L="ADS/FETCH_AD_ACCOUNT_INSIGHTS_SUCCESS",R="ADS/FETCH_AD_ACCOUNT_INSIGHTS_FAILURE",B="ADS/FETCH_AD_ACCOUNT_INSIGHTS_STREAM_START",O="ADS/FETCH_AD_ACCOUNT_INSIGHTS_STREAM_ADS",P="ADS/FETCH_AD_ACCOUNT_INSIGHTS_STREAM_AGGREGATED",M="ADS/FETCH_AD_ACCOUNT_INSIGHTS_STREAM_ERROR",U="ADS/FETCH_AD_ACCOUNT_INSIGHTS_STREAM_COMPLETE",F="ADS/EXPORT_AD_INSIGHTS_START",W="ADS/EXPORT_AD_INSIGHTS_SUCCESS",z="ADS/EXPORT_AD_INSIGHTS_FAILURE",G="ADS/CLEAR_AD_ACCOUNT_INSIGHTS",H="ADS/FETCH_LEADS_START",V="ADS/FETCH_LEADS_SUCCESS",Y="ADS/FETCH_LEADS_FAILURE",Z="ADS/FETCH_CTWA_LEADS_START",K="ADS/FETCH_CTWA_LEADS_SUCCESS",J="ADS/FETCH_CTWA_LEADS_FAILURE",$="ADS/FETCH_LEAD_FORMS_START",q="ADS/FETCH_LEAD_FORMS_SUCCESS",X="ADS/FETCH_LEAD_FORMS_FAILURE",Q="ADS/FETCH_LEADS_STATS_START",ee="ADS/FETCH_LEADS_STATS_SUCCESS",te="ADS/FETCH_LEADS_STATS_FAILURE",ae="ADS/FETCH_HISTORICAL_LEADS_START",ne="ADS/FETCH_HISTORICAL_LEADS_SUCCESS",se="ADS/FETCH_HISTORICAL_LEADS_FAILURE",oe="ADS/EXPORT_LEADS_START",ie="ADS/EXPORT_LEADS_SUCCESS",re="ADS/EXPORT_LEADS_FAILURE",le="ADS/UPDATE_LEADS_FILTERS",de="ADS/UPDATE_LEADS_PAGINATION",ce="ADS/UPDATE_LEADS_SELECTION",pe="ADS/CLEAR_LEADS_SELECTION",ue="ADS/SET_LEADS_ACTIVE_TAB",me="ADS/UPDATE_LEADS_OPTED_COUNT",he=e=>t=>{t((e=>{let{payload:t}=e;return{type:b,payload:t}})({payload:e}))},ge=e=>t=>{t((e=>{let{payload:t}=e;return{type:x,payload:t}})({payload:e}))},be=e=>t=>{t((e=>{let{payload:t}=e;return{type:A,payload:t}})({payload:e}))},ye=e=>t=>{t((e=>{let{payload:t}=e;return{type:y,payload:t}})({payload:e}))},xe=e=>t=>{t((e=>{let{payload:t}=e;return{type:I,payload:t}})({payload:e}))},fe=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;return async(o,i)=>{o({type:C});try{const i=await(0,c.tN)({assistantId:e,adId:t,previewFormat:a,startDate:n?.format("YYYY-MM-DD"),endDate:s?.format("YYYY-MM-DD")});o({type:_,payload:{iframePreview:i?.iframePreview||i?.previewIframe||null,insights:i?.insights||i||null}})}catch(e){o((e=>({type:S,payload:e}))(e.response?.data?.message||e.message||"Failed to fetch ad insights"))}}},Ae=(e,t)=>
1async a=>{a({type:v});try{const n=await(0,d.hr)({assistantId:e,adId:t});return a({type:E,payload:{adData:n?.adData||null,adAccount:n?.adAccountData||null}}),n}catch(e){throw a((e=>({type:T,payload:e}))(e.response?.data?.message||e.message||"Failed to sync ad")),e}},Ie=async function(e,t,a){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return(0,u.TE)({assistantId:e,pageId:t,formId:a,...n})},Ce=async(e,t)=>Ie(e,t,void 0,{syncFormsOnly:!0}),_e=async function(e){let{syncBatchId:t,formId:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,u.cJ)({assistantId:e,syncBatchId:t,formId:a})},Se=async e=>(0,c.gi)(e),ve=async e=>{let{assistantId:t,type:a="all",search:n,formId:s,adId:o,startDate:i,endDate:r,page:l=1,limit:d=10,answers:c}=e;const p={assistantId:t,type:a,page:l,limit:d};n&&(p.search=n),s&&(p.formId=s),o&&(p.adId=o),i&&(p.startDate=i),r&&(p.endDate=r),Array.isArray(c)&&c.length&&(p.answers=JSON.stringify(c));const m=h();return m&&(p.timezone=m),(0,u.ug)(p)},Ee=async e=>{const t={assistantId:e},a=h();return a&&(t.timezone=a),(0,u.CG)(t)},Te=async function(e,t){let{page:a=1,limit:n=50}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(0,u.AO)(e,{assistantId:t,page:a,limit:n})},De=async function(e,t,a,n){let s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:10,{automationEnabled:i,sortBy:r,sortOrder:l}=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{};const d={assistantId:e,pageId:t,page:s,limit:o};return a&&(d.status=a),n&&(d.search=n),null!=i&&(d.automationEnabled=String(i)),r&&(d.sortBy=r),l&&(d.sortOrder=l),(0,u.A7)(d)},we=async(e,t)=>(0,u.Q)(e,t),Ne=async function(e,t){let{startDate:a,endDate:n}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const s={assistantId:t};a&&(s.startDate=a),n&&(s.endDate=n);const o=h();return o&&(s.timezone=o),(0,u.$b)(e,s)},je=async function(){let{assistantId:e,startDate:t,endDate:a,formId:n,adId:s}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const o={assistantId:e};return t&&(o.startDate=t),a&&(o.endDate=a),n&&(o.formId=n),s&&(o.adId=s),(0,u.b0)(o)},ke=(e,t)=>{let a=t;const n=e.headers["content-disposition"];if(n){const e=n.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);e&&e[1]&&(a=e[1].replace(/['"]/g,""))}const s=new Blob([e.data],{type:"text/csv;charset=utf-8;"}),o=window.URL.createObjectURL(s),i=document.createElement("a");i.href=o,i.download=a,document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(o),document.body.removeChild(i)},Le=async function(e){let{type:t="all",formId:a="",adId:n="",startDate:o=null,endDate:i=null,search:r="",hasSelection:l=!1,selectAll:d=!1,selectedNums:c=[],unselectedNums:p=[]}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)throw new Error("Assistant ID is required for export");const m={assistantId:e,exportType:"form"===t?"form-submissions":"ctwa"===t?"ctwa-leads":"all",sortBy:"createdTime",sortOrder:"desc"};a&&""!==String(a).trim()&&(m.formId=String(a)),n&&""!==String(n).trim()&&(m.adId=String(n)),o&&(m.startDate=s()(o).format("YYYY-MM-DD")),i&&(m.endDate=s()(i).format("YYYY-MM-DD")),m.type=t,r&&""!==String(r).trim()&&(m.search=String(r).trim()),l&&(m.selectAll=d?"true":"false",d?m.unselectedNums=p.join(","):m.selectedNums=c.join(","));const g=h();g&&(m.timezone=g);const b=await(0,u.sz)(m);ke(b,`lead-submissions-${e}-${s()().format("YYYY-MM-DD")}.csv`)},Re=async function(e){let{formId:t,startDate:a=null,endDate:n=null,search:o="",answers:i=null,hasSelection:r=!1,selectAll:l=!1,selectedNums:d=[],unselectedNums:c=[]}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)throw new Error("Assistant ID is required for export");if(!t)throw new Error("Form ID is required for export");const p={assistantId:e,formId:t,sortBy:"createdTime",sortOrder:"desc"};o&&""!==String(o).trim()&&(p.search=String(o).trim()),a&&(p.startDate=s()(a).format("YYYY-MM-DD")),n&&(p.endDate=s()(n).format("YYYY-MM-DD")),Array.isArray(i)&&i.length&&(p.answers=JSON.stringify(i)),r&&(p.selectAll=l?"true":"false",l?p.unselectedNums=c.join(","):p.selectedNums=d.join(","));const m=h();m&&(p.timezone=m);const g=await(0,u.N$)(p);ke(g,`form-responses-${t}-${s()().format("YYYY-MM-DD")}.csv`)},Be=(e,t,a,n,s)=>async o=>{o({type:D});try{const i=await(0,d.DA)({assistantId:e,status:s,adId:a,mongoAdId:t,adAccountId:n}
1);return o({type:w}),i}catch(e){throw o((e=>({type:N,payload:e}))(e.response?.data?.message||e.message||"Failed to update ad status")),e}},Oe=e=>({type:j,payload:Array.isArray(e)?e:[e]}),Pe=e=>({type:L,payload:e}),Me=e=>({type:R,payload:e}),Ue=e=>({type:O,payload:e}),Fe=e=>({type:P,payload:e}),We=e=>({type:M,payload:e}),ze=()=>e=>{e({type:G})};let Ge=null,He=null;const Ve=e=>{const t=[],a=e.split("\n\n");for(let e=0;e<a.length-1;e++){const n=a[e].trim();if(!n)continue;const s={},o=n.split("\n");for(const e of o){const t=e.indexOf(":");if(-1===t)continue;const a=e.substring(0,t).trim(),n=e.substring(t+1).trim();if("data"===a)try{s.data=JSON.parse(n)}catch(e){s.data=n}else s[a]=n}Object.keys(s).length>0&&t.push(s)}return{events:t,remainingBuffer:a.length>0?a[a.length-1]:""}},Ye=()=>{Ge&&(Ge.cancel("Request cancelled due to tab switch"),Ge=null),He&&(He.abort(),He=null)},Ze=e=>{let{assistantId:t,adAccountId:a,page:n=1,limit:s=m,nameQuery:d="",startDate:p=null,endDate:u=null,selectedOption:h=null,bypassCache:g=!1,useStream:b=!0}=e;return async(e,m)=>{if(Ye(),!a)return void e(Me("Ad Account ID is required"));const y=m(),x=y.ads.adAccountInsights.lastFetchParams,f=y.ads.adAccountInsights.data;if(!g&&x&&f){x.accountId===a&&x.startDate?.format("YYYY-MM-DD")===p?.format("YYYY-MM-DD")&&x.endDate?.format("YYYY-MM-DD")===u?.format("YYYY-MM-DD")&&x.selectedOption===h&&x.nameQuery===d&&x.page===n&&x.limit}let A=null,I=!1;if(!g)try{const o=(0,i.fv)({assistantId:t,adAccountId:a,page:n,limit:s,nameQuery:d,startDate:p,endDate:u,selectedOption:h});A=await(0,i.Ig)(o),A&&(e(Pe({ads:A.ads||[],headerColumns:A.headerColumns||[],pagination:A.pagination||null,aggregated:A.aggregated||null,lastFetchParams:A.lastFetchParams||{accountId:a,startDate:p,endDate:u,selectedOption:h,nameQuery:d,page:n,limit:s}})),I=!0)}catch(e){console.error("Error loading cached data from IndexedDB:",e)}const C={assistantId:t,adAccountId:a,page:n,limit:s,adName:d};if(p&&u&&(C.startDate=p.format("YYYY-MM-DD"),C.endDate=u.format("YYYY-MM-DD")),h&&(C.adEffectiveStatus=h),b){He=new AbortController;const l=He.signal;I||e({type:B,payload:{abortController:He}});try{const c=`${o.k}/meta-ads/get-ad-account-insights`,g=c.includes("?")?`${c}&stream=true`:`${c}?stream=true`,b={"Content-Type":"application/json",Accept:"text/event-stream","x-wa-dev-internal-request":"true"};0;const y=await(0,r.W6)(g,{method:"POST",headers:b,body:JSON.stringify(C),signal:l,credentials:"include"});if(!y.ok)throw new Error(`HTTP error! status: ${y.status}`);const x=y.body.getReader(),f=new TextDecoder;let I="",_=!1;for(;;){const{done:o,value:r}=await x.read();if(o)break;I+=f.decode(r,{stream:!0});const{events:l,remainingBuffer:c}=Ve(I);I=c;for(const o of l){if(!o.data)continue;if("heartbeat"===o.data.type)continue;if("complete"===o.data.type){e({type:U}),He=null;const o=m().ads.adAccountInsights;try{const e=(0,i.fv)({assistantId:t,adAccountId:a,page:n,limit:s,nameQuery:d,startDate:p,endDate:u,selectedOption:h});await(0,i.kK)(e,{ads:o.data||[],headerColumns:o.headerColumns||[],pagination:o.pagination||null,aggregated:o.aggregated||null,lastFetchParams:o.lastFetchParams})}catch(e){console.error("Error saving data to IndexedDB:",e)}return}if("error"===o.data.type){const t=o.data.message||"Stream error occurred";throw e(We(t)),He=null,new Error(t)}const r=o.data,l=r.aggregated&&Object.keys(r.aggregated).length>0;_?l&&e(Fe({ads:r.ads||[],headerColumns:r.headerColumns||[],pagination:r.pagination||null,aggregated:r.aggregated||null,lastFetchParams:{accountId:a,startDate:p,endDate:u,selectedOption:h,nameQuery:d,page:n,limit:s}})):(_=!0,e(Ue({ads:r.ads||[],headerColumns:r.headerColumns||[],pagination:r.pagination||null,aggregated:A?.aggregated||null,lastFetchParams:{accountId:a,startDate:p,endDate:u,selectedOption:h,nameQuery:d,page:n,limit:s}})))}}}catch(t){if("AbortError"===t.name)return void console.log("Stream cancelled:",t.message);if(I&&A)return console.warn("Stream request failed, but cached data is available"),A;const a=t.message||"Failed to fetch ad account insights";throw e(We(a)),He=null,t}}else{Ge=(0,l.A)(),I||e({type:k});try{const o=await(0,c.Qd)(C,{cancelToken:Ge.token}),r={ads:o?.ads||[],headerColumns:o?.headerColumns||[],pagination:o?.pagination||null,aggregated:o?.aggregated||null,lastFetchParams:{accountId:a,startDate:p,endDate:u,selectedOption:h,nameQuery:d,page:n,limit:s}};e(Pe(r));try{const e=(0,i.fv)({assistantId:t,adAccountId:a,page:n,limit:s,nameQuery:d,startDate:p,endDate:u,selectedOption:h});await(0,i.kK)(e,r)}catch(e){console.error("Error saving data to IndexedDB:",e)}return Ge=null,o}catch(t){if((0,l.F)(t))return void console.log("Request cancelled:",t.message);if(I&&A)return console.warn("API request failed, but cached data is available"),A;const a=t.response?.data?.message||t.message||"Failed to fetch ad account insights";throw e(Me(a)),t}}}},Ke=e=>{let{adAccountId:t,assistantId:a,startDate:n,endDate:s,adName:o="",columns:i=[],selectedOption:r=null,reportType:l="aggregated"}=e;return async e=>{e({type:F});try{const d={adAccountId:t,assistantId:a,startDate:n?n.format("YYYY-MM-DD"):null,endD
1ate:s?s.format("YYYY-MM-DD"):null,adName:o,columns:i,exportType:l};r&&(d.adEffectiveStatus=r);const p=await(0,c.AV)(d),u=new Blob([p],{type:"text/csv"}),m=window.URL.createObjectURL(u),h=document.createElement("a");return h.href=m,h.setAttribute("download",`Ad Analytics Report${n&&s?` ${n?n.format("MM/DD/YYYY"):""} TO ${s?s.format("MM/DD/YYYY"):""}`:""}.csv`),document.body.appendChild(h),h.click(),h.parentNode.removeChild(h),window.URL.revokeObjectURL(m),e({type:W}),p}catch(t){let a="Failed to export ad account insights";if(t.response?.data instanceof Blob)try{const e=await t.response.data.text();a=JSON.parse(e).message||a}catch(e){a=t.response?.statusText||a}else a=t.response?.data?.message||t.message||a;throw e((e=>({type:z,payload:e}))(a)),t}}},Je=e=>({type:V,payload:e}),$e=e=>({type:Y,payload:e}),qe=e=>({type:X,payload:e}),Xe=e=>({type:se,payload:e}),Qe=function(e,t){let{page:a=0,rowsPerPage:n=10,search:o="",selectedFormId:i="",selectedAdId:r="",startDate:l=null,endDate:d=null,activeTab:c="all"}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return async(p,m)=>{if(console.log(e,t,{activeTab:c,rowsPerPage:n,page:a,search:o,selectedFormId:i,selectedAdId:r,startDate:l,endDate:d}),e&&t){p({type:H});try{const t={assistantId:e,page:a+1,limit:n,type:c};if(o&&(t.search=o),i&&""!==String(i).trim()&&(t.formId=String(i)),r&&""!==String(r).trim()&&(t.adId=String(r)),l){const e=s()(l).startOf("day");t.startDate=e.format("YYYY-MM-DDTHH:mm:ss.SSS")}if(d){const e=s()(d).endOf("day");t.endDate=e.format("YYYY-MM-DDTHH:mm:ss.SSS")}const m=await(0,u.ug)(t);if(m?.status){const e=m.data||[],t=new Map;e.forEach((e=>{e.adId&&!t.has(e.adId)&&t.set(e.adId,{adId:e.adId,adName:e.adName||e.adId})}));const a=Array.from(t.values());p(Je({leads:e,leadsAds:a,total:m.pagination?.total||0}))}else p($e(m?.message||"Failed to fetch leads"))}catch(e){p($e(e.response?.data?.message||"Failed to fetch leads"))}}else p(Je({leads:[],leadsAds:[],total:0}))}},et=(e,t)=>async a=>{if(e&&t){a({type:$});try{const s=await(0,u.s$)({assistantId:e,pageId:t,status:"ACTIVE",limit:50});a(s?.status?(n={forms:s.data||[]},{type:q,payload:n}):qe(s?.message||"Failed to fetch forms"))}catch(e){a(qe(e.response?.data?.message||"Failed to fetch forms"))}var n}},tt=e=>async(t,a)=>{if(e)try{const a=await(0,c.Tu)(e);if(a?.status){const e=a.data||[];t({type:q,payload:{ads:e}})}}catch(e){console.error("Error fetching ads:",e)}},at=function(e,t,a){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;return async i=>{if(e&&t)if(a){i({type:ae});try{const r={assistantId:e,pageId:t,formId:a};n&&(r.startDate=s()(n).format("YYYY-MM-DD")),o&&(r.endDate=s()(o).format("YYYY-MM-DD"));const l=await(0,u._r)(r);i(l?.status?(e=>({type:ne,payload:e}))({success:!0,message:l.message,data:l.data}):Xe(l?.message||"Failed to fetch historical leads"))}catch(e){i(Xe(e.response?.data?.message||e.message||"Failed to fetch historical leads"))}}else i(Xe("Please select a form to fetch leads from"));else i(Xe("Assistant ID and Page ID are required"))}},nt=function(e,t){let{selectedFormId:a="",selectedAdId:n="",selectedAdIdCTWA:o="",startDate:i=null,endDate:r=null,activeTab:l="all"}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return async d=>{if(!e)throw new Error("Assistant ID is required for export");if("form"===l&&!t)throw new Error("Page ID is required for exporting lead form submissions");d({type:oe});try{let t;"all"===l?t="all":"form"===l?t="form-submissions":"ctwa"===l&&(t="ctwa-leads");const c={assistantId:e,exportType:t};let p;a&&""!==String(a).trim()&&(c.formId=String(a)),"all"===l?p=n||o:"form"===l?p=n:"ctwa"===l&&(p=o),p&&""!==String(p).trim()&&(c.adId=String(p)),i&&(c.startDate=s()(i).format("YYYY-MM-DD")),r&&(c.endDate=s()(r).format("YYYY-MM-DD")),c.sortBy="createdTime",c.sortOrder="desc";const m=await(0,u.sz)(c);let h=`lead-submissions-${e}-${s()().format("YYYY-MM-DD")}.csv`;const g=m.headers["content-disposition"];if(g){const e=g.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);e&&e[1]&&(h=e[1].replace(/['"]/g,""))}const b=new Blob([m.data],{type:"text/csv;charset=utf-8;"}),y=window.URL.createObjectURL(b),x=document.createElement("a");x.href=y,x.download=h,document.body.appendChild(x),x.click(),window.URL.revokeObjectURL(y),document.body.removeChild(x),d({type:ie})}catch(e){let t="Failed to export CSV. Please try again.";if(e.response&&e.response.data)try{if(e.response.data instanceof Blob){const a=await e.response.data.text();t=JSON.parse(a).message||t}else e.response.data.message&&(t=e.response.data.message)}catch(e){console.error("Error parsing error response:",e)}throw d((e=>({type:re,payload:e}))(t)),new Error(t)}}},st=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return async n=>{try{const s=(await(0,p.az)({userNumberArray:t,assistantId:e})).optedoutLenght||0;return n({type:me,payload:a?{unSelectedOptNo:s}:{selectedOptNo:s}}),s}catch(e){return console.error("Error fetching opted-out count:",e),n({type:me,payload:a?{unSelectedOptNo:0}:{selectedOptNo:0}}),0}}},ot=(e,t)=>
1async()=>{if(!t||!e)return null;try{const a=await(0,u.Q)(t,e);if(a?.status&&a?.data)return a.data}catch(e){console.error("Error fetching form for lead:",e)}return null},it=e=>({type:le,payload:e}),rt=e=>({type:de,payload:e}),lt=e=>({type:ce,payload:e}),dt=()=>({type:pe}),ct=e=>({type:ue,payload:e});function pt(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:g,{type:t,payload:a}=arguments.length>1?arguments[1]:void 0;switch(t){case b:return{...e,...a};case y:return{...e,details:a.details};case A:return{...e,adName:a.adName};case x:return{...e,budget:a.budget};case f:return{...e,gender:a.gender};case I:return{...e,pageDetails:a};case C:return{...e,adInsights:{...e.adInsights,isLoading:!0,error:null}};case _:return{...e,adInsights:{...e.adInsights,isLoading:!1,iframePreview:a.iframePreview,insights:a.insights,error:null}};case S:return{...e,adInsights:{...e.adInsights,isLoading:!1,error:a}};case v:return{...e,syncAd:{...e.syncAd,isLoading:!0,error:null}};case E:return{...e,syncAd:{...e.syncAd,isLoading:!1,adData:a.adData,adAccount:a.adAccount,error:null}};case T:return{...e,syncAd:{...e.syncAd,isLoading:!1,error:a}};case D:return{...e,updateAdStatus:{...e.updateAdStatus,isLoading:!0,error:null}};case w:return{...e,updateAdStatus:{...e.updateAdStatus,isLoading:!1,error:null}};case N:return{...e,updateAdStatus:{...e.updateAdStatus,isLoading:!1,error:a}};case j:{if(!e.adAccountInsights.data)return e;const t={};return a.forEach((e=>{let{adId:a,newStatus:n}=e;t[a]=n})),{...e,adAccountInsights:{...e.adAccountInsights,data:e.adAccountInsights.data.map((e=>{const a=t[e.adId];return a?{...e,adStatus:a,adEffectiveStatus:"IN_PROCESS"}:e}))}}}case k:return{...e,adAccountInsights:{...e.adAccountInsights,isLoading:!0,isLoadingAds:!0,isLoadingAggregated:!0,data:e.adAccountInsights.data||[],headerColumns:e.adAccountInsights.headerColumns||[],pagination:e.adAccountInsights.pagination||null,aggregated:e.adAccountInsights.aggregated||null,error:null}};case L:return{...e,adAccountInsights:{...e.adAccountInsights,isLoading:!1,isLoadingAds:!1,isLoadingAggregated:!1,data:a.ads,headerColumns:a.headerColumns,pagination:a.pagination,aggregated:a.aggregated,error:null,lastFetchParams:a.lastFetchParams}};case R:return{...e,adAccountInsights:{...e.adAccountInsights,isLoading:!1,isLoadingAds:!1,isLoadingAggregated:!1,error:a}};case B:return{...e,adAccountInsights:{...e.adAccountInsights,isLoading:!0,isLoadingAds:!0,isLoadingAggregated:!0,streamController:a.abortController,data:e.adAccountInsights.data||[],headerColumns:e.adAccountInsights.headerColumns||[],pagination:e.adAccountInsights.pagination||null,aggregated:e.adAccountInsights.aggregated||null,error:null}};case O:return{...e,adAccountInsights:{...e.adAccountInsights,isLoadingAds:!1,data:a.ads,headerColumns:a.headerColumns,pagination:a.pagination,aggregated:null,error:null,lastFetchParams:a.lastFetchParams}};case P:return{...e,adAccountInsights:{...e.adAccountInsights,isLoading:!1,isLoadingAggregated:!1,data:a.ads,headerColumns:a.headerColumns,pagination:a.pagination,aggregated:a.aggregated,error:null,lastFetchParams:a.lastFetchParams}};case M:return{...e,adAccountInsights:{...e.adAccountInsights,isLoading:!1,isLoadingAds:!1,isLoadingAggregated:!1,error:a,streamController:null}};case U:return{...e,adAccountInsights:{...e.adAccountInsights,streamController:null}};case G:return{...e,adAccountInsights:{isLoading:!1,isLoadingAds:!1,isLoadingAggregated:!1,data:null,headerColumns:[],pagination:null,aggregated:null,error:null,lastFetchParams:null,streamController:null}};case F:return{...e,exportAdInsights:{...e.exportAdInsights,isLoading:!0,error:null}};case W:return{...e,exportAdInsights:{...e.exportAdInsights,isLoading:!1,error:null}};case z:return{...e,exportAdInsights:{...e.exportAdInsights,isLoading:!1,error:a}};case H:return{...e,leads:{...e.leads,loading:!0,error:null}};case V:return{...e,leads:{...e.leads,loading:!1,leads:a.leads||[],leadsAds:a.leadsAds||e.leads.leadsAds,total:a.total||0,error:null}};case Y:return{...e,leads:{...e.leads,loading:!1,leads:[],total:0,error:a}};case Z:return{...e,leads:{...e.leads,ctwaLoading:!0,error:null}};case K:return{...e,leads:{...e.leads,ctwaLoading:!1,ctwaLeads:a.ctwaLeads||[],ctwaAds:a.ctwaAds||e.leads.ctwaAds,ctwaTotal:a.ctwaTotal||0,error:null}};case J:return{...e,leads:{...e.leads,ctwaLoading:!1,ctwaLeads:[],ctwaTotal:0,error:a}};case $:return{...e,leads:{...e.leads,error:null}};case q:return{...e,leads:{...e.leads,forms:a.forms||e.leads.forms,ads:a.ads||e.leads.ads||{},error:null}};case X:return{...e,leads:{...e.leads,error:a}};case Q:return{...e,leads:{...e.leads,statsLoading:!0}};case ee:return{...e,leads:{...e.leads,statsLoading:!1,stats:a.stats||{total:0}}};case te:return{...e,leads:{...e.leads,statsLoading:!1,stats:{total:0},ctwaTotal:0}};case ae:return{...e,leads:{...e.leads,fetchingHistorical:!0,fetchHistoricalResult:null}};case ne:return{...e,leads:{...e.leads,fetchingHistorical:!1,fetchHistoricalResult:a}};case se:return{...e,leads:{...e.leads,fetchingHistorical:!1,fetchHistoricalResult:{success:!1,message:a}}};case oe:return{...e,leads:{...e.leads,isExporting:!0}};case ie:return{...e,leads:{...e.leads,isExporting:!1}};case re:return{...e,leads:{...e.leads,isExporting:!1,error:a}};case le:return{...e,leads:{...e.leads,...a,page:0,ctwaPage:0}};case de:case ce:return{...e,leads:{...e.leads,...a}};case pe:return{...e,leads:{...e.leads,selected:[],selectAll:!1,unSelected:[],selectedCount:0}};case ue:return{...e,leads:{...e.leads,activeTab:a,page:0,ctwaPage:0,selectedAdId:"",selectedAdIdCTWA:""}};case me:return{...e,leads:{...e.leads,...a}};default:return e}}const ut=e=>{let{assistantId:t,text:a=""}=e;return async()=>(0,d.jc)({assistantId:t,text:a})}},66289:(e,t,a)=>{"use strict";a.d(t,{Ay:()=>M,lq:()=>P,jW:()=>O,WC:()=>R,nt:()=>B,s$:()=>k,cb:()=>L,W$:()=>j});var n=a(2915),s=a(19458),o=a(72505),i=a.n(o);const r={isLoading:!1,isReloading:!1,data:{},error:null,billingAddressLoading:!1,paymentMethodLoading:!1,adSetupDetails:{},initialRedirectionAttempted:!1,accountValue:null,pageValue:null,isPageSelected:!1,isFbConnected:!1,isWhatsappLinked:!1,isSetupCompleted:void 0},l="AssistantDetails/START_FETCH",d="AssistantDetails/START_REFETCH",c="AssistantDetails/FETCH_SUCCESS",p="AssistantDetails/FETCH_FAILURE",u="AssistantDetails/RESET_ERROR",m="AssistantDetails/RESET_FETCH",h="AssistantDetails/UPDATE_ASSISTANT_STORE",g="AssistantDetails/UPDATE_AD_SETUP_STORE",b="AssistantDetails/UPDATE_AUTO_WCC",y="AssistantDetails/SYNC_BILLING_ADDDRESS_START",x="AssistantDetails/SYNC_BILLING_ADDDRESS_SUCCESS",f="AssistantDetails/SYNC_BILLING_ADDDRESS_FAIL",A="AssistantDetails/SYNC_PAYMENT_METHOD_START",I="AssistantDetails/SYNC_PAYMENT_METHOD_SUCCESS",C="AssistantDetails/SYNC_PAYMENT_METHOD_FAIL",_="AssistantDetails/UPDATE_ICEBREAKERS",S="AssistantDetails/UPDATE_FLOW_POPUP_STATUS",v="AssistantDetails/UPDATE_POPUP_FLOW_ID",E="AssistantDetails/UPDATE_AI_AD_PARAMS",T="AssistantDetails/UPDATE_AD_CREDIT",D="AssistantDetails/SET_INITIAL_REDIRECTION_DATA",w=e=>({type:D,payload:e}),N=e=>({type:g,payload:e}),j=e=>t=>{t({type:_,payload:e})},k=e=>t=>{t({type:v,payload:e})},L=e=>t=>{t({type:S,payload:e})},R=e=>t=>{t({type:T,payload:e})},B=e=>t=>{t((e=>({type:h,payload:e}))(e)),t(N(e))}
1,O=e=>t=>{t(N(e))},P=(e,t,a)=>t=>{t({type:u}),function(e){let{timeout:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return i().post(`${n.k}/api/get-wba-details`,{assistantId:e},t?{timeout:t}:void 0).then((e=>e.data))}(e,{timeout:1e4}).then((e=>{const{assistantId:a,isWhatsappVerified:s,website:o,apiKey:i,appName:r,bvbpProcess:l,kycRemark:d,whatsappNumber:p,providerType:u,subscriptionId:m,billingAddress:h,type:g,activePlan:b,planActivatedOn:y,macUsage:x,currency:f,templateCredit:A,metaAdsCredit:I,planDisplayName:C,planType:_,frequency:S,totalContact:v,cardAdded:E,macQuota:T,subscriptionStatus:D,status:N,appliedForWaba:j,pendingInvoices:k,ongoingBillingProcess:L,subscriptionScheduled:R,promotionalCredits:B,planRenewalOn:O,subscriptionStartedWith:P,cbpType:M,fbManagerVerified:U,displayNameVerified:F,whatsAppDisplayName:W,whatsAppDisplayImage:z,whatsAppAbout:G,whatsAppBusinessProfile:H,timezone:V,dailyTemplateLimit:Y,profileSetupDone:Z,appliedForGreenTick:K,qualityRating:J,testNumber:$,testName:q,sessionPeriod:X,d360ChannelId:Q,allowPurchase:ee,partnerId:te,autoResolve:ae,tagLimit:ne,attributeLimit:se,assistantName:oe,trialNumber:ie,testCountryCode:re,chargebeePlan:le,wabaAppId:de,wabaNumberId:ce,displayNameRejectionReason:pe,campaignReportingAllowed:ue,wabaProgressStep:me,campaignAnalyticsEnabled:he,campaignSchedulingEnabled:ge,clickTrackingEnabled:be,fbUserId:ye,fbGrantedScopes:xe,fbConnected:fe,selectedMetaPageId:Ae,selectedMetaAdAccountId:Ie,freeTierCoversationCount:Ce,wabaActivatedOn:_e,planDuration:Se,optSetting:ve,webEngageWebhookUrl:Ee,webEngageKey:Te,WEB_KEY:De,cleverTapOptField:we,moEngageOptField:Ne,web
1EngageOptField:je,CleverTapkey:ke,deliveryCallbackURL:Le,inboundMessageURL:Re,moEngageWebhookUrl:Be,MO_KEY:Oe,filterFreezeEnabled:Pe,autoWccRecharge:Me,metaAdvanceTargetingEnabled:Ue,partner:Fe,ecomAppStore:We,chatSearchEnabled:ze,disableEcomm:Ge,selectedMetaBusinessId:He,selectedMetaCatalogueId:Ve,selectedMetaBusinessAccessToken:Ye,selectedMetaUserId:Ze,customerId:Ke,planFamily:Je,dfProjectId:$e,placeOfSupply:qe,clientId:Xe,ongoingPlanBillingProcess:Qe,freezedMetaAdAccountId:et,freezedMetaPageId:tt,fbConnectedBy:at,flowConfiguration:nt,referralShortLink:st,subscription:ot,subscriptionScheduledItems:it,planManagement:rt,portalAddress:lt,metaAdsDetails:dt,orderCheckoutDetails:ct,addons:pt,razorpayLink:ut,subsrazorpayLink:mt,subspaymentLinkId:ht,numberBuyStep:gt,additionalSubscriptionItems:bt,csvScheduleEnabled:yt,isCatalogueVisibleOnBusiness:xt,temporarySubs:ft,aggCreditRecharged:At,aggCreditUsage:It,wccRewardExists:Ct,wabaAppStatus:_t,isOrderFlowEnabled:St,optReportingEnabled:vt,specialAccess:Et,partnerReferralId:Tt,aisensyWrap:Dt,skipBalanceCheck:wt,createdAt:Nt,shopifyAnalytics:jt,wabaDeleted:kt,templateTier:Lt,gstInfo:Rt,adSetupDetails:Bt,enableReadStatus:Ot,swipeAccessCode:Pt,flowsProFeatureEnabled:Mt,prospectId:Ut}=e,Ft={website:o,assistantId:a,bvbpProcess:l,kycRemark:d,isWhatsappVerified:s,apiKey:i,appName:r,whatsappNumber:p,providerType:u,subscriptionId:m,billingAddress:h,type:g,activePlan:b,planActivatedOn:y,macUsage:x,currency:f,templateCredit:A,planDisplayName:C,dfProjectId:$e,planType:_,frequency:S,totalContact:v,cardAdded:E,macQuota:"v4"===g?1/0:T,subscriptionStatus:D,status:N,appliedForWaba:j,pendingInvoices:k,ongoingBillingProcess:L,subscriptionScheduled:R,promotionalCredits:B,planRenewalOn:O,subscriptionStartedWith:P,cbpType:M,fbManagerVerified:U,displayNameVerified:F,whatsAppDisplayName:W,whatsAppDisplayImage:z,whatsAppAbout:G,whatsAppBusinessProfile:H,timezone:V,dailyTemplateLimit:Y,profileSetupDone:Z,appliedForGreenTick:K,qualityRating:J,testNumber:$,testName:q,sessionPeriod:X,d360ChannelId:Q,allowPurchase:ee,partnerId:te,autoResolve:ae,tagLimit:ne,attributeLimit:se,assistantName:oe,trialNumber:ie,testCountryCode:re,chargebeePlan:le,wabaAppId:de,wabaNumberId:ce,displayNameRejectionReason:pe,campaignReportingAllowed:ue,wabaProgressStep:me,campaignAnalyticsEnabled:he,campaignSchedulingEnabled:ge,clickTrackingEnabled:be,fbUserId:ye,fbGrantedScopes:xe,fbConnected:fe,selectedMetaPageId:Ae,selectedMetaAdAccountId:Ie,freeTierCoversationCount:Ce,wabaActivatedOn:_e,planDuration:Se,optSetting:ve,webEngageWebhookUrl:Ee,webEngageKey:Te,WEB_KEY:De,cleverTapOptField:we,moEngageOptField:Ne,web
1EngageOptField:je,CleverTapkey:ke,deliveryCallbackURL:Le,inboundMessageURL:Re,MO_KEY:Oe,moEngageWebhookUrl:Be,filterFreezeEnabled:Pe,autoWccRecharge:Me,metaAdvanceTargetingEnabled:Ue,partner:Fe,ecomAppStore:We,chatSearchEnabled:ze,disableEcomm:Ge,selectedMetaBusinessId:He,selectedMetaCatalogueId:Ve,selectedMetaBusinessAccessToken:Ye,selectedMetaUserId:Ze,customerId:Ke,planFamily:Je,placeOfSupply:qe,clientId:Xe,ongoingPlanBillingProcess:Qe,freezedMetaAdAccountId:et,freezedMetaPageId:tt,fbConnectedBy:at,flowConfiguration:nt,referralShortLink:st,subscription:ot,subscriptionScheduledItems:it,planManagement:rt,portalAddress:lt,metaAdsDetails:dt,orderCheckoutDetails:ct,addons:pt,razorpayLink:ut,subsrazorpayLink:mt,subspaymentLinkId:ht,numberBuyStep:gt,additionalSubscriptionItems:bt,csvScheduleEnabled:yt,isCatalogueVisibleOnBusiness:xt,temporarySubs:ft,aggCreditRecharged:At,aggCreditUsage:It,wccRewardExists:Ct,wabaAppStatus:_t,isOrderFlowEnabled:St,optReportingEnabled:vt,specialAccess:Et,partnerReferralId:Tt,aisensyWrap:Dt,skipBalanceCheck:wt,createdAt:Nt,shopifyAnalytics:jt,wabaDeleted:kt,metaAdsCredit:I,templateTier:Lt,gstInfo:Rt,adSetupDetails:Bt,enableReadStatus:Ot,swipeAccessCode:Pt,flowsProFeatureEnabled:Mt,prospectId:Ut};if(Bt?.isAdsSetupCompleted?localStorage.setItem("isAisensyAdSetupCompleted","true"):localStorage.setItem("isAisensyAdSetupCompleted","false"),t(w({isPageSelected:!!Bt?.isPageSelected,isFbConnected:fe,isWhatsappLinked:Bt?.isPageSelected&&fe&&Bt?.isAdsSetupCompleted,isSetupCompleted:!!Bt?.isAdsSetupCompleted})),t({type:c,payload:Ft}),localStorage.getItem("redirectionRoute")){const e=localStorage.getItem("redirectionRoute");localStorage.removeItem("redirectionRoute"),window.location=n.VY+`/projects/${a}`+e}})).catch((e=>{console.error(e);const{isPartner:a}=(0,s.x)();if(a||"JWT RESETTED!"===e.response?.data){localStorage.removeItem("session");const e=window.location.origin;window.location=e+"/login",i().post(`${n.k}/auth/logout-partner`).then((e=>e.data)).then((e=>{console.log(e)})).catch((e=>{console.log(e)}))}t({type:p,payload:{errmsg:"Unable to setup connection"}}),t(w({isPageSelected:!1,isFbConnected:!1,isWhatsappLinked:!1,isSetupCompleted:!1})),localStorage.setItem("isAisensyAdSetupCompleted","false")}))};function M(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:r,{type:t,payload:a}=arguments.length>1?arguments[1]:void 0;switch(t){case l:return{...e,isLoading:!0};case d:return{...e,isReloading:!0};case c:return{...e,isLoading:!1,isReloading:!1,error:null,data:{...a}};case b:case h:return{...e,data:{...e.data,...a}};case g:return{...e,adSetupDetails:{...e.adSetupDetails,...a}};case p:return{...e,isLoading:!1,isReloading:!1,error:a};case u:return{...e,error:null};case m:return{...r};case y:return{...e,billingAddressLoading:!0};case x:return{...e,billingAddressLoading:!1,data:{...e.data,...a}};case f:return{...e,billingAddressLoading:!1};case A:return{...e,paymentMethodLoading:!0};case I:return{...e,paymentMethodLoading:!1,data:{...e.data,...a}};case C:return{...e,paymentMethodLoading:!1};case D:return{...e,...a};case _:return{...e,iceBreakers:{...a}};case S:return{...e,isFlowPopupOpen:a};case v:return{...e,popupFlowId:a};case E:return{...e,aiAdParams:{...e.aiAdParams,...a}};case T:return{...e,data:{...e.data,metaAdsCredit:a}};default:return e}}},20345:(e,t,a)=>{"use strict";a.d(t,{Ay:()=>Se,ET:()=>ge,Eu:()=>de,GF:()=>pe,Nn:()=>se,Os:()=>ie,Tm:()=>me,VU:()=>be,Vn:()=>Ce,WO:()=>le,X3:()=>fe,_L:()=>oe,aR:()=>xe,cT:()=>Ae,dS:()=>he,rg:()=>Ie,s7:()=>re,w5:()=>ue,zJ:()=>ye,zq:()=>ce});var n=a(24113),s=a(56954);const o="FETCH_AUDIENCES_REQUEST",i="FETCH_AUDIENCES_SUCCESS",r="FETCH_AUDIENCES_FAILURE",l="IMPORT_AUDIENCE_USERS_REQUEST",d="IMPORT_AUDIENCE_USERS_SUCCESS",c="IMPORT_AUDIENCE_USERS_FAILURE",p="CREATE_AUDIENCE_REQUEST",u="CREATE_AUDIENCE_SUCCESS",m="CREATE_AUDIENCE_FAILURE",h="CREATE_CUSTOM_AUDIENCE_REQUEST",g="CREATE_CUSTOM_AUDIENCE_SUCCESS",b="CREATE_CUSTOM_AUDIENCE_FAILURE",y="CREATE_LOOKALIKE_AUDIENCE_REQUEST",x="CREATE_LOOKALIKE_AUDIENCE_SUCCESS",f="CREATE_LOOKALIKE_AUDIENCE_FAILURE",A="CREATE_CUSTOM_WITH_LOOKALIKE_REQUEST",I="CREATE_CUSTOM_WITH_LOOKALIKE_SUCCESS",C="CREATE_CUSTOM_WITH_LOOKALIKE_FAILURE",_="UPLOAD_AUDIENCE_CSV_REQUEST",S="UPLOAD_AUDIENCE_CSV_SUCCESS",v="UPLOAD_AUDIENCE_CSV_FAILURE",E="DELETE_AUDIENCE_REQUEST",T="DELETE_AUDIENCE_SUCCESS",D="DELETE_AUDIENCE_FAILURE",w="SYNC_AUDIENCES_REQUEST",N="SYNC_AUDIENCES_SUCCESS",j="SYNC_AUDIENCES_FAILURE",k="FETCH_PIXELS_REQUEST",L="FETCH_PIXELS_SUCCESS",R="FETCH_PIXELS_FAILURE",B="FETCH_PIXEL_DETAILS_REQUEST",O="FETCH_PIXEL_DETAILS_SUCCESS",P="FETCH_PIXEL_DETAILS_FAILURE",M="SET_PIXEL_EVENTS",U="SET_PIXEL_EVENTS_CUSTOM_FIELDS",F="FETCH_PIXEL_STATS_REQUEST",W="FETCH_PIXEL_STATS_SUCCESS",z="FETCH_PIXEL_STATS_FAILURE",G="SYNC_PIXELS_REQUEST",H="SYNC_PIXELS_SUCCESS",V="SYNC_PIXELS_FAILURE",Y="CREATE_PIXEL_REQUEST",Z="CREATE_PIXEL_SUCCESS",K="CREATE_PIXEL_FAILURE",J="SET_SEARCH_STRING",$="SET_CURRENT_TYPE",q="SET_CURRENT_PAGE",X="SET_CURRENT_SOURCE",Q="CLEAR_ERROR",ee="CLEAR_AUDIENCES",te="GET_CONVERSATION_COUNT_REQUEST",ae="GET_CONVERSATION_COUNT_SUCCESS",ne="GET_CONVERSATION_COUNT_FAILURE",se=e=>{let{assistantId:t,allFilters:a}=e;return async e=>{e({type:te});try{const s=await(0,n.Nn)({assistantId:t,allFilters:a});return e({type:ae,payload:s}),s}catch(t){const a=t.response?.data?.message||t.message||"Failed to get conversation count";throw e({type:ne,payload:a}),t}}},oe=e=>async t=>{t({type:o});try{const{assistantId:a,page:s=1,searchTerm:o="",status:r="",type:l="ALL",limit:d=10,source:c="aisensy",adAccountId:p}=e,u={assistantId:a,status:r,limit:d,page:s||1,type:l,source:c,...o&&{search:o},...p&&{adAccountId:p}},m=await(0,n._L)(u);t({type:i,payload:m})}catch(e){const a=e.response?.data?.message||e.message||"Failed to fetch audiences";t({type:r,payload:a})}},ie=e=>async t=>{t({type:h});try{const{assistantId:a,name:s,description:o,subtype:i,rule:r,fileUrl:l,headers:d,dbQuery:c,unSelected:p,skipUpload:u}=e;if(!a)throw new Error("assistantId is required");if(!s)throw new Error("name is required");if(!i)throw new Error("subtype is required");if("WEBSITE"===i&&!(Object.keys(r||{}).length>0))throw new Error("rule is required when subtype is WEBSITE");if("CUSTOMER_LIST"===i&&!u&&!l&&!c)throw new Error("fileUrl or dbQuery is required when subtype is CUSTOMER_LIST");const m={assistantId:a,name:s,...o?{description:o}:{},subtype:i,...r?{rule:r}:{},...l?{fileUrl:l}:{},...d?{headers:d}:{},...c?{allFilters:c,unSelected:p}:{},...u?{skipUpload:!0}:{}},h=await(0,n.Os)(m);return t({type:g,payload:h}),e.assistantId&&e.accountId&&t(ye({assistantId:e.assistantId,adAccountId:e.accountId})).catch((()=>{})),h}catch(e){let a="Failed to create custom audience";if(e.response){const t=e.response.status,n=e.response.data;a=400===t?n?.message||n?.error||"Validation error: Please check your input":409===t?n?.message||n?.error||"An audience with this name already exists":500===t?n?.message||n?.error||"Server error: Please try again later":n?.message||n?.error||e.message||"Failed to create custom audience"}else e.message&&(a=e.message);throw t({type:b,payload:a}),new Error(a)}},re=e=>async t=>{t({type:y});try{const{assistantId:a,name:s,description:o,origin_audience_id:i,lookalike_spec:r}=e,l={assistantId:a,name:s,description:o,type:"LOOKALIKE",origin_audience_id:i,lookalike_spec:r},d=await(0,n.s7)(l);return t({type:x,payload:d}),d}catch(e){const a=e.response?.data?.message||e.message||"Failed to create lookalike audience";throw t({type:f,payload:a}),e}},le=e=>async t=>{t({type:E}
1);try{const{audienceId:a,assistantId:s}=e,o=await(0,n.WO)({audienceId:a,assistantId:s});t({type:T,payload:{audienceId:a,response:o}})}catch(e){const a=e.response?.data?.message||e.message||"Failed to delete audience";t({type:D,payload:a})}},de=e=>{let{assistantId:t,fileName:a,csvText:s}=e;return async e=>{e({type:_});try{const o=await(0,n.DN)({assistantId:t,fileName:a}),{url:i,fields:r}=o.uploadURL,l=new FormData;Object.entries(r).forEach((e=>{let[t,a]=e;return l.append(t,a)})),l.append("file",new Blob([s],{type:"text/csv"}),a||"audience.csv"),await(0,n.r4)(i,l);const d=`https://${r.bucket}.s3.ap-south-1.amazonaws.com/${r.Key}`;return e({type:S,payload:{uploadedCsvUrl:d}}),d}catch(t){const a=t.response?.data?.message||t.message||"CSV upload failed";throw e({type:v,payload:a}),t}}},ce=e=>async t=>{try{const{assistantId:t,audienceId:a,headers:s,fileUrl:o,dbQuery:i,userNumbers:r,unSelected:l}=e;return await(0,n.zq)({assistantId:t,audienceId:a,headers:s,...o?{fileUrl:o}:{},...i?{allFilters:i,unSelected:l}:{},...r?.length?{userNumbers:r}:{}})}catch(e){const t=e.response?.data?.message||e.message||"Failed to upload contacts";throw new Error(t)}},pe=e=>({type:J,payload:e}),ue=e=>({type:$,payload:e}),me=e=>({type:q,payload:e}),he=e=>({type:X,payload:e}),ge=()=>({type:Q}),be=()=>({type:ee}),ye=e=>{let{assistantId:t,adAccountId:a}=e;return async e=>{e({type:w});try{const s=await(0,n.BF)({assistantId:t,adAccountId:a});return e({type:N,payload:s}),s}catch(t){const a=t.response?.data?.message||t.message||"Failed to sync audiences";throw e({type:j,payload:a}),t}}},xe=e=>{let{assistantId:t,page:a=1,limit:n=20,search:o=""}=e;return async e=>{e({type:k});try{const i=await(0,s.aR)({page:a,limit:n,assistantId:t,search:o});return e({type:L,payload:i}),i}catch(t){const a=t.response?.data?.message||t.message||"Failed to fetch pixels";throw e({type:R,payload:a}),t}}},fe=e=>{let{assistantId:t,pixelId:a,event:n}=e;return async e=>{e({type:B}),console.log("API calling");try{const o=await(0,s.X3)(a,t,n);if(e({type:O,payload:o}),o?.aggregatedStats){const t=[];o.aggregatedStats.forEach((e=>{e.data&&Array.isArray(e.data)&&e.data.forEach((e=>{e.value&&(t.find((t=>t.id===e.value))||t.push({id:e.value,label:"invitee_event_type_page"===e.value?"CompleteRegistration":e.value}))}))})),!n&&t.length>0&&e({type:M,payload:{pixelId:a,events:t}})}if(o?.customDataFields){const t={};Object.keys(o.customDataFields).forEach((e=>{const a=o.customDataFields[e];if(Array.isArray(a)&&a.length>0){const n=[];a.forEach((e=>{e.value&&(n.find((t=>t.id===e.value))||n.push({id:e.value,label:e.value}))})),n.length>0&&(t[e]=n)}})),Object.keys(t).length>0&&e({type:U,payload:{pixelId:a,customFields:t}})}return o}catch(t){const a=t.response?.data?.message||t.message||"Failed to fetch pixel details";throw e({type:P,payload:a}),t}}},Ae=e=>{let{assistantId:t,pixelId:a,start_time:n,end_time:o}=e;return async e=>{e({type:F});try{const i=await(0,s.cT)({assistantId:t,pixelId:a,start_time:n,end_time:o});return e({type:W,payload:i}),i}catch(t){const a=t.response?.data?.message||t.message||"Failed to fetch pixel stats";throw e({type:z,payload:a}),t}}},Ie=e=>{let{assistantId:t}=e;return async e=>{e({type:G});try{const a=await(0,s.rg)({assistantId:t});return e({type:H,payload:a}),a}catch(t){const a=t.response?.data?.message||t.message||"Failed to sync pixels";throw e({type:V,payload:a}),t}}},Ce=e=>{let{assistantId:t,pixelName:a,pixelDescription:n}=e;return async e=>{e({type:Y});try{const o=await(0,s.Vn)({assistantId:t,pixelName:a.trim(),pixelDescription:n.trim()||""});return e({type:Z,payload:o}),o}catch(t){const a=t.response?.data?.message||t.message||"Failed to create pixel";throw e({type:K,payload:a}),t}}},_e={audiences:[],loading:!1,error:null,totalPages:1,totalAudiences:0,totalReach:0,activeCampaigns:0,currentPage:0,searchString:"",currentType:"ALL",currentSource:"aisensy",createLoading:!1,createError:null,deleteLoading:!1,deleteError:null,syncLoading:!1,syncError:null,uploadLoading:!1,uploadError:null,importLoading:!1,importError:null,conversationCount:null,conversationCountLoading:!1,conversationCountError:null,pixels:[],pixelsLoading:!1,pixelsError:null,pixelsPagination:{currentPage:1,totalPages:1,totalItems:0,itemsPerPage:20,hasNextPage:!1,hasPreviousPage:!1},pixelDetails:null,pixelDetailsLoading:!1,pixelDetailsError:null,pixelEvents:{},pixelEventsCustomFields:{},pixelStats:[],pixelStatsSummary:null,pixelStatsLoading:!1,pixelStatsError:null,syncPixelsLoading:!1,syncPixelsError:null,createPixelLoading:!1,createPixelError:null,createCustomAudienceLoading:!1,createCustomAudienceError:null},Se=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_e,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case l:return{...e,importLoading:!0,importError:null};case d:return{...e,importLoading:!1};case c:return{...e,importLoading:!1,importError:t.payload};case te:return{...e,conversationCountLoading:!0,conversationCountError:null};case ae:return{...e,conversationCountLoading:!1,conversationCount:t.payload.data};case ne:return{...e,conversationCountLoading:!1,conversationCountError:t.payload};case o:return{...e,loading:!0,error:null};case i:const{data:a,pagination:n,totalPages:s,totalCount:se,totalReach:oe,activeCampaigns:ie}=t.payload,re=n||{},le=re.totalPages||s||1,de=re.totalItems||se||0,ce=re.currentPage||e.currentPage+1,pe=Math.max(0,ce-1);return{...e,loading:!1,audiences:a||[],totalPages:le,totalAudiences:de,totalReach:oe||0,activeCampaigns:ie||0,currentPage:pe};case r:return{...e,loading:!1,error:t.payload,audiences:[]};case p:return{...e,createLoading:!0,createError:null};case u:return{...e,createLoading:!1};case m:return{...e,createLoading:!1,createError:t.payload};case h:return{...e,createCustomAudienceLoading:!0,createCustomAudienceError:null};case g:return{...e,createCustomAudienceLoading:!1,createCustomAudienceError:null};case b:return{...e,createCustomAudienceLoading:!1,createCustomAudienceError:t.payload};case y:return{...e,createLoading:!0,createError:null};case x:return{...e,createLoading:!1};case f:return{...e,createLoading:!1,createError:t.payload};case A:return{...e,createCustomAudienceLoading:!0,createCustomAudienceError:null};case I:return{...e,createCustomAudienceLoading:!1,createCustomAudienceError:null};case C:return{...e,createCustomAudienceLoading:!1,createCustomAudienceError:t.payload};case E:return{...e,deleteLoading:!0,deleteError:null};case T:return{...e,deleteLoading:!1,audiences:e.audiences.filter((e=>e._id!==t.payload.audienceId)),totalAudiences:Math.max(0,e.totalAudiences-1)};case D:return{...e,deleteLoading:!1,deleteError:t.payload};case w:return{...e,syncLoading:!0,syncError:null};case N:return{...e,syncLoading:!1,syncError:null};case j:return{...e,syncLoading:!1,syncError:t.payload};case J:return{...e,searchString:t.payload};case $:return{...e,currentType:t.payload};case q:return{...e,currentPage:t.payload};case X:return{...e,currentSource:t.payload};case Q:return{...e,error:null,createError:null,deleteError:null,uploadError:null};case ee:return{...e,audiences:[],totalPages:1,totalAudiences:0,totalReach:0,activeCampaigns:0,currentPage:0};case k:return{...e,pixelsLoading:!0,pixelsError:null};case L:return{...e,pixelsLoading:!1,pixelsError:null,pixels:t.payload?.data||[],pixelsPagination:t.payload?.pagination||e.pixelsPagination};case R:return{...e,pixelsLoading:!1,pixelsError:t.payload};case B:return{...e,pixelDetailsLoading:!0,pixelDetailsError:null};case O:return{...e,pixelDetailsLoading:!1,pixelDetailsError:null,pixelDetails:t.payload};case P:return{...e,pixelDetailsLoading:!1,pixelDetailsError:t.payload};case M:return{...e,pixelEvents:{...e.pixelEvents,[t.payload.pixelId]:t.payload.events}};case"CLEAR_PIXEL_EVENTS":return{...e,pixelEvents:{}}
1;case U:return{...e,pixelEventsCustomFields:{...e.pixelEventsCustomFields,...t.payload.customFields}};case F:return{...e,pixelStatsLoading:!0,pixelStatsError:null};case W:return{...e,pixelStatsLoading:!1,pixelStatsError:null,pixelStats:t.payload?.data||[],pixelStatsSummary:t.payload?.summary||null};case z:return{...e,pixelStatsLoading:!1,pixelStatsError:t.payload};case G:return{...e,syncPixelsLoading:!0,syncPixelsError:null};case H:return{...e,syncPixelsLoading:!1,syncPixelsError:null};case V:return{...e,syncPixelsLoading:!1,syncPixelsError:t.payload};case Y:return{...e,createPixelLoading:!0,createPixelError:null};case Z:return{...e,createPixelLoading:!1,createPixelError:null};case K:return{...e,createPixelLoading:!1,createPixelError:t.payload};case _:return{...e,uploadLoading:!0,uploadError:null};case S:return{...e,uploadLoading:!1};case v:return{...e,uploadLoading:!1,uploadError:t.payload};default:return e}}},21047:(e,t,a)=>{"use strict";a.d(t,{$9:()=>s,$L:()=>d,Ay:()=>c});var n=a(24113);const s="audiences",o="Audiences/UPLOAD_LOGS_START",i="Audiences/UPLOAD_LOGS_SUCCESS",r="Audiences/UPLOAD_LOGS_FAILURE",l={uploadLogs:null,isLoadingUploadLogs:!1,error:null},d=e=>async t=>{t({type:o});try{const a=await(0,n.ze)(e);return t({type:i,payload:a}),a}catch(e){throw t({type:r,payload:e}),e}};function c(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(t.type){case o:return{...e,isLoadingUploadLogs:!0,error:null};case i:return{...e,isLoadingUploadLogs:!1,uploadLogs:t.payload};case r:return{...e,isLoadingUploadLogs:!1,error:t.payload};default:return e}}},36412:(e,t,a)=>{"use strict";a.d(t,{Ay:()=>y,Oj:()=>b});a(72505),a(2915);const n={isLoading:!1,catalogues:[],productCategories:[],catalogueProducts:[],orders:[],whatsappOrderData:{total:0,orders:[],rowPerPage:10,page:1,nameQuery:"",filter:{}},whatsappPaymentData:{total:0,uniqueCount:0,payments:[],rowPerPage:10,page:1,nameQuery:"",filter:{}},paymentTemplateData:{templates:[]},error:null,accessToken:"",isCollapse:!1},s="Cart/START_FETCH",o="Cart/SWITCH_COLLAPSE",i="Cart/FETCH_USER_ORDER_SUCCESS",r="Cart/ADD_CATALOGUE",l="Cart/FETCH_CATALOGUE_SUCCESS",d="Cart/FETCH_CATALOGUE_PRODUCT_SUCCESS",c="Cart/FETCH_PRODUCT_CATEGORY_SUCCESS",p="Cart/FETCH_WHATSAPP_ORDERS_SUCCESS",u="Cart/FETCH_WHATSAPP_PAYMENTS_SUCCESS",m="Cart/FETCH_WHATSAPP_PAYMENT_TEMPLATE_SUCCESS",h="Cart/UPDATE_STATE",g="Cart/FETCH_FAIL",b=e=>({type:o,payload:e});function y(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:n,{type:t,payload:a}=arguments.length>1?arguments[1]:void 0;switch(t){case o:return{...e,isCollapse:a};case s:return{...e,isLoading:!0};case r:return{...e,catalogues:[...e.catalogues,a]};case i:return{...e,isLoading:!1,error:null,orders:a};case l:return{...e,isLoading:!1,error:null,catalogues:a};case d:return{...e,isLoading:!1,error:null,catalogueProducts:a};case c:return{...e,isLoading:!1,error:null,productCategories:a};case p:return{...e,isLoading:!1,error:null,whatsappOrderData:a};case u:return{...e,isLoading:!1,error:null,whatsappPaymentData:a};case m:return{...e,isLoading:!1,error:null,paymentTemplateData:a};case h:return{...e,...a};case g:return{...e,isLoading:!1,error:a};default:return e}}},83560:(e,t,a)=>{"use strict";a.d(t,{$9:()=>i,Ay:()=>A,F1:()=>f,TD:()=>y,mM:()=>x});var n=a(24113),s=a(5282),o=a(42094);const i="contactsPreview",r="ContactsPreview/MATCH_COUNT_START",l="ContactsPreview/MATCH_COUNT_SUCCESS",d="ContactsPreview/MATCH_COUNT_FAILURE",c="ContactsPreview/CONTACTS_START",p="ContactsPreview/CONTACTS_SUCCESS",u="ContactsPreview/CONTACTS_FAILURE",m="ContactsPreview/TOTAL_COUNT_START",h="ContactsPreview/TOTAL_COUNT_SUCCESS",g="ContactsPreview/TOTAL_COUNT_FAILURE",b={matchCount:null,isLoadingMatchCount:!1,contacts:null,isLoadingContacts:!1,totalContacts:null,isLoadingTotalContacts:!1,error:null},y=(e,t)=>async a=>{if(!e)return null;a({type:r});try{const s=await(0,n.Nn)({assistantId:e,allFilters:t});return a({type:l,payload:s}),s}catch(e){throw a({type:d,payload:e}),e}},x=(e,t,a,n)=>async s=>{if(!e)return null;s({type:c});try{const i=await(0,o.Mo)({assistantId:e,skip:a,rowsPerPage:n,allFilters:t});return s({type:p,payload:i}),i}catch(e){throw s({type:u,payload:e}),e}},f=(e,t)=>async a=>{if(!e)return null;a({type:m});try{const n=await(0,s.tu)({assistantId:e,allFilters:t});return a({type:h,payload:n}),n}catch(e){throw a({type:g,payload:e}),e}};function A(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(t.type){case r:return{...e,isLoadingMatchCount:!0,error:null};case l:return{...e,isLoadingMatchCount:!1,matchCount:t.payload};case d:return{...e,isLoadingMatchCount:!1,error:t.payload};case c:return{...e,isLoadingContacts:!0,error:null};case p:return{...e,isLoadingContacts:!1,contacts:t.payload};case u:return{...e,isLoadingContacts:!1,error:t.payload};case m:return{...e,isLoadingTotalContacts:!0,error:null};case h:return{...e,isLoadingTotalContacts:!1,totalContacts:t.payload};case g:return{...e,isLoadingTotalContacts:!1,error:t.payload};default:return e}}},55248:(e,t,a)=>{"use strict";a.d(t,{$9:()=>s,Ay:()=>A,RI:()=>y,ap:()=>x,bO:()=>m,hI:()=>f,s3:()=>g,wu:()=>h});var n=a(49525);const s="createAd",o="CreateAd/AD_ACCOUNT_SUCCESS",i="CreateAd/PAGE_SUCCESS",r="CreateAd/AD_LOAD_START",l="CreateAd/AD_LOAD_SUCCESS",d="CreateAd/AD_LOAD_FAILURE",c="CreateAd/SUBMIT_START",p="CreateAd/SUBMIT_SETTLED",u={adAccountData:null,pageDetails:null,loadedAd:null,isLoadingAd:!1,isSubmitting:!1,error:null},m=e=>{let{assistantId:t,adAccountId:a}=e;return async e=>{const s=await(0,n.xo)({assistantId:t,adAccountId:a});return e({type:o,payload:s}),s}}
1,h=e=>{let{assistantId:t,pageId:a}=e;return async e=>{const s=await(0,n.ae)({assistantId:t,pageId:a});return e({type:i,payload:s}),s}},g=e=>{let{assistantId:t,adId:a}=e;return async e=>{e({type:r});try{const s=await(0,n.hr)({assistantId:t,adId:a});return e({type:l,payload:s?.adData??null}),s}catch(t){throw e({type:d,payload:t}),t}}},b=e=>t=>async a=>{a({type:c});try{return await e(t)}finally{a({type:p})}},y=b(n.R_),x=b(n.gD),f=b(n.zB);function A(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case o:return{...e,adAccountData:t.payload};case i:return{...e,pageDetails:t.payload};case r:return{...e,isLoadingAd:!0,error:null};case l:return{...e,isLoadingAd:!1,loadedAd:t.payload};case d:return{...e,isLoadingAd:!1,error:t.payload};case c:return{...e,isSubmitting:!0};case p:return{...e,isSubmitting:!1};default:return e}}},58416:(e,t,a)=>{"use strict";a.d(t,{$9:()=>p,PS:()=>Ne,BQ:()=>Me,Ay:()=>Ye,Se:()=>ze,xi:()=>we,hv:()=>De,fW:()=>Fe,s$:()=>_e,QK:()=>Ge,SX:()=>Re,n3:()=>ke,pI:()=>Ce,aM:()=>We,JX:()=>Be,cx:()=>Te,X8:()=>ve,jf:()=>Ee,Sc:()=>Ve,w8:()=>He,JZ:()=>Se,uF:()=>je,NF:()=>Pe,x3:()=>Ue,D:()=>Oe,s9:()=>Le});var n=a(36175),s=a(14272),o=a(39356),i=a(49525),r=a(72505),l=a.n(r),d=a(2915);var c=a(42834);const p="createAdWizard",u="CreateAdWizard/AD_CREATIVE_PROMPT_HISTORY_START",m="CreateAdWizard/AD_CREATIVE_PROMPT_HISTORY_SUCCESS",h="CreateAdWizard/AD_CREATIVE_PROMPT_HISTORY_FAILURE",g="CreateAdWizard/LEAD_FORMS_START",b="CreateAdWizard/LEAD_FORMS_SUCCESS",y="CreateAdWizard/LEAD_FORMS_FAILURE",x="CreateAdWizard/SYNC_LEAD_FORMS_START",f="CreateAdWizard/SYNC_LEAD_FORMS_SUCCESS",A="CreateAdWizard/SYNC_LEAD_FORMS_FAILURE",I="CreateAdWizard/SEARCH_LOCATIONS_START",C="CreateAdWizard/SEARCH_LOCATIONS_SUCCESS",_="CreateAdWizard/SEARCH_LOCATIONS_FAILURE",S="CreateAdWizard/SEARCH_TARGETS_START",v="CreateAdWizard/SEARCH_TARGETS_SUCCESS",E="CreateAdWizard/SEARCH_TARGETS_FAILURE",T="CreateAdWizard/SEARCH_AUDIENCES_START",D="CreateAdWizard/SEARCH_AUDIENCES_SUCCESS",w="CreateAdWizard/SEARCH_AUDIENCES_FAILURE",N="CreateAdWizard/LATEST_AUDIENCES_START",j="CreateAdWizard/LATEST_AUDIENCES_SUCCESS",k="CreateAdWizard/LATEST_AUDIENCES_FAILURE",L="CreateAdWizard/AUDIENCE_BY_ID_START",R="CreateAdWizard/AUDIENCE_BY_ID_SUCCESS",B="CreateAdWizard/AUDIENCE_BY_ID_FAILURE",O="CreateAdWizard/SAVE_AUDIENCE_START",P="CreateAdWizard/SAVE_AUDIENCE_SUCCESS",M="CreateAdWizard/SAVE_AUDIENCE_FAILURE",U="CreateAdWizard/DELIVERY_ESTIMATE_START",F="CreateAdWizard/DELIVERY_ESTIMATE_SUCCESS",W="CreateAdWizard/DELIVERY_ESTIMATE_FAILURE",z="CreateAdWizard/VALIDATE_ADVANCED_TARGETING_START",G="CreateAdWizard/VALIDATE_ADVANCED_TARGETING_SUCCESS",H="CreateAdWizard/VALIDATE_ADVANCED_TARGETING_FAILURE",V="CreateAdWizard/WEB_META_DATA_START",Y="CreateAdWizard/WEB_META_DATA_SUCCESS",Z="CreateAdWizard/WEB_META_DATA_FAILURE",K="CreateAdWizard/SAVE_ICE_BREAKERS_START",J="CreateAdWizard/SAVE_ICE_BREAKERS_SUCCESS",$="CreateAdWizard/SAVE_ICE_BREAKERS_FAILURE",q="CreateAdWizard/UPDATE_ICE_BREAKERS_START",X="CreateAdWizard/UPDATE_ICE_BREAKERS_SUCCESS",Q="CreateAdWizard/UPDATE_ICE_BREAKERS_FAILURE",ee="CreateAdWizard/UPDATE_FLOW_OBJECT_START",te="CreateAdWizard/UPDATE_FLOW_OBJECT_SUCCESS",ae="CreateAdWizard/UPDATE_FLOW_OBJECT_FAILURE",ne="CreateAdWizard/CREATE_LEAD_FORM_START",se="CreateAdWizard/CREATE_LEAD_FORM_SUCCESS",oe="CreateAdWizard/CREATE_LEAD_FORM_FAILURE",ie="CreateAdWizard/UPDATE_LEAD_FORM_AUTOMATION_START",re="CreateAdWizard/UPDATE_LEAD_FORM_AUTOMATION_SUCCESS",le="CreateAdWizard/UPDATE_LEAD_FORM_AUTOMATION_FAILURE",de="CreateAdWizard/LEAD_FORM_PARAMETERS_START",ce="CreateAdWizard/LEAD_FORM_PARAMETERS_SUCCESS",pe="CreateAdWizard/LEAD_FORM_PARAMETERS_FAILURE",ue="CreateAdWizard/SAVE_LEAD_FORM_PARAMETERS_START",me="CreateAdWizard/SAVE_LEAD_FORM_PARAMETERS_SUCCESS",he="CreateAdWizard/SAVE_LEAD_FORM_PARAMETERS_FAILURE",ge="CreateAdWizard/FETCH_API_CAMPAIGNS_START",be="CreateAdWizard/FETCH_API_CAMPAIGNS_SUCCESS",ye="CreateAdWizard/FETCH_API_CAMPAIGNS_FAILURE",xe="CreateAdWizard/FETCH_TEMPLATES_START",fe="CreateAdWizard/FETCH_TEMPLATES_SUCCESS",Ae="CreateAdWizard/FETCH_TEMPLATES_FAILURE",Ie={adCreativePromptHistory:null,isLoadingAdCreativePromptHistory:!1,leadForms:[],isLoadingLeadForms:!1,isSyncingLeadForms:!1,locationResults:[],isSearchingLocations:!1,targetResults:[],isSearchingTargets:!1,audienceResults:[],isSearchingAudiences:!1,latestAudiences:[],isLoadingLatestAudiences:!1,audienceById:null,isLoadingAudienceById:!1,isSavingAudience:!1,deliveryEstimate:null,isLoadingDeliveryEstimate:!1,isValidatingAdvancedTargeting:!1,webMetaData:null,isLoadingWebMetaData:!1,isSavingIceBreaker:!1,isUpdatingIceBreaker:!1,isUpdatingFlowObject:!1,isCreatingLeadForm:!1,isUpdatingLeadFormAutomation:!1,leadFormParameters:null,isLoadingLeadFormParameters:!1,isSavingLeadFormParameters:!1,apiCampaigns:[],isLoadingApiCampaigns:!1,campaignTemplates:[],isLoadingCampaignTemplates:!1,error:null},Ce=e=>async t=>{t({type:u});try{const a=await(e=>l().post(`${d.k}/ai-ad-creative/fetch-ad-creative-prompts`,e).then((e=>e.data)))(e);return t({type:m,payload:a}),a}catch(e){throw t({type:h,payload:e}),e}},_e=e=>{let{assistantId:t,pageId:a,status:s="ACTIVE",limit:o=50}=e;return async e=>{e({type:g});try{const i=await(0,n.s$)({assistantId:t,pageId:a,status:s,limit:o});return e({type:b,payload:i}),i}catch(t){throw e({type:y,payload:t}),t}}},Se=e=>{let{assistantId:t,pageId:a}=e;return async e=>{e({type:x});try{const s=await(0,n.JZ)({assistantId:t,pageId:a});return e({type:f,payload:s}),s}catch(t){throw e({type:A,payload:t}),t}}},ve=e=>{let{assistantId:t,adAccountId:a,text:n,signal:s}=e;return async e=>{e({type:I});try{const i=await(0,o.X8)({assistantId:t,adAccountId:a,text:n,signal:s});return e({type:C,payload:i}),i}catch(t){throw e({type:_,payload:t}),t}}},Ee=e=>{let{assistantId:t,adAccountId:a,text:n,countries:s,signal:i}=e;return async e=>{e({type:S});try{const r=await(0,o.jf)({assistantId:t,adAccountId:a,text:n,countries:s,signal:i});return e({type:v,payload:r}),r}catch(t){throw e({type:E,payload:t}),t}}},Te=e=>{let{assistantId:t,text:a}=e;return async e=>{e({type:T});try{const n=await(0,o.cx)({assistantId:t,text:a});return e({type:D,payload:n}),n}catch(t){throw e({type:w,payload:t}),t}}},De=e=>async t=>{t({type:N});try{const a=await(0,o.hv)(e);return t({type:j,payload:a}),a}catch(e){throw t({type:k,payload:e}),e}},we=e=>{let{audienceId:t,assistantId:a}=e;return async e=>{e({type:L});try{const n=await(0,o.xi)({audienceId:t,assistantId:a});return e({type:R,payload:n}),n}catch(t){throw e({type:B,payload:t}),t}}},Ne=e=>async t=>{t({type:O});try{const a=await(0,o.PS)(e);return t({type:P,payload:a}),a}catch(e){throw t({type:M,payload:e}),e}},je=e=>async t=>{t({type:O});try{const a=await(0,o.uF)(e);return t({type:P,payload:a}),a}catch(e){throw t({type:M,payload:e}),e}},ke=e=>async t=>{t({type:U});try{const a=await(0,o.n3)(e);return t({type:F,payload:a}),a}catch(e){throw t({type:W,payload:e}),e}},Le=e=>async t=>{t({type:z});try{const a=await(0,o.s9)(e);return t({type:G,payload:a}),a}catch(e){throw t({type:H,payload:e}),e}},Re=e=>{let{link:t,assistantId:a}=e;return async e=>{e({type:V});try{const n=await(0,i.SX)({link:t,assistantId:a});return e({type:Y,payload:n}),n}catch(t){throw e({type:Z,payload:t}),t}}},Be=e=>async t=>{t({type:K});try{const a=await(async e=>{const{data:t}=await l().post(`${d.k}/meta-ads/save-icebreakers`,e);return t})(e);return t({type:J,payload:a}),a}catch(e){throw t({type:$,payload:e}),e}},Oe=e=>async t=>{t({type:q});try{const a=await(async e=>{const{data:t}=await l().post(`${d.k}/meta-ads/update-icebreakers`,e);return t})(e);return t({type:X,payload:a}),a}catch(e){throw t({type:Q,payload:e}),e}},Pe=e=>{let{assistantId:t,flowId:a,flowObject:n}=e;return async e=>{e({type:ee});try{const s=await(0,c.A)({assistantId:t,flowId:a,flowObject:n});return e({type:te,payload:s}),s}catch(t){throw e({type:ae,payload:t}),t}}},Me=e=>async t=>{t({type:ne});try{const a=await(0,n.BQ)(e);return t({type:se,payload:a}),a}catch(e){throw t({type:oe,payload:e}),e}},Ue=e=>{let{assistantId:t,formId:a,automation:s}=e;return async e=>{e({type:ie});try{const o=await(0,n.x3)({assistantId:t,formId:a,automation:s});return e({type:re,payload:o}),o}catch(t){throw e({type:le,payload:t}),t}}},Fe=e=>async t=>{t({type:de});try{const a=await(0,n.fW)(e);return t({type:ce,payload:a}),a}catch(e){throw t({type:pe,payload:e}),e}},We=e=>{let{assistantId:t,parameters:a}=e;return async e=>{e({type:ue});try{const s=await(0,n.aM)({assistantId:t,parameters:a});return e({type:me,payload:s}),s}catch(t){throw e({type:he,payload:t}),t}}},ze=e=>async t=>{t({type:ge});try{const a=await(0,s.Se)(e);return t({type:be,payload:a}),a}catch(e){throw t({type:ye,payload:e}),e}},Ge=e=>async t=>{t({type:xe});try{const a=await(0,s.QK)(e);return t({type:fe,payload:a}),a}catch(e){throw t({type:Ae,payload:e}),e}},He=e=>e[p].leadForms,Ve=e=>e[p].isLoadingLeadForms;function Ye(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ie,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(t.type){case u:return{...e,isLoadingAdCreativePromptHistory:!0,error:null};case m:return{...e,isLoadingAdCreativePromptHistory:!1,adCreativePromptHistory:t.payload};case h:return{...e,isLoadingAdCreativePromptHistory:!1,error:t.payload};case g:return{...e,isLoadingLeadForms:!0,error:null};case b:return{...e,isLoadingLeadForms:!1,leadForms:t.payload};case y:return{...e,isLoadingLeadForms:!1,error:t.payload};case x:return{...e,isSyncingLeadForms:!0,error:null};case f:return{...e,isSyncingLeadForms:!1};case A:return{...e,isSyncingLeadForms:!1,error:t.payload};case I:return{...e,isSearchingLocations:!0,error:null};case C:return{...e,isSearchingLocations:!1,locationResults:t.payload};case _:return{...e,isSearchingLocations:!1,error:t.payload};case S:return{...e,isSearchingTargets:!0,error:null};case v:return{...e,isSearchingTargets:!1,targetResults:t.payload};case E:return{...e,isSearchingTargets:!1,error:t.payload};case T:return{...e,isSearchingAudiences:!0,error:null};case D:return{...e,isSearchingAudiences:!1,audienceResults:t.payload};case w:return{...e,isSearchingAudiences:!1,error:t.payload};case N:return{...e,isLoadingLatestAudiences:!0,error:null};case j:return{...e,isLoadingLatestAudiences:!1,latestAudiences:t.payload};case k:return{...e,isLoadingLatestAudiences:!1,error:t.payload};case L:return{...e,isLoadingAudienceById:!0,error:null};case R:return{...e,isLoadingAudienceById:!1,audienceById:t.payload};case B:return{...e,isLoadingAudienceById:!1,error:t.payload};case O:return{...e,isSavingAudience:!0,error:null};case P:return{...e,isSavingAudience:!1};case M:return{...e,isSavingAudience:!1,error:t.payload};case U:return{...e,isLoadingDeliveryEstimate:!0,error:null};case F:return{...e,isLoadingDeliveryEstimate:!1,deliveryEstimate:t.payload};case W:return{...e,isLoadingDeliveryEstimate:!1,error:t.payload};case z:return{...e,isValidatingAdvancedTargeting:!0,error:null};case G:return{...e,isValidatingAdvancedTargeting:!1};case H:return{...e,isValidatingAdvancedTargeting:!1,error:t.payload};case V:return{...e,isLoadingWebMetaData:!0,error:null};case Y:return{...e,isLoadingWebMetaData:!1,webMetaData:t.payload};case Z:return{...e,isLoadingWebMetaData:!1,error:t.payload};case K:return{...e,isSavingIceBreaker:!0,error:null};case J:return{...e,isSavingIceBreaker:!1};case $:return{...e,isSavingIceBreaker:!1,error:t.payload};case q:return{...e,isUpdatingIceBreaker:!0,error:null};case X:return{...e,isUpdatingIceBreaker:!1};case Q:return{...e,isUpdatingIceBreaker:!1,error:t.payload};case ee:return{...e,isUpdatingFlowObject:!0,error:null};case te:return{...e,isUpdatingFlowObject:!1};case ae:return{...e,isUpdatingFlowObject:!1,error:t.payload};case ne:return{...e,isCreatingLeadForm:!0,error:null};case se:return{...e,isCreatingLeadForm:!1};case oe:return{...e,isCreatingLeadForm:!1,error:t.payload};case ie:return{...e,isUpdatingLeadFormAutomation:!0,error:null};case re:return{...e,isUpdatingLeadFormAutomation:!1};case le:return{...e,isUpdatingLeadFormAutomation:!1,error:t.payload};case de:return{...e,isLoadingLeadFormParameters:!0,error:null};case ce:return{...e,isLoadingLeadFormParameters:!1,leadFormParameters:t.payload};case pe:return{...e,isLoadingLeadFormParameters:!1,error:t.payload};case ue:return{...e,isSavingLeadFormParameters:!0,error:null};case me:return{...e,isSavingLeadFormParameters:!1};case he:return{...e,isSavingLeadFormParameters:!1,error:t.payload};case ge:return{...e,isLoadingApiCampaigns:!0,error:null};case be:return{...e,isLoadingApiCampaigns:!1,apiCampaigns:t.payload};case ye:return{...e,isLoadingApiCampaigns:!1,error:t.payload};case xe:return{...e,isLoadingCampaignTemplates:!0,error:null};case fe:return{...e,isLoadingCampaignTemplates:!1,campaignTemplates:t.payload};case Ae:return{...e,isLoadingCampaignTemplates:!1,error:t.payload};default:return e}}},90935:(e,t,a)=>{"use strict";a.d(t,{$9:()=>s,Ay:()=>h,Vn:()=>m,X3:()=>u});var n=a(56954);const s="events",o="Events/FETCH_PIXEL_DETAILS_START",i="Events/FETCH_PIXEL_DETAILS_SUCCESS",r="Events/FETCH_PIXEL_DETAILS_FAILURE",l="Events/CREATE_PIXEL_START",d="Events/CREATE_PIXEL_SUCCESS",c="Events/CREATE_PIXEL_FAILURE",p={pixelDetails:null,isFetchingPixelDetails:!1,isCreatingPixel:!1,error:null},u=(e,t)=>
1async a=>{a({type:o});try{const s=await(0,n.X3)(e,t);return a({type:i,payload:s}),s}catch(e){throw a({type:r,payload:e}),e}},m=e=>async t=>{t({type:l});try{const a=await(0,n.Vn)(e);return t({type:d,payload:a}),a}catch(e){throw t({type:c,payload:e}),e}};function h(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(t.type){case o:return{...e,isFetchingPixelDetails:!0,error:null};case i:return{...e,isFetchingPixelDetails:!1,pixelDetails:t.payload};case r:return{...e,isFetchingPixelDetails:!1,error:t.payload};case l:return{...e,isCreatingPixel:!0,error:null};case d:return{...e,isCreatingPixel:!1};case c:return{...e,isCreatingPixel:!1,error:t.payload};default:return e}}},11859:(e,t,a)=>{"use strict";a.d(t,{Ay:()=>U,Jl:()=>R,Qj:()=>w,RM:()=>N,UQ:()=>B,Ux:()=>j,jW:()=>E});var n=a(11066),s=a(2915),o=(a(2543),a(23800)),i=a(42834),r=a(3633);const l={selectedFlow:null,flows:[],nodes:[],edges:[],isAllowToConnect:!1,draggedFromEdgeId:null,draggedFromComponentId:null,previewFlowObject:null,isSaveChanges:!1};function d(e){switch(e){case"catalogueMessage":return{body:"",footer:""};case"singleProductMessage":return{product:null,body:"",footer:""};case"multiProductMessage":return{header:"",body:"",footer:"",catalogueId:"",productsCount:0,sectionsCount:0,sections:[],buttonTitle:"View Items"};case"imageWithCaption":return{url:"",text:"",fileType:"",fileName:"",buttons:[],source:"Media Library"};case"easyinsights":return{eventType:"",conversionName:"",revenue:"",currency:"",discount:"",offerCode:""};case"message":return{text:"",buttons:[]};case"questionMessage":return{text:"",attribute:"",attributeNumberOfAttempt:"1",attributeFormatValue:{min:"",max:"",regex:""},attributeFormatValidationErrorMessage:"",attributeFormat:"Any",mediaType:""};case"questionMediaMessage":return{text:"",attribute:"",attributeNumberOfAttempt:"1",attributeFormatValue:{min:"",max:"",regex:""},attributeFormatValidationErrorMessage:"",attributeFormat:"Media",mediaType:"Any"};case"setAVariable":return{value:"",attribute:""};case"condition":return{condition:"",attributeOne:"",attributeTwo:"",rangeObject:"",conditionKey:""};case"questionAddressMessage":return{text:"",attribute:""};case"questionLocationMessage":return{text:"",longituteAttribute:"",latitudeAttribute:""};case"addTag":return{tags:[{}]};case"listMessage":return{header:"",body:"",footer:"",itemsCount:0,sectionsCount:0,sections:[],buttonTitle:"list"};case"iceBreaker":return{iceBreakersCount:1,iceBreakers:[{iceBreakerText:"",id:`icebreaker_message-right-${Date.now()}-${Date.now()}`}]};case"whatsappForms":return{header:"",body:"",footer:"",flowId:"",screenName:"",attributeName:"",flowStatus:"",flowAction:"",buttonTitle:"",flowToken:""};case"ConversionApi":return{value:"",conversionType:"Lead",currencyCode:"INR"};case"templateMessage":return{template:null};case"humanIntervention":return{isRequesting:!0};case"setupWebhook":return{requestObject:{},attribute:"",responseKey:"",statusCodes:[],capturingAttributes:[{attribute:"",responseKey:""}]};case"whatsappPay":return{amount:0,title:"",currency:"INR",margin:0,paymentMode:"",productName:"",productQuantity:0,isCustomProduct:!0,notes:[]};case"connectFlows":return{flowId:"",flowName:""};default:return null}}const c="Flow/ADD_EDGE",p="Flow/ALLOW_TARGET",u="Flow/DRAGGED_FROM",m="Flow/ADD_NODE",h="Flow/DELETE_NODE",g="Flow/CREATE_NODE_CONNECTION",b="Flow/UPDATE_NODE",y="Flow/FETCH_FLOW",x="Flow/UPDATE_FLOW",f="Flow/UPDATE_FLOW_NODE_AND_EDGES",A="Flow/CLEAR_FLOW_STATE",I="Flow/PREVIEW_FLOW_OBJECT",C="Flow/IS_SAVE_CHANGES",_="Flow/INSERT_EDGE",S=(e,t,a)=>({type:f,payload:{flowId:e,nodes:t,edges:a}}),v=(e,t)=>({type:u,payload:{draggedFromEdgeId:e,draggedFromComponentId:t}}),E=()=>({type:A,payload:{}}),T=e=>({type:m,payload:e}),D=e=>({type:b,payload:e}),w=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return(a,n)=>{const l=t?t.token:void 0,d=s.XI,c=!!d?.includes(e);(0,i.Y)(e,{useLibrary:c,cancelToken:l}).then((e=>{var t;a((t=(0,o.replaceDomainInData)(e.fetchedFlow),{type:y,payload:t}))})).catch((e=>{(0,r.F)(e)?console.log("Request canceled:",e.message):console.error(e)}))}},N=(e,t,a,s)=>(o,i)=>{const{nodes:r,edges:l,draggedFromEdgeId:c,draggedFromComponentId:p}=i().flow;"select"===e&&P("-1");const u="select"===e?"-1":`${Date.now()}`,m="select"===e?{id:u,type:`${e}`,data:d(`${e}`),position:{x:t??r[r.length-1].position.x+300,y:a??r[r.length-1].position.y}}:{id:u,type:"masterComponent",data:{isDrag:!0,id:u,content:[{id:`${Date.now()}-${e}`,type:`${e}`,data:d(`${e}`)}]},position:{x:t??r[r.length-1].position.x+300,y:a??r[r.length-1].position.y}};o(T(m)),"select"!==e&&p&&c&&s&&(o(O([...l,{source:`${p}`,sourceHandle:`${c}`,target:`${u}`,targetHandle:`master-component-left-${u}`,type:"buttonedge",markerEnd:{type:n.TG.ArrowClosed,width:20,height:20,color:"#008069"},animated:!0,style:{strokeWidth:1,stroke:"#008069"}}])),o(v(null,null)))},j=(e,t,a,s)=>(o,i)=>{if(!e||0===e.length)return;const r="iceBreaker",l=window.location.pathname.includes("chat-settings");if(o(M(!0)),l)return void o(L(e,t,a,s));if(s)return void o(k(e,t,a,s));const c=window.location.pathname.includes("duplicate"),{flows:p}=i().flow,u=t.split("-")[1],m=p.find((e=>e._id===u))?.flow?.nodes[0],h=p.find((e=>e._id===u))?.flow?.nodes,g=p.find((e=>e._id===u))?.flow?.edges;let b=h?.find((e=>e.id===t));b?b.data.highlight=!0:b={id:t,type:"masterComponent",data:{highlight:!0,isDrag:!0,id:t,content:[{id:`${Date.now()}-${r}`,type:`${r}`,data:d(`${r}`)}]},position:{x:m.position.x+300,y:m.position.y}};let y=[...h,b];const x=[];for(let a of e||[]){const e=b.data.content[0].data.iceBreakers.find((e=>e.id.includes(a.id)));e?x.push({...e,iceBreakerText:a.iceBreakerText}):x.push({iceBreakerText:a.iceBreakerText,id:`icebreaker_message-right-${t.split("-")[0]}-${a.iceBreakerId}`})}if(b.data.content[0].data.iceBreakers=x,b.data.content[0].data.iceBreakersCount=e?.length||0,y.push(b),y=y.filter(((e,t,a)=>t===a.findIndex((t=>t.id===e.id)))),o(T(b)),o(S(u,y,null)),c||a&&a!==t){let s=[];for(let e of g)if(e.source===`${a}-${u}`){const a=t,n=e.sourceHandle.split("-").reverse()[0],o={...e,source:a,sourceHandle:`icebreaker_message-right-${a.split("-")[0]}-${n}`};s.push(o)}for(let a of e){if(!a.blockId||!a.blockHandle)continue;const e={source:t,sourceHandle:`icebreaker_message-right-${t.split("-")[0]}-${a.iceBreakerId}`,target:a.blockId,targetHandle:a.blockHandle,type:"buttonedge",markerEnd:{type:n.TG.ArrowClosed,width:20,height:20,color:"#008069"},animated:!0,style:{strokeWidth:1,stroke:"#008069"}};s.push(e)}s=[...g,...s];const i=s.filter(((e,t,a)=>t===a.findIndex((t=>t.sourceHandle===e.sourceHandle))));o(O(i)),o(S(u,null,i))}},k=(e,t,a,s)=>(o,i)=>{if(!s)return;const{flows:r}=i().flow;s={...s,iceBreakerNodeId:t};const l=t.split("-")[1],d=r.find((e=>e._id===l))?.flow?.nodes,c=r.find((e=>e._id===l))?.flow?.edges,p=d.find((e=>"keyword"===e.id));p.data.ads||(p.data.ads=[]);const u=p.data.ads.filter((e=>!e?.iceBreakers?.iceBreakerNodeId)),m=p.data.ads.filter((e=>e?.iceBreakers?.iceBreakerNodeId)),h=[...[s,...m].filter(((e,t,a)=>t===a.findIndex((t=>t?.iceBreakers?.iceBreakerNodeId===e?.iceBreakers?.iceBreakerNodeId)))),...u];p.data.ads=h;let g=[p,...d];g=g.filter(((e,t,a)=>t===a.findIndex((t=>t.id===e.id)))),o(D(g));let b=[];for(let e of c)if(e.source===`${a}-${l}`){const a=t,n=e.sourceHandle.split("-").reverse()[0],s={...e,source:"keyword",sourceHandle:`icebreaker_message-right-${a.split("-")[0]}-${n}`};b.push(s)}for(let a of e){if(!a.blockId||!a.blockHandle)continue;const e={source:"keyword",sourceHandle:`icebreaker_message-right-${t.split("-")[0]}-${a.iceBreakerId}`,target:a.blockId,targetHandle:a.blockHandle,type:"buttonedge",markerEnd:{type:n.TG.ArrowClosed,width:20,height:20,color:"#008069"},animated:!0,style:{strokeWidth:1,stroke:"#008069"}};b.push(e)}b=[...c,...b];const y=b.filter(((e,t,a)=>t===a.findIndex((t=>t.sourceHandle===e.sourceHandle))));o(O(y)),o(S(l,g,y))},L=(e,t,a)=>(s,o)=>{const{flows:i}=o().flow,r=t.split("-")[1],l=i.find((e=>e._id===r))?.flow?.nodes,d=i.find((e=>e._id===r))?.flow?.edges,c=l.find((e=>"keyword"===e.id)),p=[];c.data.iceBreakers||(c.data.iceBreakers=[]);for(let a of e||[]){const e=c.data.iceBreakers.find((e=>e.id.includes(a.id)));e?p.push({...e,iceBreakerText:a.iceBreakerText}):p.push({iceBreakerText:a.iceBreakerText,id:`icebreaker_message-right-${t.split("-")[0]}-${a.iceBreakerId}`})}c.data.iceBreakers=p;let u=[c,...l];u=u.filter(((e,t,a)=>t===a.findIndex((t=>t.id===e.id)))),s(D(u));let m=[];for(let e of d)if(e.source===`${a}-${r}`){const a=t,n=e.sourceHandle.split("-").reverse()[0],s={...e,source:"keyword",sourceHandle:`icebreaker_message-right-${a.split("-")[0]}-${n}`};m.push(s)}for(let a of e){if(!a.blockId||!a.blockHandle)continue;const e={source:"keyword",sourceHandle:`icebreaker_message-right-${t.split("-")[0]}-${a.iceBreakerId}`,target:a.blockId,targetHandle:a.blockHandle,type:"buttonedge",markerEnd:{type:n.TG.ArrowClosed,width:20,height:20,color:"#008069"},animated:!0,style:{strokeWidth:1,stroke:"#008069"}};m.push(e)}m=[...d,...m];const h=m.filter(((e,t,a)=>t===a.findIndex((t=>t.sourceHandle===e.sourceHandle))));s(O(h)),s(S(r,u,h))},R=(e,t,a,n)=>(s,o)=>{const{flows:i}=o().flow||{};if(i)for(let o of i){const i=o._id;s(j(e.filter((e=>e?.flowId===i)),`${t}-${i}`,a,n))}},B=(e,t,a)=>(n,s)=>{if(!a)return;const{flows:o}=s().flow,i=o.find((e=>e._id===a))?.flow,{nodes:r,edges:l}=i,d=`${t}-${a}`,c=r.map((a=>(a.id===d&&(a.data.content[0].data.iceBreakers=a.data?.content[0]?.data?.iceBreakers.filter((a=>{let{id:n}=a;return n!==`icebreaker_message-right-${t}-${e}`})),a.data.content[0].data.iceBreakersCount=a.data?.content[0]?.data?.iceBreakers?.length||0),a))).filter((e=>e.id!==d||0!==e.data.content[0].data.iceBreakers.length)),p=`icebreaker_message-right-${t}-${e}`,u=l.filter((e=>e.sourceHandle!==p));n(S(a,c,u)),n(O(u))},O=e=>t=>{t((e=>({type:c,payload:e}))(e))},P=e=>t=>{"-1"===e&&v(null,null),t((e=>({type:h,payload:{id:e}}))(e))},M=e=>t=>{t((e=>({type:C,payload:{isSaveChanges:e}}))(e))};function U(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l,{type:t,payload:a}=arguments.length>1?arguments[1]:void 0;switch(t){case y:return{...e,flows:a};case x:return{...e,flows:e.flows.map((e=>e._id===a.flowId?{...e,status:!e.status}:e))};case f:return{...e,flows:e.flows.map((e=>e._id===a.flowId?{...e,flow:{...e.flow,nodes:a.nodes||e.flow.nodes,edges:a.edges||e.flow.edges}}:e))};case m:return{...e,nodes:[...e.nodes,a]};case _:return{...e,edges:[...e.edges,a]};case c:return{...e,edges:a.length>0?a:[]};case b:return{...e,nodes:a?.length>0?a:[]};case h:return{...e,nodes:e.nodes.filter((e=>e.id!==a.id)),edges:e.edges.filter((e=>e.source!==a.id&&e.target!==a.id))};case g:return{...e,nodes:[...e.nodes,a]};case p:return{...e,isAllowToConnect:a};case u:return{...e,draggedFromEdgeId:a.draggedFromEdgeId,draggedFromComponentId:a.draggedFromComponentId};case A:return{...e,nodes:[],edges:[]};case I:return{...e,previewFlowObject:a.flowObject};case C:return{...e,isSaveChanges:a.isSaveChanges};default:return e}}},60427:(e,t,a)=>{"use strict";a.d(t,{$9:()=>o,Ay:()=>g,Tu:()=>m,az:()=>h});var n=a(94558),s=a(42094);const o="leads",i="Leads/ADS_LIST_START",r="Leads/ADS_LIST_SUCCESS",l="Leads/ADS_LIST_FAILURE",d="Leads/OPTED_OUT_COUNT_START",c="Leads/OPTED_OUT_COUNT_SUCCESS",p="Leads/OPTED_OUT_COUNT_FAILURE",u={error:null},m=e=>async t=>{t({type:i});try{const a=await(0,n.Tu)(e);return t({type:r,payload:a}),a}catch(e){throw t({type:l,payload:e}),e}},h=e=>async t=>{t({type:d});try{const a=await(0,s.az)(e);return t({type:c,payload:a}),a}catch(e){throw t({type:p,payload:e}),e}};function g(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(t.type){case i:case d:return{...e,error:null};case r:case c:return e;case l:case p:return{...e,error:t.payload};default:return e}}},29390:(e,t,a)=>{"use strict";a.d(t,{Ay:()=>_,Ep:()=>I});var n=a(5282);const s="LISTS/FETCH_LISTS_REQUEST",o="LISTS/FETCH_LISTS_SUCCESS",i="LISTS/FETCH_LISTS_FAILURE",r="LISTS/FETCH_LIST_REQUEST",l="LISTS/FETCH_LIST_SUCCESS",d="LISTS/FETCH_LIST_FAILURE",c="LISTS/SAVE_LIST_REQUEST",p="LISTS/SAVE_LIST_SUCCESS",u="LISTS/SAVE_LIST_FAILURE",m="LISTS/DELETE_LIST_REQUEST",h="LISTS/DELETE_LIST_SUCCESS",g="LISTS/DELETE_LIST_FAILURE",b="LISTS/
1REFRESH_COUNT_START",y="LISTS/REFRESH_COUNT_DONE",x="LISTS/SET_COUNT",f="LISTS/SET_IMPORTING",A=e=>{const t=e.response?.data?.errorMessage||e.response?.data?.message||e.message||"Something went wrong",a=e.response?.data?.code,n=new Error(t);return n.code=a,n.retryAfter=e.response?.data?.retryAfter,n},I=e=>{let{assistantId:t,search:a="",page:r=1,limit:l=50}=e;return async e=>{e({type:s});try{const s=await(0,n.Ep)({assistantId:t,search:a,page:r,limit:l});return e({type:o,payload:s}),s.data||[]}catch(t){throw e({type:i,payload:A(t).message}),A(t)}}},C={list:[],listCap:null,listCount:0,currentList:null,listLoading:!0,currentLoading:!1,saving:!1,deleting:!1,error:null,countRefreshing:{},importingListIds:[],importingById:{}};function _(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:C,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case s:return{...e,listLoading:!0,error:null};case o:return{...e,listLoading:!1,list:t.payload.data||[],listCap:t.payload.listCap??e.listCap,listCount:t.payload.listCount??(t.payload.data||[]).length};case i:return{...e,listLoading:!1,error:t.payload};case f:return{...e,importingListIds:t.payload?.importingListIds||[],importingById:t.payload?.importingById||{}};case r:return{...e,currentLoading:!0,error:null};case l:return{...e,currentLoading:!1,currentList:t.payload};case d:return{...e,currentLoading:!1,error:t.payload};case c:return{...e,saving:!0,error:null};case p:return{...e,saving:!1};case u:return{...e,saving:!1,error:t.payload};case m:return{...e,deleting:!0,error:null};case h:return{...e,deleting:!1,list:e.list.filter((e=>e._id!==t.payload)),listCount:Math.max(0,e.listCount-1),currentList:e.currentList?._id===t.payload?null:e.currentList};case g:return{...e,deleting:!1,error:t.payload};case b:return{...e,countRefreshing:{...e.countRefreshing,[t.payload.listId]:!0}};case y:{const{listId:a,list:n}=t.payload,s={...e.countRefreshing};return delete s[a],{...e,countRefreshing:s,list:n?e.list.map((e=>e._id===a?{...e,...n}:e)):e.list,currentList:n&&e.currentList?._id===a?{...e.currentList,...n}:e.currentList}}case x:{const{listId:a,count:n}=t.payload;if(null==n)return e;const s=e.currentList?._id===a?e.currentList:e.list.find((e=>e._id===a));if(s&&(s.memberCount??s.contactCount)===n)return e;const o={contactCount:n,memberCount:n};return{...e,list:e.list.map((e=>e._id===a?{...e,...o}:e)),currentList:e.currentList?._id===a?{...e.currentList,...o}:e.currentList}}default:return e}}},6379:(e,t,a)=>{"use strict";a.d(t,{Ay:()=>b,pQ:()=>g});var n=a(72505),s=a.n(n),o=a(2915);const i={isLoading:!1,agents:{},error:null,totalSlots:2},r="Agents/START_FETCH",l="Agents/FETCH_SUCCESS",d="Agents/UPDATE_SUCCESS",c="Agents/FETCH_FAILURE",p="Agents/RESET_ERROR",u="Agents/RESET_FETCH",m=e=>({type:c,payload:e}),h=()=>({type:p}),g=(e,t)=>a=>{a(h()),t||a({type:r}),(e=>s().post(`${o.k}/api/fetch-agents`,{assistantId:e}).then((e=>e.data)))(e).then((e=>{const{agents:t,totalSlots:n}=e,s={agents:{},totalSlots:n};t.forEach((e=>{e.color=0===e.power?"#00C800":1===e.power?"#FFA500":"#6002EE",s.agents[e._id]=e})),a({type:l,payload:s})})).catch((e=>{console.error(e),a(m({errmsg:"Unable to setup connection"}))}))};function b(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i,{type:t,payload:a}=arguments.length>1?arguments[1]:void 0;switch(t){case r:return{...e,isLoading:!0};case l:return{...e,isLoading:!1,error:null,agents:{...a.agents},totalSlots:a.totalSlots};case d:const{agentId:t,filterObj:n}=a;return e.agents[t].filter=n,{...e,agents:{...e.agents}};case c:return{...e,isLoading:!1,error:a};case p:return{...e,error:null};case u:return{...i};default:return e}}},9928:(e,t,a)=>{"use strict";a.d(t,{Ay:()=>g,ge:()=>m});var n=a(14272),s=a(94558);const o={isLoading:!1,campaignsList:{},error:null,dailyTemplateLimit:0,consumedQuota:0},i="CampaignsList/START_FETCH",r="CampaignsList/FETCH_SUCCESS",l="CampaignsList/FETCH_FAILURE",d="CampaignsList/RESET_ERROR",c="CampaignsList/RESET_FETCH",p="CampaignsList/NEW_CAMPAIGN",u="CampaignsList/DAILY_TEMPLATE_QUOTA",m=e=>t=>{t({type:d}),t({type:i}),(0,n.ge)(e).then((async a=>{const n={};a.forEach((e=>{n[e.name]=e})),t({type:r,payload:n}),await t(h(e))})).catch((e=>{console.error(e),t({type:l,payload:{errmsg:"Unable to setup connection"}})}))},h=e=>t=>{(0,s.gi)(e).then((e=>{const{dailyTemplateLimit:a,consumedTemplateLimitQuota:n}=e;t({type:u,payload:{dailyTemplateLimit:a,consumedQuota:n}})})).catch((e=>{console.error(e)}))};function g(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o,{type:t,payload:a}=arguments.length>1?arguments[1]:void 0;switch(t){case i:return{...e,isLoading:!0};case r:return{...e,isLoading:!1,error:null,campaignsList:{...a}};case l:return{...e,isLoading:!1,error:a};case d:return{...e,error:null};case c:return{...o};case p:return{...e,campaignsList:{...e.campaignsList,[a.name]:a}};case u:return{...e,...a};default:return e}}},95454:(e,t,a)=>{"use strict";a.d(t,{A:()=>b,u:()=>g});var n=a(72505),s=a.n(n),o=a(2915);const i={isLoading:!1,tags:{},error:null,attributes:[],globalAttributes:[],rawAttributes:[]},r="Tag/START_FETCH",l="Tag/FETCH_SUCCESS",d="Tag/FETCH_FAILURE",c="Tag/RESET_ERROR",p="Tag/RESET_FETCH",u="Tag/NEW_TAG",m="Tag/REMOVE_TAG",h="Tag/RESET_SELECTED",g=(e,t)=>a=>{var n;a({type:c,payload:n}),t||a({type:r}),(e=>s().post(`${o.k}/api/fetch-tags`,{assistantId:e}).then((e=>e.data)))(e).then((e=>{const{tags:t,attributes:n,globalAttributes:s}=e,o={tags:{},attributes:[],globalAttributes:[],rawAttributes:[]};t.forEach((e=>{o.tags[e._id]=e}));const i=n.filter((e=>!e.archived));
1o.rawAttributes=i,i.forEach((e=>{const{action:t,name:a}=e,n=t?t+"_"+a:a;o.attributes.push(n)})),s.forEach((e=>{const{name:t}=e;o.globalAttributes.push(t)})),a((e=>({type:l,payload:e}))(o))})).catch((e=>{console.error(e),a((e=>({type:d,payload:e}))({errmsg:"Unable to setup connection"}))}))};function b(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i,{type:t,payload:a}=arguments.length>1?arguments[1]:void 0;switch(t){case r:return{...e,isLoading:!0};case l:return{...e,isLoading:!1,error:null,tags:{...a.tags},attributes:[...a.attributes],globalAttributes:[...a.globalAttributes],rawAttributes:[...a.rawAttributes]};case d:return{...e,isLoading:!1,error:a};case c:return{...e,error:null};case p:return{...i};case u:return{...e,tags:{...e.tags,[a._id]:a}};case m:const t={...e.tags};return delete t[a],{...e,tags:{...t}};case h:const n={...e.tags};a.selectedTags.forEach((e=>{Object.keys(n).forEach((t=>{n[t].tagName!==e&&delete n[t]}))}));const s=e.attributes.filter((e=>a.selectedAttributes.includes(e)));return{...e,tags:n,attributes:s};default:return e}}},85301:(e,t,a)=>{"use strict";a.d(t,{$9:()=>l,DX:()=>M,a3:()=>R,$L:()=>U,Ay:()=>z,sJ:()=>B,ls:()=>O,fc:()=>P,$N:()=>W,GE:()=>F});var n=a(86920),s=a(36175),o=a(72505),i=a.n(o),r=a(2915);const l="setup",d="Setup/CREATE_PAGE_START",c="Setup/CREATE_PAGE_SUCCESS",p="Setup/CREATE_PAGE_FAILURE",u="Setup/FB_TOKEN_INFO_START",m="Setup/FB_TOKEN_INFO_SUCCESS",h="Setup/FB_TOKEN_INFO_FAILURE",g="Setup/LINK_WHATSAPP_NUMBER_START",b="Setup/LINK_WHATSAPP_NUMBER_SUCCESS",y="Setup/LINK_WHATSAPP_NUMBER_FAILURE",x="Setup/SETUP_BUSINESS_ACCOUNT_START",f="Setup/SETUP_BUSINESS_ACCOUNT_SUCCESS",A="Setup/SETUP_BUSINESS_ACCOUNT_FAILURE",I="Setup/ACCEPT_LEAD_FORM_TOS_START",C="Setup/ACCEPT_LEAD_FORM_TOS_SUCCESS",_="Setup/ACCEPT_LEAD_FORM_TOS_FAILURE",S="Setup/CREATE_RAZORPAY_ORDER_START",v="Setup/CREATE_RAZORPAY_ORDER_SUCCESS",E="Setup/CREATE_RAZORPAY_ORDER_FAILURE",T="Setup/VERIFY_RAZORPAY_PAYMENT_START",D="Setup/VERIFY_RAZORPAY_PAYMENT_SUCCESS",w="Setup/VERIFY_RAZORPAY_PAYMENT_FAILURE",N="Setup/UPDATE_FAILED_RAZORPAY_ORDER_START",j="Setup/UPDATE_FAILED_RAZORPAY_ORDER_SUCCESS",k="Setup/UPDATE_FAILED_RAZORPAY_ORDER_FAILURE",L={isCreatingPage:!1,fbTokenInfo:null,isCheckingFbTokenInfo:!1,isLinkingWhatsappNumber:!1,isSettingUpBusinessAccount:!1,isAcceptingLeadFormTos:!1,isCreatingRazorpayOrder:!1,isVerifyingRazorpayPayment:!1,isUpdatingFailedRazorpayOrder:!1,error:null},R=e=>async t=>{t({type:d});try{const a=await(0,n.a3)(e);return t({type:c,payload:a}),a}catch(e){throw t({type:p,payload:e}),e}},B=e=>async t=>{t({type:u});try{const a=await(0,n.sJ)(e);return t({type:m,payload:a}),a}catch(e){throw t({type:h,payload:e}),e}},O=e=>async t=>{t({type:g});try{const a=await(0,n.ls)(e);return t({type:b,payload:a}),a}catch(e){throw t({type:y,payload:e}),e}},P=e=>async t=>{t({type:x});try{const a=await(0,n.fc)(e);return t({type:f,payload:a}),a}catch(e){throw t({type:A,payload:e}),e}},M=e=>async t=>{t({type:I});try{const a=await(0,s.DX)(e);return t({type:C,payload:a}),a}catch(e){throw t({type:_,payload:e}),e}},U=e=>async t=>{t({type:S});try{const a=await(e=>i().post(`${r.k}/payment/create-whitelabel-razorpay-order`,e).then((e=>e.data)))(e);return t({type:v,payload:a}),a}catch(e){throw t({type:E,payload:e}),e}},F=e=>async t=>{t({type:T});try{const a=await(e=>i().post(`${r.k}/payment/verify-whitelabel-razorpay-payment`,e).then((e=>e.data)))(e);return t({type:D,payload:a}),a}catch(e){throw t({type:w,payload:e}),e}},W=e=>async t=>{t({type:N});try{const a=await(e=>i().post(`${r.k}/payment/update-failed-whitelabel-razorpay-order`,e).then((e=>e.data)))(e);return t({type:j,payload:a}),a}catch(e){throw t({type:k,payload:e}),e}};function z(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:L,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(t.type){case d:return{...e,isCreatingPage:!0,error:null};case c:return{...e,isCreatingPage:!1};case p:return{...e,isCreatingPage:!1,error:t.payload};case u:return{...e,isCheckingFbTokenInfo:!0,error:null};case m:return{...e,isCheckingFbTokenInfo:!1,fbTokenInfo:t.payload};case h:return{...e,isCheckingFbTokenInfo:!1,error:t.payload};case g:return{...e,isLinkingWhatsappNumber:!0,error:null};case b:return{...e,isLinkingWhatsappNumber:!1};case y:return{...e,isLinkingWhatsappNumber:!1,error:t.payload};case x:return{...e,isSettingUpBusinessAccount:!0,error:null};case f:return{...e,isSettingUpBusinessAccount:!1};case A:return{...e,isSettingUpBusinessAccount:!1,error:t.payload};case I:return{...e,isAcceptingLeadFormTos:!0,error:null};case C:return{...e,isAcceptingLeadFormTos:!1};case _:return{...e,isAcceptingLeadFormTos:!1,error:t.payload};case S:return{...e,isCreatingRazorpayOrder:!0,error:null};case v:return{...e,isCreatingRazorpayOrder:!1};case E:return{...e,isCreatingRazorpayOrder:!1,error:t.payload};case T:return{...e,isVerifyingRazorpayPayment:!0,error:null};case D:return{...e,isVerifyingRazorpayPayment:!1};case w:return{...e,isVerifyingRazorpayPayment:!1,error:t.payload};case N:return{...e,isUpdatingFailedRazorpayOrder:!0,error:null};case j:return{...e,isUpdatingFailedRazorpayOrder:!1};case k:return{...e,isUpdatingFailedRazorpayOrder:!1,error:t.payload};default:return e}}},68049:(e,t,a)=>{"use strict";a.d(t,{Ay:()=>g,Nk:()=>h});var n=a(72505),s=a.n(n),o=a(2915);const i={templates:{},allTemplates:{},isLoading:!1,error:null},r="TEMPLATE/LOAD_START",l="TEMPLATE/LOAD_SUCCESS",d="TEMPLATE/LOAD_FAILURE",c="TEMPLATE/ADD_TEMPLATE",p="TEMPLATE/UNLOAD_TEMPLATE",u="TEMPLATE/UPDATE_TEMPLATE",m=e=>({type:d,payload:e}),h=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return n=>{n({type:r});const i=()=>{a<3&&setTimeout((()=>{n(h(e,null,a+1))}),1500)};(e=>{let{assistantId:t,cancelToken:a}=e;return s().post(`${o.k}/api/templates`,{assistantId:t}
1,{responseType:"stream",...a?{cancelToken:a}:{}}).then((e=>e.data))})({assistantId:e,cancelToken:t?t.token:void 0}).then((t=>{try{const a=JSON.parse(`[${t.substring(0,t.length-1)}]`),s={},o={};a.filter((e=>"APPROVED"===e.status)).forEach((e=>{s[e.name]=e})),a.forEach((e=>{o[e.name]=e})),n((e=>({type:l,payload:e}))({templates:s,assistantId:e,allTemplates:o}))}catch(e){console.log("Error while updating template | API - success",e),n(m(e)),i()}})).catch((e=>{console.error(e),n(m(e)),i()}))}};function g(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i,{type:t,payload:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(t){case r:return{...e,isLoading:!0,error:null};case l:return{...e,templates:{...a.templates},allTemplates:{...a.allTemplates},assistantId:a.assistantId,isLoading:!1,error:null};case d:return{...e,isLoading:!1,error:a};case c:return{...e,templates:{...e.templates,[a.name]:a}};case p:return{...i};case u:return{...e,templates:{...e.templates,[a.name]:a}};default:return e}}},2845:(e,t,a)=>{"use strict";a.d(t,{A:()=>u});var n=a(33297),s=a(1265),o=a(65613),i=a(21966),r=a(23664),l=a(15124),d=a(37200);const c=(0,r.debounce)((e=>e()),100),p=(0,n.createStore)(o.A,(0,i.tY)((0,n.applyMiddleware)(s.A),(0,l.a)(c)));(0,d.B)(p);const u=p},37200:(e,t,a)=>{"use strict";a.d(t,{B:()=>s,v:()=>
1o});let n=null;const s=e=>{n=e},o=()=>n},56870:(e,t,a)=>{"use strict";a.d(t,{c7:()=>s});const n={rewardBackground:{default:"#E4F2FF"}},s=e=>{if(!e)return e;const t=Object.keys(n).filter((t=>!e.palette||void 0===e.palette[t]));return 0===t.length?e:{...e,palette:{...e.palette,...t.reduce(((e,t)=>({...e,[t]:n[t]})),{})}}}},29445:(e,t,a)=>{"use strict";a.d(t,{A:()=>r});var n=a(31601),s=a.n(n),o=a(76314),i=a.n(o)()(s());i.push([e.id,'/* Global CSS that must exist wherever the ads app renders — INCLUDING inside\n * the console, where it is mounted as a Module Federation remote.\n *\n * index.css reaches the browser only through bootstrap.js, which runs in the\n * STANDALONE app. Embedded, the host renders AdsApp directly, bootstrap.js\n * never executes, and every rule below is simply absent — which is why MUI\'s\n * default `.MuiSelect-select:focus` grey band showed on every Select in the\n * remote but never in the console.\n *\n * Only rules that are safe to apply to a HOST page belong here: these are\n * component-scoped, and the console\'s own index.css already declares each one\n * with the same values, so injecting them there changes nothing. The rules\n * that stayed behind in index.css (body, #root, a, the scrollbar block) style\n * the PAGE and would restyle the console if they were injected.\n */\n\n.MuiTooltip-popper {\n  z-index: 99999 !important;\n}\n\n/* MUI v4 paints `.MuiSelect-select:focus` rgba(0,0,0,0.05) with square corners.\n *\n * The console suppresses it with the bare `.MuiSelect-select` selector, which\n * works there because its JSS instance emits the clean, unsuffixed class name.\n * Inside the remote the same element is emitted as `MuiSelect-select-123`, so\n * the bare selector matches NOTHING — copying the console\'s rule verbatim left\n * the grey band on every Select in the MFE. Match both forms, the way every\n * other Select override in this repo already does (AdsMediaSection,\n * AdBreakdownInsights).\n *\n * Use the PAIRED form with the trailing dash (see\n * __tests__/muiGlobalSelectors.test.js): the dash-less\n * [class*="MuiSelect-select"] also matches sibling slots like\n * MuiSelect-selectMenu, which is the over-match that shrank the Audiences\n * chevron once already. */\n.MuiSelect-select:focus,\n[class*="MuiSelect-select-"]:focus {\n  background-color: transparent !important;\n  border-radius: inherit;\n}\n.animate-enter {\n  opacity: 0.01;\n}\n\n.animate-enter.animate-enter-active {\n  opacity: 1;\n  transition: opacity 500ms ease-in;\n}\n\n.animate-leave {\n  opacity: 1;\n}\n\n.animate-leave.animate-leave-active {\n  opacity: 0.01;\n  transition: opacity 300ms ease-in;\n}\n\n/* .react-flow__node {\n  z-index: -1 !important;\n} */\n\n.rti--container {\n  width: 91%;\n  --rti-bg: #fff !important;\n  --rti-border: 1px solid transparent !important;\n  border: 1px solid transparent !important;\n  --rti-main: transparent !important;\n  --rti-radius: 4px !important;\n  --rti-s: 0.5rem !important;\n  --rti-tag: #e9edef !important;\n  --rti-tag-remove: #e53e3e !important;\n  border-radius: 4px;\n  min-height: 24px;\n}\n\n.rti--container:hover {\n  --rti-border: 1px solid #008069 !important;\n  border: 1px solid #008069 !important;\n}\n\n.border-connector {\n  position: absolute;\n  height: 2px; /* Adjust thickness as needed */\n  background-color: black; /* Adjust color as needed */\n  transform-origin: 0 0;\n}\n\n/* Ginger AI panel layout (ported from console master index.css). */\n:root {\n  --ginger-panel-width: 400px;\n  --ginger-panel-gap: 0px;\n  --ginger-shell-inset: 0px;\n}\n@media (min-width: 1300px) {\n  :root.ginger-panel-open {\n    --ginger-shell-inset: calc(\n      var(--ginger-panel-width) + var(--ginger-panel-gap) * 2\n    );\n  }\n  :root.ginger-panel-open .ginger-page-root {\n    padding-top: var(--ginger-page-header-height, 60px);\n  }\n  :root.ginger-panel-open .ginger-page-header {\n    position: fixed !important;\n    top: var(--ginger-page-header-top, 0px);\n    left: var(--ginger-page-header-left, 70px);\n    right: 0;\n    width: auto !important;\n    max-width: none;\n    z-index: 1400;\n  }\n  :root.ginger-panel-open .ginger-page-footer {\n    right: var(--ginger-shell-inset, 0px);\n  }\n}\n@media (max-width: 1299.95px) {\n  :root {\n    --ginger-panel-width: 100vw;\n    --ginger-panel-gap: 0px;\n  }\n}\n\n/* Spinner rotation, under a GLOBALLY UNIQUE name.\n *\n * The ads pages originally used JSS-scoped keyframes (`animation: "$rotation"`\n * + `"@keyframes rotation"` in the same sheet). That is correct in the console,\n * which has ONE JSS instance. Embedded, the host and the remote each run their\n * own JSS with its own counter, so both can emit the same scoped keyframes name\n * — one sheet\'s @keyframes then shadows the other\'s and the Sync Ad spinner sat\n * still instead of rotating.\n *\n * A literal name sidesteps scoping entirely. Prefixed so it cannot collide with\n * anything the host defines. */\n@keyframes adsSpinnerRotation {\n  from {\n    transform: rotate(0deg);\n  }\n  to {\n    transform: rotate(359deg);\n  }\n}\n',""]);const r=i},49181:(e,t,a)=>{"use strict";a.d(t,{A:()=>u});var n=a(31601),s=a.n(n),o=a(76314),i=a.n(o),r=a(4417),l=a.n(r),d=new URL(a(44308),a.b),c=i()(s()),p=l()(d);
1c.push([e.id,`/* Calendar icons */\n.DateRangePicker {\n  display: block;\n}\n.DateRangePickerInput_arrow.DateRangePickerInput_arrow_1 {\n  display: none;\n}\n\n.DateInput {\n  position: relative;\n  border-radius: 4px;\n  border: 1px solid lightgrey;\n  width: 120px;\n  height: 30px;\n  cursor: pointer;\n  background: transparent;\n}\n.DateInput_screenReaderMessage {\n    overflow: visible;\n    clip: auto;\n    width: 100%;\n    pointer-events: none;\n\t\ttop: 0;    \n}\n.DateInput_screenReaderMessage:after {\n    content: '';\n    width: 21px;\n    height: 22px;\n    position: absolute;\n    top: 5px;\n    left: 5px;\n    background: url(${p}) no-repeat;\n    background-size: contain;\n}\n.DateInput:first-child {\n    margin-right: 10px;\n}\n.DateInput_input:before {\n    content: '';\n    width: 100px;\n    height: 30px;\n}\n/* Theme styles */\n\n\n.DateInput__small {\n\t/*width: 90px;*/\n\toverflow: hidden;\n}\n.DayPickerNavigation {\n\tdisplay: flex;\n\tjustify-content: space-between;\n}\n.DayPickerNavigation_button {\n\tdisplay: inline-block;\n}\n.CalendarDay {\n\twidth: 38px !important;\n\theight: 38px !important;\n\tborder-radius: 50%;\n\tcolor: black;\n}\n.CalendarDay:focus {\n\toutline: none;\n}\n.CalendarDay__selected, .CalendarDay__selected:active, .CalendarDay__selected:hover {\n\tborder: none !important;\n\tbackground: #0a474c !important;\n\tcolor: white;\n}\n.CalendarDay__selected_span,.CalendarDay__selected_span:active, .CalendarDay__selected_span:hover {\n\tbackground: #ebf5f3;\n\tborder: none;\n\tcolor: black;\n}\n.CalendarDay__blocked_out_of_range, .CalendarDay__blocked_out_of_range:active, .CalendarDay__blocked_out_of_range:hover {\n\tborder: none;\n\tcolor: grey;\n}\n.CalendarDay__default {\n\tborder: none;\n}\n.CalendarDay__default:hover {\n\tborder: none;\n\tbackground: #f5f5f5;\n}\n.DateRangePicker_picker__directionLeft {\n\tleft: 0px !important;\n\ttop: 40px !important;\n}\n.DateRangePickerInput {\n\toverflow: hidden;\n\tbackground: transparent;\n\tborder: 0;\n}\n.DateRangePickerInput__withBorder {\n\tborder-radius: unset;\n\tmargin-bottom: -4px;\n}\n.DateInput_input {\n\t/*border-radius: 8px;*/\n\tpadding: 7px 5px;\n\tpadding-left: 30px;\n\toutline: none;\n\tbackground: transparent !important;\n}\n/*.DateInput_input::placeholder {\n\ttext-align: center;\n}\n.DateInput_input::-ms-input-placeholder {\n\ttext-align: center;\n}*/\n.CalendarDay__hovered_span:active {\n\tcolor: black;\n}\n.CalendarDay__hovered_span, .CalendarDay__hovered_span:hover {\n\tbackground: #f5f5f5;\n\tcolor: black;\n}`,""]);const u=c},35358:(e,t,a)=>{var n={"./af":25177,"./af.js":25177,"./ar":61509,"./ar-dz":41488,"./ar-dz.js":41488,"./ar-kw":58676,"./ar-kw.js":58676,"./ar-ly":42353,"./ar-ly.js":42353,"./ar-ma":24496,"./ar-ma.js":24496,"./ar-sa":82682,"./ar-sa.js":82682,"./ar-tn":89756,"./ar-tn.js":89756,"./ar.js":61509,"./az":95533,"./az.js":95533,"./be":28959,"./be.js":28959,"./bg":47777,"./bg.js":47777,"./bm":54903,"./bm.js":54903,"./bn":61290,"./bn-bd":17357,"./bn-bd.js":17357,"./bn.js":61290,"./bo":31545,"./bo.js":31545,"./br":11470,"./br.js":11470,"./bs":44429,"./bs.js":44429,"./ca":7306,"./ca.js":7306,"./cs":56464,"./cs.js":56464,"./cv":73635,"./cv.js":73635,"./cy":64226,"./cy.js":64226,"./da":93601,"./da.js":93601,"./de":77853,"./de-at":26111,"./de-at.js":26111,"./de-ch":54697,"./de-ch.js":54697,"./de.js":77853,"./dv":60708,"./dv.js":60708,"./el":54691,"./el.js":54691,"./en-au":53872,"./en-au.js":53872,"./en-ca":28298,"./en-ca.js":28298,"./en-gb":56195,"./en-gb.js":56195,"./en-ie":66584,"./en-ie.js":66584,"./en-il":65543,"./en-il.js":65543,"./en-in":9033,"./en-in.js":9033,"./en-nz":79402,"./en-nz.js":79402,"./en-sg":43004,"./en-sg.js":43004,"./eo":32934,"./eo.js":32934,"./es":97650,"./es-do":20838,"./es-do.js":20838,"./es-mx":17730,"./es-mx.js":17730,"./es-us":56575,"./es-us.js":56575,"./es.js":97650,"./et":3035,"./et.js":3035,"./eu":3508,"./eu.js":3508,"./fa":119,"./fa.js":119,"./fi":90527,"./fi.js":90527,"./fil":95995,"./fil.js":95995,"./fo":52477,"./fo.js":52477,"./fr":85498,"./fr-ca":26435,"./fr-ca.js":26435,"./fr-ch":37892,"./fr-ch.js":37892,"./fr.js":85498,"./fy":37071,"./fy.js":37071,"./ga":41734,"./ga.js":41734,"./gd":70217,"./gd.js":70217,"./gl":77329,"./gl.js":77329,"./gom-deva":32124,"./gom-deva.js":32124,"./gom-latn":93383,"./gom-latn.js":93383,"./gu":95050,"./gu.js":95050,"./he":11713,"./he.js":11713,"./hi":43861,"./hi.js":43861,"./hr":26308,"./hr.js":26308,"./hu":90609,"./hu.js":90609,"./hy-am":17160,"./hy-am.js":17160,"./id":74063,"./id.js":74063,"./is":89374,"./is.js":89374,"./it":88383,"./it-ch":21827,"./it-ch.js":21827,"./it.js":88383,"./ja":23827,"./ja.js":23827,"./jv":89722,"./jv.js":89722,"./ka":41794,"./ka.js":41794,"./kk":27088,"./kk.js":27088,"./km":96870,"./km.js":96870,"./kn":84451,"./kn.js":84451,"./ko":63164,"./ko.js":63164,"./ku":98174,"./ku.js":98174,"./ky":78474,"./ky.js":78474,"./lb":79680,"./lb.js":79680,"./lo":15867,"./lo.js":15867,"./lt":45766,"./lt.js":45766,"./lv":69532,"./lv.js":69532,"./me":58076,"./me.js":58076,"./mi":41848,"./mi.js":41848,"./mk":30306,"./mk.js":30306,"./ml":73739,"./ml.js":73739,"./mn":99053,"./mn.js":99053,"./mr":86169,"./mr.js":86169,"./ms":73386,"./ms-my":92297,"./ms-my.js":92297,"./ms.js":73386,"./mt":77075,"./mt.js":77075,"./my":72264,"./my.js":72264,"./nb":22274,"./nb.js":22274,"./ne":8235,"./ne.js":8235,"./nl":92572,"./nl-be":43784,"./nl-be.js":43784,"./nl.js":92572,"./nn":54566,"./nn.js":54566,"./oc-lnc":69330,"./oc-lnc.js":69330,"./pa-in":29849,"./pa-in.js":29849,"./pl":94418,"./pl.js":94418,"./pt":79834,"./pt-br":48303,"./pt-br.js":48303,"./pt.js":79834,"./ro":24457,"./ro.js":24457,"./ru":82271,"./ru.js":82271,"./sd":1221,"./sd.js":1221,"./se":33478,"./se.js":33478,"./si":17538,"./si.js":17538,"./sk":5784,"./sk.js":5784,"./sl":46637,"./sl.js":46637,"./sq":86794,"./sq.js":86794,"./sr":45719,"./sr-cyrl":3322,"./sr-cyrl.js":3322,"./sr.js":45719,"./ss":56e3,"./ss.js":56e3,"./sv":41011,"./sv.js":41011,"./sw":40748,"./sw.js":40748,"./ta":11025,"./ta.js":11025,"./te":11885,"./te.js":11885,"./tet":28861,"./tet.js":28861,"./tg":86571,"./tg.js":86571,"./th":55802,"./th.js":55802,"./tk":59527,"./tk.js":59527,"./tl-ph":29231,"./tl-ph.js":29231,"./tlh":31052,"./tlh.js":31052,"./tr":85096,"./tr.js":85096,"./tzl":79846,"./tzl.js":79846,"./tzm":81765,"./tzm-latn":97711,"./tzm-latn.js":97711,"./tzm.js":81765,"./ug-cn":48414,"./ug-cn.js":48414,"./uk":16618,"./uk.js":16618,"./ur":57777,"./ur.js":57777,"./uz":57609,"./uz-latn":72475,"./uz-latn.js":72475,"./uz.js":57609,"./vi":21135,"./vi.js":21135,"./x-pseudo":64051,"./x-pseudo.js":64051,"./yo":82218,"./yo.js":82218,"./zh-cn":52648,"./zh-cn.js":52648,"./zh-hk":1632,"./zh-hk.js":1632,"./zh-mo":31541,"./zh-mo.js":31541,"./zh-tw":50304,"./zh-tw.js":50304};function s(e){var t=o(e);return a(t)}function o(e){if(!a.o(n,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return n[e]}s.keys=function(){return Object.keys(n)},s.resolve=o,e.exports=s,s.id=35358},88334:(e,t,a)=>{"use strict";var n=a(85072),s=a.n(n),o=a(97825),i=a.n(o),r=a(77659),l=a.n(r),d=a(55056),c=a.n(d),p=a(10540
1),u=a.n(p),m=a(41113),h=a.n(m),g=a(29445),b={};b.styleTagTransform=h(),b.setAttributes=c(),b.insert=l().bind(null,"head"),b.domAPI=i(),b.insertStyleElement=u();s()(g.A,b),g.A&&g.A.locals&&g.A.locals},44308:(e,t,a)=>{"use strict";e.exports=a.p+"fd507f697e51ea7cff9e.svg"},42634:()=>{}}]);

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.