import{da as p}from"./main-tangy-colts-beg.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(e,n){return this.cache.has(e)?this.cache.get(e):(this.cache.set(e,n),n)}};const g="https://api.github.com",m=e=>p({headers:{Accept:"application/json",Authorization:["Bearer ",{encryption:"hmac_decrypt",value:e}],"X-GitHub-Api-Version":"2022-11-28"},method:"GET",url:`${g}/user`}),h=(e,n)=>p({headers:{Accept:"application/json",Authorization:["Bearer ",{encryption:"hmac_decrypt",value:e}],"X-GitHub-Api-Version":"2022-11-28"},method:"GET",url:`${g}/users/${n}/repos`}),C=(e,n,o)=>p({headers:{Accept:"application/json",Authorization:["Bearer ",{encryption:"hmac_decrypt",value:e}],"X-GitHub-Api-Version":"2022-11-28"},method:"GET",url:`${g}/repos/${n}/${o}/assignees`}),f=(e,n,o)=>p({headers:{Accept:"application/json",Authorization:["Bearer ",{encryption:"hmac_decrypt",value:e}],"X-GitHub-Api-Version":"2022-11-28"},method:"GET",url:`${g}/repos/${n}/${o}/labels`}),d=(e,n,o)=>p({headers:{Accept:"application/json",Authorization:["Bearer ",{encryption:"hmac_decrypt",value:e}],"X-GitHub-Api-Version":"2022-11-28"},method:"GET",url:`${g}/repos/${n}/${o}/issues`});globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(e,n){return this.cache.has(e)?this.cache.get(e):(this.cache.set(e,n),n)}};const w=async e=>{e.setComponent("owner",s=>{s.loading=!0});const n=await e.getConnection();if(!n){e.setComponent("owner",s=>{s.loading=!1});return}const{data:o,status:i}=await m(n.auth_details.value);if(i!=="success"){e.setComponent("owner",s=>{e.util.isSelectComponent(s)&&(s.loading=!1,s.status=i,s.invalidMessage=o)}),console.error("Failed to fetch list");return}e.setComponent("owner",s=>{e.util.isSelectComponent(s)&&(s.options=[{label:o.login,value:o.login}],s.loading=!1)})},b=async e=>{var s,l;e.setComponent("repository",a=>{a.loading=!0});const n=await e.getConnection();if(!n||u((s=e.getComponent("owner"))==null?void 0:s.value)){e.setComponent("repository",a=>{a.loading=!1});return}const{data:o,status:i}=await h(n.auth_details.value,(l=e.getComponent("owner"))==null?void 0:l.value);if(i!=="success"){e.setComponent("repository",a=>{e.util.isSelectComponent(a)&&(a.loading=!1,a.status=i,a.invalidMessage=o)}),console.error("Failed to fetch list");return}e.setComponent("repository",a=>{e.util.isSelectComponent(a)&&(a.options=o==null?void 0:o.map(r=>({label:r.full_name,value:r.name})),a.loading=!1)})};function u(e){return e==null||e===""}const A=async e=>{var s,l,a,r;e.setComponent("assignee",t=>{t.loading=!0});const n=await e.getConnection();if(!n||u((s=e.getComponent("owner"))==null?void 0:s.value)||u((l=e.getComponent("repository"))==null?void 0:l.value)){e.setComponent("assignee",t=>{t.loading=!1});return}const{data:o,status:i}=await C(n.auth_details.value,(a=e.getComponent("owner"))==null?void 0:a.value,(r=e.getComponent("repository"))==null?void 0:r.value);if(i!=="success"){e.setComponent("assignee",t=>{e.util.isSelectComponent(t)&&(t.loading=!1,t.status=i,t.invalidMessage=o)}),console.error("Failed to fetch list");return}e.setComponent("assignee",t=>{e.util.isSelectComponent(t)&&(t.options=o==null?void 0:o.map(c=>({label:c.login,value:c.login})),t.loading=!1)})},_=async e=>{var s,l,a,r;e.setComponent("label",t=>{t.loading=!0});const n=await e.getConnection();if(!n||u((s=e.getComponent("owner"))==null?void 0:s.value)||u((l=e.getComponent("repository"))==null?void 0:l.value)){e.setComponent("label",t=>{t.loading=!1});return}const{data:o,status:i}=await f(n.auth_details.value,(a=e.getComponent("owner"))==null?void 0:a.value,(r=e.getComponent("repository"))==null?void 0:r.value);if(i!=="success"){e.setComponent("label",t=>{e.util.isSelectComponent(t)&&(t.loading=!1,t.status=i,t.invalidMessage=o)}),console.error("Failed to fetch list");return}e.setComponent("label",t=>{e.util.isSelectComponent(t)&&(t.options=o==null?void 0:o.map(c=>({label:c.name,value:c.name})),t.loading=!1)})},S=async e=>{var s,l,a,r;e.setComponent("issue",t=>{t.loading=!0});const n=await e.getConnection();if(!n||u((s=e.getComponent("owner"))==null?void 0:s.value)||u((l=e.getComponent("repository"))==null?void 0:l.value)){e.setComponent("issue",t=>{t.loading=!1});return}const{data:o,status:i}=await d(n.auth_details.value,(a=e.getComponent("owner"))==null?void 0:a.value,(r=e.getComponent("repository"))==null?void 0:r.value);if(i!=="success"){e.setComponent("issue",t=>{e.util.isSelectComponent(t)&&(t.loading=!1,t.status=i,t.invalidMessage=o)}),console.error("Failed to fetch list");return}e.setComponent("issue",t=>{e.util.isSelectComponent(t)&&(t.options=o==null?void 0:o.map(c=>({label:c.title,value:c.number})),t.loading=!1)})};export{w as a,_ as b,A as c,S as d,b as f};
