import{At as e}from"./vendor-all-0-fRSUBfCr.js";import{Ll as t,Tb as n,Vm as a,zm as s}from"./shared-0-C4kdVF7Y.js";var r="pr-steward-settings";function o(e){return{"anthropic-version":"2023-06-01",...e?{"x-organization-uuid":e}:{}}}function i(e){return e instanceof n&&401===e.statusCode&&"authentication_error"===e.type}function u(e){return e instanceof n&&(429===e.statusCode||"rate_limit_error"===e.type)}function c(e){return e instanceof n&&(503===e.statusCode||"overloaded_error"===e.type)}function d(e){return e instanceof n&&"permission_error"===e.type&&"account_session_invalid"!==e.errorCode&&!e.message.includes("Not authenticated")}function l(e){return e instanceof n&&"string"==typeof e.extra.reason?e.extra.reason:null}function g(e){const{activeOrganization:n}=t(),s=n?.uuid;return a("/v1/code/pr-steward/contributions",{queryKey:["pr-steward-contributions",s],headers:o(s),enabled:e&&!!s,staleTime:3e5,meta:{noToast:!0}})}function f(e){const{activeOrganization:n}=t(),s=n?.uuid;return a("/v1/code/pr-steward/settings",{queryKey:[r,s],headers:o(s),enabled:e&&!!s,staleTime:3e5,meta:{noToast:!0}})}function _(){const{activeOrganization:n}=t(),a=n?.uuid,i=e();return s("/v1/code/pr-steward/settings","PUT",{headers:o(a),meta:{noToast:!0},onSuccess:async(e,t)=>{await i.cancelQueries({queryKey:[r,a]}),i.setQueryData([r,a],n=>{return{github_connected:!!(t.settings.enabled&&!n?.settings?.enabled||!t.settings.enabled&&"org_default_on"===n?.effective_state)||(n?.github_connected??!0),settings:e.settings,github_login:e.github_login??n?.github_login,effective_state:(a=n?.effective_state,s=e.settings?.enabled??t.settings.enabled??!1,void 0===a||"not_available"===a?a:"org_default_on"===a||"opted_out"===a?s?"org_default_on":"opted_out":s?"enabled":"disabled")};var a,s})}})}export{l as a,_ as c,u as i,i as n,g as o,c as r,f as s,d as t};