1(self.webpackChunktrustlane=self.webpackChunktrustlane||[]).push([[5024],{6173:(e,t,i)=>{"use strict";i.d(t,{A:()=>l});var s=i(7119),a=(i(9950),i(4414));const l=e=>{let{visible:t,position:i,children:l}=e;return t?(0,s.createPortal)((0,a.jsx)("div",{className:"treemap-tooltip",style:{position:"fixed",top:i.top,left:i.left,zIndex:9999},children:l}),document.body):null}},5260:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>Me});var s=i(9950),a=i(3564),l=i(4942),n=i(9449),r=i(8341),o=i(2283),c=i(4821);var d=i(2527),u=i(9359);const h=e=>[{value:1,label:e("daily")},{value:7,label:e("weekly")},{value:30,label:e("monthly")},{value:90,label:e("quarterly")},{value:365,label:e("yearly")}];function p(e,t){const i=h(t).find((t=>t.value===e));return i?i.label:null}const m="quantitative",v="numeric",x="percentage",g=(e,t)=>({[m]:[{value:"#",label:"#",description:"Number count (e.g., 5 of 10 tasks)"}],[v]:[{value:"#",label:"#"},{value:"hours",label:t("unitNumericHours"),description:"Time measurement in hours"},{value:"days",label:t("unitNumericDays"),description:"Time measurement in days"}],[x]:[{value:"%",label:"%",description:"Percentage value (e.g., 75%)"}]}[e]||[]),k="off_track",j="at_risk",f="on_track",y={[m]:"#",[x]:"%"},N={REQUIRED:"Unit is required",SELECT_KPI_TYPE_FIRST:"Please select KPI Type first",QUANTITATIVE_INVALID:'Unit must be "#" for Quantitative KPIs',NUMERIC_INVALID:'Unit must be "#" or hours" or "days" for Numeric KPIs',PERCENTAGE_INVALID:'Unit must be "%" for Percentage KPIs'},b=(e,t)=>g(e,t);const _={kpiTitle:"name",kpiDescription:"description",chart_type:"chart_type",kpiType:"type",kpiDeviationType:"deviation_type",maxValue:"max_value",unit:"unit",frequency:"frequency",target:"target",warnThreshold:"warn_threshold",criticalThreshold:"critical_threshold",owners:"owners",soas:"soas",policies:"policies",assets:"assets",incidents:"incidents",risks:"risks"};const T=e=>e&&"object"===typeof e?Object.entries(e).map((e=>{let[t,i]=e;return{id:parseInt(t,10),name:i.name,image:i.image,checked:i.checked}})):[],w=(e,t,i)=>{const s=(e=>({kpiTitle:{required:e?e("validationErrors.kpiTitleRequired"):"KPI Title is required",minLength:{value:3,message:e?e("validationErrors.kpiTitleMinLength"):"KPI Title must be at least 3 characters long"},maxLength:{value:100,message:e?e("validationErrors.kpiTitleMaxLength"):"KPI Title cannot exceed 100 characters"}},kpiDescription:{required:e?e("validationErrors.kpiDescriptionRequired"):"KPI Description is required",minLength:{value:3,message:e?e("validationErrors.kpiDescriptionMinLength"):"KPI Description must be at least 3 characters long"},maxLength:{value:2500,message:e?e("validationErrors.kpiDescriptionMaxLength"):"KPI Description cannot exceed 1000 characters"}},kpiType:{required:e?e("validationErrors.kpiTypeRequired"):"KPI Type is required"},chartType:{required:e?e("validationErrors.chartTypeRequired"):"Chart Type is required"},unit:{required:e?e("validationErrors.unitRequired"):"Unit is required"},target:{required:e?e("validationErrors.targetRequired"):"Target is required",min:{value:0,message:e?e("validationErrors.targetPositive"):"Target must be a positive number"},valueAsNumber:!0},maxValue:{min:{value:0,message:e?e("validationErrors.maxValuePositive"):"Max Value must be a positive number"},valueAsNumber:!0},warnThreshold:{required:e?e("validationErrors.warningThresholdRequired"):"Warning Threshold is required",min:{value:0,message:e?e("validationErrors.warningThresholdPositive"):"Warning Threshold must be a positive number"},valueAsNumber:!0},criticalThreshold:{required:e?e("validationErrors.criticalThresholdRequired"):"Critical Threshold is required",min:{value:0,message:e?e("validationErrors.criticalThresholdPositive"):"Critical Threshold must be a positive number"},valueAsNumber:!0},currentAchieved:{min:{value:0,message:e?e("validationErrors.currentAchievedPositive"):"Current achieved must be a positive number"},valueAsNumber:!0},currentTotal:{min:{value:0,message:e?e("validationErrors.currentTotalPositive"):"Current total must be a positive number"},valueAsNumber:!0}}))(i)[e]||{},a=(e=>({maxValue:(t,i)=>!(i.kpiDeviationType&&"lower_is_better"!==i.kpiDeviationType&&!t)||(e?e("validationErrors.maxValueRequiredWhenNotLowerBetter"):"Max Value is required when deviation type is not Lower is Better."),target:(t,i)=>{if(!t)return!0;
1if(i.maxValue&&t>i.maxValue)return e?e("validationErrors.targetCannotExceedMaxValue"):"Target cannot exceed the Max Value.";if("higher_is_better"===i.kpiDeviationType){if(i.warnThreshold&&t<i.warnThreshold)return e?e("validationErrors.targetCannotBeLowerThanWarningThresholdHigherBetter"):"Target cannot be lower than Warning Threshold when Higher is Better is selected.";if(i.criticalThreshold&&t<i.criticalThreshold)return e?e("validationErrors.targetCannotBeLowerThanCriticalThresholdHigherBetter"):"Target cannot be lower than Critical Threshold when Higher is Better is selected."}if("lower_is_better"===i.kpiDeviationType){if(i.warnThreshold&&t>i.warnThreshold)return e?e("validationErrors.targetCannotBeHigherThanWarningThresholdLowerBetter"):"Target cannot be higher than Warning Threshold when Lower is Better is selected.";if(i.criticalThreshold&&t>i.criticalThreshold)return e?e("validationErrors.targetCannotBeHigherThanCriticalThresholdLowerBetter"):"Target cannot be higher than Critical Threshold when Lower is Better is selected."}return!0},currentAchieved:(t,i)=>void 0===t||null===t||""===t||(("percentage"===i.kpiType||"numeric"===i.kpiType)&&"higher_is_better"===i.kpiDeviationType&&t>i.maxValue?e?e("validationErrors.currentAchievedCannotExceedMaxValue"):"Current Achieved cannot exceed Max Value":!("quantitative"===i.kpiType&&i.currentTotal&&t>i.currentTotal)||(e?e("validationErrors.currentAchievedCannotExceedCurrentTotal"):"Current Achieved cannot exceed Current Total. Please adjust the Current Total first.")),currentTotal:(e,t)=>!0,warnThreshold:(t,i)=>!t||(i.target&&"lower_is_better"===i.kpiDeviationType&&t<i.target?e?e("validationErrors.warningThresholdCannotBeLowerThanTargetLowerBetter"):"Warning Threshold must not be lower than the Target when Lower is Better is selected.":!(i.target&&"higher_is_better"===i.kpiDeviationType&&t>i.target)||(e?e("validationErrors.warningThresholdCannotBeHigherThanTargetHigherBetter"):"Warning Threshold cannot be higher than the Target when Higher is Better is selected.")),criticalThreshold:(t,i)=>{if(!t)return!0;if(i.target&&"lower_is_better"===i.kpiDeviationType){if(t<i.target)return e?e("validationErrors.criticalThresholdCannotBeLowerThanTargetLowerBetter"):"Critical Threshold must not be lower than the Target when Lower is Better is selected.";if(i.warnThreshold&&t<=i.warnThreshold)return e?e("validationErrors.criticalThresholdMustBeGreaterThanWarningThresholdLowerBetter"):"Critical Threshold must be greater than Warning Threshold when Lower is Better is selected."}if(i.target&&"higher_is_better"===i.kpiDeviationType){if(t>i.target)return e?e("validationErrors.criticalThresholdCannotBeHigherThanTargetHigherBetter"):"Critical Threshold cannot be higher than the Target when Higher is Better is selected.";if(i.warnThreshold&&t>i.warnThreshold)return e?e("validationErrors.criticalThresholdCannotBeHigherThanWarningThresholdHigherBetter"):"Critical Threshold cannot be higher than Warning Threshold when Higher is Better is selected."}return!0}}))(i)[e];return a?{...s,validate:e=>a(e,t())}:s};var D=i(3079),I=i(637),A=i(4583),F=i(4476),C=i(8881),L=i(8738),S=i.n(L),P=i(4414);const E=(0,s.forwardRef)(((e,t)=>{var i,l,p,L,E;let{mode:M,kpiId:R,kpiDashboardData:B,action:q,t:V}=e;const H=(e=>[{value:"gauge",label:e("gauge"),description:"Circular gauge chart with needle indicator"},{value:"progress",label:e("progress"),description:"Horizontal progress bar"}])(V),K=(e=>[{value:"quantitative",label:e("quantitative")},{value:"numeric",label:e("numeric")},{value:"percentage",label:e("percentage")}])(V),U=(e=>[{value:"higher_is_better",label:e("higher_is_better")},{value:"lower_is_better",label:e("lower_is_better")}])(V),O=h(V),W=(0,r.wA)(),z=(0,a.Zp)(),G=(0,s.useRef)({mode:null,kpiId:null,dataId:null}),Q=(0,s.useRef)({}),Y=(0,s.useRef)({}),X=(0,s.useRef)([]),$=(0,s.useRef)({}),Z=(0,s.useRef)([]),J=(0,s.useRef)({}),ee=(0,s.useRef)([]),te=(0,s.useRef)({}),ie=(0,s.useRef)([]),se=(0,s.useRef)({}),ae=(0,s.useRef)([]),le=(0,s.useRef)({}),ne=(0,s.useRef)([]),[re,oe]=(0,s.useState)(!1),[ce,de]=(0,s.useState)({isScrollInProgress:!1,totalDataFetched:!1,searchText:""}),ue=(0,s.useCallback)((()=>
1{if("Edit"===M&&B){const e=B.kpiDetails&&B.kpiDetails.id?B.kpiDetails:B.id?B:null;if(e&&e.id){const t=e.latest_measurement||{},i=(null===e||void 0===e?void 0:e.owners)||[],s=(null===e||void 0===e?void 0:e.soas)||[],a=(null===e||void 0===e?void 0:e.policies)||[],l=(null===e||void 0===e?void 0:e.assets)||[],n=(null===e||void 0===e?void 0:e.incidents)||[],r=(null===e||void 0===e?void 0:e.risks)||[];return{kpiTitle:(null===e||void 0===e?void 0:e.name)||"",kpiDescription:(null===e||void 0===e?void 0:e.description)||"",owners:i,soas:s,policies:a,assets:l,incidents:n,risks:r,status:(null===e||void 0===e?void 0:e.status)||"",chart_type:(null===e||void 0===e?void 0:e.chart_type)||"gauge",showAsPercentage:!0,kpiType:(null===e||void 0===e?void 0:e.type)||"quantitative",kpiDeviationType:(null===e||void 0===e?void 0:e.deviation_type)||"higher_is_better",unit:(null===e||void 0===e?void 0:e.unit)||"",frequency:(null===e||void 0===e?void 0:e.frequency)||"",goalInputMode:"percentage",target:null!==e&&void 0!==e&&e.target?parseFloat(e.target):"",maxValue:null!==e&&void 0!==e&&e.max_value?parseFloat(e.max_value||100):100,warnThreshold:null!==e&&void 0!==e&&e.warn_threshold?parseFloat(e.warn_threshold):"",criticalThreshold:null!==e&&void 0!==e&&e.critical_threshold?parseFloat(e.critical_threshold):"",currentAchieved:null!==t&&void 0!==t&&t.achieved?parseFloat(t.achieved):"",currentTotal:null!==t&&void 0!==t&&t.total?parseFloat(t.total):"",measurementId:(null===t||void 0===t?void 0:t.id)||null}}}return{...c.Bf.kpiFormInitialValues}}),[M,B]),{register:he,handleSubmit:pe,watch:me,reset:ve,control:xe,setValue:ge,getValues:ke,formState:{errors:je}}=(0,n.mN)({defaultValues:ue(),mode:"onChange"}),fe=me(),ye=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:300;const[i,a]=(0,s.useState)(e),l=(0,s.useRef)(null);return(0,s.useEffect)((()=>(l.current&&clearTimeout(l.current),l.current=setTimeout((()=>{a(e)}),t),()=>{l.current&&(clearTimeout(l.current),l.current=null)})),[e,t]),i}(fe,250),Ne=(0,s.useCallback)((e=>{(0,r.bN)(e,be.current)||(W((0,o.updateKpiForm)(e)),be.current=e)}),[W]),be=(0,s.useRef)({});(0,s.useEffect)((()=>{Ne(ye)}),[ye,Ne]),(0,s.useEffect)((()=>{const e=B&&B.kpiDetails?B.kpiDetails.id:B&&B.id?B.id:null;if(G.current.mode!==M||G.current.kpiId!==R||"Edit"===M&&e!==G.current.dataId){const t=ue();if("Edit"===M&&B){const e=B.kpiDetails&&B.kpiDetails.id?B.kpiDetails:B.id?B:null;e&&e.id&&(X.current=e.owners,Z.current=we(e.soas||[]),ee.current=e.policies,ie.current=e.assets,ae.current=e.incidents,ne.current=e.risks)}else"Create"===M&&(Y.current={},X.current=[],$.current={},Z.current=[],J.current={},ee.current=[],te.current={},ie.current=[],se.current={},ae.current=[],le.current={},ne.current=[]);"Edit"===M&&(Q.current={...t},Y.current={},$.current={},J.current={},te.current={},se.current={},le.current={}),"Create"===M&&W((0,o.resetKpiForm)()),ve(t),W((0,o.updateKpiForm)(t)),G.current={mode:M,kpiId:R,dataId:e}}}),[M,R,B,ve,W,ue]),(0,s.useEffect)((()=>{const e=fe.kpiType,t=fe.unit;if(e){const i=(e=>y[e]||null)(e);if(i&&t!==i)ge("unit",i);else if(e===v){b(e,V).map((e=>e.value)).includes(t)||ge("unit","")}}}),[fe.kpiType,ge,fe.unit]),(0,s.useEffect)((()=>{const{kpiType:e,kpiDeviationType:t,currentAchieved:i,criticalThreshold:s,warnThreshold:a,target:l,maxValue:n,currentTotal:r}=fe,o=((e,t,i,s,a,l,n,r)=>{if(!e||!t||null==i||null==s||null==a||null==l)return null;const o=Math.round(Number(i||0)/Number(r||1)*100)||0;let c;if(c="quantitative"===e?o:null!=n?Math.min(i,n):i,"higher_is_better"===t){if(c<s)return k;if(c>=s&&c<a)return j;if(c>=a)return f}if("lower_is_better"===t){if(c>s)return k;if(c>a&&c<=s)return j;if(c<=a)return f}return null})(e,t,i,s,a,l,n,r);ge("status",o)}),[fe.kpiDeviationType,fe.currentAchieved,fe.criticalThreshold,fe.warnThreshold,fe.target,fe.maxValue,fe.kpiType,fe.currentTotal,ge]);const _e=async e=>{try{if("Create"===M){const t=T(Y.current),i=T($.current),s=T(J.current),a=T(te.current),l=T(se.current),n=T(le.current),r={...e,owners:t,soas:i,policies:s,assets:a,incidents:l,risks:n},o=function(e){var t,i,s,a,l,n,r,o,c,d,u,h;const p=e&&(null===e||void 0===e||null===(t=e.owners)||void 0===t?void 0:t.length)>0?null===e||void 0===e||null===(i=e.owners)||void 0===i?void 0:i.filter((e=>!1!==e.checked)).map((e=>e.id)):[],m=e&&(null===e||void 0===e||null===(s=e.soas)||void 0===s?void 0:s.length)>0?null===e||void 0===e||null===(a=e.soas)||void 0===a?void 0:a.filter((e=>!1!==e.checked)).map((e=>e.id)):[],v=e&&(null===e||void 0===e||null===(l=e.policies)||void 0===l?void 0:l.length)>0?null===e||void 0===e||null===(n=e.policies)||void 0===n?void 0:n.filter((e=>!1!==e.checked)).map((e=>e.id)):[],x=e&&(null===e||void 0===e||null===(r=e.assets)||void 0===r?void 0:r.length)>0?null===e||void 0===e||null===(o=e.assets)||void 0===o?void 0:o.filter((e=>!1!==e.checked)).map((e=>e.id)):[],g=e&&(null===e||void 0===e||null===(c=e.incidents)||void 0===c?void 0:c.length)>0?null===e||void 0===e||null===(d=e.incidents)||void 0===d?void 0:d.filter((e=>!1!==e.checked)).map((e=>e.id)):[],k=e&&(null===e||void 0===e||null===(u=e.risks)||void 0===u?void 0:u.length)>0?null===e||void 0===e||null===(h=e.risks)||void 0===h?void 0:h.filter((e=>!1!==e.checked)).map((e=>
1e.id)):[],j={name:e.kpiTitle,description:e.kpiDescription,chart_type:e.chart_type,type:e.kpiType,deviation_type:e.kpiDeviationType,unit:e.unit,frequency:e.frequency,target:e.target,warn_threshold:e.warnThreshold,critical_threshold:e.criticalThreshold};return p.length>0&&(j.owners=p),m.length>0&&(j.soas=m),v.length>0&&(j.policies=v),x.length>0&&(j.assets=x),g.length>0&&(j.incidents=g),k.length>0&&(j.risks=k),"lower_is_better"!==e.kpiDeviationType&&(j.max_value=e.maxValue),j}(r),c=function(e,t){const i={comment:"Create"===t?"Initial measurement":"Updated measurement",achieved:e.currentAchieved};return"quantitative"===e.kpiType&&(i.total=e.currentTotal),i}(r,M);await q.kpiDashboardActions.tryCreatingKPI(o,c,z)}else if("Edit"===M){const t=(0,C.yD)(Y.current,e.owners,!1),i=(0,C.yD)($.current,e.soas,!1),s=(0,C.yD)(J.current,e.policies,!1),a=(0,C.yD)(te.current,e.assets,!1),l=(0,C.yD)(se.current,e.incidents,!1),n=(0,C.yD)(le.current,e.risks,!1),r={...ke(),owners:t,soas:i,policies:s,assets:a,incidents:l,risks:n},o=function(e,t){const i={},s=["owners","soas","policies","assets","incidents","risks"];return Object.keys(_).forEach((a=>{const l=e[a],n=t[a];s.includes(a)?Array.isArray(l)&&l.some((e=>"remove"===e.action||"add"===e.action&&!(Array.isArray(n)?n.map((e=>e.id)):[]).includes(e.id)))&&(i[_[a]]=l):String(l)!==String(n)&&(i[_[a]]=l)})),i}(r,Q.current),c=e.measurementId||null,d={comment:"Measurement updated",achieved:r.currentAchieved};"quantitative"===r.kpiType&&(d.total=r.currentTotal);const u=await q.kpiDashboardActions.tryUpdatingKpi(R,o,d,c);u&&200===u.code&&z("/kpi-dashboard")}}catch(t){console.error("Error during KPI ".concat(M.toLowerCase(),":"),t)}};(0,s.useImperativeHandle)(t,(()=>({saveKpi:pe(_e)})),[pe]),(0,s.useEffect)((()=>{q.kpiDashboardActions.tryFetchingSoAList(),q.kpiDashboardActions.tryFetchingPoliciesList(),q.kpiDashboardActions.tryFetchingAssetsList(),q.kpiDashboardActions.tryFetchingIncidentsList(),q.kpiDashboardActions.tryFetchingRisksList()}),[]);const Te=(0,s.useCallback)((()=>{var e;de((e=>({...e,isScrollInProgress:!0})));const t=I.TZM+"?limit="+A.L9+"&offset="+(null===B||void 0===B||null===(e=B.users)||void 0===e?void 0:e.length);(0,D.bQ)(t).then((e=>{var t,i,s;e&&200===e.code&&(e.data&&e.data&&(q.kpiDashboardActions.updateUserList([...null===B||void 0===B?void 0:B.users,...null===e||void 0===e||null===(t=e.data)||void 0===t?void 0:t.users]),de((e=>({...e,isScrollInProgress:!1}))),(null===e||void 0===e||null===(i=e.data)||void 0===i||null===(s=i.users)||void 0===s?void 0:s.length)<A.L9&&de((e=>({...e,totalDataFetched:!0})))))}))}),[null===B||void 0===B?void 0:B.users]);function we(e){return(e||[]).map((e=>{var t,i;return{...e,displayLabel:"".concat(e.sequence," - ").concat((null===(t=e.title)||void 0===t?void 0:t.default)||(null===(i=e.title)||void 0===i?void 0:i.en)||"N/A")}}))}return(0,P.jsxs)("form",{onSubmit:pe(_e),onKeyDown:e=>{"Enter"===e.key&&"TEXTAREA"!==e.target.tagName&&e.preventDefault()},className:"kpi-form-content-wrapper",children:[(0,P.jsxs)("div",{className:"form-section",children:[(0,P.jsx)("span",{className:"form-section-title",children:V("generalInfo")}),(0,P.jsxs)("div",{className:"form-field",children:[(0,P.jsx)("label",{htmlFor:"kpiTitle",children:V("kpiTitle")}),(0,P.jsx)("input",{id:"kpiTitle",type:"text",className:"common-input update-bg-color",...he("kpiTitle",w("kpiTitle",me,V)),placeholder:V("enterKpiTitle"),onKeyDown:e=>{"Enter"===e.key&&e.preventDefault()}}),je.kpiTitle&&(0,P.jsx)("span",{className:"error-text tl-text12",children:je.kpiTitle.message})]}),(0,P.jsxs)("div",{className:"form-field",children:[(0,P.jsx)("label",{htmlFor:"kpiDescription",children:V("kpiDescription")}),(0,P.jsx)("textarea",{id:"kpiDescription",className:"common-input update-bg-color description-textarea",...he("kpiDescription",w("kpiDescription",me,V)),placeholder:V("enterKpiDescription"),rows:3,style:{resize:"none",minHeight:"40px",overflow:"hidden"},onInput:e=>{e.target.style.height="auto",e.target.style.height=e.target.scrollHeight+"px"}}),je.kpiDescription&&(0,P.jsx)("span",{className:"error-text tl-text12",children:je.kpiDescription.message})]}),(0,P.jsxs)("div",{className:"form-field",children:[(0,P.jsx)("label",{htmlFor:"owners",children:V("owners")}),(0,P.jsx)(F.A,{optionList:(null===B||void 0===B?void 0:B.users)||[],values:X.current,updateSelection:e=>{Y.current=e,oe(!1)},onSearchEvent:e=>{e&&e.trim().length>0?q.kpiDashboardActions.tryFetchingUsers(e):q.kpiDashboardActions.tryFetchingUsers()},parentClass:"w-100",labelBy:"name",showImage:!0,onListScroll:!ce.isScrollInProgress&&!ce.totalDataFetched&&Te,placeholder:"N/A",paginated:!0,limit:10,showImageAvatar:!0}),re&&(0,P.jsx)("span",{className:"error-text tl-text12",children:"Owners are required"})]})]}),(0,P.jsxs)("div",{className:"form-section",children:[(0,P.jsx)("span",{className:"form-section-title",children:V("displayConfiguration")}),(0,P.jsxs)("div",{className:"form-field",children:[(0,P.jsx)("label",{children:V("chartType")}),(0,P.jsx)("div",{className:"radio-group",children:(0,P.jsx)(n.xI,{name:"chart_type",control:xe,rules:{required:"Chart Type is required"},render:e=>{let{field:t}=e;return(0,P.jsx)(P.Fragment,{children:H.map((e=>(0,P.jsxs)("div",{onClick:()=>t.onChange(e.value),className:"radio-option ".concat(t.value===e.value?"active-radio":""),children:[(0,P.jsx)(d.a,{inputId:e.value,name:"chart_type",value:e.value,className:"tl-mt4",onChange:e=>t.onChange(e.value),checked:t.value===e.value}),(0,P.jsx)("label",{htmlFor:e.value,className:"ml-2",children:e.label})]},e.value)))})}})}),je.chart_type&&(0,P.jsx)("span",{className:"error-text tl-text12",children:je.chart_type.message})]})]}),(0,P.jsxs)("div",{className:"form-section",children:[(0,P.jsx)("span",{className:"form-section-title",children:V("measurementDefinition")}),(0,P.jsxs)("div",{className:"form-field-grid",children:[(0,P.jsxs)("div",{children:[(0,P.jsx)("label",{htmlFor:"kpiType",children:V("kpiType")}),(0,P.jsx)(n.xI,{name:"kpiType",control:xe,rules:{required:"KPI Type is required"},render:e=>{let{field:t}=e;return(0,P.jsx)(u.m,{inputId:"kpiType",className:"form-dropdown",value:t.value||"",options:K,onChange:e=>t.onChange(e.value),optionValue:"value",optionLabel:"label",placeholder:V("selectKpiType")})}}),je.kpiType&&(0,P.jsx)("span",{className:"error-text tl-text12",children:je.kpiType.message})]}),(0,P.jsxs)("div",{children:[(0,P.jsx)("label",{htmlFor:"kpiDeviationType",children:V("kpiDeviationType")}),(0,P.jsx)(n.xI,{name:"kpiDeviationType",control:xe,render:e=>{let{field:t}=e;return(0,P.jsx)(u.m,{inputId:"kpiDeviationType",className:"form-dropdown",value:t.value||"",options:U,onChange:e=>t.onChange(e.value),optionValue:"value",optionLabel:"label",placeholder:V("selectDeviationType")})}}),je.kpiDeviationType&&(0,P.jsx)("span",{className:"error-text tl-text12",children:je.kpiDeviationType.message})]})]}),(0,P.jsxs)("div",{className:"form-field-grid",children:[(0,P.jsxs)("div",{children:[(0,P.jsx)("label",{htmlFor:"unit",children:V("unit")}),(0,P.jsx)(n.xI,{name:"unit",control:xe,rules:{required:"Unit is required",validate:e=>((e,t,i)=>{var s;if(!t)return N.SELECT_KPI_TYPE_FIRST;if(!((null===(s=g(t,i))||void 0===s?void 0:s.map((e=>e.value)))||[]).includes(e))switch(t){case m:return N.QUANTITATIVE_INVALID;case v:return N.NUMERIC_INVALID;case x:return N.PERCENTAGE_INVALID;default:return N.REQUIRED}return!0})(e,me("kpiType"),V)},render:e=>{let{field:t}=e;const i=me("kpiType"),s=b(i,V);return(0,P.jsx)(u.m,{inputId:"unit",className:"form-dropdown",value:t.value||"",options:s,onChange:e=>t.onChange(e.value),optionValue:"value",optionLabel:"label",placeholder:V(i?"selectUnit":"selectKpiTypeFirst"),disabled:!i||0===s.length})}}),je.unit&&(0,P.jsx)("span",{className:"error-text tl-text12",children:je.unit.message})]}),(0,P.jsxs)("div",{children:[(0,P.jsx)("label",{htmlFor:"frequency",children:V("frequency")}),(0,P.jsx)(n.xI,{name:"frequency",control:xe,rules:{required:"Frequency is required"},render:e=>{let{field:t}=e;return(0,P.jsx)(u.m,{inputId:"frequency",className:"form-dropdown",value:t.value||"",options:O,onChange:e=>t.onChange(e.value),optionValue:"value",optionLabel:"label",placeholder:V("selectFrequency")})}}),je.frequency&&(0,P.jsx)("span",{className:"error-text tl-text12",children:je.frequency.message})]})]})]}),(0,P.jsxs)("div",{className:"form-section",children:[(0,P.jsx)("span",{className:"form-section-title",children:V("goalsAndThresholds")}),(0,P.jsxs)("div",{className:"form-field-grid",children:[(0,P.jsxs)("div",{children:[(0,P.jsxs)("label",{htmlFor:"target",children:[V("target")," ","quantitative"===fe.kpiType&&"(%)"]}),(0,P.jsx)("input",{id:"target",type:"number",className:"common-input update-bg
1-color",...he("target",w("target",me,V)),placeholder:V("enterTargetValue")}),je.target&&(0,P.jsx)("span",{className:"error-text tl-text12",children:je.target.message})]}),"lower_is_better"!==fe.kpiDeviationType&&(0,P.jsxs)("div",{children:[(0,P.jsxs)("label",{htmlFor:"maxValue",children:[V("maxValue")," ","quantitative"===fe.kpiType&&"(%)"]}),(0,P.jsx)("input",{id:"maxValue",type:"number",className:S()("common-input update-bg-color"),...he("maxValue",w("maxValue",me,V)),placeholder:V("enterMaxValue"),disabled:"quantitative"===fe.kpiType||"percentage"===fe.kpiType}),je.maxValue&&(0,P.jsx)("span",{className:"error-text tl-text12",children:je.maxValue.message})]})]}),(0,P.jsxs)("div",{className:"form-field-grid",children:[(0,P.jsxs)("div",{children:[(0,P.jsxs)("label",{htmlFor:"warnThreshold",children:[V("warningThreshold")," ","quantitative"===fe.kpiType&&"(%)"]}),(0,P.jsx)("input",{id:"warnThreshold",type:"number",className:"common-input update-bg-color",...he("warnThreshold",w("warnThreshold",me,V)),placeholder:V("enterWarningThreshold")}),je.warnThreshold&&(0,P.jsx)("span",{className:"error-text tl-text12",children:je.warnThreshold.message})]}),(0,P.jsxs)("div",{children:[(0,P.jsxs)("label",{htmlFor:"criticalThreshold",children:[V("criticalThreshold")," ","quantitative"===fe.kpiType&&"(%)"]}),(0,P.jsx)("input",{id:"criticalThreshold",type:"number",className:"common-input update-bg-color",...he("criticalThreshold",w("criticalThreshold",me,V)),placeholder:V("enterCriticalThreshold")}),je.criticalThreshold&&(0,P.jsx)("span",{className:"error-text tl-text12",children:je.criticalThreshold.message})]})]})]}),(0,P.jsxs)("div",{className:"form-section",children:[(0,P.jsx)("span",{className:"form-section-title",children:V("governanceAndIsoControls")}),(0,P.jsxs)("div",{className:"form-field",children:[(0,P.jsx)("label",{htmlFor:"soas",children:V("associatedControls")}),(0,P.jsx)(F.A,{optionList:we((null===B||void 0===B||null===(i=B.soasList)||void 0===i?void 0:i.soaList)||[]),values:Z.current,updateSelection:e=>{$.current=e},onSearchEvent:e=>{e&&e.trim().length>0?(de((t=>({...t,searchText:e}))),q.kpiDashboardActions.tryFetchingSoAList(e,null,A.L9,0)):(q.kpiDashboardActions.tryFetchingSoAList(),de((e=>({...e,searchText:""}))))},parentClass:"w-100",labelBy:"displayLabel",showImage:!0,onListScroll:!ce.isScrollInProgress&&!ce.totalDataFetched&&(async()=>{if(!ce.isScrollInProgress&&!ce.totalDataFetched){de((e=>({...e,isScrollInProgress:!0})));try{var e,t;const s=await(0,o.tryFetchingSoaUtil)(ce.searchText,A.L9,(null===B||void 0===B||null===(e=B.soasList)||void 0===e||null===(t=e.soaList)||void 0===t?void 0:t.length)||0);if((null===s||void 0===s?void 0:s.length)>0){var i;const e=[...null===B||void 0===B||null===(i=B.soasList)||void 0===i?void 0:i.soaList,...s];q.kpiDashboardActions.updateSoaList({soaList:e})}((null===s||void 0===s?void 0:s.length)||0)<A.L9?de((e=>({...e,totalDataFetched:!0,isScrollInProgress:!1}))):de((e=>({...e,isScrollInProgress:!1})))}catch(s){console.error("Error fetching SOA data:",s),de((e=>({...e,isScrollInProgress:!1})))}}}),placeholder:"N/A",paginated:!0,limit:10,showCross:!0})]}),(0,P.jsxs)("div",{className:"form-field",children:[(0,P.jsx)("label",{htmlFor:"policies",children:V("associatedPolicies")}),(0,P.jsx)(F.A,{optionList:function(e){const t=new Set;return(e||[]).filter((e=>!(null===e||void 0===e||!e.id)&&(!t.has(e.id)&&(t.add(e.id),!0))))}((null===B||void 0===B||null===(l=B.policiesList)||void 0===l?void 0:l.policies)||[]),values:ee.current,updateSelection:e=>{J.current=e},onSearchEvent:e=>{e&&e.trim().length>0?(de((t=>({...t,searchText:e}))),q.kpiDashboardActions.tryFetchingPoliciesList(e,null,null,A.L9,0)):(q.kpiDashboardActions.tryFetchingPoliciesList(),de((e=>({...e,searchText:""}))))},parentClass:"w-100",labelBy:"name",showImage:!0,onListScroll:!ce.isScrollInProgress&&!ce.totalDataFetched&&(async()=>{if(!ce.isScrollInProgress&&!ce.totalDataFetched){de((e=>({...e,isScrollInProgress:!0})));try{var e,t;const s=await(0,o.tryFetchingPoliciesListUtil)(ce.searchText,A.L9,(null===B||void 0===B||null===(e=B.policiesList)||void 0===e||null===(t=e.policies)||void 0===t?void 0:t.length)||0);if((null===s||void 0===s?void 0:s.length)>0){var i;const e=[...null===B||void 0===B||null===(i=B.policiesList)||void 0===i?void 0:i.policies,...s];q.kpiDashboardActions.updatePoliciesList({policies:e})}((null===s||void 0===s?void 0:s.length)||0)<A.L9?de((e=>({...e,totalDataFetched:!0,isScrollInProgress:!1}))):de((e=>({...e,isScrollInProgress:!1})))}catch(s){de((e=>({...e,isScrollInProgress:!1})))}}}),placeholder:"N/A",paginated:!0,limit:10,showCross:!0})]}),(0,P.jsxs)("div",{className:"form-field",children:[(0,P.jsx)("label",{htmlFor:"assets",children:V("associatedProcesses")}),(0,P.jsx)(F.A,{optionList:(null===B||void 0===B||null===(p=B.assetsList)||void 0===p?void 0:p.assets)||[],values:ie.current,updateSelection:e=>{te.current=e},onSearchEvent:e=>{e&&e.trim().length>0?(de((t=>({...t,searchText:e}))),q.kpiDashboardActions.tryFetchingAssetsList(e,null,A.L9,0)):(q.kpiDashboardActions.tryFetchingAssetsList(),de((e=>({...e,searchText:""}))))},parentClass:"w-100",labelBy:"name",showImage:!0,onListScroll:!ce.isScrollInProgress&&!ce.totalDataFetched&&(async()=>
1{if(!ce.isScrollInProgress&&!ce.totalDataFetched){de((e=>({...e,isScrollInProgress:!0})));try{var e,t;const s=await(0,o.tryFetchingAssetsUtil)(ce.searchText,null,A.L9,(null===B||void 0===B||null===(e=B.assetsList)||void 0===e||null===(t=e.assets)||void 0===t?void 0:t.length)||0);if((null===s||void 0===s?void 0:s.length)>0){var i;const e=[...null===B||void 0===B||null===(i=B.assetsList)||void 0===i?void 0:i.assets,...s];q.kpiDashboardActions.updateAssetsList({assets:e})}((null===s||void 0===s?void 0:s.length)||0)<A.L9?de((e=>({...e,totalDataFetched:!0,isScrollInProgress:!1}))):de((e=>({...e,isScrollInProgress:!1})))}catch(s){console.error("Error fetching Assets data:",s),de((e=>({...e,isScrollInProgress:!1})))}}}),placeholder:"N/A",paginated:!0,limit:10,showCross:!0})]}),(0,P.jsxs)("div",{className:"form-field",children:[(0,P.jsx)("label",{htmlFor:"incidents",children:V("associatedTickets")}),(0,P.jsx)(F.A,{optionList:(null===B||void 0===B||null===(L=B.incidentsList)||void 0===L?void 0:L.incidents)||[],values:ae.current,updateSelection:e=>{se.current=e},onSearchEvent:e=>{e&&e.trim().length>0?(de((t=>({...t,searchText:e}))),q.kpiDashboardActions.tryFetchingIncidentsList(e,null,A.L9,0)):(q.kpiDashboardActions.tryFetchingIncidentsList(),de((e=>({...e,searchText:""}))))},parentClass:"w-100",labelBy:"title",showImage:!0,onListScroll:!ce.isScrollInProgress&&!ce.totalDataFetched&&(async()=>{if(!ce.isScrollInProgress&&!ce.totalDataFetched){de((e=>({...e,isScrollInProgress:!0})));try{var e,t;const s=await(0,o.tryFetchingIncidentsListUtil)(ce.searchText,null,A.L9,(null===B||void 0===B||null===(e=B.incidentsList)||void 0===e||null===(t=e.incidents)||void 0===t?void 0:t.length)||0);if((null===s||void 0===s?void 0:s.length)>0){var i;const e=[...null===B||void 0===B||null===(i=B.incidentsList)||void 0===i?void 0:i.incidents,...s];q.kpiDashboardActions.updateIncidentsList({incidents:e})}((null===s||void 0===s?void 0:s.length)||0)<A.L9?de((e=>({...e,totalDataFetched:!0,isScrollInProgress:!1}))):de((e=>({...e,isScrollInProgress:!1})))}catch(s){console.error("Error fetching Incidents data:",s),de((e=>({...e,isScrollInProgress:!1})))}}}),placeholder:"N/A",paginated:!0,limit:10,showCross:!0})]}),(0,P.jsxs)("div",{className:"form-field",children:[(0,P.jsx)("label",{htmlFor:"risks",children:V("associatedRisks")}),(0,P.jsx)(F.A,{optionList:(null===B||void 0===B||null===(E=B.risksList)||void 0===E?void 0:E.risks)||[],values:ne.current,updateSelection:e=>{le.current=e},onSearchEvent:e=>{e&&e.trim().length>0?(de((t=>({...t,searchText:e}))),q.kpiDashboardActions.tryFetchingRisksList(e,A.L9,0)):(q.kpiDashboardActions.tryFetchingRisksList(),de((e=>({...e,searchText:""}))))},parentClass:"w-100",labelBy:"identifier",showImage:!0,onListScroll:!ce.isScrollInProgress&&!ce.totalDataFetched&&(async()=>{if(!ce.isScrollInProgress&&!ce.totalDataFetched){de((e=>({...e,isScrollInProgress:!0})));try{var e,t;const s=await(0,o.tryFetchingRisksListUtil)(ce.searchText,A.L9,(null===B||void 0===B||null===(e=B.risksList)||void 0===e||null===(t=e.risks)||void 0===t?void 0:t.length)||0);if((null===s||void 0===s?void 0:s.length)>0){var i;const e=[...null===B||void 0===B||null===(i=B.risksList)||void 0===i?void 0:i.risks,...s];q.kpiDashboardActions.updateRisksList({risks:e})}((null===s||void 0===s?void 0:s.length)||0)<A.L9?de((e=>({...e,totalDataFetched:!0,isScrollInProgress:!1}))):de((e=>({...e,isScrollInProgress:!1})))}catch(s){console.error("Error fetching Risks data:",s),de((e=>({...e,isScrollInProgress:!1})))}}}),placeholder:"N/A",paginated:!0,limit:10,showCross:!0})]})]}),(0,P.jsxs)("div",{className:"form-section",children:[(0,P.jsx)("span",{className:"form-section-title",children:V("Edit"===M?"currentValues":"initialValues")}),(0,P.jsxs)("div",{className:"form-field-grid",children:[(0,P.jsxs)("div",{children:[(0,P.jsx)("label",{htmlFor:"currentAchieved",children:"quantitative"===fe.kpiType?V("currentAchievedX"):V("currentAchieved")}),(0,P.jsx)("input",{id:"currentAchieved",type:"number",className:"common-input update-bg-color",...he("currentAchieved",w("currentAchieved",me,V)),placeholder:V("enterCurrentAchievedValue")}),je.currentAchieved&&(0,P.jsx)("span",{className:"error-text tl-text12",children:je.currentAchieved.message})]}),"quantitative"===fe.kpiType&&(0,P.jsxs)("div",{children:[(0,P.jsx)("label",{htmlFor:"currentTotal",children:V("currentTotalY")}),(0,P.jsx)("input",{id:"currentTotal",type:"number",className:"common-input update-bg
1-color",...he("currentTotal",w("currentTotal",me,V)),placeholder:V("enterCurrentTotalValue")}),je.currentTotal&&(0,P.jsx)("span",{className:"error-text tl-text12",children:je.currentTotal.message})]})]})]})]})}));E.displayName="KpiForm";const M=(0,s.memo)(E);var R=i(6173),B=i(103);const q=e=>{let{value:t,target:i,min:a,max:l,status:n="off_track",className:r="",kpiType:o,name:c}=e;const{targetPosition:d,valuePosition:u}=(()=>{if("numeric"===o){const e=a||0,s=(l||100)-e;if(s<=0)return{targetPosition:i,valuePosition:t};return{targetPosition:(i-e)/s*100,valuePosition:(t-e)/s*100}}return{targetPosition:i,valuePosition:t}})(),h=u/100,p=d/100,m=180*h-90,[v,x]=(0,s.useState)(!1),[g,k]=(0,s.useState)({top:0,left:0});return(0,P.jsxs)("div",{className:"gauge-chart-container ".concat(r),onMouseEnter:e=>{const t=e.currentTarget.getBoundingClientRect(),i=window.innerWidth-(t.right+10),s=t.left-10;let a=0;a=i>230?t.right+10:s>230?t.left-180:t.left;const l=t.top;x(!0),k({top:l,left:a})},onMouseLeave:()=>{x(!1)},children:[(0,P.jsxs)("svg",{viewBox:"0 0 200 120",className:"gauge-svg",children:[(0,P.jsx)("path",{d:"M 20 100 A 80 80 0 0 1 180 100",className:"gauge-background-arc"}),(0,P.jsx)("path",{d:"M 20 100 A 80 80 0 0 1 180 100",className:"gauge-value-arc",stroke:{on_track:"#61C9A8",at_risk:"#E9A33B",off_track:"#F2545B"}[n],strokeDasharray:"".concat(251.2*h," 251.2")}),(0,P.jsx)("circle",{cx:100+80*Math.cos(Math.PI-p*Math.PI),cy:100-80*Math.sin(Math.PI-p*Math.PI),r:"6",className:"gauge-target-marker"}),(0,P.jsxs)("g",{transform:"rotate(".concat(m," 100 100)"),children:[(0,P.jsx)("line",{x1:"100",y1:"100",x2:"100",y2:"30",className:"gauge-needle"}
1),(0,P.jsx)("circle",{cx:"100",cy:"100",r:"6",className:"gauge-needle-center"})]})]}),(0,P.jsx)("div",{className:"gauge-center-value",children:(0,P.jsx)("div",{className:"gauge-value-container",children:(0,P.jsx)("div",{className:"gauge-value-text",children:"numeric"===o?t.toFixed(0):"".concat(t.toFixed(0),"%")})})}),v&&(0,P.jsx)(R.A,{position:g,visible:!0,children:(0,P.jsxs)("div",{className:"kpi-tooltip",children:[(0,P.jsx)("span",{className:"title",children:c}),(0,P.jsxs)("div",{className:"kpi-row",children:[(0,P.jsxs)("div",{children:[(0,P.jsx)("span",{dangerouslySetInnerHTML:{__html:B.J}}),(0,P.jsx)("span",{children:"Target"})]}),(0,P.jsx)("span",{children:i})]}),(0,P.jsxs)("div",{className:"kpi-row",children:[(0,P.jsxs)("div",{children:[(0,P.jsx)("span",{className:"completed-dot"}),(0,P.jsx)("span",{children:"Completed"})]}),(0,P.jsx)("span",{children:"numeric"===o?t.toFixed(0):"".concat(t.toFixed(0),"%")})]})]})})]})},V=s.memo(q,((e,t)=>e.value===t.value&&e.target===t.target&&e.min===t.min&&e.max===t.max&&e.status===t.status&&e.className===t.className&&e.kpiType===t.kpiType&&e.name===t.name)),H=e=>{let{value:t,target:i,min:a,max:l,status:n="off_track",className:r="",kpiType:o,name:c}=e;
1const[d,u]=(0,s.useState)(!1),[h,p]=(0,s.useState)({top:0,left:0}),{targetPosition:m,valuePosition:v}=(()=>{if("numeric"===o){const e=a||0,s=(l||100)-e;if(s<=0)return{targetPosition:i,valuePosition:t};return{targetPosition:(i-e)/s*100,valuePosition:(t-e)/s*100}}return{targetPosition:i,valuePosition:t}})();return(0,P.jsxs)("div",{className:"progress-chart-container ".concat(r),onMouseEnter:e=>{const t=e.currentTarget.getBoundingClientRect(),i=window.innerWidth-(t.right+10),s=t.left-10;let a=0;a=i>230?t.right+10:s>230?t.left-180:t.left;const l=t.top;u(!0),p({top:l,left:a})},onMouseLeave:()=>{u(!1)},children:[(0,P.jsxs)("div",{className:"progress-bar-wrapper",children:[(0,P.jsx)("div",{className:"progress-bar-fill",style:{width:"".concat(Math.min(v,100),"%"),backgroundColor:{on_track:"#61C9A8",at_risk:"#E9A33B",off_track:"#F2545B"}[n]}}),(0,P.jsxs)("div",{className:"progress-target-marker",style:{left:"".concat(Math.min(m,100),"%")},children:[(0,P.jsx)("div",{className:"progress-target-circle"}),(0,P.jsx)("div",{className:"progress-target-label",children:"Target"})]})]}),(0,P.jsxs)("div",{className:"progress-labels",children:[(0,P.jsx)("span",{className:"progress-label-muted",children:a}),(0,P.jsx)("span",{className:"progress-label-muted",children:l})]}),(0,P.jsx)("div",{className:"progress-label-value",children:"numeric"===o?t.toFixed(0):"".concat(t.toFixed(0),"%")}),d&&(0,P.jsx)(R.A,{position:h,visible:!0,children:(0,P.jsxs)("div",{className:"kpi-tooltip",children:[(0,P.jsx)("span",{className:"title",children:c}),(0,P.jsxs)("div",{className:"kpi-row",children:[(0,P.jsxs)("div",{children:[(0,P.jsx)("span",{dangerouslySetInnerHTML:{__html:B.J}}),(0,P.jsx)("span",{children:"Target"})]}),(0,P.jsx)("span",{children:i})]}),(0,P.jsxs)("div",{className:"kpi-row",children:[(0,P.jsxs)("div",{children:[(0,P.jsx)("span",{className:"completed-dot"}),(0,P.jsx)("span",{children:"Completed"})]}),(0,P.jsx)("span",{children:"numeric"===o?t.toFixed(0):"".concat(t.toFixed(0),"%")})]})]})})]})},K=s.memo(H,((e,t)=>e.value===t.value&&e.target===t.target&&e.min===t.min&&e.max===t.max&&e.status===t.status&&e.className===t.className&&e.kpiType===t.kpiType&&e.name===t.name)),U=e=>({at_risk:{class:"kpi-badge at-risk",text:e?e("atRisk"):"At Risk"},on_track:{class:"kpi-badge on-track",text:e?e("onTrack"):"On Track"},off_track:{class:"kpi-badge off-track",text:e?e("offTrack"):"Off Track"},"up-to-date":{class:"kpi-badge up-to-date",text:e?e("upToDate"):"Up to Date"},overdue:{class:"kpi-badge overdue",text:e?e("overdue"):"Overdue"},default:{class:"kpi-badge no-status",text:e?e("needsMeasurement"):"Needs measurement"}}),O={at_risk:{class:"kpi-badge at-risk",text:"At Risk"},on_track:{class:"kpi-badge on-track",text:"On Track"},off_track:{class:"kpi-badge off-track",text:"Off Track"},"up-to-date":{class:"kpi-badge up-to-date",text:"Up to Date"},overdue:{class:"kpi-badge overdue",text:"overdue"},default:{class:"kpi-badge no-status",text:"needsMeasurement"}},W=e=>{let{status:t,t:i}=e;const s=i?U(i):O,a=s[t]||s.default;return(0,P.jsx)("span",{className:"kpi-status-badges",children:(0,P.jsx)("span",{className:a.class,children:null!==a&&void 0!==a&&a.text&&i?i(null===a||void 0===a?void 0:a.text):null===a||void 0===a?void 0:a.text})})},z=s.memo((e=>{var t,i;let{kpi:s,optionMenuTemplate:a,hasOptionTemplate:n,onClick:r,isListing:o=!1,className:c="",t:d}=e,u=0,h=0;const p=(0,l.qz)()||"de",m=function(e){if(!e||isNaN(e)||e<=0)return null;const t=new Date;return t.setDate(t.getDate()+e),t.toISOString().split("T")[0]}((null===s||void 0===s?void 0:s.frequency)||(null===s||void 0===s?void 0:s.next_due_at))||new Date,v=(null===s||void 0===s?void 0:s.kpiType)||(null===s||void 0===s?void 0:s.kpi_type)||(null===s||void 0===s?void 0:s.type),x=(null===s||void 0===s?void 0:s.deviation_type)||(null===s||void 0===s?void 0:s.kpiDeviationType)||"higher_is_better";if("quantitative"===v)if(o){var g,k;const e=Number((null===s||void 0===s||null===(g=s.latest_measurement)||void 0===g?void 0:g.achieved)||0),t=Number((null===s||void 0===s||null===(k=s.latest_measurement)||void 0===k?void 0:k.total)||1);u=t>0?e/t*100:0,h=Number(null===s||void 0===s?void 0:s.max_value)||100}else{const e=Number((null===s||void 0===s?void 0:s.currentAchieved)||0),t=Number((null===s||void 0===s?void 0:s.currentTotal)||1);u=t>0?e/t*100:0,h=Number(null===s||void 0===s?void 0:s.currentTotal)||100}else if("numeric"===v){var j;if(o)u=Number((null===s||void 0===s||null===(j=s.latest_measurement)||void 0===j?void 0:j.achieved)||0),h=Number("lower_is_better"===x?(null===s||void 0===s?void 0:s.critical_threshold)||100:(null===s||void 0===s?void 0:s.max_value)||100);else u=Number((null===s||void 0===s?void 0:s.currentAchieved)||0),h=Number("lower_is_better"===x?(null===s||void 0===s?void 0:s.criticalThreshold)||100:(null===s||void 0===s?void 0:s.maxValue)||100)}else if("percentage"===v){var f;if(o)u=Number((null===s||void 0===s||null===(f=s.latest_measurement)||void 0===f?void 0:f.achieved)||0),h=100;else u=Number((null===s||void 0===s?void 0:s.currentAchieved)||0),h=100}u=isNaN(u)?0:u,h=isNaN(h)?100:h;const y="de"===p?"vor ".concat((null===s||void 0===s||null===(t=s.latest_measurement)||void 0===t?void 0:t.measured_ago_days)||0," Tagen"):"".concat((null===s||void 0===s||null===(i=s.latest_measurement)||void 0===i?void 0:i.measured_ago_days)||0," days ago");return(0,P.jsxs)("div",{className:"kpi-card cursor-hand ".concat(c),onClick:()=>r&&r(s),children:[(0,P.jsxs)("div",{className:"vertical-center justify-content-space-between",children:[(0,P.jsx)("span",{className:"kpi-title dotted-text",children:s.name||s.kpiTitle||(d?d("title"):"Title")}),n&&(0,P.jsx)("span",{children:a(s)})]}),(0,P.jsxs)("div",{className:"kpi-status-wrapper",children:[(0,P.jsx)(W,{status:s.status,t:d}),(0,P.jsx)(W,{status:s.measurement_status,t:d})]}),"gauge"===s.chart_type?(0,P.jsx)(V,{value:u,min:0,max:h,target:s.target||0,status:s.status||"off_track",className:o?"":"updated-width",kpiType:v,name:s.name||s.kpiTitle||"Title"},"gauge-".concat(u,"-").concat(s.currentTotal,"-").concat(s.currentAchieved,"-").concat(s.chart_type)):(0,P.jsx)(K,{value:u,min:0,max:h,target:s.target||0,status:s.status||"off_track",className:o?"":"updated-width",kpiType:v,name:s.name||s.kpiTitle||"Title"},"progress-".concat(u,"-").concat(s.currentTotal,"-").concat(s.currentAchieved,"-").concat(s.chart_type)),(0,P.jsxs)("div",{className:"kpi-footer-wrapper",children:[(0,P.jsxs)("div",{className:"kpi-footer-item",children:[(0,P.jsx)("span",{children:d?d("lastMeasured"):"Last Measured"}),(0,P.jsx)("span",{children:null===(null===s||void 0===s?void 0:s.status)?"N/A":y})]}),(0,P.jsxs)("div",{className:"kpi-footer-item",children:[(0,P.jsx)("span",{children:d?d("due"):"Due"}),(0,P.jsx)("span",{className:"overdue"===(null===s||void 0===s?void 0:s.measurement_status)?"overdue":"",children:(0,l.po)(s.next_due_at||m)||"N/A"})]})]})]})}));z.displayName="KpiCard";const G=e=>{const t=e.kpiDashboard.kpiFormInitialValues;return{kpiTitle:t.kpiTitle,kpiType:t.kpiType,chart_type:t.chart_type,target:t.target,maxValue:t.maxValue,currentAchieved:t.currentAchieved,currentTotal:t.currentTotal,status:t.status,showAsPercentage:t.showAsPercentage,frequency:t.frequency,kpiDeviationType:t.kpiDeviationType,criticalThreshold:t.criticalThreshold}},Q=s.memo((e=>{let{t:t}=e;const i=(0,r.d4)(G,r.bN);return(0,P.jsx)("div",{className:"kpi-form-preview",children:(0,P.jsx)(z,{kpi:i,optionMenuTemplate:(0,P.jsx)(P.Fragment,{}),hasOptionTemplate:!1,isListing:!1,className:"update-card",t:t})})}));Q.displayName="KpiFormPreview";
1const Y=Q,X=s.memo((e=>{let{mode:t,id:i,kpiDashboardData:l,action:n,t:r}=e;const o=(0,s.useRef)(null),c=(0,a.Zp)();(0,s.useEffect)((()=>{"Edit"===t&&i&&(0===Object.keys((null===l||void 0===l?void 0:l.kpiDetails)||{}).length&&n.kpiDashboardActions.tryFetchingKPIDetails(i),n.kpiDashboardActions.tryFetchingKPIMeasurements(i)),n.kpiDashboardActions.tryFetchingUsers()}),[i,t]);const d=function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]?c("/kpi-dashboard",{replace:!0}):c("/kpi-dashboard")},u=()=>(0,P.jsxs)("div",{className:"breadcrumb-wrapper breadcrumb-position tl-ml12",children:[(0,P.jsx)("span",{className:"breadcrumb-angle-icon cursor-hand",onClick:()=>d(!0),dangerouslySetInnerHTML:{__html:B.ak}}),(0,P.jsx)("span",{className:"line"}),(0,P.jsxs)("div",{className:"item-wrapper",children:[(0,P.jsx)("span",{className:"cursor-hand",onClick:()=>d(!0),children:r("kpiDashboard")}),(0,P.jsx)("span",{className:"angle-icon-right",dangerouslySetInnerHTML:{__html:B.rO}}),(0,P.jsx)("span",{className:"active-page",children:r("Create"===t?"createKPI":"editKPI")})]})]});return(0,P.jsxs)("div",{className:"kpi-form-wrapper",children:[(0,P.jsx)(u,{}),(0,P.jsx)("div",{className:"kpi-form",children:(0,P.jsx)(M,{ref:o,mode:t,kpiId:i,kpiDashboardData:l,action:n,t:r})}),(0,P.jsxs)("div",{className:"kpi-form-preview-wrapper",children:[(0,P.jsx)("span",{className:"title",children:r("livePreview")}),(0,P.jsx)("span",{className:"description",children:r("seeYourChangesHere")}),(0,P.jsxs)("div",{className:"preview-content",children:[(0,P.jsx)(Y,{t:r}),(0,P.jsxs)("div",{className:"btn-wrapper",children:[(0,P.jsx)("button",{className:"cancel-cta no-border",onClick:d,children:r("cancel")}),(0,P.jsx)("button",{className:l.isCreatingKpi?"inactive-section light-blue-cta no-border":"light-blue-cta no-border",onClick:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.saveKpi()},children:r("saveKPI")})]})]})]})]})}));X.displayName="KpiFormWrapper";const $=X;var Z=i(561);const J=e=>{let{currentValue:t,targetValue:i,measurements:s=[],onChangeTab:a,kpiType:n,t:r}=e;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)("div",{className:"kpi-detail__cardsRow",children:[(0,P.jsxs)("div",{className:"kpi-detail__miniCard",children:[(0,P.jsx)("div",{className:"kpi-detail__miniCardLabel",children:r("currentValue")}),(0,P.jsx)("div",{className:"kpi-detail__miniCardValue",children:t})]}),(0,P.jsxs)("div",{className:"kpi-detail__miniCard",children:[(0,P.jsx)("div",{className:"kpi-detail__miniCardLabel",children:r("target")}),(0,P.jsx)("div",{className:"kpi-detail__miniCardValue",children:i})]})]}),(0,P.jsxs)("div",{className:"kpi-detail__listHeader",children:[(0,P.jsx)("div",{className:"kpi-detail__listTitle",children:r("recentMeasurements")}),(0,P.jsx)("button",{className:"kpi-detail__linkBtn",type:"button",onClick:a,children:r("allMeasurements")})]}),(0,P.jsx)("div",{className:"kpi-detail__list",children:Array.isArray(s)&&s.map(((e,t)=>(0,P.jsxs)("div",{className:"kpi-detail__rowCard",children:[(0,P.jsx)("div",{className:"kpi-detail__rowLeft",children:(0,l.po)(e.measured_at)}),(0,P.jsxs)("div",{className:"kpi-detail__rowRight",children:[(0,P.jsx)("span",{className:"kpi-detail__rowMetric",children:e.achieved||0}),("quantitative"===n||"percentage"===n)&&(0,P.jsx)("span",{className:"kpi-detail__rowPercent",children:e.total?e.total:e.kpi_snapshot.max_value||100})]})]},"".concat(e.date,"-").concat(t))))})]})};var ee=i(6847),te=i(7267),ie=i(9452);const se=e=>{let{measurements:t=[],kpiType:i}=e;const s=[...t].sort(((e,t)=>new Date(e.measured_at)-new Date(t.measured_at))),a=s.map((e=>new Date(e.measured_at).toLocaleDateString("en-US",{month:"short",day:"numeric"}))),l=s.map((e=>{const t=parseFloat(e.achieved);if("numeric"===i)return t;{const i=parseFloat(e.total?e.total:e.kpi_snapshot.max_value||100);return i>0?t/i*100:0}})),n=[{name:"numeric"===i?"Value":"Achievement %",data:l,color:"#0095FF"}],r={chart:{type:"line",height:350,toolbar:{show:!1}},stroke:{width:3,curve:"straight"},markers:{size:6,strokeColors:"#fff",strokeWidth:2,hover:{size:8}},dataLabels:{enabled:!1},xaxis:{categories:a},yaxis:{labels:{formatter:e=>"numeric"===i?e.toFixed(0):"".concat(e.toFixed(1),"%")},min:0,max:"numeric"===i?void 0:100},fill:{opacity:1},tooltip:{y:{formatter:e=>"numeric"===i?e.toFixed(0):"".concat(e.toFixed(1),"%")},custom:e=>{let{series:t,seriesIndex:a,dataPointIndex:l}=e;const n=s[l],r=t[a][l];return"numeric"===i?'\n <div style="padding: 12px;">\n <div>Value: '.concat(r.toFixed(0),"</div>\n <div>Achieved: ").concat(n.achieved,"</div>\n </div>\n "):'\n <div style="padding: 12px;">\n <div>Value: '.concat(r.toFixed(1),"%</div>\n <div>Achieved: ").concat(n.achieved,"</div>\n <div>Total: ").concat(n.total?n.total:n.kpi_snapshot.max_value||100,"</div>\n </div>\n ")}},legend:{position:"top"}};return(0,P.jsx)("div",{children:(0,P.jsx)(ie.A,{options:r,series:n,type:"line",height:350})})};var ae=i(6268),le=i(5205),ne=i(5185);const re=e=>{let{evidenceDocs:t,t:i,action:s,kpiId:a}=e;
1return(0,P.jsx)("div",{className:"kpi-detail__evidenceAccordion",children:(0,P.jsx)(ee.n,{className:"evidence-accordion",children:(0,P.jsx)(ee.g,{header:(0,P.jsxs)("div",{className:"evidence-accordion-header",children:[(0,P.jsx)("span",{dangerouslySetInnerHTML:{__html:B.cZ}}),(0,P.jsxs)("span",{children:[t.length," ",1===t.length?i?i("document"):"Document":i?i("documents"):"Documents"]})]}),children:(0,P.jsx)("div",{className:"evidence-docs-list",children:t.map(((e,t)=>(0,P.jsxs)("div",{className:"evidence-doc-item cursor-hand",onClick:()=>(e=>{e.id&&s.kpiDashboardActions.tryGettingSignedURL(a,e.id)})(e),children:[(0,P.jsxs)("div",{className:"evidence-doc-info",children:[(0,P.jsx)("div",{className:"evidence-doc-name",children:e.name}),(0,P.jsxs)("div",{className:"evidence-doc-meta",children:[(0,P.jsx)("span",{className:"evidence-doc-type",children:(0,l.QC)(e.mime_type)}),(0,P.jsx)("span",{className:"evidence-doc-separator",children:"|"}),(0,P.jsx)("span",{className:"evidence-doc-date",children:(0,l.po)(e.createdAt,!0)})]})]}),(0,P.jsxs)("div",{className:"kpi-detail__evidenceActions",children:[(0,P.jsx)("button",{className:"kpi-detail__evidenceActionBtn kpi-detail__evidenceActionBtn--download",onClick:t=>((e,t)=>{e.stopPropagation(),t.id&&s.kpiDashboardActions.tryGettingSignedURL(a,t.id,!1)})(t,e),children:(0,P.jsx)("span",{dangerouslySetInnerHTML:{__html:B.Ry}})}),(0,P.jsx)("button",{className:"kpi-detail__evidenceActionBtn kpi-detail__evidenceActionBtn--delete",onClick:t=>((e,t)=>{e.stopPropagation(),t.id&&s.kpiDashboardActions.tryDeletingEvidenceDoc(a,t.id)})(t,e),children:(0,P.jsx)("span",{dangerouslySetInnerHTML:{__html:B.Ec}})})]})]},t)))})})})})},oe=e=>{let{measurements:t,openMeasurementModal:i,action:a,kpiId:n,kpiType:r,t:c,kpiDashboardData:d}=e;const{currentDocURL:u}
1=d,[h,p]=(0,s.useState)(!1),[m,v]=(0,s.useState)(!1),[x,g]=(0,s.useState)({isScrollInProgress:!1,totalDataFetched:!1});(0,s.useEffect)((()=>{null!==u&&void 0!==u&&u.signedURL&&null!==(null===u||void 0===u?void 0:u.signedURL)?v(!0):v(!1)}),[null===u||void 0===u?void 0:u.signedURL]);const k=async()=>{if(!x.isScrollInProgress&&!x.totalDataFetched){g((e=>({...e,isScrollInProgress:!0})));try{var e;const s=await(0,o.tryFetchingKPIMeasurementsUtil)(n,10,t.length);if(s&&(null===s||void 0===s||null===(e=s.measurements)||void 0===e?void 0:e.length)>0){var i;const e=[...t,...s.measurements];a.kpiDashboardActions.updateKPIMeasurements({...s,measurements:e}),(null===s||void 0===s||null===(i=s.measurements)||void 0===i?void 0:i.length)<10?g((e=>({...e,isScrollInProgress:!1,totalDataFetched:!0}))):g((e=>({...e,isScrollInProgress:!1})))}else g((e=>({...e,isScrollInProgress:!1,totalDataFetched:!0})))}catch(s){g((e=>({...e,isScrollInProgress:!1})))}}};return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)("div",{className:"kpi-detail__historyTop",children:[(0,P.jsx)("button",{className:"kpi-detail__linkBtn",type:"button",onClick:()=>p(!0),children:c("viewFullHistory")}),(0,P.jsx)(Z.$,{className:"kpi-detail__ghostBtn",icon:"pi pi-plus",label:c("addMeasurement"),onClick:i&&i,type:"button"})]}),(0,P.jsx)("div",{className:"kpi-detail__list kpi-detail__list--history",children:(0,P.jsx)(ae.A,{onScrollEvent:k,dataFetchingInProgress:x.isScrollInProgress,maxHeight:400,children:(0,P.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:(t||[]).map(((e,t)=>{var i;return(0,P.jsxs)("div",{className:"kpi-detail__historyCard",children:[(0,P.jsxs)("div",{className:"kpi-detail__historyHeader",children:[(0,P.jsx)("div",{className:"kpi-detail__historyDate",children:(0,P.jsx)(ne.A,{dialogHeader:"Select Measurement Date",defaultDate:e.measured_at,onChangeDate:t=>(async(e,t)=>{try{a.kpiDashboardActions.tryUpdatingMeasurementDate(n,t,e)}catch(i){console.error("Error updating measurement date:",i)}})(t,e.id)})}),(0,P.jsxs)("div",{className:"kpi-detail__historyRight",children:[(0,P.jsx)(W,{status:(null===e||void 0===e||null===(i=e.kpi_snapshot)||void 0===i?void 0:i.status)||"off_track",t:c}),(0,P.jsx)("span",{className:"kpi-detail__rowMetric",children:e.achieved||0}),("quantitative"===r||"percentage"===r)&&(0,P.jsx)("span",{className:"kpi-detail__rowPercent",children:e.total?e.total:e.kpi_snapshot.max_value||100})]})]}),(0,P.jsxs)("div",{className:"kpi-detail__historyNote",children:[(0,P.jsx)("i",{className:"pi pi-comment kpi-detail__noteIcon"}),(0,P.jsx)("span",{children:e.comment})]}),e.documents.length>0&&(0,P.jsx)(re,{evidenceDocs:e.documents,t:c,action:a,kpiId:n})]},"".concat(e.date,"-").concat(t))}))})})}),(0,P.jsxs)(te.l,{style:{width:"60vw"},className:"kpi-detail-history-modal bordered-dialogue-header",header:c("measurementHistory"),visible:h,onHide:()=>p(!1),children:[(0,P.jsx)("div",{style:{marginBottom:"16px"},children:(0,P.jsx)(se,{measurements:t,kpiType:r})}),(0,P.jsxs)("div",{className:"kpi-detail-history-header",children:[(0,P.jsx)("span",{children:c("date")}),(0,P.jsx)("span",{children:c("value")}),(0,P.jsx)("span",{children:c("comment")})]}),(0,P.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"12px",overflow:"auto"},children:(0,P.jsx)(ae.A,{onScrollEvent:k,dataFetchingInProgress:x.isScrollInProgress,maxHeight:200,children:(0,P.jsx)("div",{className:"kpi-detail-history-wrapper",children:(t||[]).map(((e,t)=>(0,P.jsxs)("div",{className:"history-row",children:[(0,P.jsx)("span",{children:(0,l.po)(e.createdAt)}),(0,P.jsxs)("div",{className:"vertical-center tl-gap-8",children:["quantitative"===r||"percentage"===r?(0,P.jsxs)("span",{children:[e.achieved," / ",e.total?e.total:e.kpi_snapshot.max_value||100]}):(0,P.jsx)("span",{children:e.achieved}),("quantitative"===r||"percentage"===r)&&(0,P.jsxs)("span",{className:"kpi-detail__rowPercent",children:[(e.achieved/(e.total||e.kpi_snapshot.max_value||100)*100).toFixed(1),"%"]})]}),(0,P.jsx)("span",{children:e.comment})]},"".concat(e.date,"-").concat(t))))})})}),(0,P.jsx)("button",{className:"cancel-cta border-cta tl-mt12",style:{width:"100%"},onClick:()=>{p(!1)},type:"button",children:(0,P.jsx)("span",{children:c("close")})})]}),(0,P.jsx)(te.l,{header:c?c("document"):"Document",visible:m,style:{width:"50vw"},modal:!0,onHide:()=>
1{v(!1),a.kpiDashboardActions.updateCurrentDocViewURL(null)},children:(0,P.jsx)(le.A,{source:(null===u||void 0===u?void 0:u.signedURL)||null})})]})};var ce=i(7935),de=i(5168);const ue=e=>{let{t:t,kpiDashboardData:i,evidenceDocs:a,action:n,id:r}=e;const{documents:c=[]}=a,{currentDocURL:d}=i,[u,h]=(0,s.useState)(!1),[p,m]=(0,s.useState)({isScrollInProgress:!1,totalDataFetched:!1}),v=e=>{if(null!==e&&void 0!==e&&e.length){const t=e.map((e=>({filename:e.fileName.trim(),content_type:e.uploadedFile.type||"application/pdf"})));n.kpiDashboardActions.tryUploadingEvidenceDocs(t,e,r)}};(0,s.useEffect)((()=>{null!==d&&void 0!==d&&d.signedURL&&null!==(null===d||void 0===d?void 0:d.signedURL)?h(!0):h(!1)}),[null===d||void 0===d?void 0:d.signedURL]);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)("div",{children:0===c.length?(0,P.jsxs)("div",{className:"kpi-detail__evidenceEmpty",children:[(0,P.jsx)("div",{className:"kpi-detail__evidenceSub",children:t("evidenceDescription")}),(0,P.jsx)(de.A,{label:"Upload Evidence",className:S()("kpi-detail__ghostBtn","update-btn"),onUploadCTAClick:v})]}):(0,P.jsxs)("div",{className:"kpi-detail__evidenceListWrapper",children:[(0,P.jsxs)("div",{children:[(0,P.jsxs)("span",{className:"kpi-detail__evidenceTitle",children:[t("evidence")," Files"]}),(0,P.jsx)(de.A,{label:"Upload Evidence",className:S()("kpi-detail__ghostBtn","update-btn"),onUploadCTAClick:v})]}),(0,P.jsx)("div",{className:"kpi-detail__evidenceList",children:(0,P.jsx)(ae.A,{onScrollEvent:async()=>{if(!p.isScrollInProgress&&!p.totalDataFetched){m((e=>({...e,isScrollInProgress:!0})));try{var e;const i=await(0,o.tryFetchingEvidenceDocsUtil)(r,10,c.length);if(i&&(null===i||void 0===i||null===(e=i.documents)||void 0===e?void 0:e.length)>0){var t;const e=[...c,...i.documents];n.kpiDashboardActions.updateEvidenceDocs({...i,documents:e}),(null===i||void 0===i||null===(t=i.documents)||void 0===t?void 0:t.length)<10?m((e=>({...e,isScrollInProgress:!1,totalDataFetched:!0}))):m((e=>({...e,isScrollInProgress:!1})))}else m((e=>({...e,isScrollInProgress:!1,totalDataFetched:!0})))}catch(i){m((e=>({...e,isScrollInProgress:!1})))}}},dataFetchingInProgress:p.isScrollInProgress,maxHeight:400,children:(0,P.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:c.map(((e,t)=>(0,P.jsxs)("div",{className:"kpi-detail__evidenceItem cursor-hand",onClick:()=>function(e){e.id&&n.kpiDashboardActions.tryGettingSignedURL(r,e.id)}(e),children:[(0,P.jsxs)("div",{className:"kpi-detail__evidenceFileInfo",children:[(0,P.jsx)("div",{className:"kpi-detail__evidenceFileName",children:e.name}),(0,P.jsxs)("div",{className:"kpi-detail__evidenceFileType",children:[(0,P.jsx)("span",{className:"kpi-detail__evidenceMimeType",children:(0,l.QC)(e.mime_type)}),(0,P.jsx)("span",{className:"kpi-detail__evidenceSeparator",children:"|"}),(0,P.jsx)("span",{className:"kpi-detail__evidenceDate",children:(0,l.po)(e.createdAt,!0)})]})]}),(0,P.jsxs)("div",{className:"kpi-detail__evidenceActions",children:[(0,P.jsx)("button",{className:"kpi-detail__evidenceActionBtn kpi-detail__evidenceActionBtn--download",onClick:t=>((e,t)=>{e.stopPropagation(),t.id&&n.kpiDashboardActions.tryGettingSignedURL(r,t.id,!1)})(t,e),children:(0,P.jsx)("span",{dangerouslySetInnerHTML:{__html:B.Ry}})}),(0,P.jsx)("button",{className:"kpi-detail__evidenceActionBtn kpi-detail__evidenceActionBtn--delete",onClick:t=>((e,t)=>{e.stopPropagation(),t.id&&n.kpiDashboardActions.tryDeletingEvidenceDoc(r,t.id)})(t,e),children:(0,P.jsx)("span",{dangerouslySetInnerHTML:{__html:B.Ec}})})]})]},t)))})})})]})}),(0,P.jsx)(te.l,{header:"Document",visible:u,style:{width:"50vw"},modal:!0,onHide:e=>(h(!1),void n.kpiDashboardActions.updateCurrentDocViewURL(null)),children:(0,P.jsx)(le.A,{source:(null===d||void 0===d?void 0:d.signedURL)||null})})]})};var he=i(9328),pe=i(653),me=i(2401),ve=i(4415);const xe=(0,s.forwardRef)(((e,t)=>{let{onUploadCTAClick:i,showUploadButton:a=!0,uploadButtonLabel:n="Upload",uploadButtonIcon:r="pi pi-check",className:o="",showToast:c=!0}=e;const[d,u]=(0,s.useState)([]),h=(0,s.useRef)(null);(0,s.useImperativeHandle)(t,(()=>({triggerUpload:()=>p(),getSelectedFiles:()=>d||[],clearFiles:()=>u([]),getTransformedFiles:()=>{const e=d||[];return 0===e.length?[]:e.map((e=>
1({fileName:(0,l.jr)(e.name),uploadedFile:e})))}})),[d]);const p=()=>{const e=d||[];if(0===e.length)return void(c&&h.current&&h.current.show({severity:"warn",summary:"No Files Selected",detail:"Please add files before uploading."}));const t=[];e.forEach((e=>{const i={fileName:(0,l.jr)(e.name),uploadedFile:e};t.push(i)})),i&&i(t),u([])};return(0,P.jsxs)("div",{className:o,children:[c&&(0,P.jsx)(ve.y,{ref:h}),(0,P.jsx)(he.e,{name:"files",accept:A.UR.WITH_IMAGE_CONFIG.allowedFileTypesToSelect,multiple:!0,customUpload:!0,auto:!1,chooseLabel:"Add Files",emptyTemplate:(0,P.jsx)("p",{className:"p-m-0",children:"No files selected yet."}),onSelect:e=>{const t=d||[],i=Array.from(e.files).filter((e=>!t.some((t=>t.name===e.name))));if(i.length>0){const e=[...t,...i];u(e),c&&h.current&&h.current.show({severity:"success",summary:"Files Added",detail:"".concat(i.length," file(s) added successfully.")})}else c&&h.current&&h.current.show({severity:"info",summary:"Duplicate Files",detail:"Some files are already selected."})},chooseOptions:{icon:"pi pi-plus",label:"Add Files",className:"custom-choose-btn"},contentStyle:{display:"none"},uploadOptions:{style:{display:"none"}},cancelOptions:{style:{display:"none"}}}),(d||[]).length>0&&(0,P.jsxs)(pe.b,{value:d||[],className:"p-mt-3",header:"Selected Files",children:[(0,P.jsx)(me.V,{field:"name",header:"File Name"}),(0,P.jsx)(me.V,{body:e=>(e=>{if(!e||0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024)),i=parseFloat((e/Math.pow(1024,t)).toFixed(1));return"".concat(i," ").concat(["B","KB","MB","GB"][t])})(e.size),header:"File Size"}),(0,P.jsx)(me.V,{body:e=>(0,P.jsx)(Z.$,{icon:"pi pi-times",className:"p-button-rounded p-button-danger p-button-text",onClick:()=>(e=>{const t=(d||[]).filter((t=>t.name!==e));u(t),c&&h.current&&h.current.show({severity:"info",summary:"File Removed",detail:"".concat(e," has been removed.")})})(e.name),tooltip:"Remove File"}),header:"Actions"})]}),a&&(d||[]).length>0&&(0,P.jsx)("div",{className:"p-d-flex p-jc-end p-mt-3 tl-mt32",children:(0,P.jsx)(Z.$,{label:n,icon:r,onClick:p,disabled:0===(d||[]).length})})]})}));xe.displayName="FileUploadArea";const ge=xe;var ke=i(8295);function je(e){let{leftColumns:t,rightColumns:i,columnRefs:a,kpiRef:l}=e;const[n,r]=(0,s.useState)({width:0,height:0}),[o,c]=(0,s.useState)([]);(0,s.useLayoutEffect)((()=>{if(!l.current)return;const e=l.current.closest(".graph-root");if(!e)return;const s=e.getBoundingClientRect();r({width:s.width,height:s.height});const n=l.current.getBoundingClientRect(),o={x:n.left-s.left,y:n.top-s.top+n.height/2},d={x:n.right-s.left,y:n.top-s.top+n.height/2},u=o.y,h=[],p=(e,t)=>{const i=a.current[e.key];if(!i)return;const l=i.getBoundingClientRect(),n={x:l.left-s.left+l.width/2,y:l.bottom-s.top},r="left"===t?{x:o.x,y:u}:{x:d.x,y:u};h.push({side:t,start:n,end:r,laneY:u})};t.forEach((e=>
1p(e,"left"))),i.forEach((e=>p(e,"right"))),c(h)}),[t,i]);const d=Math.max(1,n.width+48),u=Math.max(1,n.height+48);return(0,P.jsxs)("svg",{className:"edges-layer",width:n.width,height:n.height,viewBox:"".concat(-24," ").concat(-24," ").concat(d," ").concat(u),preserveAspectRatio:"none",children:[(0,P.jsx)("defs",{children:(0,P.jsx)("marker",{id:"arrowSmall",markerWidth:"8",markerHeight:"8",viewBox:"0 0 8 8",refX:"10",refY:"4",orient:"auto-start-reverse",markerUnits:"strokeWidth",children:(0,P.jsx)("path",{d:"M 0 0 L 8 4 L 0 8 z",fill:"#8B5CF6"})})}),o.map(((e,t)=>{const i=function(e,t,i,s){const a=16,l=e.x,n=e.y,r=i,o=r-a,c="left"===s?t.x-a:t.x+a,d="left"===s?1:-1;return["M ".concat(l," ").concat(n),"L ".concat(l," ").concat(o),"Q ".concat(l," ").concat(r," ").concat(l+d*a," ").concat(r),"L ".concat(c," ").concat(r),"Q ".concat(t.x," ").concat(r," ").concat(t.x," ").concat(t.y)].join(" ")}(e.start,e.end,e.laneY,e.side);return(0,P.jsx)("path",{d:i,stroke:"#8B5CF6",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",markerEnd:"url(#arrowSmall)"},t)})),o.map(((e,t)=>(0,P.jsx)("circle",{cx:e.start.x,cy:e.start.y,r:"4",fill:"#fff",stroke:"#8B5CF6",strokeWidth:"1.5"},"dot-".concat(t))))]})}const fe={soas:{header:"#7C3AED",bg:"#F5F3FF",border:"#7C3AED"},policies:{header:"#2563EB",bg:"#EFF6FF",border:"#2563EB"},assets:{header:"#2563EB",bg:"#EFF6FF",border:"#2563EB"},incidents:{header:"#0891B2",bg:"#ECFEFF",border:"#0891B2"},risks:{header:"#7C3AED",bg:"#F5F3FF",border:"#7C3AED"},controls:{header:"#9333EA",bg:"#FAF5FF",border:"#9333EA"}};function ye(e){let{label:t,items:i,icon:s,colKey:a}=e;const l=fe[a]||fe.assets;return(0,P.jsxs)("div",{className:"column",style:{background:l.bg,borderLeft:"3px solid ".concat(l.border)},children:[(0,P.jsxs)("div",{className:"column-header",style:{color:l.header},children:[s&&(0,P.jsx)("span",{className:"column-icon",dangerouslySetInnerHTML:{__html:s}}),(0,P.jsx)("span",{children:t.toUpperCase()})]}),(0,P.jsx)("div",{className:"column-cards",children:i.map((e=>(0,P.jsx)("div",{className:"column-card",children:e.label},e.id)))})]})}function Ne(e){let{children:t}=e;const i=(0,s.useRef)(null),a=(0,s.useRef)(null),l=(0,s.useRef)({x:0,y:0}),n=(0,s.useRef)({x:0,y:0}),r=(0,s.useRef)(1);(0,s.useLayoutEffect)((()=>{const e=a.current,t=i.current;if(!e||!t)return;const s=e.getBoundingClientRect(),n=t.getBoundingClientRect();l.current={x:(s.width-n.width)/2,y:40},o()}),[]);const o=()=>{i.current.style.transform="translate(".concat(l.current.x,"px, ").concat(l.current.y,"px) scale(").concat(r.current,")")},c=e=>{const t=a.current;if(!t)return;const i=t.getBoundingClientRect(),s=i.width/2,n=i.height/2,o=r.current;let c="in"===e?o+.15:o-.15;c=Math.min(Math.max(c,.6),2);const d=c/o;l.current.x=s-(s-l.current.x)*d,l.current.y=n-(n-l.current.y)*d,r.current=c,u()},d=e=>{l.current={x:e.clientX-n.current.x,y:e.clientY-n.current.y},u()},u=()=>{const e=a.current,t=i.current;if(!e||!t)return;const s=e.getBoundingClientRect(),n=t.offsetWidth,c=t.offsetHeight,d=n*r.current,u=c*r.current;let h,p,m,v;d<=s.width?h=p=(s.width-d)/2:(h=s.width-d-100,p=100),u<=s.height?m=v=(s.height-u)/2:(m=s.height-u-100,v=100),l.current.x=Math.min(p,Math.max(h,l.current.x)),l.current.y=Math.min(v,Math.max(m,l.current.y)),o()},h=()=>{window.removeEventListener("mousemove",d),window.removeEventListener("mouseup",h)};return(0,P.jsxs)("div",{ref:a,className:"pan-root",onMouseDown:e=>{n.current={x:e.clientX-l.current.x,y:e.clientY-l.current.y},window.addEventListener("mousemove",d),window.addEventListener("mouseup",h)},children:[(0,P.jsx)("div",{ref:i,className:"pan-inner",style:{transformOrigin:"0 0"},children:t}),(0,P.jsxs)("div",{className:"pan-zoom",children:[(0,P.jsx)("span",{onClick:()=>c("in"),dangerouslySetInnerHTML:{__html:B.sj}}),(0,P.jsx)("span",{onClick:()=>c("out"),dangerouslySetInnerHTML:{__html:B.rt}})]})]})}function be(e){let{kpiData:t}=e;return(0,P.jsxs)("div",{className:"kpi-node",children:[(0,P.jsx)("div",{className:"kpi-title",children:null===t||void 0===t?void 0:t.name}),(0,P.jsxs)("div",{className:"kpi-status",children:[(null===t||void 0===t?void 0:t.status)&&(0,P.jsx)(W,{status:null===t||void 0===t?void 0:t.status}),(null===t||void 0===t?void 0:t.measurement_status)&&(0,P.jsx)(W,{status:null===t||void 0===t?void 0:t.measurement_status})]})]})}function _e(e){let{kpiAssociatedItems:t,kpiData:i}=e;const a=(0,s.useRef)({}),l=(0,s.useRef)(null),n=(0,s.useMemo)((()=>t.map((e=>({key:e.key,label:e.label,icon:e.icon,items:e.values.map((t=>({id:t.id,label:t[e.displayValueKey]})))})))),[t]),r=Math.ceil(n.length/2),o=n.slice(0,r),c=n.slice(r);return(0,P.jsx)(Ne,{children:(0,P.jsxs)("div",{className:"graph-root",children:[(0,P.jsx)("div",{className:"columns-row",children:n.map((e=>(0,P.jsx)("div",{ref:t=>a.current[e.key]=t,children:(0,P.jsx)(ye,{...e,colKey:e.key})},e.key)))}),(0,P.jsx)("div",{className:"kpi-row",children:(0,P.jsx)("div",{ref:l,children:(0,P.jsx)(be,{kpiData:i})})}
1),(0,P.jsx)(je,{leftColumns:o,rightColumns:c,columnRefs:a,kpiRef:l})]})})}function Te(e){const{linkingItems:t,header:i,itemTemplate:a,defaultOpen:l}=e,[n,r]=(0,s.useState)(l||!1),o=(0,s.useRef)(null);return console.log(t,"children"),(0,s.useEffect)((()=>{n&&setTimeout((()=>o.current.scrollIntoView({behavior:"smooth",block:"start"})),200)}),[n]),(0,P.jsxs)("div",{className:"tree-node",ref:o,children:[(0,P.jsx)("div",{className:"tree-node-wrapper",children:(0,P.jsx)("div",{className:"tree-header-node cursor-hand",onClick:()=>r(!n),children:(0,P.jsxs)("div",{className:"tree-associated-header",children:[(0,P.jsx)("div",{className:"tree-header-title",children:i}),(0,P.jsx)("span",{className:"accordian-angle-icon ".concat(n?'rotate-n-90"':"rotate-90"," cursor-hand"),dangerouslySetInnerHTML:{__html:B.rO}})]})})}),n&&(null===t||void 0===t?void 0:t.length)>0&&(0,P.jsx)("div",{className:"tree-node-children ".concat(n?"open":""),children:null===t||void 0===t?void 0:t.map(((e,t)=>(0,P.jsx)("div",{className:"tree-node-wrapper tree-node-child",children:(0,P.jsx)("div",{className:"tree-child",children:a(e)})},t)))})]})}function we(e){const{data:t=[],kpiData:i,t:a}=e,[n,r]=(0,s.useState)(!1),o=(0,l.qz)();return(0,P.jsxs)("div",{className:"kpi-associated-wrapper",children:[(0,P.jsxs)("div",{className:"kpi-items-header",children:[(0,P.jsx)("h4",{children:a("associatedItems")}),(0,P.jsx)(ke.A,{btnText:a("viewGraph"),isInactive:!1,onBtnClick:()=>r(!0)})]}),(0,P.jsx)("div",{className:"kpi-associated-list",children:null===t||void 0===t?void 0:t.map((e=>(0,P.jsx)(Te,{linkingItems:null===e||void 0===e?void 0:e.values,header:(0,P.jsxs)("div",{className:"kpi-item-header",children:[(0,P.jsx)("span",{dangerouslySetInnerHTML:{__html:null===e||void 0===e?void 0:e.icon}}),(0,P.jsx)("span",{className:"tl-text14 tl-f500 ",children:a(null===e||void 0===e?void 0:e.label)})]}),itemTemplate:t=>{var i,s;return(0,P.jsx)("span",{className:"tl-text14",children:"sequence"===(null===e||void 0===e?void 0:e.displayValueKey)?"".concat(null===t||void 0===t?void 0:t.sequence," - ").concat((null===t||void 0===t||null===(i=t.title)||void 0===i?void 0:i[o])||(null===t||void 0===t||null===(s=t.title)||void 0===s?void 0:s.default)):null===t||void 0===t?void 0:t[null===e||void 0===e?void 0:e.displayValueKey]})}},null===e||void 0===e?void 0:e.key)))}),(0,P.jsx)(te.l,{style:{width:"60vw"},header:(0,P.jsxs)("div",{className:"kpi-graph-dialogue-header",children:[(0,P.jsx)("span",{className:"tl-f700 tl-text20",children:"KPI Relationship Graph"}),(0,P.jsx)("span",{className:"tl-636874 tl-text14",children:"View and navigate through items connected to this KPI."})]}),className:"bordered-dialogue-header",visible:n,onHide:()=>r(!1),children:(0,P.jsx)(_e,{kpiAssociatedItems:t,kpiData:i})})]})}const De=e=>{let{activeTab:t,onChange:i,t:s}=e;return(0,P.jsxs)("div",{className:"kpi-detail__tabs",children:[(0,P.jsx)("button",{className:S()("kpi-detail__tab",{"is-active":1===t}),onClick:()=>i(1),type:"button",children:s("overview")}),(0,P.jsx)("button",{className:S()("kpi-detail__tab",{"is-active":2===t}),onClick:()=>i(2),type:"button",children:s("history")}),(0,P.jsx)("button",{className:S()("kpi-detail__tab",{"is-active":3===t}),onClick:()=>i(3),type:"button",children:s("evidence")})]})};let Ie=[{label:"soas",key:"soas",values:null,displayValueKey:"sequence",icon:B.Qe},{label:"policies",key:"policies",values:null,displayValueKey:"name",icon:B.jh},{label:"assets",key:"assets",values:null,displayValueKey:"name",icon:B.KA},{label:"incidents",key:"incidents",values:null,displayValueKey:"title",icon:B.Tn},{label:"risks",key:"risks",values:null,displayValueKey:"identifier",icon:B.g1}];function Ae(e){var t,i,n,o,c,d,u,h,m,v,x;const{id:g}=(0,a.g)(),k=(0,a.Zp)(),{action:j,kpiDashboardData:f,t:y}=e,{kpiDetails:N,kpiMeasurements:b,evidenceDocs:_}=f;console.log({kpiDetails:N,kpiAssociatedItems:Ie});const[T,w]=(0,s.useState)(!1),[D,I]=(0,s.useState)({achieved:"",total:"",comment:"",measured_at:new Date}),[A,F]=(0,s.useState)({showModal:!1,kpi:null}),[C,L]=(0,s.useState)({}),[S,E]=(0,s.useState)(!1),M=(0,s.useRef)(null);Ie=(0,s.useMemo)((()=>Ie.map((e=>{const{key:t}=e;return e.values=N[t]||[],e}))),[N]);(0,r.wA)();(0,s.useEffect)((()=>
1{g&&(j.kpiDashboardActions.tryFetchingKPIDetails(g),j.kpiDashboardActions.tryFetchingKPIMeasurements(g),j.kpiDashboardActions.tryFetchingEvidenceDocs(g))}),[g]);const[R,q]=(0,s.useState)(1),V=()=>(0,P.jsxs)("div",{className:"breadcrumb-wrapper breadcrumb-position tl-ml12",children:[(0,P.jsx)("span",{className:"breadcrumb-angle-icon cursor-hand",onClick:()=>k("/kpi-dashboard"),dangerouslySetInnerHTML:{__html:B.ak}}),(0,P.jsx)("span",{className:"line"}),(0,P.jsxs)("div",{className:"item-wrapper",children:[(0,P.jsx)("span",{className:"cursor-hand",onClick:()=>k("/kpi-dashboard"),children:y("kpiDashboard")}),(0,P.jsx)("span",{className:"angle-icon-right",dangerouslySetInnerHTML:{__html:B.rO}}),(0,P.jsx)("span",{className:"active-page",children:(null===N||void 0===N?void 0:N.name)||"Detail Page"})]})]});return(0,P.jsxs)("div",{className:"kpi-detail-wrapper",children:[(0,P.jsx)(V,{}),f.fetchingKpiDetails&&(0,P.jsx)("div",{className:"transform-to-center ",children:(0,P.jsx)(ce.p,{})}),(0,P.jsxs)("div",{className:"kpi-detail-content-wrapper",children:[(0,P.jsxs)("div",{className:"kpi-detail__header",children:[(0,P.jsxs)("div",{className:"kpi-detail__titleRow",children:[(0,P.jsx)("h1",{className:"kpi-detail__title",children:null===N||void 0===N?void 0:N.name}),(0,P.jsx)(W,{status:null===N||void 0===N?void 0:N.status,t:y})]}),(0,P.jsx)("div",{className:"kpi-detail__headerActions",children:!(null!==f&&void 0!==f&&f.fetchingKpiDetails)&&(0,P.jsx)("button",{className:"kpi-detail__iconBtn",type:"button","aria-label":"More",children:(H=N,(0,P.jsx)(P.Fragment,{children:(0,P.jsx)("div",{className:"option-menu-wrapper p-relative",onClick:e=>e.stopPropagation(),children:(0,P.jsxs)("div",{className:"dropdown-container",tabIndex:"-1",children:[(0,P.jsx)("div",{className:"fa fa-ellipsis-h cursor-hand tl-636874 rotate-90"}),(0,P.jsxs)("div",{className:"dropdown updated-dropdown",children:[(0,P.jsxs)("div",{className:"vertical-center cursor-hand",onClick:()=>(e=>{null!==e&&void 0!==e&&e.id&&k("/kpi-dashboard/".concat(e.id,"/edit"))})(H),children:[(0,P.jsx)("span",{className:"tl-636874 tl-mt4 tc tl-mr8 tl-ml4",dangerouslySetInnerHTML:{__html:B.ac}}),(0,P.jsx)("span",{className:"tc tl-text14 tl-fsn",children:y("edit")})]}),(0,P.jsxs)("div",{className:"vertical-center cursor-hand",onClick:()=>(e=>{null!==e&&void 0!==e&&e.id&&F((t=>({...t,showModal:!0,kpi:e})))})(H),children:[(0,P.jsx)("span",{className:"tl-636874 tc tl-ml4 tl-mt4 tl-mr8",dangerouslySetInnerHTML:{__html:B.hd}}),(0,P.jsx)("span",{className:"tc tl-text14 tl-fsn",children:y("delete")})]})]})]})})}))})})]}),(0,P.jsxs)("div",{className:"kpi-detail__metaCard ".concat((null===(t=U(y)[null===N||void 0===N?void 0:N.measurement_status])||void 0===t?void 0:t.text)===(y?y("overdue"):"Overdue")?"overdue":""),children:[(0,P.jsxs)("div",{className:"kpi-detail__metaTop",children:[(0,P.jsx)(W,{status:null===N||void 0===N?void 0:N.measurement_status,t:y}),(0,P.jsx)(Z.$,{className:"kpi-detail__primaryBtn ".concat((null===(i=U(y)[null===N||void 0===N?void 0:N.measurement_status])||void 0===i?void 0:i.text)===(y?y("overdue"):"Overdue")?"overdue":""),icon:"pi pi-plus",label:y("addMeasurement"),onClick:()=>w(!0),type:"button"})]}),(0,P.jsxs)("div",{className:"kpi-detail__metaGrid",children:[(0,P.jsxs)("div",{className:"kpi-detail__metaItem",children:[(0,P.jsxs)("div",{className:"kpi-detail__metaLabel",children:[y("frequency"),":"]}),(0,P.jsx)("div",{className:"kpi-detail__metaValue",children:p(null===N||void 0===N?void 0:N.frequency,y)})]}),(0,P.jsxs)("div",{className:"kpi-detail__metaItem",children:[(0,P.jsxs)("div",{className:"kpi-detail__metaLabel",children:[y("lastMeasured"),":"]}),(0,P.jsxs)("div",{className:"kpi-detail__metaValue",children:[(0,P.jsx)("span",{children:(0,l.po)(null===N||void 0===N?void 0:N.last_measured_at)}),(0,P.jsx)("span",{className:"tl-ml8 ".concat("Overdue"===(null===(n=U[null===N||void 0===N?void 0:N.measurement_status])||void 0===n?void 0:n.text)?"overdue":""),children:null!=(null===N||void 0===N||null===(o=N.latest_measurement)||void 0===o?void 0:o.measured_ago_days)?"(".concat(N.latest_measurement.measured_ago_days," ").concat(y("days")," ").concat(y("ago"),")"):"NA"})]})]}),(0,P.jsxs)("div",{className:"kpi-detail__metaItem",children:[(0,P.jsxs)("div",{className:"kpi-detail__metaLabel",children:[y("nextDue"),":"]}),(0,P.jsxs)("div",{className:"kpi-detail__metaValue",children:[(0,P.jsx)("span",{children:(0,l.po)(null===N||void 0===N?void 0:N.next_due_at)}),(0,P.jsx)("span",{className:"tl-ml8 ".concat((null===(c=U(y)[null===N||void 0===N?void 0:N.measurement_status])||void 0===c?void 0:c.text)===(y?y("overdue"):"Overdue")?"overdue":""),children:(null===N||void 0===N||null===(d=N.latest_measurement)||void 0===d?void 0:d.overdue_days)>=0?"(".concat(null===N||void 0===N||null===(u=N.latest_measurement)||void 0===u?void 0:u.overdue_days," ").concat(y("daysOverdue"),")"):""})]})]})]})]}),(0,P.jsxs)("div",{className:"kpi-detail__section",children:[(0,P.jsx)("h2",{className:"kpi-detail__sectionTitle",children:y("definition")}),(0,P.jsxs)("div",{className:"kpi-detail__definitionGrid",children:[(0,P.jsxs)("div",{className:"kpi-detail__defItem kpi-detail__defItem--wide",children:[(0,P.jsxs)("div",{className:"kpi-detail__defLabel",children:[y("description"),":"]}),(0,P.jsx)("div",{className:"kpi-detail__defValue",dangerouslySetInnerHTML:{__html:(null===N||void 0===N||null===(h=N.description)||void 0===h?void 0:h.replace(/\n/g,"<br />"))||""}})]}),(0,P.jsxs)("div",{className:"kpi-detail__defItem",children:[(0,P.jsxs)("div",{className:"kpi-detail__defLabel",children:[y("type"),":"]}),(0,P.jsx)("div",{className:"kpi-detail__defValue",children:y(null===N||void 0===N?void 0:N.type)||"NA"})]}),(0,P.jsxs)("div",{className:"kpi-detail__defItem",children:[(0,P.jsxs)("div",{className:"kpi-detail__defLabel",children:[y("frequency"),":"]}),(0,P.jsx)("div",{className:"kpi-detail__defValue",children:p(null===N||void 0===N?void 0:N.frequency,y)||"NA"})]}),(0,P.jsxs)("div",{className:"kpi-detail__defItem",children:[(0,P.jsxs)("div",{className:"kpi-detail__defLabel",children:[y("owner"),":"]}),(0,P.jsx)("div",{className:"kpi-detail__defValue",children:null!==N&&void 0!==N&&N.owners&&N.owners.length>0?N.owners.length>3?"".concat(N.owners.slice(0,3).map((e=>e.name)).join(", ")," +").concat(N.owners.length-3," more"):N.owners.map((e=>e.name)).join(", "):"NA"})]}),(0,P.jsxs)("div",{className:"kpi-detail__defItem",children:[(0,P.jsxs)("div",{className:"kpi-detail__defLabel",children:[y("deviationType"),":"]}),(0,P.jsx)("div",{className:"kpi-detail__defValue",children:y(null===N||void 0===N?void 0:N.deviation_type)})]}),(0,P.jsxs)("div",{className:"kpi-detail__defItem",children:[(0,P.jsxs)("div",{className:"kpi-detail__defLabel",children:[y("lastUpdated"),":"]}),(0,P.jsx)("div",{className:"kpi-detail__defValue",children:(0,l.po)(null===N||void 0===N?void 0:N.last_updated_at)})]})]})]}),(0,P.jsx)(De,{activeTab:R,onChange:q,t:y}),1===R&&(0,P.jsx)(J,{currentValue:null==(null===N||void 0===N?void 0:N.status)?y("notYetMeasured"):"quantitative"===(null===N||void 0===N?void 0:N.type)||"percentage"===(null===N||void 0===N?void 0:N.type)?"".concat(Number((null===N||void 0===N||null===(m=N.latest_measurement)||void 0===m?void 0:m.achieved)||0)," / ").concat(Number((null===N||void 0===N||null===(v=N.latest_measurement)||void 0===v?void 0:v.total)||(null===N||void 0===N?void 0:N.max_value)||100)):"".concat(Number((null===N||void 0===N||null===(x=N.latest_measurement)||void 0===x?void 0:x.achieved)||0)),targetValue:parseInt((null===N||void 0===N?void 0:N.target)||0),measurements:(null===b||void 0===b?void 0:b.measurements)||[],onChangeTab:()=>q(2),kpiType:null===N||void 0===N?void 0:N.type,t:y}),2===R&&(0,P.jsx)(oe,{measurements:null===b||void 0===b?void 0:b.measurements,openMeasurementModal:()=>w(!0),action:j,kpiId:g,kpiType:null===N||void 0===N?void 0:N.type,t:y,kpiDashboardData:f}),3===R&&(0,P.jsx)(ue,{t:y,evidenceDocs:_,kpiDashboardData:f,action:j,id:g})]}),(0,P.jsxs)("div",{className:"kpi-detail-preview-wrapper",children:[(0,P.jsx)("span",{className:"title",children:y("dashboardPreview")}),(0,P.jsxs)("div",{className:"preview-content scrollbar-hide",children:[(0,P.jsx)(z,{kpi:N,optionMenuTemplate:{},isListing:!0,hasOptionTemplate:!1,className:"update-card",t:y}),(0,P.jsx)("div",{className:"kpi-associated-items-wrapper",children:(0,P.jsx)(we,{data:Ie,kpiData:N,t:y})})]})]}),(0,P.jsxs)(te.l,{style:{width:"35vw"},header:y("addMeasurement"),className:"bordered-dialogue-header",visible:T,onHide:()=>w(!1),children:[C.general&&(0,P.jsx)("div",{className:"error-message",style:{marginBottom:"1rem",padding:"0.5rem",backgroundColor:"#ffebee",color:"#c62828",borderRadius:"4px"},children:C.general}),(0,P.jsxs)("div",{className:"form-grid ".concat("quantitative"!==(null===N||void 0===N?void 0:N.type)?"single-input"
1:""),children:[(0,P.jsxs)("div",{style:"quantitative"!==(null===N||void 0===N?void 0:N.type)?{gridColumn:"1 / -1"}:{},children:[(0,P.jsx)("span",{children:"quantitative"===(null===N||void 0===N?void 0:N.type)?y("achievedX"):y("achievedX").replace(" (X)","")}),(0,P.jsx)("input",{type:"number",className:"common-input update-bg-color ".concat(C.achieved?"error-input":""),placeholder:y("enterValue"),value:D.achieved,onChange:e=>I({...D,achieved:e.target.value}),disabled:S}),C.achieved&&(0,P.jsx)("p",{className:"error-text tl-text12",children:C.achieved})]}),"quantitative"===(null===N||void 0===N?void 0:N.type)&&(0,P.jsxs)("div",{children:[(0,P.jsx)("span",{children:y("totalY")}),(0,P.jsx)("input",{type:"number",className:"common-input update-bg-color ".concat(C.total?"error-input":""),placeholder:y("enterValue"),value:D.total,onChange:e=>I({...D,total:e.target.value}),disabled:S}),C.total&&(0,P.jsx)("p",{className:"error-text tl-text12",children:C.total})]})]}),(0,P.jsxs)("div",{className:"d-flex flex-d-column tl-gap-8",children:[(0,P.jsx)("span",{className:"form-label",children:y("commentRequired")}),(0,P.jsx)("textarea",{className:"common-input update-bg-color description-textarea ".concat(C.comment?"error-input":""),placeholder:y("enterNotesAboutMeasurement"),value:D.comment,onChange:e=>I({...D,comment:e.target.value}),disabled:S}),C.comment&&(0,P.jsx)("span",{className:"error-text tl-text12",children:C.comment})]}),(0,P.jsxs)("div",{className:"d-flex flex-d-column tl-gap-8 tl-mt8",children:[(0,P.jsx)("span",{className:"form-label",children:"Measurement Date"}),(0,P.jsx)(ne.A,{dialogHeader:"Select Measurement Date",defaultDate:D.measured_at,onChangeDate:e=>I((t=>({...t,measured_at:e})))})]}),(0,P.jsxs)("div",{className:"d-flex flex-d-column tl-gap-8 tl-mt12",children:[(0,P.jsx)("span",{className:"form-label",children:"Evidence (optional)"}),(0,P.jsx)(ge,{ref:M,showUploadButton:!1,className:"file-upload-area"})]}),(0,P.jsxs)("div",{className:"d-flex tl-mt20 justify-content-space-between",children:[(0,P.jsx)("button",{className:"cancel-cta border-cta",style:{width:"48%"},onClick:()=>{w(!1),I({achieved:"",total:"",comment:"",measured_at:null}),L({})},disabled:S,children:(0,P.jsx)("span",{children:y("cancel")})}),(0,P.jsx)("button",{onClick:async()=>{var e;L({});const t={};if((!D.achieved||parseFloat(D.achieved)<0)&&(t.achieved="Achieved value is required and must be positive"),"quantitative"===(null===N||void 0===N?void 0:N.type)&&(!D.total||parseFloat(D.total)<=0)&&(t.total="Total value is required and must be greater than 0"),null!==(e=D.comment)&&void 0!==e&&e.trim()||(t.comment="Comment is required"),Object.keys(t).length>0)L(t);else if(g)try{E(!0);const e={achieved:parseFloat(D.achieved),comment:D.comment.trim(),measured_at:D.measured_at};"quantitative"===(null===N||void 0===N?void 0:N.type)&&(e.total=parseFloat(D.total));let t=[];if(M.current){t=M.current.getTransformedFiles();const i=t.map((e=>({filename:e.fileName.trim(),content_type:e.uploadedFile.type||"application/pdf"})));t.length>0&&(e.docs=i)}const i=await j.kpiDashboardActions.tryAddingMeasurement(g,e,t);i&&200===i.code&&(w(!1),I({achieved:"",total:"",comment:""}),M.current.clearFiles())}catch(i){console.error("Error adding measurement:",i),L({general:"Failed to add measurement. Please try again."})}finally{E(!1)}else L({general:"KPI ID is not available"})},className:"blue-cta",style:{width:"48%"},disabled:S,children:(0,P.jsx)("span",{children:y(S?"saving":"saveMeasurement")})})]})]}),(0,P.jsxs)(te.l,{style:{width:"35vw"},className:"kpi-delete-modal bordered-dialogue-header",header:y("deleteKPI"),visible:A.showModal,modal:!0,onHide:()=>F((e=>({...e,showModal:!1,kpi:null}))),children:[(0,P.jsx)("div",{className:"flex-center flex-d-column tl-gap-8 tl-mt16",children:(0,P.jsx)("span",{className:"tl-text16 tl-1F1F1F tl-fsn tl-fnormal",children:y("deleteKPIConfirm")})}),(0,P.jsxs)("div",{className:"button-container d-flex tl-mt24 tl-gap-16",children:[(0,P.jsxs)("div",{className:"cancel-cta tl-text14 tl-mt8 w-100",style:{width:"100%"},onClick:()=>F((e=>({...e,showModal:!1,kpi:null}))),type:"button",children:[(0,P.jsx)("span",{className:"tl-mt4",dangerouslySetInnerHTML:{__html:B.Pp}}),(0,P.jsx)("span",{className:"tl-ml4",children:y("cancel")})]}),(0,P.jsxs)("div",{className:"flex-center tl-mt8 tl-mb8 delete-btn w-100 cursor-hand",onClick:()=>{var e;null!==(e=A.kpi)&&void 0!==e&&e.id&&(j.kpiDashboardActions.tryDeletingKPI(A.kpi.id),F((e=>({...e,showModal:!1,kpi:null}))),k("/kpi-dashboard"))},style:{width:"100%"},type:"button",children:[(0,P.jsx)("span",{className:"ibm tc tl-mr4 tl-mt4",dangerouslySetInnerHTML:{__html:B.hd}}),(0,P.jsx)("span",{className:"ibm tc tl-text14 tl-fsn",children:y("delete")})]})]})]})]});var H}var Fe=i(2591),Ce=i(1639);const Le=()=>(0,P.jsxs)("div",{className:"kpi-card kpi-card-skeleton",children:[(0,P.jsxs)("div",{className:"vertical-center justify-content-space-between",style:{marginBottom:"12px"},children:[(0,P.jsx)(Ce.E,{width:"65%",height:"1.125rem"}),(0,P.jsx)(Ce.E,{shape:"circle",size:"1.5rem"})]}),(0,P.jsxs)("div",{className:"kpi-status-wrapper",style:{marginBottom:"16
1px",display:"flex",gap:"8px"},children:[(0,P.jsx)(Ce.E,{width:"4.5rem",height:"1.5rem",borderRadius:"0.75rem"}),(0,P.jsx)(Ce.E,{width:"5rem",height:"1.5rem",borderRadius:"0.75rem"})]}),(0,P.jsx)("div",{style:{marginBottom:"16px",display:"flex",justifyContent:"center"},children:(0,P.jsx)(Ce.E,{shape:"circle",size:"8rem"})}),(0,P.jsxs)("div",{className:"kpi-footer-wrapper",style:{display:"flex",justifyContent:"space-between"},children:[(0,P.jsxs)("div",{className:"kpi-footer-item",style:{display:"flex",flexDirection:"column",gap:"4px"},children:[(0,P.jsx)(Ce.E,{width:"5rem",height:"0.75rem"}),(0,P.jsx)(Ce.E,{width:"4rem",height:"0.875rem"})]}),(0,P.jsxs)("div",{className:"kpi-footer-item",style:{display:"flex",flexDirection:"column",gap:"4px",alignItems:"flex-end"},children:[(0,P.jsx)(Ce.E,{width:"2rem",height:"0.75rem"}),(0,P.jsx)(Ce.E,{width:"4.5rem",height:"0.875rem"})]})]})]}),Se=e=>{let{count:t=6}=e;return(0,P.jsx)("div",{className:"kpi-listing-wrapper",children:Array.from({length:t},((e,t)=>(0,P.jsx)(Le,{},"skeleton-".concat(t))))})},Pe=e=>{var t;const{kpiDashboardData:i,action:l,t:n}=e,{kpisList:c,fetchingKpisList:d}
1=i,u=(0,a.Zp)(),[h,p]=(0,s.useState)(0),[m,v]=(0,s.useState)({isScrollInProgress:!1,totalDataFetched:!1,showDeleteModal:!1,kpiToDelete:null}),x=(0,r.wA)(),[g,k]=(0,s.useState)({active:0,archived:0});(0,s.useEffect)((()=>{l.kpiDashboardActions.tryFetchingKPIs()}),[]),(0,s.useEffect)((()=>{c&&k({active:c.active_count||0,archived:c.archived_count||0})}),[c]);const j=()=>(0,P.jsxs)("div",{className:"kpi-header",children:[(0,P.jsxs)(Fe.J,{className:"kpi-tab-view",activeIndex:h,onTabChange:e=>{return t=e.index,p(t),v({isScrollInProgress:!1,totalDataFetched:!1}),void l.kpiDashboardActions.tryFetchingKPIs(A.L9,0,1===t);var t},children:[(0,P.jsx)(Fe.K,{header:n("activeKPI")+" (".concat(g.active,")")}),(0,P.jsx)(Fe.K,{header:n("archive")+" (".concat(g.archived,")")})]}),(0,P.jsx)("button",{className:"light-blue-cta no-border",onClick:()=>u("/kpi-dashboard/create"),children:(0,P.jsxs)("span",{children:["+ ",n("createKPI")]})})]}),f=e=>(0,P.jsx)(P.Fragment,{children:(0,P.jsx)("div",{className:"option-menu-wrapper p-relative tl-ml16",onClick:e=>e.stopPropagation(),children:(0,P.jsxs)("div",{className:"dropdown-container",tabIndex:"-1",children:[(0,P.jsx)("div",{className:"fa fa-ellipsis-h cursor-hand tl-636874 rotate-90"}),(0,P.jsxs)("div",{className:"dropdown updated-dropdown",children:[(0,P.jsxs)("div",{className:"vertical-center cursor-hand",onClick:()=>(e=>{null!==e&&void 0!==e&&e.id&&(u("/kpi-dashboard/".concat(e.id,"/edit")),x((0,o.updateKPIDetails)({})))})(e),children:[(0,P.jsx)("span",{className:"tl-636874 tl-mt4 tc tl-mr8 tl-ml4",dangerouslySetInnerHTML:{__html:B.ac}}),(0,P.jsx)("span",{className:"tc tl-text14 tl-fsn",children:n("edit")})]}),0===h&&(0,P.jsxs)("div",{className:"vertical-center cursor-hand",onClick:()=>(e=>{null!==e&&void 0!==e&&e.id&&v((t=>({...t,showDeleteModal:!0,kpiToDelete:e})))})(e),children:[(0,P.jsx)("span",{className:"tl-636874 tc tl-ml4 tl-mt4 tl-mr8",dangerouslySetInnerHTML:{__html:B.hd}}),(0,P.jsx)("span",{className:"tl-636874 tc tl-text14 tl-fsn",children:n("delete")})]})]})]})})});return(0,P.jsxs)("div",{className:"kpi-listing-container",children:[(0,P.jsx)(j,{}),(0,P.jsx)(P.Fragment,{children:(0,P.jsx)("div",{className:"kpi-listing-main-wrapper",children:(0,P.jsx)(ae.A,{onScrollEvent:async()=>{if(!m.isScrollInProgress&&!m.totalDataFetched){v((e=>({...e,isScrollInProgress:!0})));try{var e,t,i;const s=await(0,o.tryFetchingKPIsUtil)(10,(null===c||void 0===c||null===(e=c.kpis)||void 0===e?void 0:e.length)||0,1===h);if((null===s||void 0===s||null===(t=s.kpis)||void 0===t?void 0:t.length)>0){const e=[...(null===c||void 0===c?void 0:c.kpis)||[],...s.kpis];l.kpiDashboardActions.updateKPIList({...s,kpis:e})}((null===s||void 0===s||null===(i=s.kpis)||void 0===i?void 0:i.length)||0)<10?v((e=>({...e,totalDataFetched:!0,isScrollInProgress:!1}))):v((e=>({...e,isScrollInProgress:!1})))}catch(s){v((e=>({...e,isScrollInProgress:!1})))}}},dataFetchingInProgress:m.isScrollInProgress,maxHeight:700,children:!d||null!==c&&void 0!==c&&c.kpis&&0!==c.kpis.length?(0,P.jsx)("div",{className:"kpi-listing-wrapper",children:null===c||void 0===c||null===(t=c.kpis)||void 0===t?void 0:t.map((e=>(0,P.jsx)(z,{kpi:e,optionMenuTemplate:f,hasOptionTemplate:!0,onClick:()=>u("/kpi-dashboard/".concat(e.id)),isListing:!0,t:n},e.id)))}):(0,P.jsx)(Se,{count:6})})})}),(0,P.jsxs)(te.l,{style:{width:"35vw"},className:"kpi-delete-modal bordered-dialogue-header",header:n("deleteKPI"),visible:m.showDeleteModal,modal:!0,onHide:()=>v((e=>({...e,showDeleteModal:!1,kpiToDelete:null}))),children:[(0,P.jsx)("div",{className:"flex-center flex-d-column tl-gap-8 tl-mt16",children:(0,P.jsx)("span",{className:"tl-text16 tl-1F1F1F tl-fsn tl-fnormal",children:n("deleteKPIConfirm")})}),(0,P.jsxs)("div",{className:"button-container d-flex tl-mt24 tl-gap-16",children:[(0,P.jsxs)("div",{className:"cancel-cta tl-text14 tl-mt8 w-100",style:{width:"100%"},onClick:()=>v((e=>({...e,showDeleteModal:!1,kpiToDelete:null}))),type:"button",children:[(0,P.jsx)("span",{className:"tl-mt4",dangerouslySetInnerHTML:{__html:B.Pp}}),(0,P.jsx)("span",{className:"tl-ml4",children:n("cancel")})]}),(0,P.jsxs)("div",{className:"flex-center tl-mt8 tl-mb8 delete-btn w-100 cursor-hand",onClick:()=>{var e;null!==(e=m.kpiToDelete)&&void 0!==e&&e.id&&(l.kpiDashboardActions.tryDeletingKPI(m.kpiToDelete.id),v((e=>({...e,showDeleteModal:!1,kpiToDelete:null}))))},style:{width:"100%"},type:"button",children:[(0,P.jsx)("span",{className:"ibm tc tl-mr4 tl-mt4",dangerouslySetInnerHTML:{__html:B.hd}}),(0,P.jsx)("span",{className:"ibm tc tl-text14 tl-fsn",children:n("delete")})]})]})]})]})};var Ee=i(7818);const Me=e=>{const{actions:t,kpiDashboardData:i}=e,{t:s}=(0,Ee.Bd)(["kpiDashboard"]),{id:n}=(0,a.g)(),r=(0,a.zy)(),o=(0,l.Ez)("edit")||r.pathname.includes("/edit"),c=(0,l.Ez)("create")||r.pathname.includes("/create"),d=Boolean(n&&!o&&!c)||!1;return(0,P.jsxs)("div",{className:"kpi-dashboard-container",children:[(c||o)&&(0,P.jsx)($,{action:t,mode:o?"Edit":"Create",id:c?null:n,kpiDashboardData:i,t:s}),d&&(0,P.jsx)(Ae,{kpiId:n,action:t,kpiDashboardData:i,t:s}),!n&&!o&&!c&&(0,P.jsx)(Pe,{action:t,kpiDashboardData:i,t:s})]})}},5185:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var s=i(9950),a=i(7267),l=i(7047),n=i(4942),r=i(103),o=i(7818),c=i(4414);const d=function(e){let{defaultDate:t,dialogHeader:i,onChangeDate:d,showNull:u}=e;
1const[h,p]=(0,s.useState)(!1),[m,v]=(0,s.useState)(new Date),{t:x}=(0,o.Bd)(["commonWordsPassedThroughProps"]);return(0,s.useEffect)((()=>{if(t){const e=new Date(t);v(e)}}),[t]),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)("div",{className:"creation-container flex-center cursor-hand",onClick:()=>p(!0),children:[(0,c.jsx)("span",{className:"tl-text14 tl-mt4 theme-icon",dangerouslySetInnerHTML:{__html:r.KC}}),(0,c.jsx)("span",{className:"tl-text14 tl-166EFC tl-ml8",children:u?"N/A":t?(0,n.po)(t):(0,n.po)(new Date)})]}),(0,c.jsxs)(a.l,{header:i,visible:h,style:{width:"30vw"},modal:!0,onHide:e=>p(!1),children:[(0,c.jsx)(l.V,{value:m,onChange:e=>v(e.value),dateFormat:"dd/mm/yy"}),(0,c.jsx)("div",{className:"green-cta tl-text14 tl-mt12 tl-ml-auto tl-mr-auto click-cta",onClick:e=>(d((0,n.aQ)(m)),void p(!1)),children:x("update")})]})]})}},4476:(e,t,i)=>{"use strict";i.d(t,{A:()=>v});var s=i(9950),a=i(4100),l=i(8671),n=i(980),r=i(4942),o=i(9563),c=i(103),d=i(8738),u=i.n(d),h=i(4583),p=i(2035),m=i(4414);const v=function(e){var t,i,d;const{optionList:v,values:x,placeholder:g,updateSelection:k,onSearchEvent:j,parentClass:f="",showAddNew:y=!1,onNewStepClick:N,onListScroll:b,onViewToggle:_,labelBy:T="title",paginated:w=!1,limit:D=null,onDeleteCTA:I,showImage:A=!1,showCross:F=!1,renderFooter:C,renderCustomLabel:L,showImageAvatar:S=!1}=e,[P,E]=(0,s.useState)(!1),[M,R]=(0,s.useState)({}
1),[B,q]=(0,s.useState)([]),[V,H]=(0,s.useState)({}),K=(0,s.useRef)(null);(0,s.useEffect)((()=>{q(v)}),[v]),(0,s.useEffect)((()=>{x&&O(x)}),[null===x||void 0===x?void 0:x.length]);const U=e=>{k(e)},O=e=>{const t={};e.forEach((e=>{t[e.id]={},t[e.id].checked=!0,t[e.id][T]=(0,r.u6)(e[T]),e.image&&(t[e.id].image=e.image)})),R(t),H(t)};return(0,s.useEffect)((()=>{function e(e){K.current&&!K.current.contains(e.target)&&E(!1)}return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[]),(0,m.jsxs)("div",{className:"multi-dd-wrapper",ref:K,children:[(0,m.jsxs)("div",{className:"multi-select-dd ".concat(f," ").concat(P?"expanded-dd-menu":""),children:[(0,m.jsxs)("div",{className:"d-flex justify-content-space-between common-input",onClick:()=>(E(!P),void(_&&_())),children:[null!==(t=Object.keys(V))&&void 0!==t&&t.length?(0,m.jsxs)("section",{className:"vertical-center cursor-hand p-relative",children:[function(e,t,i){if(e&&e.length){return[...e].splice(t,i)}}(Object.keys(V),0,3).map(((e,t)=>{var i,s,a,l,n;return(0,m.jsxs)("div",{className:u()("tl-mr4 capsule"),children:[S?(0,m.jsx)(p.A,{image:null===(i=V[e])||void 0===i?void 0:i.image,name:null===(s=V[e])||void 0===s?void 0:s.name,height:"16px",width:"16px",avatarLabelFontSize:"8px"}):(null===(a=V[e])||void 0===a?void 0:a.image)&&(0,m.jsx)("img",{className:"border-r-50",height:"16px",width:"16px",src:null===(l=V[e])||void 0===l?void 0:l.image}),V[e]&&(0,m.jsx)("span",{className:u()("tl-text12 tl-f400 tl-1F1F1F"),title:V[e][T],children:(null===(n=V[e][T])||void 0===n?void 0:n.length)>15?"".concat(V[e][T].substring(0,15),"..."):V[e][T]}),(V[e].image||F)&&(0,m.jsx)("span",{className:"tl-mt4",onClick:t=>{t.stopPropagation(),(e=>{const t={...V};delete t[e],H(t);const i={...M};i[e]&&(i[e].checked=!1),R(i),U(i)})(e)},dangerouslySetInnerHTML:{__html:c.Pp}})]},t)})),(null===(i=Object.keys(V))||void 0===i?void 0:i.length)>3&&(0,m.jsx)("div",{className:"count-placeholder tl-ml4 flex-center",children:(0,m.jsxs)("span",{children:["+",(null===(d=Object.keys(V))||void 0===d?void 0:d.length)-3]})})]}):(0,m.jsx)("span",{className:"tl-text16 placeholder-text",children:g||"Select an option"}),(0,m.jsx)("span",{className:"fa fa-angle-up arrow-icon ".concat(P?"":"inverted-icon")})]}),P&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("div",{children:(0,m.jsx)(n.A,{btnText:"Search",disabled:!1,marginClass:"tl-mb20",handleInputChange:j})}),(0,m.jsx)("div",{className:"clw-list-wrapper white-bg",onScroll:function(e){if(!w)return;(function(e){return 100*e.scrollTop/(e.scrollHeight-e.clientHeight)})(e.target)>90&&b&&b()},children:B&&B.length>0&&B.map(((e,t)=>{var i;return(0,m.jsxs)("div",{className:u()("team-selection-wrapper vertical-center tl-gap-12 tl-mt4",{"inactive-section":!1===(null===e||void 0===e?void 0:e.active)&&!(null!==(i=M[e.id])&&void 0!==i&&i.checked)}),children:[(0,m.jsx)("section",{className:"team-check tl-mb4",children:(0,m.jsx)(l.S,{className:"tl-mr4",onChange:t=>function(e,t){const i={...M};if(i[e]?i[e].checked=!i[e].checked:(i[e]={},i[e].checked=!0),i[e][T]=(0,r.u6)(t[T]),A&&(i[e].image=t.image),i[e].checked){var s;const a={...V};if(a[e]={checked:!0},A&&(a[e].image=t.image),D&&(null===(s=Object.keys(a))||void 0===s?void 0:s.length)>D)return i[e].checked=!1,(0,r.mQ)({type:"warn",label:"Attention",message:"Maximum allowed limit is ".concat(D)});a[e][T]=(0,r.u6)(t[T]),H(a)}else{const t={...V};delete t[e],H(t)}R(i),U(i)}(e.id,e),checked:M[e.id]&&M[e.id].checked})}),S?(0,m.jsx)(p.A,{image:null===e||void 0===e?void 0:e.image,name:L?L(e):(0,r.u6)(e[T]),height:"32px",width:"32px",avatarLabelFontSize:"12px"}):(null===e||void 0===e?void 0:e.image)&&(0,m.jsx)("img",{className:"border-r-50",height:"16px",width:"16px",src:e.image||h.O9}),(0,m.jsxs)("section",{className:"vertical-center w-100",children:[(0,m.jsx)("span",{className:"emp-name tl-ml8 tl-text14 tl-c000000 tl-f400 tl-fsn tl-lh170",children:L?L(e):(0,r.u6)(e[T])}),I&&(null===e||void 0===e?void 0:e.organization_id)&&(0,m.jsx)("span",{className:"tl-ml-auto fa fa-trash tl-cE82442 cursor-hand",onClick:()=>{return t=e,void(0,o.Z)({message:"Are you certain you wish to proceed with deleteion ?",header:"Confirmation",icon:"pi pi-exclamation-triangle",accept:()=>I(t)});var t}})]})]},e.id||t)}))}),(0,m.jsx)("div",{className:"tl-mt12",children:y&&(0,m.jsx)(a.A,{headingText:"+ Add new option",onStepCTAClick:N})})]})]}),C&&(0,m.jsx)("div",{className:"tl-mt8",children:C((()=>E(!1)))}),(0,m.jsx)(o.T,{})]})}},5168:(e,t,i)=>{"use strict";i.d(t,{A:()=>v});var s=i(9950),a=i(9328),l=i(561),n=i(653),r=i(2401),o=i(4415),c=i(7267),d=i(4583),u=i(4942),h=i(8738),p=i.n(h),m=i(4414);const v=e=>{let{onUploadCTAClick:t,showUpload:i=!1,onUploadHide:h,className:v="",label:x="Upload Files"}=e;
1const[g,k]=(0,s.useState)([]),[j,f]=(0,s.useState)(!1),y=(0,s.useRef)(null);(0,s.useEffect)((()=>{i&&f(!0)}),[i]);return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(o.y,{ref:y}),(0,m.jsx)(l.$,{className:p()("w-100",v),label:x||"Upload Files",icon:"pi pi-upload",onClick:()=>f(!0)}),(0,m.jsxs)(c.l,{visible:j,onHide:()=>{f(!1),k([]),h&&h()},header:"Upload Files",style:{width:"50vw"},children:[(0,m.jsx)(a.e,{name:"files",accept:d.UR.WITH_IMAGE_CONFIG.allowedFileTypesToSelect,multiple:!0,customUpload:!0,auto:!1,chooseLabel:"Add Files",emptyTemplate:(0,m.jsx)("p",{className:"p-m-0",children:"No files selected yet."}),onSelect:e=>{const t=Array.from(e.files).filter((e=>!g.some((t=>t.name===e.name))));t.length>0?(k((e=>[...e,...t])),y.current.show({severity:"success",summary:"Files Added",detail:"".concat(t.length," file(s) added successfully.")})):y.current.show({severity:"info",summary:"Duplicate Files",detail:"Some files are already selected."})},chooseOptions:{icon:"pi pi-plus",label:"Add Files",className:"custom-choose-btn"},contentStyle:{display:"none"},uploadOptions:{style:{display:"none"}},cancelOptions:{style:{display:"none"}}}),g.length>0&&(0,m.jsxs)(n.b,{value:g,className:"p-mt-3",header:"Selected Files",children:[(0,m.jsx)(r.V,{field:"name",header:"File Name"}),(0,m.jsx)(r.V,{field:"size",header:"Size (Bytes)"}),(0,m.jsx)(r.V,{body:e=>(0,m.jsx)(l.$,{icon:"pi pi-times",className:"p-button-rounded p-button-danger p-button-text",onClick:()=>(e=>{const t=g.filter((t=>t.name!==e));k(t),y.current.show({severity:"info",summary:"File Removed",detail:"".concat(e," has been removed.")})})(e.name),tooltip:"Remove File"}),header:"Actions"})]}),(0,m.jsxs)("div",{className:"p-d-flex p-jc-end p-mt-3 tl-mt32",children:[(0,m.jsx)(l.$,{className:"tl-mr20",label:"Upload",icon:"pi pi-check",onClick:()=>{if(0===g.length)return void y.current.show({severity:"warn",summary:"No Files Selected",detail:"Please add files before uploading."});const e=[];g.forEach((t=>{const i={fileName:(0,u.jr)(t.name),uploadedFile:t};e.push(i)})),t(e),k([]),f(!1),h&&h()},disabled:0===g.length}),(0,m.jsx)(l.$,{label:"Cancel",icon:"pi pi-times",className:"p-button-text",onClick:()=>{f(!1),k([]),h&&h()}})]})]})]})}},4100:(e,t,i)=>{"use strict";i.d(t,{A:()=>n});var s=i(9950),a=i(7818),l=i(4414);const n=function(e){const{headingText:t,onStepCTAClick:i,iconPlaceholder:n}
1=e,[r,o]=(0,s.useState)(!1),[c,d]=(0,s.useState)(""),{t:u}=(0,a.Bd)(["commonWordsPassedThroughProps"]);return(0,l.jsxs)("div",{className:"new-step-wrapper",children:[!r&&(0,l.jsxs)("div",{className:"add-new-check-cta tl-mt12 tl-166EFC tl-text12 cursor-hand vertical-center",onClick:()=>o(!0),children:[n&&(0,l.jsx)("span",{dangerouslySetInnerHTML:{__html:n},className:"tl-mr4"}),t]}),r&&(0,l.jsxs)("div",{className:"new-check tl-mt20 vertical-center",children:[(0,l.jsx)("span",{className:"input-span",children:(0,l.jsx)("input",{className:"new-input tl-929DB0",value:c,type:"text",onChange:function(e){d(e.target.value)}})}),(0,l.jsx)("span",{className:"add-button tl-166EFC cursor-hand tl-mr12 tl-text14",onClick:()=>{c&&(i(c),o(!1),d(""))},children:u("add")}),(0,l.jsx)("span",{className:"add-button tl-166EFC cursor-hand tl-text14",onClick:()=>o(!1),children:u("cancel")})]})]})}},8881:(e,t,i)=>{"use strict";i.d(t,{Bj:()=>c,E4:()=>u,K0:()=>h,_N:()=>r,bk:()=>o,nS:()=>d,yD:()=>n});var s=i(4044),a=i.n(s),l=i(4942);function n(e){let t=arguments.length>2?arguments[2]:void 0;const i=[],s=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).reduce((function(e,t){return e[t.id]=t.access||t.id,e}),{});return Object.keys(e).forEach((a=>{const l=Number(a);if(e[l]&&e[l].checked&&!s[l]){const s={id:l,action:"add"};t&&(s.access=Number(e[l].access)?Number(e[l].access):1),i.push(s)}if((!e[l]||!e[l].checked)&&s[l]){const e={id:l,action:"remove"};i.push(e)}if(t&&!(i.length>0)&&e[l].access&&e[l].access!==s[l]){const t={id:l,action:"update",access:Number(e[l].access)};i.push(t)}})),i}function r(e,t){const i=[];return Object.keys(e).forEach((s=>{const a=Number(s);if(e[a]&&e[a].checked){var l;const s={threat_id:a,action:"add"};s.identifier=e[a].riskIdentifier,s.title=e[a].riskIdentifier,s.description=e[a].riskDesc,s.category_id=t,s.evaluation_param_type=null===(l=e[a])||void 0===l?void 0:l.evaluation_param_type,i.push(s)}})),i}function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{const t={...{length:8,characters:[a().lower+"\xe4\xf6\xfc\xdf",a().upper+"\xc4\xd6\xdc\u1e9e",a().digits,a().symbols]},...e};if(t.length<4)throw new Error("Using fallback for short passwords");if(t.length>128)throw new Error("Password length cannot exceed 128 characters");const i=a().randomPassword(t);if(!i||i.length!==t.length)throw new Error("Library generated invalid password");return i}catch(t){console.error("Password generation error, using fallback:",t.message);const i="ABCDEFGHIJKLMNOPQRSTUVWXYZ\xc4\xd6\xdc",s="abcdefghijklmnopqrstuvwxyz\xe4\xf6\xfc\xdf",a="0123456789",l="!@#$%^&*()_+-=[]{}|;:,.<>?~`\"'/",n=i+s+a+l,r=Math.max(1,Math.min(128,e.length||8));let o="";if(r>=4){o+=i.charAt(Math.floor(Math.random()*i.length)),o+=s.charAt(Math.floor(Math.random()*s.length)),o+=a.charAt(Math.floor(Math.random()*a.length)),o+=l.charAt(Math.floor(Math.random()*l.length));for(let e=4;e<r;e++)o+=n.charAt(Math.floor(Math.random()*n.length));o=o.split("").sort((()=>Math.random()-.5)).join("")}else for(let e=0;e<r;e++)o+=n.charAt(Math.floor(Math.random()*n.length));return o}}const c=e=>new Date(e).toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}),d=(e,t)=>{if(!e||!t)return null;const[i,s]=t.split(":").map(Number),a=new Date(e);return a.setHours(i,s,0,0),a.toISOString()},u=(e,t)=>{if(!e||!t)return"-";const i=new Date(t)-new Date(e);if(isNaN(i)||i<0)return"-";const s=Math.floor(i/1e3),a=Math.floor(s/3600),l=Math.floor(s%3600/60),n=s%60,r=[];return a&&r.push("".concat(a,"h")),(a||l)&&r.push("".concat(l,"m")),r.push("".concat(n,"s")),r.join(" ")},h=e=>{const t="de"===(0,l.qz)();return new Date(e).toLocaleString(t?"de-DE":"en-GB",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).replace(",",t?" um":" at")}},9:()=>{}}]);
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.