1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3252],{49700:function(e,l,t){t.d(l,{G:function(){return r},Z:function(){return i}});var s=t(57437);t(2265);var n=t(99376),a=t(88214);let r=()=>{let e=(0,n.useParams)(),l=null==e?void 0:e.company;return l?e=>"/".concat(l,"/simulation/detail?campaign_id=").concat(e):null};function i(e){let{events:l}=e,t=r();return(0,s.jsx)(a.Z,{events:l,routes:{campaign:t}})}},38237:function(e,l,t){var s=t(57437);t(2265);var n=t(42858),a=t(27946),r=t(14883);l.Z=e=>{let{drawer:l,children:t,onClose:i,...o}=e,{activeDrawer:d}=(0,n.CG)(e=>e.modals),x=(0,n.TL)();return(0,s.jsx)(r.Z,{open:d===l,onClose:()=>{x((0,a.Am)(null)),null==i||i()},...o,children:t})}},94720:function(e,l,t){var s=t(57437),n=t(36760),a=t.n(n),r=t(47469);t(2265),l.Z=e=>{let{wrapperClassName:l,children:t,...n}=e;return(0,s.jsx)(r.J9,{...n,children:(0,s.jsx)("div",{className:a()(l),children:t})})}},72962:function(e,l,t){var s=t(57437),n=t(47469),a=t(2265),r=t(36760),i=t.n(r),o=t(33145);l.Z=e=>{let{fieldName:l,hideError:t,inputContainer:r,label:d,containerClass:x,withLockIcon:c,...p}=e,{className:u,disabled:m,...g}=p,[f,h]=(0,a.useState)(g.type),{values:v,handleChange:y,errors:j,touched:w,setFieldTouched:N}=(0,n.u6)();return(0,s.jsxs)("div",{className:" ".concat(x||"w-full flex flex-col gap-[4px]"),children:[d?(0,s.jsx)("div",{className:"font-[500] text-[14px] leading-[22px] text-dark-6",children:d}):(0,s.jsx)(s.Fragment,{}),(0,s.jsxs)("div",{className:"w-full relative ".concat(r),children:[c?(0,s.jsx)("div",{className:"absolute left-[12px] top-[11px]",children:(0,s.jsx)(o.default,{src:"/lock.svg",width:"16",height:"16",alt:"lock icon"})}):(0,s.jsx)(s.Fragment,{}),(0,s.jsx)("input",{...g,type:f,disabled:m,value:v[l],onBlur:()=>N(l),onChange:y(l),className:i()("w-full h-[38px] focus:outline-none ".concat(m?"rgba(252, 252, 253, 1) text-gray-5":"bg-gray-1 text-black"," py-[8px] px-[12px] rounded-[4px] text-[14px] leading-[22px] font-[400]"),{"px-[36px]":c},u)}),!t&&(0,s.jsx)("div",{className:"w-full mt-2 font-[400] text-red-6 text-[12px]",children:w[l]&&j[l]}),"password"===g.type?(0,s.jsx)("div",{onClick:()=>{f===g.type?h("text"):h("password")},className:"absolute right-[12px] top-[11px] cursor-pointer",children:(0,s.jsx)(o.default,{src:"/eye.svg",width:"16",height:"16",alt:"lock icon"})}):(0,s.jsx)(s.Fragment,{})]})]})}},99860:function(e,l,t){var s=t(57437),n=t(36760),a=t.n(n);t(2265),l.default=e=>{let{className:l,showText:t=!0}=e;return(0,s.jsxs)("div",{role:"status",children:[(0,s.jsxs)("svg",{"aria-hidden":"true",className:a()("text-gray-200 animate-spin",l),viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),(0,s.jsx)("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]}),t&&(0,s.jsx)("span",{className:"sr-only",children:"Loading..."})]})}},7382:function(e,l,t){var s=t(57437);t(2265);var n=t(36760),a=t.n(n),r=t(42858),i=t(27946);l.Z=e=>{let{children:l,modal:t,onClose:n,preventClose:o,className:d,wrapperClass:x}=e,{activeModal:c}=(0,r.CG)(e=>e.modals),p=(0,r.TL)();return(0,s.jsxs)("div",{className:a()("absolute inset-0 flex justify-center items-center z-30",{hidden:c!==t},o?"backdrop-blur-sm bg-white/30":"",x),children:[(0,s.jsx)("div",{onClick:()=>{o||(p((0,i.dg)(null)),null==n||n())},className:"z-[60] absolute inset-0 bg-[#00000033] animate-overlayIn"}),(0,s.jsx)("div",{className:"z-[70] animate-scaleIn ".concat(d),children:c==t?l:null})]})}},48976:function(e,l,t){t.d(l,{Z:function(){return v}});var s=t(57437),n=t(2265),a=t(49700),r=t(98059),i=t(27946),o=t(42858),d=t(35517),x=t(13911),c=t(62926),p=t(55824),u=t(38237),m=t(43209),g=t(90382),f=t(76512),h=t(95118),v=()=>{let{selectedEmployeeId:e}=(0,o.CG)(e=>e.trainingTargets),l=(0,o.TL)(),t=null!=e?e:"",{profile:v,isLoading:y}=(0,d.$)(t),{employees:j}=(0,x.nx)(),{groups:w}=(0,c.cu)(),{updateEmployee:N}=(0,x.A4)(),{updateEmployeeStatus:b}=(0,x.CR)(),{unlockField:C}=(0,x.f1)(),{addEmployeesToGroup:_}=(0,p.J)(),{removeEmployeesFromGroup:k}=(0,p.a)(),Z=(0,n.useMemo)(()=>null==j?void 0:j.find(e=>
1e.id===t),[j,t]),[L,S]=(0,n.useState)(!1),[E,G]=(0,n.useState)(!1),T=()=>{l((0,i.Am)(null)),l((0,r.Ak)(null)),S(!1)},R=async()=>{if(!Z)return;let e=(0,f.l)(Z);try{for(let l of e.lockedFields)await C({employeeId:Z.id,field:l})}catch(e){(0,g._N)(e,"Failed to revert to directory sync.")}},A=async e=>{if(Z&&!E){G(!0);try{var l;await N(function(e,l){let[t,...s]=l.name.trim().split(/\s+/);return{id:e.id,first_name:t||e.first_name,last_name:s.join(" "),phone:l.phone}}(Z,e)),e.status!==Z.status&&await b({employee_id:Z.id,status:e.status});let t=(null!==(l=Z.group_assignments)&&void 0!==l?l:[]).map(e=>e.group_id),{toAdd:s,toRemove:n}=function(e,l){let t=new Set((null!=e?e:[]).filter(Boolean)),s=new Set((null!=l?l:[]).filter(Boolean));return{toAdd:[...s].filter(e=>!t.has(e)),toRemove:[...t].filter(e=>!s.has(e))}}(t,e.groupIds);for(let e of s)await _({group_id:e,employee_ids:[Z.id]});for(let e of n)await k({group_id:e,employee_ids:[Z.id]});S(!1)}catch(e){(0,g._N)(e,"Failed to save changes.")}finally{G(!1)}}},F=(0,a.G)();return(0,s.jsx)(u.Z,{drawer:m.B5.EmployeeDetail,onClose:T,nonModal:!0,rootClassName:"flex flex-col w-[440px] bg-white",children:Z?(0,s.jsx)(h.ZP,{employee:Z,profile:v,groups:null!=w?w:[],editing:L,busy:E,actions:{onClose:T,onStartEdit:()=>S(!0),onCancelEdit:()=>S(!1),onSave:A,onRevertToSync:R},routes:{close:null,edit:null,cancelEdit:null,campaign:F}}):(0,s.jsx)(h.aU,{message:y?"Loadingâ¦":"Target not found.",onClose:T})})}},91172:function(e,l,t){t.d(l,{Z:function(){return R}});var s=t(57437),n=t(2265),a=t(77398),r=t.n(a),i=t(98059),o=t(27946),d=t(42858),x=t(62926),c=t(49349),p=t(43209),u=t(65239),m=t(65262),g=t(99860),f=t(90382),h=(0,n.forwardRef)((e,l)=>{let{left:t,top:a,group_id:r,onDelete:h,onEdit:v,onClose:y,portalStyle:j,className:w}=e,N=(0,d.TL)(),b=(0,n.useRef)(null),C=l&&"function"!=typeof l?l:b,{deleteGroup:_,isDeletingGroup:k}=(0,x.LF)(),Z=async()=>{try{await _({group_id:r}),null==h||h()}catch(e){(0,f._N)(e)}},L=e=>{var t;null!=l&&null!==(t=l.current)&&void 0!==t&&t.contains(e.target)||!b.current||b.current.contains(e.target)||null==y||y()};return(0,n.useEffect)(()=>(document.addEventListener("mousedown",L),()=>{document.removeEventListener("mousedown",L)}),[]),(0,s.jsxs)(c.Z,{triggerRef:C,panelRef:b,open:!0,align:"right",className:w||"w-[180px] border bg-white border-gray-2 rounded-[10px] p-[4px] flex flex-col shadow-modal",children:[(0,s.jsxs)("div",{onClick:()=>{N((0,i.iB)(r)),N((0,o.dg)(p.nK.GroupForm)),null==v||v()},className:"flex items-center gap-[10px] px-[10px] py-[8px] rounded-[6px] cursor-pointer hover:bg-gray-1 text-[14px] leading-[20px] text-dark-6",children:[(0,s.jsx)(m.Z,{width:16,height:16,color:"#5C6B7F"}),"Edit group"]}),(0,s.jsxs)("div",{onClick:k?void 0:Z,className:"flex items-center gap-[10px] px-[10px] py-[8px] rounded-[6px] cursor-pointer hover:bg-gray-1 text-[14px] leading-[20px] text-red-6",children:[k?(0,s.jsx)(g.default,{className:"w-4 h-4 dark:text-gray-2 fill-red-6"}):(0,s.jsx)(u.Z,{width:16,height:16}),"Delete group"]})]})}),v=t(38237),y=t(36760),j=t.n(y),w=t(33145),N=t(38377),b=t(72040),C=t(83764),_=t(55824),k=e=>{var l,t,a,r,i;let c;let{search:u,setSearch:m}=e,{selectedGroupId:h,searchGroupsText:v}=(0,d.CG)(e=>e.trainingTargets),y=(0,d.TL)(),{groups:k}=(0,x.XY)(!0,v),[Z,L]=(0,n.useState)({}),S=null==k?void 0:k.list.find(e=>{let{id:l}=e;return l===h}),E=!!(null==S?void 0:S.group_synced_from),G=Object.entries(Z).filter(e=>{let[l,t]=e;return t}).length,{isRemoving:T,removeEmployeesFromGroup:R}=(0,_.a)();(0,n.useEffect)(()=>{L({}),m("")},[h]);let A=e=>Z[e]?"/checkbox.svg":"/empty-box.svg",F=e=>()=>{L(l=>({...l,[e]:!l[e]}))},O=async()=>{if(!T)try{await R({employee_ids:Object.entries(Z).filter(e=>{let[l,t]=e;return t}).map(e=>{let[l]=e;return l}),group_id:h}),L({})}catch(e){(0,f._N)(e,"Failed to removed employee from group")}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"w-full flex flex-col h-group-detail-list",children:[(0,s.jsxs)("div",{className:"bg-gray-0 flex flex-row items-center px-[16px] py-[10px] gap-[8px] border-b border-gray-2",children:[!E&&(0,s.jsx)("div",{onClick:(c=(null==S?void 0:null===(l=S.assignments)||void 0===l?void 0:l.map(e=>{let{employee:l}=e;return l.id}))||[],()=>{let e=G===(null==S?void 0:S.assignments.length);L(c.reduce((l,t)=>
1({...l,[t]:!e}),{}))}),className:"cursor-pointer",children:(0,s.jsx)(w.default,{src:0===G?"/empty-box.svg":G!==(null==S?void 0:null===(i=S.assignments)||void 0===i?void 0:i.length)?"/partial-box.svg":"/checkbox.svg",width:16,height:16,alt:""})}),(0,s.jsxs)("div",{className:"font-[600] text-[11px] tracking-[0.04em] leading-[20px] text-gray-5 uppercase",children:["Members \xb7 ",null!==(r=null==S?void 0:null===(t=S.assignments)||void 0===t?void 0:t.length)&&void 0!==r?r:0]})]}),(null==S?void 0:null===(a=S.assignments)||void 0===a?void 0:a.length)?(0,s.jsx)("div",{className:"w-full flex flex-col",children:null==S?void 0:S.assignments.filter(e=>e.employee.email.toLowerCase().includes(u.toLowerCase())||e.employee.first_name.toLowerCase().includes(u.toLowerCase())||(e.employee.last_name||"").toLowerCase().includes(u.toLowerCase())||"".concat(e.employee.first_name," ").concat(e.employee.last_name||"").toLowerCase().includes(u.toLowerCase())).map(e=>(0,s.jsxs)("div",{className:j()("w-full flex flex-row items-center gap-[10px]","py-[10px] px-[16px] border-b-[1px] border-gray-1",E?"cursor-default":"cursor-pointer",{"bg-blue-1":!!Z[e.employee.id]}),onClick:E?void 0:F(e.employee.id),children:[!E&&(0,s.jsx)("div",{className:"cursor-pointer",children:(0,s.jsx)(w.default,{src:A(e.employee.id),width:16,height:16,alt:""})}),(0,s.jsx)(C.Z,{name:"".concat(e.employee.first_name," ").concat(e.employee.last_name||""),size:32}),(0,s.jsxs)("div",{className:"flex flex-col justify-center gap-[2px]",children:[(0,s.jsx)("div",{className:"font-[500] text-[14px] leading-[18px] text-dark-6",children:"".concat(e.employee.first_name," ").concat(e.employee.last_name)}),(0,s.jsx)("div",{className:"font-[400] text-[12px] leading-[14px] text-gray-5",children:e.employee.email})]})]},e.id))}):(0,s.jsxs)("div",{className:"w-full mt-[40px] flex flex-col justify-center items-center gap-[8px]",children:[(0,s.jsx)("div",{className:"font-[600] text-[16px] leading-[24px] text-dark-6",children:"No members found"}),(0,s.jsx)("div",{className:"font-[400] text-[14px] leading-[22px] text-gray-6",children:E?"Membership is managed by your directory.":"Add members to group to use it in your campaign"}),!E&&(0,s.jsx)(b.Z,{onClick:()=>{y((0,o.Am)(null)),y((0,o.dg)(p.nK.GroupForm))},className:"w-[184px]",w:"w-[184px]",LeftIcon:(0,s.jsx)(N.Z,{}),text:"Add Members"})]})]}),(0,s.jsxs)("div",{className:j()("w-full flex flex-row items-center gap-[16px] justify-end p-[16px]",{"border-t-[1px] border-gray-2":!!G}),children:[!!G&&(0,s.jsx)(b.Z,{className:"w-[165px]",w:"w-[165px]",text:"Cancel selection",onClick:()=>L({}),buttonType:"ternary"}),!!G&&(0,s.jsx)(b.Z,{onClick:O,disabled:T,className:"w-fit min-w-[100px] px-[20px]",text:"Remove members",buttonType:"red",LeftIcon:T?(0,s.jsx)(g.default,{className:"w-4 h-4 fill-blue-6"}):void 0})]})]})},Z=t(20762),L=t(3034),S=t(96259),E=t(88258),G=t(36214),T=t(81209),R=()=>{let{selectedGroupId:e}=(0,d.CG)(e=>e.trainingTargets),{activeDrawer:l}=(0,d.CG)(e=>e.modals),{groups:t}=(0,x.XY)(l===p.B5.GroupDetail),[a,c]=(0,n.useState)(""),[u,m]=(0,n.useState)(!1),g=(0,d.TL)(),f=(0,n.useRef)(null),y=(0,n.useRef)(null),j=null==t?void 0:t.list.find(l=>{let{id:t}=l;return t===e}),w=(0,T.ug)(j),N=T.mS[w],b="synced"===w,C=()=>{g((0,o.Am)(null)),g((0,i.iB)(null))};return(0,s.jsxs)(v.Z,{drawer:p.B5.GroupDetail,onClose:C,nonModal:!0,rootClassName:"flex flex-col gap-[16px] w-[500px] bg-white",children:[(0,s.jsxs)("div",{className:"flex flex-row gap-[6px] h-[60px] items-center px-[20px] py-[16px] border-b-[1px] border-gray-2",children:[(0,s.jsx)("div",{className:"cursor-pointer",onClick:C,children:(0,s.jsx)(L.Z,{})}),(0,s.jsx)("div",{className:"font-[600] text-[20px] leading-[26px] text-dark-6 ",children:"Group details"})]}),(0,s.jsxs)("div",{ref:y,className:"flex flex-col gap-[14px] px-[16px] py-[16px] w-full",children:[(0,s.jsxs)("div",{className:"flex flex-row items-center gap-[12px]",children:[(0,s.jsxs)("span",{className:"relative flex-none w-[44px] h-[44px] rounded-[11px] flex items-center justify-center ".concat(N.tileClassName),children:[(0,s.jsx)(S.Z,{width:21,height:21}),b&&(0,s.jsx)("span",{className:"absolute -right-[4px] -bottom-[4px] w-[18px] h-[18px] rounded-full bg-white border border-gray-2 flex items-center justify-center text-indigo-6",children:(0,s.jsx)(E.Z,{width:11,height:11})})]}),(0,s.jsxs)("div",{className:"flex flex-col justify-center gap-[2px] flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"font-[700] text-[17px] leading-[24px] text-dark-6 truncate",children:null==j?void 0:j.name}),(0,s.jsxs)("div",{className:"font-[400] text-[12px] leading-[18px] text-gray-5",children:[N.description," \xb7 Created"," ",r()(null==j?void 0:j.created_at).format("DD/MM/YY")]})]}),(0,s.jsxs)("div",{className:"relative ml-auto",children:[(0,s.jsx)("div",{onClick:()=>m(e=>!e),ref:f,className:"ml-auto cursor-pointer",children:(0,s.jsx)(G.Z,{color:"#141517"})}),u&&(0,s.jsx)(h,{className:"w-[180px] border bg-white border-gray-2 rounded-[10px] p-[4px] flex flex-col shadow-modal",onClose:()=>{m(!1)},group_id:e,portalStyle:{left:"".concat(f.current.getBoundingClientRect().left-196,"px"),top:"".concat(f.current.getBoundingClientRect().top,"px")}
1,left:f.current.getBoundingClientRect().left,top:f.current.getBoundingClientRect().top,ref:f,onEdit:()=>{g((0,o.Am)(null)),m(!1)}})]})]}),b&&(0,s.jsxs)("div",{className:"flex items-center gap-[8px] px-[12px] py-[10px] rounded-[8px] bg-indigo-1",children:[(0,s.jsx)("span",{className:"flex-none text-indigo-6",children:(0,s.jsx)(E.Z,{width:15,height:15})}),(0,s.jsx)("span",{className:"text-[12px] leading-[16px] text-gray-7",children:"Membership is managed by your directory. Changes sync automatically."})]})]}),(0,s.jsx)("div",{className:"px-[16px] w-full h-[38px]",children:(0,s.jsx)(Z.Z,{wrapperClassName:"!h-[38px] overflow-hidden",inputClassName:"!font-[400] !text-[14px] !pl-[38px] !h-[38px] w-full",iconHeight:16,iconWidth:16,iconColor:"#141517",placeholder:"Search employees",value:a,onChange:e=>c(e)})}),(0,s.jsx)(k,{search:a,setSearch:c})]})}},35517:function(e,l,t){t.d(l,{$:function(){return o}});var s=t(71632),n=t(64906),a=t(82003);let r=async(e,l)=>{let{data:t}=await n.default.get("/api/people/".concat(e,"/profile"),{headers:{token:(0,a.LP)(),tenant:l}});return t};var i=t(42858);let o=e=>{let{active_tenant:l}=(0,i.CG)(e=>e.app),{data:t,isFetching:n}=(0,s.useQuery)({queryKey:["employeeProfile",e,l],queryFn:()=>r(e,l||""),enabled:!!e&&!!l,refetchOnMount:"always"});return{profile:t,isLoading:n}}},56639:function(e,l,t){var s;(s||(s={})).STORE_TOKEN="STORE_TOKEN",t(42858),t(21961),t(27946)},14772:function(e,l,t){var s=t(57437);t(2265),l.default=e=>{let{color:l="#5B6B86",height:t=16,width:n=16}=e;return(0,s.jsx)("svg",{width:n,height:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.52851 3.52876C3.78886 3.26841 4.21097 3.26841 4.47132 3.52876L7.99992 7.05735L11.5285 3.52876C11.7889 3.26841 12.211 3.26841 12.4713 3.52876C12.7317 3.78911 12.7317 4.21122 12.4713 4.47157L8.94273 8.00016L12.4713 11.5288C12.7317 11.7891 12.7317 12.2112 12.4713 12.4716C12.211 12.7319 11.7889 12.7319 11.5285 12.4716L7.99992 8.94297L4.47132 12.4716C4.21097 12.7319 3.78886 12.7319 3.52851 12.4716C3.26816 12.2112 3.26816 11.7891 3.52851 11.5288L7.05711 8.00016L3.52851 4.47157C3.26816 4.21122 3.26816 3.78911 3.52851 3.52876Z",fill:l})})}},38377:function(e,l,t){var s=t(57437);t(2265),l.Z=e=>{let{color:l="white",height:t=20,width:n=20}=e;return(0,s.jsx)("svg",{width:n,height:t,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.99992 3.33325C10.4602 3.33325 10.8333 3.70635 10.8333 4.16659V9.16658H15.8333C16.2935 9.16658 16.6666 9.53968 16.6666 9.99992C16.6666 10.4602 16.2935 10.8333 15.8333 10.8333H10.8333V15.8333C10.8333 16.2935 10.4602 16.6666 9.99992 16.6666C9.53968 16.6666 9.16658 16.2935 9.16658 15.8333V10.8333H4.16659C3.70635 10.8333 3.33325 10.4602 3.33325 9.99992C3.33325 9.53968 3.70635 9.16658 4.16659 9.16658H9.16658V4.16659C9.16658 3.70635 9.53968 3.33325 9.99992 3.33325Z",fill:l})})}},95505:function(e,l,t){t.d(l,{Z:function(){return K}});var s=t(57437),n=t(2265),a=t(98059),r=t(27946),i=t(42858),o=t(7382),d=t(43209),x=t(62926),c=t(14772),p=t(96259),u=t(72962),m=t(94720),g=t(90382),f=t(47469),h=t(99860),v=t(72040),y=e=>{let{isLoading:l}=e,{selectedGroupId:t}=(0,i.CG)(e=>e.trainingTargets),{handleSubmit:n}=(0,f.u6)();return(0,s.jsx)(v.Z,{onClick:()=>n(),disabled:l,className:"w-fit px-4 min-w-[160px]",text:"".concat(t?"Update":"Create"," Group"),LeftIcon:l?(0,s.jsx)(h.default,{className:"w-4 h-4 dark:text-gray-2 fill-blue-6"}):void 0})},j=t(33145),w=t(13911),N=t(20762),b=t(93382),C=t(41301),_=t(55824),k=t(36760),Z=t.n(k),L=t(83764),S=e=>{var l,t;let{employee:n,handleSelect:a,selectedGroupId:r,groupsDetail:i}=e,{values:o}=(0,f.u6)(),d=o.members,x=e=>{let{groupAssignments:l}=e;return!!l.find(e=>e.group_id===r)},c=d.includes(n.id)||x({groupAssignments:n.group_assignments});return(0,s.jsxs)("div",{className:Z()("flex flex-row items-center px-[16px] py-[10px] gap-[12px] cursor-pointer",{"bg-blue-1":c}),onClick:()=>a(n.id),children:[(0,s.jsx)("div",{className:"flex items-center",children:(0,s.jsx)(j.default,{src:(l=n.id,t=n.group_assignments,d.includes(l)||x({groupAssignments:t})?"/checkbox.svg":"/empty-box.svg"),width:18,height:18,alt:""})}),(0,s.jsx)(L.Z,{name:"".concat(n.first_name," ").concat(n.last_name||""),size:30}),(0,s.jsxs)("div",{className:"flex flex-col gap-[2px] min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"font-[500] text-[14px] leading-[18px] text-dark-6 truncate",children:[n.first_name," ",n.last_name]}),(0,s.jsx)("div",{className:"font-[400] text-[12px] leading-[14px] text-gray-5 truncate",children:n.email})]}),(e=>{let{groupAssigment:l}=e,t=[];return l.map(e=>{var l;t.push({id:e.group_id,name:(null===(l=i[e.group_id])||void 0===l?void 0:l.name)||""})}),t})({groupAssigment:n.group_assignments}).slice(0,1).map(e=>(0,s.jsx)("span",{className:"flex-none rounded-full bg-gray-1 px-[8px] py-[2px] text-[11px] font-[500] text-gray-6",children:e.name},e.id))]},n.id)},E=e=>{let{selectedGroupId:l,selectedGroupProvider:t}
1=e,[a,r]=(0,n.useState)(!1),{groupsDetail:i}=(0,x.cu)(),[o,c]=(0,n.useState)(""),{employees:p}=(0,w.OL)(o,!0,d.LE.Active),{removeEmployeesFromGroup:u,isRemoving:m}=(0,_.a)(),{setFieldValue:g,values:h}=(0,f.u6)(),v=h.members,y=v.length,k=(0,n.useMemo)(()=>t?null==p?void 0:p.employees.filter(e=>e.sync_from===t):null==p?void 0:p.employees,[t,p]),Z=e=>{let{groupAssignments:t}=e;return!!t.find(e=>e.group_id===l)},L=async e=>{if(!k)return;let t=k.find(l=>l.id===e);if(t&&Z({groupAssignments:t.group_assignments})){g("members",[...v.filter(l=>l===e)]);try{await u({group_id:l,employee_ids:[e]})}catch(l){g("members",[...v,e])}}else v.includes(e)?g("members",[...v.filter(l=>l!==e)]):g("members",[...v,e])};return(0,s.jsxs)("div",{className:"w-full flex flex-col gap-[16px]",children:[(0,s.jsxs)("div",{onClick:()=>r(e=>!e),className:"cursor-pointer flex flex-row gap-[8px] w-[149px] h-[32px] justify-center items-center",children:[(0,s.jsx)("div",{className:"font-[400] text-[14px] leading-[22px] text-blue-6",children:"Add members"}),a?(0,s.jsx)(C.Z,{color:"#5A87F8"}):(0,s.jsx)(b.Z,{color:"#5A87F8"})]}),a&&(0,s.jsx)("div",{className:"w-full px-[16px]",children:(0,s.jsx)(N.Z,{wrapperClassName:"!h-[38px] overflow-hidden",inputClassName:"!font-[400] !text-[14px] !pl-[38px] !h-[38px] w-full",iconHeight:16,iconWidth:16,iconColor:"#141517",placeholder:"Search employees",value:o||"",disabled:m,onChange:e=>c(e)})}),a&&(0,s.jsxs)("div",{className:"w-full flex flex-col max-h-[290px]",children:[(0,s.jsxs)("div",{className:"flex flex-row items-center w-full bg-gray-0 border-y border-gray-2 gap-[8px] py-[10px] px-[16px]",children:[(0,s.jsx)(j.default,{src:0===y?"/empty-box.svg":y!==(null==k?void 0:k.length)?"/partial-box.svg":"/checkbox.svg",width:18,height:18,alt:""}),(0,s.jsxs)("div",{className:"font-[600] text-[12px] leading-[20px] text-gray-6",children:[y," ",1===y?"employee":"employees"," ","selected"]})]}),(0,s.jsx)("div",{className:"flex flex-col w-full max-h-[250px] overflow-auto",children:null==k?void 0:k.map(e=>(0,s.jsx)(S,{groupsDetail:i,employee:e,handleSelect:L,selectedGroupId:l},e.id))})]})]})},G=t(88258);let T=()=>{var e,l;let{values:t}=(0,f.u6)(),n=null!==(l=null===(e=t.members)||void 0===e?void 0:e.length)&&void 0!==l?l:0;return(0,s.jsx)("span",{className:"text-[13px] text-gray-5",children:n>0?"".concat(n," member").concat(n>1?"s":""):"No members yet"})};var R=e=>{let{groupToUpdate:l,selectedGroupId:t}=e,n=(0,i.TL)(),{updateGroup:o,isUpdatingGroup:d}=(0,x.Sc)(),{addEmployeesToGroup:c,isAdding:p}=(0,_.J)(),f=()=>{n((0,r.dg)(null)),n((0,a.iB)(null))},h=async(e,s)=>{try{e.groupName&&e.groupName!==(null==l?void 0:l.name)&&await o({id:t,name:e.groupName});let n=e.members;await c({group_id:t,employee_ids:n}),s.resetForm(),f()}catch(e){(0,g._N)(e)}},j=async(e,l)=>h(e,l);return(0,s.jsxs)(m.Z,{initialValues:{groupName:(null==l?void 0:l.name)||"",members:[]},onSubmit:j,enableReinitialize:!0,wrapperClassName:"w-full flex flex-col gap-[16px]",children:[(0,s.jsx)("div",{className:"flex flex-col gap-[16px] w-full py-[24px] px-[24px]",children:l.group_synced_from?(0,s.jsxs)("div",{className:"flex flex-col gap-[5px]",children:[(0,s.jsx)("div",{className:"font-[500] text-[13px] text-dark-6",children:"Group name"}),(0,s.jsxs)("div",{className:"flex items-center gap-[8px] h-[38px] px-[12px] rounded-[4px] bg-gray-0 border border-gray-2 text-gray-6 text-[14px]",children:[(0,s.jsx)("span",{className:"flex-1 truncate",children:l.name}),(0,s.jsxs)("span",{className:"inline-flex items-center gap-[5px] text-[11px] font-[500] text-indigo-6",children:[(0,s.jsx)(G.Z,{width:13,height:13}),"Synced"]})]}),(0,s.jsx)("span",{className:"text-[12px] text-gray-5",children:"The name is managed by your directory and cannot be changed here."})]}):(0,s.jsx)(u.Z,{fieldName:"groupName",placeholder:"Enter group name",label:"Group name"})}),(0,s.jsx)(E,{selectedGroupId:t,selectedGroupProvider:l.group_synced_from}),(0,s.jsxs)("div",{className:"flex flex-row items-center justify-between h-[72px] px-[24px] gap-[16px] border-t-[1px] border-gray-2 bg-gray-0",children:[(0,s.jsx)(T,{}),(0,s.jsxs)("div",{className:"flex flex-row items-center gap-[12px]",children:[(0,s.jsx)(v.Z,{onClick:f,className:"w-fit px-4",buttonType:"ternary",text:"Cancel"}),(0,s.jsx)(y,{isLoading:p||d})]})]})]})},A=t(81209),F=()=>{var e;let{selectedGroupId:l,searchGroupsText:t}=(0,i.CG)(e=>e.trainingTargets),{activeModal:n}=(0,i.CG)(e=>e.modals),o=(0,i.TL)(),{groups:u}=(0,x.XY)(n===d.nK.GroupForm,t),m=null==u?void 0:null===(e=u.list)||void 0===e?void 0:e.find(e=>e.id===l),g=(0,A.ug)(m),f=A.mS[g];return(0,s.jsxs)("div",{className:"relative bg-white w-[500px] max-w-full rounded-[14px] overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex flex-row items-center gap-[12px] px-[24px] py-[20px] border-b border-gray-2",children:[(0,s.jsx)("span",{className:"flex-none w-[38px] h-[38px] rounded-[10px] flex items-center justify-center ".concat(f.tileClassName),children:(0,s.jsx)(p.Z,{width:19,height:19})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("div",{className:"font-[700] text-[17px] leading-[24px] text-dark-6",children:"Edit group"}),(0,s.jsx)("div",{className:"font-[400] text-[13px] leading-[18px] text-gray-6",children:"synced"===g?"Synced group: add or remove members manually.":"Update the group name and members."})]}),(0,s.jsx)("div",{onClick:()=>{o((0,r.dg)(null)),(null==m?void 0:m.id)&&o((0,a.iB)(null))},className:"cursor-pointer text-gray-5",children:(0,s.jsx)(c.default,{})})]}),(0,s.jsx)("div",{className:"w-full flex flex-col gap-[16px]",children:m&&l&&(0,s.jsx)(R,{groupToUpdate:m,selectedGroupId:l})})]})},O=e=>{var l;let{employee:t,handleSelect:n,groupsDetail:a}=e,{values:r}=(0,f.u6)(),i=r.members,o=i.includes(t.id);return(0,s.jsx)("div",{className:Z()("flex flex-row px-[16px] py-[8px] gap-[8px] curs
1or-pointer",{"bg-blue-1":o}),onClick:()=>n(t.id),children:(0,s.jsxs)("div",{className:"flex flex-row items-center gap-[12px] w-full",children:[(0,s.jsx)("div",{className:"flex items-center",children:(0,s.jsx)(j.default,{src:(l=t.id,i.includes(l)?"/checkbox.svg":"/empty-box.svg"),width:18,height:18,alt:""})}),(0,s.jsx)(L.Z,{name:"".concat(t.first_name," ").concat(t.last_name||""),size:30}),(0,s.jsxs)("div",{className:"flex flex-col gap-[2px] min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"font-[500] text-[14px] leading-[18px] text-dark-6 truncate",children:[t.first_name," ",t.last_name]}),(0,s.jsx)("div",{className:"font-[400] text-[12px] leading-[14px] text-gray-5 truncate",children:t.email})]}),(e=>{let{groupAssigment:l}=e,t=[];return l.map(e=>{var l;t.push({id:e.group_id,name:(null===(l=a[e.group_id])||void 0===l?void 0:l.name)||""})}),t})({groupAssigment:t.group_assignments}).slice(0,1).map(e=>(0,s.jsx)("span",{className:"flex-none rounded-full bg-gray-1 px-[8px] py-[2px] text-[11px] font-[500] text-gray-6",children:e.name},e.id))]})},t.id)},B=()=>{let[e,l]=(0,n.useState)(!1),{groupsDetail:t}=(0,x.cu)(),[a,r]=(0,n.useState)(""),{employees:i}=(0,w.OL)(a,!0,d.LE.Active),{setFieldValue:o,values:c}=(0,f.u6)(),p=c.members,u=p.length,m=async e=>{p.includes(e)?o("members",[...p.filter(l=>l!==e)]):o("members",[...p,e])};return(0,s.jsxs)("div",{className:"w-full flex flex-col gap-[16px]",children:[(0,s.jsxs)("div",{onClick:()=>l(e=>!e),className:"cursor-pointer flex flex-row gap-[8px] w-[149px] h-[32px] justify-center items-center",children:[(0,s.jsx)("div",{className:"font-[400] text-[14px] leading-[22px] text-blue-6",children:"Add members"}),e?(0,s.jsx)(C.Z,{color:"#5A87F8"}):(0,s.jsx)(b.Z,{color:"#5A87F8"})]}),e&&(0,s.jsx)("div",{className:"w-full px-[16px]",children:(0,s.jsx)(N.Z,{wrapperClassName:"!h-[38px] overflow-hidden",inputClassName:"!font-[400] !text-[14px] !pl-[38px] !h-[38px] w-full",iconHeight:16,iconWidth:16,iconColor:"#141517",placeholder:"Search employees",value:a||"",onChange:e=>r(e)})}),e&&(0,s.jsxs)("div",{className:"w-full flex flex-col max-h-[290px]",children:[(0,s.jsxs)("div",{className:"flex flex-row items-center w-full bg-gray-0 border-y border-gray-2 gap-[8px] py-[10px] px-[16px]",children:[(0,s.jsx)(j.default,{src:0===u?"/empty-box.svg":u!==(null==i?void 0:i.employees.length)?"/partial-box.svg":"/checkbox.svg",width:18,height:18,alt:""}),(0,s.jsxs)("div",{className:"font-[600] text-[12px] leading-[20px] text-gray-6",children:[u," ",1===u?"employee":"employees"," ","selected"]})]}),(0,s.jsx)("div",{className:"flex flex-col w-full max-h-[250px] overflow-auto",children:null==i?void 0:i.employees.map(e=>(0,s.jsx)(O,{groupsDetail:t,employee:e,handleSelect:m},e.id))})]})]})};let I=()=>{var e,l;let{values:t}=(0,f.u6)(),n=null!==(l=null===(e=t.members)||void 0===e?void 0:e.length)&&void 0!==l?l:0;return(0,s.jsx)("span",{className:"text-[13px] text-gray-5",children:n>0?"".concat(n," member").concat(n>1?"s":""):"No members yet"})};var M=()=>{let e=(0,i.TL)(),{createGroup:l,isCreatingGroup:t}=(0,x.lt)(),{addEmployeesToGroup:n,isAdding:a}=(0,_.J)(),o=()=>{e((0,r.dg)(null))},d=async(e,t)=>{try{let s=await l({name:e.groupName}),a=e.members;await n({group_id:s.id,employee_ids:a}),t.resetForm(),o()}catch(e){(0,g._N)(e)}},c=async(e,l)=>d(e,l);return(0,s.jsxs)(m.Z,{initialValues:{groupName:"",members:[]},onSubmit:c,enableReinitialize:!0,wrapperClassName:"w-full flex flex-col gap-[16px]",children:[(0,s.jsx)("div",{className:"flex flex-col gap-[16px] w-full py-[24px] px-[16px]",children:(0,s.jsx)(u.Z,{fieldName:"groupName",placeholder:"Enter group name",label:"Group name"})}),(0,s.jsx)(B,{}),(0,s.jsxs)("div",{className:"flex flex-row items-center justify-between h-[72px] px-[24px] gap-[16px] border-t-[1px] border-gray-2 bg-gray-0",children:[(0,s.jsx)(I,{}),(0,s.jsxs)("div",{className:"flex flex-row items-center gap-[12px]",children:[(0,s.jsx)(v.Z,{onClick:o,className:"w-fit px-4",buttonType:"ternary",text:"Cancel"}),(0,s.jsx)(y,{isLoading:a||t})]})]})]})},D=()=>{var e;let{selectedGroupId:l,searchGroupsText:t}=(0,i.CG)(e=>e.trainingTargets),{activeModal:n}=(0,i.CG)(e=>e.modals),o=(0,i.TL)(),{groups:u}=(0,x.XY)(n===d.nK.GroupForm,t),m=null==u?void 0:null===(e=u.list)||void 0===e?void 0:e.find(e=>e.id===l);return(0,s.jsxs)("div",{className:"relative bg-white w-[500px] max-w-full rounded-[14px] overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex flex-row items-center gap-[12px] px-[24px] py-[20px] border-b border-gray-2",children:[(0,s.jsx)("span",{className:"flex-none w-[38px] h-[38px] rounded-[10px] bg-blue-1 text-blue-7 flex items-center justify-center",children:(0,s.jsx)(p.Z,{width:19,height:19})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("div",{className:"font-[700] text-[17px] leading-[24px] text-dark-6",children:"New group"}),(0,s.jsx)("div",{className:"font-[400] text-[13px] leading-[18px] text-gray-6",children:"Create a group and add employees to it."})]}),(0,s.jsx)("div",{onClick:()=>{o((0,r.dg)(null)),(null==m?void 0:m.id)&&o((0,a.iB)(null))},className:"cursor-pointer text-gray-5",children:(0,s.jsx)(c.default,{})})]}),(0,s.jsx)("div",{className:"w-full flex flex-col gap-[16px]",children:(0,s.jsx)(M,{})})]})},K=()=>{let{selectedGroupId:e}=(0,i.CG)(e=>e.trainingTargets),l=(0,i.TL)();return(0,s.jsxs)(o.Z,{modal:d.nK.GroupForm,onClose:()=>{l((0,r.dg)(null)),l((0,a.iB)(null))},children:[e?(0,s.jsx)(F,{}):null,e?null:(0,s.jsx)(D,{})]})}},55824:function(e,l,t){t.d(l,{J:function(){return x},a:function(){return c}});var s=t(42858),n=t(29827),a=t(21770),r=t(82003),i=t(64906);let o=async(e,l)=>{let{data:t}=await i.default.post("/api/employee_group_assignment/add-employees-to-group",e,{headers:{token:(0,r.LP)(),tenant:l}});return t},d=async(e,l)=>{let{data:t}=await i.default.post("/api/employee_group_assignment/remove-employees-from-group",e,{headers:{token:(0,r.LP)(),tenant:l}});return t},x=()=>{let{active_tenant:e}=(0,s.CG)(e=>e.app),l=(0,n.useQueryClient)(),{mutateAsync:t,isPending:r}=(0,a.useMutation)({mutationFn:l=>o(l,e||""),onSuccess:()=>
1{l.invalidateQueries({predicate:e=>{let{queryKey:l}=e;return l.includes("groups")||l.includes("groupsAll")||l.includes("allEmployees")||l.includes("employees")||l.includes("training_campaigns")||l.includes("training_campaign_detail")||l.includes("campaigns")||l.includes("campaign")}})}});return{addEmployeesToGroup:t,isAdding:r}},c=()=>{let{active_tenant:e}=(0,s.CG)(e=>e.app),l=(0,n.useQueryClient)(),{mutateAsync:t,isPending:r}=(0,a.useMutation)({mutationFn:l=>d(l,e||""),onSuccess:()=>{l.invalidateQueries({predicate:e=>{let{queryKey:l}=e;return l.includes("groups")||l.includes("groupsAll")||l.includes("allEmployees")||l.includes("employees")||l.includes("training_campaigns")||l.includes("training_campaign_detail")||l.includes("campaigns")||l.includes("campaign")}})}});return{removeEmployeesFromGroup:t,isRemoving:r}}},36777:function(e,l,t){var s,n,a,r;t.d(l,{g:function(){return s},h:function(){return n}}),(a=s||(s={})).GOOGLE="GOOGLE",a.MICROSOFT="MICROSOFT",a.SLACK="SLACK",a.OKTA="OKTA",(r=n||(n={})).NOT_SYNCED="NOT_SYNCED",r.RE_SYNC_REQUIRED="RE_SYNC_REQUIRED",r.CONFIGURATION_
1SETUP_REQUIRED="CONFIGURATION_SETUP_REQUIRED",r.SYNCED="SYNCED"},38389:function(e,l,t){t.d(l,{C:function(){return d}});var s=t(57437),n=t(27648),a=t(2265);let r=e=>e.startsWith("/")&&!e.startsWith("//"),i=/^(https?:|mailto:|tel:)/i,o=(0,a.createContext)(e=>{let{href:l,children:t,...a}=e,o="_blank"===a.target?"noopener noreferrer":a.rel;return r(l)?(0,s.jsx)(n.default,{href:l,...a,rel:o,children:t}):i.test(l.trim())&&l.trim()===l?(0,s.jsx)("a",{href:l,...a,rel:o,children:t}):(0,s.jsx)("span",{className:a.className,title:a.title,children:t})}),d=e=>{let{component:l,children:t}=e;return(0,s.jsx)(o.Provider,{value:l,children:t})};l.Z=e=>{let l=(0,a.useContext)(o);return(0,s.jsx)(l,{...e})}}}]);
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.