const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./JVUngQ3U.js","./DrKWWDpL.js","./DsQIgu-4.js","./DTkg6Mnx.js","./DYP3EJMY.js","./DXsj0Ygw.js","./DeO5NWhN.js","./DgZn9uJn.js","./CbGRcr-D.js","./CudpqN6Z.js","./CX8DOZuw2.js","./DOqzs8kl2.js","./DIQmuJJZ.js","./D7w7HllH.js","./DB5ifLM-.js","./CxlOpib82.js","./Czb-RtcG.js","./C0nwgWmB.js","./Dw1eNzkF.js","./CVwAhlPZ.js","./CGrT1UxN.js","./vZvGnEXu.js","./BMGkukPk.js","./DoOTPDI-.js"])))=>i.map(i=>d[i]);
import{n as e,t}from"./DsQIgu-4.js";import{Dt as n}from"./DIQmuJJZ.js";import{t as r}from"./DTkg6Mnx.js";import{r as i,t as a}from"./b2R8Ad-3.js";var o=.15,s=.25,c=.3,l=.2,u=.1;function d(e){let t=0,n=0;for(let r of e)r===`(`||r===`{`||r===`[`?(t+=1,t>n&&(n=t)):(r===`)`||r===`}`||r===`]`)&&(t=Math.max(t-1,0));return Math.min(n/5,1)}var f=[`why`,`should`,`compare`,`decide`,`explain`,`analyze`,`evaluate`,`consider`,`trade-off`,`tradeoff`];function p(e){let t=e.toLowerCase(),n=0;for(let e of f){let r=0;for(;;){let i=t.indexOf(e,r);if(i===-1)break;n+=1,r=i+e.length}}return n}function m(e){let t=0;for(let n of e)n!==n.toLowerCase()&&n===n.toUpperCase()&&(t+=1);return t}function h(e){let t=_(e).filter(e=>m(e)>=2).length;return Math.min(t/10,1)}function g(e){return _(e).filter(e=>e.includes(`/`)||e.endsWith(`.rs`)||e.endsWith(`.ts`)||e.endsWith(`.md`)||e.endsWith(`.json`)).length}function _(e){return e.split(/\s+/).filter(e=>e.length>0)}function v(e){return{tokenCount:_(e).length,syntacticComplexity:d(e),reasoningDepth:p(e),domainSpecificity:h(e),touchesFilesCount:g(e)}}function y(e,t,n){return Number.isNaN(e)?t:Math.min(Math.max(e,t),n)}function b(e){return{tokenCount:Math.min(e.tokenCount/1e3,1),syntacticComplexity:y(e.syntacticComplexity,0,1),reasoningDepth:Math.min(e.reasoningDepth/10,1),domainSpecificity:y(e.domainSpecificity,0,1),touchesFilesCount:Math.min(e.touchesFilesCount/20,1)}}function x(e){let t=b(e),n=o*t.tokenCount+s*t.syntacticComplexity+c*t.reasoningDepth+l*t.domainSpecificity+u*t.touchesFilesCount;return{score:n,tier:n>=.75?`high`:n>=.35?`mid`:`low`,features:e}}function S(e){return x(v(e)).tier}function C(e){switch(e){case`low`:return`hygiene`;case`mid`:return`consolidation`;case`high`:return`judgement`}}function w(e){return C(S(e))}e();var T=r(`llm-system-resolver`);function E(e){return typeof e==`object`&&!!e&&e.kind===`role`}function D(e,t){if(t?.roleOverride)return t.roleOverride;if(E(e))return e.id;let r=n[e]??null;if(r!==null)return r;if(t?.complexityPrompt!==void 0){let n=w(t.complexityPrompt);return T.debug({system:e,proposedRole:n},`system-resolver: derived role from L1 complexity classifier (no explicit tier/role)`),n}return null}async function O(e){if(e.source!==`implicit-fallback`)return e;try{let{resolveCatalogEntry:n}=await t(async()=>{let{resolveCatalogEntry:e}=await import(`./JVUngQ3U.js`);return{resolveCatalogEntry:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),import.meta.url),{catalogKeyForProvider:r}=await t(async()=>{let{catalogKeyForProvider:e}=await import(`./CGrT1UxN.js`);return{catalogKeyForProvider:e}},__vite__mapDeps([20,5,1,4]),import.meta.url),i=await n(r(e.provider));if(i?.id&&i.id!==e.model)return T.debug({provider:e.provider,from:e.model,to:i.id,source:i.source},`system-resolver: upgrading implicit-fallback model to models_catalog default`),{...e,model:i.id};if(i?.id)return e;let{getProviderProfile:a}=await t(async()=>{let{getProviderProfile:e}=await import(`./vZvGnEXu.js`);return{getProviderProfile:e}},__vite__mapDeps([21,22,1,2,23,11,4,10,12,13,14,15]),import.meta.url),o=await a(e.provider);return o?.defaultModel&&o.defaultModel!==e.model?(T.debug({provider:e.provider,from:e.model,to:o.defaultModel},`system-resolver: catalog empty — degrading to static builtin defaultModel floor`),{...e,model:o.defaultModel}):e}catch(t){return T.warn({err:t instanceof Error?t.message:String(t)},`system-resolver: catalog default lookup failed; keeping existing fallback model`),e}}async function k(e,t){let n=D(e,t),r=n??`consolidation`,o=t?.systemKey??(E(e)?void 0:e),s;try{s=await i(r,{projectRoot:t?.projectRoot,systemKey:o,...t?.profile===void 0?{}:{profileOverride:t.profile}})}catch(t){T.warn({err:t instanceof Error?t.message:String(t),system:e,role:r},`system-resolver: resolveLLMForRole threw unexpectedly; returning null-credential envelope`),s={provider:a,model:`unknown`,client:null,credential:null,sealedCredential:null,source:`implicit-fallback`,apiMode:`anthropic_messages`,baseUrl:null,authType:null}}return{...t?.skipCatalogDefault?s:await O(s),system:e,resolvedRole:n}}export{k as resolveLLMForSystem};