// @bun
import{w as Q,x as S}from"./chunk-6xnzhztm.js";import"./chunk-ks3qn9ry.js";import{B as X,F as Y}from"./chunk-hggcmr0j.js";async function $(A,G){try{let z=G.split("/").pop()||"";if(z==="package.json"){let E=JSON.parse(A),q=[];return K(E.dependencies,"dependencies",G,q),K(E.devDependencies,"devDependencies",G,q),K(E.peerDependencies,"peerDependencies",G,q),K(E.optionalDependencies,"optionalDependencies",G,q),{path:G,type:"package.json",content:A,dependencies:q}}if(Q(G))return await S(G,A);if(z==="composer.json"||z==="composer.lock"){let{parseComposerFile:E}=await import("./chunk-cbrgaec3.js");return await E(G,A)}return null}catch{return null}}function K(A,G,z,E){if(!A)return;for(let[q,H]of Object.entries(A))E.push({name:q,currentVersion:H,type:G,file:z})}function I(A){return"bun"}function L(A,G){if(G)return G;if(A.length===1){let H=A[0];return`chore(deps): update dependency ${H.name} to ${H.newVersion}`}let z=A.filter((H)=>H.updateType==="major"),E=A.filter((H)=>H.updateType==="minor"),q=A.filter((H)=>H.updateType==="patch");if(z.length>0)return`chore(deps): update ${z.length} major dependencies`;else if(E.length>0)return`chore(deps): update ${E.length} minor dependencies`;else return`chore(deps): update ${q.length} patch dependencies`}function T(A,G){if(G)return G;if(A.length===1){let E=A[0];return`chore(deps): update dependency ${E.name} to v${E.newVersion}`}let z=A.filter((E)=>E.updateType==="major");if(z.length>0)return`chore(deps): update ${z.length} major dependencies`;else return"chore(deps): update all non-major dependencies"}function O(A,G){if(G)return G;let z=`This PR contains the following updates:

`;z+=`| Package | Change | Age | Adoption | Passing | Confidence |
`,z+=`|---|---|---|---|---|---|
`;for(let q of A){let H=`\`${q.currentVersion}\` -> \`${q.newVersion}\``,J=q.metadata?.homepage?`[${q.name}](${q.metadata.homepage})`:q.name;z+=`| ${J} | ${H} | [![age](https://developer.mend.io/api/mc/badges/age/npm/${q.name}/${q.newVersion}?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/${q.name}/${q.newVersion}?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/${q.name}/${q.currentVersion}/${q.newVersion}?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/${q.name}/${q.currentVersion}/${q.newVersion}?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
`}z+=`
---

`;let E=A.filter((q)=>q.releaseNotesUrl);if(E.length>0){z+=`### Release Notes

`;for(let q of E)if(q.releaseNotesUrl)z+=`<details>
<summary>${q.name}</summary>

`,z+=`[Release Notes](${q.releaseNotesUrl})

`,z+=`</details>

`}return z+=`### Configuration

`,z+=`\uD83D\uDCC5 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

`,z+=`\uD83D\uDEA6 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

`,z+=`\u267B **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

`,z+=`\uD83D\uDD15 **Ignore**: Close this PR and you won't be reminded about this update again.

`,z+=`---

`,z+=` - [ ] <!-- rebase-check -->If you want to update/retry this PR, check this box

`,z+=`---

`,z+="This PR was generated by [Buddy](https://github.com/stacksjs/buddy-bot).",z}function B(A,G="buddy"){let z=new Date().toISOString().slice(0,10).replace(/-/g,"");if(A.length===1){let q=A[0],H=q.name.replace(/[^a-z0-9-]/gi,"-");return`${G}/update-${H}-to-${q.newVersion}-${z}`}if(A.filter((q)=>q.updateType==="major").length>0)return`${G}/update-major-dependencies-${z}`;else return`${G}/update-dependencies-${z}`}function M(A){let G=[],z=A.filter((H)=>H.updateType==="major"),E=A.filter((H)=>H.updateType==="minor"),q=A.filter((H)=>H.updateType==="patch");for(let H of z)G.push({name:`Major Update - ${H.name}`,updates:[H],updateType:"major",title:`chore(deps): update dependency ${H.name} to ${H.newVersion}`,body:O([H])});if(E.length>0||q.length>0){let H=[...E,...q];G.push({name:"Non-Major Updates",updates:H,updateType:E.length>0?"minor":"patch",title:"chore(deps): update all non-major dependencies",body:O(H)})}return G}function W(A){let G={major:3,minor:2,patch:1};return A.sort((z,E)=>{let q=G[z.updateType],H=G[E.updateType];if(q!==H)return H-q;return z.name.localeCompare(E.name)})}function v(A,G){let z=A.replace(/^[v^~>=<]+/,""),E=G.replace(/^[v^~>=<]+/,""),q=z.split(".").map(Number),H=E.split(".").map(Number);if(H[0]>q[0])return"major";if(H[0]===q[0]&&H[1]>q[1])return"minor";return"patch"}function C(A,G){let z=A.replace(/^[\^~>=<]+/,""),E=G.replace(/^[\^~>=<]+/,"");return z===E}async function F(A,G,z){if(!A)throw new Error("GitHub token is required");try{let E=await fetch(`https://api.github.com/repos/${G}/${z}/pulls?state=open`,{headers:{Authorization:`Bearer ${A}`,Accept:"application/vnd.github+json","User-Agent":"buddy-bot"}});if(!E.ok)throw new Error(`GitHub API error: ${E.status} ${E.statusText}`);return(await E.json()).filter((J)=>{if(!J.body)return!1;return/- \[x\] <!-- rebase-check -->.*(?:want to (?:rebase|update)\/retry this PR|If you want to (?:rebase|update)\/retry)/i.test(J.body)}).map((J)=>({number:J.number,branchName:J.head.ref}))}catch(E){throw new Error(`Failed to check for rebase requests: ${E}`)}}export{W as sortUpdatesByPriority,C as satisfiesRange,$ as parsePackageFile,M as groupUpdates,v as getUpdateType,B as generateBranchName,T as formatPRTitle,O as formatPRBody,L as formatCommitMessage,I as detectPackageManager,F as checkForRebaseRequests};
export{$ as n,I as o,L as p,T as q,O as r,B as s,M as t,W as u,v};
