import{gQ as ke,gR as Rt,r as w,gS as Ce,gU as Ft,gV as Je,gW as Dt,gX as Ue,gT as et,gY as pt,f as le,gZ as Ot,g_ as Bt,eu as Wt,j as t,c as ce,s as De,v as Oe,q as Be,hQ as oe,hR as zt,hS as Gt,aI as ve,dd as qt,c7 as c,hT as $t,em as Lt,aa as _e,al as Ht,aW as Kt,F as I,aM as Qt,bX as _,au as ae,B as S,aZ as Xt,b9 as Yt,ba as Zt,bb as Jt,bc as es,bd as ts,dY as ss,hU as is,f6 as rs,eL as ns,d4 as os,db as ht,dc as gt,U as Re,fk as X,a0 as k,fe as Fe,aA as as,b8 as ge,bI as xt,a8 as ls,a9 as cs,hV as us,b_ as ds,bH as tt,be as st,ac as ms,a5 as ps,dC as hs,dD as gs,C as Y,b6 as xs,dF as vs,ct as bs,fE as js,hW as vt,hX as bt,bj as fs,a_ as ys,X as Ps,Y as ws,bg as xe,_ as Ss,hY as ks,hZ as Cs,$ as Us,g1 as _s,h_ as Ts,ee as Ms,T as jt,gB as ft,h$ as it,i0 as he,i1 as As,i2 as Is,i3 as Es,eR as Vs,i4 as Ns,eT as Rs,a1 as Fs,gG as Ds,i5 as Os,a6 as Bs,dM as Ws,cG as zs,d5 as Gs,aq as qs,ha as $s,i6 as Ls,bU as rt,i7 as Hs,i8 as Ks,i9 as Qs,x as Te,ia as Xs,A as Ys,hi as Zs,ib as Js,ic as ei,id as ti,hG as si,fa as ii,hf as ri,hg as ni,ie as oi,d7 as ai,c0 as nt,bq as li,a3 as Me,bB as Ae,er as ci,aw as ui}from"./index-b90158b7.js";import{i as di,j as mi,g as pi,a as hi,b as Ie,d as Q,c as Ee,e as gi,h as ue}from"./index-eb5a8818.js";import{S as xi}from"./chunk-MZBQPWGD-f62a78bc.js";function vi(e){var s;const{min:r=0,max:n=100,onChange:a,value:g,defaultValue:x,isReversed:y,direction:p="ltr",orientation:f="horizontal",id:N,isDisabled:j,isReadOnly:W,onChangeStart:D,onChangeEnd:T,step:U=1,getAriaValueText:i,"aria-valuetext":b,"aria-label":d,"aria-labelledby":P,name:u,focusThumbOnChange:Z=!0,...M}=e,R=ke(D),$=ke(T),de=ke(i),A=gi({isReversed:y,direction:p,orientation:f}),[fe,J]=Rt({value:g,defaultValue:x??ji(r,n),onChange:a}),[ee,me]=w.useState(!1),[te,pe]=w.useState(!1),se=!(j||W),H=(n-r)/10,h=U||(n-r)/100,m=Ce(fe,r,n),E=n-m+r,L=et(A?E:m,r,n),C=f==="vertical",v=di({min:r,max:n,step:U,isDisabled:j,value:m,isInteractive:se,isReversed:A,isVertical:C,eventSource:null,focusThumbOnChange:Z,orientation:f}),K=w.useRef(null),ye=w.useRef(null),We=w.useRef(null),kt=w.useId(),ze=N??kt,[Ge,qe]=[`slider-thumb-${ze}`,`slider-track-${ze}`],Ct=w.useCallback(o=>{var l,re;if(!K.current)return;const V=v.current;V.eventSource="pointer";const z=K.current.getBoundingClientRect(),{clientX:we,clientY:Et}=(re=(l=o.touches)==null?void 0:l[0])!=null?re:o,Vt=C?z.bottom-Et:we-z.left,Nt=C?z.height:z.width;let Se=Vt/Nt;A&&(Se=1-Se);let ne=Ft(Se,V.min,V.max);return V.step&&(ne=parseFloat(Je(ne,V.min,V.step))),ne=Ce(ne,V.min,V.max),ne},[C,A,v]),G=w.useCallback(o=>{const l=v.current;l.isInteractive&&(o=parseFloat(Je(o,l.min,h)),o=Ce(o,l.min,l.max),J(o))},[h,J,v]),q=w.useMemo(()=>({stepUp(o=h){const l=A?m-o:m+o;G(l)},stepDown(o=h){const l=A?m+o:m-o;G(l)},reset(){G(x||0)},stepTo(o){G(o)}}),[G,A,m,h,x]),$e=w.useCallback(o=>{const l=v.current,V={ArrowRight:()=>q.stepUp(),ArrowUp:()=>q.stepUp(),ArrowLeft:()=>q.stepDown(),ArrowDown:()=>q.stepDown(),PageUp:()=>q.stepUp(H),PageDown:()=>q.stepDown(H),Home:()=>G(l.min),End:()=>G(l.max)}[o.key];V&&(o.preventDefault(),o.stopPropagation(),V(o),l.eventSource="keyboard")},[q,G,H,v]),Le=(s=de==null?void 0:de(m))!=null?s:b,Pe=mi(ye),{getThumbStyle:He,rootStyle:Ke,trackStyle:Qe,innerTrackStyle:Xe}=w.useMemo(()=>{const o=v.current,l=Pe??{width:0,height:0};return pi({isReversed:A,orientation:o.orientation,thumbRects:[l],thumbPercents:[L]})},[A,Pe,L,v]),Ye=w.useCallback(()=>{v.current.focusThumbOnChange&&setTimeout(()=>{var l;return(l=ye.current)==null?void 0:l.focus()})},[v]);Dt(()=>{const o=v.current;Ye(),o.eventSource==="keyboard"&&($==null||$(o.value))},[m,$]);function Ze(o){const l=Ct(o);l!=null&&l!==v.current.value&&J(l)}hi(We,{onPanSessionStart(o){const l=v.current;l.isInteractive&&(me(!0),Ye(),Ze(o),R==null||R(l.value))},onPanSessionEnd(){const o=v.current;o.isInteractive&&(me(!1),$==null||$(o.value))},onPan(o){v.current.isInteractive&&Ze(o)}});const Ut=w.useCallback((o={},l=null)=>({...o,...M,ref:Ue(l,We),tabIndex:-1,"aria-disabled":Ie(j),"data-focused":Q(te),style:{...o.style,...Ke}}),[M,j,te,Ke]),_t=w.useCallback((o={},l=null)=>({...o,ref:Ue(l,K),id:qe,"data-disabled":Q(j),style:{...o.style,...Qe}}),[j,qe,Qe]),Tt=w.useCallback((o={},l=null)=>({...o,ref:l,style:{...o.style,...Xe}}),[Xe]),Mt=w.useCallback((o={},l=null)=>({...o,ref:Ue(l,ye),role:"slider",tabIndex:se?0:void 0,id:Ge,"data-active":Q(ee),"aria-valuetext":Le,"aria-valuemin":r,"aria-valuemax":n,"aria-valuenow":m,"aria-orientation":f,"aria-disabled":Ie(j),"aria-readonly":Ie(W),"aria-label":d,"aria-labelledby":d?void 0:P,style:{...o.style,...He(0)},onKeyDown:Ee(o.onKeyDown,$e),onFocus:Ee(o.onFocus,()=>pe(!0)),onBlur:Ee(o.onBlur,()=>pe(!1))}),[se,Ge,ee,Le,r,n,m,f,j,W,d,P,He,$e]),At=w.useCallback((o,l=null)=>{const re=!(o.value<r||o.value>n),V=m>=o.value,z=et(o.value,r,n),we={position:"absolute",pointerEvents:"none",...bi({orientation:f,vertical:{bottom:A?`${100-z}%`:`${z}%`},horizontal:{left:A?`${100-z}%`:`${z}%`}})};return{...o,ref:l,role:"presentation","aria-hidden":!0,"data-disabled":Q(j),"data-invalid":Q(!re),"data-highlighted":Q(V),style:{...o.style,...we}}},[j,A,n,r,f,m]),It=w.useCallback((o={},l=null)=>({...o,ref:l,type:"hidden",value:m,name:u}),[u,m]);return{state:{value:m,isFocused:te,isDragging:ee},actions:q,getRootProps:Ut,getTrackProps:_t,getInnerTrackProps:Tt,getThumbProps:Mt,getMarkerProps:At,getInputProps:It}}function bi(e){const{orientation:s,vertical:r,horizontal:n}=e;return s==="vertical"?r:n}function ji(e,s){return s<e?e:e+(s-e)/2}var[fi,be]=pt({name:"SliderContext",hookName:"useSliderContext",providerName:"<Slider />"}),[yi,je]=pt({name:"SliderStylesContext",hookName:"useSliderStyles",providerName:"<Slider />"}),yt=le((e,s)=>{var r;const n={...e,orientation:(r=e==null?void 0:e.orientation)!=null?r:"horizontal"},a=Ot("Slider",n),g=Bt(n),{direction:x}=Wt();g.direction=x;const{getInputProps:y,getRootProps:p,...f}=vi(g),N=p(),j=y({},s);return t.jsx(fi,{value:f,children:t.jsx(yi,{value:a,children:t.jsxs(ce.div,{...N,className:ue("chakra-slider",n.className),__css:a.container,children:[n.children,t.jsx("input",{...j})]})})})});yt.displayName="Slider";var Pt=le((e,s)=>{const{getThumbProps:r}=be(),n=je(),a=r(e,s);return t.jsx(ce.div,{...a,className:ue("chakra-slider__thumb",e.className),__css:n.thumb})});Pt.displayName="SliderThumb";var wt=le((e,s)=>{const{getTrackProps:r}=be(),n=je(),a=r(e,s);return t.jsx(ce.div,{...a,className:ue("chakra-slider__track",e.className),__css:n.track})});wt.displayName="SliderTrack";var St=le((e,s)=>{const{getInnerTrackProps:r}=be(),n=je(),a=r(e,s);return t.jsx(ce.div,{...a,className:ue("chakra-slider__filled-track",e.className),__css:n.filledTrack})});St.displayName="SliderFilledTrack";var Pi=le((e,s)=>{const{getMarkerProps:r}=be(),n=je(),a=r(e,s);return t.jsx(ce.div,{...a,className:ue("chakra-slider__marker",e.className),__css:n.mark})});Pi.displayName="SliderMark";const wi="3.3",Si="scores",ki={"api-version":wi},Ci={previewAccess:e=>({url:`${Si}/preview-access`,method:"post",json:e,query:ki})},Ui=()=>{const e=De();return Oe({mutationFn:({uid:s,score:r})=>Be.patch(`scores/${s}?api-version=3.3`,{json:r}),onSuccess:s=>{e.setQueryData([oe],r=>r?{scores:r.scores.map(n=>n.uid===s.uid?s:n)}:{scores:[s]}),e.setQueryData([oe,s.uid],()=>s)}})},_i=()=>{const e=De();return Oe({mutationKey:[oe],mutationFn:s=>Be.delete(`scores/${s}?api-version=3.3`,{}),onSuccess:(s,r)=>{e.setQueryData([oe],n=>n?{scores:n.scores.filter(a=>a.uid!==r)}:{scores:[]})}})},Ti=()=>{const e=De();return Oe({mutationFn:s=>Be.post(zt,{json:s}),onSuccess:s=>{e.setQueryData([oe],r=>r?{scores:[s,...r.scores]}:{scores:[s]})}})},ot=({userUid:e,date:s,label:r})=>{const{i18n:n}=Gt(),a=ve(),g=qt(e),x=a.id===e,y=c._({id:"av/PD9"}),p=g?c._({id:"whcO1V",values:{label:r,0:x?y:g.name}}):void 0,f=n.date(s,{day:"numeric",month:"long",year:"numeric"});return t.jsx("span",{children:[p,f].filter(Boolean).join(", ")})},Mi=e=>{const{isEditing:s,getSubmitButtonProps:r,getCancelButtonProps:n,getEditButtonProps:a}=$t();return s?t.jsxs(Lt,{justifyContent:"center",size:"sm",...e,children:[t.jsx(_e,{icon:t.jsx(Ht,{}),"aria-label":c._({id:"y3aU20"}),...r()}),t.jsx(_e,{icon:t.jsx(Kt,{}),"aria-label":c._({id:"ifkrYE"}),...n()})]}):t.jsx(I,{justifyContent:"center",...e,children:t.jsx(_e,{size:"sm",icon:t.jsx(Qt,{}),"aria-label":c._({id:"ePK91l"}),...a()})})},at=1,F=10;var lt;(function(e){e.LESS_THAN="<",e.MORE_THAN=">",e.RANGE="-"})(lt||(lt={}));const Ai=({range:e,onChange:s})=>{const r=[{value:">",label:c._({id:"CW11B+"})},{value:"<",label:c._({id:"mOFgdC"})},{value:"-",label:c._({id:"XtFNg/"})}],[n,a]=_.useState(()=>{const{min:p,max:f}=e;return p==null&&f==null||p!=null&&f==null?">":p==null&&f!=null?"<":"-"}),g=w.useCallback(p=>{a(p),p===">"&&s({min:e.min??e.max??5,max:void 0}),p==="<"&&s({min:void 0,max:e.max??e.min??5}),p==="-"&&s({min:e.min??1,max:e.max??10})},[s,e.max,e.min]),x=[">","-"].includes(n),y=["<","-"].includes(n);return t.jsxs(ae,{spacing:1,isInline:!0,children:[t.jsx(S,{minW:"8em",children:t.jsx(Xt,{value:r.find(p=>p.value===n),options:r,onChange:p=>{p!=null&&g(p.value)},menuPortalTarget:document.body})}),x&&t.jsx(S,{w:"5em",children:t.jsx(ct,{value:e==null?void 0:e.min,max:n==="-"?e==null?void 0:e.max:10,onChange:p=>s({...e,min:p})})}),y&&t.jsx(S,{w:"5em",children:t.jsx(ct,{value:e==null?void 0:e.max,min:n==="-"?e==null?void 0:e.min:0,onChange:p=>s({...e,max:p})})})]})},ct=({min:e=0,max:s=10,value:r,onChange:n})=>{const[a,g]=_.useState((r==null?void 0:r.toString())||"");return t.jsxs(Yt,{min:e,max:s,step:.5,precision:1,inputMode:"decimal",onChange:x=>{g(x);const y=Number.parseFloat(x);n==null||n(Number.isNaN(y)?void 0:y)},value:a,size:"sm",children:[t.jsx(Zt,{}),t.jsxs(Jt,{children:[t.jsx(es,{}),t.jsx(ts,{})]})]})};var Ii=is,Ei=rs;function Vi(e){return e&&e.length?Ii(e,Ei):0}var Ni=Vi;const Ri=ss(Ni),Fi=({params:e,goal:s})=>{const r=Ri(e.map(p=>p.weight??0)),n=ns(r,0,F),{min:a,max:g}=s||{},x=a!=null?a/F*100:0,y=g!=null?(F-g)/F*100:0;return t.jsx(I,{direction:"column",children:t.jsxs(I,{mt:2,children:[t.jsxs(S,{flex:"1",children:[t.jsx(os,{value:n,min:0,max:F,colorScheme:"primary",borderRadius:"sm",width:"full",h:5,flex:1,css:{div:{transition:"all 300ms ease-out"}}}),s&&t.jsx(S,{mt:"2",w:"100%",h:"3px",pos:"relative",children:t.jsx(S,{pos:"absolute",left:`${x}%`,right:`${y}%`,h:"100%",bg:"success",transition:"all 150ms ease"})})]}),t.jsxs(ht,{ml:4,w:6,flex:"0 0 auto",textAlign:"right",children:[n,t.jsx(S,{display:"inline",color:"primary.500",float:"right",children:F<r?" *":""})]})]})})},ut={lg:"minmax(0, 2fr) 1fr"},Di=({goal:e,params:s,onGoalChange:r,onParameterChange:n})=>{const a=ve(),g=gt(a,{teamUids:{componentOptions:{isMulti:!0}},userUids:{componentOptions:{isMulti:!0}},subjects:{componentOptions:{isMulti:!0}},labels:{componentOptions:{isMulti:!0}},trackers:{componentOptions:{isMulti:!0}},notTrackers:{componentOptions:{isMulti:!0}},customProp1:{componentOptions:{isMulti:!1}},customProp2:{componentOptions:{isMulti:!1}},customProp3:{componentOptions:{isMulti:!1}},customProp4:{componentOptions:{isMulti:!1}},customProp5:{componentOptions:{isMulti:!1}},customProp6:{componentOptions:{isMulti:!1}},customProp7:{componentOptions:{isMulti:!1}},customProp8:{componentOptions:{isMulti:!1}},customProp9:{componentOptions:{isMulti:!1}},customProp10:{componentOptions:{isMulti:!1}},scores:{isAvailable:()=>!1},repeatCalls:{isAvailable:()=>!1},keyTopics:{isAvailable:()=>!1},qaIsReviewed:{isAvailable:()=>!1}}),x=!!e,[y,p]=w.useState(x),f=(i,b)=>{const d=[...s],P=s[i];d[i]={...P,value:b},n(d)},N=(i,b)=>{const d=[...s],P=s[i];d[i]={...P,weight:b},n(d)},j=Oi(g),[W,D]=_.useState(),T=i=>{n([...s,{filterValueType:i,value:null,weight:at}]),setTimeout(()=>D(s==null?void 0:s.length))},U=i=>{const b=s.filter(d=>d!==i);n(b)};return t.jsxs(S,{children:[t.jsxs(Re,{mt:8,gap:4,templateColumns:ut,children:[t.jsxs(S,{children:[t.jsx(X,{mb:0,children:t.jsx(k,{id:"zelwwH"})}),t.jsx(Fe,{color:"textMuted",maxW:"sm",children:t.jsx(k,{id:"4QG8Zf"})})]}),t.jsxs(S,{children:[t.jsx(X,{mb:0,"data-stonly":"parameter_score",children:t.jsx(k,{id:"SrKs2H"})}),t.jsx(Fe,{color:"textMuted",children:t.jsx(k,{id:"P5I+4T",values:{MAX_PARAMETER_WEIGHT:F}})}),t.jsx(Fi,{params:s,goal:e}),t.jsxs(I,{direction:"column",children:[t.jsxs(ae,{isInline:!0,spacing:2,align:"center",wrap:"wrap",minH:8,children:[t.jsx(as,{id:"goal-toggle",size:"sm",isChecked:y,onChange:i=>{p(i.target.checked),i.target.checked?r({goal:{min:5,max:void 0}}):r({goal:null})}}),t.jsx(X,{htmlFor:"goal-toggle",mb:"0",fontWeight:e?"medium":"normal",rightIcon:t.jsx(ge,{label:c._({id:"9FGP6M"}),children:t.jsx("span",{children:t.jsx(xt,{})})}),children:t.jsx(k,{id:"EEZvNu"})})]}),y&&e&&t.jsx(I,{children:t.jsx(Ai,{range:e,onChange:i=>{r({goal:{min:i.min,max:i.max}})}})})]})]})]}),t.jsx(ae,{mt:4,spacing:2,divider:t.jsx(xi,{visibility:{base:"visible",lg:"hidden"},my:{base:2,lg:1}}),children:(s||[]).map((i,b)=>{const d=g.get(i.filterValueType),P=_.createRef();return t.jsxs(Re,{templateColumns:ut,alignItems:"center",gap:4,children:[t.jsx(S,{minWidth:0,children:t.jsx(ls,{placement:"bottom-start",isOpen:W===b,onClose:()=>D(void 0),initialFocusRef:P,isLazy:!0,children:({isOpen:u,onClose:Z})=>{var M;return t.jsxs(t.Fragment,{children:[t.jsx(cs,{children:t.jsx(us,{size:"sm",hasValue:((M=d==null?void 0:d.hasValue)==null?void 0:M.call(d,i.value))??!ds(i.value),leftIcon:t.jsx(tt,{boxSize:5,as:d==null?void 0:d.icon}),onReset:()=>U(i),onClick:()=>D(b),isActive:u,css:st`
                            max-width: 100%;
                          `,children:(d==null?void 0:d.renderText(i.value))??"?"})}),t.jsx(ms,{children:t.jsx(_.Suspense,{fallback:t.jsx(ps,{display:"block",m:"1rem auto"}),children:d&&t.jsx(d.Component,{onClose:Z,initialFocusRef:P,value:i.value,setValue:R=>{f(b,R)},resetValue:()=>{f(b,null)},options:d.componentOptions})})})]})}})}),t.jsx(S,{children:t.jsxs(I,{children:[t.jsxs(yt,{min:0,max:F,defaultValue:i.weight??at,step:1,colorScheme:"primary",onChange:u=>{N(b,u)},flex:1,children:[t.jsx(wt,{children:t.jsx(St,{})}),t.jsx(Pt,{})]}),t.jsx(ht,{ml:4,minW:6,flex:"0 0 auto",textAlign:"right",children:i.weight})]})})]},b)})}),t.jsx(S,{mt:2,children:t.jsxs(hs,{children:[t.jsx(gs,{as:Y,leftIcon:t.jsx(tt,{as:xs,boxSize:4}),primary:!0,variant:(s==null?void 0:s.length)===0?"solid":"ghost",children:t.jsx(k,{id:"mqWXXZ"})}),t.jsx(vs,{maxH:"min(calc( 100vh - 264px ),700px)",overflow:"auto",css:st`
              &::-webkit-scrollbar {
                display: none;
              }
            `,children:j.map((i,b,d)=>t.jsxs(_.Fragment,{children:[i.map(P=>{const u=g.get(P);return u?t.jsxs(bs,{onClick:()=>{T(P)},children:[t.jsx(S,{as:u.icon,mr:2}),u.name]},P):null}),b<d.length-1&&t.jsx(js,{})]},b))})]})})]})};function Oi(e){return _.useMemo(()=>{const s=Array.from(e.keys()).reduce((r,n)=>{var x;const a=e.get(n);if(a===void 0||((x=a.isAvailable)==null?void 0:x.call(a))===!1||a.inactive)return r;const{sortGroup:g="default"}=a;return r[g]===void 0&&(r[g]=[]),r[g].push(n),r},{default:[]});return Object.values(s).map(r=>r.sort((n,a)=>{const g=e.get(n),x=e.get(a);return((g==null?void 0:g.name)??"").localeCompare((x==null?void 0:x.name)??"")}))},[e])}const Bi=({header:e,isOpen:s=!1,onClose:r,onSave:n,initialPermissionPreset:a,initialAcl:g,folderPermissionPreset:x,folderAcl:y,permissionPresetUserUid:p})=>{const f=ve(),N=c._({id:"tLv3Bv"}),[j,W]=_.useState(()=>({permissionPreset:a??"Private",permissionPresetUserUid:p??null,acl:g??[],folderPermissionPreset:x??void 0,folderAcl:y??[]})),D=_.useCallback(U=>{W(i=>({...i,...U,acl:vt(U,i,f.id),permissionPresetUserUid:bt(U,i,f.id)}))},[f.id]),T=j.permissionPreset==="Custom"||a==="Inherit"&&x==="Custom";return t.jsxs(fs,{isOpen:s,onClose:r,closeOnOverlayClick:!1,size:T?"4xl":"lg",children:[t.jsx(ys,{}),t.jsxs(Ps,{children:[t.jsx(ws,{children:e}),t.jsx(xe,{}),t.jsx(Ss,{children:t.jsxs(Re,{templateColumns:{base:"1fr",md:T?"1fr 1px 1fr":"1fr"},gap:4,children:[t.jsx(ae,{borderRight:{base:"none",md:T?"1px solid var(--chakra-colors-gray-200)":"none"},pr:{base:0,md:T?8:0},pb:{base:2,md:0},spacing:4,children:t.jsx(ks,{permissionPreset:j.permissionPreset,folderPermissionPreset:x,onChange:U=>D({permissionPreset:U}),localizedEntityName:N})}),t.jsx(xe,{}),T&&t.jsx(I,{maxH:{base:"660px",md:"430px"},children:t.jsx(Cs,{acl:(j.permissionPreset==="Inherit"?y:j.acl)??[],isDisabled:j.permissionPreset==="Inherit",onChange:U=>D({acl:U})})})]})}),t.jsx(xe,{}),t.jsx(Us,{children:t.jsxs(I,{alignItems:"flex-start",justifyContent:"space-between",w:"100%",children:[t.jsx(_s,{}),t.jsxs(ae,{isInline:!0,children:[t.jsx(Y,{type:"button",onClick:r,children:t.jsx(k,{id:"dEgA5A"})}),t.jsx(Y,{primary:!0,type:"button",onClick:()=>{n({permissionPreset:j.permissionPreset,permissionPresetUserUid:j.permissionPresetUserUid,acl:j.acl}),r()},children:t.jsx(k,{id:"DB8zMK"})})]})]})})]})]})};function Wi(){const s=Ts({name:"parameters"}).reduce((r,n)=>r+n.weight,0)>F;return t.jsx(Ms,{in:s,children:t.jsx(I,{justify:"right",textAlign:"right",mt:4,color:"primary.500",children:t.jsx(jt,{maxW:"35em","data-stonly":"maximum-score-exceeded",children:t.jsx(k,{id:"MN9q2M",values:{MAX_PARAMETER_WEIGHT:F}})})})})}function dt(e,s){const r={name:"",description:"",segmentation:{channel:"phone",values:{}},filters:{},savedFilterGroupUid:null,parameters:[],goal:null,permissionPreset:"Private",acl:[],permissionPresetUserUid:null,folderUid:null};if(!e)return r;const n={uid:e.uid,name:e.name,description:e.description??void 0,segmentation:{channel:"phone",savedFilter:s,values:ft((s==null?void 0:s.values)??{})},filters:e.filters,parameters:e.parameters,goal:e.goal==null?null:{min:e.goal.min??void 0,max:e.goal.max??void 0},permissionPreset:e.permissionPreset??void 0,acl:e.acl??[],permissionPresetUserUid:e.permissionPresetUserUid??null,folderUid:e.folderUid??null};return{...r,...n}}const Ve={customers:e=>({type:"customer",weight:e.weight,customers:e.value}),customNumberProp1:e=>({type:"custom-number-prop-1",weight:e.weight,...e.value}),customNumberProp2:e=>({type:"custom-number-prop-2",weight:e.weight,...e.value}),customNumberProp3:e=>({type:"custom-number-prop-3",weight:e.weight,...e.value}),customNumberProp4:e=>({type:"custom-number-prop-4",weight:e.weight,...e.value}),customNumberProp5:e=>({type:"custom-number-prop-5",weight:e.weight,...e.value}),customNumberProp6:e=>({type:"custom-number-prop-6",weight:e.weight,...e.value}),customNumberProp7:e=>({type:"custom-number-prop-7",weight:e.weight,...e.value}),customNumberProp8:e=>({type:"custom-number-prop-8",weight:e.weight,...e.value}),customNumberProp9:e=>({type:"custom-number-prop-9",weight:e.weight,...e.value}),customNumberProp10:e=>({type:"custom-number-prop-10",weight:e.weight,...e.value}),customProp1:e=>({type:"custom-prop-1",weight:e.weight,value:e.value[0]}),customProp2:e=>({type:"custom-prop-2",weight:e.weight,value:e.value[0]}),customProp3:e=>({type:"custom-prop-3",weight:e.weight,value:e.value[0]}),customProp4:e=>({type:"custom-prop-4",weight:e.weight,value:e.value[0]}),customProp5:e=>({type:"custom-prop-5",weight:e.weight,value:e.value[0]}),customProp6:e=>({type:"custom-prop-6",weight:e.weight,value:e.value[0]}),customProp7:e=>({type:"custom-prop-7",weight:e.weight,value:e.value[0]}),customProp8:e=>({type:"custom-prop-8",weight:e.weight,value:e.value[0]}),customProp9:e=>({type:"custom-prop-9",weight:e.weight,value:e.value[0]}),customProp10:e=>({type:"custom-prop-10",weight:e.weight,value:e.value[0]}),duration:e=>({type:"duration",weight:e.weight,...e.value}),externalIdentity:e=>({type:"external-identity",weight:e.weight,externalIdentity:e.value}),labels:e=>({type:"label",weight:e.weight,labels:e.value}),sentiment:e=>({type:"sentiment",weight:e.weight,...e.value}),status:e=>({type:"status",weight:e.weight,status:e.value}),subjects:e=>({type:"subject",weight:e.weight,subjects:e.value}),teamUids:e=>({type:"team",weight:e.weight,teamUids:e.value}),trackers:e=>({type:"tracker",weight:e.weight,trackerUids:e.value.uids}),notTrackers:e=>({type:"not-tracker",weight:e.weight,trackerUids:e.value.uids}),userUids:e=>({type:"user",weight:e.weight,userUids:e.value})};function O(e,s){const{min:r,max:n}=s;return{filterValueType:`customNumberProp${e}`,weight:s.weight,value:{min:r,max:n}}}function B(e,s){return{filterValueType:`customProp${e}`,weight:s.weight,value:s.value}}const Ne={"external-identity":e=>({filterValueType:"externalIdentity",weight:e.weight,value:e.externalIdentity}),customer:e=>({filterValueType:"customers",weight:e.weight,value:e.customers}),"custom-number-prop-1":e=>O(1,e),"custom-number-prop-2":e=>O(2,e),"custom-number-prop-3":e=>O(3,e),"custom-number-prop-4":e=>O(4,e),"custom-number-prop-5":e=>O(5,e),"custom-number-prop-6":e=>O(6,e),"custom-number-prop-7":e=>O(7,e),"custom-number-prop-8":e=>O(8,e),"custom-number-prop-9":e=>O(9,e),"custom-number-prop-10":e=>O(10,e),"custom-prop-1":e=>B(1,e),"custom-prop-2":e=>B(2,e),"custom-prop-3":e=>B(3,e),"custom-prop-4":e=>B(4,e),"custom-prop-5":e=>B(5,e),"custom-prop-6":e=>B(6,e),"custom-prop-7":e=>B(7,e),"custom-prop-8":e=>B(8,e),"custom-prop-9":e=>B(9,e),"custom-prop-10":e=>B(10,e),duration:e=>{const{min:s,max:r}=e;return{filterValueType:"duration",weight:e.weight,value:{min:s,max:r}}},label:e=>({filterValueType:"labels",weight:e.weight,value:e.labels}),sentiment:e=>{const{score:s,speaker:r}=e;return{filterValueType:"sentiment",weight:e.weight,value:{score:s,speaker:r}}},status:e=>({filterValueType:"status",weight:e.weight,value:e.status}),subject:e=>({filterValueType:"subjects",weight:e.weight,value:e.subjects}),team:e=>({filterValueType:"teamUids",weight:e.weight,value:e.teamUids}),tracker:e=>({filterValueType:"trackers",weight:e.weight,value:{uids:e.trackerUids}}),"not-tracker":e=>({filterValueType:"notTrackers",weight:e.weight,value:{uids:e.trackerUids}}),user:e=>({filterValueType:"userUids",weight:e.weight,value:e.userUids})};function zi(e){var s;return(s=Ve[e.filterValueType])==null?void 0:s.call(Ve,e)}function mt(e){var s;return(s=Ne[e.type])==null?void 0:s.call(Ne,e)}const Gi=it().shape({uid:he(),name:he().required(()=>c._({id:"BskXWC"})),description:he(),parameters:As().of(it().shape({filterValueType:he().required(),value:Is().required(()=>c._({id:"p3GAHe"})),weight:Es().positive().max(F).required()})).required().min(1,()=>c._({id:"5rojsr"}))}),qi=!1,Yi=({initialValues:e,children:s})=>{const r=_.useRef((e==null?void 0:e(dt))??dt()),n=Vs({defaultValues:r.current,resolver:Ns(Gi)});return t.jsxs(Rs,{...n,children:[s,qi]})};function $i(e){switch(e){case"NoAccess":return c._({id:"2BsGLu"});case"Editable":return;case"Viewable":return c._({id:"cAhYpC"})}}const Zi=({uid:e})=>{var H;const[s]=Fs(Ds),r=ve(),n=gt(r,{scores:{inactive:!0}}),{mutate:a}=Ui(),{mutate:g}=Ti(),{mutate:x}=_i(),{data:y}=Os(e),p=y==null?void 0:y.length,f=Bs(),{isOpen:N,onOpen:j,onClose:W}=Ws(),D=zs(),[T,U]=_.useState(!1),{data:i}=Gs(e,T?7e3:0);_.useEffect(()=>{i&&(i.isProcessing?T||U(!0):T&&U(!1))},[i,T]);const b=qs(),d=(h,m=!1)=>{f(ai.main(h),{replace:m})},{data:P}=$s({uid:i==null?void 0:i.savedFilterGroupUid}),[u,Z]=_.useState(()=>({uid:e??void 0,name:(i==null?void 0:i.name)??"",description:(i==null?void 0:i.description)??"",filters:(i==null?void 0:i.filters)??null,goal:e?(i==null?void 0:i.goal)??null:{min:5,max:void 0},segmentation:{channel:"phone",savedFilter:P,values:P!=null&&P.values?ft((P==null?void 0:P.values)??{}):(i==null?void 0:i.filters)??{}},savedFilterGroupUid:(i==null?void 0:i.savedFilterGroupUid)??null,permissionPreset:(i==null?void 0:i.permissionPreset)??"Private",permissionPresetUserUid:(i==null?void 0:i.permissionPresetUserUid)??null,acl:(i==null?void 0:i.acl)??[],folderUid:(i==null?void 0:i.folderUid)??void 0})),M=_.useCallback(h=>{Z(m=>({...m,...h,acl:vt(h,m,r.id),permissionPresetUserUid:bt(h,m,r.id)}))},[r.id]),[R,$]=_.useState((H=(i==null?void 0:i.parameters)||[])==null?void 0:H.map(mt)),de=()=>{var m;const h=R.map(zi);try{if(i){const E=(m=i.parameters||[])==null?void 0:m.map(mt),ie=nt(E,R),L=Object.keys(u).filter(C=>{if(C==="segmentation")return!1;const v=C;return!nt(i[v],u[v])});a({uid:i.uid,score:{...li(u,L),parameters:ie?void 0:h}},{onError:C=>{C instanceof Me&&b({title:c._({id:"BKcp+k"}),description:C.message,status:"error"})},onSuccess:C=>{Ae.event("scoreEditor_score_updated"),b({title:c._({id:"hStYGe",values:{0:C.name}}),status:"success"}),d(C.uid)}})}else g({...ci(u,"segmentation"),parameters:h},{onError:E=>{E instanceof Me&&b({title:c._({id:"BKcp+k"}),description:E.message,status:"error"})},onSuccess:E=>{Ae.event("scoreEditor_score_created"),b({title:c._({id:"4Ta+xI",values:{0:E.name}}),status:"success"}),d(E.uid)}})}catch{b({title:c._({id:"ATeu9g"}),description:"...",status:"error"})}},A=async()=>{try{i&&x(i.uid,{onSuccess:()=>{Ae.event("scoreEditor_score_deleted"),b({title:c._({id:"RLDLUk"}),status:"success"}),d()},onError:h=>{const m=ui(h,{409:c._({id:"gsWJ/u"})});m?b({title:c._({id:"gzr527"}),description:m,status:"error"}):h instanceof Me&&b({title:c._({id:"BKcp+k"}),description:h.message,status:"error"})}})}catch{b({title:c._({id:"2JFSkX"}),description:"...",status:"error"})}},fe=async()=>{if(p){s({heading:c._({id:"zlNGDl"}),description:c._({id:"LOONxx"}),dependents:y});return}try{await D({title:c._({id:"6foA8n"}),description:c._({id:"nGQQgf",values:{0:i==null?void 0:i.name}}),cancelText:c._({id:"dEgA5A"}),confirmText:c._({id:"cnGeoo"})}),A()}catch{return}},J={uid:e,permissionPreset:u.permissionPreset,permissionPresetUserUid:u.permissionPresetUserUid,acl:u.acl,folderUid:u.folderUid},{previewAccessResponse:ee,validationError:me}=Ls({previewAccessRequestModel:J,createPreviewAccessRequest:Ci.previewAccess}),te=R.length?u.name?"":c._({id:"ibUQ+0"}):c._({id:"+rYG8a"}),pe=i!=null&&i.isProcessing?c._({id:"gsWJ/u"}):void 0,se=c._({id:"DzJBOE"});return t.jsxs(t.Fragment,{children:[t.jsxs(I,{flexDirection:{base:"column",md:"row-reverse"},children:[t.jsx(S,{flex:1,children:t.jsx(I,{direction:"column",children:i&&t.jsxs(t.Fragment,{children:[t.jsx(rt,{fontSize:"sm",textAlign:"right",mt:2,children:t.jsx(ot,{userUid:i.createdByUserUid,date:i.created,label:c._({id:"d+F6q9"})})}),t.jsx(rt,{fontSize:"sm",textAlign:"right",children:t.jsx(ot,{userUid:i.updatedByUserUid,date:i.updated,label:c._({id:"+b7T3G"})})})]})})}),t.jsx(S,{mr:4,children:t.jsxs(Hs,{fontSize:"2xl",display:"flex",alignItems:"center",placeholder:c._({id:"Z5QedU"}),value:u.name,startWithEditView:!u.name.length,children:[t.jsx(Ks,{color:u.name.length?"inherit":"gray.400",whiteSpace:"nowrap"}),t.jsx(Qs,{onChange:h=>{M({name:h.target.value})},value:u.name,pl:2}),t.jsx(Mi,{ml:4})]})})]}),t.jsxs(I,{fontWeight:"500",alignItems:"center",justifyContent:"start",mb:"2",mt:8,children:[t.jsxs(Te,{pr:4,w:"initial",children:[t.jsx(X,{id:"description",leftIcon:t.jsx(Xs,{}),rightIcon:t.jsx(ge,{label:c._({id:"B4R6MK"}),children:t.jsx("span",{children:t.jsx(xt,{})})}),children:t.jsx(k,{id:"Nu4oKW"})}),t.jsx(Ys,{placeholder:c._({id:"Nu4oKW"}),minW:"32em",minH:"5em",maxW:"36em",onChange:h=>M({description:h.target.value}),value:u.description})]}),t.jsx(xe,{orientation:"vertical",height:"150px",backgroundColor:"gray.200",mr:4}),t.jsxs(S,{w:"100%",children:[t.jsxs(S,{fontWeight:"500",display:"flex",alignItems:"center",mb:"2",children:[t.jsx(Zs,{}),t.jsx(jt,{mx:2,children:t.jsx(k,{id:"DVDmRx"})})]}),t.jsx(Js,{permissionPreset:u.permissionPreset,localizedEntityName:"scores",onOpen:j,acl:u.acl}),t.jsx(ei,{warningText:$i(ee)}),t.jsx(ti,{validationError:me})]}),t.jsx(Te,{children:N&&t.jsx(Bi,{initialPermissionPreset:u.permissionPreset,initialAcl:(u==null?void 0:u.acl)??null,folderPermissionPreset:void 0,permissionPresetUserUid:u.permissionPresetUserUid,folderAcl:void 0,header:se,isOpen:N,onClose:W,onSave:h=>{M({acl:h.acl}),M({permissionPreset:h.permissionPreset}),M({permissionPresetUserUid:h.permissionPresetUserUid})}})})]}),t.jsxs(Te,{mt:8,children:[t.jsx(X,{id:"score",leftIcon:t.jsx(si,{}),"data-stonly":"score",children:t.jsx(k,{id:"Eq6YVV"})}),t.jsxs(Li,{mt:4,children:[t.jsxs(S,{children:[t.jsx(X,{mb:0,children:t.jsx(k,{id:"Jb157J"})}),t.jsx(Fe,{color:"textMuted",children:t.jsx(k,{id:"UD7yhA"})}),t.jsx(S,{children:t.jsx(ii,{name:"segmentation",render:({field:h})=>{var m,E,ie,L,C;return t.jsx(ri,{filterDefinitions:n,state:{channel:"phone",...u.segmentation,values:{...(m=u.segmentation)==null?void 0:m.values,duration:ni((ie=(E=u.segmentation)==null?void 0:E.values.duration)==null?void 0:ie.min,(C=(L=u.segmentation)==null?void 0:L.values.duration)==null?void 0:C.max)}},onStateChange:v=>{var K;oi(v)&&(v.savedFilter=void 0),h.onChange(v),v.savedFilter?M({savedFilterGroupUid:(K=v.savedFilter)==null?void 0:K.uid,segmentation:{channel:"phone",savedFilter:v.savedFilter,values:v.values},filters:null}):v.values&&M({filters:v.values,segmentation:{channel:"phone",savedFilter:void 0,values:v.values},savedFilterGroupUid:null})}})}})})]}),t.jsx(Di,{goal:u.goal,params:R,onGoalChange:h=>M({goal:h.goal}),onParameterChange:$})]})]}),t.jsx(Wi,{}),t.jsxs(I,{as:"footer",mt:8,justifyContent:i?"initial":"end",children:[i&&t.jsx(ge,{label:pe,placement:"top",children:t.jsx(Y,{mr:"auto",colorScheme:"red",size:"md",onClick:()=>fe(),isDisabled:i==null?void 0:i.isProcessing,children:t.jsx(k,{id:"cnGeoo"})})}),t.jsx(Y,{secondary:!0,size:"md",mr:2,onClick:()=>d(),children:t.jsx(k,{id:"dEgA5A"})}),t.jsx(ge,{label:te,isDisabled:R.length>0&&u.name.length>0,hasArrow:!0,placement:"top",children:t.jsx(Y,{isDisabled:R.length<1||u.name.length<1,size:"md",primary:!0,onClick:de,children:t.jsx(k,{id:"vnSDk7"})})})]})]})},Li=e=>t.jsx(I,{direction:"column",border:"1px",borderColor:"gray.300",borderRadius:"md",p:4,...e});export{Yi as S,Zi as a};
//# sourceMappingURL=ScoreEditor-b3a6313c.js.map
