1import{hp as X,ay as y,j as t,c as Z,r as tt,bd as _,ch as et,aA as g,hq as N,ci as O,ak as C,bS as at,T as ot,hr as D,a_ as rt,by as nt}from"./index-2CwtICst.js";import{c as st}from"./utils-Byo2OGEK.js";import{C as lt}from"./index-IOqWghCC.js";import{D as it}from"./index-BCDMll3A.js";import{A as ct}from"./index-CADnEo0S.js";import{d as k,e as dt}from"./utils-D3WBMLgg.js";import{u as pt,f as mt}from"./index-DHJtGw0g.js";import{T as ut}from"./table_loader-9XCof2ZJ.js";import{T as _t}from"./Table-CwvOdCcz.js";import{D as xt}from"./index-DHIWKDau.js";import{C as bt}from"./automation_content-BQSPJ9In.js";import{D as ft}from"./index-kmTZdMdj.js";import{D as yt}from"./dropdown-1Xi7yUr8.js";import{R as jt}from"./CloseCircleFilled-CbIeIgTN.js";import{R as Ct}from"./DownOutlined-DqNR-cNR.js";import{R as gt}from"./SyncOutlined-Cxccdn5y.js";import"./react-number-format.es-Dr0FQMRn.js";import"./index-CUYKYEVB.js";import"./Portal-m7W4unkL.js";import"./getScrollBarSize-CHB1zEd-.js";import"./CloseIcon-CdU2swGf.js";import"./modal_component-CQ9TsgKw.js";import"./modal_header-Zzno9Dew.js";import"./index-BC4zRIry.js";import"./DialogWrap-DDRffVA8.js";import"./useId-BeW6vcu-.js";import"./index--dXMqRbm.js";import"./download-BsIsPJWO.js";import"./LoadingOutlined-GuF8KcDa.js";import"./RightOutlined-CDcErbka.js";import"./Skeleton-DmHcwJm8.js";import"./index-BDRnyUiW.js";import"./progress-BiVrF1Ei.js";import"./PackageSmall-DXcoG-iG.js";import"./disable_tooltips-CFCTnA_K.js";import"./index-BxPsFHPt.js";import"./css-CG3sgCP8.js";import"./isEqual-DAIv1GAa.js";import"./index-BtZub4HM.js";import"./index-D5oTgR_k.js";import"./constant-BEBLfsgt.js";import"./utils-CJar-MsZ.js";import"./PackageMedium-p3o-GjjV.js";import"./CartTrolley-BJIgsVV3.js";import"./index-9Fh93l2Z.js";import"./index-D-uFs3Zw.js";import"./index-cyGERVfb.js";import"./mixpanel_utils-DOVBG_9P.js";import"./index-DaN20Aem.js";import"./Dropdown-CSDSyzzq.js";import"./PlusOutlined-ByZyTB3m.js";import"./CheckCircleOutlined-M_0-lFA0.js";import"./InfoCircleOutlined-WJAwMEA5.js";import"./index-l3dd8B4K.js";import"./DownloadOutlined-hBiodi2E.js";import"./DownloadOutlined-DTidZHln.js";import"./isNumeric-OYazz19Q.js";const Tt=({onClose:l,automationHistoryId:u,orderId:d})=>{var A,v,F,R,L,M,H,S,P,$,E,Y,V;const{automationHistory:e}=k(),{agents:i,isLoading:s}=pt(),{shipfastShipment:o,isLoading:p}=X({orderId:d}),{calls:r,isLoading:a}=mt({orderId:d}),c=(v=(A=o==null?void 0:o.attributes)==null?void 0:A.shipping_address)==null?void 0:v.name,{query:b}=y(),T=b==null?void 0:b.current_tab,w=e==null?void 0:e.find(m=>m.id===u),f=T==="order",I=f?i==null?void 0:i.find(m=>m.attributes.key==="order_and_address_confirmation"):i==null?void 0:i.find(m=>m.attributes.key==="ndr_management"),U=I==null?void 0:I.id,W=r==null?void 0:r.filter(m=>{var B,z;return((z=(B=m==null?void 0:m.attributes)==null?void 0:B.agent)==null?void 0:z.id)===U}),G=f?(R=(F=o==null?void 0:o.attributes)==null?void 0:F.order)==null?void 0:R.automation_outcomes:(L=o==null?void 0:o.attributes)==null?void 0:L.automation_outcomes,K=f?(H=(M=o==null?void 0:o.attributes)==null?void 0:M.order)==null?void 0:H.final_automation_outcome:(S=o==null?void 0:o.attributes)==null?void 0:S.final_automation_outcome,Q=(E=($=(P=o==null?void 0:o.attributes)==null?void 0:P.whats_app_communications)==null?void 0:$.find(m=>f?["order_confirmation","full_prepaid_no_discount","full_prepaid_discount","partial_prepaid_no_discount","partial_prepaid_discount"].includes(m.template_id):["undelivered","ndr_full_prepaid_no_discount","ndr_full_prepaid_discount","ndr_partial_prepaid_no_discount","ndr_partial_prepaid_discount","ndr_full_prepaid_payment_success","ndr_partial_prepaid_payment_success","ndr_prepaid_payment_refund_success"].includes(m.template_id)))==null?void 0:E.sent_at,J=(V=(Y=o==null?void 0:o.attributes)==null?void 0:Y.whats_app_communications)==null?void 0:V.find(m=>f?["order_confirmation","full_prepaid_no_discount","full_prepaid_discount","partial_prepaid_no_discount","partial_prepaid_discount"].includes(m.template_id):["undelivered","ndr_full_prepaid_no_discount","ndr_full_prepaid_discount","ndr_partial_prepaid_no_discount","ndr_partial_prepaid_discount","ndr_full_prepaid_payment_success","ndr_partial_prepaid_payment_success","ndr_prepaid_payment_refund_success"].includes(m.template_id));return t.jsx(lt,{header:t.jsx(it,{headerTitle:`Order ID: ${w==null?void 0:w.attributes.reference_id}`,onClose:l}),onClose:l,width:"500px",open:!0,children:p||a||s?t.jsx(Z,{}):t.jsx(ct,{finalOutput:K,callHistory:W,customerName:c,automationOutcomes:G,whatsappSentAt:Q,currentWhatsappCommunication:J})})},wt="_container_soaef_10",It="_table_soaef_13",Nt="_cellItem_soaef_19",Ot="_isPrimary_soaef_24",ht="_callTypeTag_soaef_27",Dt="_aiCallTag_soaef_38",kt="_ivrCallTag_soaef_42",n={container:wt,table:It,cellItem:Nt,isPrimary:Ot,callTypeTag:ht,aiCallTag:Dt,ivrCallTag:kt},At=l=>l==="ivr"||l==="ivr_call",q=l=>
1{l.stopPropagation()},vt=()=>{const{automationHistory:l,isLoading:u,isValidating:d,meta:e}=k();y();const[i,s]=tt.useState({show:!1,automationHistoryId:"",orderId:""}),o=[{title:"OrderID",key:"order_id",render:(p,r)=>{const a=r.attributes.reference_id;return t.jsx("p",{className:n.cellItem,children:a})}},{title:"WhatsApp Sent At",key:"whatsapp_sent_at",render:(p,r)=>{const a=r.attributes.whatsapp_sent_at;return a?t.jsx("p",{className:n.cellItem,children:g(a).format("DD MMM, YY")}):t.jsx("p",{className:n.cellItem,children:"--"})}},{title:"WhatsApp Outcome",key:"whatsapp_outcome",render:(p,r)=>{const a=r.attributes.whatsapp_outcome;if(!a)return t.jsx("p",{className:n.cellItem,children:"--"});const c=N(a)||O(a);return t.jsx("p",{className:n.cellItem,children:c})}},{title:"First Call Time",key:"first_call_time",render:(p,r)=>{const{first_call_time:a,call_type:c}=r.attributes;if(!a)return t.jsx("p",{className:n.cellItem,children:"--"});const b=c==="ai_call",T=At(c);return t.jsxs(_,{align:"center",gap:6,children:[t.jsx("p",{className:n.cellItem,children:g(a).format("HH:mm A")}),b&&t.jsx("span",{className:C(n.callTypeTag,n.aiCallTag),onClick:q,children:"AI Call"}),T&&t.jsx("span",{className:C(n.callTypeTag,n.ivrCallTag),onClick:q,children:"IVR Call"})]})}},{title:"Total Calls Count",key:"total_calls_count",render:(p,r)=>{const a=r.attributes.total_call_count;return a?t.jsx("p",{className:n.cellItem,children:a}):t.jsx("p",{className:n.cellItem,children:"--"})}},{title:"Last Call Duration",key:"last_call_duration",render:(p,r)=>{const a=r.attributes.last_call_duration;if(!a)return t.jsx("p",{className:n.cellItem,children:"--"});const c=st(parseInt(a));return t.jsxs("p",{className:C(n.cellItem,n.isPrimary),children:[c," Mins"]})}},{title:"Call Outcome",key:"call_outcome",render:(p,r)=>{const a=r.attributes.call_outcome;if(!a)return t.jsx("p",{className:n.cellItem,children:"--"});const c=N(a)||O(a);return t.jsx("p",{className:n.cellItem,children:c})}},{title:"Final Outcome",key:"final_outcome",render:(p,r)=>{const a=r.attributes.final_outcome;if(!a)return t.jsx("p",{className:n.cellItem,children:"--"});const c=N(a)||O(a);return t.jsx("p",{className:n.cellItem,children:c})}}];return t.jsxs(_,{vertical:!0,gap:16,className:n.container,justify:"space-between",children:[u?t.jsx(ut,{columns:8}):t.jsxs(t.Fragment,{children:[t.jsx(_t,{columns:o,dataSource:l,loading:d,rowKey:"id",pagination:!1,className:n.table,sticky:{offsetHeader:0},onRow:p=>({onClick:()=>{s({show:!0,automationHistoryId:p.id,orderId:p.attributes.shipment_id})}})}),t.jsx(et,{meta:e})]}),i.show&&t.jsx(Tt,{onClose:()=>{s({show:!1,automationHistoryId:"",orderId:""})},automationHistoryId:i.automationHistoryId,orderId:i.orderId})]})},Ft="_container_bjiyz_10",Rt="_itemContainer_bjiyz_17",Lt="_itemValue_bjiyz_23",Mt="_itemLabel_bjiyz_29",j={container:Ft,itemContainer:Rt,itemValue:Lt,itemLabel:Mt},Ht=()=>{var a;const{query:l}=y(),d=l.current_tab==="order",{insights:e,isLoading:i}=dt(),s=e!=null&&e.total_executions?`${parseFloat(((e==null?void 0:e.pickup_response_rate)/(e==null?void 0:e.total_executions)*100).toFixed(2))}%`:"0%",o=e!=null&&e.total_executions?`${parseFloat(((e==null?void 0:e.goal_completion)/(e==null?void 0:e.total_executions)*100).toFixed(2))}%`:"0%",p=e!=null&&e.total_call_duration?`${parseFloat((a=e==null?void 0:e.total_call_duration)==null?void 0:a.toFixed(2))} hrs`:"0 hrs",r=[{key:"total_executions",value:(e==null?void 0:e.total_executions)||0,label:"Total Executions",bgBorderColor:"#C7D5F8"},{key:"pickup_response_rate",value:s,label:"Pickup/Response rate",bgBorderColor:"#C9F2ED"},{key:"goal_completion_rate",value:o,label:"Goal completion %",bgBorderColor:"#EEE2FE"},{key:"total_call_duration",value:p,label:"Total Call Duration",bgBorderColor:"#D0F0DC"},{key:d?"cancellations_detected":"fake_NDR_attempt",value:d?(e==null?void 0:e.cancellation_detected)||"0":(e==null?void 0:e.fake_NDR_attempt)||"0",label:d?"Cancellations Detected":"Fake NDR Attempts",bgBorderColor:"#FAE3D3"}];return i?t.jsx(bt,{width:"100%",height:96}):t.jsx("div",{className:j.container,children:r.map(c=>t.jsxs(_,{className:j.itemContainer,vertical:!0,gap:12,style:{boxShadow:`-4px 4px 1px ${c.bgBorderColor}`}
1,children:[t.jsx("p",{className:j.itemValue,children:c.value}),t.jsx("p",{className:j.itemLabel,children:c.label})]},c.key))})},St="_label_yjbc0_10",Pt="_button_yjbc0_15",$t="_dropdownIcon_yjbc0_18",Et="_dropdownOverlay_yjbc0_22",Yt="_dropdownMenu_yjbc0_35",Vt="_optionContainer_yjbc0_42",Bt="_isOptionSelected_yjbc0_51",zt="_isOptionNotSelected_yjbc0_58",x={label:St,button:Pt,dropdownIcon:$t,dropdownOverlay:Et,dropdownMenu:Yt,optionContainer:Vt,isOptionSelected:Bt,isOptionNotSelected:zt},{Text:qt}=ot,Ut=Object.keys(D).map(l=>({label:D[l],value:l})),Wt=()=>{const{query:l,appendParams:u}=y(),d=l.finalOutcome||"",e=d.length>0,i=e?D[d]:"All";return t.jsxs(_,{className:x.container,align:"center",gap:6,children:[t.jsx("p",{className:x.label,children:"Final Outcome"}),t.jsx(yt,{menu:{items:[{key:"1",label:t.jsx(_,{vertical:!0,gap:2,className:x.dropdownMenu,children:Ut.map(s=>{const o=d===s.value;return t.jsx(_,{className:C(x.optionContainer,{[x.isOptionSelected]:o,[x.isOptionNotSelected]:!o}),align:"center",onClick:p=>{const r=s.value;u(o?{finalOutcome:[],pageNumber:[]}:{finalOutcome:r,pageNumber:[]})},children:t.jsx("p",{children:s.label})},s.value)})}),onClick:s=>{s==null||s.stopPropagation()}}]},placement:"bottomLeft",overlayClassName:x.dropdownOverlay,children:t.jsx(at,{size:"small",className:x.button,children:t.jsxs(_,{justify:"space-between",gap:6,children:[t.jsx(qt,{ellipsis:{tooltip:!0},children:i}),e?t.jsx(jt,{onClick:s=>{s.stopPropagation(),u({finalOutcome:[],pageNumber:[]})},className:x.dropdownIcon}):t.jsx(Ct,{className:x.dropdownIcon})]})})})]})},Gt="_container_9jpxq_10",Kt="_dateRangeText_9jpxq_14",Qt="_showText_9jpxq_22",h={container:Gt,dateRangeText:Kt,showText:Qt},ta=()=>{y();const{automationHistory:l,isLoading:u,isValidating:d,reloadAutomationHistory:e}=k(),{from:i,to:s}=rt();return t.jsxs(_,{vertical:!0,gap:12,className:h.container,children:[t.jsxs(_,{justify:"space-between",align:"center",gap:20,children:[t.jsxs("p",{className:h.dateRangeText,children:["Showing results from"," ",i&&t.jsx("span",{children:g.unix(i).format("DD MMM, YYYY")})," -"," ",s&&t.jsx("span",{children:g.unix(s).format("DD MMM, YYYY")})]}),t.jsxs(_,{align:"center",gap:8,children:[t.jsx(Wt,{}),t.jsxs(_,{align:"center",gap:6,children:[t.jsx("p",{className:h.showText,children:"Show"}),t.jsx(xt,{hideAll:!0,defaultOption:"last_30_days"})]}),t.jsx(ft,{disableDownload:u||d||l.length===0}),t.jsx(nt,{size:"small",icon:t.jsx(gt,{}),loading:u||d,disabled:u||d,onClick:e})]})]}),t.jsx(Ht,{}),t.jsx(vt,{})]})};export{ta 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.