1import{r as o,bR as Y,bI as V,u as z,E as O,j as e,T as i,M as a,H as A,B as r,bx as $,e as R,S as b,bY as J,c9 as K,by as w,bs as Q,am as B,t as N,bw as T,c6 as X,ab as Z,ac as ee,J as H,aD as te,aj as y,n as L,a8 as W,c7 as F,ak as M,A as _,a9 as se,a4 as q,c5 as ne,c8 as ae,ah as ie,v as re,w as oe,x as le,y as ce,m as de,b5 as xe}from"./index-BRYgt7Qm.js";import{I as ue}from"./IzDownloadCsv-B8Pczokn.js";import{I as he}from"./IzBarGraph-CZLwZCc3.js";import{r as fe,s as me,c as je,a as ge}from"./autoengage.service-Cfx-5aCq.js";import{L as pe}from"./Launch-9dmhQZu0.js";import{I as Ce}from"./IzListingTable-x_8hXXcs.js";import{E as be}from"./Edit-hOycgGtb.js";import"./index-4p_RJOuY.js";import"./server.browser-BSs4twPF.js";import"./TableFooter-CH5m0aG9.js";const ve=t=>{B(N({open:!0,message:t,variant:"default",anchorOrigin:{vertical:"bottom",horizontal:"center"}}))},E=(t,n)=>{let s=0,d=0;const x=[],{startDate:l,endDate:u}=n;return(l&&u?t.filter(c=>J(K(c.runDate),{start:l,end:u})):t).forEach(c=>{if(c.statistics){const p=c.statistics,C=p.delivered||0,h=(p.clicks||0)+(p.button1Clicks||0)+(p.button2Clicks||0)+(p.button3Clicks||0);s+=C,d+=h;const j=C>0?(h/C*100).toFixed(2):0;x.push({Date:Q(c.runDate),Sent:w(C),Clicked:w(h),CTR:j})}}),{calculatedCtr:s>0?Math.min((d/s*100).toFixed(2)):0,sent:s,clicked:d,csvFormattedData:x}},ke=({data:t})=>{const[n,s]=o.useState(()=>{const j=new Date;return{startDate:Y(V(j,6)),endDate:j}}
1),[d,x]=o.useState(0),[l,u]=o.useState([{label:"Sent",value:0,color:"#1194ff"},{label:"Clicked",value:0,color:"#71bfff"}]),[g,m]=o.useState([]),c=z(),{currentProject:p}=O(),C=j=>{s({startDate:j.startDate,endDate:j.endDate})};o.useEffect(()=>{if(t){const{calculatedCtr:j,sent:S,clicked:D,csvFormattedData:k}=E(t,n);u([{label:"Sent",value:S,color:"#1194ff"},{label:"Clicked",value:D,color:"#1194ff"}]),k.length===0&&ve(e.jsx(a,{id:"No data to show for the selected date criteria."})),x(j)}},[n,t]);const h=async()=>{const{csvFormattedData:j}=E(t,n);m(j)};return e.jsxs(e.Fragment,{children:[e.jsx(i,{variant:"subtitle1",children:e.jsx(a,{id:"Performance"})}),e.jsx(i,{variant:"body2",children:e.jsx(a,{id:"* The day-wise data is available from 1st March 2023 only."})}),e.jsxs(A,{sx:{mt:"1rem",borderRadius:"4px",backGround:"white"},children:[e.jsxs(r,{display:"flex",alignContent:"center",children:[e.jsx($,{onChange:C,defaultRangeLabel:c.formatMessage({id:"Last 7 Days"})}),e.jsx(r,{sx:{marginLeft:".5rem"},children:e.jsx(ue,{data:g,headers:["Date","Sent","Clicked","CTR"],filename:c.formatMessage({id:"msngr-aut-engag-reprt-csv-name"},{brandName:R.brandName,projectName:p.name}),fetchData:h})})]}),e.jsxs(b,{display:"flex",flexDirection:"row",alignItems:"center",gap:1,mt:2,children:[e.jsx(i,{variant:"h5",children:e.jsx(a,{id:"CTR"})}),e.jsxs(i,{variant:"h2",children:[d,"%"]})]}),e.jsx(he,{data:l})]})]})},ye={pageIndex:1,pageSize:1e5},we=({onClose:t,data:n})=>{const[s,d]=o.useState(null),[x,l]=o.useState(!1),u=async()=>{l(!0);try{const c=await fe(n.id,ye);d(c.data.runReport)}catch{}finally{l(!1)}};o.useEffect(()=>{u()},[]);const g=T(n?.lastPushedAt);X(n?.workflowConfig[0]?.gapDuration);const m=T(n?.createdAt);return e.jsx(r,{children:e.jsx(Z,{fullWidth:!0,maxWidth:"sm",open:!0,onClose:!0,sx:{"& .MuiDialog-paper":{backgroundColor:"#f5f5f5",color:"#333333"}},children:e.jsxs(ee,{children:[e.jsx(H,{onClick:()=>t(!1),sx:{position:"absolute",top:8,right:8},children:e.jsx(te,{})}),e.jsxs(r,{width:"100%",children:[e.jsx(y,{display:"flex",alignContent:"center",justifyContent:"space-between",mt:3,mb:3,children:e.jsxs(r,{children:[e.jsx(i,{variant:"h4",component:"h2",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"700px"},children:n?.workflowConfig[0].name}),e.jsx(r,{children:e.jsx(L,{href:n?.workflowConfig[0].feedUrl,target:"_blank",underline:"always",color:"#0000008a",rel:"noopener",children:e.jsxs(b,{direction:"row",alignItems:"center",sx:{marginBottom:"0.7rem"},children:[e.jsx(i,{variant:"body2",noWrap:!0,sx:{display:"inline-block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:{xs:"200px",sm:"600px"}},children:n?.workflowConfig[0].feedUrl}),e.jsx(pe,{sx:{fontSize:12,ml:.5}})]})})})]})}),x?e.jsxs(b,{alignContent:"center",alignItems:"center",gap:2,children:[e.jsx(W,{}),e.jsx(a,{id:"Loading"}),"... "]}):e.jsxs(y,{container:!0,spacing:5,children:[e.jsx(y,{item:!0,xs:12,md:6,lg:6,children:e.jsx(ke,{data:s})}),e.jsxs(y,{item:!0,xs:12,md:6,lg:6,children:[e.jsx(i,{variant:"subtitle1",children:e.jsx(a,{id:"Timing"})}),e.jsxs(A,{sx:{mt:"1rem",borderRadius:"4px",backGround:"white",padding:"1rem 0rem"},children:[e.jsxs(b,{direction:{xs:"column",sm:"row"},spacing:1,alignContent:"center",justifyContent:"space-around",children:[e.jsxs(r,{textAlign:"center",children:[e.jsx(i,{variant:"subtitle2",color:"textSecondary",children:e.jsx(a,{id:"Daily-start-Time"})}),e.jsx(i,{variant:"body1",children:F(n?.workflowConfig[0]?.startTime)})]}),e.jsxs(r,{textAlign:"center",children:[e.jsx(i,{variant:"subtitle2",color:"textSecondary",children:e.jsx(a,{id:"Daily-End-Time"})}),e.jsx(i,{variant:"body1",children:F(n?.workflowConfig[0]?.endTime)})]})]}),e.jsx(M,{sx:{mt:"1.5rem",mb:"1.5rem"}}),e.jsxs(b,{direction:{xs:"column",sm:"row"},spacing:1,alignContent:"center",justifyContent:"space-around",children:[e.jsxs(r,{textAlign:"center",children:[e.jsx(i,{variant:"subtitle2",color:"textSecondary",children:e.jsx(a,{id:"Created-At"})}),e.jsx(i,{variant:"body1",children:m})]}),e.jsxs(r,{textAlign:"center",children:[e.jsx(i,{variant:"subtitle2",color:"textSecondary",children:e.jsx(a,{id:"last-sent"})}),e.jsx(i,{variant:"body1",children:g})]})]}),e.jsx(M,{sx:{mt:"1.5rem",mb:"1.5rem"}}),e.jsx(b,{children:e.jsxs(r,{alignItem:"center",textAlign:"center",children:[e.jsx(i,{variant:"subtitle2",color:"textSecondary",children:e.jsx(a,{id:"Time-Between-Notification"})}),e.jsxs(i,{variant:"body1",children:[n?.workflowConfig[0]?.gapValue," ",n?.workflowConfig[0]?.gapUnit===2?"hours":"mins"]})]})})]})]})]})]})]})})})},Se=(t,n)=>e.jsxs(r,{children:[e.jsx(q,{title:t?.workflowConfig[0]?.name?.length>45&&t.workflowConfig[0]?.name,children:e.jsx(i,{onClick:()=>n(t),sx:{cursor:"pointer",color:"blue","&:hover":{textDecoration:"underline"},whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"350px"},children:t.workflowConfig[0].name})}
1),e.jsx(i,{variant:"caption",sx:{display:"inline-block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"350px"},children:t.workflowConfig[0].feedUrl})]}),De=t=>t.lastPushedAt?e.jsxs(r,{children:[e.jsx(i,{variant:"body1",children:ne(t.lastPushedAt)}),e.jsx(i,{variant:"body2",children:ae(t.lastPushedAt)})]}):"-",Ie=(t,n)=>e.jsx(ie,{checked:t.status===1,onChange:()=>n(t)}),Re=t=>{const{statistics:n}=t,{delivered:s,clicks:d,button1Clicks:x,button2Clicks:l,button3Clicks:u}=n,g=d+x||0+l||0+u||0;return!s||s===0?"0%":`${(g/s*100).toFixed(2)}%`},Le=(t,n)=>[{id:"Feed Name & URL",label:e.jsx(a,{id:"Feed-Name-&-URL"}),cell:s=>Se(s,t)},{id:"Last-sent",label:e.jsx(a,{id:"Last-sent"}),cell:s=>De(s)},{id:"Sent",label:e.jsx(a,{id:"Sent"}),cell:s=>s.lastPushedAt?w(s.statistics.delivered):"-"},{id:"Clicked",label:e.jsx(a,{id:"Clicked"}),cell:s=>{const{clicks:d=0,button1Clicks:x=0,button2Clicks:l=0,button3Clicks:u=0}=s.statistics||{};return s.lastPushedAt?w(d+x+l+u):"-"}},{id:"CTR",label:e.jsx(a,{id:"CTR"}),cell:s=>s.lastPushedAt?Re(s):"-"},{id:"Status",label:e.jsx(a,{id:"Status"}),cell:s=>Ie(s,n)}],Ae=(t,n,s)=>e.jsx(r,{display:"flex",gap:1,children:e.jsx(q,{title:e.jsx(a,{id:"Edit"}),arrow:!0,children:e.jsx(H,{sx:{backgroundColor:"#EDF3FF"},children:e.jsx(be,{onClick:()=>s(n)})})})}),Te=({data:t,onSuccess:n})=>{const[s,d]=o.useState(),[x,l]=o.useState(!1),[u,g]=o.useState(!1),[m,c]=o.useState(null),[p,C]=o.useState(""),h=_(),j=f=>{h("/auto-engage/edit",{state:{rowData:f}})},S=f=>{c(f);const I=f.status===1?e.jsx(a,{id:"Are you sure you want to disable feed?"}):e.jsx(a,{id:"Are you sure you want to enable feed?"});C(I),g(!0)},D=async()=>{if(m)try{const f=m.status===2?1:2;await me(m.id,{status:f}),n(),k(f===1?e.jsx(a,{id:"AutoEngage enabled successfully."}):e.jsx(a,{id:"AutoEngage disabled successfully."}))}catch{}finally{g(!1)}},k=f=>{B(N({open:!0,message:f,variant:"default",anchorOrigin:{vertical:"bottom",horizontal:"center"}}))},G=()=>{g(!1),c(null)},U=f=>{l(!0),d(f)};return e.jsxs(e.Fragment,{children:[e.jsx(Ce,{data:t,columns:Le(U,S),actions:(f,I)=>Ae(f,I,j)}),e.jsx(se,{open:u,onClose:G,onConfirm:D,confirmationText:p,status:m?.status===2}),x&&e.jsx(we,{onClose:l,data:s})]})};var v={},P;function Fe(){if(P)return v;P=1;var t=re();Object.defineProperty(v,"__esModule",{value:!0}),v.default=void 0;var n=t(oe()),s=le();return v.default=(0,n.default)((0,s.jsx)("path",{d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1M8 13h8v-2H8zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5"}),"Link"),v}var Me=Fe();const Ee=ce(Me),Ue=()=>{const[t,n]=o.useState(null),[s,d]=o.useState(!0),[x,l]=o.useState(!1),u=_(),{currentData:g}=O();z();const m=g.channelId,c=async()=>{try{const h=await je(m,1,1);n(h.data.campaigns)}catch{}finally{d(!1)}};o.useEffect(()=>{c()},[]);const p=async()=>{try{(await ge(m)).data.channelConfigResponse.pageId&&l(!0)}catch{}};o.useEffect(()=>{p()},[]);const C=()=>{u("/auto-engage/connect")};return e.jsxs(b,{children:[e.jsx(b,{direction:"row",justifyContent:"space-between",mb:2,mt:2,children:e.jsx(i,{variant:"h4",children:e.jsx(a,{id:"Messenger AutoEngage"})})}),e.jsx(A,{sx:{minHeight:"80vh"},position:"relative",elevation:1,children:s?e.jsx(r,{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"80vh",children:e.jsx(W,{})}):e.jsx(e.Fragment,{children:t&&t.length>0?e.jsx(e.Fragment,{children:e.jsx(r,{children:e.jsx(Te,{data:t,onSuccess:c})})}):e.jsxs(r,{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",minHeight:"70vh",children:[e.jsxs(r,{textAlign:"center",spacing:2,children:[e.jsx(i,{variant:"h4",children:e.jsx(a,{id:"Messenger AutoEngage"})}),e.jsxs(i,{mt:2,mb:2,children:[e.jsx(a,{id:"Automatically send latest news updates to your subscribers. "}),R.docLink?.msngrAutoengage?e.jsx(L,{target:"_blank",underline:"always",href:R.docLink.msngrAutoengage,sx:{fontSize:"14px"},children:e.jsx(a,{id:"Learn More"})}):e.jsx(e.Fragment,{})]}),e.jsxs(de,{variant:"contained",onClick:C,disabled:!x,children:[e.jsx(Ee,{fontSize:"small",sx:{transform:"rotate(-45deg)",mr:"4px"}}),e.jsx(a,{id:"Connect RSS Feed"})]})]}),!x&&e.jsxs(b,{direction:"row",alignItems:"center",mt:2,children:[e.jsx(xe,{sx:{fontSize:"14px",mr:"4px"}}),e.jsx(i,{variant:"body2",fontStyle:"italic",color:"#3f3e3e8a",children:e.jsx(a,{id:"linkFacebookPage",values:{formatLink:h=>e.jsx(L,{href:"settings/setup",target:"_self",rel:"noopener noreferrer",children:h})}})})]})]})})})]})};export{Ue as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.