import{At as e}from"./vendor-all-0-fRSUBfCr.js";import{$r as r,Ll as a,Vm as o,zm as t}from"./shared-0-C4kdVF7Y.js";import{ki as i}from"./vendor-frame-CwiylG4Y.js";import{Mh as n}from"./shared-1-3-6x7RKF.js";import{rn as s}from"./vendor-all-2-BJdkbLSj.js";var g=i(),d=e=>(0,g.jsx)(r,{...e,children:(0,g.jsx)("path",{d:"M13.5 3a.5.5 0 0 1 .5.5V4h2.5A1.5 1.5 0 0 1 18 5.5v9a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 2 14.5v-9A1.5 1.5 0 0 1 3.5 4H6v-.5a.5.5 0 0 1 1 0V4h6v-.5a.5.5 0 0 1 .5-.5m-10 2a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5H14v.5a.5.5 0 0 1-1 0V5H7v.5a.5.5 0 0 1-1 0V5zm9.616 3.18a.5.5 0 0 1 .768.64l-2.5 3a.5.5 0 0 1-.738.034L9.034 10.24l-2.15 2.58a.5.5 0 0 1-.767-.64l2.5-3 .074-.073a.5.5 0 0 1 .664.04l1.612 1.612z"})}),u="ccr-webhook-triggers";function c(e){return{"anthropic-version":"2023-06-01","anthropic-beta":"ccr-triggers-2026-01-30",...e?{"x-organization-uuid":e}:{}}}function l(e){const{activeOrganization:r}=a(),t=r?.uuid;return o("/v1/code/webhook-triggers",{queryKey:[u,{orgUuid:t}],enabled:Boolean(t)&&(e?.enabled??!0),staleTime:1e4,headers:c(t),meta:{noToast:!0}})}function m(e,r){const{activeOrganization:t}=a(),i=t?.uuid;return o(`/v1/code/webhook-triggers?routine_trigger_id=${encodeURIComponent(e??"")}`,{queryKey:[u,{orgUuid:i,routineTriggerId:e}],enabled:Boolean(i)&&Boolean(e)&&(r?.enabled??!0),staleTime:1e4,headers:c(i),meta:{noToast:!0}})}function v(e){const{activeOrganization:r}=a(),t=r?.uuid;return o("/v1/code/plugins",{queryKey:["ccr-webhook-plugins",{orgUuid:t}],enabled:Boolean(t)&&(e?.enabled??!0),staleTime:6e4,headers:c(t),meta:{noToast:!0}})}function h(r){const{activeOrganization:o}=a(),i=o?.uuid,g=e(),{addError:d}=n(),l=s(),m=void 0===r?.errorToast?l.formatMessage({defaultMessage:"Failed to enable security review. You can try again.",id:"cJ7iFOGFAD"}):r.errorToast;return t("/v1/code/webhook-triggers","POST",{onSuccess:e=>{if(!e.trigger)return;const r=e.trigger;g.setQueryData([u,{orgUuid:i}],e=>e?{...e,data:[...e.data??[],r]}:{data:[r]});const a=r.routine_trigger_id;a&&g.setQueryData([u,{orgUuid:i,routineTriggerId:a}],e=>e?{...e,data:[...e.data??[],r]}:{data:[r]})},onError:e=>{null!==m&&d(m,{error:e,errorContext:{tags:{source:"ccr_webhook_trigger_create"}},messageForLogging:"Failed to create CCR webhook trigger"})},meta:{noToast:!0},headers:c(i)})}function b(r){const{activeOrganization:o}=a(),i=o?.uuid,g=e(),{addError:d}=n(),l=s(),m=void 0===r?.errorToast?l.formatMessage({defaultMessage:"Failed to remove GitHub trigger. You can try again.",id:"JgJ5T3QTfz"}):r.errorToast;return t(e=>`/v1/code/webhook-triggers/${e.triggerId}`,"DELETE",{transformVariables:()=>({}),onSuccess:(e,r)=>{g.setQueryData([u,{orgUuid:i}],e=>e?{...e,data:(e.data??[]).filter(e=>e.trigger_id!==r.triggerId)}:void 0),g.invalidateQueries({queryKey:[u],exact:!1})},onError:e=>{null!==m&&d(m,{error:e,errorContext:{tags:{source:"ccr_webhook_trigger_delete"}},messageForLogging:"Failed to delete CCR webhook trigger"})},meta:{noToast:!0},headers:c(i)})}export{b as a,h as i,m as n,d as o,l as r,v as t};