import{getLevelsForSelectedModel}from'./model-selection-utils.js';export const USE_DEFAULT_SENTINEL='__use_default__';export const RESUBMIT_PROVIDERS=[{'agent':'claude','modelEnv':'CLAUDE_MODEL','levelEnv':'CLAUDE_CODE_EFFORT_LEVEL','modelSelectId':'resubmit-claude-model','levelSelectId':'resubmit-effort-level','countInputId':'resubmit-claude-count'},{'agent':'codex','modelEnv':'OPENAI_MODEL','levelEnv':'CODEX_REASONING_LEVEL','modelSelectId':'resubmit-codex-model','levelSelectId':'resubmit-reasoning-level','countInputId':'resubmit-codex-count'},{'agent':'grok','modelEnv':'GROK_MODEL','levelEnv':'GROK_EFFORT_LEVEL','modelSelectId':'resubmit-grok-model','levelSelectId':'resubmit-grok-effort-level','countInputId':'resubmit-grok-count'}];export function stripModelDefaultLabel(_0x11ece4){return String(_0x11ece4||'')['replace'](/\s*\(default\)\s*$/i,'');}function defaultEscape(_0x4d568f){return String(_0x4d568f==null?'':_0x4d568f)['replace'](/&/g,'&amp;')['replace'](/</g,'&lt;')['replace'](/>/g,'&gt;')['replace'](/"/g,'&quot;')['replace'](/'/g,'&#39;');}export function findProviderModel(_0x5af030,_0x183f7b){if(!_0x183f7b)return null;return(_0x5af030?.['models']||[])['find'](_0x30c042=>_0x30c042?.['id']===_0x183f7b)||null;}export function findProviderLevel(_0x4a8ec9,_0x43bee6,_0x1beb70){if(!_0x1beb70)return null;return getLevelsForSelectedModel(_0x4a8ec9,_0x43bee6)['find'](_0x1a0d74=>_0x1a0d74?.['id']===_0x1beb70)||null;}export function isLevelIncompatible(_0x22f7ab,_0x46a95b,_0x345aef){if(!_0x345aef)return![];const _0x1d968d=getLevelsForSelectedModel(_0x22f7ab,_0x46a95b);if(!_0x1d968d['length'])return![];return!_0x1d968d['some'](_0x27da91=>_0x27da91?.['id']===_0x345aef);}function buildOption(_0x46d031,_0x3215c8,_0x2a9da0){return'<option\x20value=\x22'+_0x2a9da0(_0x46d031)+'\x22>'+_0x2a9da0(stripModelDefaultLabel(_0x3215c8))+'</option>';}function buildEmptyOption(_0x306b08,_0x4bc455){const _0x109290=_0x306b08?'\x20('+_0x4bc455(_0x306b08)+')':'';return'<option\x20value=\x22\x22>Same\x20as\x20original'+_0x109290+'</option>';}function buildUseDefaultOption(_0x12d304){return'<option\x20value=\x22'+_0x12d304(USE_DEFAULT_SENTINEL)+'\x22>Use\x20server\x20default</option>';}export function buildModelOptionsHtml(_0x2b0406,_0x36a76b,{escape:escape=defaultEscape}={}){const _0x25f790=_0x2b0406?.['models']||[],_0x10d1dc=findProviderModel(_0x2b0406,_0x36a76b),_0x5a7b46=_0x10d1dc?stripModelDefaultLabel(_0x10d1dc['displayName']||_0x10d1dc['id']):null,_0x17cdd1=[buildEmptyOption(_0x5a7b46,escape)];if(_0x36a76b)_0x17cdd1['push'](buildUseDefaultOption(escape));for(const _0x123ce6 of _0x25f790){_0x17cdd1['push'](buildOption(_0x123ce6['id'],_0x123ce6['displayName']||_0x123ce6['id'],escape));}return _0x17cdd1['join']('');}export function buildLevelOptionsHtml(_0x5b2149,_0x41e441,_0x1983a9,{escape:escape=defaultEscape}={}){const _0x570082=getLevelsForSelectedModel(_0x5b2149,_0x41e441),_0x488a5b=findProviderLevel(_0x5b2149,_0x41e441,_0x1983a9),_0x3ad76a=_0x488a5b?stripModelDefaultLabel(_0x488a5b['displayName']||_0x488a5b['id']):null,_0x184b9f=[buildEmptyOption(_0x3ad76a,escape)];if(_0x1983a9)_0x184b9f['push'](buildUseDefaultOption(escape));for(const _0xdfdf0e of _0x570082){_0x184b9f['push'](buildOption(_0xdfdf0e['id'],_0xdfdf0e['displayName']||_0xdfdf0e['id'],escape));}return _0x184b9f['join']('');}export function collectModelOverrides({selections:selections={},agentCounts:agentCounts={},envVars:envVars={},availableModels:availableModels={}}={}){const _0x4fc64b={},_0x77da1d=(_0x4db1aa,_0x3ab76a)=>{if(_0x3ab76a==='')return;_0x4fc64b[_0x4db1aa]=_0x3ab76a===USE_DEFAULT_SENTINEL?'':_0x3ab76a;};for(const _0x511fa2 of RESUBMIT_PROVIDERS){if((agentCounts[_0x511fa2['agent']]||0x0)<=0x0)continue;const _0x5df0bd=selections[_0x511fa2['modelEnv']]||'',_0x3e52c0=selections[_0x511fa2['levelEnv']]||'';_0x77da1d(_0x511fa2['modelEnv'],_0x5df0bd),_0x77da1d(_0x511fa2['levelEnv'],_0x3e52c0);const _0x18242d=_0x5df0bd&&_0x5df0bd!==USE_DEFAULT_SENTINEL;if(_0x18242d&&_0x3e52c0===''){const _0x19bd38=envVars[_0x511fa2['levelEnv']],_0x4e7e9d=availableModels[_0x511fa2['agent']];_0x19bd38&&_0x4e7e9d&&isLevelIncompatible(_0x4e7e9d,_0x5df0bd,_0x19bd38)&&(_0x4fc64b[_0x511fa2['levelEnv']]='');}}return _0x4fc64b;}