import{At as s}from"./vendor-all-0-fRSUBfCr.js";import{Ll as a,Tb as t,Ul as e,Vm as r,dd as n,zm as o}from"./shared-0-C4kdVF7Y.js";import{Zd as i}from"./shared-3-D-Ux4aGn.js";import{hi as u,mi as c}from"./shared-2-CMUBhYOn.js";var d="pr-steward-org-settings",m=1e4,g=/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}]/u;function f(s,a){return s?a?.run_on_drafts?"on_with_drafts":"on":"off"}function p(s){return{"anthropic-version":"2023-06-01",...s?{"x-organization-uuid":s}:{}}}function y(s){return s instanceof t&&(501===s.statusCode||404===s.statusCode)}function _(s){return s.trim().toLowerCase()}var l=/^[A-Za-z0-9](?:-?[A-Za-z0-9]){0,38}(?:_[A-Za-z0-9](?:-?[A-Za-z0-9]){0,38})?$/;function h(s){return s.trim().toLowerCase()}function v(s,a){const t=[],e=new Set;for(const r of[...s,...a]){const s=_(r);s&&!e.has(s)&&(e.add(s),t.push(s))}return t}function w(s){const{activeOrganization:t}=a(),e=t?.uuid;return r("/v1/code/pr-steward/org-settings",{queryKey:[d,e],headers:p(e),enabled:s&&!!e,staleTime:3e5,meta:{noToast:!0}})}function z(){const{activeOrganization:t}=a(),e=t?.uuid,r=s();return o("/v1/code/pr-steward/org-settings","PUT",{headers:p(e),meta:{noToast:!0},onSuccess:async(s,a)=>{await r.cancelQueries({queryKey:[d,e]}),r.setQueryData([d,e],t=>({...s,settings:s.settings??a.settings,cost_summary:s.cost_summary??t?.cost_summary}))}})}function T(){const{activeOrganization:t}=a(),e=t?.uuid,r=s();return o("/v1/code/pr-steward/org-settings/repo","POST",{headers:p(e),meta:{noToast:!0},onSuccess:async s=>{await r.cancelQueries({queryKey:[d,e]}),r.setQueryData([d,e],a=>({...s,cost_summary:s.cost_summary??a?.cost_summary}))}})}var Z=()=>{const{isLoading:s}=a(),t=c();return!s&&t},C=()=>{const s=i(),a=u("drey_spyglass"),t=e(n.OrganizationManage);return s&&a&&t},A=s=>s.merged?"merged":s.closed_at?"closed":"no_outcome",O=s=>{const a=Number(s??"0");return Number.isFinite(a)?a:0},b=s=>s.reduce((s,a)=>s+O(a.session_count),0);export{z as _,Z as a,m as c,h as d,_ as f,T as g,w as h,C as i,y as l,f as m,A as n,l as o,p,b as r,g as s,O as t,v as u};