PageSourceSearch

https://myreplify.ai/assets/index-BPJ2UTpF.js

js myreplify.ai collected 2026-10-05 12:18:00 UTC 33,546 bytes, 4 lines download raw bytes

1import{e2 as yt,e3 as St,d$ as tt,gI as ts,e1 as K,F as st,j as t,r as u,gq as At,e8 as ss,e4 as Je,gr as he,e5 as It,e6 as Ae,gz as as,gs as ge,u as Le,v as jt,bW as ns,d2 as os,of as Me,og as Se,lv as pe,lw as is,q4 as He,oe as Qe,lJ as N,lD as wt,q5 as rs,pb as $e,q6 as Rt,bg as ls,q7 as ds,q8 as Xe,S as m,bf as cs,aY as us,T as I,bu as gs,a as l,af as ie,B as re,b0 as ye,bI as ps,b2 as Et,oG as hs,Y as ms,cy as bs,d as ne,q9 as Ye,it as xs,ap as fs,b as Be,b8 as vs,l as gt,lT as kt,pK as Ze,pH as Nt,pj as Cs,c1 as Pt,a_ as ys,aX as Ss,ac as As,cL as Is,bV as js,o3 as ws,dr as Rs,lA as Es,mp as ks,qa as Ns,lx as Ps,ou as Ms,ov as pt,aj as ht,de as mt,hQ as Ve,ox as bt,n as $s,Q as E,qb as Bs,lI as Ls,h1 as Os,pd as Ts}from"./index-rKXnMT8v.js";import{M as zs}from"./index-DPObDx4V.js";import{g as Mt,C as Fs,K as Ks,a as et}from"./customRulesKnowledgeInfoAlert-Xytr2gTz.js";import{D as Gs}from"./DeleteOutline-DqnzbGKn.js";import{S as Ds}from"./Search-iuod-19f.js";import{L as xt,F as ft}from"./LastPage-BR0HA9vf.js";import"./index-ChUBT5Ql.js";import"./index-DHNZwsvB.js";import"./TableRow-DLHUhRBh.js";import"./Search-xczNAubh.js";function Ws(e){return yt("MuiPagination",e)}St("MuiPagination",["root","ul","outlined","text"]);const _s=["boundaryCount","componentName","count","defaultPage","disabled","hideNextButton","hidePrevButton","onChange","page","showFirstButton","showLastButton","siblingCount"];function Vs(e={}){const{boundaryCount:a=1,componentName:o="usePagination",count:g=1,defaultPage:P=1,disabled:n=!1,hideNextButton:b=!1,hidePrevButton:c=!1,onChange:v,page:w,showFirstButton:j=!1,showLastButton:O=!1,siblingCount:C=1}=e,y=tt(e,_s),[S,T]=ts({controlled:w,default:P,name:o,state:"page"}),Q=(h,k)=>{w||T(k),v&&v(h,k)},R=(h,k)=>{const L=k-h+1;return Array.from({length:L},(le,X)=>h+X)},M=R(1,Math.min(a,g)),$=R(Math.max(g-a+1,a+1),g),_=Math.max(Math.min(S-C,g-a-C*2-1),a+2),G=Math.min(Math.max(S+C,a+C*2+2),$.length>0?$[0]-2:g-1),x=[...j?["first"]:[],...c?[]:["previous"],...M,..._>a+2?["start-ellipsis"]:a+1<g-a?[a+1]:[],...R(_,G),...G<g-a-1?["end-ellipsis"]:g-a>a?[g-a]:[],...$,...b?[]:["next"],...O?["last"]:[]],V=h=>{switch(h){case"first":return 1;case"previous":return S-1;case"next":return S+1;case"last":return g;default:return null}},q=x.map(h=>typeof h=="number"?{onClick:k=>{Q(k,h)},type:"page",page:h,selected:h===S,disabled:n,"aria-current":h===S?"true":void 0}:{onClick:k=>{Q(k,V(h))},type:h,page:V(h),selected:!1,disabled:n||h.indexOf("ellipsis")===-1&&(h==="next"||h==="last"?S>=g:S<=1)});return K({items:q},y)}function qs(e){return yt("MuiPaginationItem",e)}const J=St("MuiPaginationItem",["root","page","sizeSmall","sizeLarge","text","textPrimary","textSecondary","outlined","outlinedPrimary","outlinedSecondary","rounded","ellipsis","firstLast","previousNext","focusVisible","disabled","selected","icon","colorPrimary","colorSecondary"]),vt=st(t.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"}),"NavigateBefore"),Ct=st(t.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}),"NavigateNext"),Us=["className","color","component","components","disabled","page","selected","shape","size","slots","type","variant"],$t=(e,a)=>{const{ownerState:o}=e;return[a.root,a[o.variant],a[`size${he(o.size)}`],o.variant==="text"&&a[`text${he(o.color)}`],o.variant==="outlined"&&a[`outlined${he(o.color)}`],o.shape==="rounded"&&a.rounded,o.type==="page"&&a.page,(o.type==="start-ellipsis"||o.type==="end-ellipsis")&&a.ellipsis,(o.type==="previous"||o.type==="next")&&a.previousNext,(o.type==="first"||o.type==="last")&&a.firstLast]},Js=e=>{const{classes:a,color:o,disabled:g,selected:P,size:n,shape:b,type:c,variant:v}=e,w={root:["root",`size${he(n)}`,v,b,o!=="standard"&&`color${he(o)}`,o!=="standard"&&`${v}${he(o)}`,g&&"disabled",P&&"selected",{page:"page",first:"firstLast",last:"firstLast","start-ellipsis":"ellipsis","end-ellipsis":"ellipsis",previous:"previousNext",next:"previousNext"}[c]],icon:["icon"]};return It(w,qs,a)},Hs=Ae("div",{name:"MuiPaginationItem",slot:"Root",overridesResolver:$t})(({theme:e,ownerState:a})=>K({},e.typography.body2,{borderRadius:32/2,textAlign:"center",boxSizing:"border-box",minWidth:32,padding:"0 6px",margin:"0 3px",color:(e.vars||e).palette.text.primary,height:"auto",[`&.${J.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity}},a.size==="small"&&{minWidth:26,borderRadius:26/2,margin:"0 1px",padding:"0 4px"},a.size==="large"&&{minWidth:40,borderRadius:40/2,padding:"0 10px",fontSize:e.typography.pxToRem(15)})),Qs=Ae(as,{name:"MuiPaginationItem",slot:"Root",overridesResolver:$t})(({theme:e,ownerState:a})=>K({},e.typography.body2,{borderRadius:32/2,textAlign:"center",boxSizing:"border-box",minWidth:32,height:32,padding:"0 6px",margin:"0 3px",color:(e.vars||e).palette.text.primary,[`&.${J.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${J.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},transition:e.transitions.create(["color","background-color"],{duration:e.transitions.duration.short}),"&:hover":{backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${J.selected}`]:{backgroundColor:(e.vars||e).palette.action.selected,"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette.action.selectedChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.hoverOpacity}))`:ge.alpha(e.palette.action.selected,e.palette.action.selectedOpacity+e.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:(e.vars||e).palette.action.selected}},[`&.${J.focusVisible}`]:{backgroundColor:e.vars?`rgba(${e.vars.palette.action.selectedChannel} / calc(${e.vars.palette.action.selectedOpacity} + ${e.vars.palette.action.focusOpacity}))`:ge.alpha(e.palette.action.selected,e.palette.action.selectedOpacity+e.palette.action.focusOpacity)},[`&.${J.disabled}`]:{opacity:1,color:(e.vars||e).palette.action.disabled,backgroundColor:(e.vars||e).palette.action.selected}}},a.size==="small"&&{minWidth:26,height:26,borderRadius:26/2,margin:"0 1px",padding:"0 4px"},a.size==="large"&&{minWidth:40,height:40,borderRadius:40/2,padding:"0 10px",fontSize:e.typography.pxToRem(15)},a.shape==="rounded"&&{borderRadius:(e.vars||e).shape.borderRadius}),({theme:e,ownerState:a})=>K({},a.variant==="text"&&{[`&.${J.selected}`]:K({},a.color!=="standard"&&{color:(e.vars||e).palette[a.color].contrastText,backgroundColor:(e.vars||e).palette[a.color].main,"&:hover":{backgroundColor:(e.vars||e).palette[a.color].dark,"@media (hover: none)":{backgroundColor:(e.vars||e).palette[a.color].main}},[`&.${J.focusVisible}`]:{backgroundColor:(e.vars||e).palette[a.color].dark}},{[`&.${J.disabled}`]:{color:(e.vars||e).palette.action.disabled}})},a.variant==="outlined"&&{border:e.vars?`1px solid rgba(${e.vars.palette.common.onBackgroun
1dChannel} / 0.23)`:`1px solid ${e.palette.mode==="light"?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)"}`,[`&.${J.selected}`]:K({},a.color!=="standard"&&{color:(e.vars||e).palette[a.color].main,border:`1px solid ${e.vars?`rgba(${e.vars.palette[a.color].mainChannel} / 0.5)`:ge.alpha(e.palette[a.color].main,.5)}`,backgroundColor:e.vars?`rgba(${e.vars.palette[a.color].mainChannel} / ${e.vars.palette.action.activatedOpacity})`:ge.alpha(e.palette[a.color].main,e.palette.action.activatedOpacity),"&:hover":{backgroundColor:e.vars?`rgba(${e.vars.palette[a.color].mainChannel} / calc(${e.vars.palette.action.activatedOpacity} + ${e.vars.palette.action.focusOpacity}))`:ge.alpha(e.palette[a.color].main,e.palette.action.activatedOpacity+e.palette.action.focusOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${J.focusVisible}`]:{backgroundColor:e.vars?`rgba(${e.vars.palette[a.color].mainChannel} / calc(${e.vars.palette.action.activatedOpacity} + ${e.vars.palette.action.focusOpacity}))`:ge.alpha(e.palette[a.color].main,e.palette.action.activatedOpacity+e.palette.action.focusOpacity)}},{[`&.${J.disabled}`]:{borderColor:(e.vars||e).palette.action.disabledBackground,color:(e.vars||e).palette.action.disabled}})})),Xs=Ae("div",{name:"MuiPaginationItem",slot:"Icon",overridesResolver:(e,a)=>a.icon})(({theme:e,ownerState:a})=>K({fontSize:e.typography.pxToRem(20),margin:"0 -8px"},a.size==="small"&&{fontSize:e.typography.pxToRem(18)},a.size==="large"&&{fontSize:e.typography.pxToRem(22)})),Ys=u.forwardRef(function(a,o){const g=At({props:a,name:"MuiPaginationItem"}),{className:P,color:n="standard",component:b,components:c={},disabled:v=!1,page:w,selected:j=!1,shape:O="circular",size:C="medium",slots:y={},type:S="page",variant:T="text"}=g,Q=tt(g,Us),R=K({},g,{color:n,disabled:v,selected:j,shape:O,size:C,type:S,variant:T}),M=ss(),$=Js(R),G=(M?{previous:y.next||c.next||Ct,next:y.previous||c.previous||vt,last:y.first||c.first||ft,first:y.last||c.last||xt}:{previous:y.previous||c.previous||vt,next:y.next||c.next||Ct,first:y.first||c.first||ft,last:y.last||c.last||xt})[S];return S==="start-ellipsis"||S==="end-ellipsis"?t.jsx(Hs,{ref:o,ownerState:R,className:Je($.root,P),children:"…"}):t.jsxs(Qs,K({ref:o,ownerState:R,component:b,disabled:v,className:Je($.root,P)},Q,{children:[S==="page"&&w,G?t.jsx(Xs,{as:G,ownerState:R,className:$.icon}):null]}))}),Zs=["boundaryCount","className","color","count","defaultPage","disabled","getItemAriaLabel","hideNextButton","hidePrevButton","onChange","page","renderItem","shape","showFirstButton","showLastButton","siblingCount","size","variant"],ea=e=>{const{classes:a,variant:o}=e;return It({root:["root",o],ul:["ul"]},Ws,a)},ta=Ae("nav",{name:"MuiPagination",slot:"Root",overridesResolver:(e,a)=>{const{ownerState:o}=e;return[a.root,a[o.variant]]}})({}),sa=Ae("ul",{name:"MuiPagination",slot:"Ul",overridesResolver:(e,a)=>a.ul})({display:"flex",flexWrap:"wrap",alignItems:"center",padding:0,margin:0,listStyle:"none"});function aa(e,a,o){return e==="page"?`${o?"":"Go to "}page ${a}`:`Go to ${e} page`}const na=u.forwardRef(function(a,o){const g=At({props:a,name:"MuiPagination"}),{boundaryCount:P=1,className:n,color:b="standard",count:c=1,defaultPage:v=1,disabled:w=!1,getItemAriaLabel:j=aa,hideNextButton:O=!1,hidePrevButton:C=!1,renderItem:y=q=>t.jsx(Ys,K({},q)),shape:S="circular",showFirstButton:T=!1,showLastButton:Q=!1,siblingCount:R=1,size:M="medium",variant:$="text"}=g,_=tt(g,Zs),{items:G}=Vs(K({},g,{componentName:"Pagination"})),x=K({},g,{boundaryCount:P,color:b,count:c,defaultPage:v,disabled:w,getItemAriaLabel:j,hideNextButton:O,hidePrevButton:C,renderItem:y,shape:S,showFirstButton:T,showLastButton:Q,siblingCount:R,size:M,variant:$}),V=ea(x);return t.jsx(ta,K({"aria-label":"pagination navigation",className:Je(V.root,n),ownerState:x,ref:o},_,{children:t.jsx(sa,{className:V.ul,ownerState:x,children:G.map((q,h)=>t.jsx("li",{children:y(K({},q,{color:b,"aria-label":j(q.type,q.page,q.selected),shape:S,size:M,variant:$}))},h))})}))}),oa=st(t.jsx("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 14H4V6h16zM4 0h16v2H4zm0 22h16v2H4zm8-10c1.38 0 2.5-1.12 2.5-2.5S13.38 7 12 7 9.5 8.12 9.5 9.5 10.62 12 12 12m0-3.5c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1m5 7.49C17 13.9 13.69 13 12 13s-5 .9-5 2.99V17h10zm-8.19-.49c.61-.52 2.03-1 3.19-1 1.17 0 2.59.48 3.2 1z"}),"ContactsOutlined"),qe={height:l(32)},Ne=e=>({width:l(32),height:l(32),border:`${l(1)} solid ${e.palette.secondaryButtonFont}`,borderRadius:l(8),display:"flex",alignItems:"center",justifyContent:"center",color:e.palette.secondaryButtonFont,p:l(4),"&:hover":{backgroundColor:"transparent",color:e.palette.tert
1iary1,border:`${l(1)} solid ${e.palette.tertiary1}`,"& svg":{fill:e.palette.tertiary1}},"&:disabled":{color:e.palette.tertiary5,border:`${l(1)} solid ${e.palette.tertiary5}`}});function ia({campaign:e,junction:a,assistantDraft:o,isExpanded:g,isSelected:P,isActiveManageFlow:n,isUpdating:b,canEditCampaigns:c=!0,hasGlobalGoLiveValidationErrors:v,knowledgeDraftInput:w,getGoLiveTooltipTitle:j,onToggleSelection:O,onExpandAssistant:C,onOpenSingleGoLive:y,onOpenRemoveAssistant:S,isRemoveDisabled:T=!1,removeDisabledReason:Q="",onRevertToDraft:R,onAddKnowledgeItems:M,onSaveInlineSettings:$,onAssistantDraftChange:_,onKnowledgeDraftInputChange:G}){var ae;const x=Le(),V=jt(),q=ns(),h=os("(max-width:600px)"),L=Me(a)===Se.notStarted,le=L?pe.notStarted:pe.inProgress,X=is(x,le),Z=He({campaign:e,junction:a}),Oe=Qe(a),U=String(a.agentId),H=(ae=e==null?void 0:e[N.sharedCampaignAgentSettings])==null?void 0:ae[U],me=u.useMemo(()=>wt(e==null?void 0:e[N.agentMetadataKeys]),[e]),Ie=u.useMemo(()=>rs(e).reduce((i,f)=>{const D=$e(String(f.variable||f.friendlyName||""));if(!D)return i;const W=String(f.friendlyName||f.variable||D).trim();return W&&(i[D]=W),i},{}),[e]),de=Rt({campaign:e,junction:a}),Te=de.reduce((i,f)=>(f.variable&&(i[f.variable]=f.friendlyName||f.variable),i),{...Ie}),be=Array.from(new Set([...me,...de.map(i=>String(i.variable||"").trim()).filter(Boolean),...Object.keys(a.agentMetadata||{}).map(i=>$e(String(i))).filter(Boolean).map(String),...Object.keys(o.locationFields||{})])),je=new Map(ls.map(i=>[$e(String(i.value)),i.label])),A=new Set(de.map(i=>String(i.variable||"").trim()).filter(Boolean)),ee=be.map(i=>({variable:i,value:ds({locationFieldsDraft:o.locationFields,variable:i,junctionMetadata:a.agentMetadata||{}}),label:je.get(i)||Te[i]||i,isRequiredMissing:A.has(i)})),te=!L,B=Mt(o.customKnowledge,U),xe=JSON.stringify(o.locationFields)===JSON.stringify((H==null?void 0:H.locationFields)??{}),we=(H==null?void 0:H.customRules)||(typeof a.agentCampaignRules=="string"?a.agentCampaignRules:""),Re=(H==null?void 0:H.customKnowledge)||Xe(a.agentCampaignKnowledge)||"",oe=o.customRules.trim()===we.trim()&&o.customKnowledge.trim()===Re.trim()&&xe,ze=!c||n&&!L?"View rules":"Edit rules",ce=(i="")=>kt({id:(e==null?void 0:e.id)||"",stepId:Ze.multiAssistantSetup,assistantId:i||void 0});return t.jsxs(m,{"data-testid":`${cs.CampaignOfuAssistantCard}-${U}`,gap:1,sx:{border:`${l(1)} solid ${x.palette.divider}`,borderRadius:l(10),p:l(12)},children:[t.jsxs(m,{direction:"row",alignItems:"center",justifyContent:"space-between",onClick:()=>{n&&C()},sx:{cursor:n?"pointer":"default"},children:[t.jsxs(m,{direction:"row",gap:1.5,alignItems:"center",sx:{flex:1,minWidth:0,pr:l(8)},children:[c&&t.jsx(us,{size:"small",checked:P,disabled:!L||!Z,onClick:i=>i.stopPropagation(),onChange:i=>O(i.target.checked)}),t.jsx(I,{variant:"body1",noWrap:!0,sx:{minWidth:0},children:Oe}),t.jsx(gs,{size:"small",label:X.label,sx:{flexShrink:0,borderRadius:l(6),border:`${l(1)} solid ${X.borderColor}`,backgroundColor:X.backgroundColor,color:X.color,height:l(22),textAlign:"center"}})]}),t.jsxs(m,{direction:"row",gap:.5,alignItems:"center",sx:{flexShrink:0},children:[t.jsx(ie,{title:ze,children:t.jsx(re,{component:"span",children:t.jsx(ye,{size:"small",sx:Ne(x),disabled:b,onClick:i=>{if(i.stopPropagation(),n){C();return}V(ce(U))},children:!c||n&&!L?t.jsx(ps,{sx:{fontSize:l(18)}}):t.jsx(Et,{sx:{fontSize:l(18)}})})})}),t.jsx(ie,{title:"View contacts",children:t.jsx(ye,{size:"small",sx:Ne(x),onClick:i=>{i.stopPropagation(),V(`${ms(bs.campaignOfuContacts,{id:(e==null?void 0:e.id)||""})}?${hs}=${U}`)},children:t.jsx(oa,{sx:{fontSize:l(18)}})})}),c&&L&&t.jsx(ie,{title:j(a,Z),placement:"bottom",leaveDelay:400,disableInteractive:!1,children:t.jsx(re,{component:"span",children:h?t.jsx(ne,{variant:"primaryModern",sx:{...qe,minWidth:l(32),width:l(32),p:0},disabled:b||!Z||v,onClick:i=>{i.stopPropagation(),y(U)},children:t.jsx(Ye,{sx:{fontSize:l(18)}})}):t.jsx(ne,{variant:"primaryModern",startIcon:t.jsx(Ye,{}),sx:qe,disabled:b||!Z||v,onClick:i=>{i.stopPropagation(),y(U)},children:"Go Live"})})}),c&&L&&t.jsx(ie,{title:T?Q:"Remove assistant",children:t.jsx(re,{component:"span",children:t.jsx(ye,{size:"small",sx:Ne(
1x),disabled:b||T,onClick:i=>{i.stopPropagation(),S(U)},children:t.jsx(Gs,{sx:{fontSize:l(18)}})})})}),c&&!L&&q&&t.jsx(ie,{title:"Revert to Draft",children:t.jsx(re,{component:"span",children:t.jsx(ye,{size:"small",sx:Ne(x),disabled:b,onClick:i=>{i.stopPropagation(),R()},children:t.jsx(xs,{sx:{fontSize:l(18)}})})})})]})]}),n&&g&&t.jsxs(t.Fragment,{children:[t.jsx(fs,{}),t.jsxs(m,{gap:1.5,px:.5,pb:.5,children:[te&&t.jsx(I,{variant:"body2",color:"text.secondary",children:"Rules are locked for live assistants. Revert this assistant to draft to edit custom rules and location fields."}),t.jsx(Fs,{}),t.jsxs(m,{spacing:1,useFlexGap:!0,children:[t.jsx(I,{fontWeight:600,variant:"subtitle1",children:"Custom Rules (optional)"}),t.jsx(Be,{fullWidth:!0,multiline:!0,minRows:3,disabled:te||b||!c,value:o.customRules,onChange:i=>_({...o,customRules:i.target.value}),placeholder:"e.g., 'Use a warm and encouraging tone. Emphasize the benefits of our service. Always mention our satisfaction guarantee.'",sx:{".MuiOutlinedInput-root":{borderRadius:l(8),backgroundColor:x.palette.mainBackground}}})]}),t.jsxs(m,{spacing:1,useFlexGap:!0,children:[t.jsx(I,{fontWeight:600,variant:"subtitle1",children:"Custom Knowledge (optional)"}),t.jsxs(m,{direction:"row",spacing:1,alignItems:"center",children:[t.jsx(Be,{disabled:te||b||!c,fullWidth:!0,multiline:!0,minRows:1,maxRows:4,placeholder:"Add knowledge snippet and press Enter...",value:w,onChange:i=>G(i.target.value),onKeyDown:i=>{i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),M())},sx:{".MuiOutlinedInput-root":{paddingBlock:l(6.5),borderRadius:l(8),backgroundColor:x.palette.mainBackground}}}),c&&t.jsx(ye,{disabled:te||b,onClick:M,sx:{backgroundColor:x.palette.primaryButtonBg,border:`${l(1)} solid ${x.palette.divider}`,borderRadius:l(8),height:l(36),width:l(36),"& .MuiTouchRipple-child":{borderRadius:"inherit"},"&:hover":{backgroundColor:gt(x.palette.primaryButtonBg,.2)},"&.Mui-disabled":{backgroundColor:x.palette.tertiary5},"> .MuiSvgIcon-root":{color:x.palette.common.white}},children:t.jsx(vs,{sx:{fontSize:l(18)}})})]}),t.jsx(Ks,{isDisabled:te||b||!c,items:B,onEditItem:async({index:i,text:f})=>{const D=B.map((W,fe)=>fe===i?{...W,text:f}:W);_({...o,customKnowledge:et(D)})},onRemoveItem:async i=>{const f=B.filter((D,W)=>W!==i);_({...o,customKnowledge:et(f)})}})]}),be.length>0&&t.jsxs(m,{spacing:1.5,useFlexGap:!0,sx:{p:l(12),borderRadius:l(8),border:`${l(1)} solid ${x.palette.warning.light}`,backgroundColor:gt(x.palette.warning.light,.9)},children:[t.jsx(I,{variant:"subtitle1",children:"Location Fields"}),t.jsx(I,{variant:"body2",color:x.palette.warning.dark,children:"These values are inserted in campaign messages for this assistant."}),ee.map(({label:i,value:f,variable:D,isRequiredMissing:W})=>t.jsx(m,{spacing:.5,useFlexGap:!0,children:t.jsxs(m,{direction:"row",spacing:1,alignItems:"center",useFlexGap:!0,children:[t.jsxs(m,{spacing:.25,useFlexGap:!0,sx:{minWidth:l(120),maxWidth:l(180)},children:[t.jsx(I,{variant:"body2",fontWeight:600,children:i}),t.jsx(I,{variant:"body2",color:x.palette.warning.dark,children:`[[${D}]]`})]}),t.jsxs(m,{spacing:.5,useFlexGap:!0,sx:{flex:1},children:[t.jsx(Be,{fullWidth:!0,disabled:te||b||!c,value:f,onChange:fe=>_({...o,locationFields:{...o.locationFields,[D]:fe.target.value}}),placeholder:`Enter value for [[${D}]]`,sx:{".MuiOutlinedInput-root":{borderRadius:l(8),height:l(36),backgroundColor:x.palette.mainBackground}}}),W&&!f.trim()?t.jsx(I,{variant:"caption",color:x.palette.error.main,children:"Required"}):null]})]})},D))]}),c&&!te&&t.jsx(m,{direction:"row",justifyContent:"flex-end",children:t.jsx(ne,{variant:"primaryModern",sx:qe,disabled:b||oe,onClick:$,children:"Save"})})]})]})]},a.id||a.agentId)}function ra({assistant:e,campaignChannels:a,selectedNotEnabledAssistantIds:o,isUpdating:g,canEditCampaigns:P=!0,onToggleSelection:n}){const b=Le(),c=String(e.id),v=Nt(e,a),w=v.length===0,j=o.includes(c),O=e.agentReferenceName||e.businessName||e.agentName||c,C=`This assistant doesn't have ${v.map(Cs).join(", ")} enabled.`;return t.jsx(ie,{title:w?"":C,placement:"bottom",children:t.jsxs(m,{direction:"row",alignItems:"center",sx:{border:`${l(1)} solid ${b.palette.divider}`,borderRadius:l(10),p:l(12),opacity:!j&&!w?.55:1,minWidth:0},children:[t.jsx(Pt,{checked:j,disabled:g||!w||!P,onChange:()=>n(c)}),t.jsx(I,{variant:"body1",noWrap:!0,sx:{minWidth:0},children:O})]})},c)}function la({searchValue:e,showOnlyEnableableAssistants:a,isUpdating:o,canEnableAll:g,canClearAll:P,canEditCampaigns:n=!0,onSearchChange:b,onToggleShowOnlyEnableableAssistants:c,onEnableAll:v,onClearAll:w}){const j=Le();return t.jsxs(m,{direction:"row",alignItems:"flex-start",spacing:2,useFlexGap:!0,sx:{mt:2,pt:.5,width:"100%",flexWrap:"nowrap",gap:l(12)},children:[t.jsxs(m,{spacing:.5,children:[t.jsx(Be,{placeholder:"Search assistants...",value:e,onCh
1ange:O=>b(O.target.value),variant:"outlined",size:"small",disabled:o,InputProps:{startAdornment:t.jsx(ys,{position:"start",children:t.jsx(Ds,{color:"action"})})},sx:{flex:"0 1 auto",width:{xxxs:l(200),sm:l(260)},maxWidth:{sm:l(280)},minWidth:l(160),"& .MuiOutlinedInput-root":{borderRadius:l(8),backgroundColor:j.palette.common.white}}}),t.jsx(Ss,{control:t.jsx(Pt,{checked:a,disabled:o,onChange:(O,C)=>c(C)}),label:"Can be enabled"})]}),n&&t.jsxs(m,{direction:"row",spacing:1,alignItems:"center",flexShrink:0,useFlexGap:!0,children:[t.jsx(ne,{variant:"secondaryModern",size:"small",onClick:v,disabled:!g,sx:{whiteSpace:"nowrap"},children:"Enable all"}),t.jsx(ne,{variant:"secondaryModern",size:"small",onClick:w,disabled:!P,sx:{whiteSpace:"nowrap"},children:"Clear all"})]})]})}const Ue={height:l(32)},Pe=10,da="At least one assistant has to be enabled for a campaign.";function Ca(){const e=Le(),{canEdit:a}=As(),o=a(Is.campaigns),g=js(),P=jt(),{campaign:n,isDraft:b,isSharedCampaign:c}=ws(),{agents:v,selectedAgent:w}=Rs(),{mutate:j,isPending:O}=Es((n==null?void 0:n.id)||""),[C,y]=u.useState([]),[S,T]=u.useState([]),[Q,R]=u.useState(!1),[M,$]=u.useState(""),[_,G]=u.useState(!1),[x,V]=u.useState(!1),[q,h]=u.useState(!1),[k,L]=u.useState([]),[le,X]=u.useState(1),[Z,Oe]=u.useState(!0),[U,H]=u.useState(""),[me,Ie]=u.useState(""),[de,Te]=u.useState({}),[be,je]=u.useState({}),A=u.useMemo(()=>ks(n),[n]),ee=u.useMemo(()=>String((n==null?void 0:n[N.agentId])||"").trim(),[n]),te=Ns(n),B=O||_||x,xe=u.useMemo(()=>Ps({channel:n==null?void 0:n[N.channel],ofu_channels:n==null?void 0:n[N.ofuChannels]}),[n]),we=u.useMemo(()=>{const s=A.map(r=>String(r.agentId));return ee&&s.push(ee),Array.from(new Set(s.filter(Boolean)))},[ee,A]),Re=u.useMemo(()=>new Set(we),[we]),oe=u.useMemo(()=>(v||[]).filter(s=>!Re.has(String(s.id))),[v,Re]),se=u.useMemo(()=>new Set(oe.filter(s=>Nt(s,xe).length===0).map(s=>String(s.id))),[xe,oe]),ze=se.size,ce=u.useMemo(()=>U.trim().toLowerCase(),[U]),ae=u.useMemo(()=>oe.filter(s=>{const r=String(s.id),d=se.has(r),p=s.agentReferenceName||s.businessName||s.agentName||r;return!(Z&&!d||ce&&!p.toLowerCase().includes(ce))}),[se,oe,ce,Z]),i=u.useMemo(()=>k.filter(s=>se.has(String(s))).length,[se,k]),f=u.useMemo(()=>ae.map(s=>String(s.id)).filter(s=>se.has(s)),[se,ae]),D=u.useMemo(()=>f.length>0&&f.every(s=>k.includes(s)),[k,f]),W=Math.max(1,Math.ceil(ae.length/Pe)),fe=u.useMemo(()=>{const s=(le-1)*Pe;return ae.slice(s,s+Pe)},[le,ae]);u.useEffect(()=>{X(s=>Math.min(s,W))},[W]),u.useEffect(()=>{X(1)},[Z,ce]);const Fe=u.useMemo(()=>new Set(wt(n==null?void 0:n[N.agentMetadataKeys])),[n]),{isScheduleStepsReady:Ke,validationErrorsWithSteps:Ee}=Ms(n,{selectedAgent:w}),ve=!Ke||Ee.length>0;let Ge="";Ke?Ee.length>0&&(Ge=t.jsx(pt,{validationErrorsWithSteps:Ee,campaignId:n==null?void 0:n.id,linkColor:e.palette.common.white,showLabel:!0})):Ge=bt;const Bt=s=>Rt({campaign:n,junction:s}).map(r=>{const d=String(r.variable||r.friendlyName||"").trim();return{message:`${Qe(s)}: ${r.friendlyName||r.variable||"Required field"}`,friendlyField:r.friendlyName||r.variable||"Required field",stepId:Ze.multiAssistantSetup,fieldPath:`${Ts.sharedCampaignAgentSettings}.${s.agentId}.locationFields.${d}`}}),Lt=(s,r)=>{if(!Ke)return bt;const p=[...r?[]:Bt(s),...Ee].filter((z,ue,Y)=>Y.findIndex(F=>F.message===z.message&&F.fieldPath===z.fieldPath&&F.stepId===z.stepId)===ue);return p.length?t.jsx(pt,{validationErrorsWithSteps:p,campaignId:n==null?void 0:n.id,linkColor:e.palette.common.white,showLabel:!0}):""},Ot=!b,ke=s=>{var Y;const r=de[s];if(r)return r;const d=(Y=n==null?void 0:n[N.sharedCampaignAgentSettings])==null?void 0:Y[s],p=A.find(F=>String(F.agentId)===String(s)),z=Xe(p==null?void 0:p.agentCampaignKnowledge),ue=typeof(p==null?void 0:p.agentCampaignRules)=="string"?p.agentCampaignRules:"";return{customKnowledge:(d==null?void 0:d.customKnowledge)||z||"",customRules:(d==null?void 0:d.customRules)||ue||"",locationFields:(d==null?void 0:d.locationFields)??{}}},De=(s,r)=>{Te(d=>({...d,[s]:r}))},Tt=s=>{Ie(me===s?"":s),de[s]||De(s,ke(s))},zt=(s,r)=>{var it,rt,lt,dt;if(!o)return;const d=ke(s),p=Object.fromEntries(Object.entries({...r.agentMetadata||{},...d.locationFields||{}}).flatMap(([Ce,ct])=>{if(typeof ct!="string")return[];const ut=ct.trim();if(!ut)return[];const _e=$e(Ce);return _e?Fe.size>0&&!Fe.has(_e)?[]:[[_e,ut]]:[]})),z={agentId:s},Y=d.customKnowledge.trim().split(`
2`).map(Ce=>
2Ce.trim()).filter(Boolean).map(Ce=>({id:$s(),text:Ce})),F=d.customRules.trim(),We=!!Xe(r.agentCampaignKnowledge).trim()||!!(((rt=(it=n==null?void 0:n[N.sharedCampaignAgentSettings])==null?void 0:it[s])==null?void 0:rt.customKnowledge)||"").trim(),es=!!(r.agentCampaignRules||"").trim()||!!(((dt=(lt=n==null?void 0:n[N.sharedCampaignAgentSettings])==null?void 0:lt[s])==null?void 0:dt.customRules)||"").trim();(Y.length||We)&&(z.agentCampaignKnowledge=Y),(F||es)&&(z.agentCampaignRules=F),Object.keys(p).length&&(z.agentMetadata=p),j({[N.agents]:[z]},{onSuccess:()=>{E.success("Assistant settings saved.")},onError:()=>{E.error("Unable to save assistant settings.")}})},Ft=s=>{var Y;if(!o)return;const r=((Y=be[s])==null?void 0:Y.trim())||"";if(!r)return;const d=ke(s),p=Mt(d.customKnowledge,s),z=r.split(`
3`).map(F=>F.trim()).filter(Boolean).map((F,We)=>({id:`${s}-new-${We}`,text:F})),ue=[...p,...z];De(s,{...d,customKnowledge:et(ue)}),je(F=>({...F,[s]:""}))},Kt=A.filter(s=>Me(s)===Se.notStarted),Gt=(s,r)=>{const d=A.find(p=>p.agentId===s);if(r&&!He({campaign:n,junction:d})){E.error("Complete required assistant details before going live.");return}y(p=>r?p.includes(s)?p:[...p,s]:p.filter(z=>z!==s))},Dt=()=>{if(o){if(ve){E.error("Complete campaign configuration before going live.");return}if(A.length===0){if(!ee){E.error("No assistant found for this campaign.");return}T([ee]),R(!0);return}if(!C.length){E.error("Select at least one draft assistant before going live.");return}T(C),R(!0)}},Wt=s=>{if(!o)return;if(ve){E.error("Complete campaign configuration before going live.");return}const r=A.find(d=>d.agentId===s);if(!He({campaign:n,junction:r})){E.error("Complete required assistant details before going live.");return}T([s]),R(!0)},at=()=>{R(!1),T([])},_t=s=>{A.length<=1||$(String(s))},nt=()=>{$("")},Vt=()=>{if(!M||B)return;const s=String(M);V(!0),j({[N.agents]:[{agentId:s,isDeleted:!0}]},{onSuccess:()=>{V(!1),y(r=>r.filter(d=>String(d)!==s)),me===s&&Ie(""),$(""),E.success("Assistant removed from campaign.")},onError:()=>{V(!1),E.error("Unable to remove assistant from campaign.")}})},qt=()=>{if(B||!o)return;if(ve){E.error("Complete campaign configuration before going live.");return}const s=Bs({junctions:A,selectedAgentIds:S,fallbackAgentId:ee}),r=A.some(p=>Me(p)===Se.started),d=s.length>0;G(!0),j({[N.agents]:s,[N.executionStatus]:r||d?pe.inProgress:pe.notStarted},{onSuccess:()=>{G(!1),y([]),T([]),R(!1),E.success("Selected assistants are now live.")},onError:()=>{G(!1),E.error("Unable to go live for selected assistants.")}})},Ut=s=>{if(!o)return;const r=A.some(d=>String(d.agentId)!==String(s)&&Me(d)===Se.started);j({[N.agents]:[{agentId:String(s),status:Se.notStarted}],[N.executionStatus]:r?pe.inProgress:pe.notStarted},{onSuccess:()=>{y(d=>d.filter(p=>p!==String(s))),E.success("Assistant reverted to draft.")},onError:()=>{E.error("Unable to revert assistant to draft.")}})},Jt=s=>{o&&L(r=>r.includes(s)?r.filter(d=>d!==s):[...r,s])},Ht=()=>{o&&L(s=>Array.from(new Set([...s,...f])))},Qt=()=>{o&&L([])},ot=()=>{if(!o)return;const s=k.filter(d=>se.has(String(d))),r=Ls({assistantIds:s.map(String),assistants:oe,metadataVariables:Array.from(Fe),sharedCampaignAgentSettings:n==null?void 0:n[N.sharedCampaignAgentSettings]});if(!r.length){h(!1),E.info("No compatible assistants selected to enable.");return}j({[N.agents]:r},{onSuccess:()=>{L([]),h(!1),n!=null&&n.id&&g.invalidateQueries({queryKey:Os.campaign(n.id)}),E.success("Assistants enabled for this campaign.")},onError:()=>{E.error("Unable to enable selected assistants.")}})},Xt=()=>{if(o){if(!c){h(!0);return}ot()}},Yt=(s="")=>kt({id:(n==null?void 0:n.id)||"",stepId:Ze.multiAssistantSetup,assistantId:s||void 0}),Zt=u.useMemo(()=>{if(!M)return"this Agent";const s=A.find(r=>String(r.agentId)===M);return Qe(s)||"this Agent"},[M,A]);return t.jsxs(m,{p:4,gap:2,children:[t.jsx(ht,{severity:"info",children:"Going live for one or more assistants locks campaign-wide configuration."}),t.jsxs(mt,{variant:"outlined",sx:{"&.MuiPaper-root":{borderRadius:l(12),p:l(20)}},children:[t.jsxs(m,{direction:"row",justifyContent:"space-between",alignItems:"center",gap:2,flexWrap:"wrap",children:[t.jsxs(re,{sx:{flex:1,minWidth:0},children:[t.jsx(m,{direction:"row",alignItems:"center",justifyContent:"space-between",width:"100%",children:t.jsx(I,{variant:"h6",children:"Assigned Assistants"})}),t.jsxs(I,{variant:"body2",color:e.palette.text.secondary,children:[A.length," enabled for this campaign"]})]}),t.jsx(zs,{campaign:n}),o&&t.jsxs(m,{direction:"row",gap:1,children:[b&&t.jsx(ne,{variant:"secondaryModern",startIcon:t.jsx(Et,{}),sx:Ue,onClick:()=>P(Yt()),disabled:!Kt.length,children:"Edit custom rules"}),(C.length>0||A.length===0)&&t.jsx(ie,{title:Ge,placement:"bottom",leaveDelay:400,disableInteractive:!1,children:t.jsx(re,{component:"span",children:t.jsx(ne,{variant:"primaryModern",startIcon:t.jsx(Ye,{}),sx:Ue,disabled:B||ve||(A.length>0?C.length===0:!ee),onClick:Dt,children:"Go Live on Selected"})})})]})]}),t.jsx(m,{gap:1.5,mt:2,children:A.map(s=>{const r=String(s.agentId);return t.jsx(ia,{campaign:n,junction:s,assistantDraft:ke(r),isExpanded:me===r,isSelected:C.includes(s.agentId),isActiveManageFlow:Ot,isUpdating:B,canEditCampaigns:o,hasGlobalGoLiveValidationErrors:ve,knowledgeDraftInput:be[r]||"",getGoLiveTooltipTitle:Lt,onToggleSelection:d=>Gt(s.agentId,d),onExpandAssistant:()=>Tt(r),onOpenSingleGoLive:Wt,onOpenRemoveAssistant:_t,isRemoveDisabled:A.length<=1,removeDisabledReason:da,onRevertToDraft:()=>Ut(r),onAddKnowledgeItems:()=>Ft(r),onSaveInlineSettings:()=>zt(r,s),onAssistantDraftChange:d=>De(r,d),onKnowledgeDraftInputChange:d=>je(p=>({...p,[r]:d}))},s.id||s.agentId)})}),te&&t.jsx(I,{variant:"body2",color:e.palette.text.secondary,mt:2,children:"Global campaign configuration is locked because at least one assistant is already live."})]}),t.jsxs(mt,{variant:"outlined",sx:{"&.MuiPaper-root":{borderRadius:l(12),p:l(20)}},children:[t.jsxs(m,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",ga
3p:2,children:[t.jsxs(re,{children:[t.jsx(I,{variant:"h6",children:"Not Enabled Assistants"}),t.jsxs(I,{variant:"body2",color:e.palette.text.secondary,children:[ze," available to enable"]})]}),o&&t.jsxs(m,{alignItems:"flex-end",spacing:.5,sx:{height:l(56)},children:[t.jsx(ne,{variant:"primaryModern",sx:Ue,disabled:B||i===0,onClick:Xt,children:"Enable assistants"}),i>0&&t.jsxs(I,{variant:"body2",color:e.palette.text.secondary,children:[i," selected"]})]})]}),t.jsx(la,{searchValue:U,showOnlyEnableableAssistants:Z,isUpdating:B,canEnableAll:!B&&f.length>0&&!D,canClearAll:!B&&k.length>0,canEditCampaigns:o,onSearchChange:H,onToggleShowOnlyEnableableAssistants:Oe,onEnableAll:Ht,onClearAll:Qt}),t.jsx(m,{gap:1.5,mt:2,children:fe.map(s=>t.jsx(ra,{assistant:s,campaignChannels:xe,selectedNotEnabledAssistantIds:k,isUpdating:B,canEditCampaigns:o,onToggleSelection:Jt},s.id))}),ae.length>Pe&&t.jsx(m,{direction:"row",justifyContent:"center",mt:2,children:t.jsx(na,{count:W,page:le,onChange:(s,r)=>X(r),disabled:B,shape:"rounded"})})]}),t.jsx(Ve,{isOpen:Q,onClose:at,onCancel:at,title:"Go Live for selected assistants?",confirmText:"Go Live",cancelText:"Cancel",isDisabled:B,onConfirm:qt,children:t.jsx(I,{variant:"body2",color:e.palette.text.secondary,children:"This action will mark selected assistants as live and lock campaign-wide configuration."})}),t.jsx(Ve,{isOpen:q,onClose:()=>h(!1),onCancel:()=>h(!1),title:"Share campaign to enable assistants?",confirmText:"Share and Save",cancelText:"Cancel",onConfirm:ot,children:t.jsx(I,{variant:"body2",color:e.palette.text.secondary,children:"This action cannot be undone. Enabling additional assistants will switch this campaign to shared mode."})}),t.jsx(Ve,{isOpen:!!M,onClose:nt,onCancel:nt,title:"Remove assistant?",confirmText:"Remove",cancelText:"Cancel",isDisabled:B,onConfirm:Vt,children:t.jsxs(m,{spacing:2,useFlexGap:!0,children:[t.jsx(I,{variant:"body2",children:"Are you sure you want to remove this Assistant from the campaign?"}),t.jsxs(I,{variant:"body2",color:e.palette.text.secondary,children:["All the settings for this assistant and the contacts added to the campaign and associated with ",Zt," will be removed."]}),t.jsx(ht,{severity:"warning",children:"After saving, this removes the assistant from this campaign and permanently deletes its campaign contacts and settings. You can add the assistant back later, but previous data will not be restored."})]})})]})}export{Ca as default};
4//# sourceMappingURL=index-BPJ2UTpF.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.