var{defineProperty:u,getOwnPropertyNames:x,getOwnPropertyDescriptor:R}=Object,k=Object.prototype.hasOwnProperty;function G(t){return this[t]}var I=(t)=>{var e=(n??=new WeakMap).get(t),a;if(e)return e;if(e=u({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function"){for(var g of x(t))if(!k.call(e,g))u(e,g,{get:G.bind(t,g),enumerable:!(a=R(t,g))||a.enumerable})}return n.set(t,e),e},n;var L=(t)=>t;function D(t,e){this[t]=L.bind(null,e)}var O=(t,e)=>{for(var a in e)u(t,a,{get:e[a],enumerable:!0,configurable:!0,set:D.bind(e,a)})};var S=(t,e)=>()=>(t&&(e=t(t=0)),e);var C=/^(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*))?(?:\+([a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*))?$/;function P(t){let e=t.trim().match(C);if(!e)return null;let a=e[1],g=e[2],d=e[3],f=e[4],c=e[5];if(!a||!g||!d)return null;return{major:parseInt(a,10),minor:parseInt(g,10),patch:parseInt(d,10),...f&&{prerelease:f},...c&&{build:c}}}function U(t){let e=P(t);if(!e)throw Error(`Invalid semantic version: "${t}"`);return e}function p(t){let e=`${t.major}.${t.minor}.${t.patch}`;if(t.prerelease)e+=`-${t.prerelease}`;if(t.build)e+=`+${t.build}`;return e}function l(t,e){let a=U(t),g=U(e);if(a.major!==g.major)return a.major>g.major?1:-1;if(a.minor!==g.minor)return a.minor>g.minor?1:-1;if(a.patch!==g.patch)return a.patch>g.patch?1:-1;if(a.prerelease&&!g.prerelease)return-1;if(!a.prerelease&&g.prerelease)return 1;if(a.prerelease&&g.prerelease)return a.prerelease<g.prerelease?-1:a.prerelease>g.prerelease?1:0;return 0}function q(t,e){return l(t,e)===1}function z(t,e){return l(t,e)===-1}function F(t,e){return l(t,e)===0}function H(t,e){let a=U(t);switch(e){case"major":return p({major:a.major+1,minor:0,patch:0});case"minor":return p({major:a.major,minor:a.minor+1,patch:0});case"patch":return p({major:a.major,minor:a.minor,patch:a.patch+1})}}function J(t,e){if(t)return"major";if(e)return"minor";return"patch"}function M(t){switch(t){case"major":return 3;case"minor":return 2;case"patch":return 1}}function K(t){if(t.length===0)return null;return t.reduce((e,a)=>M(a)>M(e)?a:e)}function Q(t){return P(t)!==null}function W(t){let e=[];if(!t||typeof t!=="string")return e.push("Version must be a non-empty string"),e;let a=t.trim();if(a!==t)e.push("Version should not have leading or trailing whitespace");if(!P(a))e.push(`Invalid semantic version format: "${t}". Expected format: MAJOR.MINOR.PATCH[-prerelease][+build]`);return e}function w(t){if(t.version)return t.version;let e=t.packages.map((a)=>a.version).filter((a)=>typeof a==="string");if(e.length===0)return null;return e.reduce((a,g)=>l(g,a)===1?g:a)}function A(t){return[...t.releases].sort((e,a)=>{let g=new Date(a.date).getTime()-new Date(e.date).getTime();if(g!==0)return g;let d=w(e),f=w(a);if(d&&f)return l(f,d);if(d)return-1;if(f)return 1;return e.slug.localeCompare(a.slug)})}function E(t){return t.reduce((e,a)=>{return e[a.level]+=1,e},{auto:0,assisted:0,manual:0})}function X(t){let e=new Map;for(let a of t){let g=e.get(a.id);if(!g){e.set(a.id,{...a,instructions:[...a.instructions],packages:a.packages?[...a.packages]:void 0,autofixes:a.autofixes?[...a.autofixes]:void 0});continue}g.instructions=Array.from(new Set([...g.instructions,...a.instructions])),g.packages=Array.from(new Set([...g.packages??[],...a.packages??[]])),g.autofixes=Array.from(new Map([...g.autofixes??[],...a.autofixes??[]].map((d)=>[d.id,d])).values())}return Array.from(e.values())}function _(t,e,a){return e.map((g)=>({agent:g,title:`Upgrade guide for ${g}`,prompt:a(g,t)}))}export{A as sortReleaseManifest,X as dedupeUpgradePlanSteps,_ as createAgentPromptBundles,E as countUpgradePlanStepLevels};
