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(_0x201f6b){return String(_0x201f6b||'')['replace'](/\s*\(default\)\s*$/i,'');}function defaultEscape(_0x33428b){return String(_0x33428b==null?'':_0x33428b)['replace'](/&/g,'&amp;')['replace'](/</g,'&lt;')['replace'](/>/g,'&gt;')['replace'](/"/g,'&quot;')['replace'](/'/g,'&#39;');}export function findProviderModel(_0x191f46,_0x25ec72){if(!_0x25ec72)return null;return(_0x191f46?.['models']||[])['find'](_0x23d5d1=>_0x23d5d1?.['id']===_0x25ec72)||null;}export function findProviderLevel(_0x4627b4,_0x37e48f,_0x3daf4e){if(!_0x3daf4e)return null;return getLevelsForSelectedModel(_0x4627b4,_0x37e48f)['find'](_0x284553=>_0x284553?.['id']===_0x3daf4e)||null;}export function isLevelIncompatible(_0x1ef05d,_0x52759f,_0x5bf87f){if(!_0x5bf87f)return![];const _0x5c4b9d=getLevelsForSelectedModel(_0x1ef05d,_0x52759f);if(!_0x5c4b9d['length'])return![];return!_0x5c4b9d['some'](_0x4e9bb3=>_0x4e9bb3?.['id']===_0x5bf87f);}function buildOption(_0x5a59fd,_0xfc8ab3,_0x4ab542){return'<option\x20value=\x22'+_0x4ab542(_0x5a59fd)+'\x22>'+_0x4ab542(stripModelDefaultLabel(_0xfc8ab3))+'</option>';}function buildEmptyOption(_0x5e22a9,_0xf0656){const _0x4491f1=_0x5e22a9?'\x20('+_0xf0656(_0x5e22a9)+')':'';return'<option\x20value=\x22\x22>Same\x20as\x20original'+_0x4491f1+'</option>';}function buildUseDefaultOption(_0x35e75e){return'<option\x20value=\x22'+_0x35e75e(USE_DEFAULT_SENTINEL)+'\x22>Use\x20server\x20default</option>';}export function buildModelOptionsHtml(_0x13e3b3,_0x108755,{escape:escape=defaultEscape}={}){const _0x387e0c=_0x13e3b3?.['models']||[],_0x5dfb54=findProviderModel(_0x13e3b3,_0x108755),_0x4807a4=_0x5dfb54?stripModelDefaultLabel(_0x5dfb54['displayName']||_0x5dfb54['id']):null,_0x4f2e2b=[buildEmptyOption(_0x4807a4,escape)];if(_0x108755)_0x4f2e2b['push'](buildUseDefaultOption(escape));for(const _0x571dd1 of _0x387e0c){_0x4f2e2b['push'](buildOption(_0x571dd1['id'],_0x571dd1['displayName']||_0x571dd1['id'],escape));}return _0x4f2e2b['join']('');}export function buildLevelOptionsHtml(_0x4db3f0,_0x4f26a6,_0xa38851,{escape:escape=defaultEscape}={}){const _0x1c44dd=getLevelsForSelectedModel(_0x4db3f0,_0x4f26a6),_0x2a3fd3=findProviderLevel(_0x4db3f0,_0x4f26a6,_0xa38851),_0x3f4f22=_0x2a3fd3?stripModelDefaultLabel(_0x2a3fd3['displayName']||_0x2a3fd3['id']):null,_0x3c2958=[buildEmptyOption(_0x3f4f22,escape)];if(_0xa38851)_0x3c2958['push'](buildUseDefaultOption(escape));for(const _0x20ce17 of _0x1c44dd){_0x3c2958['push'](buildOption(_0x20ce17['id'],_0x20ce17['displayName']||_0x20ce17['id'],escape));}return _0x3c2958['join']('');}export function collectModelOverrides({selections:selections={},agentCounts:agentCounts={},envVars:envVars={},availableModels:availableModels={}}={}){const _0x2dd05a={},_0x4f9147=(_0x34aa26,_0x682fe4)=>{if(_0x682fe4==='')return;_0x2dd05a[_0x34aa26]=_0x682fe4===USE_DEFAULT_SENTINEL?'':_0x682fe4;};for(const _0x4dbaaf of RESUBMIT_PROVIDERS){if((agentCounts[_0x4dbaaf['agent']]||0x0)<=0x0)continue;const _0x3e7ee9=selections[_0x4dbaaf['modelEnv']]||'',_0x20702c=selections[_0x4dbaaf['levelEnv']]||'';_0x4f9147(_0x4dbaaf['modelEnv'],_0x3e7ee9),_0x4f9147(_0x4dbaaf['levelEnv'],_0x20702c);const _0x1e785b=_0x3e7ee9&&_0x3e7ee9!==USE_DEFAULT_SENTINEL;if(_0x1e785b&&_0x20702c===''){const _0x17f09f=envVars[_0x4dbaaf['levelEnv']],_0x449bf3=availableModels[_0x4dbaaf['agent']];_0x17f09f&&_0x449bf3&&isLevelIncompatible(_0x449bf3,_0x3e7ee9,_0x17f09f)&&(_0x2dd05a[_0x4dbaaf['levelEnv']]='');}}return _0x2dd05a;}