import{h as e,bQ as t,aw as n}from"./c6eedc03a-CsEFTfjy.js";import{u as r}from"./vendor-query-BwvgHhJ1.js";import{r as i}from"./vendor-react-Dp9pL_Wn.js";import{b0 as s,b2 as o,b1 as a}from"./index-DhMXk6CR.js";const c="role_assignments",l="account_bindings",u=e=>e.assignments??[];async function d(e,t,n,r){const i=[];let s;do{if(r?.current)return null;const o=new URLSearchParams;o.set("page_size",String(100)),s&&o.set("page_token",s);const a=await e(`/api/organizations/${t}/roles/${n}/assignments?${o.toString()}`,{});if(!a.ok||r?.current)return null;const c=await a.json();i.push(...c.assignments??[]),s=c.next_page_token||void 0}while(s);return i}const p=(t,n)=>{const{activeOrganization:r}=e(),i=r?.uuid;return s(`/api/organizations/${i}/roles/${t}/assignments?page_size=100`,{queryKey:[c,"by_role",i,t],enabled:!!i&&!!t&&(n?.enabled??!0),items:u})},m=(n,r)=>{const{activeOrganization:s}=e(),o=s?.uuid,a=t("Query error"),c=!!o&&(r?.enabled??!0),[l,u]=i.useState(null),[d,p]=i.useState(0),m=i.useRef(new Set),g=i.useRef(new Set),b=i.useRef(0),f=i.useRef(0),k=i.useCallback(async e=>{const t=[];for(let i=0;i<e.length;i+=100)t.push(e.slice(i,i+100));const n=await Promise.all(t.map(async e=>await a(`/api/organizations/${o}/rbac/account-bindings:query`,{method:"POST",body:JSON.stringify({account_uuids:e})})));if(1===n.length)return n[0];const r={bindings:[],groups:{},roles:{}};for(const i of n)r.bindings.push(...i.bindings),Object.assign(r.groups,i.groups),Object.assign(r.roles,i.roles);return r},[a,o]),y=i.useRef(void 0);i.useEffect(()=>{const e=n[0];void 0!==y.current&&y.current!==e&&(f.current++,b.current=0,m.current=new Set,g.current=new Set,p(0),u(null)),y.current=e},[n]),i.useEffect(()=>{if(!c)return;const e=n.slice(b.current);if(0===e.length)return;b.current=n.length;const t=f.current;for(const n of e){const e=n.filter(e=>!m.current.has(e));if(0===e.length)continue;const r=()=>{for(const t of e)m.current.add(t);p(m.current.size)},i=e=>{t===f.current&&(r(),u(t=>t?{bindings:[...t.bindings,...e.bindings],groups:{...t.groups,...e.groups},roles:{...t.roles,...e.roles}}:e))},s=()=>{if(t===f.current){for(const t of e)g.current.add(t);r()}};k(e).then(i).catch(s)}},[c,n,k]);const h=i.useCallback(e=>d>0&&m.current.has(e),[d]),x=i.useCallback(e=>d>0&&g.current.has(e),[d]);return{bindingsData:l,bindingsLoadedCount:d,hasMemberBindings:h,isBindingsFailed:x}},g=(t,n)=>{const{activeOrganization:r}=e(),i=r?.uuid;return s(`/api/organizations/${i}/role-assignments?principal_id=${t}&page_size=100`,{queryKey:[c,"by_principal",i,t],enabled:!!i&&!!t&&(n?.enabled??!0),items:u})},b=(t={})=>{const{activeOrganization:i}=e(),s=i?.uuid,a=r();return n(e=>`/api/organizations/${s}/roles/${e.roleUuid}/assignments`,"POST",{enabled:!!s,transformVariables:e=>({principal_type:e.principal_type,principal_id:e.principal_id}),...t,onSuccess(e,n,r){const i=o("assignments",e);a.setQueryData([c,"by_role",s,n.roleUuid],i),a.setQueryData([c,"by_principal",s,n.principal_id],i),t.onSuccess?.(e,n,r)}})},f=(t={})=>{const{activeOrganization:i}=e(),s=i?.uuid,o=r();return n(e=>`/api/organizations/${s}/roles/${e.roleUuid}/assignments/${e.principalId}?principal_type=${e.principalType}`,"DELETE",{enabled:!!s,...t,onSuccess(e,n,r){const i=e=>a("assignments",e);o.setQueryData([c,"by_role",s,n.roleUuid],i(e=>e.principal_id===n.principalId)),o.setQueryData([c,"by_principal",s,n.principalId],i(e=>e.role_uuid===n.roleUuid)),t.onSuccess?.(e,n,r)}})};
/*!-----------------------------------------------------------------------------
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
 * Released under the MIT license
 * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
 *-----------------------------------------------------------------------------*/
var k={wordPattern:/(#?-?\d*\.\d\w*%?)|([@#!.:]?[\w-?]+%?)|[@#!.]/g,comments:{blockComment:["/*","*/"],lineComment:"//"},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}",notIn:["string","comment"]},{open:"[",close:"]",notIn:["string","comment"]},{open:"(",close:")",notIn:["string","comment"]},{open:'"',close:'"',notIn:["string","comment"]},{open:"'",close:"'",notIn:["string","comment"]}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],folding:{markers:{start:new RegExp("^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\/"),end:new RegExp("^\\s*\\/\\*\\s*#endregion\\b.*\\*\\/")}}};const y=Object.freeze(Object.defineProperty({__proto__:null,conf:k,language:{defaultToken:"",tokenPostfix:".less",identifier:"-?-?([a-zA-Z]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))([\\w\\-]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))*",identifierPlus:"-?-?([a-zA-Z:.]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))([\\w\\-:.]|(\\\\(([0-9a-fA-F]{1,6}\\s?)|[^[0-9a-fA-F])))*",brackets:[{open:"{",close:"}",token:"delimiter.curly"},{open:"[",close:"]",token:"delimiter.bracket"},{open:"(",close:")",token:"delimiter.parenthesis"},{open:"<",close:">",token:"delimiter.angle"}],tokenizer:{root:[{include:"@nestedJSBegin"},["[ \\t\\r\\n]+",""],{include:"@comments"},{include:"@keyword"},{include:"@strings"},{include:"@numbers"},["[*_]?[a-zA-Z\\-\\s]+(?=:.*(;|(\\\\$)))","attribute.name","@attribute"],["url(\\-prefix)?\\(",{token:"tag",next:"@urldeclaration"}],["[{}()\\[\\]]","@brackets"],["[,:;]","delimiter"],["#@identifierPlus","tag.id"],["&","tag"],["\\.@identifierPlus(?=\\()","tag.class","@attribute"],["\\.@identifierPlus","tag.class"],["@identifierPlus","tag"],{include:"@operators"},["@(@identifier(?=[:,\\)]))","variable","@attribute"],["@(@identifier)","variable"],["@","key","@atRules"]],nestedJSBegin:[["``","delimiter.backtick"],["`",{token:"delimiter.backtick",next:"@nestedJSEnd",nextEmbedded:"text/javascript"}]],nestedJSEnd:[["`",{token:"delimiter.backtick",next:"@pop",nextEmbedded:"@pop"}]],operators:[["[<>=\\+\\-\\*\\/\\^\\|\\~]","operator"]],keyword:[["(@[\\s]*import|![\\s]*important|true|false|when|iscolor|isnumber|isstring|iskeyword|isurl|ispixel|ispercentage|isem|hue|saturation|lightness|alpha|lighten|darken|saturate|desaturate|fadein|fadeout|fade|spin|mix|round|ceil|floor|percentage)\\b","keyword"]],urldeclaration:[{include:"@strings"},["[^)\r\n]+","string"],["\\)",{token:"tag",next:"@pop"}]],attribute:[{include:"@nestedJSBegin"},{include:"@comments"},{include:"@strings"},{include:"@numbers"},{include:"@keyword"},["[a-zA-Z\\-]+(?=\\()","attribute.value","@attribute"],[">","operator","@pop"],["@identifier","attribute.value"],{include:"@operators"},["@(@identifier)","variable"],["[)\\}]","@brackets","@pop"],["[{}()\\[\\]>]","@brackets"],["[;]","delimiter","@pop"],["[,=:]","delimiter"],["\\s",""],[".","attribute.value"]],comments:[["\\/\\*","comment","@comment"],["\\/\\/+.*","comment"]],comment:[["\\*\\/","comment","@pop"],[".","comment"]],numbers:[["(\\d*\\.)?\\d+([eE][\\-+]?\\d+)?",{token:"attribute.value.number",next:"@units"}],["#[0-9a-fA-F_]+(?!\\w)","attribute.value.hex"]],units:[["(em|ex|ch|rem|fr|vmin|vmax|vw|vh|vm|cm|mm|in|px|pt|pc|deg|grad|rad|turn|s|ms|Hz|kHz|%)?","attribute.value.unit","@pop"]],strings:[['~?"',{token:"string.delimiter",next:"@stringsEndDoubleQuote"}],["~?'",{token:"string.delimiter",next:"@stringsEndQuote"}]],stringsEndDoubleQuote:[['\\\\"',"string"],['"',{token:"string.delimiter",next:"@popall"}],[".","string"]],stringsEndQuote:[["\\\\'","string"],["'",{token:"string.delimiter",next:"@popall"}],[".","string"]],atRules:[{include:"@comments"},{include:"@strings"},["[()]","delimiter"],["[\\{;]","delimiter","@pop"],[".","key"]]}}},Symbol.toStringTag,{value:"Module"}));
/*!-----------------------------------------------------------------------------
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
 * Released under the MIT license
 * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
 *-----------------------------------------------------------------------------*/const h=Object.freeze(Object.defineProperty({__proto__:null,conf:{comments:{lineComment:"#"},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'}]},language:{defaultToken:"",tokenPostfix:".r",roxygen:["@alias","@aliases","@assignee","@author","@backref","@callGraph","@callGraphDepth","@callGraphPrimitives","@concept","@describeIn","@description","@details","@docType","@encoding","@evalNamespace","@evalRd","@example","@examples","@export","@exportClass","@exportMethod","@exportPattern","@family","@field","@formals","@format","@import","@importClassesFrom","@importFrom","@importMethodsFrom","@include","@inherit","@inheritDotParams","@inheritParams","@inheritSection","@keywords","@md","@method","@name","@noMd","@noRd","@note","@param","@rawNamespace","@rawRd","@rdname","@references","@return","@S3method","@section","@seealso","@setClass","@slot","@source","@template","@templateVar","@title","@TODO","@usage","@useDynLib"],constants:["NULL","FALSE","TRUE","NA","Inf","NaN","NA_integer_","NA_real_","NA_complex_","NA_character_","T","F","LETTERS","letters","month.abb","month.name","pi","R.version.string"],keywords:["break","next","return","if","else","for","in","repeat","while","array","category","character","complex","double","function","integer","list","logical","matrix","numeric","vector","data.frame","factor","library","require","attach","detach","source"],special:["\\n","\\r","\\t","\\b","\\a","\\f","\\v","\\'",'\\"',"\\\\"],brackets:[{open:"{",close:"}",token:"delimiter.curly"},{open:"[",close:"]",token:"delimiter.bracket"},{open:"(",close:")",token:"delimiter.parenthesis"}],tokenizer:{root:[{include:"@numbers"},{include:"@strings"},[/[{}\[\]()]/,"@brackets"],{include:"@operators"},[/#'$/,"comment.doc"],[/#'/,"comment.doc","@roxygen"],[/(^#.*$)/,"comment"],[/\s+/,"white"],[/[,:;]/,"delimiter"],[/@[a-zA-Z]\w*/,"tag"],[/[a-zA-Z]\w*/,{cases:{"@keywords":"keyword","@constants":"constant","@default":"identifier"}}]],roxygen:[[/@\w+/,{cases:{"@roxygen":"tag","@eos":{token:"comment.doc",next:"@pop"},"@default":"comment.doc"}}],[/\s+/,{cases:{"@eos":{token:"comment.doc",next:"@pop"},"@default":"comment.doc"}}],[/.*/,{token:"comment.doc",next:"@pop"}]],numbers:[[/0[xX][0-9a-fA-F]+/,"number.hex"],[/-?(\d*\.)?\d+([eE][+\-]?\d+)?/,"number"]],operators:[[/<{1,2}-/,"operator"],[/->{1,2}/,"operator"],[/%[^%\s]+%/,"operator"],[/\*\*/,"operator"],[/%%/,"operator"],[/&&/,"operator"],[/\|\|/,"operator"],[/<</,"operator"],[/>>/,"operator"],[/[-+=&|!<>^~*/:$]/,"operator"]],strings:[[/'/,"string.escape","@stringBody"],[/"/,"string.escape","@dblStringBody"]],stringBody:[[/\\./,{cases:{"@special":"string","@default":"error-token"}}],[/'/,"string.escape","@popall"],[/./,"string"]],dblStringBody:[[/\\./,{cases:{"@special":"string","@default":"error-token"}}],[/"/,"string.escape","@popall"],[/./,"string"]]}}},Symbol.toStringTag,{value:"Module"}));export{l as A,c as R,b as a,f as b,p as c,m as d,d as f,y as l,h as r,g as u};
