unleash-server 5.3.0 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/services/client-metrics/metrics-service-v2.d.ts +2 -0
- package/dist/lib/services/client-metrics/metrics-service-v2.js +27 -17
- package/dist/lib/services/client-metrics/metrics-service-v2.js.map +1 -1
- package/dist/lib/services/client-metrics/metrics-service-v2.test.d.ts +1 -0
- package/dist/lib/services/client-metrics/metrics-service-v2.test.js +96 -0
- package/dist/lib/services/client-metrics/metrics-service-v2.test.js.map +1 -0
- package/dist/lib/types/experimental.d.ts +1 -1
- package/dist/lib/types/experimental.js +1 -0
- package/dist/lib/types/experimental.js.map +1 -1
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/{AdvancedPlayground-4c9d02ea.js → AdvancedPlayground-48dddbf4.js} +1 -1
- package/frontend/build/static/{CreateProject-16b35d57.js → CreateProject-c1b0f704.js} +1 -1
- package/frontend/build/static/{Error-50364f10.js → Error-e6f7c2ee.js} +1 -1
- package/frontend/build/static/FeatureArchiveDialog-9ad60db1.js +10 -0
- package/frontend/build/static/{FeatureMetricsChart-839cdf1e.js → FeatureMetricsChart-81da0ce4.js} +1 -1
- package/frontend/build/static/{FeatureViewLazyExport-47bb7f13.js → FeatureViewLazyExport-58a3e977.js} +2 -2
- package/frontend/build/static/{LazyAdminExport-8ef0ca21.js → LazyAdminExport-c98b11d7.js} +2 -2
- package/frontend/build/static/{LazyProjectExport-49541c75.js → LazyProjectExport-14db2e37.js} +1 -1
- package/frontend/build/static/{NetworkOverview-711050f3.js → NetworkOverview-cd06e59f.js} +2 -2
- package/frontend/build/static/{NetworkTraffic-e587c2c7.js → NetworkTraffic-ba933617.js} +1 -1
- package/frontend/build/static/{RoleCell-9a62b4ed.js → RoleCell-c534790e.js} +1 -1
- package/frontend/build/static/{StrategyItemContainer-4098c8ef.js → StrategyItemContainer-88c18285.js} +1 -1
- package/frontend/build/static/{chartjs-adapter-date-fns.esm-d57aaddd.js → chartjs-adapter-date-fns.esm-799be047.js} +1 -1
- package/frontend/build/static/{flowchart-elk-definition-170a3958-4dece62b.js → flowchart-elk-definition-170a3958-543f0844.js} +1 -1
- package/frontend/build/static/{index-9c528324.js → index-1c4c68c3.js} +2 -2
- package/frontend/build/static/{index-9bb67f88.js → index-88f1c682.js} +1 -1
- package/frontend/build/static/{index-1c8194e0.js → index-aa638b65.js} +1 -1
- package/frontend/build/static/{is_dark-ba77f0b9.js → is_dark-735e3a95.js} +1 -1
- package/frontend/build/static/{mindmap-definition-44684416-a4071c9f.js → mindmap-definition-44684416-ac92f950.js} +1 -1
- package/frontend/build/static/{timeline-definition-8e5a9bc6-c996bf40.js → timeline-definition-8e5a9bc6-6c09f608.js} +1 -1
- package/frontend/build/static/{unknownify-db48ebae.js → unknownify-0b176a78.js} +1 -1
- package/package.json +1 -1
- package/frontend/build/static/FeatureArchiveDialog-fda1aa0c.js +0 -10
|
@@ -353,12 +353,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
353
353
|
--data-raw '${JSON.stringify(S(),void 0,2)}'`,children:l(FM,{handleSubmit:async z=>{if(r){z.preventDefault(),A();try{await c(r.id,S()),await d(),s(t?`/projects/${t}/settings/segments/`:"/segments/"),i({title:"Segment updated",type:"success"})}catch(L){a(gt(L))}}},name:p,setName:f,description:h,setDescription:g,project:v,setProject:b,constraints:y,setConstraints:w,errors:k,clearErrors:A,mode:"edit",children:l(zc,{permission:W2,disabled:!T||_,"data-testid":Yie})})})},aAe=()=>{const{uiConfig:e}=It(),t=pt();return l(iD,{onClick:()=>t("/environments/create"),maxWidth:"700px",Icon:ha,permission:yi,disabled:!e.flags.EEA,children:"New environment"})},sAe=(e,t,n)=>{const r=m.useRef(null);return m.useEffect(()=>{if(r.current)return r.current.dataset.index=String(e),lAe(r.current,t,(n==null?void 0:n.current)??void 0)},[e,t]),r},lAe=(e,t,n)=>{const r=p=>{bg&&t(Number(bg.dataset.index),Number(e.dataset.index),p)},o=n??e,i=p=>{p.target===o&&(e.draggable=!0)},a=()=>{e.draggable=!1},s=()=>{e.draggable=!0,bg=e},c=()=>{r(!1)},u=p=>{p.preventDefault()},d=()=>{r(!0),bg=null};return o.addEventListener("mouseenter",i),o.addEventListener("mouseleave",a),n&&e.addEventListener("mouseenter",a),e.addEventListener("dragstart",s),e.addEventListener("dragenter",c),e.addEventListener("dragover",u),e.addEventListener("drop",d),()=>{o.removeEventListener("mouseenter",i),o.removeEventListener("mouseleave",a),n&&e.removeEventListener("mouseenter",a),e.removeEventListener("dragstart",s),e.removeEventListener("dragenter",c),e.removeEventListener("dragover",u),e.removeEventListener("drop",d)}};let bg;const cAe=C(ui)(()=>({"&:hover":{".drag-handle .drag-icon":{display:"inherit",cursor:"grab"}}})),uAe=({row:e,moveListItem:t})=>{const{hasAccess:n}=m.useContext(_o),r=m.useRef(null),{searchQuery:o}=Ol(),i=!o&&n(wx),a=sAe(e.index,t,r),s=(c,u)=>i&&c.column.isDragHandle?l(pi,{...c.getCellProps(),ref:u,className:"drag-handle",children:c.render("Cell")}):l(pi,{...c.getCellProps(),children:c.render("Cell")});return l(cAe,{hover:!0,ref:i?a:void 0,children:e.cells.map(c=>s(c,r))})},dAe=C(se)(({theme:e})=>({fontWeight:"bold",fontSize:e.fontSizes.smallerBody})),pAe=C(se)(({theme:e})=>({fontSize:e.fontSizes.smallerBody})),W3=C(qt)(({theme:e})=>({marginLeft:e.spacing(1)})),fAe=({environment:e})=>{const{searchQuery:t}=Ol();return x(Hn,{sx:n=>({[n.breakpoints.up("sm")]:{minWidth:"350px"}}),children:[l(Ya,{search:t,children:e.name}),l(q,{condition:e.protected,show:l(W3,{color:"success",children:"Predefined"})}),l(q,{condition:!e.enabled,show:l(Dc,{maxWidth:"270px",title:x(ve,{children:[l(dAe,{children:"Deprecated environment"}),l(pAe,{children:"This environment is not auto-enabled for new projects. The project owner will need to manually enable it in the project."})]}),describeChild:!0,arrow:!0,children:l(W3,{color:"neutral",children:"Deprecated"})})})]})},wu=({permission:e,projectId:t,children:n,environmentId:r,tooltip:o,tooltipProps:i})=>{const{hasAccess:a}=m.useContext(_o);let s;return t&&r?s=a(e,t,r):t?s=a(e,t):s=a(e),l(Id,{...i,title:O1(s,o),children:n({hasAccess:s})})},hAe=C(ZE)(({theme:e})=>({padding:e.spacing(1)})),Gg=C(qa)(({theme:e})=>({borderRadius:e.shape.borderRadius})),mAe=C(Gg)(({theme:e})=>({color:e.palette.error.main})),gAe=C(Du)(({theme:e})=>({color:e.palette.error.main})),vAe=({environment:e,onEdit:t,onDeprecateToggle:n,onClone:r,onDelete:o})=>{const[i,a]=m.useState(null),s=!!i,c=f=>{a(f.currentTarget)},u=()=>{a(null)},d=`environment-${e.name}-actions`,p=`${d}-menu`;return x(ve,{children:[l(xt,{title:"Environment actions",arrow:!0,describeChild:!0,children:l(jt,{id:d,"aria-controls":s?p:void 0,"aria-haspopup":"true","aria-expanded":s?"true":void 0,onClick:c,type:"button",children:l(rT,{})})}),l(e2,{id:p,anchorEl:i,open:s,onClose:u,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},disableScrollLock:!0,children:x(hAe,{"aria-labelledby":d,children:[l(wu,{permission:wx,children:({hasAccess:f})=>x(Gg,{onClick:()=>{t(),u()},disabled:!f||e.protected,children:[l(Du,{children:l(di,{})}),l(rn,{children:l(se,{variant:"body2",children:"Edit"})})]})}),l(wu,{permission:yi,children:({hasAccess:f})=>x(Gg,{onClick:()=>{r(),u()},disabled:!f,children:[l(Du,{children:l(Cle,{})}),l(rn,{children:l(se,{variant:"body2",children:"Clone"})})]})}),l(wu,{permission:wx,children:({hasAccess:f})=>x(Gg,{onClick:()=>{n(),u()},disabled:!f||e.protected,children:[l(Du,{children:l(q,{condition:e.enabled,show:l(Zle,{}),elseShow:l(ece,{})})}),l(rn,{children:l(se,{variant:"body2",children:e.enabled?"Deprecate":"Undeprecate"})})]})}),l(wu,{permission:xpe,children:({hasAccess:f})=>x(mAe,{onClick:()=>{o(),u()},disabled:!f||e.protected,children:[l(gAe,{children:l(vo,{})}),l(rn,{children:l(se,{variant:"body2",children:"Delete"})})]})})]})})]})},H3=(e,t)=>{var n;return!!((n=t==null?void 0:t.toLowerCase())!=null&&n.includes(e.toLowerCase()))},yAe=C("div")(({theme:e})=>({display:"flex",flexDirection:"column",color:e.palette.text.secondary,"& > span:first-of-type":{color:e.palette.text.primary}})),bAe=C("div")(({theme:e})=>({paddingLeft:e.spacing(1)})),wAe=C("div")(({theme:e})=>({display:"flex",marginBottom:e.spacing(3),"& > div:first-of-type":{width:"100%",maxWidth:e.spacing(50),marginRight:e.spacing(1)}})),SAe=(e,t,n)=>x("li",{...e,children:[l(pa,{icon:l(n0,{fontSize:"small"}),checkedIcon:l(r0,{fontSize:"small"}),style:{marginRight:8},checked:n}),x(yAe,{children:[l("span",{children:t.name}),l("span",{children:t.description})]})]}),xAe=e=>l(bAe,{children:e.length>1?`${e.length} projects selected`:e[0].name}),CAe=({projects:e,setProjects:t})=>{const{projects:n}=ma(),r=n.sort((c,u)=>c.name.localeCompare(u.name)).map(({id:c,name:u,description:d})=>({id:c,name:u,description:d})),o=r.filter(({id:c})=>e.includes(c)),i=e.length>0&&e.length===r.length,a=()=>{const c=i?[]:r.map(({id:u})=>u);t(c)};return l(wAe,{children:l(Ad,{size:"small",multiple:!0,limitTags:1,openOnFocus:!0,disableCloseOnSelect:!0,value:o,onChange:(c,u,d)=>{c.type==="keydown"&&c.key==="Backspace"&&d==="removeOption"||t(u.map(({id:p})=>p))},options:r,renderOption:(c,u,{selected:d})=>SAe(c,u,d),filterOptions:(c,{inputValue:u})=>c.filter(({name:d,description:p})=>H3(u,d)||H3(u,p)),isOptionEqualToValue:(c,u)=>c.id===u.id,getOptionLabel:c=>c.name||c.description||"",renderInput:c=>l(pn,{...c,label:"Projects"}),renderTags:c=>xAe(c),groupBy:()=>"Select/Deselect all",renderGroup:({key:c,children:u})=>x(m.Fragment,{children:[l(q,{condition:r.length>2,show:l(GT,{isAllSelected:i,onClick:a})}),u]},c)})})},Lp="*",EAe=({...e})=>l(Cr,{elevation:8,...e}),TAe=C(pa)(({theme:e})=>({marginRight:e.spacing(.4)})),kAe=({options:e,defaultValue:t=[Lp],onChange:n,disabled:r,error:o,onFocus:i})=>{const[a,s]=m.useState(typeof t=="string"?[t]:t),[c,u]=m.useState(typeof t=="string"||t.includes(Lp)),d=a.length>0&&a.length===e.length&&a[0]!==Lp,p=(b,y)=>{y?(u(!0),n([Lp])):(u(!1),n(a.includes(Lp)?[]:a))},f=()=>{const b=d?[]:e.map(({value:y})=>y);s(b),n(b)};return x($e,{sx:{mt:-1,mb:3},children:[l($e,{sx:{mt:1,mb:.25,ml:1.5},children:l(Mr,{disabled:r,"data-testid":"select-all-projects",control:l(pa,{checked:r||c,onChange:p}),label:"ALL current and future projects"})}),l(Ad,{disabled:r||c,multiple:!0,limitTags:2,options:e,disableCloseOnSelect:!0,getOptionLabel:({label:b})=>b,groupBy:()=>"Select/Deselect all",renderGroup:({key:b,children:y})=>x(m.Fragment,{children:[l(q,{condition:e.length>2,show:l(GT,{isAllSelected:d,onClick:f})}),y]},b),fullWidth:!0,PaperComponent:EAe,renderOption:(b,y,{selected:w})=>x("li",{...b,children:[l(TAe,{icon:l(n0,{fontSize:"small"}),checkedIcon:l(r0,{fontSize:"small"}),checked:w}),y.label]}),renderInput:b=>l(pn,{...b,error:!!o,helperText:o,variant:"outlined",label:"Projects",placeholder:"Select one or more projects",onFocus:i,"data-testid":"select-input"}),value:c||r?e:e.filter(b=>a.includes(b.value)),onChange:(b,y)=>{const w=y.map(({value:S})=>S);s(w),n(w)}})]})},AAe=()=>{const{makeRequest:e,createRequest:t,errors:n,loading:r}=Vn({propagateErrors:!0});return{deleteToken:async a=>{const s=`api/admin/api-tokens/${a}`,c=t(s,{method:"DELETE"});try{return await e(c.caller,c.id)}catch(u){throw u}},createToken:async a=>{const c=t("api/admin/api-tokens",{method:"POST",body:JSON.stringify(a)});try{return await e(c.caller,c.id)}catch(u){throw u}},errors:n,loading:r}},RAe=C("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),iu=C("p")(({theme:e})=>({display:"flex",color:e.palette.text.primary,marginBottom:e.spacing(1),"&:not(:first-of-type)":{marginTop:e.spacing(4)}})),Cw=C("p")(({theme:e})=>({color:e.palette.text.secondary,marginBottom:e.spacing(1)})),_Ae=C(rr)(({theme:e})=>({width:"100%",maxWidth:e.spacing(50)})),PAe=C("div")(({theme:e})=>({padding:e.spacing(3),backgroundColor:e.palette.background.elevation2,borderRadius:e.shape.borderRadiusMedium,marginTop:e.spacing(4)})),IAe=C("div")(({theme:e})=>({padding:e.spacing(0,4),"& > p:not(:first-of-type)":{marginTop:e.spacing(2)}})),OAe=C("div")(({theme:e})=>({marginTop:"auto",display:"flex",justifyContent:"flex-end",[e.breakpoints.down("sm")]:{marginTop:e.spacing(4)}})),$Ae=C(Ve)(({theme:e})=>({marginLeft:e.spacing(3)})),NAe=({environment:e,open:t,setOpen:n,newToken:r})=>{const{environments:o,refetchEnvironments:i}=$d(),{cloneEnvironment:a,loading:s}=Md(),{createToken:c}=AAe(),{projects:u}=ma(),{setToastData:d,setToastApiError:p}=$t(),{uiConfig:f}=It(),[h,g]=m.useState(`${e.name}_clone`),[v,b]=m.useState("development"),[y,w]=m.useState([]),[S,k]=m.useState(["*"]),[A,T]=m.useState(!0),[R,P]=m.useState("later"),[_,O]=m.useState({}),$=J=>{O(ae=>({...ae,[J]:void 0}))},z=(J,ae)=>{O(Te=>({...Te,[J]:ae}))};m.useEffect(()=>{g(L(e.name)),b("development"),w([]),k(["*"]),T(!0),P("later"),O({})},[e]);const L=J=>{let ae=`${J}_clone`,Te=2;for(;!W(ae);)ae=`${e.name}_clone_${Te}`,Te++;return ae},B=()=>({name:h,type:v,projects:y,clonePermissions:A}),Y=()=>({username:`${h}_token`,type:"CLIENT",environment:h,projects:S}),H=async J=>{J.preventDefault();try{if(await a(e.name,B()),R==="now"){const Te=await(await c(Y())).json();r(Te)}d({title:"Environment successfully cloned!",type:"success"}),i(),n(!1)}catch(ae){p(gt(ae))}},ee=()=>`curl --location --request POST '${f.unleashUrl}/api/admin/environments/${e.name}/clone' \\
|
|
354
354
|
--header 'Authorization: INSERT_API_KEY' \\
|
|
355
355
|
--header 'Content-Type: application/json' \\
|
|
356
|
-
--data-raw '${JSON.stringify(B(),void 0,2)}'`,V=J=>J.length,W=J=>!(o!=null&&o.some(ae=>ae.name===J)),j=V(h)&&W(h)&&S.length,I=J=>{$("name"),W(J)||z("name","An environment with that name already exists."),g(J)},M=u.map(J=>({value:J.id,label:J.name}));return l(om,{open:t,onClose:()=>{n(!1)},label:`Clone ${e.name} environment`,children:l(Fr,{loading:s,modal:!0,title:`Clone ${e.name} environment`,description:"Cloning an environment will clone all feature toggles and their configuration (activation strategies, segments, status, etc) into a new environment.",documentationLink:"https://docs.getunleash.io/reference/environments#cloning-environments",documentationLinkLabel:"Cloning environments documentation",formatApiCode:ee,children:x(RAe,{onSubmit:H,children:[x("div",{children:[l(iu,{children:"What is your new environment name? (Can't be changed later)"}),l(_Ae,{autoFocus:!0,label:"Environment name",error:!!_.name,errorText:_.name,value:h,onChange:J=>I(J.target.value),required:!0}),l(iu,{children:"What type of environment do you want to create?"}),l(cD,{onChange:J=>b(J.currentTarget.value),value:v}),x(iu,{children:["Select which projects you want to clone the environment configuration in?",l(Xa,{tooltip:"The cloned environment will keep the feature toggle state for the selected projects, where it will be enabled by default."})]}),l(CAe,{projects:y,setProjects:w}),l(iu,{children:"Keep the users permission for this environment?"}),l(Cw,{children:"If you turn it off, the permission for this environment across all projects and feature toggles will remain only for admin and editor roles."}),l(Mr,{label:A?"Yes":"No",control:l(fa,{onChange:J=>T(J.target.checked),checked:A})}),x(PAe,{children:[l(iu,{children:"API Token"}),x(Cw,{children:["In order to connect your SDKs to your newly cloned environment, you will also need an API token."," ",l(Gr,{href:"https://docs.getunleash.io/reference/api-tokens-and-client-keys",target:"_blank",rel:"noreferrer",children:"Read more about API tokens"}),"."]}),l($s,{children:x(r2,{value:R,onChange:J=>P(J.target.value),name:"api-token-generation",children:[l(Mr,{value:"later",control:l(sc,{}),label:"I want to generate an API token later"}),l(Mr,{value:"now",control:l(sc,{}),label:"Generate an API token now"})]})}),x(IAe,{children:[l(Cw,{children:"A new Server-side SDK (CLIENT) API token will be generated for the cloned environment, so you can get started right away."}),l(q,{condition:R==="now",show:x(ve,{children:[l(iu,{children:"Which projects do you want this token to give access to?"}),l(kAe,{options:M,defaultValue:S,onChange:k,error:_.projects,onFocus:()=>$("projects")})]})})]})]})]}),x(OAe,{children:[l(Ve,{type:"submit",variant:"contained",color:"primary",disabled:!j,children:"Clone environment"}),l($Ae,{onClick:()=>{n(!1)},children:"Cancel"})]})]})})})};var JT={},LAe=An;Object.defineProperty(JT,"__esModule",{value:!0});var jM=JT.default=void 0,DAe=LAe(Rn()),MAe=_n,BAe=(0,DAe.default)((0,MAe.jsx)("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4 6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z"}),"FileCopy");jM=JT.default=BAe;const UM=({token:e})=>{const{setToastData:t}=$t();return x($e,{sx:r=>({backgroundColor:r.palette.background.elevation2,padding:r.spacing(4),borderRadius:`${r.shape.borderRadius}px`,marginTop:r.spacing(2),display:"flex",justifyContent:"space-between",alignItems:"center",wordBreak:"break-all"}),children:[e,l(xt,{title:"Copy token",arrow:!0,children:l(jt,{onClick:()=>{pD(e)?t({type:"success",title:"Token copied to clipboard"}):t({type:"error",title:"Could not copy token"})},size:"large",children:l(jM,{})})})]})},FAe=({open:e,setOpen:t,token:n})=>x(vr,{open:e,secondaryButtonText:"Close",onClose:(r,o)=>{o||t(!1)},title:"New API token created",children:[l(se,{variant:"body1",children:"Your new token has been created successfully."}),x(se,{variant:"body1",children:['You can also find it as "',l("strong",{children:n==null?void 0:n.username}),'" in the'," ",l(an,{to:"/admin/api",children:"API access page"}),"."]}),l(UM,{token:(n==null?void 0:n.secret)||""})]}),zAe=C($e)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"flex-end",paddingLeft:e.spacing(.5),minWidth:e.spacing(6.5),cursor:"grab"})),jAe=C(jt)(({theme:e})=>({padding:e.spacing(1.5,0),cursor:"inherit",transition:"color 0.2s ease-in-out",color:e.palette.action.active})),UAe=C($L,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:t})=>({color:t?e.palette.neutral.border:e.palette.primary.main})),WM=({environment:e})=>x(zAe,{children:[l(jAe,{size:"large",disableRipple:!0,className:"drag-icon",children:l(Ole,{titleAccess:"Drag to reorder"})}),l(UAe,{deprecated:!e.enabled})]}),WAe=C(Gi)(({theme:e})=>({marginTop:e.spacing(3)})),HAe=C("p",{shouldForwardProp:e=>e!=="warning"})(({theme:e,warning:t})=>({color:t?e.palette.error.dark:e.palette.text.primary})),HM=({environment:e,warnEnabledToggles:t})=>{const n=m.useMemo(()=>[{id:"Icon",width:"1%",Cell:({row:{original:c}})=>l(WM,{environment:c})},{Header:"Name",accessor:"name",Cell:Hn},{Header:"Type",accessor:"type",Cell:Hn},{Header:"Visible in",accessor:c=>c.projectCount===1?"1 project":`${c.projectCount} projects`,Cell:({row:{original:c},value:u})=>x(Hn,{children:[u,l(q,{condition:!!t,show:l(HAe,{warning:!!(c.enabledToggleCount&&c.enabledToggleCount>0),children:c.enabledToggleCount===1?"1 toggle enabled":`${c.enabledToggleCount} toggles enabled`})})]})}],[t]),{getTableProps:r,getTableBodyProps:o,headerGroups:i,rows:a,prepareRow:s}=Jt.useTable({columns:n,data:[e],disableSortBy:!0});return x(WAe,{...r(),rowHeight:"compact",children:[l(Vi,{headerGroups:i}),l(Wi,{...o(),children:a.map(c=>(s(c),l(ui,{hover:!0,...c.getRowProps(),children:c.cells.map(u=>l(pi,{...u.getCellProps(),children:u.render("Cell")}))})))})]})},VAe=({environment:e,open:t,setOpen:n,onConfirm:r})=>{const{enabled:o}=e,i=o?"Deprecate":"Undeprecate";return x(vr,{title:`${i} environment?`,open:t,primaryButtonText:i,secondaryButtonText:"Close",onClick:r,onClose:()=>{n(!1)},children:[l(q,{condition:o,show:l(Vt,{severity:"info",children:"Deprecating an environment will mark it as deprecated. Deprecated environments are set as not visible by default for new projects. Project owners are still able to override this setting in the project. This environment will still be visible in any current projects."}),elseShow:l(Vt,{severity:"info",children:"Undeprecating an environment will no longer mark it as deprecated. An undeprecated environment will be set as visible by default for new projects."})}),l(HM,{environment:e})]})},GAe=C("p")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1.5)})),qAe=C(rr)(()=>({width:"100%"})),YAe=({environment:e,open:t,setOpen:n,onConfirm:r})=>{const[o,i]=m.useState("");return m.useEffect(()=>{i("")},[t]),x(vr,{title:"Delete environment?",open:t,primaryButtonText:"Delete environment",disabledPrimaryButton:e.name!==o,secondaryButtonText:"Close",onClick:r,onClose:()=>{n(!1)},children:[x(Vt,{severity:"error",children:[l("strong",{children:"Danger! This action is not reversible. Please proceed with caution."})," ","Deleting this environment will result in removing all strategies that are active in this environment across all feature toggles."]}),l(HM,{environment:e,warnEnabledToggles:!0}),x(GAe,{children:["In order to delete this environment, please enter the id of the environment in the textfield below:"," ",l("strong",{children:e.name})]}),l(qAe,{label:"Environment name",value:o,onChange:a=>i(a.target.value)})]})},KAe=({environment:e})=>{const t=pt(),{setToastApiError:n,setToastData:r}=$t(),{environments:o,refetchEnvironments:i}=$d(),{refetch:a}=oT(),{deleteEnvironment:s,toggleEnvironmentOn:c,toggleEnvironmentOff:u}=Md(),[d,p]=m.useState(!1),[f,h]=m.useState(!1),[g,v]=m.useState(!1),[b,y]=m.useState(!1),[w,S]=m.useState();return x(da,{children:[l(vAe,{environment:e,onEdit:()=>t(`/environments/${e.name}`),onDeprecateToggle:()=>h(!0),onClone:()=>{o.length<Wv?v(!0):r({type:"error",title:"Environment limit reached",text:`You have reached the maximum number of environments (${Wv}). Please reach out if you need more.`})},onDelete:()=>p(!0)}),l(YAe,{environment:e,open:d,setOpen:p,onConfirm:async()=>{try{await s(e.name),a(),r({type:"success",title:"Environment deleted",text:`You have successfully deleted the ${e.name} environment.`})}catch(T){n(gt(T))}finally{p(!1),await i()}}}),l(VAe,{environment:e,open:f,setOpen:h,onConfirm:async()=>{try{e.enabled?(await u(e.name),r({type:"success",title:"Environment deprecated successfully"})):(await c(e.name),r({type:"success",title:"Environment undeprecated successfully"}))}catch(T){n(gt(T))}finally{h(!1),await i()}}}),l(NAe,{environment:e,open:g,setOpen:v,newToken:T=>{S(T),y(!0)}}),l(FAe,{open:b,setOpen:y,token:w})]})},XAe=C(Vt)(({theme:e})=>({marginBottom:e.spacing(4)})),JAe=()=>{const{changeSortOrder:e}=Md(),{setToastApiError:t}=$t(),{environments:n,mutateEnvironments:r}=$d(),o=m.useCallback(async(b,y,w=!1)=>{const S=[...n],k=S[b];if(S.splice(b,1),S.splice(y,0,k),await r(S),w)try{await e(Ove(S))}catch(A){t(gt(A))}},[e,n,r,t]),{getTableProps:i,getTableBodyProps:a,headerGroups:s,rows:c,prepareRow:u,state:{globalFilter:d},setGlobalFilter:p}=Jt.useTable({columns:QAe,data:n,disableSortBy:!0},Jt.useGlobalFilter),h=x(ve,{children:[l(ko,{initialValue:d,onChange:p}),l(Tn.Divider,{}),l(aAe,{})]});let g=c.length;const v=l(Tn,{title:`Environments (${g})`,actions:h});return x(yr,{header:v,children:[l(XAe,{severity:"info",children:"This is the order of environments that you have today in each feature toggle. Rearranging them here will change also the order inside each feature toggle."}),l(Ls,{value:d,children:x(Gi,{...i(),rowHeight:"compact",children:[l(Vi,{headerGroups:s}),l(Wi,{...a(),children:c.map(b=>(u(b),l(uAe,{row:b,moveListItem:o},b.original.name)))})]})}),l(q,{condition:c.length===0,show:l(q,{condition:(d==null?void 0:d.length)>0,show:x(ar,{children:["No environments found matching “",d,"”"]}),elseShow:l(ar,{children:"No environments available. Get started by adding one."})})})]})},QAe=[{id:"Icon",width:"1%",Cell:({row:{original:e}})=>l(WM,{environment:e}),disableGlobalFilter:!0,isDragHandle:!0},{Header:"Name",accessor:"name",Cell:({row:{original:e}})=>l(fAe,{environment:e}),minWidth:350},{Header:"Type",accessor:"type",Cell:bs},{Header:"Visible in",accessor:e=>e.projectCount===1?"1 project":`${e.projectCount} projects`,Cell:Hn},{Header:"API Tokens",accessor:e=>e.apiTokenCount===1?"1 token":`${e.apiTokenCount} tokens`,Cell:Hn},{Header:"Actions",id:"Actions",align:"center",width:"1%",Cell:({row:{original:e}})=>l(KAe,{environment:e}),disableGlobalFilter:!0}],ZAe=()=>{const e=Ka("projectId"),t=pt();return l(Po,{onClick:()=>{t(e?`/projects/${e}/settings/segments/create`:"/segments/create")},permission:[N1,H2],projectId:e,"data-testid":Fie,children:"New segment"})},eRe=C("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:e.spacing(6),marginLeft:"auto",marginRight:"auto"})),tRe=C(se)(({theme:e})=>({fontSize:e.fontSizes.mainHeader,marginBottom:e.spacing(2.5)})),nRe=C("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,maxWidth:515,marginBottom:e.spacing(2.5),textAlign:"center"})),rRe=C(an)(({theme:e})=>({textDecoration:"none",color:e.palette.primary.main,fontWeight:e.fontWeight.bold})),oRe=()=>{const{hasAccess:e}=m.useContext(_o);return x(eRe,{children:[l(tRe,{children:"No segments yet!"}),l(nRe,{children:"Segment makes it easy for you to define who should be exposed to your feature. The segment is often a collection of constraints and can be reused."}),l(q,{condition:e(N1),show:l(rRe,{to:"/segments/create",children:"Create your first segment"})})]})},iRe=C(rr)(({theme:e})=>({marginTop:e.spacing(2)})),aRe=({segment:e,open:t,onClose:n,onRemove:r})=>{const[o,i]=m.useState(""),a=u=>i(u.currentTarget.value),s=()=>{n(),i("")},c="delete-segment-confirmation-form";return x(vr,{title:"Are you sure you want to delete this segment?",open:t,primaryButtonText:"Delete segment",secondaryButtonText:"Cancel",onClick:()=>{r(),i("")},disabledPrimaryButton:(e==null?void 0:e.name)!==o,onClose:s,formId:c,children:[x("p",{children:["In order to delete this segment, please enter the name of the segment in the field below: ",l("strong",{children:e==null?void 0:e.name})]}),l("form",{id:c,children:l(iRe,{autoFocus:!0,onChange:a,value:o,label:"Segment name","data-testid":Xie})})]})},sRe=C("ul")({marginBottom:0}),lRe=C(an)(({theme:e})=>({textDecoration:"none",color:e.palette.primary.main,fontWeight:e.fontWeight.bold})),cRe=({segment:e,open:t,onClose:n,strategies:r})=>x(vr,{title:"You can't delete a segment that's currently in use",open:t,primaryButtonText:"OK",onClick:n,children:[x("p",{children:["The following feature toggles are using the"," ",l("strong",{children:e.name})," segment for their strategies:"]}),l(sRe,{children:r==null?void 0:r.map(o=>l("li",{children:x(lRe,{to:BT(o.projectId,o.featureName,o.environment,o.id),target:"_blank",rel:"noopener noreferrer",children:[o.featureName," ",uRe(o)]})},o.id))})]}),uRe=e=>e.strategyName?`(${ks(e.strategyName)})`:"",dRe=({segment:e,open:t,onClose:n,onRemove:r})=>{const{strategies:o,loading:i}=DM(e.id),a=(o==null?void 0:o.length)===0;return i?null:l(q,{condition:a,show:l(aRe,{segment:e,open:t,onClose:n,onRemove:r}),elseShow:l(cRe,{segment:e,open:t,onClose:n,strategies:o})})},pRe=({segment:e})=>{const t=Ka("projectId"),{refetchSegments:n}=$l(),{deleteSegment:r}=qT(),{setToastData:o,setToastApiError:i}=$t(),[a,s]=m.useState(!1),c=async()=>{try{await r(e.id),await n(),o({type:"success",title:"Successfully deleted segment"})}catch(u){i(gt(u))}finally{s(!1)}};return x(ve,{children:[l($r,{onClick:()=>s(!0),permission:[Tpe,H2],projectId:t,tooltipProps:{title:"Remove segment"},"data-testid":`${Kie}_${e.name}`,children:l(vo,{"data-loading":!0})}),l(q,{condition:a,show:()=>l(dRe,{segment:e,open:a,onClose:()=>s(!1),onRemove:c})})]})},fRe=({segment:e})=>{const t=Ka("projectId"),n=pt();return l($r,{onClick:()=>{n(t?`/projects/${t}/settings/segments/edit/${e.id}`:`/segments/edit/${e.id}`)},permission:[W2,H2],projectId:t,tooltipProps:{title:"Edit segment"},children:l(di,{"data-loading":!0})})},hRe=({segment:e})=>x(da,{children:[l(fRe,{segment:e}),l(pRe,{segment:e})]}),mRe=()=>{const e=Ka("projectId"),{segments:t,loading:n}=$l(),r=tr(ua.breakpoints.down("md")),[o]=m.useState({sortBy:[{id:"createdAt"}],hiddenColumns:["description"]}),i=m.useMemo(()=>t?e?t.filter(({project:v})=>v===e):t:Array(5).fill({name:"Segment name",description:"Segment descripton",createdAt:new Date().toISOString(),createdBy:"user",projectId:"Project"}),[t,e]),a=m.useMemo(()=>gRe(),[]),{getTableProps:s,getTableBodyProps:c,headerGroups:u,rows:d,prepareRow:p,state:{globalFilter:f},setGlobalFilter:h,setHiddenColumns:g}=Jt.useTable({initialState:o,columns:a,data:i,sortTypes:qo,autoResetGlobalFilter:!1,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,defaultColumn:{Cell:bs}},Jt.useGlobalFilter,Jt.useSortBy);return Od([{condition:r,columns:["createdAt","createdBy"]},{condition:!!e,columns:["project"]}],g,a),l(yr,{header:l(Tn,{title:`Segments (${d.length})`,actions:x(ve,{children:[l(ko,{initialValue:f,onChange:h}),l(Tn.Divider,{}),l(ZAe,{})]})}),isLoading:n,children:l(q,{condition:!n&&i.length===0,show:l(ar,{children:l(oRe,{})}),elseShow:()=>x(ve,{children:[l(Ls,{value:f,children:x(Gi,{...s(),rowHeight:"standard",children:[l(Vi,{headerGroups:u}),l(Wi,{...c(),children:d.map(v=>(p(v),l(ui,{hover:!0,...v.getRowProps(),children:v.cells.map(b=>l(pi,{...b.getCellProps(),children:b.render("Cell")}))})))})]})}),l(q,{condition:d.length===0&&(f==null?void 0:f.length)>0,show:x(ar,{children:["No segments found matching “",f,"”"]})})]})})})},gRe=()=>[{id:"Icon",width:"1%",disableGlobalFilter:!0,disableSortBy:!0,Cell:()=>l(Xh,{icon:l(NL,{color:"disabled"})})},{Header:"Name",accessor:"name",width:"60%",Cell:({row:{original:{name:e,description:t,id:n}}})=>l(Ts,{title:e,to:`/segments/edit/${n}`,subtitle:t})},{Header:"Used in",width:"60%",Cell:({row:{original:e}})=>l(AM,{original:e})},{Header:"Project",accessor:"project",Cell:({value:e})=>l(q,{condition:!!e,show:l(Ts,{title:e,to:`/projects/${e}`}),elseShow:l(Hn,{children:"Global"})}),sortType:"alphanumeric",maxWidth:150,filterName:"project",searchable:!0},{Header:"Created at",accessor:"createdAt",minWidth:150,Cell:ch,disableGlobalFilter:!0},{Header:"Created by",accessor:"createdBy",width:"25%"},{Header:"Actions",id:"Actions",align:"center",width:"1%",disableSortBy:!0,disableGlobalFilter:!0,Cell:({row:{original:e}})=>l(hRe,{segment:e})},{accessor:"description"}],vRe=e=>fetch(e).then(bn("Feature toggle archive")).then(t=>t.json()),VM=e=>{const{data:t,error:n,mutate:r,isLoading:o}=Pn(Rt(e?`/api/admin/archive/features/${e}`:"api/admin/archive/features"),vRe,{refreshInterval:15e3});return{archivedFeatures:t==null?void 0:t.features,refetchArchived:r,loading:o,error:n}},yRe=({onRevive:e,onDelete:t,project:n})=>x(da,{children:[l($r,{onClick:e,projectId:n,permission:U2,tooltipProps:{title:"Revive feature toggle"},children:l(FL,{})}),l($r,{permission:m9,projectId:n,tooltipProps:{title:"Delete feature toggle"},onClick:t,children:l(vo,{})})]}),bRe=()=>{const{makeRequest:e,createRequest:t,errors:n,loading:r}=Vn({propagateErrors:!0});return{reviveFeature:async a=>{const s=`api/admin/archive/revive/${a}`,c=t(s,{method:"POST"});return e(c.caller,c.id)},deleteFeature:async a=>{const s=`api/admin/archive/${a}`,c=t(s,{method:"DELETE"});return e(c.caller,c.id)},errors:n,loading:r}},wRe=({value:e})=>{const{locationSettings:t}=es(),n=yn();return e?l(Hn,{children:l(xt,{title:`Archived on: ${rd(e,t.locale)}`,arrow:!0,children:l(se,{noWrap:!0,variant:"body2","data-loading":!0,children:l(P1,{date:new Date(e),title:"",live:!1})})})}):l(Hn,{children:l(se,{variant:"body2",color:n.palette.text.secondary,children:"not available"})})},SRe=C("p")(({theme:e})=>({marginTop:e.spacing(3)})),xRe=C(rr)(({theme:e})=>({marginTop:e.spacing(2),width:"100%"})),CRe="I want to delete",GM=({deletedFeatures:e,projectId:t,open:n,setOpen:r,refetch:o})=>{const[i,a]=m.useState(""),{setToastData:s,setToastApiError:c}=$t(),{deleteFeatures:u}=Jh(),d=async()=>{try{if(e.length===0)return;await u(t,e),await o(),s({type:"success",title:"Feature toggles deleted",text:`You have successfully deleted following features toggles: ${e.join(", ")}.`})}catch(h){c(gt(h))}finally{p()}},p=()=>{r(!1),a("")},f="delete-feature-toggle-confirmation-form";return x(vr,{title:"Delete feature toggles?",open:n,primaryButtonText:"Delete feature toggles",secondaryButtonText:"Cancel",onClick:d,onClose:p,disabledPrimaryButton:CRe!==i,formId:f,children:[x(Vt,{severity:"warning",children:[l("b",{children:"Warning!"})," Before you delete a feature toggle, make sure all in-code references to that feature toggle have been removed. Otherwise, a new feature toggle with the same name could activate the old code paths."]}),x(SRe,{children:["In order to delete feature toggles, please enter the following confirmation text in the text field below:"," ",l("strong",{children:"I want to delete"})]}),l("form",{id:f,children:l(xRe,{autoFocus:!0,onChange:h=>{a(h.currentTarget.value)},value:i,placeholder:"<deletion confirmation>",label:"Deletion confirmation"})})]})},ERe=C($e)(({theme:e})=>({display:"flex",justifyContent:"center",paddingLeft:e.spacing(2)})),TRe=({onChange:e,checked:t,title:n})=>l(ERe,{"data-testid":mae,children:l(pa,{onChange:e,title:n,checked:t})}),kRe=C("div")(({theme:e})=>({position:"sticky",marginTop:"auto",bottom:0,zIndex:e.zIndex.mobileStepper,pointerEvents:"none"})),ARe=C($e)(({theme:e})=>({display:"flex",justifyContent:"center",width:"100%",flexWrap:"wrap",paddingBottom:e.spacing(2)})),RRe=C(Cr)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"flex-end",marginTop:e.spacing(2),marginLeft:"auto",marginRight:"auto",padding:e.spacing(2,3),backgroundColor:e.palette.background.paper,border:`1px solid ${e.palette.background.alternative}`,borderRadius:e.shape.borderRadiusLarge,gap:e.spacing(1),flexWrap:"wrap",pointerEvents:"auto"})),_Re=C("span")(({theme:e})=>({background:e.palette.background.alternative,color:e.palette.common.white,padding:e.spacing(.5,1),borderRadius:e.shape.borderRadius})),PRe=C(se)(({theme:e})=>({paddingRight:e.spacing(2),marginRight:"auto"})),IRe=({count:e,children:t})=>e===0?null:l(kRe,{"data-testid":fae,children:l(ARe,{children:x(RRe,{elevation:4,children:[x(PRe,{children:[l(_Re,{"data-testid":hae,children:e})," selected"]}),t]})})}),ORe=({selectedIds:e,projectId:t})=>{const{reviveFeatures:n}=Jh(),{setToastData:r,setToastApiError:o}=$t(),{refetchArchived:i}=VM(t),[a,s]=m.useState(!1),{trackEvent:c}=br(),u=async()=>{try{await n(t,e),await i(),r({type:"success",title:"And we're back!",text:"The feature toggles have been revived."}),c("batch_operations",{props:{eventType:"features revived"}})}catch(p){o(gt(p))}},d=async()=>{s(!0)};return x(ve,{children:[l(wu,{projectId:t,permission:U2,children:({hasAccess:p})=>l(Ve,{disabled:!p,startIcon:l(FL,{}),variant:"outlined",size:"small",onClick:u,children:"Revive"})}),l(wu,{projectId:t,permission:m9,children:({hasAccess:p})=>l(Ve,{disabled:!p,startIcon:l(vo,{}),variant:"outlined",size:"small",onClick:d,children:"Delete"})}),l(GM,{deletedFeatures:e,projectId:t,open:a,setOpen:s,refetch:()=>{i(),c("batch_operations",{props:{eventType:"features deleted"}})}})]})},$Re=({archivedFeatures:e=[],loading:t,refetch:n,storedParams:r,setStoredParams:o,title:i,projectId:a})=>{const s=tr(ua.breakpoints.down("md")),c=tr(ua.breakpoints.down("lg")),{setToastData:u,setToastApiError:d}=$t(),[p,f]=m.useState(!1),[h,g]=m.useState(),[v,b]=Sd(),{reviveFeature:y}=bRe(),[w,S]=m.useState(v.get("search")||""),k=m.useCallback(async V=>{try{await y(V),await n(),u({type:"success",title:"And we're back!",text:"The feature toggle has been revived."})}catch(W){d(gt(W))}},[n,y,d,u]),A=m.useMemo(()=>[...a?[{id:"Select",Header:({getToggleAllRowsSelectedProps:V})=>l(pa,{...V()}),Cell:({row:V})=>{var W;return l(TRe,{...(W=V==null?void 0:V.getToggleRowSelectedProps)==null?void 0:W.call(V)})},maxWidth:50,disableSortBy:!0,hideInMenu:!0}]:[],{Header:"Seen",width:85,canSort:!0,Cell:s9,accessor:"lastSeenAt",align:"center"},{Header:"Type",accessor:"type",width:85,canSort:!0,Cell:p9,align:"center"},{Header:"Name",accessor:"name",searchable:!0,minWidth:100,Cell:({value:V,row:{original:W}})=>l(bs,{value:V,subtitle:W.description}),sortType:"alphanumeric"},{Header:"Created",accessor:"createdAt",width:150,Cell:ch,sortType:"date"},{Header:"Archived",accessor:"archivedAt",width:150,Cell:wRe,sortType:"date"},...a?[]:[{Header:"Project ID",accessor:"project",sortType:"alphanumeric",filterName:"project",searchable:!0,maxWidth:170,Cell:({value:V})=>l(Ts,{title:V,to:`/projects/${V}`})}],{Header:"Actions",id:"Actions",align:"center",maxWidth:120,canSort:!1,Cell:({row:{original:V}})=>l(yRe,{project:V.project,onRevive:()=>k(V.name),onDelete:()=>{g(V),f(!0)}})},{accessor:"description",header:"Description",searchable:!0}],[a]),{data:T,getSearchText:R,getSearchContext:P}=Yh(A,w,e),_=m.useMemo(()=>t?P9:T,[T,t]),[O]=m.useState(()=>({sortBy:[{id:v.get("sort")||r.id,desc:v.has("order")?v.get("order")==="desc":r.desc}],hiddenColumns:["description"],selectedRowIds:{}})),$=m.useCallback(V=>V.name,[]),{headerGroups:z,rows:L,state:{sortBy:B,selectedRowIds:Y},prepareRow:H,setHiddenColumns:ee}=Jt.useTable({columns:A,data:_,initialState:O,sortTypes:qo,autoResetHiddenColumns:!1,disableSortRemove:!0,autoResetSortBy:!1,getRowId:$},Jt.useFlexLayout,Jt.useSortBy,Jt.useRowSelect);return Od([{condition:s,columns:["type","createdAt"]},{condition:c,columns:["lastSeenAt","stale"]}],ee,A),m.useEffect(()=>{if(t)return;const V={};V.sort=B[0].id,B[0].desc&&(V.order="desc"),w&&(V.search=w),b(V,{replace:!0}),o({id:B[0].id,desc:B[0].desc||!1})},[t,B,w]),x(ve,{children:[x(yr,{isLoading:t,header:l(Tn,{titleElement:`${i} (${L.length<_.length?`${L.length} of ${_.length}`:_.length})`,actions:l(ko,{initialValue:w,onChange:S,hasFilters:!0,getSearchContext:P})}),children:[l(Ls,{value:R(w),children:l(A1,{rows:L,headerGroups:z,prepareRow:H})}),l(q,{condition:L.length===0,show:()=>l(q,{condition:(w==null?void 0:w.length)>0,show:x(ar,{children:["No feature toggles found matching “",w,"”"]}),elseShow:l(ar,{children:"None of the feature toggles were archived yet."})})}),l(GM,{deletedFeatures:[h==null?void 0:h.name],projectId:a??(h==null?void 0:h.project),open:p,setOpen:f,refetch:n})]}),l(q,{condition:!!a,show:l(IRe,{count:Object.keys(Y).length,children:l(ORe,{selectedIds:Object.keys(Y),projectId:a})})})]})},NRe={id:"createdAt"},{value:LRe,setValue:DRe}=Lc("FeaturesArchiveTable:v1",NRe),MRe=()=>{f9("Archive");const{archivedFeatures:e=[],loading:t,refetchArchived:n}=VM();return l($Re,{title:"Archive",archivedFeatures:e,loading:t,storedParams:LRe,setStoredParams:DRe,refetch:n})},BRe=m.lazy(()=>import("./AdvancedPlayground-4c9d02ea.js")),FRe=C(Ve)(({theme:e,selected:t})=>({"&.MuiButton-root":{cursor:"pointer",height:e.spacing(6.5),border:0,backgroundColor:t?e.palette.background.paper:"transparent",borderLeft:`${e.spacing(1)} solid ${t?e.palette.background.alternative:"transparent"}`,borderRadius:e.shape.borderRadiusMedium,justifyContent:"start",transition:"background-color 0.2s ease",color:e.palette.text.primary,textAlign:"left",padding:e.spacing(2,4),fontSize:e.fontSizes.bodySize,fontWeight:t?e.fontWeight.bold:e.fontWeight.medium,lineHeight:1.2},"&:hover":{backgroundColor:e.palette.neutral.light},"&.Mui-disabled":{pointerEvents:"auto"},"&:focus-visible":{outline:`2px solid ${e.palette.primary.main}`},justifyContent:"space-between","& > span":{borderTopLeftRadius:0,borderBottomLeftRadius:0}})),zRe=({label:e,selected:t,onClick:n})=>l(FRe,{selected:!!t,onClick:n,disableElevation:!0,disableFocusRipple:!0,fullWidth:!0,children:e}),jRe=C("div")(({theme:e})=>({display:"flex",gap:e.spacing(3),[e.breakpoints.down("md")]:{flexDirection:"column"}})),URe=C("div")(()=>({flexGrow:1,display:"flex",flexDirection:"column"})),WRe=C("div")(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing(1),width:e.spacing(30),flexShrink:0,[e.breakpoints.down("md")]:{width:"100%"}})),HRe=({tabs:e,value:t,onChange:n,children:r})=>x(jRe,{children:[l(WRe,{children:e.filter(o=>!o.hidden).map(o=>l(zRe,{label:o.label,selected:o.id===t,onClick:()=>n(o)},o.id))}),l(URe,{children:r})]}),qM=(e,t={})=>{const n=async()=>{const u=Rt(`api/admin/auth/${e}/settings`);return(await fetch(u,{method:"GET"}).then(bn("Auth settings"))).json()},r=`api/admin/auth/${e}/settings`,{data:o,error:i}=Pn(r,n,t),[a,s]=m.useState(!i&&!o),c=()=>{Jr(r)};return m.useEffect(()=>{s(!i&&!o)},[o,i]),{config:o||{},error:i,loading:a,refetch:c}},VRe=()=>{const{makeRequest:e,createRequest:t,errors:n,loading:r}=Vn({propagateErrors:!0});return{changePassword:async i=>{const a=t("api/admin/user/change-password",{method:"POST",body:JSON.stringify(i)});try{await e(a.caller,a.id)}catch(s){throw s}},errors:n,loading:r}},GRe=C("form")(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing(2),maxWidth:e.spacing(44)})),qRe=()=>{const{config:e,loading:t}=qM("simple"),[n,r]=m.useState(!1),{setToastData:o,setToastApiError:i}=$t(),[a,s]=m.useState(!1),[c,u]=m.useState(),[d,p]=m.useState(),[f,h]=m.useState(""),[g,v]=m.useState(""),[b,y]=m.useState(""),{changePassword:w}=VRe(),S=async k=>{if(k.preventDefault(),f===g){if(!a)u(Q9);else{r(!0),u(void 0),p(void 0);try{await w({password:f,confirmPassword:g,oldPassword:b}),o({title:"Password changed successfully",text:"Now you can sign in using your new password.",type:"success"})}catch(A){const T=gt(A);A instanceof R2?p(T):u(T),i(T)}}r(!1)}};return t?null:l(yr,{isLoading:n,header:"Change password",children:l(q,{condition:e.disabled,show:l(Vt,{severity:"error",children:"Password based login is currently disabled for your Unleash instance."}),elseShow:x(GRe,{children:[l(Z9,{password:f,callback:s,"data-loading":!0}),l(dc,{"data-loading":!0,label:"Old password",name:"oldPassword",value:b,error:!!d,helperText:d,autoComplete:"current-password",onChange:k=>y(k.target.value)}),l(dc,{"data-loading":!0,label:"Password",name:"password",value:f,error:!!c,helperText:c,autoComplete:"new-password",onChange:k=>h(k.target.value)}),l(dc,{"data-loading":!0,label:"Confirm password",name:"confirmPassword",value:g,autoComplete:"new-password",onChange:k=>v(k.target.value)}),l(tD,{"data-loading":!0,started:!!(f&&g),matchingPasswords:f===g}),l(Ve,{"data-loading":!0,variant:"contained",color:"primary",type:"submit",onClick:S,children:"Save"})]})})})},YRe="environment",KRe="project",YM="root",KM="project",XRe="root-custom",JRe="custom",QRe=[YM,KM],w8e=[YM,XRe],ZRe=[KM,JRe],e_e=10,QT=()=>{const{data:e,error:t,mutate:n}=Pn(Rt("api/admin/user/tokens"),t_e);return{tokens:e?e.pats:void 0,loading:!t&&!e,refetchTokens:()=>n(),error:t}},t_e=e=>fetch(e).then(bn("Personal API Tokens")).then(t=>t.json()),XM=()=>{const{makeRequest:e,createRequest:t,errors:n,loading:r}=Vn({propagateErrors:!0});return{createPersonalAPIToken:async c=>{const u=t("api/admin/user/tokens",{method:"POST",body:JSON.stringify(c)});try{return await(await e(u.caller,u.id)).json()}catch(d){throw d}},deletePersonalAPIToken:async c=>{const u=t(`api/admin/user/tokens/${c}`,{method:"DELETE"});try{await e(u.caller,u.id)}catch(d){throw d}},createUserPersonalAPIToken:async(c,u)=>{const d=t(`api/admin/user-admin/${c}/pat`,{method:"POST",body:JSON.stringify(u)});try{return await(await e(d.caller,d.id)).json()}catch(p){throw p}},deleteUserPersonalAPIToken:async(c,u)=>{const d=t(`api/admin/user-admin/${c}/pat/${u}`,{method:"DELETE"});try{await e(d.caller,d.id)}catch(p){throw p}},errors:n,loading:r}},n_e=e=>{const t=new Date(e);return lh(t,"yyyy-MM-dd")},r_e=e=>{const t=new Date(e);return lh(t,"yyyy-MM-dd")+"T"+lh(t,"HH:mm")},o_e=({label:e,type:t="datetime",error:n,errorText:r,min:o,max:i,value:a,onChange:s,...c})=>{const u=t==="datetime"?r_e:n_e;return l(pn,{type:t==="datetime"?"datetime-local":"date",size:"small",variant:"outlined",label:e,error:n,helperText:r,value:u(a.toISOString()),onChange:p=>{const f=uD(p.target.value);s(f??a)},FormHelperTextProps:{"data-testid":Q6},inputProps:{min:o&&u(o.toISOString()),max:i&&u(i.toISOString())},...c})},V3=C("p")(({theme:e})=>({color:e.palette.text.secondary,marginBottom:e.spacing(1)})),i_e=C(rr)(({theme:e})=>({width:"100%",maxWidth:e.spacing(50),marginBottom:e.spacing(2)})),a_e=C("div")(({theme:e,custom:t})=>({display:"flex",alignItems:t?"start":"center",gap:e.spacing(1.5),marginBottom:e.spacing(2),[e.breakpoints.down("sm")]:{flexDirection:"column",alignItems:"flex-start"}})),s_e=C(Qh)(({theme:e})=>({minWidth:e.spacing(20),marginRight:e.spacing(.5),[e.breakpoints.down("sm")]:{width:e.spacing(50)}})),l_e=C(o_e)(({theme:e})=>({width:e.spacing(28),[e.breakpoints.down("sm")]:{width:e.spacing(50)}})),c_e=C(Vt)(({theme:e})=>({marginBottom:e.spacing(2),maxWidth:e.spacing(50)}));var JM=(e=>(e["7DAYS"]="7d",e["30DAYS"]="30d",e["60DAYS"]="60d",e.NEVER="never",e.CUSTOM="custom",e))(JM||{});const QM=[{key:"7d",days:7,label:"7 days"},{key:"30d",days:30,label:"30 days"},{key:"60d",days:60,label:"60 days"},{key:"never",label:"Never"},{key:"custom",label:"Custom"}],Mx=e=>{const t=new Date,n=QM.find(({key:r})=>r===e);return e==="never"?t.setFullYear(t.getFullYear()+1e3):e==="custom"?t.setMinutes(t.getMinutes()+30):n!=null&&n.days&&t.setDate(t.getDate()+n.days),t},u_e=({description:e,setDescription:t,isDescriptionUnique:n,expiration:r,setExpiration:o,expiresAt:i,setExpiresAt:a,errors:s,setErrors:c})=>{const{locationSettings:u}=es(),d=v=>{c(b=>({...b,[v]:void 0}))},p=(v,b)=>{c(y=>({...y,[v]:b}))};m.useEffect(()=>{d("expiresAt"),a(Mx(r))},[r]);const f=v=>{d("description"),n&&!n(v)&&p("description","A token with that description already exists."),t(v)},h=r==="custom",g=i.getFullYear()>new Date().getFullYear()+100;return x(ve,{children:[l(V3,{children:"Describe what this token will be used for"}),l(i_e,{autoFocus:!0,label:"Description",error:!!s.description,errorText:s.description,value:e,onChange:v=>f(v.target.value),required:!0}),l(V3,{children:"Token expiration date"}),x(a_e,{custom:h,children:[l(s_e,{name:"expiration",id:"expiration",label:"Token will expire in",value:r,onChange:v=>o(v.target.value),options:QM}),l(q,{condition:h,show:()=>l(l_e,{label:"Date",value:i,onChange:v=>{d("expiresAt"),v<new Date&&p("expiresAt","Invalid date, must be in the future"),a(v)},min:new Date,error:!!s.expiresAt,errorText:s.expiresAt,required:!0}),elseShow:l(q,{condition:g,show:x(se,{variant:"body2",children:["The token will ",l("strong",{children:"never"})," ","expire!"]}),elseShow:()=>x(se,{variant:"body2",children:["Token will expire on"," ",l("strong",{children:rd(i,u.locale)})]})})})]}),l(q,{condition:g,show:l(c_e,{severity:"warning",children:"We strongly recommend that you set an expiration date for your token to help keep your information secure."})})]})},d_e=C("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),p_e=C("div")(({theme:e})=>({marginTop:"auto",display:"flex",justifyContent:"flex-end",[e.breakpoints.down("sm")]:{marginTop:e.spacing(4)}})),f_e=C(Ve)(({theme:e})=>({marginLeft:e.spacing(3)})),wg=JM["30DAYS"],h_e=({open:e,setOpen:t,newToken:n})=>{const{tokens:r,refetchTokens:o}=QT(),{createPersonalAPIToken:i,loading:a}=XM(),{setToastApiError:s}=$t(),{uiConfig:c}=It(),[u,d]=m.useState(""),[p,f]=m.useState(wg),[h,g]=m.useState(Mx(wg)),[v,b]=m.useState({});m.useEffect(()=>{d(""),f(wg),g(Mx(wg)),b({})},[e]);const y=()=>({description:u,expiresAt:h}),w=async R=>{R.preventDefault();try{const P=await i(y());n(P),o(),t(!1)}catch(P){s(gt(P))}},S=()=>`curl --location --request POST '${c.unleashUrl}/api/admin/user/tokens' \\
|
|
356
|
+
--data-raw '${JSON.stringify(B(),void 0,2)}'`,V=J=>J.length,W=J=>!(o!=null&&o.some(ae=>ae.name===J)),j=V(h)&&W(h)&&S.length,I=J=>{$("name"),W(J)||z("name","An environment with that name already exists."),g(J)},M=u.map(J=>({value:J.id,label:J.name}));return l(om,{open:t,onClose:()=>{n(!1)},label:`Clone ${e.name} environment`,children:l(Fr,{loading:s,modal:!0,title:`Clone ${e.name} environment`,description:"Cloning an environment will clone all feature toggles and their configuration (activation strategies, segments, status, etc) into a new environment.",documentationLink:"https://docs.getunleash.io/reference/environments#cloning-environments",documentationLinkLabel:"Cloning environments documentation",formatApiCode:ee,children:x(RAe,{onSubmit:H,children:[x("div",{children:[l(iu,{children:"What is your new environment name? (Can't be changed later)"}),l(_Ae,{autoFocus:!0,label:"Environment name",error:!!_.name,errorText:_.name,value:h,onChange:J=>I(J.target.value),required:!0}),l(iu,{children:"What type of environment do you want to create?"}),l(cD,{onChange:J=>b(J.currentTarget.value),value:v}),x(iu,{children:["Select which projects you want to clone the environment configuration in?",l(Xa,{tooltip:"The cloned environment will keep the feature toggle state for the selected projects, where it will be enabled by default."})]}),l(CAe,{projects:y,setProjects:w}),l(iu,{children:"Keep the users permission for this environment?"}),l(Cw,{children:"If you turn it off, the permission for this environment across all projects and feature toggles will remain only for admin and editor roles."}),l(Mr,{label:A?"Yes":"No",control:l(fa,{onChange:J=>T(J.target.checked),checked:A})}),x(PAe,{children:[l(iu,{children:"API Token"}),x(Cw,{children:["In order to connect your SDKs to your newly cloned environment, you will also need an API token."," ",l(Gr,{href:"https://docs.getunleash.io/reference/api-tokens-and-client-keys",target:"_blank",rel:"noreferrer",children:"Read more about API tokens"}),"."]}),l($s,{children:x(r2,{value:R,onChange:J=>P(J.target.value),name:"api-token-generation",children:[l(Mr,{value:"later",control:l(sc,{}),label:"I want to generate an API token later"}),l(Mr,{value:"now",control:l(sc,{}),label:"Generate an API token now"})]})}),x(IAe,{children:[l(Cw,{children:"A new Server-side SDK (CLIENT) API token will be generated for the cloned environment, so you can get started right away."}),l(q,{condition:R==="now",show:x(ve,{children:[l(iu,{children:"Which projects do you want this token to give access to?"}),l(kAe,{options:M,defaultValue:S,onChange:k,error:_.projects,onFocus:()=>$("projects")})]})})]})]})]}),x(OAe,{children:[l(Ve,{type:"submit",variant:"contained",color:"primary",disabled:!j,children:"Clone environment"}),l($Ae,{onClick:()=>{n(!1)},children:"Cancel"})]})]})})})};var JT={},LAe=An;Object.defineProperty(JT,"__esModule",{value:!0});var jM=JT.default=void 0,DAe=LAe(Rn()),MAe=_n,BAe=(0,DAe.default)((0,MAe.jsx)("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4 6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z"}),"FileCopy");jM=JT.default=BAe;const UM=({token:e})=>{const{setToastData:t}=$t();return x($e,{sx:r=>({backgroundColor:r.palette.background.elevation2,padding:r.spacing(4),borderRadius:`${r.shape.borderRadius}px`,marginTop:r.spacing(2),display:"flex",justifyContent:"space-between",alignItems:"center",wordBreak:"break-all"}),children:[e,l(xt,{title:"Copy token",arrow:!0,children:l(jt,{onClick:()=>{pD(e)?t({type:"success",title:"Token copied to clipboard"}):t({type:"error",title:"Could not copy token"})},size:"large",children:l(jM,{})})})]})},FAe=({open:e,setOpen:t,token:n})=>x(vr,{open:e,secondaryButtonText:"Close",onClose:(r,o)=>{o||t(!1)},title:"New API token created",children:[l(se,{variant:"body1",children:"Your new token has been created successfully."}),x(se,{variant:"body1",children:['You can also find it as "',l("strong",{children:n==null?void 0:n.username}),'" in the'," ",l(an,{to:"/admin/api",children:"API access page"}),"."]}),l(UM,{token:(n==null?void 0:n.secret)||""})]}),zAe=C($e)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"flex-end",paddingLeft:e.spacing(.5),minWidth:e.spacing(6.5),cursor:"grab"})),jAe=C(jt)(({theme:e})=>({padding:e.spacing(1.5,0),cursor:"inherit",transition:"color 0.2s ease-in-out",color:e.palette.action.active})),UAe=C($L,{shouldForwardProp:e=>e!=="deprecated"})(({theme:e,deprecated:t})=>({color:t?e.palette.neutral.border:e.palette.primary.main})),WM=({environment:e})=>x(zAe,{children:[l(jAe,{size:"large",disableRipple:!0,className:"drag-icon",children:l(Ole,{titleAccess:"Drag to reorder"})}),l(UAe,{deprecated:!e.enabled})]}),WAe=C(Gi)(({theme:e})=>({marginTop:e.spacing(3)})),HAe=C("p",{shouldForwardProp:e=>e!=="warning"})(({theme:e,warning:t})=>({color:t?e.palette.error.dark:e.palette.text.primary})),HM=({environment:e,warnEnabledToggles:t})=>{const n=m.useMemo(()=>[{id:"Icon",width:"1%",Cell:({row:{original:c}})=>l(WM,{environment:c})},{Header:"Name",accessor:"name",Cell:Hn},{Header:"Type",accessor:"type",Cell:Hn},{Header:"Visible in",accessor:c=>c.projectCount===1?"1 project":`${c.projectCount} projects`,Cell:({row:{original:c},value:u})=>x(Hn,{children:[u,l(q,{condition:!!t,show:l(HAe,{warning:!!(c.enabledToggleCount&&c.enabledToggleCount>0),children:c.enabledToggleCount===1?"1 toggle enabled":`${c.enabledToggleCount} toggles enabled`})})]})}],[t]),{getTableProps:r,getTableBodyProps:o,headerGroups:i,rows:a,prepareRow:s}=Jt.useTable({columns:n,data:[e],disableSortBy:!0});return x(WAe,{...r(),rowHeight:"compact",children:[l(Vi,{headerGroups:i}),l(Wi,{...o(),children:a.map(c=>(s(c),l(ui,{hover:!0,...c.getRowProps(),children:c.cells.map(u=>l(pi,{...u.getCellProps(),children:u.render("Cell")}))})))})]})},VAe=({environment:e,open:t,setOpen:n,onConfirm:r})=>{const{enabled:o}=e,i=o?"Deprecate":"Undeprecate";return x(vr,{title:`${i} environment?`,open:t,primaryButtonText:i,secondaryButtonText:"Close",onClick:r,onClose:()=>{n(!1)},children:[l(q,{condition:o,show:l(Vt,{severity:"info",children:"Deprecating an environment will mark it as deprecated. Deprecated environments are set as not visible by default for new projects. Project owners are still able to override this setting in the project. This environment will still be visible in any current projects."}),elseShow:l(Vt,{severity:"info",children:"Undeprecating an environment will no longer mark it as deprecated. An undeprecated environment will be set as visible by default for new projects."})}),l(HM,{environment:e})]})},GAe=C("p")(({theme:e})=>({marginTop:e.spacing(3),marginBottom:e.spacing(1.5)})),qAe=C(rr)(()=>({width:"100%"})),YAe=({environment:e,open:t,setOpen:n,onConfirm:r})=>{const[o,i]=m.useState("");return m.useEffect(()=>{i("")},[t]),x(vr,{title:"Delete environment?",open:t,primaryButtonText:"Delete environment",disabledPrimaryButton:e.name!==o,secondaryButtonText:"Close",onClick:r,onClose:()=>{n(!1)},children:[x(Vt,{severity:"error",children:[l("strong",{children:"Danger! This action is not reversible. Please proceed with caution."})," ","Deleting this environment will result in removing all strategies that are active in this environment across all feature toggles."]}),l(HM,{environment:e,warnEnabledToggles:!0}),x(GAe,{children:["In order to delete this environment, please enter the id of the environment in the textfield below:"," ",l("strong",{children:e.name})]}),l(qAe,{label:"Environment name",value:o,onChange:a=>i(a.target.value)})]})},KAe=({environment:e})=>{const t=pt(),{setToastApiError:n,setToastData:r}=$t(),{environments:o,refetchEnvironments:i}=$d(),{refetch:a}=oT(),{deleteEnvironment:s,toggleEnvironmentOn:c,toggleEnvironmentOff:u}=Md(),[d,p]=m.useState(!1),[f,h]=m.useState(!1),[g,v]=m.useState(!1),[b,y]=m.useState(!1),[w,S]=m.useState();return x(da,{children:[l(vAe,{environment:e,onEdit:()=>t(`/environments/${e.name}`),onDeprecateToggle:()=>h(!0),onClone:()=>{o.length<Wv?v(!0):r({type:"error",title:"Environment limit reached",text:`You have reached the maximum number of environments (${Wv}). Please reach out if you need more.`})},onDelete:()=>p(!0)}),l(YAe,{environment:e,open:d,setOpen:p,onConfirm:async()=>{try{await s(e.name),a(),r({type:"success",title:"Environment deleted",text:`You have successfully deleted the ${e.name} environment.`})}catch(T){n(gt(T))}finally{p(!1),await i()}}}),l(VAe,{environment:e,open:f,setOpen:h,onConfirm:async()=>{try{e.enabled?(await u(e.name),r({type:"success",title:"Environment deprecated successfully"})):(await c(e.name),r({type:"success",title:"Environment undeprecated successfully"}))}catch(T){n(gt(T))}finally{h(!1),await i()}}}),l(NAe,{environment:e,open:g,setOpen:v,newToken:T=>{S(T),y(!0)}}),l(FAe,{open:b,setOpen:y,token:w})]})},XAe=C(Vt)(({theme:e})=>({marginBottom:e.spacing(4)})),JAe=()=>{const{changeSortOrder:e}=Md(),{setToastApiError:t}=$t(),{environments:n,mutateEnvironments:r}=$d(),o=m.useCallback(async(b,y,w=!1)=>{const S=[...n],k=S[b];if(S.splice(b,1),S.splice(y,0,k),await r(S),w)try{await e(Ove(S))}catch(A){t(gt(A))}},[e,n,r,t]),{getTableProps:i,getTableBodyProps:a,headerGroups:s,rows:c,prepareRow:u,state:{globalFilter:d},setGlobalFilter:p}=Jt.useTable({columns:QAe,data:n,disableSortBy:!0},Jt.useGlobalFilter),h=x(ve,{children:[l(ko,{initialValue:d,onChange:p}),l(Tn.Divider,{}),l(aAe,{})]});let g=c.length;const v=l(Tn,{title:`Environments (${g})`,actions:h});return x(yr,{header:v,children:[l(XAe,{severity:"info",children:"This is the order of environments that you have today in each feature toggle. Rearranging them here will change also the order inside each feature toggle."}),l(Ls,{value:d,children:x(Gi,{...i(),rowHeight:"compact",children:[l(Vi,{headerGroups:s}),l(Wi,{...a(),children:c.map(b=>(u(b),l(uAe,{row:b,moveListItem:o},b.original.name)))})]})}),l(q,{condition:c.length===0,show:l(q,{condition:(d==null?void 0:d.length)>0,show:x(ar,{children:["No environments found matching “",d,"”"]}),elseShow:l(ar,{children:"No environments available. Get started by adding one."})})})]})},QAe=[{id:"Icon",width:"1%",Cell:({row:{original:e}})=>l(WM,{environment:e}),disableGlobalFilter:!0,isDragHandle:!0},{Header:"Name",accessor:"name",Cell:({row:{original:e}})=>l(fAe,{environment:e}),minWidth:350},{Header:"Type",accessor:"type",Cell:bs},{Header:"Visible in",accessor:e=>e.projectCount===1?"1 project":`${e.projectCount} projects`,Cell:Hn},{Header:"API Tokens",accessor:e=>e.apiTokenCount===1?"1 token":`${e.apiTokenCount} tokens`,Cell:Hn},{Header:"Actions",id:"Actions",align:"center",width:"1%",Cell:({row:{original:e}})=>l(KAe,{environment:e}),disableGlobalFilter:!0}],ZAe=()=>{const e=Ka("projectId"),t=pt();return l(Po,{onClick:()=>{t(e?`/projects/${e}/settings/segments/create`:"/segments/create")},permission:[N1,H2],projectId:e,"data-testid":Fie,children:"New segment"})},eRe=C("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:e.spacing(6),marginLeft:"auto",marginRight:"auto"})),tRe=C(se)(({theme:e})=>({fontSize:e.fontSizes.mainHeader,marginBottom:e.spacing(2.5)})),nRe=C("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.text.secondary,maxWidth:515,marginBottom:e.spacing(2.5),textAlign:"center"})),rRe=C(an)(({theme:e})=>({textDecoration:"none",color:e.palette.primary.main,fontWeight:e.fontWeight.bold})),oRe=()=>{const{hasAccess:e}=m.useContext(_o);return x(eRe,{children:[l(tRe,{children:"No segments yet!"}),l(nRe,{children:"Segment makes it easy for you to define who should be exposed to your feature. The segment is often a collection of constraints and can be reused."}),l(q,{condition:e(N1),show:l(rRe,{to:"/segments/create",children:"Create your first segment"})})]})},iRe=C(rr)(({theme:e})=>({marginTop:e.spacing(2)})),aRe=({segment:e,open:t,onClose:n,onRemove:r})=>{const[o,i]=m.useState(""),a=u=>i(u.currentTarget.value),s=()=>{n(),i("")},c="delete-segment-confirmation-form";return x(vr,{title:"Are you sure you want to delete this segment?",open:t,primaryButtonText:"Delete segment",secondaryButtonText:"Cancel",onClick:()=>{r(),i("")},disabledPrimaryButton:(e==null?void 0:e.name)!==o,onClose:s,formId:c,children:[x("p",{children:["In order to delete this segment, please enter the name of the segment in the field below: ",l("strong",{children:e==null?void 0:e.name})]}),l("form",{id:c,children:l(iRe,{autoFocus:!0,onChange:a,value:o,label:"Segment name","data-testid":Xie})})]})},sRe=C("ul")({marginBottom:0}),lRe=C(an)(({theme:e})=>({textDecoration:"none",color:e.palette.primary.main,fontWeight:e.fontWeight.bold})),cRe=({segment:e,open:t,onClose:n,strategies:r})=>x(vr,{title:"You can't delete a segment that's currently in use",open:t,primaryButtonText:"OK",onClick:n,children:[x("p",{children:["The following feature toggles are using the"," ",l("strong",{children:e.name})," segment for their strategies:"]}),l(sRe,{children:r==null?void 0:r.map(o=>l("li",{children:x(lRe,{to:BT(o.projectId,o.featureName,o.environment,o.id),target:"_blank",rel:"noopener noreferrer",children:[o.featureName," ",uRe(o)]})},o.id))})]}),uRe=e=>e.strategyName?`(${ks(e.strategyName)})`:"",dRe=({segment:e,open:t,onClose:n,onRemove:r})=>{const{strategies:o,loading:i}=DM(e.id),a=(o==null?void 0:o.length)===0;return i?null:l(q,{condition:a,show:l(aRe,{segment:e,open:t,onClose:n,onRemove:r}),elseShow:l(cRe,{segment:e,open:t,onClose:n,strategies:o})})},pRe=({segment:e})=>{const t=Ka("projectId"),{refetchSegments:n}=$l(),{deleteSegment:r}=qT(),{setToastData:o,setToastApiError:i}=$t(),[a,s]=m.useState(!1),c=async()=>{try{await r(e.id),await n(),o({type:"success",title:"Successfully deleted segment"})}catch(u){i(gt(u))}finally{s(!1)}};return x(ve,{children:[l($r,{onClick:()=>s(!0),permission:[Tpe,H2],projectId:t,tooltipProps:{title:"Remove segment"},"data-testid":`${Kie}_${e.name}`,children:l(vo,{"data-loading":!0})}),l(q,{condition:a,show:()=>l(dRe,{segment:e,open:a,onClose:()=>s(!1),onRemove:c})})]})},fRe=({segment:e})=>{const t=Ka("projectId"),n=pt();return l($r,{onClick:()=>{n(t?`/projects/${t}/settings/segments/edit/${e.id}`:`/segments/edit/${e.id}`)},permission:[W2,H2],projectId:t,tooltipProps:{title:"Edit segment"},children:l(di,{"data-loading":!0})})},hRe=({segment:e})=>x(da,{children:[l(fRe,{segment:e}),l(pRe,{segment:e})]}),mRe=()=>{const e=Ka("projectId"),{segments:t,loading:n}=$l(),r=tr(ua.breakpoints.down("md")),[o]=m.useState({sortBy:[{id:"createdAt"}],hiddenColumns:["description"]}),i=m.useMemo(()=>t?e?t.filter(({project:v})=>v===e):t:Array(5).fill({name:"Segment name",description:"Segment descripton",createdAt:new Date().toISOString(),createdBy:"user",projectId:"Project"}),[t,e]),a=m.useMemo(()=>gRe(),[]),{getTableProps:s,getTableBodyProps:c,headerGroups:u,rows:d,prepareRow:p,state:{globalFilter:f},setGlobalFilter:h,setHiddenColumns:g}=Jt.useTable({initialState:o,columns:a,data:i,sortTypes:qo,autoResetGlobalFilter:!1,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,defaultColumn:{Cell:bs}},Jt.useGlobalFilter,Jt.useSortBy);return Od([{condition:r,columns:["createdAt","createdBy"]},{condition:!!e,columns:["project"]}],g,a),l(yr,{header:l(Tn,{title:`Segments (${d.length})`,actions:x(ve,{children:[l(ko,{initialValue:f,onChange:h}),l(Tn.Divider,{}),l(ZAe,{})]})}),isLoading:n,children:l(q,{condition:!n&&i.length===0,show:l(ar,{children:l(oRe,{})}),elseShow:()=>x(ve,{children:[l(Ls,{value:f,children:x(Gi,{...s(),rowHeight:"standard",children:[l(Vi,{headerGroups:u}),l(Wi,{...c(),children:d.map(v=>(p(v),l(ui,{hover:!0,...v.getRowProps(),children:v.cells.map(b=>l(pi,{...b.getCellProps(),children:b.render("Cell")}))})))})]})}),l(q,{condition:d.length===0&&(f==null?void 0:f.length)>0,show:x(ar,{children:["No segments found matching “",f,"”"]})})]})})})},gRe=()=>[{id:"Icon",width:"1%",disableGlobalFilter:!0,disableSortBy:!0,Cell:()=>l(Xh,{icon:l(NL,{color:"disabled"})})},{Header:"Name",accessor:"name",width:"60%",Cell:({row:{original:{name:e,description:t,id:n}}})=>l(Ts,{title:e,to:`/segments/edit/${n}`,subtitle:t})},{Header:"Used in",width:"60%",Cell:({row:{original:e}})=>l(AM,{original:e})},{Header:"Project",accessor:"project",Cell:({value:e})=>l(q,{condition:!!e,show:l(Ts,{title:e,to:`/projects/${e}`}),elseShow:l(Hn,{children:"Global"})}),sortType:"alphanumeric",maxWidth:150,filterName:"project",searchable:!0},{Header:"Created at",accessor:"createdAt",minWidth:150,Cell:ch,disableGlobalFilter:!0},{Header:"Created by",accessor:"createdBy",width:"25%"},{Header:"Actions",id:"Actions",align:"center",width:"1%",disableSortBy:!0,disableGlobalFilter:!0,Cell:({row:{original:e}})=>l(hRe,{segment:e})},{accessor:"description"}],vRe=e=>fetch(e).then(bn("Feature toggle archive")).then(t=>t.json()),VM=e=>{const{data:t,error:n,mutate:r,isLoading:o}=Pn(Rt(e?`/api/admin/archive/features/${e}`:"api/admin/archive/features"),vRe,{refreshInterval:15e3});return{archivedFeatures:t==null?void 0:t.features,refetchArchived:r,loading:o,error:n}},yRe=({onRevive:e,onDelete:t,project:n})=>x(da,{children:[l($r,{onClick:e,projectId:n,permission:U2,tooltipProps:{title:"Revive feature toggle"},children:l(FL,{})}),l($r,{permission:m9,projectId:n,tooltipProps:{title:"Delete feature toggle"},onClick:t,children:l(vo,{})})]}),bRe=()=>{const{makeRequest:e,createRequest:t,errors:n,loading:r}=Vn({propagateErrors:!0});return{reviveFeature:async a=>{const s=`api/admin/archive/revive/${a}`,c=t(s,{method:"POST"});return e(c.caller,c.id)},deleteFeature:async a=>{const s=`api/admin/archive/${a}`,c=t(s,{method:"DELETE"});return e(c.caller,c.id)},errors:n,loading:r}},wRe=({value:e})=>{const{locationSettings:t}=es(),n=yn();return e?l(Hn,{children:l(xt,{title:`Archived on: ${rd(e,t.locale)}`,arrow:!0,children:l(se,{noWrap:!0,variant:"body2","data-loading":!0,children:l(P1,{date:new Date(e),title:"",live:!1})})})}):l(Hn,{children:l(se,{variant:"body2",color:n.palette.text.secondary,children:"not available"})})},SRe=C("p")(({theme:e})=>({marginTop:e.spacing(3)})),xRe=C(rr)(({theme:e})=>({marginTop:e.spacing(2),width:"100%"})),CRe="I want to delete",GM=({deletedFeatures:e,projectId:t,open:n,setOpen:r,refetch:o})=>{const[i,a]=m.useState(""),{setToastData:s,setToastApiError:c}=$t(),{deleteFeatures:u}=Jh(),d=async()=>{try{if(e.length===0)return;await u(t,e),await o(),s({type:"success",title:"Feature toggles deleted",text:`You have successfully deleted following features toggles: ${e.join(", ")}.`})}catch(h){c(gt(h))}finally{p()}},p=()=>{r(!1),a("")},f="delete-feature-toggle-confirmation-form";return x(vr,{title:"Delete feature toggles?",open:n,primaryButtonText:"Delete feature toggles",secondaryButtonText:"Cancel",onClick:d,onClose:p,disabledPrimaryButton:CRe!==i,formId:f,children:[x(Vt,{severity:"warning",children:[l("b",{children:"Warning!"})," Before you delete a feature toggle, make sure all in-code references to that feature toggle have been removed. Otherwise, a new feature toggle with the same name could activate the old code paths."]}),x(SRe,{children:["In order to delete feature toggles, please enter the following confirmation text in the text field below:"," ",l("strong",{children:"I want to delete"})]}),l("form",{id:f,children:l(xRe,{autoFocus:!0,onChange:h=>{a(h.currentTarget.value)},value:i,placeholder:"<deletion confirmation>",label:"Deletion confirmation"})})]})},ERe=C($e)(({theme:e})=>({display:"flex",justifyContent:"center",paddingLeft:e.spacing(2)})),TRe=({onChange:e,checked:t,title:n})=>l(ERe,{"data-testid":mae,children:l(pa,{onChange:e,title:n,checked:t})}),kRe=C("div")(({theme:e})=>({position:"sticky",marginTop:"auto",bottom:0,zIndex:e.zIndex.mobileStepper,pointerEvents:"none"})),ARe=C($e)(({theme:e})=>({display:"flex",justifyContent:"center",width:"100%",flexWrap:"wrap",paddingBottom:e.spacing(2)})),RRe=C(Cr)(({theme:e})=>({display:"flex",alignItems:"center",justifyContent:"flex-end",marginTop:e.spacing(2),marginLeft:"auto",marginRight:"auto",padding:e.spacing(2,3),backgroundColor:e.palette.background.paper,border:`1px solid ${e.palette.background.alternative}`,borderRadius:e.shape.borderRadiusLarge,gap:e.spacing(1),flexWrap:"wrap",pointerEvents:"auto"})),_Re=C("span")(({theme:e})=>({background:e.palette.background.alternative,color:e.palette.common.white,padding:e.spacing(.5,1),borderRadius:e.shape.borderRadius})),PRe=C(se)(({theme:e})=>({paddingRight:e.spacing(2),marginRight:"auto"})),IRe=({count:e,children:t})=>e===0?null:l(kRe,{"data-testid":fae,children:l(ARe,{children:x(RRe,{elevation:4,children:[x(PRe,{children:[l(_Re,{"data-testid":hae,children:e})," selected"]}),t]})})}),ORe=({selectedIds:e,projectId:t})=>{const{reviveFeatures:n}=Jh(),{setToastData:r,setToastApiError:o}=$t(),{refetchArchived:i}=VM(t),[a,s]=m.useState(!1),{trackEvent:c}=br(),u=async()=>{try{await n(t,e),await i(),r({type:"success",title:"And we're back!",text:"The feature toggles have been revived."}),c("batch_operations",{props:{eventType:"features revived"}})}catch(p){o(gt(p))}},d=async()=>{s(!0)};return x(ve,{children:[l(wu,{projectId:t,permission:U2,children:({hasAccess:p})=>l(Ve,{disabled:!p,startIcon:l(FL,{}),variant:"outlined",size:"small",onClick:u,children:"Revive"})}),l(wu,{projectId:t,permission:m9,children:({hasAccess:p})=>l(Ve,{disabled:!p,startIcon:l(vo,{}),variant:"outlined",size:"small",onClick:d,children:"Delete"})}),l(GM,{deletedFeatures:e,projectId:t,open:a,setOpen:s,refetch:()=>{i(),c("batch_operations",{props:{eventType:"features deleted"}})}})]})},$Re=({archivedFeatures:e=[],loading:t,refetch:n,storedParams:r,setStoredParams:o,title:i,projectId:a})=>{const s=tr(ua.breakpoints.down("md")),c=tr(ua.breakpoints.down("lg")),{setToastData:u,setToastApiError:d}=$t(),[p,f]=m.useState(!1),[h,g]=m.useState(),[v,b]=Sd(),{reviveFeature:y}=bRe(),[w,S]=m.useState(v.get("search")||""),k=m.useCallback(async V=>{try{await y(V),await n(),u({type:"success",title:"And we're back!",text:"The feature toggle has been revived."})}catch(W){d(gt(W))}},[n,y,d,u]),A=m.useMemo(()=>[...a?[{id:"Select",Header:({getToggleAllRowsSelectedProps:V})=>l(pa,{...V()}),Cell:({row:V})=>{var W;return l(TRe,{...(W=V==null?void 0:V.getToggleRowSelectedProps)==null?void 0:W.call(V)})},maxWidth:50,disableSortBy:!0,hideInMenu:!0}]:[],{Header:"Seen",width:85,canSort:!0,Cell:s9,accessor:"lastSeenAt",align:"center"},{Header:"Type",accessor:"type",width:85,canSort:!0,Cell:p9,align:"center"},{Header:"Name",accessor:"name",searchable:!0,minWidth:100,Cell:({value:V,row:{original:W}})=>l(bs,{value:V,subtitle:W.description}),sortType:"alphanumeric"},{Header:"Created",accessor:"createdAt",width:150,Cell:ch,sortType:"date"},{Header:"Archived",accessor:"archivedAt",width:150,Cell:wRe,sortType:"date"},...a?[]:[{Header:"Project ID",accessor:"project",sortType:"alphanumeric",filterName:"project",searchable:!0,maxWidth:170,Cell:({value:V})=>l(Ts,{title:V,to:`/projects/${V}`})}],{Header:"Actions",id:"Actions",align:"center",maxWidth:120,canSort:!1,Cell:({row:{original:V}})=>l(yRe,{project:V.project,onRevive:()=>k(V.name),onDelete:()=>{g(V),f(!0)}})},{accessor:"description",header:"Description",searchable:!0}],[a]),{data:T,getSearchText:R,getSearchContext:P}=Yh(A,w,e),_=m.useMemo(()=>t?P9:T,[T,t]),[O]=m.useState(()=>({sortBy:[{id:v.get("sort")||r.id,desc:v.has("order")?v.get("order")==="desc":r.desc}],hiddenColumns:["description"],selectedRowIds:{}})),$=m.useCallback(V=>V.name,[]),{headerGroups:z,rows:L,state:{sortBy:B,selectedRowIds:Y},prepareRow:H,setHiddenColumns:ee}=Jt.useTable({columns:A,data:_,initialState:O,sortTypes:qo,autoResetHiddenColumns:!1,disableSortRemove:!0,autoResetSortBy:!1,getRowId:$},Jt.useFlexLayout,Jt.useSortBy,Jt.useRowSelect);return Od([{condition:s,columns:["type","createdAt"]},{condition:c,columns:["lastSeenAt","stale"]}],ee,A),m.useEffect(()=>{if(t)return;const V={};V.sort=B[0].id,B[0].desc&&(V.order="desc"),w&&(V.search=w),b(V,{replace:!0}),o({id:B[0].id,desc:B[0].desc||!1})},[t,B,w]),x(ve,{children:[x(yr,{isLoading:t,header:l(Tn,{titleElement:`${i} (${L.length<_.length?`${L.length} of ${_.length}`:_.length})`,actions:l(ko,{initialValue:w,onChange:S,hasFilters:!0,getSearchContext:P})}),children:[l(Ls,{value:R(w),children:l(A1,{rows:L,headerGroups:z,prepareRow:H})}),l(q,{condition:L.length===0,show:()=>l(q,{condition:(w==null?void 0:w.length)>0,show:x(ar,{children:["No feature toggles found matching “",w,"”"]}),elseShow:l(ar,{children:"None of the feature toggles were archived yet."})})}),l(GM,{deletedFeatures:[h==null?void 0:h.name],projectId:a??(h==null?void 0:h.project),open:p,setOpen:f,refetch:n})]}),l(q,{condition:!!a,show:l(IRe,{count:Object.keys(Y).length,children:l(ORe,{selectedIds:Object.keys(Y),projectId:a})})})]})},NRe={id:"createdAt"},{value:LRe,setValue:DRe}=Lc("FeaturesArchiveTable:v1",NRe),MRe=()=>{f9("Archive");const{archivedFeatures:e=[],loading:t,refetchArchived:n}=VM();return l($Re,{title:"Archive",archivedFeatures:e,loading:t,storedParams:LRe,setStoredParams:DRe,refetch:n})},BRe=m.lazy(()=>import("./AdvancedPlayground-48dddbf4.js")),FRe=C(Ve)(({theme:e,selected:t})=>({"&.MuiButton-root":{cursor:"pointer",height:e.spacing(6.5),border:0,backgroundColor:t?e.palette.background.paper:"transparent",borderLeft:`${e.spacing(1)} solid ${t?e.palette.background.alternative:"transparent"}`,borderRadius:e.shape.borderRadiusMedium,justifyContent:"start",transition:"background-color 0.2s ease",color:e.palette.text.primary,textAlign:"left",padding:e.spacing(2,4),fontSize:e.fontSizes.bodySize,fontWeight:t?e.fontWeight.bold:e.fontWeight.medium,lineHeight:1.2},"&:hover":{backgroundColor:e.palette.neutral.light},"&.Mui-disabled":{pointerEvents:"auto"},"&:focus-visible":{outline:`2px solid ${e.palette.primary.main}`},justifyContent:"space-between","& > span":{borderTopLeftRadius:0,borderBottomLeftRadius:0}})),zRe=({label:e,selected:t,onClick:n})=>l(FRe,{selected:!!t,onClick:n,disableElevation:!0,disableFocusRipple:!0,fullWidth:!0,children:e}),jRe=C("div")(({theme:e})=>({display:"flex",gap:e.spacing(3),[e.breakpoints.down("md")]:{flexDirection:"column"}})),URe=C("div")(()=>({flexGrow:1,display:"flex",flexDirection:"column"})),WRe=C("div")(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing(1),width:e.spacing(30),flexShrink:0,[e.breakpoints.down("md")]:{width:"100%"}})),HRe=({tabs:e,value:t,onChange:n,children:r})=>x(jRe,{children:[l(WRe,{children:e.filter(o=>!o.hidden).map(o=>l(zRe,{label:o.label,selected:o.id===t,onClick:()=>n(o)},o.id))}),l(URe,{children:r})]}),qM=(e,t={})=>{const n=async()=>{const u=Rt(`api/admin/auth/${e}/settings`);return(await fetch(u,{method:"GET"}).then(bn("Auth settings"))).json()},r=`api/admin/auth/${e}/settings`,{data:o,error:i}=Pn(r,n,t),[a,s]=m.useState(!i&&!o),c=()=>{Jr(r)};return m.useEffect(()=>{s(!i&&!o)},[o,i]),{config:o||{},error:i,loading:a,refetch:c}},VRe=()=>{const{makeRequest:e,createRequest:t,errors:n,loading:r}=Vn({propagateErrors:!0});return{changePassword:async i=>{const a=t("api/admin/user/change-password",{method:"POST",body:JSON.stringify(i)});try{await e(a.caller,a.id)}catch(s){throw s}},errors:n,loading:r}},GRe=C("form")(({theme:e})=>({display:"flex",flexDirection:"column",gap:e.spacing(2),maxWidth:e.spacing(44)})),qRe=()=>{const{config:e,loading:t}=qM("simple"),[n,r]=m.useState(!1),{setToastData:o,setToastApiError:i}=$t(),[a,s]=m.useState(!1),[c,u]=m.useState(),[d,p]=m.useState(),[f,h]=m.useState(""),[g,v]=m.useState(""),[b,y]=m.useState(""),{changePassword:w}=VRe(),S=async k=>{if(k.preventDefault(),f===g){if(!a)u(Q9);else{r(!0),u(void 0),p(void 0);try{await w({password:f,confirmPassword:g,oldPassword:b}),o({title:"Password changed successfully",text:"Now you can sign in using your new password.",type:"success"})}catch(A){const T=gt(A);A instanceof R2?p(T):u(T),i(T)}}r(!1)}};return t?null:l(yr,{isLoading:n,header:"Change password",children:l(q,{condition:e.disabled,show:l(Vt,{severity:"error",children:"Password based login is currently disabled for your Unleash instance."}),elseShow:x(GRe,{children:[l(Z9,{password:f,callback:s,"data-loading":!0}),l(dc,{"data-loading":!0,label:"Old password",name:"oldPassword",value:b,error:!!d,helperText:d,autoComplete:"current-password",onChange:k=>y(k.target.value)}),l(dc,{"data-loading":!0,label:"Password",name:"password",value:f,error:!!c,helperText:c,autoComplete:"new-password",onChange:k=>h(k.target.value)}),l(dc,{"data-loading":!0,label:"Confirm password",name:"confirmPassword",value:g,autoComplete:"new-password",onChange:k=>v(k.target.value)}),l(tD,{"data-loading":!0,started:!!(f&&g),matchingPasswords:f===g}),l(Ve,{"data-loading":!0,variant:"contained",color:"primary",type:"submit",onClick:S,children:"Save"})]})})})},YRe="environment",KRe="project",YM="root",KM="project",XRe="root-custom",JRe="custom",QRe=[YM,KM],w8e=[YM,XRe],ZRe=[KM,JRe],e_e=10,QT=()=>{const{data:e,error:t,mutate:n}=Pn(Rt("api/admin/user/tokens"),t_e);return{tokens:e?e.pats:void 0,loading:!t&&!e,refetchTokens:()=>n(),error:t}},t_e=e=>fetch(e).then(bn("Personal API Tokens")).then(t=>t.json()),XM=()=>{const{makeRequest:e,createRequest:t,errors:n,loading:r}=Vn({propagateErrors:!0});return{createPersonalAPIToken:async c=>{const u=t("api/admin/user/tokens",{method:"POST",body:JSON.stringify(c)});try{return await(await e(u.caller,u.id)).json()}catch(d){throw d}},deletePersonalAPIToken:async c=>{const u=t(`api/admin/user/tokens/${c}`,{method:"DELETE"});try{await e(u.caller,u.id)}catch(d){throw d}},createUserPersonalAPIToken:async(c,u)=>{const d=t(`api/admin/user-admin/${c}/pat`,{method:"POST",body:JSON.stringify(u)});try{return await(await e(d.caller,d.id)).json()}catch(p){throw p}},deleteUserPersonalAPIToken:async(c,u)=>{const d=t(`api/admin/user-admin/${c}/pat/${u}`,{method:"DELETE"});try{await e(d.caller,d.id)}catch(p){throw p}},errors:n,loading:r}},n_e=e=>{const t=new Date(e);return lh(t,"yyyy-MM-dd")},r_e=e=>{const t=new Date(e);return lh(t,"yyyy-MM-dd")+"T"+lh(t,"HH:mm")},o_e=({label:e,type:t="datetime",error:n,errorText:r,min:o,max:i,value:a,onChange:s,...c})=>{const u=t==="datetime"?r_e:n_e;return l(pn,{type:t==="datetime"?"datetime-local":"date",size:"small",variant:"outlined",label:e,error:n,helperText:r,value:u(a.toISOString()),onChange:p=>{const f=uD(p.target.value);s(f??a)},FormHelperTextProps:{"data-testid":Q6},inputProps:{min:o&&u(o.toISOString()),max:i&&u(i.toISOString())},...c})},V3=C("p")(({theme:e})=>({color:e.palette.text.secondary,marginBottom:e.spacing(1)})),i_e=C(rr)(({theme:e})=>({width:"100%",maxWidth:e.spacing(50),marginBottom:e.spacing(2)})),a_e=C("div")(({theme:e,custom:t})=>({display:"flex",alignItems:t?"start":"center",gap:e.spacing(1.5),marginBottom:e.spacing(2),[e.breakpoints.down("sm")]:{flexDirection:"column",alignItems:"flex-start"}})),s_e=C(Qh)(({theme:e})=>({minWidth:e.spacing(20),marginRight:e.spacing(.5),[e.breakpoints.down("sm")]:{width:e.spacing(50)}})),l_e=C(o_e)(({theme:e})=>({width:e.spacing(28),[e.breakpoints.down("sm")]:{width:e.spacing(50)}})),c_e=C(Vt)(({theme:e})=>({marginBottom:e.spacing(2),maxWidth:e.spacing(50)}));var JM=(e=>(e["7DAYS"]="7d",e["30DAYS"]="30d",e["60DAYS"]="60d",e.NEVER="never",e.CUSTOM="custom",e))(JM||{});const QM=[{key:"7d",days:7,label:"7 days"},{key:"30d",days:30,label:"30 days"},{key:"60d",days:60,label:"60 days"},{key:"never",label:"Never"},{key:"custom",label:"Custom"}],Mx=e=>{const t=new Date,n=QM.find(({key:r})=>r===e);return e==="never"?t.setFullYear(t.getFullYear()+1e3):e==="custom"?t.setMinutes(t.getMinutes()+30):n!=null&&n.days&&t.setDate(t.getDate()+n.days),t},u_e=({description:e,setDescription:t,isDescriptionUnique:n,expiration:r,setExpiration:o,expiresAt:i,setExpiresAt:a,errors:s,setErrors:c})=>{const{locationSettings:u}=es(),d=v=>{c(b=>({...b,[v]:void 0}))},p=(v,b)=>{c(y=>({...y,[v]:b}))};m.useEffect(()=>{d("expiresAt"),a(Mx(r))},[r]);const f=v=>{d("description"),n&&!n(v)&&p("description","A token with that description already exists."),t(v)},h=r==="custom",g=i.getFullYear()>new Date().getFullYear()+100;return x(ve,{children:[l(V3,{children:"Describe what this token will be used for"}),l(i_e,{autoFocus:!0,label:"Description",error:!!s.description,errorText:s.description,value:e,onChange:v=>f(v.target.value),required:!0}),l(V3,{children:"Token expiration date"}),x(a_e,{custom:h,children:[l(s_e,{name:"expiration",id:"expiration",label:"Token will expire in",value:r,onChange:v=>o(v.target.value),options:QM}),l(q,{condition:h,show:()=>l(l_e,{label:"Date",value:i,onChange:v=>{d("expiresAt"),v<new Date&&p("expiresAt","Invalid date, must be in the future"),a(v)},min:new Date,error:!!s.expiresAt,errorText:s.expiresAt,required:!0}),elseShow:l(q,{condition:g,show:x(se,{variant:"body2",children:["The token will ",l("strong",{children:"never"})," ","expire!"]}),elseShow:()=>x(se,{variant:"body2",children:["Token will expire on"," ",l("strong",{children:rd(i,u.locale)})]})})})]}),l(q,{condition:g,show:l(c_e,{severity:"warning",children:"We strongly recommend that you set an expiration date for your token to help keep your information secure."})})]})},d_e=C("form")(()=>({display:"flex",flexDirection:"column",height:"100%"})),p_e=C("div")(({theme:e})=>({marginTop:"auto",display:"flex",justifyContent:"flex-end",[e.breakpoints.down("sm")]:{marginTop:e.spacing(4)}})),f_e=C(Ve)(({theme:e})=>({marginLeft:e.spacing(3)})),wg=JM["30DAYS"],h_e=({open:e,setOpen:t,newToken:n})=>{const{tokens:r,refetchTokens:o}=QT(),{createPersonalAPIToken:i,loading:a}=XM(),{setToastApiError:s}=$t(),{uiConfig:c}=It(),[u,d]=m.useState(""),[p,f]=m.useState(wg),[h,g]=m.useState(Mx(wg)),[v,b]=m.useState({});m.useEffect(()=>{d(""),f(wg),g(Mx(wg)),b({})},[e]);const y=()=>({description:u,expiresAt:h}),w=async R=>{R.preventDefault();try{const P=await i(y());n(P),o(),t(!1)}catch(P){s(gt(P))}},S=()=>`curl --location --request POST '${c.unleashUrl}/api/admin/user/tokens' \\
|
|
357
357
|
--header 'Authorization: INSERT_API_KEY' \\
|
|
358
358
|
--header 'Content-Type: application/json' \\
|
|
359
359
|
--data-raw '${JSON.stringify(y(),void 0,2)}'`,k=R=>R.length,A=R=>!(r!=null&&r.some(P=>P.description===R)),T=k(u)&&A(u)&&h>new Date;return l(om,{open:e,onClose:()=>{t(!1)},label:"Create personal API token",children:l(Fr,{loading:a,modal:!0,title:"Create personal API token",description:`Use personal API tokens to authenticate to the Unleash API as
|
|
360
360
|
yourself. A personal API token has the same access privileges as
|
|
361
|
-
your user.`,documentationLink:"https://docs.getunleash.io/reference/api-tokens-and-client-keys",documentationLinkLabel:"Tokens documentation",formatApiCode:S,children:x(d_e,{onSubmit:w,children:[l("div",{children:l(u_e,{description:u,setDescription:d,isDescriptionUnique:A,expiration:p,setExpiration:f,expiresAt:h,setExpiresAt:g,errors:v,setErrors:b})}),x(p_e,{children:[l(Ve,{type:"submit",variant:"contained",color:"primary",disabled:!T,children:"Create token"}),l(f_e,{onClick:()=>{t(!1)},children:"Cancel"})]})]})})})},m_e=({open:e,setOpen:t,token:n})=>{const{refetchTokens:r}=QT(),{deletePersonalAPIToken:o}=XM(),{setToastData:i,setToastApiError:a}=$t();return l(vr,{open:e,primaryButtonText:"Delete token",secondaryButtonText:"Cancel",onClick:async()=>{if(n)try{await o(n==null?void 0:n.id),r(),t(!1),i({title:"Token deleted successfully",type:"success"})}catch(c){a(gt(c))}},onClose:()=>{t(!1)},title:"Delete token?",children:x(se,{children:['Any applications or scripts using this token "',l("strong",{children:n==null?void 0:n.description}),'" will no longer be able to access the Unleash API. You cannot undo this action.']})})},g_e=C(Vt)(({theme:e})=>({marginBottom:e.spacing(3)})),v_e=({open:e,setOpen:t,token:n})=>x(vr,{open:e,secondaryButtonText:"Close",onClose:(r,o)=>{o||t(!1)},title:"Personal API token created",children:[l(g_e,{severity:"info",children:"Make sure to copy your personal API token now. You won't be able to see it again!"}),l(se,{variant:"body1",children:"Your token:"}),l(UM,{token:(n==null?void 0:n.secret)||""})]}),ZM=({value:e,live:t=!1,emptyText:n,title:r,dateFormat:o=rd})=>{const{locationSettings:i}=es();if(!e)return l(Hn,{children:n});const a=o(e,i.locale);return l(Hn,{children:l(xt,{title:(r==null?void 0:r(a))??a,arrow:!0,children:l(se,{noWrap:!0,component:"span",variant:"body2","data-loading":!0,children:l(P1,{date:new Date(e),live:t,title:""})})})})},y_e=C(Vt)(({theme:e})=>({marginBottom:e.spacing(3)})),b_e=C("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",padding:e.spacing(10,2)})),w_e=C(se)(({theme:e})=>({fontSize:e.fontSizes.mainHeader,marginBottom:e.spacing(1.5)})),S_e=C(se)(({theme:e})=>({color:e.palette.text.secondary,marginBottom:e.spacing(4.5)})),x_e=Array(15).fill({description:"Short description of the feature",type:"-",createdAt:new Date(2022,1,1),project:"projectID"}),C_e={id:"createdAt"},{value:G3,setValue:E_e}=Lc("PersonalAPITokensTable:v1",C_e),T_e=()=>{const e=yn(),t=tr(e.breakpoints.down("md")),n=tr(e.breakpoints.down("sm")),{tokens:r=[],loading:o}=QT(),[i,a]=Sd(),[s]=m.useState(()=>({sortBy:[{id:i.get("sort")||G3.id,desc:i.has("order")?i.get("order")==="desc":G3.desc}],globalFilter:i.get("search")||""})),[c,u]=m.useState(s.globalFilter),[d,p]=m.useState(!1),[f,h]=m.useState(!1),[g,v]=m.useState(!1),[b,y]=m.useState(),[w,S]=m.useState(),k=m.useMemo(()=>[{Header:"Description",accessor:"description",Cell:bs,minWidth:100,searchable:!0},{Header:"Expires",accessor:"expiresAt",Cell:({value:B})=>new Date(B).getFullYear()>new Date().getFullYear()+100?l(Hn,{children:"Never"}):l(ch,{value:B}),sortType:"date",maxWidth:150},{Header:"Created",accessor:"createdAt",Cell:ch,sortType:"date",maxWidth:150},{Header:"Last seen",accessor:"seenAt",Cell:ZM,sortType:"date",maxWidth:150},{Header:"Actions",id:"Actions",align:"center",Cell:({row:{original:B}})=>l(da,{children:l(xt,{title:"Delete token",arrow:!0,describeChild:!0,children:l("span",{children:l(jt,{onClick:()=>{S(B),v(!0)},children:l(vo,{})})})})}),maxWidth:100,disableSortBy:!0}],[S,v]),{data:A,getSearchText:T,getSearchContext:R}=Yh(k,c,r),P=m.useMemo(()=>(A==null?void 0:A.length)===0&&o?x_e:A,[A,o]),{headerGroups:_,rows:O,prepareRow:$,state:{sortBy:z},setHiddenColumns:L}=Jt.useTable({columns:k,data:P,initialState:s,sortTypes:qo,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},Jt.useSortBy,Jt.useFlexLayout);return Od([{condition:n,columns:["expiresAt"]},{condition:t,columns:["createdAt"]}],L,k),m.useEffect(()=>{const B={};B.sort=z[0].id,z[0].desc&&(B.order="desc"),c&&(B.search=c),a(B,{replace:!0}),E_e({id:z[0].id,desc:z[0].desc||!1})},[z,c,a]),x(yr,{isLoading:o,header:l(Tn,{title:`Personal API tokens (${O.length<P.length?`${O.length} of ${P.length}`:P.length})`,actions:x(ve,{children:[l(q,{condition:!t,show:x(ve,{children:[l(ko,{initialValue:c,onChange:u,getSearchContext:R}),l(Tn.Divider,{})]})}),l(Ve,{variant:"contained",color:"primary",disabled:r.length>=e_e,onClick:()=>p(!0),children:"New token"})]}),children:l(q,{condition:t,show:l(ko,{initialValue:c,onChange:u,hasFilters:!0,getSearchContext:R})})}),children:[l(y_e,{severity:"info",children:"Use personal API tokens to authenticate to the Unleash API as yourself. A personal API token has the same access privileges as your user."}),l(Ls,{value:T(c),children:l(A1,{rows:O,headerGroups:_,prepareRow:$})}),l(q,{condition:O.length===0,show:l(q,{condition:(c==null?void 0:c.length)>0,show:x(ar,{children:["No tokens found matching “",c,"”"]}),elseShow:x(b_e,{children:[l(w_e,{children:"You have no personal API tokens yet."}),l(S_e,{variant:"body2",children:"Need an API token for scripts or testing? Create a personal API token for quick access to the Unleash API."}),l(Ve,{variant:"outlined",onClick:()=>p(!0),children:"Create your first token"})]})})}),l(h_e,{open:d,setOpen:p,newToken:B=>{y(B),h(!0)}}),l(v_e,{open:f,setOpen:h,token:b}),l(m_e,{open:g,setOpen:v,token:w})]})},k_e=()=>{const{data:e,error:t,mutate:n}=Pn(Rt("api/admin/user/profile"),A_e);return{profile:e,loading:!t&&!e,refetchProfile:()=>n(),error:t}},A_e=e=>fetch(e).then(bn("Profile")).then(t=>t.json());var ZT={},R_e=An;Object.defineProperty(ZT,"__esModule",{value:!0});var eB=ZT.default=void 0,__e=R_e(Rn()),P_e=_n,I_e=(0,__e.default)((0,P_e.jsx)("path",{d:"M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16.77c.68 0 1.23-.56 1.23-1.23V8c0-1.1-.9-2-2-2zm0 12H4V6h5.17l2 2H20v10zm-2-6H6v-2h12v2zm-4 4H6v-2h8v2z"}),"TopicOutlined");eB=ZT.default=I_e;const tB=(e,t={})=>{const{isEnterprise:n}=It(),{data:r,error:o,mutate:i}=Mc(!!e&&n(),void 0,Rt(`api/admin/roles/${e}`),O_e,t);return m.useMemo(()=>({role:r,loading:!o&&!r,refetch:()=>i(),error:o}),[r,o,i])},O_e=e=>fetch(e).then(bn("Role")).then(t=>t.json()),hc=e=>e.environment?`${e.id}-${e.environment}`:`${e.id}`,S8e=e=>e.reduce((t,n)=>(t[hc(n)]=n,t),{}),x8e=(e,t)=>{let n=rm(e);return n[hc(t)]?delete n[hc(t)]:n[hc(t)]={...t},n},C8e=(e,t)=>{let n=rm(e);return t.every(o=>n[hc(o)])?t.forEach(o=>{delete n[hc(o)]}):t.forEach(o=>{n[hc(o)]={...o}}),n},$_e=e=>e.filter(({name:n})=>n!=="ADMIN").reduce((n,r)=>{var a;const o=((a=CTe.find(s=>s.permissions.includes(r.name)))==null?void 0:a.label)||"Other",i=n.find(({label:s})=>s===o);return i?i.permissions.push(r):n.push({label:o,type:"root",permissions:[r]}),n},[]).sort(L_e),N_e=e=>{const t=e.filter(({type:o})=>o===KRe),n=e.filter(({type:o})=>o===YRe),r=[];return t.length&&r.push({label:"Project",type:"project",permissions:t}),r.push(...n.reduce((o,i)=>{const a=i.environment,s=o.find(({label:c})=>c===a);return s?s.permissions.push(i):o.push({label:a,type:"environment",permissions:[i]}),o},[])),r},E8e=(e,t)=>[...e,...t.flatMap(({permissions:n})=>n)],L_e=({label:e},{label:t})=>e==="Other"&&t!=="Other"?1:e!=="Other"&&t==="Other"?-1:e.localeCompare(t),D_e=C("div",{shouldForwardProp:e=>e!=="tooltip"})(({theme:e,tooltip:t})=>({width:"100%",maxWidth:e.spacing(50),padding:t?e.spacing(1):e.spacing(3),backgroundColor:t?e.palette.background.paper:e.palette.neutral.light,color:e.palette.text.secondary,fontSize:e.fontSizes.smallBody,borderRadius:e.shape.borderRadiusMedium})),M_e=C("div")(({theme:e})=>({marginTop:e.spacing(2)})),q3=C("p")(({theme:e})=>({color:e.palette.text.primary,fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.bold,marginBottom:e.spacing(1)})),B_e=C("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,marginTop:e.spacing(1)})),F_e=({roleId:e,tooltip:t,...n})=>{const{role:r}=tB(e.toString());if(!r)return null;const{name:o,description:i,permissions:a,type:s}=r,u=ZRe.includes(s)?N_e(a):$_e(a);return x(D_e,{tooltip:t,...n,children:[l(q3,{sx:{mb:0},children:o}),l(B_e,{children:i}),l(q,{condition:!QRe.includes(r.type),show:()=>u.map(({label:d,permissions:p})=>x(M_e,{children:[l(q3,{children:d}),p.map(f=>l("p",{children:f.displayName},f.id))]},d))})]})},z_e=({roleId:e,children:t})=>{const{role:n}=tB(e.toString());return n?l(Dc,{title:l(F_e,{roleId:e,tooltip:!0}),arrow:!0,children:l(qt,{color:"success",icon:l(IP,{}),sx:{cursor:"pointer"},children:n.name})}):t?l(qt,{color:"success",icon:l(IP,{}),children:t}):null},j_e=C("div")(({theme:e})=>({display:"flex",flexDirection:"row",alignItems:"center",padding:e.spacing(6),borderRadius:e.shape.borderRadiusLarge,backgroundColor:e.palette.background.alternative,color:e.palette.primary.contrastText,marginBottom:e.spacing(3),boxShadow:e.boxShadows.primaryHeader})),U_e=C("div")(()=>({flexGrow:1})),W_e=C(se)(({theme:e})=>({fontSize:e.spacing(3.75)})),H_e=C(y2)(({theme:e})=>({width:e.spacing(9.5),height:e.spacing(9.5),marginRight:e.spacing(3)})),Y3=C(se)(({theme:e})=>({fontSize:e.fontSizes.mainHeader,marginBottom:e.spacing(3)})),V_e=C("div")(({theme:e})=>({display:"flex",flexDirection:"row","& > div > p":{marginBottom:e.spacing(1.5)}})),G_e=C(qt)(({theme:e})=>({cursor:"pointer",marginRight:e.spacing(1)})),q_e=C("div")(({theme:e})=>({width:"100%",height:"1px",backgroundColor:e.palette.divider,margin:e.spacing(3,0)})),Y_e=C($s)(({theme:e})=>({marginTop:e.spacing(1.5),width:e.spacing(30)})),K_e=C(zh)(({theme:e})=>({backgroundColor:e.palette.background.paper})),X_e=({user:e})=>{const{profile:t}=k_e(),n=pt(),{locationSettings:r,setLocationSettings:o}=es(),[i,a]=m.useState(),[s,c]=m.useState(["en-US","en-GB","nb-NO","sv-SE","da-DK","en-IN","de","cs","pt-BR","fr-FR"]);m.useEffect(()=>{const d=s.find(p=>p.toLowerCase().includes(r.locale.toLowerCase()));a(d),d||c(p=>[...p,r.locale])},[r]);const u=d=>{const p=d.target.value;a(p),o({locale:p})};return x(ve,{children:[x(j_e,{children:[l(H_e,{user:e}),x(U_e,{children:[l(W_e,{children:e.name||e.username}),l(se,{variant:"body1",children:e.email})]})]}),x(yr,{children:[l(Y3,{children:"Access"}),x(V_e,{children:[l($e,{sx:{width:"50%"},children:l(q,{condition:!!(t!=null&&t.rootRole),show:()=>x(ve,{children:[l(se,{variant:"body2",children:"Your root role"}),l(z_e,{roleId:t==null?void 0:t.rootRole.id,children:t==null?void 0:t.rootRole.name})]})})}),x($e,{children:[l(se,{variant:"body2",children:"Projects"}),l(q,{condition:!!(t!=null&&t.projects.length),show:t==null?void 0:t.projects.map(d=>l(xt,{title:"View project",arrow:!0,placement:"bottom-end",describeChild:!0,children:l(G_e,{onClick:p=>{p.preventDefault(),n(`/projects/${d}`)},color:"secondary",icon:l(eB,{}),children:d})},d)),elseShow:l(xt,{title:"You are not assigned to any projects",arrow:!0,describeChild:!0,children:l(qt,{children:"No projects"})})})]})]}),l(q_e,{}),l(Y3,{children:"Settings"}),l(se,{variant:"body2",children:"This is the format used across the system for time and date"}),x(Y_e,{variant:"outlined",size:"small",children:[l(K_e,{htmlFor:"locale-select",children:"Date/Time formatting"}),l(jh,{id:"locale-select",value:i||"",native:!0,onChange:u,MenuProps:{style:{zIndex:9999}},children:s.map(d=>l("option",{value:d,children:d},d))})]})]})]})},J_e=()=>{const{user:e}=vi(),t=Ro(),n=pt(),{config:r,loading:o}=qM("simple"),{uiConfig:i}=It(),a=[{id:"profile",label:"Profile"},{id:"password",label:"Change password",path:"change-password",hidden:r.disabled},{id:"pat",label:"Personal API tokens",path:"personal-api-tokens",hidden:i.flags.personalAccessTokensKillSwitch}],s=p=>{n(p.path?`/profile/${p.path}`:"/profile",{replace:!0}),d(p.id)},c=()=>{const p=t.pathname;return(a.find(({path:h})=>h&&p.includes(h))||a[0]).id},[u,d]=m.useState(c());return m.useEffect(()=>{d(c())},[t]),o?null:x(HRe,{tabs:a,value:u,onChange:s,children:[l(q,{condition:u==="profile",show:l(X_e,{user:e})}),l(q,{condition:u==="password",show:l(qRe,{})}),l(q,{condition:u==="pat",show:l(T_e,{})})]})},Q_e=m.lazy(()=>import("./CreateProject-16b35d57.js")),Z_e=m.lazy(()=>import("./FeatureViewLazyExport-47bb7f13.js")),ePe=m.lazy(()=>import("./LazyAdminExport-8ef0ca21.js")),tPe=m.lazy(()=>import("./LazyProjectExport-49541c75.js")),nPe=()=>l($c,{to:"/admin/users",replace:!0}),rPe=()=>{const{isEnterprise:e}=It(),{data:t,error:n,mutate:r}=Mc(e(),{events:[]},Rt("api/admin/logins"),oPe);return m.useMemo(()=>({events:(t==null?void 0:t.events)??[],loading:!n&&!t,refetch:()=>r(),error:n}),[t,n,r])},oPe=e=>fetch(e).then(bn("Login History")).then(t=>t.json()),K3=C($e)(()=>({display:"flex",justifyContent:"center"})),iPe=({row:e,value:t})=>{const{searchQuery:n}=Ol();return t?l(K3,{children:l(qt,{color:"success",children:"True"})}):l(K3,{children:l(Dc,{arrow:!0,title:l(Ya,{search:n,children:e.original.failure_reason}),children:l(qt,{color:"error",children:"False"})})})},aPe=()=>{const{loading:e,makeRequest:t,createRequest:n,errors:r}=Vn({propagateErrors:!0});return{downloadCSV:async()=>{const a=n("api/admin/logins",{method:"GET",responseType:"blob",headers:{Accept:"text/csv"}},"downloadCSV"),s=await(await t(a.caller,a.id)).blob(),c=window.URL.createObjectURL(s);window.location.assign(c)},errors:r,loading:e}},sPe={id:"created_at"},{value:X3,setValue:lPe}=Lc("LoginHistoryTable:v1",sPe),cPe={simple:"Password",oidc:"OIDC",saml:"SAML",google:"Google"},uPe=()=>{const{events:e,loading:t}=rPe(),{downloadCSV:n}=aPe(),[r,o]=Sd(),[i]=m.useState(()=>({sortBy:[{id:r.get("sort")||X3.id,desc:r.has("order")?r.get("order")==="desc":X3.desc}],hiddenColumns:["failure_reason"],globalFilter:r.get("search")||""})),[a,s]=m.useState(i.globalFilter),c=tr(ua.breakpoints.down("sm")),u=tr(ua.breakpoints.down("md")),d=m.useMemo(()=>[{Header:"Created",accessor:"created_at",Cell:({value:S})=>l(ZM,{value:S,dateFormat:_1}),sortType:"date",maxWidth:150},{Header:"Username",accessor:"username",minWidth:100,Cell:bs,searchable:!0},{Header:"Authentication",accessor:S=>cPe[S.auth_type]||S.auth_type,width:150,maxWidth:150,Cell:bs,searchable:!0,filterName:"auth"},{Header:"IP address",accessor:"ip",Cell:bs,searchable:!0},{Header:"Success",accessor:"successful",align:"center",Cell:iPe,filterName:"success",filterParsing:S=>S.toString()},{accessor:"failure_reason",Header:"Failure Reason",searchable:!0}],[]),{data:p,getSearchText:f,getSearchContext:h}=Yh(d,a,e),{headerGroups:g,rows:v,prepareRow:b,state:{sortBy:y},setHiddenColumns:w}=Jt.useTable({columns:d,data:p,initialState:i,sortTypes:qo,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0,defaultColumn:{Cell:Hn}},Jt.useSortBy,Jt.useFlexLayout);return Od([{condition:c,columns:["role","seenAt"]},{condition:u,columns:["imageUrl","tokens","createdAt"]}],w,d),m.useEffect(()=>{const S={};S.sort=y[0].id,y[0].desc&&(S.order="desc"),a&&(S.search=a),o(S,{replace:!0}),lPe({id:y[0].id,desc:y[0].desc||!1})},[y,a,o]),x(yr,{isLoading:t,header:l(Tn,{title:`Login history (${v.length})`,actions:x(ve,{children:[l(q,{condition:!u,show:l(ko,{initialValue:a,onChange:s,hasFilters:!0,getSearchContext:h})}),l(q,{condition:v.length>0,show:x(ve,{children:[l(q,{condition:!u,show:l(Tn.Divider,{})}),l(xt,{title:"Download login history",arrow:!0,children:l(jt,{onClick:n,children:l(Ile,{})})})]})})]}),children:l(q,{condition:u,show:l(ko,{initialValue:a,onChange:s,hasFilters:!0,getSearchContext:h})})}),children:[l(Ls,{value:f(a),children:l(A1,{rows:v,headerGroups:g,prepareRow:b})}),l(q,{condition:v.length===0,show:l(q,{condition:(a==null?void 0:a.length)>0,show:x(ar,{children:["No login events found matching “",a,"”"]}),elseShow:l(ar,{children:"No login events available."})})})]})},dPe=()=>l("div",{children:l(PM,{permissions:yi,children:l(uPe,{})})}),pPe=()=>{const{makeRequest:e,createRequest:t,errors:n,loading:r}=Vn({propagateErrors:!0});return{updateFeatureTypeLifetime:async(i,a)=>{const s={lifetimeDays:a},c=`api/admin/feature-types/${i}/lifetime`,u=t(c,{method:"PUT",body:JSON.stringify(s)});try{await e(u.caller,u.id)}catch(d){throw d}},errors:n,loading:r}},fPe=C("div")(({theme:e})=>({display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100vh",padding:e.spacing(4),position:"fixed",inset:0,backgroundColor:e.palette.background.paper,width:"100%"})),hPe=C(tL)(({theme:e})=>({height:"80px"})),mPe=C("div")(({theme:e})=>({display:"flex",position:"relative"})),gPe=C("div")(({theme:e})=>({marginTop:e.spacing(4)})),vPe=C(Ve)(({theme:e})=>({height:"150px",width:"150px",position:"absolute",right:100,top:45})),nB=({children:e})=>{const t=pt();return x(fPe,{children:[x("div",{children:[l(hPe,{}),l(mPe,{children:l(se,{variant:"h1",style:{fontSize:"2rem"},children:"Ooops. That's a page we haven't toggled on yet."})}),x(gPe,{children:[l(Ve,{variant:"contained",color:"primary",onClick:()=>{t(yo)},children:"Go back"}),l(vPe,{onClick:()=>{t("/")},children:"Go home"})]})]}),e]})},yPe=C($e)(({theme:e})=>({display:"flex",justifyContent:"flex-end",marginTop:"auto",gap:e.spacing(2),paddingTop:e.spacing(4)})),bPe=C($e)(()=>({display:"flex",flexDirection:"column",flexGrow:1})),wPe=({featureType:e,loading:t})=>{const n=pt(),{uiConfig:r}=It(),{refetch:o}=qh(),{updateFeatureTypeLifetime:i,loading:a}=pPe(),[s,c]=m.useState((e==null?void 0:e.lifetimeDays)||0),[u,d]=m.useState(!(e!=null&&e.lifetimeDays)),{setToastData:p,setToastApiError:f}=$t(),h=br(),g=S=>{const k=parseInt(As(S.target.value),10);c(k),k===0&&d(!0)},v=S=>{d(S.target.checked),s===0&&c((e==null?void 0:e.lifetimeDays)||1)},b=!u&&(Number.isNaN(s)||s<0),y=async S=>{S.preventDefault();try{if(!(e!=null&&e.id))throw new Error("No feature toggle type loaded");const k=u?0:s;await i(e==null?void 0:e.id,k),o(),p({title:"Feature type updated",type:"success"}),n("/feature-toggle-type"),h.trackEvent("feature-type-edit")}catch(k){f(gt(k))}},w=m.useCallback(()=>[`curl --location --request PUT '${r.unleashUrl}/api/admin/feature-types/${e==null?void 0:e.id}/lifetime`,"--header 'Authorization: INSERT_API_KEY'","--header 'Content-Type: application/json'",`--data-raw '{
|
|
361
|
+
your user.`,documentationLink:"https://docs.getunleash.io/reference/api-tokens-and-client-keys",documentationLinkLabel:"Tokens documentation",formatApiCode:S,children:x(d_e,{onSubmit:w,children:[l("div",{children:l(u_e,{description:u,setDescription:d,isDescriptionUnique:A,expiration:p,setExpiration:f,expiresAt:h,setExpiresAt:g,errors:v,setErrors:b})}),x(p_e,{children:[l(Ve,{type:"submit",variant:"contained",color:"primary",disabled:!T,children:"Create token"}),l(f_e,{onClick:()=>{t(!1)},children:"Cancel"})]})]})})})},m_e=({open:e,setOpen:t,token:n})=>{const{refetchTokens:r}=QT(),{deletePersonalAPIToken:o}=XM(),{setToastData:i,setToastApiError:a}=$t();return l(vr,{open:e,primaryButtonText:"Delete token",secondaryButtonText:"Cancel",onClick:async()=>{if(n)try{await o(n==null?void 0:n.id),r(),t(!1),i({title:"Token deleted successfully",type:"success"})}catch(c){a(gt(c))}},onClose:()=>{t(!1)},title:"Delete token?",children:x(se,{children:['Any applications or scripts using this token "',l("strong",{children:n==null?void 0:n.description}),'" will no longer be able to access the Unleash API. You cannot undo this action.']})})},g_e=C(Vt)(({theme:e})=>({marginBottom:e.spacing(3)})),v_e=({open:e,setOpen:t,token:n})=>x(vr,{open:e,secondaryButtonText:"Close",onClose:(r,o)=>{o||t(!1)},title:"Personal API token created",children:[l(g_e,{severity:"info",children:"Make sure to copy your personal API token now. You won't be able to see it again!"}),l(se,{variant:"body1",children:"Your token:"}),l(UM,{token:(n==null?void 0:n.secret)||""})]}),ZM=({value:e,live:t=!1,emptyText:n,title:r,dateFormat:o=rd})=>{const{locationSettings:i}=es();if(!e)return l(Hn,{children:n});const a=o(e,i.locale);return l(Hn,{children:l(xt,{title:(r==null?void 0:r(a))??a,arrow:!0,children:l(se,{noWrap:!0,component:"span",variant:"body2","data-loading":!0,children:l(P1,{date:new Date(e),live:t,title:""})})})})},y_e=C(Vt)(({theme:e})=>({marginBottom:e.spacing(3)})),b_e=C("div")(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"center",padding:e.spacing(10,2)})),w_e=C(se)(({theme:e})=>({fontSize:e.fontSizes.mainHeader,marginBottom:e.spacing(1.5)})),S_e=C(se)(({theme:e})=>({color:e.palette.text.secondary,marginBottom:e.spacing(4.5)})),x_e=Array(15).fill({description:"Short description of the feature",type:"-",createdAt:new Date(2022,1,1),project:"projectID"}),C_e={id:"createdAt"},{value:G3,setValue:E_e}=Lc("PersonalAPITokensTable:v1",C_e),T_e=()=>{const e=yn(),t=tr(e.breakpoints.down("md")),n=tr(e.breakpoints.down("sm")),{tokens:r=[],loading:o}=QT(),[i,a]=Sd(),[s]=m.useState(()=>({sortBy:[{id:i.get("sort")||G3.id,desc:i.has("order")?i.get("order")==="desc":G3.desc}],globalFilter:i.get("search")||""})),[c,u]=m.useState(s.globalFilter),[d,p]=m.useState(!1),[f,h]=m.useState(!1),[g,v]=m.useState(!1),[b,y]=m.useState(),[w,S]=m.useState(),k=m.useMemo(()=>[{Header:"Description",accessor:"description",Cell:bs,minWidth:100,searchable:!0},{Header:"Expires",accessor:"expiresAt",Cell:({value:B})=>new Date(B).getFullYear()>new Date().getFullYear()+100?l(Hn,{children:"Never"}):l(ch,{value:B}),sortType:"date",maxWidth:150},{Header:"Created",accessor:"createdAt",Cell:ch,sortType:"date",maxWidth:150},{Header:"Last seen",accessor:"seenAt",Cell:ZM,sortType:"date",maxWidth:150},{Header:"Actions",id:"Actions",align:"center",Cell:({row:{original:B}})=>l(da,{children:l(xt,{title:"Delete token",arrow:!0,describeChild:!0,children:l("span",{children:l(jt,{onClick:()=>{S(B),v(!0)},children:l(vo,{})})})})}),maxWidth:100,disableSortBy:!0}],[S,v]),{data:A,getSearchText:T,getSearchContext:R}=Yh(k,c,r),P=m.useMemo(()=>(A==null?void 0:A.length)===0&&o?x_e:A,[A,o]),{headerGroups:_,rows:O,prepareRow:$,state:{sortBy:z},setHiddenColumns:L}=Jt.useTable({columns:k,data:P,initialState:s,sortTypes:qo,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0},Jt.useSortBy,Jt.useFlexLayout);return Od([{condition:n,columns:["expiresAt"]},{condition:t,columns:["createdAt"]}],L,k),m.useEffect(()=>{const B={};B.sort=z[0].id,z[0].desc&&(B.order="desc"),c&&(B.search=c),a(B,{replace:!0}),E_e({id:z[0].id,desc:z[0].desc||!1})},[z,c,a]),x(yr,{isLoading:o,header:l(Tn,{title:`Personal API tokens (${O.length<P.length?`${O.length} of ${P.length}`:P.length})`,actions:x(ve,{children:[l(q,{condition:!t,show:x(ve,{children:[l(ko,{initialValue:c,onChange:u,getSearchContext:R}),l(Tn.Divider,{})]})}),l(Ve,{variant:"contained",color:"primary",disabled:r.length>=e_e,onClick:()=>p(!0),children:"New token"})]}),children:l(q,{condition:t,show:l(ko,{initialValue:c,onChange:u,hasFilters:!0,getSearchContext:R})})}),children:[l(y_e,{severity:"info",children:"Use personal API tokens to authenticate to the Unleash API as yourself. A personal API token has the same access privileges as your user."}),l(Ls,{value:T(c),children:l(A1,{rows:O,headerGroups:_,prepareRow:$})}),l(q,{condition:O.length===0,show:l(q,{condition:(c==null?void 0:c.length)>0,show:x(ar,{children:["No tokens found matching “",c,"”"]}),elseShow:x(b_e,{children:[l(w_e,{children:"You have no personal API tokens yet."}),l(S_e,{variant:"body2",children:"Need an API token for scripts or testing? Create a personal API token for quick access to the Unleash API."}),l(Ve,{variant:"outlined",onClick:()=>p(!0),children:"Create your first token"})]})})}),l(h_e,{open:d,setOpen:p,newToken:B=>{y(B),h(!0)}}),l(v_e,{open:f,setOpen:h,token:b}),l(m_e,{open:g,setOpen:v,token:w})]})},k_e=()=>{const{data:e,error:t,mutate:n}=Pn(Rt("api/admin/user/profile"),A_e);return{profile:e,loading:!t&&!e,refetchProfile:()=>n(),error:t}},A_e=e=>fetch(e).then(bn("Profile")).then(t=>t.json());var ZT={},R_e=An;Object.defineProperty(ZT,"__esModule",{value:!0});var eB=ZT.default=void 0,__e=R_e(Rn()),P_e=_n,I_e=(0,__e.default)((0,P_e.jsx)("path",{d:"M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16.77c.68 0 1.23-.56 1.23-1.23V8c0-1.1-.9-2-2-2zm0 12H4V6h5.17l2 2H20v10zm-2-6H6v-2h12v2zm-4 4H6v-2h8v2z"}),"TopicOutlined");eB=ZT.default=I_e;const tB=(e,t={})=>{const{isEnterprise:n}=It(),{data:r,error:o,mutate:i}=Mc(!!e&&n(),void 0,Rt(`api/admin/roles/${e}`),O_e,t);return m.useMemo(()=>({role:r,loading:!o&&!r,refetch:()=>i(),error:o}),[r,o,i])},O_e=e=>fetch(e).then(bn("Role")).then(t=>t.json()),hc=e=>e.environment?`${e.id}-${e.environment}`:`${e.id}`,S8e=e=>e.reduce((t,n)=>(t[hc(n)]=n,t),{}),x8e=(e,t)=>{let n=rm(e);return n[hc(t)]?delete n[hc(t)]:n[hc(t)]={...t},n},C8e=(e,t)=>{let n=rm(e);return t.every(o=>n[hc(o)])?t.forEach(o=>{delete n[hc(o)]}):t.forEach(o=>{n[hc(o)]={...o}}),n},$_e=e=>e.filter(({name:n})=>n!=="ADMIN").reduce((n,r)=>{var a;const o=((a=CTe.find(s=>s.permissions.includes(r.name)))==null?void 0:a.label)||"Other",i=n.find(({label:s})=>s===o);return i?i.permissions.push(r):n.push({label:o,type:"root",permissions:[r]}),n},[]).sort(L_e),N_e=e=>{const t=e.filter(({type:o})=>o===KRe),n=e.filter(({type:o})=>o===YRe),r=[];return t.length&&r.push({label:"Project",type:"project",permissions:t}),r.push(...n.reduce((o,i)=>{const a=i.environment,s=o.find(({label:c})=>c===a);return s?s.permissions.push(i):o.push({label:a,type:"environment",permissions:[i]}),o},[])),r},E8e=(e,t)=>[...e,...t.flatMap(({permissions:n})=>n)],L_e=({label:e},{label:t})=>e==="Other"&&t!=="Other"?1:e!=="Other"&&t==="Other"?-1:e.localeCompare(t),D_e=C("div",{shouldForwardProp:e=>e!=="tooltip"})(({theme:e,tooltip:t})=>({width:"100%",maxWidth:e.spacing(50),padding:t?e.spacing(1):e.spacing(3),backgroundColor:t?e.palette.background.paper:e.palette.neutral.light,color:e.palette.text.secondary,fontSize:e.fontSizes.smallBody,borderRadius:e.shape.borderRadiusMedium})),M_e=C("div")(({theme:e})=>({marginTop:e.spacing(2)})),q3=C("p")(({theme:e})=>({color:e.palette.text.primary,fontSize:e.fontSizes.smallBody,fontWeight:e.fontWeight.bold,marginBottom:e.spacing(1)})),B_e=C("p")(({theme:e})=>({fontSize:e.fontSizes.smallBody,marginTop:e.spacing(1)})),F_e=({roleId:e,tooltip:t,...n})=>{const{role:r}=tB(e.toString());if(!r)return null;const{name:o,description:i,permissions:a,type:s}=r,u=ZRe.includes(s)?N_e(a):$_e(a);return x(D_e,{tooltip:t,...n,children:[l(q3,{sx:{mb:0},children:o}),l(B_e,{children:i}),l(q,{condition:!QRe.includes(r.type),show:()=>u.map(({label:d,permissions:p})=>x(M_e,{children:[l(q3,{children:d}),p.map(f=>l("p",{children:f.displayName},f.id))]},d))})]})},z_e=({roleId:e,children:t})=>{const{role:n}=tB(e.toString());return n?l(Dc,{title:l(F_e,{roleId:e,tooltip:!0}),arrow:!0,children:l(qt,{color:"success",icon:l(IP,{}),sx:{cursor:"pointer"},children:n.name})}):t?l(qt,{color:"success",icon:l(IP,{}),children:t}):null},j_e=C("div")(({theme:e})=>({display:"flex",flexDirection:"row",alignItems:"center",padding:e.spacing(6),borderRadius:e.shape.borderRadiusLarge,backgroundColor:e.palette.background.alternative,color:e.palette.primary.contrastText,marginBottom:e.spacing(3),boxShadow:e.boxShadows.primaryHeader})),U_e=C("div")(()=>({flexGrow:1})),W_e=C(se)(({theme:e})=>({fontSize:e.spacing(3.75)})),H_e=C(y2)(({theme:e})=>({width:e.spacing(9.5),height:e.spacing(9.5),marginRight:e.spacing(3)})),Y3=C(se)(({theme:e})=>({fontSize:e.fontSizes.mainHeader,marginBottom:e.spacing(3)})),V_e=C("div")(({theme:e})=>({display:"flex",flexDirection:"row","& > div > p":{marginBottom:e.spacing(1.5)}})),G_e=C(qt)(({theme:e})=>({cursor:"pointer",marginRight:e.spacing(1)})),q_e=C("div")(({theme:e})=>({width:"100%",height:"1px",backgroundColor:e.palette.divider,margin:e.spacing(3,0)})),Y_e=C($s)(({theme:e})=>({marginTop:e.spacing(1.5),width:e.spacing(30)})),K_e=C(zh)(({theme:e})=>({backgroundColor:e.palette.background.paper})),X_e=({user:e})=>{const{profile:t}=k_e(),n=pt(),{locationSettings:r,setLocationSettings:o}=es(),[i,a]=m.useState(),[s,c]=m.useState(["en-US","en-GB","nb-NO","sv-SE","da-DK","en-IN","de","cs","pt-BR","fr-FR"]);m.useEffect(()=>{const d=s.find(p=>p.toLowerCase().includes(r.locale.toLowerCase()));a(d),d||c(p=>[...p,r.locale])},[r]);const u=d=>{const p=d.target.value;a(p),o({locale:p})};return x(ve,{children:[x(j_e,{children:[l(H_e,{user:e}),x(U_e,{children:[l(W_e,{children:e.name||e.username}),l(se,{variant:"body1",children:e.email})]})]}),x(yr,{children:[l(Y3,{children:"Access"}),x(V_e,{children:[l($e,{sx:{width:"50%"},children:l(q,{condition:!!(t!=null&&t.rootRole),show:()=>x(ve,{children:[l(se,{variant:"body2",children:"Your root role"}),l(z_e,{roleId:t==null?void 0:t.rootRole.id,children:t==null?void 0:t.rootRole.name})]})})}),x($e,{children:[l(se,{variant:"body2",children:"Projects"}),l(q,{condition:!!(t!=null&&t.projects.length),show:t==null?void 0:t.projects.map(d=>l(xt,{title:"View project",arrow:!0,placement:"bottom-end",describeChild:!0,children:l(G_e,{onClick:p=>{p.preventDefault(),n(`/projects/${d}`)},color:"secondary",icon:l(eB,{}),children:d})},d)),elseShow:l(xt,{title:"You are not assigned to any projects",arrow:!0,describeChild:!0,children:l(qt,{children:"No projects"})})})]})]}),l(q_e,{}),l(Y3,{children:"Settings"}),l(se,{variant:"body2",children:"This is the format used across the system for time and date"}),x(Y_e,{variant:"outlined",size:"small",children:[l(K_e,{htmlFor:"locale-select",children:"Date/Time formatting"}),l(jh,{id:"locale-select",value:i||"",native:!0,onChange:u,MenuProps:{style:{zIndex:9999}},children:s.map(d=>l("option",{value:d,children:d},d))})]})]})]})},J_e=()=>{const{user:e}=vi(),t=Ro(),n=pt(),{config:r,loading:o}=qM("simple"),{uiConfig:i}=It(),a=[{id:"profile",label:"Profile"},{id:"password",label:"Change password",path:"change-password",hidden:r.disabled},{id:"pat",label:"Personal API tokens",path:"personal-api-tokens",hidden:i.flags.personalAccessTokensKillSwitch}],s=p=>{n(p.path?`/profile/${p.path}`:"/profile",{replace:!0}),d(p.id)},c=()=>{const p=t.pathname;return(a.find(({path:h})=>h&&p.includes(h))||a[0]).id},[u,d]=m.useState(c());return m.useEffect(()=>{d(c())},[t]),o?null:x(HRe,{tabs:a,value:u,onChange:s,children:[l(q,{condition:u==="profile",show:l(X_e,{user:e})}),l(q,{condition:u==="password",show:l(qRe,{})}),l(q,{condition:u==="pat",show:l(T_e,{})})]})},Q_e=m.lazy(()=>import("./CreateProject-c1b0f704.js")),Z_e=m.lazy(()=>import("./FeatureViewLazyExport-58a3e977.js")),ePe=m.lazy(()=>import("./LazyAdminExport-c98b11d7.js")),tPe=m.lazy(()=>import("./LazyProjectExport-14db2e37.js")),nPe=()=>l($c,{to:"/admin/users",replace:!0}),rPe=()=>{const{isEnterprise:e}=It(),{data:t,error:n,mutate:r}=Mc(e(),{events:[]},Rt("api/admin/logins"),oPe);return m.useMemo(()=>({events:(t==null?void 0:t.events)??[],loading:!n&&!t,refetch:()=>r(),error:n}),[t,n,r])},oPe=e=>fetch(e).then(bn("Login History")).then(t=>t.json()),K3=C($e)(()=>({display:"flex",justifyContent:"center"})),iPe=({row:e,value:t})=>{const{searchQuery:n}=Ol();return t?l(K3,{children:l(qt,{color:"success",children:"True"})}):l(K3,{children:l(Dc,{arrow:!0,title:l(Ya,{search:n,children:e.original.failure_reason}),children:l(qt,{color:"error",children:"False"})})})},aPe=()=>{const{loading:e,makeRequest:t,createRequest:n,errors:r}=Vn({propagateErrors:!0});return{downloadCSV:async()=>{const a=n("api/admin/logins",{method:"GET",responseType:"blob",headers:{Accept:"text/csv"}},"downloadCSV"),s=await(await t(a.caller,a.id)).blob(),c=window.URL.createObjectURL(s);window.location.assign(c)},errors:r,loading:e}},sPe={id:"created_at"},{value:X3,setValue:lPe}=Lc("LoginHistoryTable:v1",sPe),cPe={simple:"Password",oidc:"OIDC",saml:"SAML",google:"Google"},uPe=()=>{const{events:e,loading:t}=rPe(),{downloadCSV:n}=aPe(),[r,o]=Sd(),[i]=m.useState(()=>({sortBy:[{id:r.get("sort")||X3.id,desc:r.has("order")?r.get("order")==="desc":X3.desc}],hiddenColumns:["failure_reason"],globalFilter:r.get("search")||""})),[a,s]=m.useState(i.globalFilter),c=tr(ua.breakpoints.down("sm")),u=tr(ua.breakpoints.down("md")),d=m.useMemo(()=>[{Header:"Created",accessor:"created_at",Cell:({value:S})=>l(ZM,{value:S,dateFormat:_1}),sortType:"date",maxWidth:150},{Header:"Username",accessor:"username",minWidth:100,Cell:bs,searchable:!0},{Header:"Authentication",accessor:S=>cPe[S.auth_type]||S.auth_type,width:150,maxWidth:150,Cell:bs,searchable:!0,filterName:"auth"},{Header:"IP address",accessor:"ip",Cell:bs,searchable:!0},{Header:"Success",accessor:"successful",align:"center",Cell:iPe,filterName:"success",filterParsing:S=>S.toString()},{accessor:"failure_reason",Header:"Failure Reason",searchable:!0}],[]),{data:p,getSearchText:f,getSearchContext:h}=Yh(d,a,e),{headerGroups:g,rows:v,prepareRow:b,state:{sortBy:y},setHiddenColumns:w}=Jt.useTable({columns:d,data:p,initialState:i,sortTypes:qo,autoResetHiddenColumns:!1,autoResetSortBy:!1,disableSortRemove:!0,disableMultiSort:!0,defaultColumn:{Cell:Hn}},Jt.useSortBy,Jt.useFlexLayout);return Od([{condition:c,columns:["role","seenAt"]},{condition:u,columns:["imageUrl","tokens","createdAt"]}],w,d),m.useEffect(()=>{const S={};S.sort=y[0].id,y[0].desc&&(S.order="desc"),a&&(S.search=a),o(S,{replace:!0}),lPe({id:y[0].id,desc:y[0].desc||!1})},[y,a,o]),x(yr,{isLoading:t,header:l(Tn,{title:`Login history (${v.length})`,actions:x(ve,{children:[l(q,{condition:!u,show:l(ko,{initialValue:a,onChange:s,hasFilters:!0,getSearchContext:h})}),l(q,{condition:v.length>0,show:x(ve,{children:[l(q,{condition:!u,show:l(Tn.Divider,{})}),l(xt,{title:"Download login history",arrow:!0,children:l(jt,{onClick:n,children:l(Ile,{})})})]})})]}),children:l(q,{condition:u,show:l(ko,{initialValue:a,onChange:s,hasFilters:!0,getSearchContext:h})})}),children:[l(Ls,{value:f(a),children:l(A1,{rows:v,headerGroups:g,prepareRow:b})}),l(q,{condition:v.length===0,show:l(q,{condition:(a==null?void 0:a.length)>0,show:x(ar,{children:["No login events found matching “",a,"”"]}),elseShow:l(ar,{children:"No login events available."})})})]})},dPe=()=>l("div",{children:l(PM,{permissions:yi,children:l(uPe,{})})}),pPe=()=>{const{makeRequest:e,createRequest:t,errors:n,loading:r}=Vn({propagateErrors:!0});return{updateFeatureTypeLifetime:async(i,a)=>{const s={lifetimeDays:a},c=`api/admin/feature-types/${i}/lifetime`,u=t(c,{method:"PUT",body:JSON.stringify(s)});try{await e(u.caller,u.id)}catch(d){throw d}},errors:n,loading:r}},fPe=C("div")(({theme:e})=>({display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100vh",padding:e.spacing(4),position:"fixed",inset:0,backgroundColor:e.palette.background.paper,width:"100%"})),hPe=C(tL)(({theme:e})=>({height:"80px"})),mPe=C("div")(({theme:e})=>({display:"flex",position:"relative"})),gPe=C("div")(({theme:e})=>({marginTop:e.spacing(4)})),vPe=C(Ve)(({theme:e})=>({height:"150px",width:"150px",position:"absolute",right:100,top:45})),nB=({children:e})=>{const t=pt();return x(fPe,{children:[x("div",{children:[l(hPe,{}),l(mPe,{children:l(se,{variant:"h1",style:{fontSize:"2rem"},children:"Ooops. That's a page we haven't toggled on yet."})}),x(gPe,{children:[l(Ve,{variant:"contained",color:"primary",onClick:()=>{t(yo)},children:"Go back"}),l(vPe,{onClick:()=>{t("/")},children:"Go home"})]})]}),e]})},yPe=C($e)(({theme:e})=>({display:"flex",justifyContent:"flex-end",marginTop:"auto",gap:e.spacing(2),paddingTop:e.spacing(4)})),bPe=C($e)(()=>({display:"flex",flexDirection:"column",flexGrow:1})),wPe=({featureType:e,loading:t})=>{const n=pt(),{uiConfig:r}=It(),{refetch:o}=qh(),{updateFeatureTypeLifetime:i,loading:a}=pPe(),[s,c]=m.useState((e==null?void 0:e.lifetimeDays)||0),[u,d]=m.useState(!(e!=null&&e.lifetimeDays)),{setToastData:p,setToastApiError:f}=$t(),h=br(),g=S=>{const k=parseInt(As(S.target.value),10);c(k),k===0&&d(!0)},v=S=>{d(S.target.checked),s===0&&c((e==null?void 0:e.lifetimeDays)||1)},b=!u&&(Number.isNaN(s)||s<0),y=async S=>{S.preventDefault();try{if(!(e!=null&&e.id))throw new Error("No feature toggle type loaded");const k=u?0:s;await i(e==null?void 0:e.id,k),o(),p({title:"Feature type updated",type:"success"}),n("/feature-toggle-type"),h.trackEvent("feature-type-edit")}catch(k){f(gt(k))}},w=m.useCallback(()=>[`curl --location --request PUT '${r.unleashUrl}/api/admin/feature-types/${e==null?void 0:e.id}/lifetime`,"--header 'Authorization: INSERT_API_KEY'","--header 'Content-Type: application/json'",`--data-raw '{
|
|
362
362
|
"lifetimeDays": 7
|
|
363
363
|
}'`].join(` \\
|
|
364
364
|
`),[r,e==null?void 0:e.id]);return!t&&!e?l(nB,{children:l("div",{"data-testid":"404_NOT_FOUND"})}):l(Fr,{modal:!0,title:t?"Edit toggle type":`Edit toggle type: ${e==null?void 0:e.name}`,description:(e==null?void 0:e.description)||"",documentationLink:"https://docs.getunleash.io/reference/feature-toggle-types",documentationLinkLabel:"Feature toggle types documentation",formatApiCode:w,children:x(bPe,{component:"form",onSubmit:y,children:[x(se,{sx:S=>({margin:S.spacing(3,0,1),display:"flex",alignItems:"center"}),children:[l($e,{component:"label",htmlFor:"feature-toggle-lifetime",children:"Expected lifetime"}),l(Xa,{htmlTooltip:!0,tooltip:x(ve,{children:[l("p",{children:"If your toggle exceeded lifetime of it's type it will be marked as potencially stale."}),l("br",{}),l("a",{href:"https://docs.getunleash.io/reference/feature-toggle-types#expected-lifetime",target:"_blank",rel:"noreferrer",children:"Read more in the documentation"})]})})]}),x($e,{component:"label",sx:S=>({display:"flex",alignItems:"center",cursor:"pointer",marginBottom:S.spacing(1),marginRight:"auto"}),htmlFor:"feature-toggle-expire",children:[l(pa,{checked:u||s===0,id:"feature-toggle-expire",onChange:v,disabled:t}),l($e,{children:"doesn't expire"})]}),l(rr,{autoFocus:!0,disabled:u||t,type:"number",label:"Lifetime in days",id:"feature-toggle-lifetime",value:u?"0":`${s}`,onChange:g,error:b}),x(yPe,{children:[l(Po,{permission:yi,variant:"contained",color:"primary",type:"submit",disabled:t||a,children:"Save feature toggle type"}),l(Ve,{type:"button",color:"primary",onClick:()=>n(yo),children:"Cancel"})]})]})})},SPe=({featureTypes:e,loading:t})=>{const{featureTypeId:n}=J$(),r=e.find(o=>o.id===n);return l(wPe,{featureType:r,loading:t})},xPe="/feature-toggle-type",CPe=()=>{const{featureTypes:e,loading:t}=qh(),n=pt(),r=m.useMemo(()=>[{accessor:"id",Cell:({value:d})=>{const p=d9(d);return l(Xh,{icon:l(p,{"data-loading":"true",color:"action"})})},width:50,disableSortBy:!0},{Header:"Name",accessor:"name",width:"90%",Cell:({row:{original:{name:d,description:p}}})=>l(Ts,{"data-loading":!0,title:d,subtitle:p}),sortType:"alphanumeric"},{Header:"Lifetime",accessor:"lifetimeDays",Cell:({value:d})=>d?l(Hn,{children:d===1?"1 day":`${d} days`}):l(Hn,{children:"doesn't expire"}),minWidth:150,sortType:"numericZeroLast"},{Header:"Actions",Cell:({row:{original:d}})=>l($e,{sx:p=>({padding:p.spacing(.5,0)}),children:l(da,{children:l($r,{disabled:!d.id,"data-loading":"true",onClick:()=>n(`/feature-toggle-type/edit/${d.id}`),permission:yi,tooltipProps:{title:`Edit ${d.name} feature toggle type`},children:l(di,{})})})}),disableSortBy:!0}],[n]),o=m.useMemo(()=>t?Array(5).fill({id:"",name:"Loading...",description:"Loading...",lifetimeDays:1}):e,[t,e]),{getTableProps:i,getTableBodyProps:a,headerGroups:s,rows:c,prepareRow:u}=Jt.useTable({columns:r,data:o,sortTypes:qo,autoResetSortBy:!1,disableSortRemove:!0,initialState:{sortBy:[{id:"lifetimeDays"}]}},Jt.useSortBy);return x(yr,{isLoading:t,header:l(Tn,{children:l(se,{component:"h2",sx:d=>({fontSize:d.fontSizes.mainHeader}),children:"Feature toggle types"})}),children:[x(Gi,{...i(),children:[l(Vi,{headerGroups:s}),l(Wi,{...a(),children:c.map(d=>(u(d),l(ui,{hover:!0,...d.getRowProps(),children:d.cells.map(p=>l(pi,{...p.getCellProps(),children:p.render("Cell")}))})))})]}),l(Z$,{children:l(hf,{path:"edit/:featureTypeId",element:l(om,{label:"Edit feature toggle type",onClose:()=>n(xPe),open:!0,children:l(SPe,{featureTypes:e,loading:t})})})})]})},bh=[{path:"/splash/:splashId",title:"Unleash",component:yke,type:"protected",menu:{},isStandalone:!0},{path:"/projects/create",parent:"/projects",title:"Create",component:Q_e,type:"protected",enterprise:!0,menu:{}},{path:"/projects/:projectId/edit",parent:"/projects",title:":projectId",component:OEe,type:"protected",enterprise:!0,menu:{}},{path:"/projects/:projectId/archived",title:":projectId",parent:"/archive",component:Ive,type:"protected",menu:{}},{path:"/projects/:projectId/features/:featureId/:activeTab/copy",parent:"/projects/:projectId/features/:featureId/:activeTab",title:"Copy",component:J2e,type:"protected",menu:{}},{path:"/projects/:projectId/features/:featureId/edit",parent:"/projects",title:"Edit feature",component:s2e,type:"protected",menu:{}},{path:"/projects/:projectId/features/:featureId/*",parent:"/projects",title:"FeatureView",component:Z_e,type:"protected",menu:{}},{path:"/projects/:projectId/create-toggle",parent:"/projects/:projectId/features",title:"Create feature toggle",component:GEe,type:"protected",menu:{}},{path:"/projects/:projectId/features2/:featureId",parent:"/features",title:":featureId",component:O3,type:"protected",menu:{}},{path:"/projects/:projectId/*",parent:"/projects",title:":projectId",component:tPe,flag:vge,type:"protected",menu:{}},{path:"/projects",title:"Projects",component:Pve,type:"protected",menu:{mobile:!0}},{path:"/features/:activeTab/:featureId",parent:"/features",title:":featureId",component:O3,type:"protected",menu:{}},{path:"/features",title:"Feature toggles",component:Ofe,type:"protected",menu:{mobile:!0}},{path:"/playground",title:"Playground",component:BRe,hidden:!1,type:"protected",menu:{mobile:!0}},{path:"/applications/:name",title:":name",parent:"/applications",component:f2e,type:"protected",menu:{}},{path:"/applications",title:"Applications",component:h2e,type:"protected",menu:{mobile:!0,advanced:!0}},{path:"/context/create",parent:"/context",title:"Create",component:Ske,type:"protected",menu:{}},{path:"/context/edit/:name",parent:"/context",title:":name",component:oEe,type:"protected",menu:{}},{path:"/context",title:"Context fields",component:v2e,type:"protected",menu:{mobile:!0,advanced:!0}},{path:"/feature-toggle-type/*",title:"Feature toggle types",component:CPe,type:"protected",menu:{mobile:!0,advanced:!0},flag:"configurableFeatureTypeLifetimes"},{path:"/strategies/create",title:"Create",parent:"/strategies",component:nke,type:"protected",menu:{}},{path:"/strategies/:name/edit",title:":name",parent:"/strategies",component:rke,type:"protected",menu:{}},{path:"/strategies/:name",title:":name",parent:"/strategies",component:yhe,type:"protected",menu:{}},{path:"/strategies",title:"Strategy types",component:nme,type:"protected",menu:{mobile:!0,advanced:!0}},{path:"/environments/create",title:"Environments",component:Sye,parent:"/environments",type:"protected",menu:{}},{path:"/environments/:id",title:"Edit",component:Eye,type:"protected",menu:{}},{path:"/environments",title:"Environments",component:JAe,type:"protected",flag:yge,menu:{mobile:!0,advanced:!0}},{path:"/tag-types/create",parent:"/tag-types",title:"Create",component:hEe,type:"protected",menu:{}},{path:"/tag-types/edit/:name",parent:"/tag-types",title:":name",component:fEe,type:"protected",menu:{}},{path:"/tag-types",title:"Tag types",component:ime,type:"protected",menu:{mobile:!0,advanced:!0}},{path:"/addons/create/:providerId",parent:"/addons",title:"Create",component:U2e,type:"protected",menu:{}},{path:"/addons/edit/:addonId",parent:"/addons",title:"Edit",component:W2e,type:"protected",menu:{}},{path:"/addons",title:"Addons",component:wme,hidden:!1,type:"protected",menu:{mobile:!0,advanced:!0}},{path:"/segments/create",title:"Segments",component:nAe,hidden:!1,type:"protected",layout:"main",menu:{},flag:Jb},{path:"/segments/edit/:segmentId",title:"Segments",component:iAe,hidden:!1,type:"protected",layout:"main",menu:{},flag:Jb},{path:"/segments",title:"Segments",component:mRe,hidden:!1,type:"protected",menu:{mobile:!0,advanced:!0},flag:Jb},{path:"/history",title:"Event log",component:FTe,type:"protected",menu:{adminSettings:!0}},{path:"/admin/logins",title:"Login history",component:dPe,type:"protected",menu:{adminSettings:!0}},{path:"/archive",title:"Archived toggles",component:MRe,type:"protected",menu:{}},{path:"/admin",title:"Admin",component:nPe,hidden:!1,type:"protected",menu:{}},{path:"/admin/*",title:"Admin",component:ePe,hidden:!1,type:"protected",menu:{}},{path:"/profile/*",title:"Profile",component:J_e,type:"protected",menu:{}},{path:"/login",title:"Log in",component:gge,type:"unprotected",hidden:!0,menu:{},isStandalone:!0},{path:"/new-user",title:"New user",hidden:!0,component:Vge,type:"unprotected",menu:{},isStandalone:!0},{path:"/reset-password",title:"Reset password",hidden:!0,component:Yge,type:"unprotected",menu:{},isStandalone:!0},{path:"/forgotten-password",title:"Forgotten password",hidden:!0,component:tve,type:"unprotected",menu:{},isStandalone:!0}],EPe=[{path:"/admin/users",title:"Users",menu:{adminSettings:!0}},{path:"/admin/service-accounts",title:"Service accounts",menu:{adminSettings:!0,mode:["enterprise"]}},{path:"/admin/groups",title:"Groups",menu:{adminSettings:!0,mode:["enterprise"]},flag:bge},{path:"/admin/roles/*",title:"Roles",menu:{adminSettings:!0,mode:["enterprise"]}},{path:"/admin/cors",title:"CORS origins",flag:"embedProxyFrontend",menu:{adminSettings:!0}},{path:"/admin/auth",title:"Single sign-on",menu:{adminSettings:!0}},{path:"/admin/instance",title:"Instance stats",menu:{adminSettings:!0}},{path:"/admin/network/*",title:"Network",menu:{adminSettings:!0,mode:["pro","enterprise"]},configFlag:"networkViewEnabled"},{path:"/admin/maintenance",title:"Maintenance",menu:{adminSettings:!0}},{path:"/admin/admin-invoices",title:"Billing & invoices",menu:{adminSettings:!0,mode:["pro"]}},{path:"/admin/instance-privacy",title:"Instance privacy",menu:{adminSettings:!0}},{path:"/history",title:"Event log",menu:{adminSettings:!0}},{path:"/admin/logins",title:"Login history",menu:{adminSettings:!0,mode:["enterprise"]}}],TPe=bh.filter(e=>!e.hidden),kPe=()=>{const e=TPe.filter(o=>o.menu.advanced),t=bh.filter(o=>o.menu.adminSettings),n=bh.filter(o=>o.menu.mobile),r={mainNavRoutes:e,adminRoutes:t,mobileRoutes:n};return()=>r},J3=e=>e.map(t=>({path:t.path,flag:t.flag,title:t.title,menu:t.menu,configFlag:t.configFlag})),APe=kPe(),RPe=(e={})=>{const t=Rt("api/admin/notifications"),{data:n,error:r,mutate:o}=Pn(t,_Pe,e),i=m.useCallback(()=>{o().catch(console.warn)},[o]);return{notifications:n,error:r,loading:!r&&!n,refetchNotifications:i,mutateNotifications:o}},_Pe=async e=>await(await fetch(e).then(bn("Notifications"))).json();var ek={},PPe=An;Object.defineProperty(ek,"__esModule",{value:!0});var tk=ek.default=void 0,IPe=PPe(Rn()),OPe=_n,$Pe=(0,IPe.default)((0,OPe.jsx)("path",{d:"M12 22c1.1 0 2-.9 2-2h-4c0 1.1.89 2 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z"}),"Notifications");tk=ek.default=$Pe;const NPe=C($e)(({theme:e})=>({padding:e.spacing(1,1.5,1,3),display:"flex",justifyContent:"space-between",alignItems:"center",position:"relative",boxShadow:e.boxShadows.separator})),LPe=({children:e})=>l(ve,{children:x(NPe,{children:[l(se,{fontWeight:"bold",children:"Notifications"}),e]})}),DPe=C(ca)(({theme:e})=>({padding:e.spacing(1,1,3,1)})),MPe=({children:e})=>l(DPe,{"data-testid":"NOTIFICATIONS_LIST",children:e}),BPe=e=>m.createElement("svg",{width:18,height:14,viewBox:"0 0 18 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},m.createElement("path",{d:"M0.59 2.00016L2 0.590157L5.41 4.00016L4 5.41016L0.59 2.00016ZM13 11.5002L13 8.00016L7.41 8.00016L2 13.4102L0.59 12.0002L6.59 6.00016L13 6.00016L13 2.50016L17.5 7.00016L13 11.5002Z",fill:"currentColor"})),Q3=C($e,{shouldForwardProp:e=>e!=="readAt"})(({theme:e,readAt:t})=>({padding:e.spacing(.5),marginRight:e.spacing(1.5),backgroundColor:t?e.palette.neutral.light:e.palette.secondary.light,width:"30px",height:"30px",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:`${e.shape.borderRadius}px`,top:3,left:7})),FPe=C(rte)(({theme:e})=>({position:"relative",cursor:"pointer",padding:e.spacing(2.5,2,3,2),borderRadius:e.shape.borderRadiusMedium,width:"100%","&:after":{content:'""',width:`calc(100% - ${e.spacing(4)})`,height:"1px",position:"absolute",bottom:0,backgroundColor:e.palette.divider}})),zPe=C($e)(({theme:e})=>({display:"flex",flexDirection:"column",width:"100%"})),jPe=C($e)(({theme:e})=>({display:"flex",justifyContent:"space-between",alignItems:"center",margin:e.spacing(1,0,0,5.25)})),UPe=C(se,{shouldForwardProp:e=>e!=="readAt"})(({theme:e,readAt:t})=>({display:"flex",alignItems:"center",fontSize:e.fontSizes.smallBody,fontWeight:t?"normal":"bold",textDecoration:"none",color:"inherit",wordBreak:"break-all"})),WPe=C(se)(({theme:e})=>({fontSize:e.fontSizes.smallerBody,color:e.palette.neutral.main})),HPe=C($e)(({theme:e})=>({...Nc})),VPe=C(Rd)(({theme:e})=>({width:"18px",height:"18px"})),GPe=C(se)(({theme:e})=>({fontSize:e.fontSizes.smallBody,color:e.palette.neutral.main,marginLeft:e.spacing(1)})),qPe=({notification:e,onNotificationClick:t})=>{const n=yn(),{readAt:r}=e;return l(FPe,{onClick:()=>t(e),children:x(zPe,{children:[x(UPe,{readAt:!!r,children:[(i=>{if(i==="change-request")return l(Q3,{readAt:!!r,children:l(BPe,{color:e.readAt?n.palette.neutral.main:n.palette.primary.main,style:{transform:"scale(0.8)"}})});if(i==="toggle")return l(Q3,{readAt:!!r,children:l(Xle,{sx:a=>({height:"20px",width:"20px",color:r?a.palette.neutral.main:a.palette.primary.main})})})})(e.notificationType)," ",e.message]}),x(jPe,{children:[x(HPe,{children:[l(VPe,{src:e.createdBy.imageUrl||""}),x(GPe,{children:["Created by ",e.createdBy.username]})]}),l(WPe,{children:l(P1,{date:new Date(e.createdAt)})})]})]})})},YPe=C($e)(()=>({display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",minHeight:"150px"})),KPe=C(tk)(({theme:e})=>({height:"30px",width:"30px",color:e.palette.neutral.main,marginBottom:e.spacing(1)})),XPe=({text:e})=>x(YPe,{children:[l(KPe,{}),l(se,{color:"neutral.main",children:e})]}),JPe=()=>{const{makeRequest:e,createRequest:t,errors:n,loading:r}=Vn({propagateErrors:!0});return{loading:r,errors:n,markAsRead:async i=>{const s=t("api/admin/notifications/read",{method:"POST",body:JSON.stringify(i)});try{await e(s.caller,s.id)}catch(c){throw c}}}},QPe=C($e)(({theme:e})=>({display:"flex",gap:e.spacing(1),marginTop:e.spacing(.5)})),ZPe=({id:e,localStorageKey:t,eventName:n})=>{var d;const{uiConfig:r}=It(),{value:o,setValue:i}=Lc(`${r.baseUriPath}:${t}:v1:${e}`,{}),[a,s]=m.useState(o.value),{trackEvent:c}=br();if(!((d=r==null?void 0:r.flags)!=null&&d.T)||a)return null;const u=p=>{s(p),i({value:p}),c(n,{props:{eventType:e,wasHelpful:p==="yes"}})};return x(Cr,{elevation:0,sx:{background:p=>p.palette.neutral.light,padding:p=>p.spacing(1.5,2),marginTop:p=>p.spacing(1.5)},children:["Was this information useful to you?",x(QPe,{children:[l(Ve,{size:"small",variant:a==="yes"?"contained":"outlined",sx:{padding:0},onClick:()=>u("yes"),disabled:!!a,children:"Yes"}),l(Ve,{size:"small",variant:a==="no"?"contained":"outlined",sx:{padding:0},onClick:()=>u("no"),disabled:!!a,children:"No"})]})]})},e5e=C($e)(()=>({position:"relative"})),t5e=C($e)(({theme:e})=>({backgroundColor:e.palette.background.elevation1,display:"flex",justifyContent:"center"})),n5e=C(se)(({theme:e})=>({fontWeight:"bold",fontSize:e.fontSizes.smallBody,color:e.palette.primary.main,textAlign:"center"})),r5e=C(Cr)(({theme:e})=>({width:"420px",boxShadow:e.boxShadows.popup,borderRadius:`${e.shape.borderRadiusLarge}px`,position:"absolute",right:-100,top:60,maxHeight:"80vh",overflowY:"auto"})),o5e=C($e)(({theme:e})=>({backgroundColor:e.palette.primary.main,borderRadius:"100%",width:"7px",height:"7px",position:"absolute",top:7,right:4})),i5e=C($e)(()=>({...Nc})),a5e=C(se)(({theme:e})=>({fontSize:e.fontSizes.smallBody})),s5e=C(jt)(({theme:e})=>({"&:focus-visible":{outlineStyle:"solid",outlineWidth:2,outlineColor:e.palette.primary.main,borderRadius:"100%"}})),l5e=()=>{const[e,t]=m.useState(!1),{notifications:n,refetchNotifications:r}=RPe({refreshInterval:15e3}),o=pt(),{markAsRead:i}=JPe(),{uiConfig:a}=It(),{trackEvent:s}=br(),[c,u]=m.useState(!1),d=async w=>{var S;w.link&&o(w.link),(S=a==null?void 0:a.flags)!=null&&S.T&&s("notifications",{props:{eventType:w.notificationType}}),t(!1);try{await i({notifications:[w.id]}),r()}catch(k){console.error("Error marking notification as read: ",k)}},p=async()=>{try{n&&n.length>0&&(await i({notifications:n.map(w=>w.id)}),r())}catch(w){console.error("Error marking all notification as read: ",w)}},f=w=>{w.key==="Escape"&&t(!1)},h=n==null?void 0:n.filter(w=>w.readAt===null),g=!!(h&&h.length>0),v=w=>c?!w.readAt:!0,b=n==null?void 0:n.filter(v).map(w=>l(qPe,{notification:w,onNotificationClick:d},w.id)),y=!!(n&&n.length>0&&!c);return x(e5e,{children:[x(s5e,{onClick:()=>t(!e),"data-testid":"NOTIFICATIONS_BUTTON",disableFocusRipple:!0,children:[l(q,{condition:g,show:l(o5e,{})}),l(tk,{})]}),l(q,{condition:e,show:l(qN,{onClickAway:()=>t(!1),children:x(r5e,{className:"dropdown-outline",onKeyDown:f,"data-testid":"NOTIFICATIONS_MODAL",children:[l(LPe,{children:x(i5e,{children:[l(a5e,{children:"Show only unread"}),l(fa,{onClick:()=>u(!c),checked:c})]})}),l(q,{condition:g,show:l(t5e,{"data-testid":"UNREAD_NOTIFICATIONS",children:l(Ve,{onClick:p,children:x(n5e,{children:["Mark all as read (",h==null?void 0:h.length,")"]})})})})," ",l(q,{condition:(b==null?void 0:b.length)===0,show:l(XPe,{text:c?"No unread notifications":"No new notifications"})}),l(MPe,{children:b}),l(q,{condition:y,show:x(ve,{children:[l(ZPe,{eventName:"notifications",id:"useful",localStorageKey:"NotificationsUsefulPrompt"}),l("br",{})]})})]})})})]})},Z3=C(SK)(({theme:e})=>({backgroundColor:e.palette.background.paper,padding:e.spacing(1),boxShadow:"none",position:"relative",zIndex:300})),eI=C(VJ)(({theme:e})=>({display:"flex",alignItems:"center",maxWidth:1280,"&&&":{padding:0}})),tI=C("div")({marginLeft:"auto",display:"flex",alignItems:"center"}),c5e=C("nav")({display:"flex",alignItems:"center",flexGrow:1}),u5e=C(TL)({width:"150px"}),d5e=C(EL)({width:"150px"}),p5e=C("div")(({theme:e})=>({display:"flex",justifyContent:"center",marginLeft:e.spacing(3),"& a":{textDecoration:"none",color:"inherit",marginRight:e.spacing(3),display:"flex",alignItems:"center"}})),f5e=C("button")(({theme:e})=>({...Hi(e),border:"none",background:"transparent",height:"100%",display:"flex",fontSize:e.fontSizes.bodySize,fontFamily:e.typography.fontFamily,alignItems:"center",color:"inherit",cursor:"pointer"})),nI=e=>({color:e.palette.neutral.main}),Sg=C(an)(({theme:e})=>Hi(e)),h5e=C(jt)(({theme:e})=>({...Hi(e),borderRadius:100})),Ew=e=>({...e,path:e.path.replace("/*","")}),m5e=()=>{const{onSetThemeMode:e,themeMode:t}=K6(),n=yn(),r=Cl(),o=Cl(),[i,a]=m.useState(null),[s,c]=m.useState(null),{uiConfig:u,isOss:d,isPro:p,isEnterprise:f}=It(),h=tr(n.breakpoints.down("md")),[g,v]=m.useState(!1),b=()=>v(T=>!T),y=()=>a(null),w=()=>c(null),S=APe(),k=T=>{const{mode:R}=T.menu;return!R||R.includes("pro")&&p()||R.includes("enterprise")&&f()},A={mainNavRoutes:J3(S.mainNavRoutes).concat([{path:"/admin/api",title:"API access",menu:{}}]).filter(tw(u)).map(Ew),mobileRoutes:J3(S.mobileRoutes).concat([{path:"/admin/api",title:"API access",menu:{}}]).filter(tw(u)).map(Ew),adminRoutes:EPe.filter(tw(u)).filter(k).map(Ew)};return h?l(Z3,{position:"static",children:x(eI,{children:[l(xt,{title:"Menu",arrow:!0,children:l(jt,{sx:{color:T=>T.palette.text.primary},onClick:b,"aria-controls":"header-drawer","aria-expanded":g,size:"large",children:l(bL,{})})}),l(xle,{flags:u.flags,links:u.links,open:g,toggleDrawer:b,routes:A}),l(tI,{children:l(RP,{})})]})}):l(Z3,{position:"static",children:x(eI,{children:[l(Sg,{to:"/",sx:Nc,"aria-label":"Home",children:l(Pd,{darkmode:l(u5e,{"aria-label":"Unleash logo"}),lightmode:l(d5e,{"aria-label":"Unleash logo"})})}),x(c5e,{children:[x(p5e,{children:[l(Sg,{to:"/projects",children:"Projects"}),l(Sg,{to:"/features",children:"Feature toggles"}),l(Sg,{to:"/playground",children:"Playground"}),x(f5e,{onClick:T=>c(T.currentTarget),"aria-controls":s?o:void 0,"aria-expanded":!!s,children:["Configure",l(dx,{sx:nI})]}),l(NP,{id:o,options:A.mainNavRoutes,anchorEl:s,handleClose:w,style:{top:10}})]}),x(tI,{children:[l(xt,{title:t==="dark"?"Switch to light theme":"Switch to dark theme",arrow:!0,children:l(jt,{onClick:e,sx:Hi,children:l(q,{condition:t==="dark",show:l(_le,{}),elseShow:l(Ule,{})})})})," ",l(q,{condition:!d()&&!(u!=null&&u.flags.disableNotifications),show:l(l5e,{})}),l(xt,{title:"Documentation",arrow:!0,children:l(jt,{href:"https://docs.getunleash.io/",target:"_blank",rel:"noopener noreferrer",size:"large",disableRipple:!0,sx:Hi,children:l(w2,{})})}),l(xt,{title:"Settings",arrow:!0,children:x(h5e,{onClick:T=>a(T.currentTarget),"aria-controls":i?r:void 0,"aria-expanded":!!i,size:"large",disableRipple:!0,children:[l(wL,{}),l(dx,{sx:nI})]})}),l(NP,{id:r,options:A.adminRoutes,anchorEl:i,handleClose:y,style:{top:5,left:-100}})," ",l(RP,{})]})]})]})})},g5e=e=>{var n;const t=(n=e.versionInfo)==null?void 0:n.current;return t!=null&&t.enterprise?`${e.name} ${t.enterprise}`:t!=null&&t.oss?`${e.name} ${t.oss}`:`${e.name} ${e.version}`},v5e=e=>{var r,o;const t=(r=e.versionInfo)==null?void 0:r.latest,n=(o=e.versionInfo)==null?void 0:o.isLatest;if(t!=null&&t.enterprise&&!n)return`Upgrade available - Latest Enterprise release: ${t.enterprise}`;if(t!=null&&t.oss&&!n)return`Upgrade available - Latest OSS release: ${t.oss}`},qg=C("h2")(({theme:e})=>({all:"unset",display:"block",margin:e.spacing(2,0),fontSize:e.fontSizes.bodySize,fontWeight:e.fontWeight.bold})),y5e=e=>{var i;const t=(i=e.uiConfig.versionInfo)==null?void 0:i.instanceId,n=g5e(e.uiConfig),r=e.uiConfig.environment,o=v5e(e.uiConfig);return x("section",{title:"API details",children:[x(qg,{children:[n," ",l(q,{condition:!!r,show:x("small",{children:["(",r,")"]})})]}),l(q,{condition:!!o,show:x("small",{children:[o,l("br",{})]})}),l("br",{}),l("small",{children:e.uiConfig.slogan}),l("br",{}),l(q,{condition:!!t,show:l("small",{children:`${t}`})})]})},b5e=C("footer")(({theme:e})=>({padding:e.spacing(4,8),width:"100%",flexGrow:1,zIndex:100,backgroundColor:e.palette.background.paper})),Tw=C(ca)({padding:0,margin:0}),ur=C(Na)(({theme:e})=>({padding:0,margin:0,"& a":{...Hi(e),textDecoration:"none",color:e.palette.text.primary,"&:hover":{textDecoration:"underline"}}})),w5e=()=>{const{uiConfig:e}=It();return l(b5e,{children:x(Wn,{container:!0,justifyContent:"center",spacing:10,style:{marginBottom:0},children:[l(Wn,{item:!0,md:4,xs:12,children:l(y5e,{uiConfig:e})}),l(Wn,{item:!0,xs:12,md:"auto",children:x(Wn,{container:!0,spacing:7,direction:"row",children:[l(Wn,{item:!0,children:x("section",{title:"Unleash SDK",children:[l(qg,{children:"Server SDKs"}),x(Tw,{dense:!0,children:[l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/sdks/node",target:"_blank",rel:"noreferrer",children:"Node.js"})})}),l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/sdks/java",target:"_blank",rel:"noreferrer",children:"Java"})})}),l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/sdks/go",target:"_blank",rel:"noreferrer",children:"Go"})})})," ",l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/sdks/rust",target:"_blank",rel:"noreferrer",children:"Rust"})})})," ",l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/sdks/ruby",target:"_blank",rel:"noreferrer",children:"Ruby"})})})," ",l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/sdks/python",target:"_blank",rel:"noreferrer",children:"Python"})})}),l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/sdks/dotnet",target:"_blank",rel:"noreferrer",children:".NET"})})}),l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/sdks/php",target:"_blank",rel:"noreferrer",children:"PHP"})})}),l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/sdks",target:"_blank",rel:"noreferrer",children:"All SDKs"})})})]})]})}),l(Wn,{item:!0,children:x("section",{title:"Unleash SDK",children:[l(qg,{children:"Frontend SDKs"}),x(Tw,{dense:!0,children:[l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/unleash-proxy",target:"_blank",rel:"noreferrer",children:"Unleash Proxy"})})}),l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/sdks/javascript-browser",target:"_blank",rel:"noreferrer",children:"JavaScript"})})}),l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/sdks/react",target:"_blank",rel:"noreferrer",children:"React"})})}),l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/sdks/next-js",target:"_blank",rel:"noreferrer",children:"Next.js"})})}),l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/sdks/vue",target:"_blank",rel:"noreferrer",children:"Vue"})})}),l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/sdks/ios-proxy",target:"_blank",rel:"noreferrer",children:"iOS"})})}),l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/sdks/android-proxy",target:"_blank",rel:"noreferrer",children:"Android"})})}),l(ur,{children:l(rn,{primary:l("a",{href:"https://docs.getunleash.io/reference/sdks/flutter",target:"_blank",rel:"noreferrer",children:"Flutter"})})})]})]})}),l(Wn,{item:!0,children:x("section",{children:[l(qg,{children:"About"}),x(Tw,{dense:!0,children:[l(ur,{children:l(rn,{primary:l("a",{href:"https://www.getunleash.io/",target:"_blank",rel:"noreferrer",children:"getunleash.io"})})}),l(ur,{children:l(rn,{primary:l("a",{href:"https://twitter.com/getunleash",target:"_blank",rel:"noreferrer",children:"Twitter"})})}),l(ur,{children:l(rn,{primary:l("a",{href:"https://www.linkedin.com/company/getunleash",target:"_blank",rel:"noreferrer",children:"LinkedIn"})})}),l(ur,{children:l(rn,{primary:l("a",{href:"https://github.com/Unleash/unleash",target:"_blank",rel:"noreferrer",children:"GitHub"})})}),l(ur,{children:l(rn,{primary:l("a",{href:"https://slack.unleash.run",target:"_blank",rel:"noreferrer",children:"Slack Community"})})})]})]})})]})})]})})},S5e=C(Vt)(({theme:e})=>({marginBottom:e.spacing(2)})),x5e=C(se)(({theme:e})=>({maxWidth:"800px"})),C5e=C("a")(({theme:e})=>({display:"block",marginTop:e.spacing(1),width:"100px"})),E5e=e=>!(!e||localStorage&&localStorage.getItem(e)),T5e=({toast:e})=>{const[t,n]=m.useState(!1);m.useEffect(()=>{n(E5e((e==null?void 0:e.id)||""))},[e==null?void 0:e.id]);const r=()=>{localStorage&&localStorage.setItem((e==null?void 0:e.id)||"","seen"),n(!1)};return e?l(q,{condition:t,show:x(S5e,{severity:e.severity,onClose:r,children:[l(x5e,{variant:"body2",children:e.message}),l(C5e,{href:e.link,target:"_blank",rel:"noopener noreferrer",children:"View more"})]})}):null},k5e=C("div")(({theme:e})=>({height:e.spacing(2.5),margin:e.spacing(2,0)})),A5e=C(YX)({"& > ol":{flexWrap:"nowrap","& > li:last-child":{minWidth:0}}}),rI=C("p")(V6),R5e=C(an)(({theme:e})=>({"& > *":{maxWidth:e.spacing(25)}})),_5e=()=>{const{isAdmin:e}=m.useContext(_o),t=Ro(),n=t.pathname.split("/").filter(r=>r).filter(r=>r!=="create"&&r!=="edit"&&r!=="view"&&r!=="variants"&&r!=="logs"&&r!=="metrics"&&r!=="copy"&&r!=="features"&&r!=="features2"&&r!=="create-toggle"&&r!=="settings"&&r!=="profile");return l(k5e,{children:l(q,{condition:t.pathname.includes("admin")&&e||!t.pathname.includes("admin"),show:l(q,{condition:n.length>1,show:l(A5e,{"aria-label":"Breadcrumbs",children:n.map((r,o)=>{if(o===n.length-1)return l(rI,{children:r},r);let a="/";return n.forEach((s,c)=>{c!==o&&c<o?a+=s+"/":c===o&&(a+=s)}),l(R5e,{to:a,children:l(rI,{children:r})},r)})})})})})},oI="/static/texture-c29e66c0.png",rB="skip-nav-target-id",P5e=()=>l("div",{id:rB}),I5e=C("a")(({theme:e})=>({position:"fixed",overflow:"hidden",zIndex:1e3,top:e.spacing(2.25),left:e.spacing(2.25),padding:e.spacing(1,2),whiteSpace:"nowrap",textDecoration:"none",background:e.palette.background.alternative,color:e.palette.common.white,borderRadius:e.shape.borderRadius,fontSize:e.fontSizes.smallBody,...Hi(e),[e.breakpoints.down(960)]:{top:"0.8rem",left:"0.8rem"},"&:not(:focus):not(:active)":{clip:"rect(0 0 0 0)",clipPath:"inset(50%)",zIndex:-1,width:1,height:1,margin:-1,padding:0}})),O5e=()=>x(I5e,{href:`#${rB}`,children:["Skip to content ",l("span",{"aria-hidden":!0,children:"↓"})]}),$5e=({featureName:e,projectId:t,conflict:n,onNavigate:r,children:o})=>x(f6,{elevation:0,sx:i=>({marginTop:i.spacing(2),overflow:"hidden"}),children:[x($e,{sx:i=>({backgroundColor:i.palette.neutral.light,borderRadius:a=>`${a.shape.borderRadiusLarge}px ${a.shape.borderRadiusLarge}px 0 0`,border:"1px solid",borderColor:a=>n?a.palette.warning.border:a.palette.divider,borderBottom:"none",overflow:"hidden"}),children:[l(q,{condition:!!n,show:x(Vt,{severity:"warning",sx:{px:3,mb:2,"&.MuiAlert-standardWarning":{borderStyle:"none"}},children:[l("strong",{children:"Conflict!"})," ",n,"."]})}),x($e,{sx:{display:"flex",pt:n?0:2,pb:2,px:3},children:[l(se,{children:"Feature toggle name: "}),l(Gr,{component:an,to:`/projects/${t}/features/${e}`,color:"primary",underline:"hover",sx:{marginLeft:1,"& :hover":{textDecoration:"underline"}},onClick:r,children:l("strong",{children:e})})]})]}),l($e,{children:o})]});var nk={},N5e=An;Object.defineProperty(nk,"__esModule",{value:!0});var oB=nk.default=void 0,L5e=N5e(Rn()),D5e=_n,M5e=(0,L5e.default)((0,D5e.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12zm8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8z"}),"Block");oB=nk.default=M5e;var rk={},B5e=An;Object.defineProperty(rk,"__esModule",{value:!0});var iB=rk.default=void 0,F5e=B5e(Rn()),z5e=_n,j5e=(0,F5e.default)((0,z5e.jsx)("path",{d:"m19.07 4.93-1.41 1.41C19.1 7.79 20 9.79 20 12c0 4.42-3.58 8-8 8s-8-3.58-8-8c0-4.08 3.05-7.44 7-7.93v2.02C8.16 6.57 6 9.03 6 12c0 3.31 2.69 6 6 6s6-2.69 6-6c0-1.66-.67-3.16-1.76-4.24l-1.41 1.41C15.55 9.9 16 10.9 16 12c0 2.21-1.79 4-4 4s-4-1.79-4-4c0-1.86 1.28-3.41 3-3.86v2.14c-.6.35-1 .98-1 1.72 0 1.1.9 2 2 2s2-.9 2-2c0-.74-.4-1.38-1-1.72V2h-1C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10c0-2.76-1.12-5.26-2.93-7.07z"}),"TrackChanges");iB=rk.default=j5e;var U5e=200,ok="__lodash_hash_undefined__",W5e=1/0,aB=9007199254740991,H5e="[object Arguments]",V5e="[object Function]",G5e="[object GeneratorFunction]",q5e="[object Symbol]",Y5e=/[\\^$.*+?()[\]{}|]/g,K5e=/^\[object .+?Constructor\]$/,X5e=/^(?:0|[1-9]\d*)$/,J5e=typeof ki=="object"&&ki&&ki.Object===Object&&ki,Q5e=typeof self=="object"&&self&&self.Object===Object&&self,ik=J5e||Q5e||Function("return this")();function Z5e(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function e3e(e,t){var n=e?e.length:0;return!!n&&r3e(e,t,0)>-1}function t3e(e,t,n){for(var r=-1,o=e?e.length:0;++r<o;)if(n(t,e[r]))return!0;return!1}function sB(e,t){for(var n=-1,r=e?e.length:0,o=Array(r);++n<r;)o[n]=t(e[n],n,e);return o}function ak(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}function n3e(e,t,n,r){for(var o=e.length,i=n+(r?1:-1);r?i--:++i<o;)if(t(e[i],i,e))return i;return-1}function r3e(e,t,n){if(t!==t)return n3e(e,o3e,n);for(var r=n-1,o=e.length;++r<o;)if(e[r]===t)return r;return-1}function o3e(e){return e!==e}function i3e(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function a3e(e){return function(t){return e(t)}}function s3e(e,t){return e.has(t)}function l3e(e,t){return e==null?void 0:e[t]}function c3e(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function lB(e,t){return function(n){return e(t(n))}}var u3e=Array.prototype,d3e=Function.prototype,o0=Object.prototype,kw=ik["__core-js_shared__"],iI=function(){var e=/[^.]+$/.exec(kw&&kw.keys&&kw.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),cB=d3e.toString,Ud=o0.hasOwnProperty,sk=o0.toString,p3e=RegExp("^"+cB.call(Ud).replace(Y5e,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),aI=ik.Symbol,f3e=lB(Object.getPrototypeOf,Object),h3e=o0.propertyIsEnumerable,m3e=u3e.splice,sI=aI?aI.isConcatSpreadable:void 0,Bx=Object.getOwnPropertySymbols,lI=Math.max,g3e=dB(ik,"Map"),wh=dB(Object,"create");function Tc(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function v3e(){this.__data__=wh?wh(null):{}}function y3e(e){return this.has(e)&&delete this.__data__[e]}function b3e(e){var t=this.__data__;if(wh){var n=t[e];return n===ok?void 0:n}return Ud.call(t,e)?t[e]:void 0}function w3e(e){var t=this.__data__;return wh?t[e]!==void 0:Ud.call(t,e)}function S3e(e,t){var n=this.__data__;return n[e]=wh&&t===void 0?ok:t,this}Tc.prototype.clear=v3e;Tc.prototype.delete=y3e;Tc.prototype.get=b3e;Tc.prototype.has=w3e;Tc.prototype.set=S3e;function Wd(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function x3e(){this.__data__=[]}function C3e(e){var t=this.__data__,n=i0(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():m3e.call(t,n,1),!0}function E3e(e){var t=this.__data__,n=i0(t,e);return n<0?void 0:t[n][1]}function T3e(e){return i0(this.__data__,e)>-1}function k3e(e,t){var n=this.__data__,r=i0(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}Wd.prototype.clear=x3e;Wd.prototype.delete=C3e;Wd.prototype.get=E3e;Wd.prototype.has=T3e;Wd.prototype.set=k3e;function Hd(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function A3e(){this.__data__={hash:new Tc,map:new(g3e||Wd),string:new Tc}}function R3e(e){return a0(this,e).delete(e)}function _3e(e){return a0(this,e).get(e)}function P3e(e){return a0(this,e).has(e)}function I3e(e,t){return a0(this,e).set(e,t),this}Hd.prototype.clear=A3e;Hd.prototype.delete=R3e;Hd.prototype.get=_3e;Hd.prototype.has=P3e;Hd.prototype.set=I3e;function Qv(e){var t=-1,n=e?e.length:0;for(this.__data__=new Hd;++t<n;)this.add(e[t])}function O3e(e){return this.__data__.set(e,ok),this}function $3e(e){return this.__data__.has(e)}Qv.prototype.add=Qv.prototype.push=O3e;Qv.prototype.has=$3e;function N3e(e,t){var n=lk(e)||pB(e)?i3e(e.length,String):[],r=n.length,o=!!r;for(var i in e)(t||Ud.call(e,i))&&!(o&&(i=="length"||G3e(i,r)))&&n.push(i);return n}function i0(e,t){for(var n=e.length;n--;)if(Z3e(e[n][0],t))return n;return-1}function L3e(e,t,n,r){var o=-1,i=e3e,a=!0,s=e.length,c=[],u=t.length;if(!s)return c;n&&(t=sB(t,a3e(n))),r?(i=t3e,a=!1):t.length>=U5e&&(i=s3e,a=!1,t=new Qv(t));e:for(;++o<s;){var d=e[o],p=n?n(d):d;if(d=r||d!==0?d:0,a&&p===p){for(var f=u;f--;)if(t[f]===p)continue e;c.push(d)}else i(t,p,r)||c.push(d)}return c}function uB(e,t,n,r,o){var i=-1,a=e.length;for(n||(n=V3e),o||(o=[]);++i<a;){var s=e[i];t>0&&n(s)?t>1?uB(s,t-1,n,r,o):ak(o,s):r||(o[o.length]=s)}return o}function D3e(e,t,n){var r=t(e);return lk(e)?r:ak(r,n(e))}function M3e(e){if(!ck(e)||Y3e(e))return!1;var t=hB(e)||c3e(e)?p3e:K5e;return t.test(Q3e(e))}function B3e(e){if(!ck(e))return X3e(e);var t=K3e(e),n=[];for(var r in e)r=="constructor"&&(t||!Ud.call(e,r))||n.push(r);return n}function F3e(e,t){return e=Object(e),z3e(e,t,function(n,r){return r in e})}function z3e(e,t,n){for(var r=-1,o=t.length,i={};++r<o;){var a=t[r],s=e[a];n(s,a)&&(i[a]=s)}return i}function j3e(e,t){return t=lI(t===void 0?e.length-1:t,0),function(){for(var n=arguments,r=-1,o=lI(n.length-t,0),i=Array(o);++r<o;)i[r]=n[t+r];r=-1;for(var a=Array(t+1);++r<t;)a[r]=n[r];return a[t]=i,Z5e(e,this,a)}}function U3e(e){return D3e(e,rIe,H3e)}function a0(e,t){var n=e.__data__;return q3e(t)?n[typeof t=="string"?"string":"hash"]:n.map}function dB(e,t){var n=l3e(e,t);return M3e(n)?n:void 0}var W3e=Bx?lB(Bx,Object):gB,H3e=Bx?function(e){for(var t=[];e;)ak(t,W3e(e)),e=f3e(e);return t}:gB;function V3e(e){return lk(e)||pB(e)||!!(sI&&e&&e[sI])}function G3e(e,t){return t=t??aB,!!t&&(typeof e=="number"||X5e.test(e))&&e>-1&&e%1==0&&e<t}function q3e(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Y3e(e){return!!iI&&iI in e}function K3e(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||o0;return e===n}function X3e(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}function J3e(e){if(typeof e=="string"||nIe(e))return e;var t=e+"";return t=="0"&&1/e==-W5e?"-0":t}function Q3e(e){if(e!=null){try{return cB.call(e)}catch{}try{return e+""}catch{}}return""}function Z3e(e,t){return e===t||e!==e&&t!==t}function pB(e){return eIe(e)&&Ud.call(e,"callee")&&(!h3e.call(e,"callee")||sk.call(e)==H5e)}var lk=Array.isArray;function fB(e){return e!=null&&tIe(e.length)&&!hB(e)}function eIe(e){return mB(e)&&fB(e)}function hB(e){var t=ck(e)?sk.call(e):"";return t==V5e||t==G5e}function tIe(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=aB}function ck(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function mB(e){return!!e&&typeof e=="object"}function nIe(e){return typeof e=="symbol"||mB(e)&&sk.call(e)==q5e}function rIe(e){return fB(e)?N3e(e,!0):B3e(e)}var oIe=j3e(function(e,t){return e==null?{}:(t=sB(uB(t,1),J3e),F3e(e,L3e(U3e(e),t)))});function gB(){return[]}var iIe=oIe;const aIe=Yr(iIe),sIe=C("div")(({theme:e})=>({overflowX:"auto","& code":{wordWrap:"break-word",whiteSpace:"pre-wrap",fontFamily:"monospace",lineHeight:1.5,fontSize:e.fontSizes.smallBody}})),Aw=({change:e,currentStrategy:t})=>{const n=e.action==="deleteStrategy"?void 0:e.payload;return l(sIe,{children:l(t0,{entry:{preData:aIe(t,"sortOrder"),data:n}})})},lIe=({change:e,previousTitle:t})=>x(ve,{children:[l(q,{condition:!!(t&&t!==e.payload.title),show:x(Fx,{children:[l(se,{component:"span",color:"text.secondary",children:t||ks(e.payload.name)})," "]})}),l(Fx,{children:l(se,{component:"span",children:e.payload.title})})]}),cIe=C("div")(({theme:e})=>({display:"grid",gridAutoFlow:"column",gridTemplateColumns:"auto 1fr",gap:e.spacing(1),alignItems:"center"})),Fx=C("div")(()=>({...V6,maxWidth:500})),Rw=({change:e,previousTitle:t,children:n})=>x(cIe,{children:[l(jhe,{strategyName:e.payload.name}),x(Fx,{children:[l(Kh,{tooltip:n,tooltipProps:{maxWidth:500,maxHeight:600},children:l(se,{component:"span",children:ks(e.payload.name)})}),l(lIe,{change:e,previousTitle:t})]})]}),cI=({percentage:e,size:t="4rem"})=>{const n=yn(),r={display:"block",borderRadius:"100%",transform:"rotate(-90deg)",height:t,width:t,background:n.palette.background.elevation2},o=100/(2*Math.PI),i=2*o;return l("svg",{viewBox:`0 0 ${i} ${i}`,style:r,"aria-hidden":!0,children:l("circle",{r:o,cx:o,cy:o,fill:"none",stroke:n.palette.primary.light,strokeWidth:i,strokeDasharray:`${e} 100`})})},uIe=C("div")(({theme:e})=>({width:"100%",padding:e.spacing(2,3),borderRadius:e.shape.borderRadiusMedium,border:`1px solid ${e.palette.divider}`})),dIe=C("p")(({theme:e})=>({display:"inline",margin:e.spacing(.5,0),maxWidth:"95%",textAlign:"center",wordBreak:"break-word"})),pIe=C(Os)(({theme:e})=>({margin:e.spacing(.5)})),_w=({value:e,text:t})=>l(uIe,{children:l(q,{condition:e.length===0,show:x("p",{children:["No ",t,"s added yet."]}),elseShow:x("div",{children:[x(dIe,{children:[e.length," ",e.length>1?`${t}s`:t," will get access."]}),e.map(n=>l(pIe,{label:l(Ra,{maxWidth:"300",text:n,maxLength:50})},n))]})})}),fIe=({segments:e})=>!e||e.length===0?null:l(ve,{children:e.map((t,n)=>x(m.Fragment,{children:[l(q,{condition:n>0,show:l(NT,{text:"AND"})}),l(oM,{segment:t})]},t.id))}),uI=()=>l($e,{sx:{px:3,color:"text.disabled"},children:"This strategy does not have constraints or parameters."}),Ul=C($e)(({theme:e})=>({padding:e.spacing(2,3),border:`1px solid ${e.palette.divider}`,borderRadius:e.shape.borderRadiusMedium})),Pw=C("span")(({theme:e})=>({color:e.palette.neutral.main})),dI=({strategy:e})=>{const{parameters:t,constraints:n=[]}=e,{strategies:r}=Ld(),{uiConfig:o}=It(),{segments:i}=$l(),a=i==null?void 0:i.filter(p=>{var f;return(f=e.segments)==null?void 0:f.includes(p.id)}),s=r.find(p=>p.name===e.name),c=m.useMemo(()=>!t||s!=null&&s.editable?null:Object.keys(t).map(p=>{switch(p){case"rollout":case"Rollout":const f=Cf(t[p]);return x(Ul,{sx:{display:"flex",alignItems:"center"},children:[l($e,{sx:{mr:2},children:l(cI,{percentage:f,size:"2rem"})}),x("div",{children:[x(qt,{color:"success",children:[f,"%"]})," of your base"," ",n.length>0?"who match constraints":""," ","is included."]})]});case"userIds":case"UserIds":const h=tl(t[p]);return l(_w,{value:h,text:"user"},p);case"hostNames":case"HostNames":const g=tl(t[p]);return l(_w,{value:g,text:"host"},p);case"IPs":const v=tl(t[p]);return l(_w,{value:v,text:"IP"},p);case"stickiness":case"groupId":return null;default:return null}}),[t,s,n]),u=m.useMemo(()=>{if(!t||!(s!=null&&s.editable))return null;const p=l(Pw,{children:" is set to "});return s==null?void 0:s.parameters.map(f=>{const{type:h,name:g}={...f};if(!h||!g||t[g]===void 0)return null;const v=l(Ra,{maxLength:15,maxWidth:"150",text:g});switch(f==null?void 0:f.type){case"list":const b=tl(t[g]);return b.length>0?x(Ul,{children:[v," ",x(Pw,{children:["has ",b.length," ",b.length>1?"items":"item",":"," ",b.map(k=>l(Os,{label:l(Ra,{maxWidth:"300",text:k,maxLength:50}),sx:{mr:.5}},k))]})]}):null;case"percentage":const y=Cf(t[g]);return t[g]!==""?x(Ul,{sx:{display:"flex",alignItems:"center"},children:[l($e,{sx:{mr:2},children:l(cI,{percentage:y,size:"2rem"})}),x("div",{children:[v,p,x(qt,{color:"success",children:[y,"%"]})]})]}):null;case"boolean":return t[g]==="true"||t[g]==="false"?x(Ul,{children:[l(Ra,{maxLength:15,maxWidth:"150",text:g}),p,l(qt,{color:t[g]==="true"?"success":"error",children:t[g]})]}):null;case"string":const w=pl(t[g]);return typeof t[g]<"u"?x(Ul,{children:[v,l(q,{condition:w==="",show:l(Pw,{children:" is an empty string"}),elseShow:x(ve,{children:[p,l(Ra,{maxWidth:"300",text:w,maxLength:50})]})})]}):null;case"number":const S=Cf(t[g]);return t[g]!==""&&S!==void 0?x(Ul,{children:[v,p,l(Ra,{maxWidth:"300",text:String(S),maxLength:50})]}):null;case"default":return null}return null})},[t,s]);if(!t)return l(uI,{});const d=[!!o.flags.SE&&a&&a.length>0&&l(fIe,{segments:a}),n.length>0&&l(Z1,{constraints:n,showLabel:!1}),e.name==="default"&&l(ve,{children:x(Ul,{sx:{width:"100%"},children:["The standard strategy is ",l(qt,{color:"success",children:"ON"})," ","for all users."]})}),...c??[],...u??[]].filter(Boolean);return l(q,{condition:d.length>0,show:l(ve,{children:d.map((p,f)=>x(m.Fragment,{children:[l(q,{condition:f>0,show:l(NT,{text:"AND"})}),p]},f))}),elseShow:l(uI,{})})},hIe=(e,t,n,r)=>{var a,s;return(s=(a=Rs(t,n).feature)==null?void 0:a.environments.find(c=>c.name===r))==null?void 0:s.strategies.find(c=>"id"in e.payload&&c.id===e.payload.id)},vB=C($e)({display:"flex",justifyContent:"space-between",alignItems:"center"}),pI=C($e)(({theme:e})=>({display:"grid",gridTemplateColumns:"auto 40px",gap:e.spacing(1),alignItems:"center",marginBottom:e.spacing(2),width:"100%"})),Iw=C($e)(({theme:e})=>({display:"grid",gridTemplateColumns:"150px auto",gridAutoFlow:"column",alignItems:"center",flexGrow:1,gap:e.spacing(1)})),mIe=e=>typeof e=="object"&&e!==null&&"name"in e,fI=({show:e=!0,disabled:t})=>e?t?l(xt,{title:"This strategy will not be taken into account when evaluating feature toggle.",arrow:!0,sx:{cursor:"pointer"},children:l(qt,{color:"disabled",icon:l(oB,{}),children:"Disabled"})}):l(xt,{title:"This was disabled before and with this change it will be taken into account when evaluating feature toggle.",arrow:!0,sx:{cursor:"pointer"},children:l(qt,{color:"success",icon:l(iB,{}),children:"Enabled"})}):null,gIe=({wasDisabled:e=!1,willBeDisabled:t=!1})=>e&&t?l(se,{color:"action.disabled",children:"Editing strategy:"}):!e&&t?l(se,{color:"error.dark",children:"Editing strategy:"}):e&&!t?l(se,{color:"success.dark",children:"Editing strategy:"}):l(se,{children:"Editing strategy:"}),vIe=({discard:e,change:t,featureName:n,environmentName:r,projectId:o})=>{var a,s,c,u,d;const i=hIe(t,o,n,r);return x(ve,{children:[t.action==="addStrategy"&&x(ve,{children:[x(pI,{children:[x(Iw,{children:[l(se,{color:(a=t.payload)!=null&&a.disabled?"action.disabled":"success.dark",children:"+ Adding strategy:"}),l(Rw,{change:t,children:l(Aw,{change:t,currentStrategy:i})}),l("div",{children:l(fI,{disabled:!0,show:((s=t.payload)==null?void 0:s.disabled)===!0})})]}),l("div",{children:e})]}),l(dI,{strategy:t.payload})]}),t.action==="deleteStrategy"&&x(vB,{children:[x(Iw,{children:[l(se,{sx:p=>({color:p.palette.error.main}),children:"- Deleting strategy:"}),mIe(t.payload)&&l(Rw,{change:t,children:l(Aw,{change:t,currentStrategy:i})})]}),l("div",{children:e})]}),t.action==="updateStrategy"&&x(ve,{children:[x(pI,{children:[x(Iw,{children:[l(gIe,{wasDisabled:i==null?void 0:i.disabled,willBeDisabled:(c=t.payload)==null?void 0:c.disabled}),l(Rw,{change:t,previousTitle:i==null?void 0:i.title,children:l(Aw,{change:t,currentStrategy:i})})]}),l("div",{children:e})]}),l(q,{condition:((u=t.payload)==null?void 0:u.disabled)!==(i==null?void 0:i.disabled),show:x(se,{sx:{marginTop:p=>p.spacing(2),marginBottom:p=>p.spacing(2),...Nc,gap:p=>p.spacing(1)},children:["This strategy will be"," ",l(fI,{disabled:((d=t.payload)==null?void 0:d.disabled)||!1})]})}),l(dI,{strategy:t.payload})]})]})},yIe=({enabled:e,discard:t})=>x(vB,{children:[x($e,{sx:{display:"flex",alignItems:"center"},children:["New status:"," ",l(qt,{sx:n=>({marginLeft:n.spacing(1)}),color:e?"success":"error",children:e?" Enabled":"Disabled"})]}),t]}),bIe=C(se)(({theme:e})=>({fontSize:e.fontSizes.smallerBody,whiteSpace:"pre-wrap"})),wIe=({value:e})=>{const{searchQuery:t}=Ol();return e?e.type==="string"&&e.value.length<20?l(Hn,{children:l(Ya,{search:t,children:e.value})}):l(Hn,{children:l(Kh,{tooltip:l(ve,{children:l(bIe,{children:l(Ya,{search:t,children:e.value})})}),highlighted:t.length>0&&e.value.toLowerCase().includes(t.toLowerCase()),children:e.type})}):l(Hn,{})},SIe=C(se)(({theme:e})=>({fontSize:e.fontSizes.smallerBody})),xIe=({value:e})=>{const{searchQuery:t}=Ol();if(!e||e.length===0)return l(Hn,{});const n=r=>`${r.contextName}:${r.values.join()}`;return l(Hn,{children:l(Kh,{tooltip:l(ve,{children:e.map((r,o)=>l(SIe,{children:l(Ya,{search:t,children:n(r)})},r.contextName+o))}),highlighted:t.length>0&&(e==null?void 0:e.map(n).join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cC as u,cF as g,cE as i}from"./index-
|
|
1
|
+
import{cC as u,cF as g,cE as i}from"./index-1c4c68c3.js";function f(n,o){u(2,arguments);var e=g(n),a=i(o);if(isNaN(a))return new Date(NaN);if(!a)return e;var r=e.getDate(),t=new Date(e.getTime());t.setMonth(e.getMonth()+a+1,0);var s=t.getDate();return r>=s?t:(e.setFullYear(t.getFullYear(),t.getMonth(),r),e)}export{f as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cC as n,cF as s,cE as o}from"./index-
|
|
1
|
+
import{cC as n,cF as s,cE as o}from"./index-1c4c68c3.js";function i(e,r){n(2,arguments);var a=s(e),t=o(r);return isNaN(t)?new Date(NaN):(t&&a.setDate(a.getDate()+t),a)}export{i as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as c,_ as r}from"./NetworkOverview-
|
|
1
|
+
import{C as c,_ as r}from"./NetworkOverview-cd06e59f.js";const e=n=>{const{r:t,g:o,b:a}=c.parse(n),s=.2126*r.channel.toLinear(t)+.7152*r.channel.toLinear(o)+.0722*r.channel.toLinear(a);return r.lang.round(s)},i=e,l=n=>i(n)>=.5,u=l,h=n=>!u(n),L=h;export{L as i};
|