import{n as e}from"./chunk-DR8-3Aex.js";import{l as t,p as n}from"./debug-otxXY3j-.js";import{n as r,t as i}from"./cwd--iizewsn.js";import{m as a,v as o}from"./git-C0IuvuIy.js";function s(){m.clear()}async function c(){let e=await l();return!e||e.host!==`github.com`?null:`${e.owner}/${e.name}`}async function l(){let e=i();if(m.has(e))return m.get(e)??null;try{let t=await a();if(n(`Git remote URL: ${t}`),!t)return n(`No git remote URL found`),m.set(e,null),null;let r=d(t);return n(`Parsed repository: ${r?`${r.host}/${r.owner}/${r.name}`:null} from URL: ${t}`),m.set(e,r),r}catch(t){return n(`Error detecting repository: ${t}`),m.set(e,null),null}}function u(){let e=m.get(i());return!e||e.host!==`github.com`?null:`${e.owner}/${e.name}`}function d(e){let t=e.trim(),n=t.match(/^git@([^:]+):([^/]+)\/([^/]+?)(?:\.git)?$/);if(n?.[1]&&n[2]&&n[3])return p(n[1])?{host:n[1],owner:n[2],name:n[3]}:null;let r=t.match(/^(https?|ssh|git):\/\/(?:[^@]+@)?([^/:]+(?::\d+)?)\/([^/]+)\/([^/]+?)(?:\.git)?$/);if(r?.[1]&&r[2]&&r[3]&&r[4]){let e=r[1],t=r[2],n=t.split(`:`)[0]??``;return p(n)?{host:e===`https`||e===`http`?t:n,owner:r[3],name:r[4]}:null}return null}function f(e){let t=e.trim(),r=d(t);if(r)return r.host===`github.com`?`${r.owner}/${r.name}`:null;if(!t.includes(`://`)&&!t.includes(`@`)&&t.includes(`/`)){let e=t.split(`/`);if(e.length===2&&e[0]&&e[1]){let t=e[1].replace(/\.git$/,``);return`${e[0]}/${t}`}}return n(`Could not parse repository from: ${t}`),null}function p(e){if(!e.includes(`.`))return!1;let t=e.split(`.`).pop();return t?/^[a-zA-Z]+$/.test(t):!1}var m,h=e((()=>{r(),t(),o(),m=new Map}));export{h as a,u as i,c as n,f as o,l as r,d as s,s as t};