dsh-model-think-level 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -4,7 +4,7 @@ window.__ModuleLoader__.load({
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
6
6
 
7
- "use strict";var fo=Object.defineProperty;var mg=Object.getOwnPropertyDescriptor;var gg=Object.getOwnPropertyNames;var hg=Object.prototype.hasOwnProperty;var bg=(e,t,n)=>t in e?fo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var yg=(e,t)=>{for(var n in t)fo(e,n,{get:t[n],enumerable:!0})},vg=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of gg(t))!hg.call(e,o)&&o!==n&&fo(e,o,{get:()=>t[o],enumerable:!(r=mg(t,o))||r.enumerable});return e};var wg=e=>vg(fo({},"__esModule",{value:!0}),e);var Ke=(e,t,n)=>bg(e,typeof t!="symbol"?t+"":t,n);var fk={};yg(fk,{EffortEditor:()=>_o,REFRESH_MIN_INTERVAL_MS:()=>fg,apply:()=>uk,baselineModelsOf:()=>bl,compatOf:()=>Ao,createEditorApi:()=>Ho,defaultEffortOf:()=>Ro,describeNamespace:()=>le,effortsOf:()=>Mo,findModelMenu:()=>$a,findModelTrigger:()=>Va,imageGenOf:()=>Ia,inject:()=>ck,inputOf:()=>Lo,invalidateProbeCache:()=>Da,name:()=>lk,nameOf:()=>Co,providerHeadersOf:()=>Pa,providersOf:()=>qe,routeIsDeclared:()=>st,userProvidersOf:()=>on,writeModelRows:()=>Mr,writeProviderHeaders:()=>Lr});module.exports=wg(fk);var ug=require("react");function Cd(e,t){let n=!1,r=0,o=!1,i;return{schedule:()=>{if(o||n)return;n=!0;let a=Math.max(0,t-(Date.now()-r));i=setTimeout(()=>{i=void 0,n=!1,r=Date.now(),o||e()},a)},dispose:()=>{o=!0,i!==void 0&&clearTimeout(i),i=void 0,n=!1}}}var we="dsh-model-think-level",Rd="/dsh-model-think-level/raw-models";var po="/dsh-model-think-level/provider-key",mo="/dsh-model-think-level/key-index",Hd="/dsh-model-think-level/balance",Nd="/dsh-model-think-level/autofill-config",Od="/dsh-model-think-level/headers-config",ea="/dsh-model-think-level/fingerprint",ta="/dsh-model-think-level/ui-order";var De="llm-pi-ai",it="reasoningEffortsUnset",wt="inputUnset",at="inputImageGen",Mn="reasoningEffortsAutofilled",Ln="defaultEffort",na="/dsh-model-think-level/camouflage";var ra="/dsh-model-think-level/history-compat";var oa="/dsh-model-think-level/image-config";var ia=we;var hr=require("react");function Id(e){let{locale:t}=e,n=(0,hr.useCallback)(o=>t.subscribe(o),[t]),r=(0,hr.useCallback)(()=>t.getSnapshot().revision??0,[t]);return(0,hr.useSyncExternalStore)(n,r),e.children()}var Dd={reasoningEffort:"Reasoning effort",thinkingMode:"Thinking",thinkingModeOff:"Off \u2014 this model is declared as not reasoning.",levelsLabel:"Declared levels",levelsHint:"Click to declare; clear every level to declare nothing \u2014 requests follow the provider default.",stateDeclared:"{count} declared \xB7 default {default}",stateUndeclared:"Nothing declared \u2014 requests follow the provider default.",modalityText:"Text",autoAdapt:"Auto-adapt",autoAdaptAll:"Auto-detect thinking levels",autoAdaptWorking:"Detecting\u2026",autoAdaptDone:"Adapted {count} \xB7 save to write",autoAdaptEmpty:"All already configured",autoAdaptUnsuggested:"No suggestion available",autoAdaptBlocked:"No models to adapt yet",autoAdaptFailed:"Detection failed: {message}",autoAdaptDoneHint:"Held for {count} model(s): they land when this card is saved.",autoAdaptEmptyHint:"Every model of this provider already declares its thinking levels.",autoAdaptUnsuggestedHint:"The models that still need a declaration have no knowledge-base match \u2014 adapt them one by one.",autoAdaptBlockedHint:"Nothing to adapt yet: the card has no models, is not saved, or the settings document is read-only.",apply:"Apply",reset:"Reset",referenceTitle:"Reference capacities",contextWindowLabel:"Context window",maxTokensLabel:"Max output",capacityBlank:"Catalogue value",capacityUnitsHint:"Digits or K/M/B/T shorthand, e.g. 1,048,576 or 1M.",capacityRule:"Max output above the window is refused upstream; this check is local only.",tokensUnit:"tokens",inputModality:"Supported modalities",modalityImage:"Image",modalityImageGen:"Image generation",modalityImageGenHint:"Marked as an image generator \u2014 pick it in the composer, type a prompt, and the send goes straight to the images API.",modalityInherit:"Not declared \u2014 the provider default applies (usually text-only).",modalityDeclared:"Declared \u2014 clearing Image goes back to text only.",capacityInherit:"Empty keeps the catalogue value.",clearDeclaration:"Clear declaration",noSuggestion:"No suggestion is available for this model.",writeError:"Failed: {message}",renderFailed:"Reasoning-effort editor failed to render",wirePlaceholder:"Wire value",wireValue:"value",wireShow:"Edit wire values",wireHide:"Hide wire values",wireHint:"Empty keeps the level's conventional spelling; a non-empty off value is what gets sent when thinking is closed.",reasoningDisabled:"No reasoning-effort control declared for this model (false) \u2014 do not arm thinking levels.",bareHint:"Clearing every level removes the declaration \u2014 requests go out bare (provider default), which some relays require.",defaultRiskDisabled:"No off level: Default and provider tests send thinking: disabled, which this model rejects (e.g. 1210).",defaultRiskQwen:"No off level: Default sends enable_thinking: false \u2014 only fails where the upstream requires thinking on.",stagedHint:"Not saved yet. Staged settings are applied automatically once the model is saved.",level_off:"off",level_minimal:"minimal",level_low:"low",level_medium:"medium",level_high:"high",level_xhigh:"xhigh",level_max:"max",sliderToggleTitle:"Model and reasoning-effort rows",sliderToggleDescription:"Show the model row and the reasoning-level chips in the model menu; the levels follow the current model.",sliderToggleAria:"Enable the model and reasoning-effort rows",settingOn:"On",settingOff:"Off",sliderNoLevels:"The current model exposes no reasoning-effort levels.",triggerFallback:"Select model",effortDefault:"Default",modelRowLabel:"Model",effortRowLabel:"Reasoning level",tagVision:"Image input",tagThinking:"Sends thinking levels",tagImageGen:"Image generation model",sliderNoCurrent:"No model selected.",sliderCommitSlow:"The switch is taking too long \u2014 try again.",defaultEffortLabel:"Default effort",defaultEffortUnset:"Follow memory",defaultEffortHint:"The level new sessions start at; a level you pick by hand always wins. Empty follows memory.",followMemory:"Follow memory",clearDefaultEffort:"Clear pick",modelSearchPlaceholder:"Search models\u2026",modelSearchNoMatches:"No matching models",modelSearchClear:"Clear search",modelSearchFailed:"Model search failed to render",editorTabsLabel:"Editor sections",editorTabProvider:"Provider",editorTabModels:"Models",editorTabAdvanced:"Advanced",editorTabFingerprint:"Fingerprint",fpTitle:"Model fingerprint",fpIntro:"Only GPT and Claude models can be probed \u2014 the fingerprint library covers those two families, and models outside it never appear here.",fpCount:"{count} probeable",fpSummary:"Identified {identified} \xB7 doubtful {doubtful} \xB7 failed {failed}",fpSummaryNone:"Nothing checked yet.",fpRunning:"Checking \xB7 {done} / {total} (keeps going if you leave)",fpDetectAll:"Check all",fpDetect:"Check",fpRetest:"Re-check",fpRetry:"Retry",fpCost:"{count} prompts \xB7 about {seconds}s",fpCostMinutes:"{count} prompts \xB7 about {minutes} min",fpCostUnknown:"{count} prompts",fpForget:"Forget",fpStateUnchecked:"Not checked",fpStateRunning:"Checking \xB7 {done}/{total}",fpStateIdentified:"{model} \xB7 {probability}",fpStateDoubtful:"Doubtful \xB7 {probability}",fpStateFailed:"Check failed",fpQueued:"Queued \xB7 #{position}",fpEvidence:"{used} / {total} prompts",fpSimilarity:"Similarity",fpDetailShow:"Show result",fpDetailHide:"Hide result",fpFamily:"Family",fpChallengeCounted:"Q{index} {numbers} \xB7 counted",fpChallengeRejected:"Q{index} {parsed}/{numbers} \xB7 not counted",fpChallengeSkipped:"Q{index} {numbers} \xB7 early stop",fpChallengeTitle:"How each of the three prompts settled. The number is how many integers the prompt asked for; a slash means it asked for the right-hand count and answered only the left. A prompt only counts when it returns at least max(80, 55% of what it asked).",fpCandidates:"Closest candidates",fpClosedSet:"Closed-set result: a model outside the library is still attributed to the nearest listed one. Read it as a comparison, not a certificate.",fpCheckedAt:"Checked {time}",fpTiming:"Timing: first token {first}s \xB7 total {total}s \xB7 ~{rate} chars/s",fpLoadFailed:"Could not read the stored verdicts: {error}",fpRunFailed:"Check failed: {error}",keyRevealShow:"Show key",keyRevealHide:"Hide key",keyRevealFailed:"Stored key unavailable",keysLoading:"Loading keys\u2026",keysAdd:"Add another key",keysAddConfirm:"Add",keysEnable:"Enable {name}",keysDisable:"Disable {name}",keysMissing:"Not stored",keysEdit:"Edit",keysRemove:"Delete",keysConfirmRemove:"Confirm delete",keysCancel:"Cancel",keysSave:"Save",keysAlias:"Label",keysAliasPlaceholder:"Name (optional), e.g. Team",keysValue:"Key",keysValuePlaceholder:"Paste the API key",keysNewValuePlaceholder:"Paste the new API key",keysAddIllegal:"A key is printable ASCII without spaces.",keysAdded:"Key stored.",keysRenamed:"Label saved.",keysReplaced:"Key replaced.",keysRemoved:"Key removed.",keysCopy:"Copy {name}",keysCopied:"Key copied.",keysCopyFailed:"Could not copy the key.",keysScope:"Models served by {name}",keysModels:"Models",keysScopeAll:"All models",keysScopeNone:"No models found",keysScopeCount:"{count} models",keysScopeSaved:"Model scope saved.",keysScopeHint:"Only the ticked models use this key; the rest go to the provider's other keys.",keysScopeAutoHint:"This scope was written by the auto-probe from the models this key actually lists; every sweep re-checks it.",keysProbe:"Auto-probe",keysProbing:"Probing\u2026",keysProbeHint:`Ask every key what it actually serves, then keep each key to the models it shares with this provider's list. A key that serves every added model keeps "All models"; a key that serves none of them is switched off.`,keysProbeSingle:"One key has nothing to divide \u2014 add a second key first.",keysProbeDone:"Probe finished \u2014 scopes checked against what each key serves.",keysScopeEmpty:"This provider has no models yet. Add models first, then pick them here.",keysProtocolLabel:"Protocol for {name}",keysProtocolCreate:"Protocol",keysProtocolCreateHint:"The wire this key signs with; the addresses the provider has configured decide which families are offered.",keysProtocolDefault:"Auto (per model)",keysProtocolDefaultHint:"Picks each model\u2019s own wire: claude models use the Anthropic address, the rest the provider\u2019s protocol (where that address is configured).",keysProtocolAnthropic:"Anthropic",keysProtocolAnthropicHint:"Anthropic API \xB7 Claude models",keysProtocolOpenAI:"Chat Completions",keysProtocolOpenAIHint:"OpenAI API \xB7 GPT models, most agents",keysProtocolResponses:"Responses",keysProtocolResponsesHint:"OpenAI API \xB7 Codex",keysProtocolShortChat:"Chat",keysProtocolShortResponses:"Responses",keysProtocolShortAnthropic:"Anthropic",keysProtocolSaved:"Protocol saved.",keysEndpointOpenAI:"OpenAI",keysEndpointAnthropic:"Anthropic",keysEndpointBalance:"Balance",keysEndpointBalanceHint:"Read-only endpoint queried for this provider\u2019s balance; the first API key is sent along.",keysMoreEndpoints:"More endpoints",keysEndpointsCount:"{count} more",keysEndpointInvalid:"The address must start with http:// or https://",keysUnreachable:"The plugin\u2019s key route did not answer.",keysPanelFailed:"Key manager failed to render",keysDraftHint:"Held by this page and stored when the provider is created \u2014 a reload discards them, exactly like the card\u2019s own fields.",keysLastEnabledOff:"The last enabled key cannot be switched off.",headersTitle:"Request headers",headersHint:"Sent on every request of this route.",camouflageTitle:"Request disguise",camouflageHint:"Sends this route\u2019s requests as the official CLI of the vendor you pick: its client headers, and for Claude the identity system prompt and user id its validator looks for. Off by default.",camouflageOff:"Off",camouflageCodex:"Codex",camouflageClaude:"Claude",camouflageSaved:"Disguise saved.",camouflageError:"The plugin\u2019s disguise endpoint did not answer.",camouflageUnavailable:"The request interception is not installed, so this switch has no effect.",historyCompatTitle:"Old-topic recovery",historyCompatHint:"When the relay answers that this topic was created under a different upstream resource, replay the request with the foreign-looking history removed instead of failing the turn. Off by default.",historyCompatCost:"Only on that refusal, and at most two extra upstream calls.",historyCompatOff:"Off",historyCompatOn:"On",historyCompatUnavailable:"The request interception is not installed, so this switch has no effect.",headersEmpty:"No extra request headers are configured.",headersAdd:"Add header",headersName:"Name",headersNamePlaceholder:"e.g. x-company",headersValue:"Value",headersEdit:"Edit",headersSave:"Save",headersCancel:"Cancel",headersClear:"Clear all",headersRemove:"Remove header",headersSaved:"Saved.",headersCleared:"Cleared \u2014 this route sends no extra request headers.",headersReadOnly:"The settings document is not writable.",headersConflictOrigin:"Routes sharing one endpoint declare different request-header values: when the model in a request body does not identify exactly one of them, that request falls back to the first route.",headersConflictPatched:"The installed dsh-llm-pi-ai already carries a request-header patch: enter values in the headers above and this plugin need not take the request layer over.",headersConflictSiblings:"A plugin rewriting the same layer is installed: {names}. Only one user-agent rewrite should be active at a time, or the last writer on the wire wins.",headersError:"Save failed: {error}",headersNoRoute:"This route is no longer in the settings document \u2014 save the official card once first.",providerReorderAria:"Reorder {provider}",providerReorderHint:"Drag to set the provider order \u2014 the model switcher follows it.",providerToggleAria:"Enable {provider}",providerToggleHint:"A disabled provider is not listed by the model switcher.",providerBalanceLabel:"Balance",providerBalanceHint:"Fetched from this provider\u2019s balance endpoint.",providerBalanceRefresh:"Refresh balance",providerBalanceUnavailable:"Balance \u2014",providerDisabledGroupShow:"Show {count} switched-off provider(s)",providerDisabledGroupHide:"Hide {count} switched-off provider(s)",providerDisabledGroupHint:"A switched-off provider keeps its configuration and folds away here \u2014 unfold it to switch it back on.",providerRemoveDisabled:"Delete",providerRemoveLocked:"A built-in provider cannot be deleted.",modelReorderAria:"Reorder {model}",modelReorderHint:"Drag to set the order of this provider\u2019s models \u2014 the model switcher follows it.",configButton:"Advanced settings",configButtonHint:"Open advanced settings",configPaneTitle:"Advanced settings",configPaneClose:"Close",configPaneFailed:"Config pane failed to render",imagegenSectionTitle:"Image generation",imagegenEnable:"Enable image generation",cardStateOn:"On",cardStateOff:"Off",imagegenEnabledHint:"Allow the image-generation tool. Expand to configure the model and image parameters.",imagegenDisabledHint:"The image-generation tool is off. Your model and image settings are kept.",imagegenExpand:"Configure image generation",imagegenCollapse:"Collapse image-generation settings",imagegenSaving:"Saving\u2026",imagegenRefreshFailed:"Saved, but could not refresh the configuration: {error}",imagegenLoading:"Loading\u2026",imagegenLoadFailed:"Could not read the image config",imagegenDefaultsLabel:"Defaults",imagegenDefaultModelLabel:"Default model",imagegenDefaultModelNone:"Not set",imagegenSizeLabel:"Size",imagegenQualityLabel:"Quality",imagegenCountLabel:"Count",imagegenTimeoutLabel:"Timeout",imagegenTimeoutMinutes:"{minutes} min",imagegenTimeoutHint:"The per-request cap; every retry of the parameter fallback chain gets this budget too.",imagegenCardRunning:"Generating image\u2026",imagegenToolMissing:"The built-in image tool is not registered, so a model cannot call it.",imagegenToolMissingWhy:"Host said: {reason}",autoContinueSectionTitle:"Auto-continue",autoContinueExpand:"Configure auto-continue",autoContinueCollapse:"Collapse auto-continue settings",autoContinueTitle:"Continue interrupted turns",autoContinueDescription:"When a turn is cut off by a disconnect, a timeout or the output limit, reply \u201CContinue\u201D automatically. Clean finishes, your own stops and auth or quota errors are left alone.",autoContinueHint:"Wait {seconds}s after a failure \xB7 Up to {count} retries",autoContinueWaitLabel:"Wait after failure",autoContinueRetriesLabel:"Retry limit",autoContinueSecondsUnit:"s",autoContinueRetriesUnit:"retries",autoContinueConfigHint:"Whole numbers: {waitMin}\u2013{waitMax} seconds, {retriesMin}\u2013{retriesMax} retries. Saved when you leave the field or press Enter. After every failure, wait this long before sending \u201CContinue\u201D; a longer provider-requested delay wins.",autoContinueAria:"Enable auto-continue",autoContinueMessage:"Continue",autoContinueTriggers:"Triggers",autoContinueRestore:"Restore defaults",autoContinueMaxTokens:"Output token ceiling",autoContinueHttpStatus:"HTTP 408 / 425 / 429 / 5xx",autoContinueErrorTypes:"Error types",autoContinueCodesMore:"+{count}",autoContinueCodesAll:"All",autoContinueCodesNone:"None",autoContinueGroupTransient:"Transient \u2014 usually clears on retry",autoContinueGroupOther:"Request/config problem \u2014 the same send likely fails again",autoContinueGroupFlags:"Built-in triggers",autoContinueWhyMaxTokens:"The reply hit the output ceiling and was cut off",autoContinueWhyHttpStatus:"Gateway or provider answered 408 \xB7 425 \xB7 429 \xB7 5xx",autoContinueChipHttp:"HTTP 5xx",autoContinueTagContinue:"Worth retrying",autoContinueTagUseless:"Won't help",autoContinueTagDepends:"Depends",autoContinueWhyEMPTY_RESPONSE:"Upstream returned an empty body \u2014 stream truncated or reasoning timed out",autoContinueWhyRATE_LIMIT:"Provider rate limit (429) \u2014 too fast or too many concurrent calls",autoContinueWhySERVER:"Provider 5xx, or the gateway downstream is briefly unreachable",autoContinueWhyTIMEOUT:"No new token for too long \u2014 killed by the idle timeout",autoContinueWhyTRANSPORT:"Connection dropped mid-stream \u2014 network blip or proxy reset",autoContinueWhyPI_AI_ERROR:"Provider business error: content filter, Azure resource mismatch",autoContinueWhyINVALID_REQUEST:"Bad request (400/413): context over the window, bad parameters",autoContinueWhyAUTH:"Invalid key, no permission, or quota exhausted (401/403)",autoContinueWhyLEGACY_CLI_OUTCOME_UNKNOWN:"The old CLI never recorded the outcome",autoContinueWhyUNSUPPORTED_REASONING_EFFORT:"This model does not support the current reasoning effort",autoContinueWhyMALFORMED_RESPONSE:"Model output or tool-call JSON was malformed \u2014 regenerating may help",autoContinueWhyUNKNOWN_MODEL:"This model name is not configured at the provider",autoContinueControllerWaiting:"Retry {n}/{max} \xB7 {seconds}s",autoContinueControllerSent:"Sent \u201CContinue\u201D \xB7 retry {n}/{max}",autoContinueControllerExhausted:"Stood down after {max} tries",autoContinueControllerStop:"Stop",autoContinueControllerResume:"Continue now",autoContinueControllerReset:"Reset",autoContinueControllerSettings:"Settings\u2026",autoContinueControllerAria:"Auto-continue status",autoContinueControllerDetail:"Last interruption: {detail}",errorDetailSectionTitle:"Failure details",errorDetailSummary:"A details seat on failed turns",errorDetailHint:"Adds a \u201CView details\u201D seat to a failed turn. It shows what the provider actually answered \u2014 status, code, reason, traceId \u2014 instead of the fixed label.",errorDetailAria:"Show the real failure details",errorDetailButton:"View details",errorDetailTitle:"Turn failure details",errorDetailClose:"Close",errorDetailReason:"Actual reason",errorDetailTrace:"traceId",errorDetailCode:"DSH code",errorDetailShown:"UI showed",errorDetailRaw:"Upstream response",errorDetailCopy:"Copy",errorDetailCopied:"Copied",errorDetailCopyRaw:"Copy raw",errorDetailSource:"Read from the session\u2019s turn/end event, unwrapped by DSH",errorDetailUnwrapped:"shown as-is (not wrapped)",errorDetailFixedLabel:"fixed label, hiding the real reason"},Pd={reasoningEffort:"\u601D\u8003\u5F3A\u5EA6",thinkingMode:"\u601D\u8003",thinkingModeOff:"\u5DF2\u5173\u95ED\u2014\u2014\u8BE5\u6A21\u578B\u58F0\u660E\u4E3A\u4E0D\u601D\u8003\u3002",levelsLabel:"\u652F\u6301\u6863\u4F4D",levelsHint:"\u70B9\u9009\u5373\u58F0\u660E\uFF1B\u5168\u90E8\u53D6\u6D88\u5219\u4E0D\u58F0\u660E\uFF0C\u8BF7\u6C42\u6309\u4F9B\u5E94\u5546\u9ED8\u8BA4\u53D1\u9001\u3002",stateDeclared:"\u5DF2\u58F0\u660E {count} \u6863 \xB7 \u9ED8\u8BA4 {default}",stateUndeclared:"\u672A\u58F0\u660E\u2014\u2014\u8BF7\u6C42\u6309\u4F9B\u5E94\u5546\u9ED8\u8BA4\u53D1\u9001\u3002",modalityText:"\u6587\u672C",autoAdapt:"\u81EA\u52A8\u9002\u914D",autoAdaptAll:"\u81EA\u52A8\u83B7\u53D6\u601D\u8003\u7B49\u7EA7",autoAdaptWorking:"\u83B7\u53D6\u4E2D\u2026",autoAdaptDone:"\u5DF2\u9002\u914D {count} \u4E2A\xB7\u4FDD\u5B58\u540E\u5199\u5165",autoAdaptEmpty:"\u5DF2\u5168\u90E8\u914D\u7F6E",autoAdaptUnsuggested:"\u6CA1\u6709\u53EF\u7528\u5EFA\u8BAE",autoAdaptBlocked:"\u6682\u65E0\u53EF\u9002\u914D\u6A21\u578B",autoAdaptFailed:"\u83B7\u53D6\u5931\u8D25\uFF1A{message}",autoAdaptDoneHint:"\u5DF2\u6682\u5B58 {count} \u4E2A\u6A21\u578B\u7684\u9002\u914D\u7ED3\u679C\uFF1A\u70B9\u8BE5\u5361\u7247\u7684\u300C\u4FDD\u5B58\u300D\u540E\u5199\u5165\u3002",autoAdaptEmptyHint:"\u8BE5\u4F9B\u5E94\u5546\u4E0B\u6240\u6709\u6A21\u578B\u90FD\u5DF2\u58F0\u660E\u601D\u8003\u7B49\u7EA7\u3002",autoAdaptUnsuggestedHint:"\u4ECD\u9700\u58F0\u660E\u7684\u6A21\u578B\u6CA1\u6709\u77E5\u8BC6\u5E93\u5339\u914D\u2014\u2014\u8BF7\u9010\u4E2A\u6253\u5F00\u6A21\u578B\u884C\u624B\u52A8\u9002\u914D\u3002",autoAdaptBlockedHint:"\u6682\u65E0\u53EF\u9002\u914D\u5185\u5BB9\uFF1A\u8BE5\u5361\u7247\u8FD8\u6CA1\u6709\u6A21\u578B\u3001\u5C1A\u672A\u4FDD\u5B58\uFF0C\u6216\u5F53\u524D\u8BBE\u7F6E\u6587\u6863\u4E0D\u53EF\u5199\u5165\u3002",apply:"\u5E94\u7528",reset:"\u653E\u5F03\u4FEE\u6539",referenceTitle:"\u53C2\u8003\u5BB9\u91CF",contextWindowLabel:"\u4E0A\u4E0B\u6587\u7A97\u53E3",maxTokensLabel:"\u6700\u5927\u8F93\u51FA",capacityBlank:"\u6CBF\u7528\u76EE\u5F55\u503C",capacityUnitsHint:"\u53EF\u586B\u6570\u5B57\u6216 K/M/B/T \u7B80\u5199\uFF0C\u4F8B\u5982 1,048,576 \u6216 1M\u3002",capacityRule:"\u6700\u5927\u8F93\u51FA\u8D85\u8FC7\u7A97\u53E3\u4F1A\u88AB\u4E0A\u6E38\u62D2\u7EDD\uFF0C\u8FD9\u91CC\u53EA\u505A\u672C\u5730\u6821\u9A8C\u3002",tokensUnit:"tokens",inputModality:"\u652F\u6301\u6A21\u6001",modalityImage:"\u56FE\u7247",modalityImageGen:"\u751F\u56FE",modalityImageGenHint:"\u5DF2\u6807\u8BB0\u4E3A\u751F\u56FE\u6A21\u578B\u2014\u2014\u5728\u5BF9\u8BDD\u6846\u9009\u4E2D\u5B83\u540E\u76F4\u63A5\u8F93\u5165\u63D0\u793A\u8BCD\u53D1\u9001\uFF0C\u5373\u8D70\u56FE\u7247\u63A5\u53E3\u751F\u6210\u56FE\u7247\u3002",modalityInherit:"\u672A\u58F0\u660E\u2014\u2014\u7EE7\u627F\u63D0\u4F9B\u65B9\u9ED8\u8BA4\uFF08\u901A\u5E38\u4EC5\u6587\u672C\uFF09\u3002",modalityDeclared:"\u5DF2\u58F0\u660E\u2014\u2014\u53D6\u6D88\u300C\u56FE\u7247\u300D\u5373\u56DE\u5230\u4EC5\u6587\u672C\u3002",capacityInherit:"\u7559\u7A7A\uFF1D\u6CBF\u7528\u6A21\u578B\u76EE\u5F55\u91CC\u7684\u503C\u3002",clearDeclaration:"\u6E05\u9664\u58F0\u660E",noSuggestion:"\u6CA1\u6709\u9002\u7528\u4E8E\u8BE5\u6A21\u578B\u7684\u5EFA\u8BAE\u3002",writeError:"\u5199\u5165\u5931\u8D25\uFF1A{message}",renderFailed:"\u601D\u8003\u5F3A\u5EA6\u7F16\u8F91\u5668\u6E32\u67D3\u5931\u8D25",wirePlaceholder:"\u7EBF\u4E0A\u53D6\u503C",wireValue:"\u53D6\u503C",wireShow:"\u7F16\u8F91\u7EBF\u4E0A\u53D6\u503C",wireHide:"\u6536\u8D77\u7EBF\u4E0A\u53D6\u503C",wireHint:"\u7559\u7A7A\uFF1D\u6CBF\u7528\u8BE5\u6863\u4F4D\u7684\u7EA6\u5B9A\u62FC\u5199\uFF1Boff \u6863\u586B\u4E86\u975E\u7A7A\u503C\uFF0C\u5C31\u4F1A\u5728\u5173\u95ED\u601D\u8003\u65F6\u53D1\u9001\u8FD9\u4E00\u6BB5\u3002",reasoningDisabled:"\u8BE5\u6A21\u578B\u58F0\u660E\u4E3A\u65E0 reasoning-effort \u63A7\u5236\uFF08false\uFF09\u2014\u2014\u8BF7\u52FF\u52FE\u9009\u601D\u8003\u6863\u3002",bareHint:"\u5168\u90E8\u53D6\u6D88\u5E76\u4FDD\u5B58\u5C06\u6E05\u9664\u58F0\u660E\u2014\u2014\u8BF7\u6C42\u4EE5\u88F8\u683C\u5F0F\u53D1\u51FA\uFF08\u8D70\u63D0\u4F9B\u65B9\u9ED8\u8BA4\uFF09\uFF0C\u90E8\u5206\u4E2D\u8F6C\u7AD9\u9700\u8981\u8FD9\u6837\u3002",defaultRiskDisabled:"\u65E0 off \u6863\uFF1ADefault \u4E0E\u63D0\u4F9B\u5546\u6D4B\u8BD5\u4F1A\u53D1\u9001 thinking: disabled\uFF0C\u8BE5\u6A21\u578B\u4F1A\u62A5\u9519\uFF08\u5982 1210\uFF09\u3002",defaultRiskQwen:"\u65E0 off \u6863\uFF1ADefault \u4F1A\u53D1\u9001 enable_thinking: false\u2014\u2014\u4EC5\u5728\u4E0A\u6E38\u8981\u6C42\u5F00\u542F\u601D\u8003\u65F6\u624D\u4F1A\u5931\u8D25\u3002",stagedHint:"\u5C1A\u672A\u4FDD\u5B58\u3002\u6682\u5B58\u7684\u914D\u7F6E\u5C06\u5728\u8BE5\u6A21\u578B\u4FDD\u5B58\u540E\u81EA\u52A8\u5E94\u7528\u3002",level_off:"off",level_minimal:"minimal",level_low:"low",level_medium:"medium",level_high:"high",level_xhigh:"xhigh",level_max:"max",sliderToggleTitle:"\u6A21\u578B\u4E0E\u601D\u8003\u7B49\u7EA7\u884C",sliderToggleDescription:"\u5728\u6A21\u578B\u83DC\u5355\u4E2D\u663E\u793A\u6A21\u578B\u884C\u4E0E\u601D\u8003\u7B49\u7EA7\u6807\u7B7E\uFF0C\u6863\u4F4D\u968F\u5F53\u524D\u6A21\u578B\u81EA\u52A8\u9002\u914D",sliderToggleAria:"\u542F\u7528\u6A21\u578B\u4E0E\u601D\u8003\u7B49\u7EA7\u884C",settingOn:"\u542F\u7528",settingOff:"\u505C\u7528",sliderNoLevels:"\u5F53\u524D\u6A21\u578B\u672A\u63D0\u4F9B\u601D\u8003\u5F3A\u5EA6\u6863\u4F4D",triggerFallback:"\u9009\u62E9\u6A21\u578B",effortDefault:"\u9ED8\u8BA4",modelRowLabel:"\u6A21\u578B",effortRowLabel:"\u601D\u8003\u7B49\u7EA7",tagVision:"\u652F\u6301\u56FE\u7247\u8F93\u5165",tagThinking:"\u652F\u6301\u601D\u8003\u7B49\u7EA7",tagImageGen:"\u751F\u56FE\u6A21\u578B",sliderNoCurrent:"\u5F53\u524D\u65E0\u9009\u62E9\u4E2D\u7684\u6A21\u578B\u3002",sliderCommitSlow:"\u5207\u6362\u8D85\u65F6\u2014\u2014\u8BF7\u91CD\u8BD5\u3002",defaultEffortLabel:"\u9ED8\u8BA4\u601D\u8003\u5F3A\u5EA6",defaultEffortUnset:"\u8DDF\u968F\u8BB0\u5FC6",defaultEffortHint:"\u65B0\u4F1A\u8BDD\u7684\u8D77\u59CB\u6863\u4F4D\uFF1B\u4F1A\u8BDD\u5185\u624B\u52A8\u9009\u62E9\u59CB\u7EC8\u4F18\u5148\u3002\u7559\u7A7A\u5219\u8DDF\u968F\u8BB0\u5FC6\u94FE\u3002",followMemory:"\u8DDF\u968F\u8BB0\u5FC6",clearDefaultEffort:"\u6E05\u9664\u9009\u62E9",modelSearchPlaceholder:"\u641C\u7D22\u6A21\u578B\u2026",modelSearchNoMatches:"\u672A\u627E\u5230\u5339\u914D\u6A21\u578B",modelSearchClear:"\u6E05\u7A7A\u641C\u7D22",modelSearchFailed:"\u6A21\u578B\u641C\u7D22\u6E32\u67D3\u5931\u8D25",editorTabsLabel:"\u7F16\u8F91\u5668\u5206\u533A",editorTabProvider:"\u4F9B\u5E94\u5546\u914D\u7F6E",editorTabModels:"\u6A21\u578B\u914D\u7F6E",editorTabAdvanced:"\u9AD8\u7EA7\u914D\u7F6E",editorTabFingerprint:"\u6307\u7EB9\u68C0\u6D4B",fpTitle:"\u6A21\u578B\u6307\u7EB9",fpIntro:"\u53EA\u6709 GPT \u4E0E Claude \u7CFB\u5217\u6A21\u578B\u53EF\u68C0\u6D4B\u2014\u2014\u6307\u7EB9\u5E93\u53EA\u8986\u76D6\u8FD9\u4E24\u4E2A\u5BB6\u65CF\uFF0C\u4E0D\u5728\u6B64\u5217\u7684\u6A21\u578B\u4E0D\u4F1A\u51FA\u73B0\u5728\u8FD9\u91CC\u3002",fpCount:"{count} \u4E2A\u53EF\u68C0\u6D4B",fpSummary:"\u5DF2\u8BC6\u522B {identified} \xB7 \u5B58\u7591 {doubtful} \xB7 \u5931\u8D25 {failed}",fpSummaryNone:"\u5C1A\u672A\u68C0\u6D4B\u3002",fpRunning:"\u6B63\u5728\u68C0\u6D4B \xB7 {done} / {total}\uFF08\u5207\u8D70\u4E5F\u4F1A\u7EE7\u7EED\uFF09",fpDetectAll:"\u68C0\u6D4B\u5168\u90E8",fpDetect:"\u68C0\u6D4B",fpRetest:"\u91CD\u6D4B",fpRetry:"\u91CD\u8BD5",fpCost:"{count} \u9898 \xB7 \u7EA6 {seconds} \u79D2",fpCostMinutes:"{count} \u9898 \xB7 \u7EA6 {minutes} \u5206\u949F",fpCostUnknown:"{count} \u9898",fpForget:"\u5FD8\u6389",fpStateUnchecked:"\u672A\u68C0\u6D4B",fpStateRunning:"\u68C0\u6D4B\u4E2D \xB7 {done}/{total}",fpStateIdentified:"{model} \xB7 {probability}",fpStateDoubtful:"\u5B58\u7591 \xB7 {probability}",fpStateFailed:"\u68C0\u6D4B\u5931\u8D25",fpQueued:"\u6392\u961F \xB7 \u7B2C {position} \u4E2A",fpEvidence:"{used} / {total} \u9898",fpSimilarity:"\u76F8\u4F3C\u5EA6",fpDetailShow:"\u5C55\u5F00\u7ED3\u679C",fpDetailHide:"\u6536\u8D77\u7ED3\u679C",fpFamily:"\u5BB6\u65CF",fpChallengeCounted:"\u9898{index} {numbers} \u4E2A \xB7 \u8BA1\u5165",fpChallengeRejected:"\u9898{index} {parsed}/{numbers} \xB7 \u672A\u8BA1\u5165",fpChallengeSkipped:"\u9898{index} {numbers} \u4E2A \xB7 \u65E9\u505C",fpChallengeTitle:"\u4E09\u9053\u9898\u5404\u81EA\u7684\u843D\u70B9\u3002\u6570\u5B57\u662F\u8FD9\u9898\u8981\u6C42\u7684\u6574\u6570\u4E2A\u6570\uFF1B\u6709\u659C\u6760\u65F6\uFF0C\u53F3\u8FB9\u662F\u8981\u6C42\u6570\u3001\u5DE6\u8FB9\u662F\u5B9E\u9645\u7B54\u56DE\u7684\u4E2A\u6570\u3002\u7B54\u56DE\u4E0D\u5230 max(80, \u8981\u6C42\u6570\u7684 55%) \u5C31\u4E0D\u8BA1\u5165\u3002",fpCandidates:"\u6700\u63A5\u8FD1\u7684\u5019\u9009",fpClosedSet:"\u95ED\u96C6\u7ED3\u8BBA\uFF1A\u4E0D\u5728\u5E93\u91CC\u7684\u6A21\u578B\u4ECD\u4F1A\u88AB\u5F52\u7ED9\u6700\u63A5\u8FD1\u7684\u90A3\u4E2A\u3002\u8BF7\u5F53\u6210\u4E00\u6B21\u6BD4\u5BF9\uFF0C\u4E0D\u662F\u8BC1\u660E\u3002",fpCheckedAt:"\u68C0\u6D4B\u4E8E {time}",fpTiming:"\u8017\u65F6\uFF1A\u9996\u5B57 {first} \u79D2 \xB7 \u603B\u8BA1 {total} \u79D2 \xB7 \u5410\u5B57\u7EA6 {rate} \u5B57\u7B26/\u79D2",fpLoadFailed:"\u8BFB\u4E0D\u5230\u5DF2\u5B58\u7ED3\u8BBA\uFF1A{error}",fpRunFailed:"\u68C0\u6D4B\u5931\u8D25\uFF1A{error}",keyRevealShow:"\u663E\u793A\u5BC6\u94A5",keyRevealHide:"\u9690\u85CF\u5BC6\u94A5",keyRevealFailed:"\u65E0\u6CD5\u8BFB\u53D6\u5DF2\u4FDD\u5B58\u7684\u5BC6\u94A5",keysLoading:"\u6B63\u5728\u8BFB\u53D6\u5BC6\u94A5\u2026",keysAdd:"\u6DFB\u52A0\u53E6\u4E00\u4E2A\u5BC6\u94A5",keysAddConfirm:"\u6DFB\u52A0",keysEnable:"\u542F\u7528 {name}",keysDisable:"\u505C\u7528 {name}",keysMissing:"\u672A\u5B58\u50A8",keysEdit:"\u4FEE\u6539",keysRemove:"\u5220\u9664",keysConfirmRemove:"\u786E\u8BA4\u5220\u9664",keysCancel:"\u53D6\u6D88",keysSave:"\u4FDD\u5B58",keysAlias:"\u522B\u540D",keysAliasPlaceholder:"\u540D\u79F0\uFF08\u53EF\u9009\uFF09\uFF0C\u4F8B\u5982 \u56E2\u961F",keysValue:"\u5BC6\u94A5",keysValuePlaceholder:"\u7C98\u8D34 API \u5BC6\u94A5",keysNewValuePlaceholder:"\u7C98\u8D34\u65B0\u7684 API \u5BC6\u94A5",keysAddIllegal:"\u5BC6\u94A5\u53EA\u80FD\u662F\u53EF\u6253\u5370 ASCII \u5B57\u7B26\uFF0C\u4E14\u4E0D\u80FD\u5305\u542B\u7A7A\u683C\u3002",keysAdded:"\u5DF2\u4FDD\u5B58\u5BC6\u94A5\u3002",keysRenamed:"\u5DF2\u4FDD\u5B58\u522B\u540D\u3002",keysReplaced:"\u5DF2\u66FF\u6362\u5BC6\u94A5\u3002",keysRemoved:"\u5DF2\u5220\u9664\u5BC6\u94A5\u3002",keysCopy:"\u590D\u5236 {name}",keysCopied:"\u5DF2\u590D\u5236\u5BC6\u94A5\u3002",keysCopyFailed:"\u65E0\u6CD5\u590D\u5236\u5BC6\u94A5\u3002",keysScope:"{name} \u63D0\u4F9B\u670D\u52A1\u7684\u6A21\u578B",keysModels:"\u6A21\u578B",keysScopeAll:"\u5168\u90E8\u6A21\u578B",keysScopeNone:"\u672A\u53D1\u73B0\u6A21\u578B",keysScopeCount:"{count} \u4E2A\u6A21\u578B",keysScopeSaved:"\u5DF2\u4FDD\u5B58\u6A21\u578B\u8303\u56F4\u3002",keysScopeHint:"\u53EA\u6709\u9009\u4E2D\u7684\u6A21\u578B\u4F1A\u7528\u8FD9\u4E2A Key\uFF0C\u5176\u4ED6\u6A21\u578B\u4EA4\u7ED9\u8BE5\u4F9B\u5E94\u5546\u7684\u5176\u4ED6 Key\u3002",keysScopeAutoHint:"\u8FD9\u4E2A\u8303\u56F4\u7531\u81EA\u52A8\u63A2\u6D4B\u6309\u8FD9\u628A\u5BC6\u94A5\u5B9E\u9645\u63D0\u4F9B\u7684\u6A21\u578B\u5199\u5165\uFF0C\u6BCF\u6B21\u63A2\u6D4B\u90FD\u4F1A\u91CD\u65B0\u6821\u51C6\u3002",keysProbe:"\u81EA\u52A8\u63A2\u6D4B",keysProbing:"\u63A2\u6D4B\u4E2D\u2026",keysProbeHint:"\u63A2\u6D4B\u6BCF\u628A\u5BC6\u94A5\u5B9E\u9645\u63D0\u4F9B\u54EA\u4E9B\u6A21\u578B\uFF0C\u628A\u6BCF\u628A\u5BC6\u94A5\u9650\u5B9A\u5728\u5B83\u4E0E\u672C\u4F9B\u5E94\u5546\u6A21\u578B\u5217\u8868\u7684\u4EA4\u96C6\u4E0A\uFF1A\u80FD\u63D0\u4F9B\u5168\u90E8\u5DF2\u6DFB\u52A0\u6A21\u578B\u65F6\u4FDD\u6301\u201C\u5168\u90E8\u6A21\u578B\u201D\uFF0C\u4E00\u4E2A\u90FD\u4E0D\u63D0\u4F9B\u65F6\u5173\u95ED\u8FD9\u628A\u5BC6\u94A5\u3002",keysProbeSingle:"\u53EA\u6709\u4E00\u4E2A\u5BC6\u94A5\uFF0C\u65E0\u9700\u63A2\u6D4B\u2014\u2014\u5148\u6DFB\u52A0\u7B2C\u4E8C\u4E2A\u5BC6\u94A5\u3002",keysProbeDone:"\u63A2\u6D4B\u5B8C\u6210\uFF0C\u5DF2\u6309\u5404\u5BC6\u94A5\u5B9E\u9645\u652F\u6301\u7684\u6A21\u578B\u52FE\u9009\u3002",keysScopeEmpty:"\u8BE5\u4F9B\u5E94\u5546\u8FD8\u6CA1\u6709\u6A21\u578B\u3002\u8BF7\u5148\u6DFB\u52A0\u6A21\u578B\uFF0C\u518D\u6765\u8FD9\u91CC\u9009\u62E9\u3002",keysProtocolLabel:"{name} \u4F7F\u7528\u7684\u534F\u8BAE",keysProtocolCreate:"\u534F\u8BAE",keysProtocolCreateHint:"\u8FD9\u628A\u5BC6\u94A5\u8981\u8D70\u7684\u534F\u8BAE\uFF1B\u53EF\u9009\u54EA\u4E9B\u53D6\u51B3\u4E8E\u4F9B\u5E94\u5546\u5DF2\u914D\u7F6E\u7684\u7AEF\u70B9\u5730\u5740\u3002",keysProtocolDefault:"\u81EA\u52A8\uFF08\u6309\u6A21\u578B\uFF09",keysProtocolDefaultHint:"\u6309\u6A21\u578B\u81EA\u52A8\u9009\u62E9\u534F\u8BAE\uFF1Aclaude \u7CFB\u6A21\u578B\u8D70 Anthropic \u5730\u5740\uFF0C\u5176\u4F59\u6CBF\u7528\u8BE5\u4F9B\u5E94\u5546\u81EA\u5E26\u7684\u534F\u8BAE\uFF08\u9700\u5DF2\u914D\u7F6E\u5BF9\u5E94\u5730\u5740\uFF09",keysProtocolAnthropic:"Anthropic",keysProtocolAnthropicHint:"Anthropic API \xB7 Claude \u6A21\u578B",keysProtocolOpenAI:"Chat Completions",keysProtocolOpenAIHint:"OpenAI API \xB7 GPT \u6A21\u578B\u3001\u5927\u591A\u6570 agent",keysProtocolResponses:"Responses",keysProtocolResponsesHint:"OpenAI API \xB7 Codex",keysProtocolShortChat:"Chat",keysProtocolShortResponses:"Responses",keysProtocolShortAnthropic:"Anthropic",keysProtocolSaved:"\u5DF2\u4FDD\u5B58\u534F\u8BAE\u3002",keysEndpointOpenAI:"OpenAI",keysEndpointAnthropic:"Anthropic",keysEndpointBalance:"\u4F59\u989D",keysEndpointBalanceHint:"\u53EA\u8BFB\u63A5\u53E3\uFF1A\u7528\u4E8E\u8BFB\u53D6\u8BE5\u4F9B\u5E94\u5546\u4F59\u989D\uFF0C\u4F1A\u5E26\u4E0A\u5BC6\u94A5\u5217\u8868\u4E2D\u7684\u7B2C\u4E00\u628A\u5BC6\u94A5\u3002",keysMoreEndpoints:"\u66F4\u591A\u7AEF\u70B9",keysEndpointsCount:"\u53E6\u6709 {count} \u4E2A",keysEndpointInvalid:"\u5730\u5740\u9700\u4EE5 http:// \u6216 https:// \u5F00\u5934",keysUnreachable:"\u63D2\u4EF6\u7684\u5BC6\u94A5\u63A5\u53E3\u6CA1\u6709\u54CD\u5E94\u3002",keysPanelFailed:"\u5BC6\u94A5\u7BA1\u7406\u9762\u677F\u6E32\u67D3\u5931\u8D25",keysDraftHint:"\u5BC6\u94A5\u6682\u5B58\u5728\u672C\u9875\uFF0C\u521B\u5EFA\u4F9B\u5E94\u5546\u540E\u81EA\u52A8\u4FDD\u5B58\uFF1B\u5237\u65B0\u9875\u9762\u4F1A\u4E22\u5F03\uFF0C\u4E0E\u5361\u7247\u81EA\u8EAB\u8868\u5355\u4E00\u81F4\u3002",keysLastEnabledOff:"\u4E0D\u80FD\u505C\u7528\u6700\u540E\u4E00\u628A\u542F\u7528\u4E2D\u7684\u5BC6\u94A5\u3002",headersTitle:"\u8BF7\u6C42\u5934",headersHint:"\u8BE5\u8DEF\u7531\u7684\u6BCF\u4E2A\u8BF7\u6C42\u90FD\u4F1A\u643A\u5E26\u81EA\u5B9A\u4E49\u8BF7\u6C42\u5934\u3002",camouflageTitle:"\u8BF7\u6C42\u4F2A\u88C5",camouflageHint:"\u8BA9\u8BE5\u8DEF\u7531\u7684\u8BF7\u6C42\u4EE5\u6240\u9009\u5382\u5546\u5B98\u65B9 CLI \u7684\u8EAB\u4EFD\u53D1\u51FA\uFF1A\u643A\u5E26\u5176\u5BA2\u6237\u7AEF\u8BF7\u6C42\u5934\uFF0CClaude \u9884\u8BBE\u8FD8\u4F1A\u8865\u4E0A\u5BF9\u5E94\u6821\u9A8C\u6240\u9700\u7684\u8EAB\u4EFD\u7CFB\u7EDF\u63D0\u793A\u4E0E user_id\u3002\u9ED8\u8BA4\u5173\u95ED\u3002",camouflageOff:"\u5173\u95ED",camouflageCodex:"Codex",camouflageClaude:"Claude",camouflageSaved:"\u5DF2\u4FDD\u5B58\u4F2A\u88C5\u3002",camouflageError:"\u63D2\u4EF6\u7684\u4F2A\u88C5\u63A5\u53E3\u6CA1\u6709\u54CD\u5E94\u3002",camouflageUnavailable:"\u8BF7\u6C42\u62E6\u622A\u672A\u5B89\u88C5\uFF0C\u6B64\u5F00\u5173\u4E0D\u4F1A\u751F\u6548\u3002",historyCompatTitle:"\u65E7\u8BDD\u9898\u6062\u590D",historyCompatHint:"\u5F53\u4E2D\u8F6C\u63D0\u793A\u8BE5\u8BDD\u9898\u7531\u53E6\u4E00\u4E2A\u4E0A\u6E38\u8D44\u6E90\u521B\u5EFA\u65F6\uFF0C\u5728\u53D1\u9001\u526F\u672C\u91CC\u53BB\u6389\u7ED1\u5B9A\u65E7\u8D44\u6E90\u7684\u6807\u8BC6\uFF08\u5FC5\u8981\u65F6\u8FDE\u5386\u53F2\u63A8\u7406\u4E00\u8D77\uFF09\uFF0C\u518D\u91CD\u653E\u8FD9\u6B21\u8BF7\u6C42\uFF0C\u800C\u4E0D\u662F\u8BA9\u8BE5\u56DE\u5408\u76F4\u63A5\u5931\u8D25\u3002\u9ED8\u8BA4\u5173\u95ED\u3002",historyCompatCost:"\u540C\u65F6\u8BC6\u522B 400 \u4E0E 200 \u6D41\u5185\u5931\u8D25\uFF1B\u6700\u591A\u8FFD\u52A0\u4E24\u6B21\u4E0A\u6E38\u8C03\u7528\uFF0C\u5DF2\u8F93\u51FA\u7684\u56DE\u5408\u4E0D\u91CD\u653E\u3002",historyCompatOff:"\u5173\u95ED",historyCompatOn:"\u5F00\u542F",historyCompatUnavailable:"\u8BF7\u6C42\u62E6\u622A\u672A\u5B89\u88C5\uFF0C\u6B64\u5F00\u5173\u4E0D\u4F1A\u751F\u6548\u3002",headersEmpty:"\u5C1A\u672A\u914D\u7F6E\u989D\u5916\u8BF7\u6C42\u5934\u3002",headersAdd:"\u6DFB\u52A0\u8BF7\u6C42\u5934",headersName:"\u540D\u79F0",headersNamePlaceholder:"\u4F8B\u5982 x-company",headersValue:"\u503C",headersEdit:"\u7F16\u8F91",headersSave:"\u4FDD\u5B58",headersCancel:"\u53D6\u6D88",headersClear:"\u5168\u90E8\u6E05\u7A7A",headersRemove:"\u5220\u9664\u8BF7\u6C42\u5934",headersSaved:"\u5DF2\u4FDD\u5B58\u3002",headersCleared:"\u5DF2\u6E05\u7A7A\u2014\u2014\u8BE5\u8DEF\u7531\u4E0D\u518D\u643A\u5E26\u989D\u5916\u8BF7\u6C42\u5934\u3002",headersReadOnly:"\u5F53\u524D\u8BBE\u7F6E\u6587\u6863\u4E0D\u53EF\u5199\u5165\u3002",headersConflictOrigin:"\u540C\u4E00\u4E2A endpoint \u4E0A\u6709\u591A\u4E2A\u8DEF\u7531\u914D\u7F6E\u4E86\u4E0D\u540C\u7684\u8BF7\u6C42\u5934\u503C\uFF1A\u5F53\u8BF7\u6C42\u4F53\u91CC\u7684\u6A21\u578B\u65E0\u6CD5\u552F\u4E00\u5B9A\u4F4D\u5176\u4E2D\u4E00\u4E2A\u8DEF\u7531\u65F6\uFF0C\u8BE5\u8BF7\u6C42\u56DE\u9000\u5230\u7B2C\u4E00\u4E2A\u8DEF\u7531\u7684\u914D\u7F6E\u3002",headersConflictPatched:"\u68C0\u6D4B\u5230\u5B98\u65B9 dsh-llm-pi-ai \u5DF2\u5728\u8BF7\u6C42\u5C42\u5904\u7406\u8BF7\u6C42\u5934\uFF1A\u628A\u503C\u586B\u5728\u4E0A\u65B9\u8BF7\u6C42\u5934\u914D\u7F6E\u4E2D\u5373\u53EF\uFF0C\u65E0\u9700\u91CD\u590D\u63A5\u7BA1\u3002",headersConflictSiblings:"\u68C0\u6D4B\u5230\u4F1A\u6539\u5199\u540C\u4E00\u5C42\u7684\u540C\u7C7B\u63D2\u4EF6\uFF1A{names}\u3002\u540C\u4E00\u65F6\u95F4\u53EA\u5E94\u542F\u7528\u4E00\u79CD\u8BF7\u6C42\u5934\u6539\u5199\uFF0C\u5426\u5219\u7EBF\u4E0A\u751F\u6548\u7684\u662F\u6700\u540E\u5199\u5165\u8005\u3002",headersError:"\u4FDD\u5B58\u5931\u8D25\uFF1A{error}",headersNoRoute:"\u8BE5\u8DEF\u7531\u5DF2\u4E0D\u5728\u8BBE\u7F6E\u6587\u6863\u4E2D\u2014\u2014\u8BF7\u5148\u4FDD\u5B58\u4E00\u6B21\u5B98\u65B9\u5361\u7247\u3002",providerReorderAria:"\u62D6\u52A8\u6392\u5E8F\uFF1A{provider}",providerReorderHint:"\u62D6\u52A8\u8C03\u6574\u4F9B\u5E94\u5546\u987A\u5E8F\u2014\u2014\u6A21\u578B\u5207\u6362\u6309\u6B64\u987A\u5E8F\u663E\u793A\u3002",providerToggleAria:"\u542F\u7528 {provider}",providerToggleHint:"\u7981\u7528\u540E\u8BE5\u4F9B\u5E94\u5546\u4E0D\u5728\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u663E\u793A\u3002",providerBalanceLabel:"\u4F59\u989D",providerBalanceHint:"\u6765\u81EA\u8BE5\u4F9B\u5E94\u5546\u914D\u7F6E\u7684\u4F59\u989D\u63A5\u53E3\u3002",providerBalanceRefresh:"\u5237\u65B0\u4F59\u989D",providerBalanceUnavailable:"\u4F59\u989D \u2014",providerDisabledGroupShow:"\u5C55\u5F00 {count} \u4E2A\u5DF2\u7981\u7528\u7684\u4F9B\u5E94\u5546",providerDisabledGroupHide:"\u6536\u8D77 {count} \u4E2A\u5DF2\u7981\u7528\u7684\u4F9B\u5E94\u5546",providerDisabledGroupHint:"\u5DF2\u7981\u7528\u7684\u4F9B\u5E94\u5546\u914D\u7F6E\u4ECD\u5728\uFF0C\u53EA\u662F\u6298\u53E0\u5728\u8FD9\u91CC\u2014\u2014\u5C55\u5F00\u540E\u53EF\u4EE5\u91CD\u65B0\u542F\u7528\u3002",providerRemoveDisabled:"\u5220\u9664",providerRemoveLocked:"\u5185\u7F6E\u4F9B\u5E94\u5546\u4E0D\u53EF\u5220\u9664\u3002",modelReorderAria:"\u62D6\u52A8\u6392\u5E8F\uFF1A{model}",modelReorderHint:"\u62D6\u52A8\u8C03\u6574\u8BE5\u4F9B\u5E94\u5546\u5185\u6A21\u578B\u987A\u5E8F\u2014\u2014\u6A21\u578B\u5207\u6362\u6309\u6B64\u987A\u5E8F\u663E\u793A\u3002",configButton:"\u9AD8\u7EA7\u8BBE\u7F6E",configButtonHint:"\u6253\u5F00\u9AD8\u7EA7\u8BBE\u7F6E",configPaneTitle:"\u9AD8\u7EA7\u8BBE\u7F6E",configPaneClose:"\u5173\u95ED",configPaneFailed:"\u914D\u7F6E\u9762\u677F\u6E32\u67D3\u5931\u8D25",imagegenSectionTitle:"\u751F\u56FE",imagegenEnable:"\u542F\u7528\u751F\u56FE",cardStateOn:"\u5F00\u542F",cardStateOff:"\u5173\u95ED",imagegenEnabledHint:"\u5141\u8BB8\u4F7F\u7528\u751F\u56FE\u5DE5\u5177\uFF0C\u70B9\u51FB\u5C55\u5F00\u914D\u7F6E\u6A21\u578B\u548C\u56FE\u7247\u53C2\u6570\u3002",imagegenDisabledHint:"\u4E0D\u4F7F\u7528\u751F\u56FE\u5DE5\u5177\uFF0C\u5DF2\u914D\u7F6E\u7684\u6A21\u578B\u548C\u56FE\u7247\u53C2\u6570\u4ECD\u4F1A\u4FDD\u7559\u3002",imagegenExpand:"\u5C55\u5F00\u751F\u56FE\u8BBE\u7F6E",imagegenCollapse:"\u6536\u8D77\u751F\u56FE\u8BBE\u7F6E",imagegenSaving:"\u6B63\u5728\u4FDD\u5B58\u2026",imagegenRefreshFailed:"\u5DF2\u4FDD\u5B58\uFF0C\u4F46\u65E0\u6CD5\u5237\u65B0\u914D\u7F6E\uFF1A{error}",imagegenLoading:"\u6B63\u5728\u8BFB\u53D6\u2026",imagegenLoadFailed:"\u8BFB\u4E0D\u5230\u751F\u56FE\u914D\u7F6E",imagegenDefaultsLabel:"\u9ED8\u8BA4\u53C2\u6570",imagegenDefaultModelLabel:"\u9ED8\u8BA4\u751F\u56FE\u6A21\u578B",imagegenDefaultModelNone:"\u672A\u8BBE\u7F6E",imagegenSizeLabel:"\u5C3A\u5BF8",imagegenQualityLabel:"\u8D28\u91CF",imagegenCountLabel:"\u6570\u91CF",imagegenTimeoutLabel:"\u8D85\u65F6",imagegenTimeoutMinutes:"{minutes} \u5206\u949F",imagegenTimeoutHint:"\u5355\u6B21\u8BF7\u6C42\u4E0A\u9650\uFF1B\u53C2\u6570\u56DE\u9000\u7684\u6BCF\u6B21\u91CD\u8BD5\u4E5F\u7528\u5B83\u3002",imagegenCardRunning:"\u6B63\u5728\u751F\u6210\u56FE\u7247\u2026",imagegenToolMissing:"\u5185\u5EFA\u751F\u56FE\u5DE5\u5177\u6CA1\u6709\u6CE8\u518C\u6210\u529F\uFF0C\u6A21\u578B\u8C03\u4E0D\u5230\u5B83\u3002",imagegenToolMissingWhy:"\u5BBF\u4E3B\u8BF4\uFF1A{reason}",autoContinueSectionTitle:"\u81EA\u52A8\u7EE7\u7EED",autoContinueExpand:"\u5C55\u5F00\u81EA\u52A8\u7EE7\u7EED\u8BBE\u7F6E",autoContinueCollapse:"\u6536\u8D77\u81EA\u52A8\u7EE7\u7EED\u8BBE\u7F6E",autoContinueTitle:"\u81EA\u52A8\u7EE7\u7EED\u88AB\u4E2D\u65AD\u7684\u4F1A\u8BDD",autoContinueDescription:"\u4F1A\u8BDD\u56E0\u65AD\u7EBF\u3001\u8D85\u65F6\u6216\u8F93\u51FA\u8FBE\u5230\u4E0A\u9650\u800C\u4E2D\u65AD\u65F6\uFF0C\u81EA\u52A8\u56DE\u590D\u300C\u7EE7\u7EED\u300D\u3002\u6B63\u5E38\u5B8C\u6210\u3001\u624B\u52A8\u505C\u6B62\u3001\u9274\u6743\u6216\u989D\u5EA6\u7C7B\u9519\u8BEF\u4E0D\u4F1A\u89E6\u53D1\u3002",autoContinueHint:"\u5931\u8D25\u540E\u7B49 {seconds} \u79D2\u518D\u7EE7\u7EED \xB7 \u6700\u591A {count} \u6B21",autoContinueWaitLabel:"\u5931\u8D25\u540E\u7B49\u5F85",autoContinueRetriesLabel:"\u91CD\u8BD5\u4E0A\u9650",autoContinueSecondsUnit:"\u79D2",autoContinueRetriesUnit:"\u6B21",autoContinueConfigHint:"\u586B\u6574\u6570\uFF1A{waitMin}\u2013{waitMax} \u79D2\u3001{retriesMin}\u2013{retriesMax} \u6B21\uFF1B\u79FB\u5F00\u7126\u70B9\u6216\u6309\u56DE\u8F66\u81EA\u52A8\u4FDD\u5B58\u3002\u6BCF\u6B21\u5931\u8D25\u540E\u5148\u7B49\u8FD9\u4E48\u4E45\u518D\u53D1\u9001\u300C\u7EE7\u7EED\u300D\uFF1B\u4F9B\u5E94\u5546\u8981\u6C42\u7684\u7B49\u5F85\u66F4\u4E45\u65F6\u6309\u66F4\u4E45\u7684\u6765\u3002",autoContinueAria:"\u542F\u7528\u81EA\u52A8\u7EE7\u7EED",autoContinueMessage:"\u7EE7\u7EED",autoContinueTriggers:"\u89E6\u53D1\u6761\u4EF6",autoContinueRestore:"\u6062\u590D\u63A8\u8350",autoContinueMaxTokens:"\u8F93\u51FA\u8FBE\u5230\u4E0A\u9650",autoContinueHttpStatus:"HTTP 408 / 425 / 429 / 5xx",autoContinueErrorTypes:"\u9519\u8BEF\u7C7B\u578B",autoContinueCodesMore:"+{count}",autoContinueCodesAll:"\u5168\u9009",autoContinueCodesNone:"\u6E05\u7A7A",autoContinueGroupTransient:"\u77AC\u65F6\u6545\u969C \xB7 \u7B49\u4E00\u4F1A\u513F\u518D\u8BD5\u901A\u5E38\u80FD\u8FC7",autoContinueGroupOther:"\u8BF7\u6C42/\u914D\u7F6E\u672C\u8EAB\u6709\u95EE\u9898 \xB7 \u539F\u6837\u518D\u53D1\u591A\u534A\u8FD8\u662F\u540C\u4E00\u4E2A\u9519",autoContinueGroupFlags:"\u5185\u7F6E\u89E6\u53D1",autoContinueWhyMaxTokens:"\u56DE\u590D\u649E\u5230\u8F93\u51FA\u4E0A\u9650\u88AB\u622A\u65AD\uFF0C\u53D1\u300C\u7EE7\u7EED\u300D\u5C31\u80FD\u63A5\u7740\u5199",autoContinueWhyHttpStatus:"\u7F51\u5173\u6216\u4F9B\u5E94\u5546\u8FD4\u56DE 408 \xB7 425 \xB7 429 \xB7 5xx",autoContinueChipHttp:"HTTP 5xx",autoContinueTagContinue:"\u503C\u5F97\u7EE7\u7EED",autoContinueTagUseless:"\u7EE7\u7EED\u6CA1\u7528",autoContinueTagDepends:"\u770B\u60C5\u51B5",autoContinueWhyEMPTY_RESPONSE:"\u4E0A\u6E38\u56DE\u4E86\u7A7A\u5185\u5BB9\uFF0C\u6D41\u88AB\u622A\u65AD\u6216\u63A8\u7406\u8D85\u65F6",autoContinueWhyRATE_LIMIT:"\u4F9B\u5E94\u5546\u9650\u6D41\uFF08429\uFF09\uFF1A\u53D1\u5F97\u592A\u5FEB\u6216\u5E76\u53D1\u8D85\u4E86",autoContinueWhySERVER:"\u4F9B\u5E94\u5546 5xx\uFF0C\u6216\u7F51\u5173\u4E0B\u6E38\u6682\u65F6\u8FDE\u4E0D\u4E0A",autoContinueWhyTIMEOUT:"\u6D41\u957F\u65F6\u95F4\u6CA1\u6709\u65B0 token\uFF0C\u88AB\u7A7A\u95F2\u8D85\u65F6\u6390\u65AD",autoContinueWhyTRANSPORT:"\u8FDE\u63A5\u4E2D\u9014\u65AD\u5F00\uFF1A\u7F51\u7EDC\u6296\u52A8\u6216\u4EE3\u7406\u6389\u7EBF",autoContinueWhyPI_AI_ERROR:"\u4F9B\u5E94\u5546\u4E1A\u52A1\u9519\u8BEF\uFF1A\u5185\u5BB9\u8FC7\u6EE4\u3001Azure \u8D44\u6E90\u4E0D\u5339\u914D",autoContinueWhyINVALID_REQUEST:"\u8BF7\u6C42\u4E0D\u5408\u6CD5\uFF08400/413\uFF09\uFF1A\u4E0A\u4E0B\u6587\u8D85\u7A97\u53E3\u3001\u53C2\u6570\u9519",autoContinueWhyAUTH:"\u5BC6\u94A5\u65E0\u6548\u3001\u6CA1\u6743\u9650\u6216\u989D\u5EA6\u7528\u5B8C\uFF08401/403\uFF09",autoContinueWhyLEGACY_CLI_OUTCOME_UNKNOWN:"\u65E7\u7248 CLI \u6CA1\u8BB0\u4E0B\u7ED3\u679C",autoContinueWhyUNSUPPORTED_REASONING_EFFORT:"\u8BE5\u6A21\u578B\u4E0D\u652F\u6301\u5F53\u524D\u601D\u8003\u6863\u4F4D\uFF08high \u7B49\uFF09",autoContinueWhyMALFORMED_RESPONSE:"\u6A21\u578B\u8F93\u51FA\u6216\u5DE5\u5177\u8C03\u7528 JSON \u574F\u4E86\uFF0C\u91CD\u751F\u6210\u53EF\u80FD\u597D",autoContinueWhyUNKNOWN_MODEL:"\u8FD9\u4E2A\u6A21\u578B\u540D\u6CA1\u5728\u4F9B\u5E94\u5546\u90A3\u8FB9\u914D\u7F6E",autoContinueControllerWaiting:"\u7B2C {n}/{max} \u6B21 \xB7 {seconds}s",autoContinueControllerSent:"\u5DF2\u53D1\u9001\u300C\u7EE7\u7EED\u300D \u7B2C {n}/{max} \u6B21",autoContinueControllerExhausted:"\u8FDE\u7EED {max} \u6B21\u540E\u505C\u624B",autoContinueControllerStop:"\u505C\u6B62",autoContinueControllerResume:"\u7ACB\u5373\u7EE7\u7EED",autoContinueControllerReset:"\u91CD\u7F6E",autoContinueControllerSettings:"\u8BBE\u7F6E\u2026",autoContinueControllerAria:"\u81EA\u52A8\u7EE7\u7EED\u72B6\u6001",autoContinueControllerDetail:"\u4E0A\u6B21\u4E2D\u65AD\uFF1A{detail}",errorDetailSectionTitle:"\u5931\u8D25\u8BE6\u60C5",errorDetailSummary:"\u5728\u62A5\u9519\u884C\u672B\u5C3E\u52A0\u300C\u67E5\u770B\u8BE6\u60C5\u300D",errorDetailHint:"\u5728\u5931\u8D25\u7684\u90A3\u4E00\u8F6E\u672B\u5C3E\u52A0\u4E00\u4E2A\u300C\u67E5\u770B\u8BE6\u60C5\u300D\u3002\u70B9\u5F00\u76F4\u63A5\u770B\u4F9B\u5E94\u5546\u539F\u672C\u8FD4\u56DE\u7684\u5185\u5BB9\u2014\u2014\u72B6\u6001\u7801\u3001\u9519\u8BEF\u7801\u3001\u539F\u56E0\u3001traceId\uFF0C\u800C\u4E0D\u662F\u88AB\u6362\u6389\u7684\u56FA\u5B9A\u6587\u6848\u3002",errorDetailAria:"\u663E\u793A\u771F\u5B9E\u62A5\u9519\u8BE6\u60C5",errorDetailButton:"\u67E5\u770B\u8BE6\u60C5",errorDetailTitle:"\u672C\u8F6E\u5931\u8D25\u8BE6\u60C5",errorDetailClose:"\u5173\u95ED",errorDetailReason:"\u771F\u5B9E\u539F\u56E0",errorDetailTrace:"traceId",errorDetailCode:"DSH \u9519\u8BEF\u7801",errorDetailShown:"\u754C\u9762\u539F\u672C\u663E\u793A",errorDetailRaw:"\u4E0A\u6E38\u539F\u59CB\u54CD\u5E94",errorDetailCopy:"\u590D\u5236",errorDetailCopied:"\u5DF2\u590D\u5236",errorDetailCopyRaw:"\u590D\u5236\u539F\u6587",errorDetailSource:"\u8BFB\u53D6\u81EA\u4F1A\u8BDD\u539F\u59CB\u4E8B\u4EF6 turn/end\uFF0C\u672A\u7ECF DSH \u5305\u88C5",errorDetailUnwrapped:"\u539F\u6837\u663E\u793A\uFF08\u672A\u88AB\u5305\u88C5\uFF09",errorDetailFixedLabel:"\u56FA\u5B9A\u6587\u6848\uFF0C\u5305\u4F4F\u4E86\u771F\u5B9E\u539F\u56E0"};var go="dsh-model-think-level.slider.enabled",xg=["dsh-reasoning-effort.enabled","@dsh-external/dsh-reasoning-effort.enabled"],br=kg();function kg(){try{let e=window.localStorage.getItem(go),t=e===null?xg.map(n=>window.localStorage.getItem(n)).find(n=>n!==null):null;return(e??t??null)!=="false"}catch{return!0}}var aa=new Set;function _d(){for(let e of[...aa])e()}function mt(){return br}function Fd(e){if(br!==e){br=e;try{window.localStorage.setItem(go,String(e))}catch{}_d()}}function Kd(e){br!==e&&(br=e,_d())}function ho(e){return aa.add(e),()=>{aa.delete(e)}}var bo="dsh-model-think-level.provider-order",qd=["deepseek-account","deepseek-official"];function Cn(e){if(e===null)return[];try{let t=JSON.parse(e);return Array.isArray(t)?da(t.filter(n=>typeof n=="string")):[]}catch{return[]}}function da(e){let t=new Set,n=[];for(let r of e)r.length===0||t.has(r)||(t.add(r),n.push(r));return n}var An=(()=>{try{return Cn(window.localStorage.getItem(bo))}catch{return[]}})(),sa=new Set;function Bd(){for(let e of[...sa])e()}function Wd(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function Rn(){return An}function yo(e){let t=da(e);if(!Wd(An,t)){An=t;try{window.localStorage.setItem(bo,JSON.stringify(An))}catch{}Bd()}}function Gd(e){let t=da(e);Wd(An,t)||(An=t,Bd())}function Hn(e){return sa.add(e),()=>{sa.delete(e)}}function la(e){let t=n=>{let r=qd.indexOf(n);return r<0?qd.length:r};return e.map((n,r)=>({id:n,index:r,rank:t(n)})).sort((n,r)=>n.rank-r.rank||n.index-r.index).map(n=>n.id)}function Nn(e,t){let n=new Map;for(let a of t)n.has(a)||n.set(a,n.size);let r=[],o=[];e.forEach((a,s)=>{n.has(a)&&(r.push(s),o.push(a))}),o.sort((a,s)=>n.get(a)-n.get(s));let i=[...e];return r.forEach((a,s)=>{i[a]=o[s]}),i}function Ud(e){return Nn(la(e),Rn())}function ca(e,t,n){let r=e.indexOf(t);if(r<0)return[...e];let o=[...e];o.splice(r,1);let i=Math.max(0,Math.min(o.length,n));return o.splice(i,0,t),o}var vo="dsh-model-think-level.providers.disabled",ua=new Set,_t=Eg();function Eg(){try{return Cn(window.localStorage.getItem(vo))}catch{return[]}}function jd(e){return Cn(e)}function yr(){return _t}function On(e){return!_t.includes(e)}function zd(e,t){let n=!_t.includes(e);t!==n&&fa(t?_t.filter(r=>r!==e):[..._t,e],!0)}function $d(e){fa(e,!1)}function Vd(e){fa(e,!0)}function In(e){return ua.add(e),()=>{ua.delete(e)}}function Tg(e,t){return e.length!==t.length?!1:e.every(n=>t.includes(n))}function fa(e,t){if(!Tg(_t,e)){if(_t=[...new Set(e)],t)try{window.localStorage.setItem(vo,JSON.stringify(_t))}catch{}for(let n of[...ua])n()}}var wo="dsh-model-think-level.model-order";function ma(e){if(e===null)return{};try{let t=JSON.parse(e);if(t===null||typeof t!="object"||Array.isArray(t))return{};let n={};for(let[r,o]of Object.entries(t)){if(r.length===0||!Array.isArray(o))continue;let i=ga(o.filter(a=>typeof a=="string"));i.length>0&&(n[r]=i)}return n}catch{return{}}}function ga(e){let t=new Set,n=[];for(let r of e)r.length===0||t.has(r)||(t.add(r),n.push(r));return n}var Ft=(()=>{try{return ma(window.localStorage.getItem(wo))}catch{return{}}})(),pa=new Set;function ha(){for(let e of[...pa])e()}function Sg(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function Yd(){try{window.localStorage.setItem(wo,JSON.stringify(Ft))}catch{}}function vr(){return Ft}function Jd(e){return Ft[e]??Mg}var Mg=[];function Xd(e,t){if(e.length===0)return;let n=ga(t),r=Jd(e);if(Sg(r,n)&&(n.length>0||!(e in Ft)))return;let o={...Ft};n.length===0?delete o[e]:o[e]=n,Ft=o,Yd(),ha()}function Qd(e){Ft=e,ha()}function Zd(e){let t={};for(let[n,r]of Object.entries(e)){if(n.length===0)continue;let o=ga(r);o.length>0&&(t[n]=o)}Ft=t,Yd(),ha()}function Dn(e){return pa.add(e),()=>{pa.delete(e)}}function Lg(e,t){return Nn(e,t)}function el(e,t){return Nn(t,Jd(e))}function ba(e,t){if(e.length===0||t.length===0)return e;let n=new Map(e.map(r=>[r.id,r]));return Lg(e.map(r=>r.id),t).map(r=>n.get(r))}var tl="dsh-model-think-level.order-saved-at",Ag=400,Cg=6e4;function wa(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e){if(typeof r!="string")continue;let o=r.trim();o.length===0||t.has(o)||(t.add(o),n.push(o))}return n}function Rg(e){if(typeof e!="object"||e===null||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e)){if(n.length===0)continue;let o=wa(r);o.length>0&&(t[n]=o)}return t}function nl(e){if(typeof e!="object"||e===null)return;let t=e;return{savedAt:typeof t.savedAt=="number"&&Number.isFinite(t.savedAt)?t.savedAt:0,providerOrder:wa(t.providerOrder),modelOrder:Rg(t.modelOrder),providersDisabled:Array.isArray(t.providersDisabled)?wa(t.providersDisabled):void 0}}function rl(e){return e.providerOrder.length>0||Object.keys(e.modelOrder).length>0||e.providersDisabled!==void 0}function wr(){try{let e=window.localStorage.getItem(tl),t=e===null?0:Number(e);return Number.isFinite(t)&&t>0?t:0}catch{return 0}}function ka(e){try{window.localStorage.setItem(tl,String(e))}catch{}}function xr(){return JSON.stringify({providerOrder:Rn(),modelOrder:vr(),providersDisabled:yr()})}var qt,gt,Pn=new Set,xo,ya,Pe=!1,xa=!1,Kt,$e=0;function Hg(){let e=Math.max(Date.now(),wr()+1);return ka(e),e}function ol(){if(gt=void 0,Pe)return;let e=wr(),t=JSON.stringify({savedAt:e>0?e:Date.now(),providerOrder:Rn(),modelOrder:vr(),providersDisabled:yr()});qt=xr();let n=$e,r=fetch(ta,{method:"POST",headers:{"content-type":"application/json"},body:t}).then(async o=>{if(Pe||n!==$e)return!0;let i=await o.json().catch(()=>{});if(Pe||n!==$e)return!0;let a=nl(i?.data);return o.status===409?wr()!==e?!0:a!==void 0&&rl(a)?(il(a),!0):(qt=void 0,!1):o.ok?(a!==void 0&&a.savedAt>wr()&&ka(a.savedAt),!0):(qt=void 0,!1)}).catch(()=>(!Pe&&n===$e&&(qt=void 0),!1));Pn.add(r),r.then(()=>{Pn.delete(r)})}function Ea(e){Pe||gt!==void 0||xr()!==qt&&(gt=setTimeout(ol,e))}function Ta(){gt!==void 0&&(clearTimeout(gt),ol())}async function Ng(){if(Pe)return;let e=$e;if(await Eo(),!(Pe||e!==$e))for(xr()!==qt&&gt===void 0&&Pn.size===0&&Ea(0);!Pe&&e===$e&&(gt!==void 0||Pn.size>0);){Ta();let t=await Promise.all([...Pn]);if(Pe||e!==$e)return;if(t.includes(!1))throw new Error("\u6A21\u578B\u987A\u5E8F\u548C\u542F\u505C\u5C1A\u672A\u4FDD\u5B58\uFF0C\u8BF7\u91CD\u8BD5\u540C\u6B65")}}function va(){Pe||xa||(Hg(),Ea(Ag))}function il(e){xa=!0;try{yo(e.providerOrder),Zd(e.modelOrder),e.providersDisabled!==void 0&&Vd(e.providersDisabled)}finally{xa=!1}ka(e.savedAt),qt=xr()}function Eo(){if(Pe)return Promise.resolve();if(Kt!==void 0)return Kt;let e=Og().finally(()=>{Kt===e&&(Kt=void 0)});return Kt=e,e}async function Og(){let e=$e,t;try{let o=await fetch(ta,{method:"GET"});if(o.ok){let i=await o.json();i.ok===!0&&(t=nl(i.data))}}catch{return}if(Pe||e!==$e||gt!==void 0)return;let n=wr(),r=JSON.stringify({providerOrder:t?.providerOrder??[],modelOrder:t?.modelOrder??{},providersDisabled:t?.providersDisabled??[]});if(t!==void 0&&rl(t)&&t.savedAt>=n){il(t);return}xr()!==r&&Ea(0)}function ko(){Pe||typeof document<"u"&&document.visibilityState==="hidden"||Eo()}function al(){Pe=!1,$e+=1,Kt=void 0,Pn.clear(),qt=void 0;let e=Hn(va),t=Dn(va),n=In(va);xo=setInterval(ko,Cg);let r=a=>{let s=a.detail;typeof s?.waitUntil=="function"&&s.waitUntil(Ng())},o=()=>{let a=$e;(async()=>(Kt!==void 0&&await Kt,!Pe&&a===$e&&await Eo()))()};typeof window<"u"&&(window.addEventListener("focus",ko),window.addEventListener("dsh-webdav-sync:before-snapshot",r),window.addEventListener("dsh-webdav-sync:applied",o));let i=()=>{document.visibilityState==="visible"&&ko()};return typeof document<"u"&&document.addEventListener("visibilitychange",i),ya=()=>{typeof document<"u"&&document.removeEventListener("visibilitychange",i),typeof window<"u"&&(window.removeEventListener("focus",ko),window.removeEventListener("dsh-webdav-sync:before-snapshot",r),window.removeEventListener("dsh-webdav-sync:applied",o))},Eo(),()=>{Pe=!0,$e+=1,gt!==void 0&&clearTimeout(gt),gt=void 0,xo!==void 0&&clearInterval(xo),xo=void 0,ya?.(),ya=void 0,e(),t(),n()}}var sl=`
7
+ "use strict";var fo=Object.defineProperty;var gg=Object.getOwnPropertyDescriptor;var hg=Object.getOwnPropertyNames;var bg=Object.prototype.hasOwnProperty;var yg=(e,t,n)=>t in e?fo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var vg=(e,t)=>{for(var n in t)fo(e,n,{get:t[n],enumerable:!0})},wg=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of hg(t))!bg.call(e,o)&&o!==n&&fo(e,o,{get:()=>t[o],enumerable:!(r=gg(t,o))||r.enumerable});return e};var xg=e=>wg(fo({},"__esModule",{value:!0}),e);var qe=(e,t,n)=>yg(e,typeof t!="symbol"?t+"":t,n);var gk={};vg(gk,{EffortEditor:()=>_o,REFRESH_MIN_INTERVAL_MS:()=>pg,apply:()=>mk,baselineModelsOf:()=>yl,compatOf:()=>Ao,createEditorApi:()=>Ho,defaultEffortOf:()=>Co,describeNamespace:()=>pe,effortsOf:()=>Mo,findModelMenu:()=>Va,findModelTrigger:()=>Ya,imageGenOf:()=>Pa,inject:()=>pk,inputOf:()=>Lo,invalidateProbeCache:()=>Da,name:()=>fk,nameOf:()=>Ro,providerHeadersOf:()=>_a,providersOf:()=>Ke,routeIsDeclared:()=>st,userProvidersOf:()=>rn,writeModelRows:()=>Lr,writeProviderHeaders:()=>Ar});module.exports=xg(gk);var fg=require("react");function Cd(e,t){let n=!1,r=0,o=!1,i;return{schedule:()=>{if(o||n)return;n=!0;let a=Math.max(0,t-(Date.now()-r));i=setTimeout(()=>{i=void 0,n=!1,r=Date.now(),o||e()},a)},dispose:()=>{o=!0,i!==void 0&&clearTimeout(i),i=void 0,n=!1}}}var ke="dsh-model-think-level",Hd="/dsh-model-think-level/raw-models";var po="/dsh-model-think-level/provider-key",mo="/dsh-model-think-level/key-index",Nd="/dsh-model-think-level/balance",Od="/dsh-model-think-level/autofill-config",Id="/dsh-model-think-level/headers-config",ta="/dsh-model-think-level/fingerprint",na="/dsh-model-think-level/ui-order";var De="llm-pi-ai",it="reasoningEffortsUnset",wt="inputUnset",at="inputImageGen",Sn="reasoningEffortsAutofilled",Mn="defaultEffort",ra="/dsh-model-think-level/camouflage";var oa="/dsh-model-think-level/history-compat";var ia="/dsh-model-think-level/image-config";var aa=ke;var br=require("react");function Pd(e){let{locale:t}=e,n=(0,br.useCallback)(o=>t.subscribe(o),[t]),r=(0,br.useCallback)(()=>t.getSnapshot().revision??0,[t]);return(0,br.useSyncExternalStore)(n,r),e.children()}var Dd={reasoningEffort:"Reasoning effort",thinkingMode:"Thinking",thinkingModeOff:"Off \u2014 this model is declared as not reasoning.",levelsLabel:"Declared levels",levelsHint:"Click to declare; clear every level to declare nothing \u2014 requests follow the provider default.",stateDeclared:"{count} declared \xB7 default {default}",stateUndeclared:"Nothing declared \u2014 requests follow the provider default.",modalityText:"Text",autoAdapt:"Auto-adapt",autoAdaptAll:"Auto-detect thinking levels",autoAdaptWorking:"Detecting\u2026",autoAdaptDone:"Adapted {count} \xB7 save to write",autoAdaptEmpty:"All already configured",autoAdaptUnsuggested:"No suggestion available",autoAdaptBlocked:"No models to adapt yet",autoAdaptFailed:"Detection failed: {message}",autoAdaptDoneHint:"Held for {count} model(s): they land when this card is saved.",autoAdaptEmptyHint:"Every model of this provider already declares its thinking levels.",autoAdaptUnsuggestedHint:"The models that still need a declaration have no knowledge-base match \u2014 adapt them one by one.",autoAdaptBlockedHint:"Nothing to adapt yet: the card has no models, is not saved, or the settings document is read-only.",apply:"Apply",reset:"Reset",referenceTitle:"Reference capacities",contextWindowLabel:"Context window",maxTokensLabel:"Max output",capacityBlank:"Catalogue value",capacityUnitsHint:"Digits or K/M/B/T shorthand, e.g. 1,048,576 or 1M.",capacityRule:"Max output above the window is refused upstream; this check is local only.",tokensUnit:"tokens",inputModality:"Supported modalities",modalityImage:"Image",modalityImageGen:"Image generation",modalityImageGenHint:"Marked as an image generator \u2014 pick it in the composer, type a prompt, and the send goes straight to the images API.",modalityInherit:"Not declared \u2014 the provider default applies (usually text-only).",modalityDeclared:"Declared \u2014 clearing Image goes back to text only.",capacityInherit:"Empty keeps the catalogue value.",clearDeclaration:"Clear declaration",noSuggestion:"No suggestion is available for this model.",writeError:"Failed: {message}",renderFailed:"Reasoning-effort editor failed to render",wirePlaceholder:"Wire value",wireValue:"value",wireShow:"Edit wire values",wireHide:"Hide wire values",wireHint:"Empty keeps the level's conventional spelling; a non-empty off value is what gets sent when thinking is closed.",reasoningDisabled:"No reasoning-effort control declared for this model (false) \u2014 do not arm thinking levels.",bareHint:"Clearing every level removes the declaration \u2014 requests go out bare (provider default), which some relays require.",defaultRiskDisabled:"No off level: Default and provider tests send thinking: disabled, which this model rejects (e.g. 1210).",defaultRiskQwen:"No off level: Default sends enable_thinking: false \u2014 only fails where the upstream requires thinking on.",stagedHint:"Not saved yet. Staged settings are applied automatically once the model is saved.",level_off:"off",level_minimal:"minimal",level_low:"low",level_medium:"medium",level_high:"high",level_xhigh:"xhigh",level_max:"max",sliderToggleTitle:"Model and reasoning-effort rows",sliderToggleDescription:"Show the model row and the reasoning-level chips in the model menu; the levels follow the current model.",sliderToggleAria:"Enable the model and reasoning-effort rows",settingOn:"On",settingOff:"Off",sliderNoLevels:"The current model exposes no reasoning-effort levels.",triggerFallback:"Select model",effortDefault:"Default",modelRowLabel:"Model",effortRowLabel:"Reasoning level",tagVision:"Image input",tagThinking:"Sends thinking levels",tagImageGen:"Image generation model",sliderNoCurrent:"No model selected.",sliderCommitSlow:"The switch is taking too long \u2014 try again.",defaultEffortLabel:"Default effort",defaultEffortUnset:"Follow memory",defaultEffortHint:"The level new sessions start at; a level you pick by hand always wins. Empty follows memory.",followMemory:"Follow memory",clearDefaultEffort:"Clear pick",modelSearchPlaceholder:"Search models\u2026",modelSearchNoMatches:"No matching models",modelSearchClear:"Clear search",modelSearchFailed:"Model search failed to render",editorTabsLabel:"Editor sections",editorTabProvider:"Provider",editorTabModels:"Models",editorTabAdvanced:"Advanced",editorTabFingerprint:"Fingerprint",fpTitle:"Model fingerprint",fpIntro:"Only GPT and Claude models can be probed \u2014 the fingerprint library covers those two families, and models outside it never appear here.",fpCount:"{count} probeable",fpSummary:"Identified {identified} \xB7 doubtful {doubtful} \xB7 failed {failed}",fpSummaryNone:"Nothing checked yet.",fpRunning:"Checking \xB7 {done} / {total} (keeps going if you leave)",fpDetectAll:"Check all",fpDetect:"Check",fpRetest:"Re-check",fpRetry:"Retry",fpCost:"{count} prompts \xB7 about {seconds}s",fpCostMinutes:"{count} prompts \xB7 about {minutes} min",fpCostUnknown:"{count} prompts",fpForget:"Forget",fpStateUnchecked:"Not checked",fpStateRunning:"Checking \xB7 {done}/{total}",fpStateIdentified:"{model} \xB7 {probability}",fpStateDoubtful:"Doubtful \xB7 {probability}",fpStateFailed:"Check failed",fpQueued:"Queued \xB7 #{position}",fpEvidence:"{used} / {total} prompts",fpSimilarity:"Similarity",fpDetailShow:"Show result",fpDetailHide:"Hide result",fpFamily:"Family",fpChallengeCounted:"Q{index} {numbers} \xB7 counted",fpChallengeRejected:"Q{index} {parsed}/{numbers} \xB7 not counted",fpChallengeSkipped:"Q{index} {numbers} \xB7 early stop",fpChallengeTitle:"How each of the three prompts settled. The number is how many integers the prompt asked for; a slash means it asked for the right-hand count and answered only the left. A prompt only counts when it returns at least max(80, 55% of what it asked).",fpCandidates:"Closest candidates",fpClosedSet:"Closed-set result: a model outside the library is still attributed to the nearest listed one. Read it as a comparison, not a certificate.",fpCheckedAt:"Checked {time}",fpTiming:"Timing: first token {first}s \xB7 total {total}s \xB7 ~{rate} chars/s",fpLoadFailed:"Could not read the stored verdicts: {error}",fpRunFailed:"Check failed: {error}",keyRevealShow:"Show key",keyRevealHide:"Hide key",keyRevealFailed:"Stored key unavailable",keysLoading:"Loading keys\u2026",keysAdd:"Add another key",keysAddConfirm:"Add",keysEnable:"Enable {name}",keysDisable:"Disable {name}",keysMissing:"Not stored",keysEdit:"Edit",keysRemove:"Delete",keysConfirmRemove:"Confirm delete",keysCancel:"Cancel",keysSave:"Save",keysAlias:"Label",keysAliasPlaceholder:"Name (optional), e.g. Team",keysValue:"Key",keysValuePlaceholder:"Paste the API key",keysNewValuePlaceholder:"Paste the new API key",keysAddIllegal:"A key is printable ASCII without spaces.",keysAdded:"Key stored.",keysRenamed:"Label saved.",keysReplaced:"Key replaced.",keysRemoved:"Key removed.",keysCopy:"Copy {name}",keysCopied:"Key copied.",keysCopyFailed:"Could not copy the key.",keysScope:"Models served by {name}",keysModels:"Models",keysScopeAll:"All models",keysScopeNone:"No models found",keysScopeCount:"{count} models",keysScopeSaved:"Model scope saved.",keysScopeHint:"Only the ticked models use this key; the rest go to the provider's other keys.",keysScopeAutoHint:"This scope was written by the auto-probe from the models this key actually lists; every sweep re-checks it.",keysProbe:"Auto-probe",keysProbing:"Probing\u2026",keysProbeHint:`Ask every key what it actually serves, then keep each key to the models it shares with this provider's list. A key that serves every added model keeps "All models"; a key that serves none of them is switched off.`,keysProbeSingle:"One key has nothing to divide \u2014 add a second key first.",keysProbeDone:"Probe finished \u2014 scopes checked against what each key serves.",keysScopeEmpty:"This provider has no models yet. Add models first, then pick them here.",keysProtocolLabel:"Protocol for {name}",keysProtocolCreate:"Protocol",keysProtocolCreateHint:"The wire this key signs with; the addresses the provider has configured decide which families are offered.",keysProtocolDefault:"Auto (per model)",keysProtocolDefaultHint:"Picks each model\u2019s own wire: claude models use the Anthropic address, the rest the provider\u2019s protocol (where that address is configured).",keysProtocolAnthropic:"Anthropic",keysProtocolAnthropicHint:"Anthropic API \xB7 Claude models",keysProtocolOpenAI:"Chat Completions",keysProtocolOpenAIHint:"OpenAI API \xB7 GPT models, most agents",keysProtocolResponses:"Responses",keysProtocolResponsesHint:"OpenAI API \xB7 Codex",keysProtocolShortChat:"Chat",keysProtocolShortResponses:"Responses",keysProtocolShortAnthropic:"Anthropic",keysProtocolSaved:"Protocol saved.",keysEndpointOpenAI:"OpenAI",keysEndpointAnthropic:"Anthropic",keysEndpointBalance:"Balance",keysEndpointBalanceHint:"Read-only endpoint queried for this provider\u2019s balance; the first API key is sent along.",keysMoreEndpoints:"More endpoints",keysEndpointsCount:"{count} more",keysEndpointInvalid:"The address must start with http:// or https://",keysUnreachable:"The plugin\u2019s key route did not answer.",keysPanelFailed:"Key manager failed to render",keysDraftHint:"Held by this page and stored when the provider is created \u2014 a reload discards them, exactly like the card\u2019s own fields.",keysLastEnabledOff:"The last enabled key cannot be switched off.",headersTitle:"Request headers",headersHint:"Sent on every request of this route.",camouflageTitle:"Request disguise",camouflageHint:"Sends this route\u2019s requests as the official CLI of the vendor you pick: its client headers, and for Claude the identity system prompt and user id its validator looks for. Off by default.",camouflageOff:"Off",camouflageCodex:"Codex",camouflageClaude:"Claude",camouflageSaved:"Disguise saved.",camouflageError:"The plugin\u2019s disguise endpoint did not answer.",camouflageUnavailable:"The request interception is not installed, so this switch has no effect.",historyCompatTitle:"Old-topic recovery",historyCompatHint:"When the relay answers that this topic was created under a different upstream resource, replay the request with the foreign-looking history removed instead of failing the turn. Off by default.",historyCompatCost:"Only on that refusal, and at most two extra upstream calls.",historyCompatOff:"Off",historyCompatOn:"On",historyCompatUnavailable:"The request interception is not installed, so this switch has no effect.",headersEmpty:"No extra request headers are configured.",headersAdd:"Add header",headersName:"Name",headersNamePlaceholder:"e.g. x-company",headersValue:"Value",headersEdit:"Edit",headersSave:"Save",headersCancel:"Cancel",headersClear:"Clear all",headersRemove:"Remove header",headersSaved:"Saved.",headersCleared:"Cleared \u2014 this route sends no extra request headers.",headersReadOnly:"The settings document is not writable.",headersConflictOrigin:"Routes sharing one endpoint declare different request-header values: when the model in a request body does not identify exactly one of them, that request falls back to the first route.",headersConflictPatched:"The installed dsh-llm-pi-ai already carries a request-header patch: enter values in the headers above and this plugin need not take the request layer over.",headersConflictSiblings:"A plugin rewriting the same layer is installed: {names}. Only one user-agent rewrite should be active at a time, or the last writer on the wire wins.",headersError:"Save failed: {error}",headersNoRoute:"This route is no longer in the settings document \u2014 save the official card once first.",providerReorderAria:"Reorder {provider}",providerReorderHint:"Drag to set the provider order \u2014 the model switcher follows it.",providerToggleAria:"Enable {provider}",providerToggleHint:"A disabled provider is not listed by the model switcher.",providerBalanceLabel:"Balance",providerBalanceHint:"Fetched from this provider\u2019s balance endpoint.",providerBalanceRefresh:"Refresh balance",providerBalanceUnavailable:"Balance \u2014",providerDisabledGroupShow:"Show {count} switched-off provider(s)",providerDisabledGroupHide:"Hide {count} switched-off provider(s)",providerDisabledGroupHint:"A switched-off provider keeps its configuration and folds away here \u2014 unfold it to switch it back on.",providerRemoveDisabled:"Delete",providerRemoveLocked:"A built-in provider cannot be deleted.",modelReorderAria:"Reorder {model}",modelReorderHint:"Drag to set the order of this provider\u2019s models \u2014 the model switcher follows it.",configButton:"Advanced settings",configButtonHint:"Open advanced settings",configPaneTitle:"Advanced settings",configPaneClose:"Close",configPaneFailed:"Config pane failed to render",imagegenSectionTitle:"Image generation",imagegenEnable:"Enable image generation",cardStateOn:"On",cardStateOff:"Off",imagegenEnabledHint:"Allow the image-generation tool. Expand to configure the model and image parameters.",imagegenDisabledHint:"The image-generation tool is off. Your model and image settings are kept.",imagegenExpand:"Configure image generation",imagegenCollapse:"Collapse image-generation settings",imagegenSaving:"Saving\u2026",imagegenRefreshFailed:"Saved, but could not refresh the configuration: {error}",imagegenLoading:"Loading\u2026",imagegenLoadFailed:"Could not read the image config",imagegenDefaultsLabel:"Defaults",imagegenDefaultModelLabel:"Default model",imagegenDefaultModelNone:"Not set",imagegenSizeLabel:"Size",imagegenQualityLabel:"Quality",imagegenCountLabel:"Count",imagegenTimeoutLabel:"Timeout",imagegenTimeoutMinutes:"{minutes} min",imagegenTimeoutHint:"The per-request cap; every retry of the parameter fallback chain gets this budget too.",imagegenCardRunning:"Generating image\u2026",imagegenToolMissing:"The built-in image tool is not registered, so a model cannot call it.",imagegenToolMissingWhy:"Host said: {reason}",autoContinueSectionTitle:"Auto-continue",autoContinueExpand:"Configure auto-continue",autoContinueCollapse:"Collapse auto-continue settings",autoContinueTitle:"Continue interrupted turns",autoContinueDescription:"When a turn is cut off by a disconnect, a timeout or the output limit, reply \u201CContinue\u201D automatically. Clean finishes, your own stops and auth or quota errors are left alone.",autoContinueHint:"Wait {seconds}s after a failure \xB7 Up to {count} retries",autoContinueWaitLabel:"Wait after failure",autoContinueRetriesLabel:"Retry limit",autoContinueSecondsUnit:"s",autoContinueRetriesUnit:"retries",autoContinueConfigHint:"Whole numbers: {waitMin}\u2013{waitMax} seconds, {retriesMin}\u2013{retriesMax} retries. Saved when you leave the field or press Enter. After every failure, wait this long before sending \u201CContinue\u201D; a longer provider-requested delay wins.",autoContinueAria:"Enable auto-continue",autoContinueMessage:"Continue",autoContinueTriggers:"Triggers",autoContinueRestore:"Restore defaults",autoContinueMaxTokens:"Output token ceiling",autoContinueHttpStatus:"HTTP 408 / 425 / 429 / 5xx",autoContinueErrorTypes:"Error types",autoContinueCodesMore:"+{count}",autoContinueCodesAll:"All",autoContinueCodesNone:"None",autoContinueGroupTransient:"Transient \u2014 usually clears on retry",autoContinueGroupOther:"Request/config problem \u2014 the same send likely fails again",autoContinueGroupFlags:"Built-in triggers",autoContinueWhyMaxTokens:"The reply hit the output ceiling and was cut off",autoContinueWhyHttpStatus:"Gateway or provider answered 408 \xB7 425 \xB7 429 \xB7 5xx",autoContinueChipHttp:"HTTP 5xx",autoContinueTagContinue:"Worth retrying",autoContinueTagUseless:"Won't help",autoContinueTagDepends:"Depends",autoContinueWhyEMPTY_RESPONSE:"Upstream returned an empty body \u2014 stream truncated or reasoning timed out",autoContinueWhyRATE_LIMIT:"Provider rate limit (429) \u2014 too fast or too many concurrent calls",autoContinueWhySERVER:"Provider 5xx, or the gateway downstream is briefly unreachable",autoContinueWhyTIMEOUT:"No new token for too long \u2014 killed by the idle timeout",autoContinueWhyTRANSPORT:"Connection dropped mid-stream \u2014 network blip or proxy reset",autoContinueWhyPI_AI_ERROR:"Provider business error: content filter, Azure resource mismatch",autoContinueWhyINVALID_REQUEST:"Bad request (400/413): context over the window, bad parameters",autoContinueWhyAUTH:"Invalid key, no permission, or quota exhausted (401/403)",autoContinueWhyLEGACY_CLI_OUTCOME_UNKNOWN:"The old CLI never recorded the outcome",autoContinueWhyUNSUPPORTED_REASONING_EFFORT:"This model does not support the current reasoning effort",autoContinueWhyMALFORMED_RESPONSE:"Model output or tool-call JSON was malformed \u2014 regenerating may help",autoContinueWhyUNKNOWN_MODEL:"This model name is not configured at the provider",autoContinueControllerWaiting:"Retry {n}/{max} \xB7 {seconds}s",autoContinueControllerSent:"Sent \u201CContinue\u201D \xB7 retry {n}/{max}",autoContinueControllerExhausted:"Stood down after {max} tries",autoContinueControllerStop:"Stop",autoContinueControllerResume:"Continue now",autoContinueControllerReset:"Reset",autoContinueControllerSettings:"Settings\u2026",autoContinueControllerAria:"Auto-continue status",autoContinueControllerDetail:"Last interruption: {detail}",errorDetailSectionTitle:"Failure details",errorDetailSummary:"A details seat on failed turns",errorDetailHint:"Adds a \u201CView details\u201D seat to a failed turn. It shows what the provider actually answered \u2014 status, code, reason, traceId \u2014 instead of the fixed label.",errorDetailAria:"Show the real failure details",errorDetailButton:"View details",errorDetailTitle:"Turn failure details",errorDetailClose:"Close",errorDetailReason:"Actual reason",errorDetailTrace:"traceId",errorDetailCode:"DSH code",errorDetailShown:"UI showed",errorDetailRaw:"Upstream response",errorDetailCopy:"Copy",errorDetailCopied:"Copied",errorDetailCopyRaw:"Copy raw",errorDetailSource:"Read from the session\u2019s turn/end event, unwrapped by DSH",errorDetailUnwrapped:"shown as-is (not wrapped)",errorDetailFixedLabel:"fixed label, hiding the real reason"},_d={reasoningEffort:"\u601D\u8003\u5F3A\u5EA6",thinkingMode:"\u601D\u8003",thinkingModeOff:"\u5DF2\u5173\u95ED\u2014\u2014\u8BE5\u6A21\u578B\u58F0\u660E\u4E3A\u4E0D\u601D\u8003\u3002",levelsLabel:"\u652F\u6301\u6863\u4F4D",levelsHint:"\u70B9\u9009\u5373\u58F0\u660E\uFF1B\u5168\u90E8\u53D6\u6D88\u5219\u4E0D\u58F0\u660E\uFF0C\u8BF7\u6C42\u6309\u4F9B\u5E94\u5546\u9ED8\u8BA4\u53D1\u9001\u3002",stateDeclared:"\u5DF2\u58F0\u660E {count} \u6863 \xB7 \u9ED8\u8BA4 {default}",stateUndeclared:"\u672A\u58F0\u660E\u2014\u2014\u8BF7\u6C42\u6309\u4F9B\u5E94\u5546\u9ED8\u8BA4\u53D1\u9001\u3002",modalityText:"\u6587\u672C",autoAdapt:"\u81EA\u52A8\u9002\u914D",autoAdaptAll:"\u81EA\u52A8\u83B7\u53D6\u601D\u8003\u7B49\u7EA7",autoAdaptWorking:"\u83B7\u53D6\u4E2D\u2026",autoAdaptDone:"\u5DF2\u9002\u914D {count} \u4E2A\xB7\u4FDD\u5B58\u540E\u5199\u5165",autoAdaptEmpty:"\u5DF2\u5168\u90E8\u914D\u7F6E",autoAdaptUnsuggested:"\u6CA1\u6709\u53EF\u7528\u5EFA\u8BAE",autoAdaptBlocked:"\u6682\u65E0\u53EF\u9002\u914D\u6A21\u578B",autoAdaptFailed:"\u83B7\u53D6\u5931\u8D25\uFF1A{message}",autoAdaptDoneHint:"\u5DF2\u6682\u5B58 {count} \u4E2A\u6A21\u578B\u7684\u9002\u914D\u7ED3\u679C\uFF1A\u70B9\u8BE5\u5361\u7247\u7684\u300C\u4FDD\u5B58\u300D\u540E\u5199\u5165\u3002",autoAdaptEmptyHint:"\u8BE5\u4F9B\u5E94\u5546\u4E0B\u6240\u6709\u6A21\u578B\u90FD\u5DF2\u58F0\u660E\u601D\u8003\u7B49\u7EA7\u3002",autoAdaptUnsuggestedHint:"\u4ECD\u9700\u58F0\u660E\u7684\u6A21\u578B\u6CA1\u6709\u77E5\u8BC6\u5E93\u5339\u914D\u2014\u2014\u8BF7\u9010\u4E2A\u6253\u5F00\u6A21\u578B\u884C\u624B\u52A8\u9002\u914D\u3002",autoAdaptBlockedHint:"\u6682\u65E0\u53EF\u9002\u914D\u5185\u5BB9\uFF1A\u8BE5\u5361\u7247\u8FD8\u6CA1\u6709\u6A21\u578B\u3001\u5C1A\u672A\u4FDD\u5B58\uFF0C\u6216\u5F53\u524D\u8BBE\u7F6E\u6587\u6863\u4E0D\u53EF\u5199\u5165\u3002",apply:"\u5E94\u7528",reset:"\u653E\u5F03\u4FEE\u6539",referenceTitle:"\u53C2\u8003\u5BB9\u91CF",contextWindowLabel:"\u4E0A\u4E0B\u6587\u7A97\u53E3",maxTokensLabel:"\u6700\u5927\u8F93\u51FA",capacityBlank:"\u6CBF\u7528\u76EE\u5F55\u503C",capacityUnitsHint:"\u53EF\u586B\u6570\u5B57\u6216 K/M/B/T \u7B80\u5199\uFF0C\u4F8B\u5982 1,048,576 \u6216 1M\u3002",capacityRule:"\u6700\u5927\u8F93\u51FA\u8D85\u8FC7\u7A97\u53E3\u4F1A\u88AB\u4E0A\u6E38\u62D2\u7EDD\uFF0C\u8FD9\u91CC\u53EA\u505A\u672C\u5730\u6821\u9A8C\u3002",tokensUnit:"tokens",inputModality:"\u652F\u6301\u6A21\u6001",modalityImage:"\u56FE\u7247",modalityImageGen:"\u751F\u56FE",modalityImageGenHint:"\u5DF2\u6807\u8BB0\u4E3A\u751F\u56FE\u6A21\u578B\u2014\u2014\u5728\u5BF9\u8BDD\u6846\u9009\u4E2D\u5B83\u540E\u76F4\u63A5\u8F93\u5165\u63D0\u793A\u8BCD\u53D1\u9001\uFF0C\u5373\u8D70\u56FE\u7247\u63A5\u53E3\u751F\u6210\u56FE\u7247\u3002",modalityInherit:"\u672A\u58F0\u660E\u2014\u2014\u7EE7\u627F\u63D0\u4F9B\u65B9\u9ED8\u8BA4\uFF08\u901A\u5E38\u4EC5\u6587\u672C\uFF09\u3002",modalityDeclared:"\u5DF2\u58F0\u660E\u2014\u2014\u53D6\u6D88\u300C\u56FE\u7247\u300D\u5373\u56DE\u5230\u4EC5\u6587\u672C\u3002",capacityInherit:"\u7559\u7A7A\uFF1D\u6CBF\u7528\u6A21\u578B\u76EE\u5F55\u91CC\u7684\u503C\u3002",clearDeclaration:"\u6E05\u9664\u58F0\u660E",noSuggestion:"\u6CA1\u6709\u9002\u7528\u4E8E\u8BE5\u6A21\u578B\u7684\u5EFA\u8BAE\u3002",writeError:"\u5199\u5165\u5931\u8D25\uFF1A{message}",renderFailed:"\u601D\u8003\u5F3A\u5EA6\u7F16\u8F91\u5668\u6E32\u67D3\u5931\u8D25",wirePlaceholder:"\u7EBF\u4E0A\u53D6\u503C",wireValue:"\u53D6\u503C",wireShow:"\u7F16\u8F91\u7EBF\u4E0A\u53D6\u503C",wireHide:"\u6536\u8D77\u7EBF\u4E0A\u53D6\u503C",wireHint:"\u7559\u7A7A\uFF1D\u6CBF\u7528\u8BE5\u6863\u4F4D\u7684\u7EA6\u5B9A\u62FC\u5199\uFF1Boff \u6863\u586B\u4E86\u975E\u7A7A\u503C\uFF0C\u5C31\u4F1A\u5728\u5173\u95ED\u601D\u8003\u65F6\u53D1\u9001\u8FD9\u4E00\u6BB5\u3002",reasoningDisabled:"\u8BE5\u6A21\u578B\u58F0\u660E\u4E3A\u65E0 reasoning-effort \u63A7\u5236\uFF08false\uFF09\u2014\u2014\u8BF7\u52FF\u52FE\u9009\u601D\u8003\u6863\u3002",bareHint:"\u5168\u90E8\u53D6\u6D88\u5E76\u4FDD\u5B58\u5C06\u6E05\u9664\u58F0\u660E\u2014\u2014\u8BF7\u6C42\u4EE5\u88F8\u683C\u5F0F\u53D1\u51FA\uFF08\u8D70\u63D0\u4F9B\u65B9\u9ED8\u8BA4\uFF09\uFF0C\u90E8\u5206\u4E2D\u8F6C\u7AD9\u9700\u8981\u8FD9\u6837\u3002",defaultRiskDisabled:"\u65E0 off \u6863\uFF1ADefault \u4E0E\u63D0\u4F9B\u5546\u6D4B\u8BD5\u4F1A\u53D1\u9001 thinking: disabled\uFF0C\u8BE5\u6A21\u578B\u4F1A\u62A5\u9519\uFF08\u5982 1210\uFF09\u3002",defaultRiskQwen:"\u65E0 off \u6863\uFF1ADefault \u4F1A\u53D1\u9001 enable_thinking: false\u2014\u2014\u4EC5\u5728\u4E0A\u6E38\u8981\u6C42\u5F00\u542F\u601D\u8003\u65F6\u624D\u4F1A\u5931\u8D25\u3002",stagedHint:"\u5C1A\u672A\u4FDD\u5B58\u3002\u6682\u5B58\u7684\u914D\u7F6E\u5C06\u5728\u8BE5\u6A21\u578B\u4FDD\u5B58\u540E\u81EA\u52A8\u5E94\u7528\u3002",level_off:"off",level_minimal:"minimal",level_low:"low",level_medium:"medium",level_high:"high",level_xhigh:"xhigh",level_max:"max",sliderToggleTitle:"\u6A21\u578B\u4E0E\u601D\u8003\u7B49\u7EA7\u884C",sliderToggleDescription:"\u5728\u6A21\u578B\u83DC\u5355\u4E2D\u663E\u793A\u6A21\u578B\u884C\u4E0E\u601D\u8003\u7B49\u7EA7\u6807\u7B7E\uFF0C\u6863\u4F4D\u968F\u5F53\u524D\u6A21\u578B\u81EA\u52A8\u9002\u914D",sliderToggleAria:"\u542F\u7528\u6A21\u578B\u4E0E\u601D\u8003\u7B49\u7EA7\u884C",settingOn:"\u542F\u7528",settingOff:"\u505C\u7528",sliderNoLevels:"\u5F53\u524D\u6A21\u578B\u672A\u63D0\u4F9B\u601D\u8003\u5F3A\u5EA6\u6863\u4F4D",triggerFallback:"\u9009\u62E9\u6A21\u578B",effortDefault:"\u9ED8\u8BA4",modelRowLabel:"\u6A21\u578B",effortRowLabel:"\u601D\u8003\u7B49\u7EA7",tagVision:"\u652F\u6301\u56FE\u7247\u8F93\u5165",tagThinking:"\u652F\u6301\u601D\u8003\u7B49\u7EA7",tagImageGen:"\u751F\u56FE\u6A21\u578B",sliderNoCurrent:"\u5F53\u524D\u65E0\u9009\u62E9\u4E2D\u7684\u6A21\u578B\u3002",sliderCommitSlow:"\u5207\u6362\u8D85\u65F6\u2014\u2014\u8BF7\u91CD\u8BD5\u3002",defaultEffortLabel:"\u9ED8\u8BA4\u601D\u8003\u5F3A\u5EA6",defaultEffortUnset:"\u8DDF\u968F\u8BB0\u5FC6",defaultEffortHint:"\u65B0\u4F1A\u8BDD\u7684\u8D77\u59CB\u6863\u4F4D\uFF1B\u4F1A\u8BDD\u5185\u624B\u52A8\u9009\u62E9\u59CB\u7EC8\u4F18\u5148\u3002\u7559\u7A7A\u5219\u8DDF\u968F\u8BB0\u5FC6\u94FE\u3002",followMemory:"\u8DDF\u968F\u8BB0\u5FC6",clearDefaultEffort:"\u6E05\u9664\u9009\u62E9",modelSearchPlaceholder:"\u641C\u7D22\u6A21\u578B\u2026",modelSearchNoMatches:"\u672A\u627E\u5230\u5339\u914D\u6A21\u578B",modelSearchClear:"\u6E05\u7A7A\u641C\u7D22",modelSearchFailed:"\u6A21\u578B\u641C\u7D22\u6E32\u67D3\u5931\u8D25",editorTabsLabel:"\u7F16\u8F91\u5668\u5206\u533A",editorTabProvider:"\u4F9B\u5E94\u5546\u914D\u7F6E",editorTabModels:"\u6A21\u578B\u914D\u7F6E",editorTabAdvanced:"\u9AD8\u7EA7\u914D\u7F6E",editorTabFingerprint:"\u6307\u7EB9\u68C0\u6D4B",fpTitle:"\u6A21\u578B\u6307\u7EB9",fpIntro:"\u53EA\u6709 GPT \u4E0E Claude \u7CFB\u5217\u6A21\u578B\u53EF\u68C0\u6D4B\u2014\u2014\u6307\u7EB9\u5E93\u53EA\u8986\u76D6\u8FD9\u4E24\u4E2A\u5BB6\u65CF\uFF0C\u4E0D\u5728\u6B64\u5217\u7684\u6A21\u578B\u4E0D\u4F1A\u51FA\u73B0\u5728\u8FD9\u91CC\u3002",fpCount:"{count} \u4E2A\u53EF\u68C0\u6D4B",fpSummary:"\u5DF2\u8BC6\u522B {identified} \xB7 \u5B58\u7591 {doubtful} \xB7 \u5931\u8D25 {failed}",fpSummaryNone:"\u5C1A\u672A\u68C0\u6D4B\u3002",fpRunning:"\u6B63\u5728\u68C0\u6D4B \xB7 {done} / {total}\uFF08\u5207\u8D70\u4E5F\u4F1A\u7EE7\u7EED\uFF09",fpDetectAll:"\u68C0\u6D4B\u5168\u90E8",fpDetect:"\u68C0\u6D4B",fpRetest:"\u91CD\u6D4B",fpRetry:"\u91CD\u8BD5",fpCost:"{count} \u9898 \xB7 \u7EA6 {seconds} \u79D2",fpCostMinutes:"{count} \u9898 \xB7 \u7EA6 {minutes} \u5206\u949F",fpCostUnknown:"{count} \u9898",fpForget:"\u5FD8\u6389",fpStateUnchecked:"\u672A\u68C0\u6D4B",fpStateRunning:"\u68C0\u6D4B\u4E2D \xB7 {done}/{total}",fpStateIdentified:"{model} \xB7 {probability}",fpStateDoubtful:"\u5B58\u7591 \xB7 {probability}",fpStateFailed:"\u68C0\u6D4B\u5931\u8D25",fpQueued:"\u6392\u961F \xB7 \u7B2C {position} \u4E2A",fpEvidence:"{used} / {total} \u9898",fpSimilarity:"\u76F8\u4F3C\u5EA6",fpDetailShow:"\u5C55\u5F00\u7ED3\u679C",fpDetailHide:"\u6536\u8D77\u7ED3\u679C",fpFamily:"\u5BB6\u65CF",fpChallengeCounted:"\u9898{index} {numbers} \u4E2A \xB7 \u8BA1\u5165",fpChallengeRejected:"\u9898{index} {parsed}/{numbers} \xB7 \u672A\u8BA1\u5165",fpChallengeSkipped:"\u9898{index} {numbers} \u4E2A \xB7 \u65E9\u505C",fpChallengeTitle:"\u4E09\u9053\u9898\u5404\u81EA\u7684\u843D\u70B9\u3002\u6570\u5B57\u662F\u8FD9\u9898\u8981\u6C42\u7684\u6574\u6570\u4E2A\u6570\uFF1B\u6709\u659C\u6760\u65F6\uFF0C\u53F3\u8FB9\u662F\u8981\u6C42\u6570\u3001\u5DE6\u8FB9\u662F\u5B9E\u9645\u7B54\u56DE\u7684\u4E2A\u6570\u3002\u7B54\u56DE\u4E0D\u5230 max(80, \u8981\u6C42\u6570\u7684 55%) \u5C31\u4E0D\u8BA1\u5165\u3002",fpCandidates:"\u6700\u63A5\u8FD1\u7684\u5019\u9009",fpClosedSet:"\u95ED\u96C6\u7ED3\u8BBA\uFF1A\u4E0D\u5728\u5E93\u91CC\u7684\u6A21\u578B\u4ECD\u4F1A\u88AB\u5F52\u7ED9\u6700\u63A5\u8FD1\u7684\u90A3\u4E2A\u3002\u8BF7\u5F53\u6210\u4E00\u6B21\u6BD4\u5BF9\uFF0C\u4E0D\u662F\u8BC1\u660E\u3002",fpCheckedAt:"\u68C0\u6D4B\u4E8E {time}",fpTiming:"\u8017\u65F6\uFF1A\u9996\u5B57 {first} \u79D2 \xB7 \u603B\u8BA1 {total} \u79D2 \xB7 \u5410\u5B57\u7EA6 {rate} \u5B57\u7B26/\u79D2",fpLoadFailed:"\u8BFB\u4E0D\u5230\u5DF2\u5B58\u7ED3\u8BBA\uFF1A{error}",fpRunFailed:"\u68C0\u6D4B\u5931\u8D25\uFF1A{error}",keyRevealShow:"\u663E\u793A\u5BC6\u94A5",keyRevealHide:"\u9690\u85CF\u5BC6\u94A5",keyRevealFailed:"\u65E0\u6CD5\u8BFB\u53D6\u5DF2\u4FDD\u5B58\u7684\u5BC6\u94A5",keysLoading:"\u6B63\u5728\u8BFB\u53D6\u5BC6\u94A5\u2026",keysAdd:"\u6DFB\u52A0\u53E6\u4E00\u4E2A\u5BC6\u94A5",keysAddConfirm:"\u6DFB\u52A0",keysEnable:"\u542F\u7528 {name}",keysDisable:"\u505C\u7528 {name}",keysMissing:"\u672A\u5B58\u50A8",keysEdit:"\u4FEE\u6539",keysRemove:"\u5220\u9664",keysConfirmRemove:"\u786E\u8BA4\u5220\u9664",keysCancel:"\u53D6\u6D88",keysSave:"\u4FDD\u5B58",keysAlias:"\u522B\u540D",keysAliasPlaceholder:"\u540D\u79F0\uFF08\u53EF\u9009\uFF09\uFF0C\u4F8B\u5982 \u56E2\u961F",keysValue:"\u5BC6\u94A5",keysValuePlaceholder:"\u7C98\u8D34 API \u5BC6\u94A5",keysNewValuePlaceholder:"\u7C98\u8D34\u65B0\u7684 API \u5BC6\u94A5",keysAddIllegal:"\u5BC6\u94A5\u53EA\u80FD\u662F\u53EF\u6253\u5370 ASCII \u5B57\u7B26\uFF0C\u4E14\u4E0D\u80FD\u5305\u542B\u7A7A\u683C\u3002",keysAdded:"\u5DF2\u4FDD\u5B58\u5BC6\u94A5\u3002",keysRenamed:"\u5DF2\u4FDD\u5B58\u522B\u540D\u3002",keysReplaced:"\u5DF2\u66FF\u6362\u5BC6\u94A5\u3002",keysRemoved:"\u5DF2\u5220\u9664\u5BC6\u94A5\u3002",keysCopy:"\u590D\u5236 {name}",keysCopied:"\u5DF2\u590D\u5236\u5BC6\u94A5\u3002",keysCopyFailed:"\u65E0\u6CD5\u590D\u5236\u5BC6\u94A5\u3002",keysScope:"{name} \u63D0\u4F9B\u670D\u52A1\u7684\u6A21\u578B",keysModels:"\u6A21\u578B",keysScopeAll:"\u5168\u90E8\u6A21\u578B",keysScopeNone:"\u672A\u53D1\u73B0\u6A21\u578B",keysScopeCount:"{count} \u4E2A\u6A21\u578B",keysScopeSaved:"\u5DF2\u4FDD\u5B58\u6A21\u578B\u8303\u56F4\u3002",keysScopeHint:"\u53EA\u6709\u9009\u4E2D\u7684\u6A21\u578B\u4F1A\u7528\u8FD9\u4E2A Key\uFF0C\u5176\u4ED6\u6A21\u578B\u4EA4\u7ED9\u8BE5\u4F9B\u5E94\u5546\u7684\u5176\u4ED6 Key\u3002",keysScopeAutoHint:"\u8FD9\u4E2A\u8303\u56F4\u7531\u81EA\u52A8\u63A2\u6D4B\u6309\u8FD9\u628A\u5BC6\u94A5\u5B9E\u9645\u63D0\u4F9B\u7684\u6A21\u578B\u5199\u5165\uFF0C\u6BCF\u6B21\u63A2\u6D4B\u90FD\u4F1A\u91CD\u65B0\u6821\u51C6\u3002",keysProbe:"\u81EA\u52A8\u63A2\u6D4B",keysProbing:"\u63A2\u6D4B\u4E2D\u2026",keysProbeHint:"\u63A2\u6D4B\u6BCF\u628A\u5BC6\u94A5\u5B9E\u9645\u63D0\u4F9B\u54EA\u4E9B\u6A21\u578B\uFF0C\u628A\u6BCF\u628A\u5BC6\u94A5\u9650\u5B9A\u5728\u5B83\u4E0E\u672C\u4F9B\u5E94\u5546\u6A21\u578B\u5217\u8868\u7684\u4EA4\u96C6\u4E0A\uFF1A\u80FD\u63D0\u4F9B\u5168\u90E8\u5DF2\u6DFB\u52A0\u6A21\u578B\u65F6\u4FDD\u6301\u201C\u5168\u90E8\u6A21\u578B\u201D\uFF0C\u4E00\u4E2A\u90FD\u4E0D\u63D0\u4F9B\u65F6\u5173\u95ED\u8FD9\u628A\u5BC6\u94A5\u3002",keysProbeSingle:"\u53EA\u6709\u4E00\u4E2A\u5BC6\u94A5\uFF0C\u65E0\u9700\u63A2\u6D4B\u2014\u2014\u5148\u6DFB\u52A0\u7B2C\u4E8C\u4E2A\u5BC6\u94A5\u3002",keysProbeDone:"\u63A2\u6D4B\u5B8C\u6210\uFF0C\u5DF2\u6309\u5404\u5BC6\u94A5\u5B9E\u9645\u652F\u6301\u7684\u6A21\u578B\u52FE\u9009\u3002",keysScopeEmpty:"\u8BE5\u4F9B\u5E94\u5546\u8FD8\u6CA1\u6709\u6A21\u578B\u3002\u8BF7\u5148\u6DFB\u52A0\u6A21\u578B\uFF0C\u518D\u6765\u8FD9\u91CC\u9009\u62E9\u3002",keysProtocolLabel:"{name} \u4F7F\u7528\u7684\u534F\u8BAE",keysProtocolCreate:"\u534F\u8BAE",keysProtocolCreateHint:"\u8FD9\u628A\u5BC6\u94A5\u8981\u8D70\u7684\u534F\u8BAE\uFF1B\u53EF\u9009\u54EA\u4E9B\u53D6\u51B3\u4E8E\u4F9B\u5E94\u5546\u5DF2\u914D\u7F6E\u7684\u7AEF\u70B9\u5730\u5740\u3002",keysProtocolDefault:"\u81EA\u52A8\uFF08\u6309\u6A21\u578B\uFF09",keysProtocolDefaultHint:"\u6309\u6A21\u578B\u81EA\u52A8\u9009\u62E9\u534F\u8BAE\uFF1Aclaude \u7CFB\u6A21\u578B\u8D70 Anthropic \u5730\u5740\uFF0C\u5176\u4F59\u6CBF\u7528\u8BE5\u4F9B\u5E94\u5546\u81EA\u5E26\u7684\u534F\u8BAE\uFF08\u9700\u5DF2\u914D\u7F6E\u5BF9\u5E94\u5730\u5740\uFF09",keysProtocolAnthropic:"Anthropic",keysProtocolAnthropicHint:"Anthropic API \xB7 Claude \u6A21\u578B",keysProtocolOpenAI:"Chat Completions",keysProtocolOpenAIHint:"OpenAI API \xB7 GPT \u6A21\u578B\u3001\u5927\u591A\u6570 agent",keysProtocolResponses:"Responses",keysProtocolResponsesHint:"OpenAI API \xB7 Codex",keysProtocolShortChat:"Chat",keysProtocolShortResponses:"Responses",keysProtocolShortAnthropic:"Anthropic",keysProtocolSaved:"\u5DF2\u4FDD\u5B58\u534F\u8BAE\u3002",keysEndpointOpenAI:"OpenAI",keysEndpointAnthropic:"Anthropic",keysEndpointBalance:"\u4F59\u989D",keysEndpointBalanceHint:"\u53EA\u8BFB\u63A5\u53E3\uFF1A\u7528\u4E8E\u8BFB\u53D6\u8BE5\u4F9B\u5E94\u5546\u4F59\u989D\uFF0C\u4F1A\u5E26\u4E0A\u5BC6\u94A5\u5217\u8868\u4E2D\u7684\u7B2C\u4E00\u628A\u5BC6\u94A5\u3002",keysMoreEndpoints:"\u66F4\u591A\u7AEF\u70B9",keysEndpointsCount:"\u53E6\u6709 {count} \u4E2A",keysEndpointInvalid:"\u5730\u5740\u9700\u4EE5 http:// \u6216 https:// \u5F00\u5934",keysUnreachable:"\u63D2\u4EF6\u7684\u5BC6\u94A5\u63A5\u53E3\u6CA1\u6709\u54CD\u5E94\u3002",keysPanelFailed:"\u5BC6\u94A5\u7BA1\u7406\u9762\u677F\u6E32\u67D3\u5931\u8D25",keysDraftHint:"\u5BC6\u94A5\u6682\u5B58\u5728\u672C\u9875\uFF0C\u521B\u5EFA\u4F9B\u5E94\u5546\u540E\u81EA\u52A8\u4FDD\u5B58\uFF1B\u5237\u65B0\u9875\u9762\u4F1A\u4E22\u5F03\uFF0C\u4E0E\u5361\u7247\u81EA\u8EAB\u8868\u5355\u4E00\u81F4\u3002",keysLastEnabledOff:"\u4E0D\u80FD\u505C\u7528\u6700\u540E\u4E00\u628A\u542F\u7528\u4E2D\u7684\u5BC6\u94A5\u3002",headersTitle:"\u8BF7\u6C42\u5934",headersHint:"\u8BE5\u8DEF\u7531\u7684\u6BCF\u4E2A\u8BF7\u6C42\u90FD\u4F1A\u643A\u5E26\u81EA\u5B9A\u4E49\u8BF7\u6C42\u5934\u3002",camouflageTitle:"\u8BF7\u6C42\u4F2A\u88C5",camouflageHint:"\u8BA9\u8BE5\u8DEF\u7531\u7684\u8BF7\u6C42\u4EE5\u6240\u9009\u5382\u5546\u5B98\u65B9 CLI \u7684\u8EAB\u4EFD\u53D1\u51FA\uFF1A\u643A\u5E26\u5176\u5BA2\u6237\u7AEF\u8BF7\u6C42\u5934\uFF0CClaude \u9884\u8BBE\u8FD8\u4F1A\u8865\u4E0A\u5BF9\u5E94\u6821\u9A8C\u6240\u9700\u7684\u8EAB\u4EFD\u7CFB\u7EDF\u63D0\u793A\u4E0E user_id\u3002\u9ED8\u8BA4\u5173\u95ED\u3002",camouflageOff:"\u5173\u95ED",camouflageCodex:"Codex",camouflageClaude:"Claude",camouflageSaved:"\u5DF2\u4FDD\u5B58\u4F2A\u88C5\u3002",camouflageError:"\u63D2\u4EF6\u7684\u4F2A\u88C5\u63A5\u53E3\u6CA1\u6709\u54CD\u5E94\u3002",camouflageUnavailable:"\u8BF7\u6C42\u62E6\u622A\u672A\u5B89\u88C5\uFF0C\u6B64\u5F00\u5173\u4E0D\u4F1A\u751F\u6548\u3002",historyCompatTitle:"\u65E7\u8BDD\u9898\u6062\u590D",historyCompatHint:"\u5F53\u4E2D\u8F6C\u63D0\u793A\u8BE5\u8BDD\u9898\u7531\u53E6\u4E00\u4E2A\u4E0A\u6E38\u8D44\u6E90\u521B\u5EFA\u65F6\uFF0C\u5728\u53D1\u9001\u526F\u672C\u91CC\u53BB\u6389\u7ED1\u5B9A\u65E7\u8D44\u6E90\u7684\u6807\u8BC6\uFF08\u5FC5\u8981\u65F6\u8FDE\u5386\u53F2\u63A8\u7406\u4E00\u8D77\uFF09\uFF0C\u518D\u91CD\u653E\u8FD9\u6B21\u8BF7\u6C42\uFF0C\u800C\u4E0D\u662F\u8BA9\u8BE5\u56DE\u5408\u76F4\u63A5\u5931\u8D25\u3002\u9ED8\u8BA4\u5173\u95ED\u3002",historyCompatCost:"\u540C\u65F6\u8BC6\u522B 400 \u4E0E 200 \u6D41\u5185\u5931\u8D25\uFF1B\u6700\u591A\u8FFD\u52A0\u4E24\u6B21\u4E0A\u6E38\u8C03\u7528\uFF0C\u5DF2\u8F93\u51FA\u7684\u56DE\u5408\u4E0D\u91CD\u653E\u3002",historyCompatOff:"\u5173\u95ED",historyCompatOn:"\u5F00\u542F",historyCompatUnavailable:"\u8BF7\u6C42\u62E6\u622A\u672A\u5B89\u88C5\uFF0C\u6B64\u5F00\u5173\u4E0D\u4F1A\u751F\u6548\u3002",headersEmpty:"\u5C1A\u672A\u914D\u7F6E\u989D\u5916\u8BF7\u6C42\u5934\u3002",headersAdd:"\u6DFB\u52A0\u8BF7\u6C42\u5934",headersName:"\u540D\u79F0",headersNamePlaceholder:"\u4F8B\u5982 x-company",headersValue:"\u503C",headersEdit:"\u7F16\u8F91",headersSave:"\u4FDD\u5B58",headersCancel:"\u53D6\u6D88",headersClear:"\u5168\u90E8\u6E05\u7A7A",headersRemove:"\u5220\u9664\u8BF7\u6C42\u5934",headersSaved:"\u5DF2\u4FDD\u5B58\u3002",headersCleared:"\u5DF2\u6E05\u7A7A\u2014\u2014\u8BE5\u8DEF\u7531\u4E0D\u518D\u643A\u5E26\u989D\u5916\u8BF7\u6C42\u5934\u3002",headersReadOnly:"\u5F53\u524D\u8BBE\u7F6E\u6587\u6863\u4E0D\u53EF\u5199\u5165\u3002",headersConflictOrigin:"\u540C\u4E00\u4E2A endpoint \u4E0A\u6709\u591A\u4E2A\u8DEF\u7531\u914D\u7F6E\u4E86\u4E0D\u540C\u7684\u8BF7\u6C42\u5934\u503C\uFF1A\u5F53\u8BF7\u6C42\u4F53\u91CC\u7684\u6A21\u578B\u65E0\u6CD5\u552F\u4E00\u5B9A\u4F4D\u5176\u4E2D\u4E00\u4E2A\u8DEF\u7531\u65F6\uFF0C\u8BE5\u8BF7\u6C42\u56DE\u9000\u5230\u7B2C\u4E00\u4E2A\u8DEF\u7531\u7684\u914D\u7F6E\u3002",headersConflictPatched:"\u68C0\u6D4B\u5230\u5B98\u65B9 dsh-llm-pi-ai \u5DF2\u5728\u8BF7\u6C42\u5C42\u5904\u7406\u8BF7\u6C42\u5934\uFF1A\u628A\u503C\u586B\u5728\u4E0A\u65B9\u8BF7\u6C42\u5934\u914D\u7F6E\u4E2D\u5373\u53EF\uFF0C\u65E0\u9700\u91CD\u590D\u63A5\u7BA1\u3002",headersConflictSiblings:"\u68C0\u6D4B\u5230\u4F1A\u6539\u5199\u540C\u4E00\u5C42\u7684\u540C\u7C7B\u63D2\u4EF6\uFF1A{names}\u3002\u540C\u4E00\u65F6\u95F4\u53EA\u5E94\u542F\u7528\u4E00\u79CD\u8BF7\u6C42\u5934\u6539\u5199\uFF0C\u5426\u5219\u7EBF\u4E0A\u751F\u6548\u7684\u662F\u6700\u540E\u5199\u5165\u8005\u3002",headersError:"\u4FDD\u5B58\u5931\u8D25\uFF1A{error}",headersNoRoute:"\u8BE5\u8DEF\u7531\u5DF2\u4E0D\u5728\u8BBE\u7F6E\u6587\u6863\u4E2D\u2014\u2014\u8BF7\u5148\u4FDD\u5B58\u4E00\u6B21\u5B98\u65B9\u5361\u7247\u3002",providerReorderAria:"\u62D6\u52A8\u6392\u5E8F\uFF1A{provider}",providerReorderHint:"\u62D6\u52A8\u8C03\u6574\u4F9B\u5E94\u5546\u987A\u5E8F\u2014\u2014\u6A21\u578B\u5207\u6362\u6309\u6B64\u987A\u5E8F\u663E\u793A\u3002",providerToggleAria:"\u542F\u7528 {provider}",providerToggleHint:"\u7981\u7528\u540E\u8BE5\u4F9B\u5E94\u5546\u4E0D\u5728\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u663E\u793A\u3002",providerBalanceLabel:"\u4F59\u989D",providerBalanceHint:"\u6765\u81EA\u8BE5\u4F9B\u5E94\u5546\u914D\u7F6E\u7684\u4F59\u989D\u63A5\u53E3\u3002",providerBalanceRefresh:"\u5237\u65B0\u4F59\u989D",providerBalanceUnavailable:"\u4F59\u989D \u2014",providerDisabledGroupShow:"\u5C55\u5F00 {count} \u4E2A\u5DF2\u7981\u7528\u7684\u4F9B\u5E94\u5546",providerDisabledGroupHide:"\u6536\u8D77 {count} \u4E2A\u5DF2\u7981\u7528\u7684\u4F9B\u5E94\u5546",providerDisabledGroupHint:"\u5DF2\u7981\u7528\u7684\u4F9B\u5E94\u5546\u914D\u7F6E\u4ECD\u5728\uFF0C\u53EA\u662F\u6298\u53E0\u5728\u8FD9\u91CC\u2014\u2014\u5C55\u5F00\u540E\u53EF\u4EE5\u91CD\u65B0\u542F\u7528\u3002",providerRemoveDisabled:"\u5220\u9664",providerRemoveLocked:"\u5185\u7F6E\u4F9B\u5E94\u5546\u4E0D\u53EF\u5220\u9664\u3002",modelReorderAria:"\u62D6\u52A8\u6392\u5E8F\uFF1A{model}",modelReorderHint:"\u62D6\u52A8\u8C03\u6574\u8BE5\u4F9B\u5E94\u5546\u5185\u6A21\u578B\u987A\u5E8F\u2014\u2014\u6A21\u578B\u5207\u6362\u6309\u6B64\u987A\u5E8F\u663E\u793A\u3002",configButton:"\u9AD8\u7EA7\u8BBE\u7F6E",configButtonHint:"\u6253\u5F00\u9AD8\u7EA7\u8BBE\u7F6E",configPaneTitle:"\u9AD8\u7EA7\u8BBE\u7F6E",configPaneClose:"\u5173\u95ED",configPaneFailed:"\u914D\u7F6E\u9762\u677F\u6E32\u67D3\u5931\u8D25",imagegenSectionTitle:"\u751F\u56FE",imagegenEnable:"\u542F\u7528\u751F\u56FE",cardStateOn:"\u5F00\u542F",cardStateOff:"\u5173\u95ED",imagegenEnabledHint:"\u5141\u8BB8\u4F7F\u7528\u751F\u56FE\u5DE5\u5177\uFF0C\u70B9\u51FB\u5C55\u5F00\u914D\u7F6E\u6A21\u578B\u548C\u56FE\u7247\u53C2\u6570\u3002",imagegenDisabledHint:"\u4E0D\u4F7F\u7528\u751F\u56FE\u5DE5\u5177\uFF0C\u5DF2\u914D\u7F6E\u7684\u6A21\u578B\u548C\u56FE\u7247\u53C2\u6570\u4ECD\u4F1A\u4FDD\u7559\u3002",imagegenExpand:"\u5C55\u5F00\u751F\u56FE\u8BBE\u7F6E",imagegenCollapse:"\u6536\u8D77\u751F\u56FE\u8BBE\u7F6E",imagegenSaving:"\u6B63\u5728\u4FDD\u5B58\u2026",imagegenRefreshFailed:"\u5DF2\u4FDD\u5B58\uFF0C\u4F46\u65E0\u6CD5\u5237\u65B0\u914D\u7F6E\uFF1A{error}",imagegenLoading:"\u6B63\u5728\u8BFB\u53D6\u2026",imagegenLoadFailed:"\u8BFB\u4E0D\u5230\u751F\u56FE\u914D\u7F6E",imagegenDefaultsLabel:"\u9ED8\u8BA4\u53C2\u6570",imagegenDefaultModelLabel:"\u9ED8\u8BA4\u751F\u56FE\u6A21\u578B",imagegenDefaultModelNone:"\u672A\u8BBE\u7F6E",imagegenSizeLabel:"\u5C3A\u5BF8",imagegenQualityLabel:"\u8D28\u91CF",imagegenCountLabel:"\u6570\u91CF",imagegenTimeoutLabel:"\u8D85\u65F6",imagegenTimeoutMinutes:"{minutes} \u5206\u949F",imagegenTimeoutHint:"\u5355\u6B21\u8BF7\u6C42\u4E0A\u9650\uFF1B\u53C2\u6570\u56DE\u9000\u7684\u6BCF\u6B21\u91CD\u8BD5\u4E5F\u7528\u5B83\u3002",imagegenCardRunning:"\u6B63\u5728\u751F\u6210\u56FE\u7247\u2026",imagegenToolMissing:"\u5185\u5EFA\u751F\u56FE\u5DE5\u5177\u6CA1\u6709\u6CE8\u518C\u6210\u529F\uFF0C\u6A21\u578B\u8C03\u4E0D\u5230\u5B83\u3002",imagegenToolMissingWhy:"\u5BBF\u4E3B\u8BF4\uFF1A{reason}",autoContinueSectionTitle:"\u81EA\u52A8\u7EE7\u7EED",autoContinueExpand:"\u5C55\u5F00\u81EA\u52A8\u7EE7\u7EED\u8BBE\u7F6E",autoContinueCollapse:"\u6536\u8D77\u81EA\u52A8\u7EE7\u7EED\u8BBE\u7F6E",autoContinueTitle:"\u81EA\u52A8\u7EE7\u7EED\u88AB\u4E2D\u65AD\u7684\u4F1A\u8BDD",autoContinueDescription:"\u4F1A\u8BDD\u56E0\u65AD\u7EBF\u3001\u8D85\u65F6\u6216\u8F93\u51FA\u8FBE\u5230\u4E0A\u9650\u800C\u4E2D\u65AD\u65F6\uFF0C\u81EA\u52A8\u56DE\u590D\u300C\u7EE7\u7EED\u300D\u3002\u6B63\u5E38\u5B8C\u6210\u3001\u624B\u52A8\u505C\u6B62\u3001\u9274\u6743\u6216\u989D\u5EA6\u7C7B\u9519\u8BEF\u4E0D\u4F1A\u89E6\u53D1\u3002",autoContinueHint:"\u5931\u8D25\u540E\u7B49 {seconds} \u79D2\u518D\u7EE7\u7EED \xB7 \u6700\u591A {count} \u6B21",autoContinueWaitLabel:"\u5931\u8D25\u540E\u7B49\u5F85",autoContinueRetriesLabel:"\u91CD\u8BD5\u4E0A\u9650",autoContinueSecondsUnit:"\u79D2",autoContinueRetriesUnit:"\u6B21",autoContinueConfigHint:"\u586B\u6574\u6570\uFF1A{waitMin}\u2013{waitMax} \u79D2\u3001{retriesMin}\u2013{retriesMax} \u6B21\uFF1B\u79FB\u5F00\u7126\u70B9\u6216\u6309\u56DE\u8F66\u81EA\u52A8\u4FDD\u5B58\u3002\u6BCF\u6B21\u5931\u8D25\u540E\u5148\u7B49\u8FD9\u4E48\u4E45\u518D\u53D1\u9001\u300C\u7EE7\u7EED\u300D\uFF1B\u4F9B\u5E94\u5546\u8981\u6C42\u7684\u7B49\u5F85\u66F4\u4E45\u65F6\u6309\u66F4\u4E45\u7684\u6765\u3002",autoContinueAria:"\u542F\u7528\u81EA\u52A8\u7EE7\u7EED",autoContinueMessage:"\u7EE7\u7EED",autoContinueTriggers:"\u89E6\u53D1\u6761\u4EF6",autoContinueRestore:"\u6062\u590D\u63A8\u8350",autoContinueMaxTokens:"\u8F93\u51FA\u8FBE\u5230\u4E0A\u9650",autoContinueHttpStatus:"HTTP 408 / 425 / 429 / 5xx",autoContinueErrorTypes:"\u9519\u8BEF\u7C7B\u578B",autoContinueCodesMore:"+{count}",autoContinueCodesAll:"\u5168\u9009",autoContinueCodesNone:"\u6E05\u7A7A",autoContinueGroupTransient:"\u77AC\u65F6\u6545\u969C \xB7 \u7B49\u4E00\u4F1A\u513F\u518D\u8BD5\u901A\u5E38\u80FD\u8FC7",autoContinueGroupOther:"\u8BF7\u6C42/\u914D\u7F6E\u672C\u8EAB\u6709\u95EE\u9898 \xB7 \u539F\u6837\u518D\u53D1\u591A\u534A\u8FD8\u662F\u540C\u4E00\u4E2A\u9519",autoContinueGroupFlags:"\u5185\u7F6E\u89E6\u53D1",autoContinueWhyMaxTokens:"\u56DE\u590D\u649E\u5230\u8F93\u51FA\u4E0A\u9650\u88AB\u622A\u65AD\uFF0C\u53D1\u300C\u7EE7\u7EED\u300D\u5C31\u80FD\u63A5\u7740\u5199",autoContinueWhyHttpStatus:"\u7F51\u5173\u6216\u4F9B\u5E94\u5546\u8FD4\u56DE 408 \xB7 425 \xB7 429 \xB7 5xx",autoContinueChipHttp:"HTTP 5xx",autoContinueTagContinue:"\u503C\u5F97\u7EE7\u7EED",autoContinueTagUseless:"\u7EE7\u7EED\u6CA1\u7528",autoContinueTagDepends:"\u770B\u60C5\u51B5",autoContinueWhyEMPTY_RESPONSE:"\u4E0A\u6E38\u56DE\u4E86\u7A7A\u5185\u5BB9\uFF0C\u6D41\u88AB\u622A\u65AD\u6216\u63A8\u7406\u8D85\u65F6",autoContinueWhyRATE_LIMIT:"\u4F9B\u5E94\u5546\u9650\u6D41\uFF08429\uFF09\uFF1A\u53D1\u5F97\u592A\u5FEB\u6216\u5E76\u53D1\u8D85\u4E86",autoContinueWhySERVER:"\u4F9B\u5E94\u5546 5xx\uFF0C\u6216\u7F51\u5173\u4E0B\u6E38\u6682\u65F6\u8FDE\u4E0D\u4E0A",autoContinueWhyTIMEOUT:"\u6D41\u957F\u65F6\u95F4\u6CA1\u6709\u65B0 token\uFF0C\u88AB\u7A7A\u95F2\u8D85\u65F6\u6390\u65AD",autoContinueWhyTRANSPORT:"\u8FDE\u63A5\u4E2D\u9014\u65AD\u5F00\uFF1A\u7F51\u7EDC\u6296\u52A8\u6216\u4EE3\u7406\u6389\u7EBF",autoContinueWhyPI_AI_ERROR:"\u4F9B\u5E94\u5546\u4E1A\u52A1\u9519\u8BEF\uFF1A\u5185\u5BB9\u8FC7\u6EE4\u3001Azure \u8D44\u6E90\u4E0D\u5339\u914D",autoContinueWhyINVALID_REQUEST:"\u8BF7\u6C42\u4E0D\u5408\u6CD5\uFF08400/413\uFF09\uFF1A\u4E0A\u4E0B\u6587\u8D85\u7A97\u53E3\u3001\u53C2\u6570\u9519",autoContinueWhyAUTH:"\u5BC6\u94A5\u65E0\u6548\u3001\u6CA1\u6743\u9650\u6216\u989D\u5EA6\u7528\u5B8C\uFF08401/403\uFF09",autoContinueWhyLEGACY_CLI_OUTCOME_UNKNOWN:"\u65E7\u7248 CLI \u6CA1\u8BB0\u4E0B\u7ED3\u679C",autoContinueWhyUNSUPPORTED_REASONING_EFFORT:"\u8BE5\u6A21\u578B\u4E0D\u652F\u6301\u5F53\u524D\u601D\u8003\u6863\u4F4D\uFF08high \u7B49\uFF09",autoContinueWhyMALFORMED_RESPONSE:"\u6A21\u578B\u8F93\u51FA\u6216\u5DE5\u5177\u8C03\u7528 JSON \u574F\u4E86\uFF0C\u91CD\u751F\u6210\u53EF\u80FD\u597D",autoContinueWhyUNKNOWN_MODEL:"\u8FD9\u4E2A\u6A21\u578B\u540D\u6CA1\u5728\u4F9B\u5E94\u5546\u90A3\u8FB9\u914D\u7F6E",autoContinueControllerWaiting:"\u7B2C {n}/{max} \u6B21 \xB7 {seconds}s",autoContinueControllerSent:"\u5DF2\u53D1\u9001\u300C\u7EE7\u7EED\u300D \u7B2C {n}/{max} \u6B21",autoContinueControllerExhausted:"\u8FDE\u7EED {max} \u6B21\u540E\u505C\u624B",autoContinueControllerStop:"\u505C\u6B62",autoContinueControllerResume:"\u7ACB\u5373\u7EE7\u7EED",autoContinueControllerReset:"\u91CD\u7F6E",autoContinueControllerSettings:"\u8BBE\u7F6E\u2026",autoContinueControllerAria:"\u81EA\u52A8\u7EE7\u7EED\u72B6\u6001",autoContinueControllerDetail:"\u4E0A\u6B21\u4E2D\u65AD\uFF1A{detail}",errorDetailSectionTitle:"\u5931\u8D25\u8BE6\u60C5",errorDetailSummary:"\u5728\u62A5\u9519\u884C\u672B\u5C3E\u52A0\u300C\u67E5\u770B\u8BE6\u60C5\u300D",errorDetailHint:"\u5728\u5931\u8D25\u7684\u90A3\u4E00\u8F6E\u672B\u5C3E\u52A0\u4E00\u4E2A\u300C\u67E5\u770B\u8BE6\u60C5\u300D\u3002\u70B9\u5F00\u76F4\u63A5\u770B\u4F9B\u5E94\u5546\u539F\u672C\u8FD4\u56DE\u7684\u5185\u5BB9\u2014\u2014\u72B6\u6001\u7801\u3001\u9519\u8BEF\u7801\u3001\u539F\u56E0\u3001traceId\uFF0C\u800C\u4E0D\u662F\u88AB\u6362\u6389\u7684\u56FA\u5B9A\u6587\u6848\u3002",errorDetailAria:"\u663E\u793A\u771F\u5B9E\u62A5\u9519\u8BE6\u60C5",errorDetailButton:"\u67E5\u770B\u8BE6\u60C5",errorDetailTitle:"\u672C\u8F6E\u5931\u8D25\u8BE6\u60C5",errorDetailClose:"\u5173\u95ED",errorDetailReason:"\u771F\u5B9E\u539F\u56E0",errorDetailTrace:"traceId",errorDetailCode:"DSH \u9519\u8BEF\u7801",errorDetailShown:"\u754C\u9762\u539F\u672C\u663E\u793A",errorDetailRaw:"\u4E0A\u6E38\u539F\u59CB\u54CD\u5E94",errorDetailCopy:"\u590D\u5236",errorDetailCopied:"\u5DF2\u590D\u5236",errorDetailCopyRaw:"\u590D\u5236\u539F\u6587",errorDetailSource:"\u8BFB\u53D6\u81EA\u4F1A\u8BDD\u539F\u59CB\u4E8B\u4EF6 turn/end\uFF0C\u672A\u7ECF DSH \u5305\u88C5",errorDetailUnwrapped:"\u539F\u6837\u663E\u793A\uFF08\u672A\u88AB\u5305\u88C5\uFF09",errorDetailFixedLabel:"\u56FA\u5B9A\u6587\u6848\uFF0C\u5305\u4F4F\u4E86\u771F\u5B9E\u539F\u56E0"};var go="dsh-model-think-level.slider.enabled",kg=["dsh-reasoning-effort.enabled","@dsh-external/dsh-reasoning-effort.enabled"],yr=Eg();function Eg(){try{let e=window.localStorage.getItem(go),t=e===null?kg.map(n=>window.localStorage.getItem(n)).find(n=>n!==null):null;return(e??t??null)!=="false"}catch{return!0}}var sa=new Set;function Fd(){for(let e of[...sa])e()}function mt(){return yr}function qd(e){if(yr!==e){yr=e;try{window.localStorage.setItem(go,String(e))}catch{}Fd()}}function Kd(e){yr!==e&&(yr=e,Fd())}function ho(e){return sa.add(e),()=>{sa.delete(e)}}var bo="dsh-model-think-level.provider-order",Bd=["deepseek-account","deepseek-official"];function An(e){if(e===null)return[];try{let t=JSON.parse(e);return Array.isArray(t)?la(t.filter(n=>typeof n=="string")):[]}catch{return[]}}function la(e){let t=new Set,n=[];for(let r of e)r.length===0||t.has(r)||(t.add(r),n.push(r));return n}var Ln=(()=>{try{return An(window.localStorage.getItem(bo))}catch{return[]}})(),da=new Set;function Wd(){for(let e of[...da])e()}function Gd(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function Rn(){return Ln}function yo(e){let t=la(e);if(!Gd(Ln,t)){Ln=t;try{window.localStorage.setItem(bo,JSON.stringify(Ln))}catch{}Wd()}}function Ud(e){let t=la(e);Gd(Ln,t)||(Ln=t,Wd())}function Cn(e){return da.add(e),()=>{da.delete(e)}}function ca(e){let t=n=>{let r=Bd.indexOf(n);return r<0?Bd.length:r};return e.map((n,r)=>({id:n,index:r,rank:t(n)})).sort((n,r)=>n.rank-r.rank||n.index-r.index).map(n=>n.id)}function Hn(e,t){let n=new Map;for(let a of t)n.has(a)||n.set(a,n.size);let r=[],o=[];e.forEach((a,s)=>{n.has(a)&&(r.push(s),o.push(a))}),o.sort((a,s)=>n.get(a)-n.get(s));let i=[...e];return r.forEach((a,s)=>{i[a]=o[s]}),i}function jd(e){return Hn(ca(e),Rn())}function ua(e,t,n){let r=e.indexOf(t);if(r<0)return[...e];let o=[...e];o.splice(r,1);let i=Math.max(0,Math.min(o.length,n));return o.splice(i,0,t),o}var vo="dsh-model-think-level.providers.disabled",fa=new Set,_t=Tg();function Tg(){try{return An(window.localStorage.getItem(vo))}catch{return[]}}function zd(e){return An(e)}function vr(){return _t}function Nn(e){return!_t.includes(e)}function $d(e,t){let n=!_t.includes(e);t!==n&&pa(t?_t.filter(r=>r!==e):[..._t,e],!0)}function Vd(e){pa(e,!1)}function Yd(e){pa(e,!0)}function On(e){return fa.add(e),()=>{fa.delete(e)}}function Sg(e,t){return e.length!==t.length?!1:e.every(n=>t.includes(n))}function pa(e,t){if(!Sg(_t,e)){if(_t=[...new Set(e)],t)try{window.localStorage.setItem(vo,JSON.stringify(_t))}catch{}for(let n of[...fa])n()}}var wo="dsh-model-think-level.model-order";function ga(e){if(e===null)return{};try{let t=JSON.parse(e);if(t===null||typeof t!="object"||Array.isArray(t))return{};let n={};for(let[r,o]of Object.entries(t)){if(r.length===0||!Array.isArray(o))continue;let i=ha(o.filter(a=>typeof a=="string"));i.length>0&&(n[r]=i)}return n}catch{return{}}}function ha(e){let t=new Set,n=[];for(let r of e)r.length===0||t.has(r)||(t.add(r),n.push(r));return n}var Ft=(()=>{try{return ga(window.localStorage.getItem(wo))}catch{return{}}})(),ma=new Set;function ba(){for(let e of[...ma])e()}function Mg(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function Jd(){try{window.localStorage.setItem(wo,JSON.stringify(Ft))}catch{}}function wr(){return Ft}function Xd(e){return Ft[e]??Lg}var Lg=[];function Qd(e,t){if(e.length===0)return;let n=ha(t),r=Xd(e);if(Mg(r,n)&&(n.length>0||!(e in Ft)))return;let o={...Ft};n.length===0?delete o[e]:o[e]=n,Ft=o,Jd(),ba()}function Zd(e){Ft=e,ba()}function el(e){let t={};for(let[n,r]of Object.entries(e)){if(n.length===0)continue;let o=ha(r);o.length>0&&(t[n]=o)}Ft=t,Jd(),ba()}function In(e){return ma.add(e),()=>{ma.delete(e)}}function Ag(e,t){return Hn(e,t)}function tl(e,t){return Hn(t,Xd(e))}function ya(e,t){if(e.length===0||t.length===0)return e;let n=new Map(e.map(r=>[r.id,r]));return Ag(e.map(r=>r.id),t).map(r=>n.get(r))}var nl="dsh-model-think-level.order-saved-at",Rg=400,Cg=6e4;function xa(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e){if(typeof r!="string")continue;let o=r.trim();o.length===0||t.has(o)||(t.add(o),n.push(o))}return n}function Hg(e){if(typeof e!="object"||e===null||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e)){if(n.length===0)continue;let o=xa(r);o.length>0&&(t[n]=o)}return t}function rl(e){if(typeof e!="object"||e===null)return;let t=e;return{savedAt:typeof t.savedAt=="number"&&Number.isFinite(t.savedAt)?t.savedAt:0,providerOrder:xa(t.providerOrder),modelOrder:Hg(t.modelOrder),providersDisabled:Array.isArray(t.providersDisabled)?xa(t.providersDisabled):void 0}}function ol(e){return e.providerOrder.length>0||Object.keys(e.modelOrder).length>0||e.providersDisabled!==void 0}function xr(){try{let e=window.localStorage.getItem(nl),t=e===null?0:Number(e);return Number.isFinite(t)&&t>0?t:0}catch{return 0}}function Ea(e){try{window.localStorage.setItem(nl,String(e))}catch{}}function kr(){return JSON.stringify({providerOrder:Rn(),modelOrder:wr(),providersDisabled:vr()})}var Kt,gt,Pn=new Set,xo,va,_e=!1,ka=!1,qt,Ve=0;function Ng(){let e=Math.max(Date.now(),xr()+1);return Ea(e),e}function il(){if(gt=void 0,_e)return;let e=xr(),t=JSON.stringify({savedAt:e>0?e:Date.now(),providerOrder:Rn(),modelOrder:wr(),providersDisabled:vr()});Kt=kr();let n=Ve,r=fetch(na,{method:"POST",headers:{"content-type":"application/json"},body:t}).then(async o=>{if(_e||n!==Ve)return!0;let i=await o.json().catch(()=>{});if(_e||n!==Ve)return!0;let a=rl(i?.data);return o.status===409?xr()!==e?!0:a!==void 0&&ol(a)?(al(a),!0):(Kt=void 0,!1):o.ok?(a!==void 0&&a.savedAt>xr()&&Ea(a.savedAt),!0):(Kt=void 0,!1)}).catch(()=>(!_e&&n===Ve&&(Kt=void 0),!1));Pn.add(r),r.then(()=>{Pn.delete(r)})}function Ta(e){_e||gt!==void 0||kr()!==Kt&&(gt=setTimeout(il,e))}function Sa(){gt!==void 0&&(clearTimeout(gt),il())}async function Og(){if(_e)return;let e=Ve;if(await Eo(),!(_e||e!==Ve))for(kr()!==Kt&&gt===void 0&&Pn.size===0&&Ta(0);!_e&&e===Ve&&(gt!==void 0||Pn.size>0);){Sa();let t=await Promise.all([...Pn]);if(_e||e!==Ve)return;if(t.includes(!1))throw new Error("\u6A21\u578B\u987A\u5E8F\u548C\u542F\u505C\u5C1A\u672A\u4FDD\u5B58\uFF0C\u8BF7\u91CD\u8BD5\u540C\u6B65")}}function wa(){_e||ka||(Ng(),Ta(Rg))}function al(e){ka=!0;try{yo(e.providerOrder),el(e.modelOrder),e.providersDisabled!==void 0&&Yd(e.providersDisabled)}finally{ka=!1}Ea(e.savedAt),Kt=kr()}function Eo(){if(_e)return Promise.resolve();if(qt!==void 0)return qt;let e=Ig().finally(()=>{qt===e&&(qt=void 0)});return qt=e,e}async function Ig(){let e=Ve,t;try{let o=await fetch(na,{method:"GET"});if(o.ok){let i=await o.json();i.ok===!0&&(t=rl(i.data))}}catch{return}if(_e||e!==Ve||gt!==void 0)return;let n=xr(),r=JSON.stringify({providerOrder:t?.providerOrder??[],modelOrder:t?.modelOrder??{},providersDisabled:t?.providersDisabled??[]});if(t!==void 0&&ol(t)&&t.savedAt>=n){al(t);return}kr()!==r&&Ta(0)}function ko(){_e||typeof document<"u"&&document.visibilityState==="hidden"||Eo()}function sl(){_e=!1,Ve+=1,qt=void 0,Pn.clear(),Kt=void 0;let e=Cn(wa),t=In(wa),n=On(wa);xo=setInterval(ko,Cg);let r=a=>{let s=a.detail;typeof s?.waitUntil=="function"&&s.waitUntil(Og())},o=()=>{let a=Ve;(async()=>(qt!==void 0&&await qt,!_e&&a===Ve&&await Eo()))()};typeof window<"u"&&(window.addEventListener("focus",ko),window.addEventListener("dsh-webdav-sync:before-snapshot",r),window.addEventListener("dsh-webdav-sync:applied",o));let i=()=>{document.visibilityState==="visible"&&ko()};return typeof document<"u"&&document.addEventListener("visibilitychange",i),va=()=>{typeof document<"u"&&document.removeEventListener("visibilitychange",i),typeof window<"u"&&(window.removeEventListener("focus",ko),window.removeEventListener("dsh-webdav-sync:before-snapshot",r),window.removeEventListener("dsh-webdav-sync:applied",o))},Eo(),()=>{_e=!0,Ve+=1,gt!==void 0&&clearTimeout(gt),gt=void 0,xo!==void 0&&clearInterval(xo),xo=void 0,va?.(),va=void 0,e(),t(),n()}}var dl=`
8
8
  /* ---- Quiet Precision: the plugin's own token layer ----
9
9
  Every value below is a HOST design-platform token (--dsw-*) with the light
10
10
  theme's literal as the fallback, so the plugin inherits a theme switch for
@@ -5303,11 +5303,12 @@ li.bre-row-disabled [class*="rowName"] { opacity: .5; }
5303
5303
  .bre-ed-src { flex: 1; min-width: 0; font-size: 10.5px; color: var(--bre-ink-3); }
5304
5304
  .bre-config-error-detail-copy { margin: 0; max-width: none; }
5305
5305
 
5306
- `;var kr="bre:endpoints-changed",Er="bre:settings-changed",Tr="bre:balance-changed";var Ar=require("react"),Bl=require("react-dom");var O=require("react"),Al=require("react-dom");var V=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function dl(e){let t=e.toLowerCase();return t.includes("compat")||t.includes("thinkingtokenbudget")||t.includes("vllmpriority")||t.includes("supportsmaxoutput")}function _n(e,t){if(!V(e))return[];let n=e[t];return!V(n)||!Array.isArray(n.models)?[]:n.models.filter(V)}function nn(e,t){if(!V(e))return{};let n=e[t];if(!V(n))return{};let r=typeof n.api=="string"?n.api:void 0,o=typeof n.baseURL=="string"?n.baseURL:void 0,i=typeof n.displayName=="string"?n.displayName:void 0;return{api:r,baseURL:o,displayName:i}}var ml=["off","minimal","low","medium","high","xhigh","max"],Ig=["text","image"];var Dg=[{id:"deepseek-v4-vision",patterns:["deepseek-v4-flash-vision","deepseek-v4-vision"],efforts:{off:"none",low:"low",high:"high",max:"max"},defaultEffort:"high",compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:384e3,note:"DeepSeek \u89C6\u89C9\u5B9E\u9A8C\u7248 id\uFF08deepseek-v4-flash-vision-exp\uFF09\u3002\u5B98\u65B9\u76EE\u5F55\u5DF2\u6807\u6CE8\u8BE5\u6A21\u578B\u9000\u5F79\uFF0C\u540D\u5B57\u4ECD\u88AB\u63A5\u53D7\u3001\u7531\u73B0\u884C deepseek-flash \u63D0\u4F9B\u670D\u52A1\u2014\u2014\u56FE\u7247\u8F93\u5165\u73B0\u5DF2\u7531 deepseek-flash \u539F\u751F\u63D0\u4F9B\u3002"},{id:"deepseek-v4-1-flash",patterns:["deepseek-v4.1-flash","deepseek-flash"],efforts:{off:"none",low:"low",high:"high",max:"max"},defaultEffort:"high",compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:384e3,note:'DeepSeek-V4.1-Flash\uFF082026-09-10 \u53D1\u5E03\u7684\u73B0\u884C\u5B98\u65B9\u6A21\u578B\uFF0C\u5B98\u65B9 id \u4E3A deepseek-flash\uFF1B25 \u4E07\u5E76\u53D1\u3001**\u539F\u751F\u56FE\u7247\u8F93\u5165**\uFF09\u3002V4.1 \u7684\u5404\u5199\u6CD5\uFF08deepseek-flash\u3001deepseek-v4.1-flash\u3001deepseek-v4-1-flash\uFF0C\u4EE5\u53CA\u5E26\u65E5\u671F\u540E\u7F00\u7684\u7B2C\u4E09\u65B9\u53D8\u4F53\uFF09\u90FD\u5F52\u6B64\u6761\u2014\u2014\u7EAF\u6587\u672C\u7684 deepseek-v4 \u4E3B\u5E72\u4E0D\u518D\u541E\u6389\u5B83\u4EEC\u3002\u5B98\u65B9\u679A\u4E3E\u540C V4 \u7CFB\uFF1AOff\uFF08thinking:"disabled"\uFF09/ Low / High / Max\uFF0C\u9ED8\u8BA4 High\uFF1B\u5BB9\u91CF 1,048,576 \u4E0A\u4E0B\u6587 / \u6700\u5927\u8F93\u51FA 384K\u3002'},{id:"deepseek-v4",patterns:["deepseek-v4"],efforts:{off:"none",low:"low",high:"high",max:"max"},defaultEffort:"high",compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text"],contextWindow:1048576,maxTokens:384e3,note:'DeepSeek \u5B98\u65B9\u679A\u4E3E Low / High / Max\uFF08\u9ED8\u8BA4 High\uFF1Bminimal\u3001medium\u3001xhigh \u517C\u5BB9\u6620\u5C04\uFF0Cultra\u2192max\uFF09\uFF0COff \u5373 thinking:"disabled"\uFF08Responses API \u4E0B off \u4EE5 reasoning.effort:"none" \u8868\u793A\uFF09\u3002\u672C\u6761\u76EE\u662F V4 \u5BB6\u65CF\u7684**\u7EAF\u6587\u672C**\u6210\u5458\uFF1Adeepseek-v4-pro\uFF08= DeepSeek-V4-Pro-0813\uFF0C\u5B98\u65B9\u4E0D\u652F\u6301\u56FE\u7247\uFF09\u4E0E\u5DF2\u9000\u5F79\u6A21\u578B\u7684\u517C\u5BB9\u522B\u540D deepseek-v4-flash\uFF08deepseek-v4-flash-vision-exp \u53E6\u6709\u89C6\u89C9\u6761\u76EE\uFF09\u3002**\u6536\u56FE\u7684 V4.1-Flash\uFF08\u5B98\u65B9 id deepseek-flash\uFF09\u53E6\u6709\u4E13\u95E8\u6761\u76EE**\uFF0C\u5176 input \u542B image\u3002\u5BB9\u91CF\uFF1A1,048,576 \u4E0A\u4E0B\u6587 / \u6700\u5927\u8F93\u51FA 384K\uFF08393,216\uFF1B\u9ED8\u8BA4\u975E\u601D\u8003 8K\u3001\u601D\u8003 64K\u3001effort=max \u65F6 128K\uFF09\u3002'},{id:"deepseek-v3",patterns:["deepseek-v3","deepseek-chat"],efforts:{off:"none",high:"high",max:"max"},compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text"],contextWindow:163840,maxTokens:65536,note:"DeepSeek V3 \u6863\u4F4D\uFF1AOff / High / Max\u3002\u5B98\u65B9\u5DF2\u505C\u552E V3 \u4EE3\uFF08\u5B9A\u4EF7\u9875\u4EC5\u5269 V4 \u4E09\u578B\uFF09\uFF0C\u5BB9\u91CF\u53D6\u76EE\u5F55\u73B0\u5F79\u503C\u3002"},{id:"deepseek-r1",patterns:["deepseek-r1","deepseek-reasoner"],efforts:{high:"high"},defaultEffort:"high",compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text"],contextWindow:163840,maxTokens:32768,note:"DeepSeek-R1 \u4E3A\u63A8\u7406\u6A21\u578B\uFF0C\u4EC5\u63D0\u4F9B High\u3002\u5B98\u65B9\u5DF2\u4E0B\u67B6 R1 \u4EE3\uFF0C\u5BB9\u91CF\u53D6\u76EE\u5F55 r1-0528 \u503C\u3002"},{id:"openai-gpt-5-2",patterns:["gpt-5.2"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.2 \u6863\u4F4D\uFF1ANone / Low / Medium / High / XHigh\uFF08\u9ED8\u8BA4 None\uFF09\u3002\u5B98\u65B9\u53E6\u652F\u6301 PDF \u8F93\u5165\uFF08\u6838\u5FC3\u8BCD\u8868\u6682\u4E0D\u542B\uFF09\u3002gpt-5.2-pro \u5B98\u65B9\u9875\u672A\u5355\u5217\u6863\u4F4D\u884C\uFF0C\u6309\u672C\u6761\u76EE\u540C\u6863\u5904\u7406\uFF1Bgpt-5.2-codex \u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"openai-gpt-5-2-codex",patterns:["gpt-5.2-codex"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.2-Codex \u6863\u4F4D\uFF1ALow / Medium / High / XHigh\uFF08\u65E0 None \u6863\uFF0C\u52FF\u52FE Off\uFF09\uFF0C\u5E26\u56FE\u8F93\u5165\u3001400K\u3002"},{id:"openai-gpt-5-6",patterns:["gpt-5.6"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:"GPT-5.6\uFF08\u522B\u540D\u5373 sol\uFF09\u6863\u4F4D\uFF1ANone / Low / Medium(\u9ED8\u8BA4) / High / XHigh / Max\uFF1Bsol/luna/terra \u540C\u6863\uFF0C\u5E26\u56FE\u8F93\u5165\u30022026-10 \u6821\u51C6\uFF1A\u4E0A\u4E0B\u6587\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8BB0 272,000\uFF08\u6B64\u524D\u8BEF\u8BB0 1,050,000\uFF09\u3002"},{id:"openai-gpt-5-5",patterns:["gpt-5.5"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:"GPT-5.5 \u6863\u4F4D\uFF1ANone / Low / Medium(\u9ED8\u8BA4) / High / XHigh\uFF08\u65E0 Max \u6863\uFF09\uFF0C\u5E26\u56FE\u8F93\u5165\u3002pro \u53D8\u4F53\u4EC5 High(\u9ED8\u8BA4) / XHigh\u30011.05M \u4E0A\u4E0B\u6587\u4E14\u4EC5 Responses API\u30022026-10 \u6821\u51C6\uFF1A\u4E0A\u4E0B\u6587\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8BB0 272,000\uFF08\u6B64\u524D\u8BEF\u8BB0 1,050,000\uFF09\u3002"},{id:"openai-gpt-5-4",patterns:["gpt-5.4"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:"GPT-5.4 \u6863\u4F4D\uFF1ANone(\u9ED8\u8BA4) / Low / Medium / High / XHigh\uFF0C\u5E26\u56FE\u8F93\u5165\u3002pro \u53D8\u4F53\u4EC5 Medium/High/XHigh\uFF081.05M\uFF09\uFF1Bmini/nano \u4E3A 400K \u4E0A\u4E0B\u6587\u30022026-10 \u6821\u51C6\uFF1A\u4E0A\u4E0B\u6587\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8BB0 272,000\uFF08\u6B64\u524D\u8BEF\u8BB0 1,050,000\uFF09\u3002"},{id:"openai-gpt-5-3",patterns:["gpt-5.3"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.3-Codex \u6863\u4F4D\uFF1ANone / Low / Medium(\u9ED8\u8BA4) / High / XHigh\uFF0C\u5E26\u56FE\u8F93\u5165\u3001400K\uFF1B2026-10 \u6821\u51C6\uFF1ANone \u6863\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8865\u56DE\uFF08\u6B64\u524D\u6309\u65E7\u6A21\u578B\u9875\u8BB0\u4E3A\u65E0 None\uFF09\u3002gpt-5.3-chat \u4E3A\u975E\u63A8\u7406\u804A\u5929\u6A21\u578B\uFF08\u89C1 chat \u6761\u76EE\uFF09\u3002"},{id:"openai-gpt-5-1",patterns:["gpt-5.1"],efforts:{off:"none",low:"low",medium:"medium",high:"high"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.1 \u6863\u4F4D\uFF1ANone / Low / Medium / High\uFF08\u9ED8\u8BA4 None\uFF09\u3002"},{id:"openai-gpt-5-1-codex",patterns:["gpt-5.1-codex"],efforts:{low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.1-Codex \u7CFB\u5217\uFF1A\u5B98\u65B9\u6A21\u578B\u9875\u672A\u5355\u5217 effort \u503C\u57DF\uFF0C\u6309\u540C\u4EE3\u4FDD\u5B88\u6863 Low / Medium / High\uFF08\u65E0 None\uFF1Bxhigh \u672A\u8BC1\u5B9E\uFF09\u3002\u5982\u7AEF\u70B9\u652F\u6301 xhigh/none \u53EF\u624B\u8C03\u3002"},{id:"openai-gpt-5",patterns:["gpt-5"],efforts:{minimal:"minimal",low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5 \u521D\u4EE3\u6863\u4F4D\uFF1AMinimal / Low / Medium / High\uFF0C\u65E0\u5173\u95ED\u6863\u3002"},{id:"openai-gpt-5-2-chat",patterns:["gpt-5.2-chat"],efforts:{off:null,medium:"medium",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:128e3,maxTokens:16384,note:"GPT-5.2-Chat\uFF08\u5B98\u65B9 id gpt-5.2-chat-latest\uFF09\uFF1Api-ai 1.2.0 \u76EE\u5F55\u8BB0\u4E3A\u63A8\u7406\u6A21\u578B\uFF0C\u4EC5 Medium / XHigh \u4E24\u6863\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF0C\u975E\u663E\u5F0F\u5173\u95ED\uFF09\uFF0C128K / 16,384 \u8F93\u51FA\u30022026-10 \u65B0\u589E\u6761\u76EE\u3002"},{id:"openai-chat",patterns:["gpt-5.1-chat-latest","gpt-5.3-chat-latest","gpt-5-chat-latest","gpt-chat-latest","gpt-5-chat","gpt-5.1-chat","gpt-5.3-chat"],efforts:!1,input:["text","image"],contextWindow:128e3,maxTokens:16384,note:"-chat \u7CFB\u5217\uFF08\u5B98\u65B9 id \u4E3A gpt-5.x-chat-latest\uFF09\u4E3A\u975E\u63A8\u7406\u804A\u5929\u6A21\u578B\uFF0C\u4E0D\u652F\u6301 effort \u53C2\u6570\uFF08\u52FF\u52FE\u601D\u8003\u6863\uFF09\uFF1B\u5B98\u65B9\u652F\u6301\u56FE\u7247\u8F93\u5165\uFF0C128K / 16,384 \u8F93\u51FA\u3002gpt-5-chat-latest \u5DF2\u4E8E 2026-07-23 \u4E0B\u67B6\u3001gpt-chat-latest \u5DF2\u65E0\u5B98\u65B9\u9875\u9762\uFF08\u4FDD\u7559\u6A21\u5F0F\u4F9B\u7F51\u5173\uFF09\u3002gpt-5.2-chat \u53E6\u6709\u63A8\u7406\u6761\u76EE\u3002"},{id:"openai-o",patterns:["o1","o3","o4"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:2e5,maxTokens:1e5,note:"OpenAI o \u7CFB\u6863\u4F4D\uFF1ALow / Medium / High\u3002\u5B98\u65B9\u5DF2\u4E8E 2026-06 \u516C\u544A\u9000\u5F79\uFF08o1/o1-pro/o3-mini/o4-mini 2026-10-23 \u79FB\u9664\u3001o3/o3-pro 2026-12-11\uFF09\uFF0C\u7F51\u5173\u6B8B\u7559\u4ECD\u53EF\u547D\u4E2D\uFF1B\u591A\u6570 o \u7CFB\u7AEF\u70B9\u6536\u56FE\uFF08o3-mini \u4F8B\u5916\uFF09\u3002"},{id:"openai-gpt-oss",patterns:["gpt-oss"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"low",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:131072,maxTokens:131072,note:"GPT-OSS \u5F00\u6E90\u6743\u91CD\uFF08Ollama/vLLM \u5E38\u89C1\uFF09\uFF1Areasoning effort Low / Medium / High\uFF0C\u7EAF\u6587\u672C\uFF0C131K \u4E0A\u4E0B\u6587 / 131K \u8F93\u51FA\u30022026-09 \u590D\u6838\uFF1A\u5B98\u65B9\u6A21\u578B\u9875\u73B0\u5728\u5199 Chat Completions = Not supported\u3001\u65E0\u56FE\u7247\u8F93\u5165\uFF08\u9ED8\u8BA4 Low \u6765\u81EA\u5B98\u65B9 CLI\uFF0C\u4E0D\u662F API \u9875\uFF09\uFF0C\u56E0\u6B64\u8FD9\u91CC\u4E0D\u518D\u58F0\u660E Off\u3002"},{id:"openai-gpt-6",patterns:["gpt-6-luna","gpt-6-sol","gpt-6-terra","gpt-6.1"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:'GPT-6 \u7CFB\uFF08luna/sol/terra\uFF0C2026-10 \u6821\u51C6\u65B0\u589E\uFF09\uFF1Api-ai 1.2.0 \u76EE\u5F55\u5168\u6863 None / Low / Medium / High / XHigh / Max\uFF0C\u5E26\u56FE\u8F93\u5165\uFF0C272,000 \u4E0A\u4E0B\u6587 / 128,000 \u8F93\u51FA\u3002gpt-6-astra \u89C1\u5355\u72EC\u6761\u76EE\uFF08\u88F8 "gpt-6" \u4E0E 6.1-sol \u7531 astra \u6761\u76EE\u627F\u63A5\uFF0Coff \u4EE5\u7701\u7565\u8868\u8FBE\uFF0C"none" \u672A\u8BC1\u5B9E\u53EF\u624B\u8C03\uFF09\u3002'},{id:"openai-gpt-6-astra",patterns:["gpt-6-astra","gpt-6","gpt-6.1-sol"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:'GPT-6 Astra \u6863\u4F4D\uFF1ALow / Medium / High / XHigh / Max\u2014\u2014**\u6CA1\u6709 None \u6863**\uFF08\u5B98\u65B9\u539F\u6587\uFF1A\u8BBE\u4E3A none \u8FD4\u56DE HTTP 400\uFF09\uFF0C\u56E0\u6B64\u672C\u6761\u76EE\u4E0D\u58F0\u660E Off\u3002\u5E26\u56FE\u8F93\u5165\uFF1B2026-10 \u6821\u51C6\uFF1A\u4E0A\u4E0B\u6587\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8BB0 272,000\uFF08\u6B64\u524D\u8BEF\u8BB0 1,050,000\uFF09\u3002\u5DE5\u5177\u8C03\u7528\u9700\u8D70 Responses API\u3002gpt-6 luna/sol/terra \u89C1\u5355\u72EC\u6761\u76EE\uFF1B\u88F8 "gpt-6" \u4E0E 6.1-sol\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\u7531\u672C\u6761\u76EE\u627F\u63A5\u3002'},{id:"openai-gpt-daybreak",patterns:["gpt-daybreak"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:105e4,maxTokens:128e3,note:"GPT-Daybreak\uFF08blue-latest 1.05M / red-latest 400K\uFF0C2026-10 \u65B0\u589E\uFF09\uFF1Api-ai 1.2.0 \u76EE\u5F55\u5168\u6863 None / Low / Medium / High / XHigh / Max\uFF0C\u5E26\u56FE\u8F93\u5165 / 128,000 \u8F93\u51FA\u3002"},{id:"openai-gpt-realtime",patterns:["gpt-realtime"],efforts:{minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:128e3,maxTokens:32e3,note:"GPT-Realtime 2.1\uFF082026-10 \u65B0\u589E\uFF09\uFF1Api-ai 1.2.0 \u76EE\u5F55\u6863\u4F4D Minimal / Low / Medium / High / XHigh\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF0C128,000 \u4E0A\u4E0B\u6587 / 32,000 \u8F93\u51FA\u3002"},{id:"openai-gpt-5-6-cyber",patterns:["gpt-5.6-cyber"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.6-Cyber\uFF1A\u5B98\u65B9\u6A21\u578B\u9875\u672A\u5355\u5217 effort \u503C\u57DF\uFF08\u4E0D\u7B49\u4E8E\u4E0D\u652F\u6301\uFF09\uFF0C\u6545\u6309\u540C\u4EE3\u4FDD\u5B88\u6863 Low / Medium / High / XHigh\uFF1B\u8BE5\u578B\u53F7\u4EC5 Responses API\uFF0C\u5E26\u56FE\u8F93\u5165\u3001400K \u4E0A\u4E0B\u6587\u3002\u5B98\u65B9\u652F\u6301\u7684\u5176\u4ED6\u6863\u4F4D\u53EF\u624B\u8C03\u540E\u5E94\u7528\u3002"},{id:"openai-gpt-4o",patterns:["gpt-4o"],efforts:!1,input:["text","image"],contextWindow:128e3,maxTokens:16384,note:"GPT-4o \u4EE3\u9645\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u4E0D\u652F\u6301 effort \u53C2\u6570\uFF08\u52FF\u52FE\u601D\u8003\u6863\uFF09\uFF1B\u56FE\u7247\u8F93\u5165\u5168\u7CFB\u6807\u914D\uFF0C128K / 16,384 \u8F93\u51FA\u3002"},{id:"openai-gpt-4-1",patterns:["gpt-4.1"],efforts:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,note:"GPT-4.1 \u5168\u7CFB\uFF08\u542B mini/nano\uFF09\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u4E0D\u652F\u6301 effort \u53C2\u6570\uFF1B\u5B98\u65B9 1,047,576 \u4E0A\u4E0B\u6587 / 32,768 \u8F93\u51FA\uFF0C\u5168\u7CFB\u5E26\u56FE\u8F93\u5165\u3002"},{id:"openai-gpt-4-turbo-preview",patterns:["gpt-4-turbo-preview"],efforts:!1,input:["text"],contextWindow:128e3,maxTokens:4096,note:"GPT-4 Turbo Preview\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u7EAF\u6587\u672C\u8F93\u5165\uFF08\u6B63\u5F0F turbo \u5FEB\u7167\u652F\u6301\u56FE\u7247\uFF0C\u89C1\u4E0B\u6761\uFF09\uFF0C128K\u3002"},{id:"openai-gpt-4-turbo",patterns:["gpt-4-turbo"],efforts:!1,input:["text","image"],contextWindow:128e3,maxTokens:4096,note:"GPT-4 Turbo\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u5B98\u65B9\u652F\u6301\u56FE\u7247\u8F93\u5165\uFF0C128K / 4,096 \u8F93\u51FA\u3002"},{id:"openai-gpt",patterns:["gpt-4","gpt-3.5"],efforts:!1,input:["text"],note:"GPT-4/3.5 \u4EE3\u9645\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u4E0D\u652F\u6301 effort \u53C2\u6570\uFF08\u52FF\u52FE\u601D\u8003\u6863\uFF09\u3002gpt-4-turbo/4.1 \u8D77\u652F\u6301\u56FE\u7247\uFF0C\u89C1\u5355\u72EC\u6761\u76EE\uFF1B\u65B0\u4EE3\u8BF7\u7528 GPT-5 \u7CFB\uFF08\u89C1 openai-chat/gpt-5.x \u6761\u76EE\uFF09\u3002"},{id:"anthropic-claude-5-5",patterns:["claude-haiku-5.5","claude-opus-5-5","claude-sonnet-5-5","haiku-5.5","claude-5-5"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},defaultEffort:"high",compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude 5.5 \u4EE3\uFF08Haiku 5.5 / Opus 5.5 / Sonnet 5.5\uFF09\uFF1Api-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u5168\u6863 Low / Medium / High(\u9ED8\u8BA4) / XHigh / Max\uFF0C\u81EA\u9002\u5E94\u601D\u8003\uFF0C1M \u4E0A\u4E0B\u6587 / 128K \u8F93\u51FA\u3002off/minimal \u4EE5\u7701\u7565\u8868\u8FBE\uFF08\u76EE\u5F55\u5C06\u4E24\u952E\u8BB0\u4E3A null\uFF0C\u975E\u663E\u5F0F\u5173\u95ED\uFF09\u3002"},{id:"anthropic-claude-5",patterns:["claude-fable-5","claude-mythos-5","claude-opus-5","claude-sonnet-5"],efforts:{xhigh:"xhigh",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude 5 \u4EE3\uFF08Fable 5 / Mythos 5 / Opus 5 / Sonnet 5\uFF09\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u5DF2\u6536\u7D27\u4E3A XHigh / Max\uFF08low/medium/high \u6863\u5DF2\u4ECE\u8BE5\u4EE3 effort \u76EE\u5F55\u79FB\u9664\uFF1BFable 5 \u4E0E Opus 5 \u53E6\u63A5\u53D7\u4EE5\u7701\u7565\u8868\u8FBE\u7684 off\uFF0CSonnet 5 \u65E0 off\uFF09\u30021M \u4E0A\u4E0B\u6587 / 128K \u8F93\u51FA\uFF08Batch 300K\uFF09\u3002\u5B98\u65B9\u652F\u6301 PDF \u8F93\u5165\u3002\u6CE8\u610F\uFF1AAnthropic \u5B98\u65B9 OpenAI \u517C\u5BB9\u5C42\u4F1A\u5FFD\u7565 effort \u53C2\u6570\uFF0C\u58F0\u660E\u5728\u7B2C\u4E09\u65B9\u7F51\u5173\u6620\u5C04\u65F6\u751F\u6548\u3002"},{id:"anthropic-claude-5-1",patterns:["claude-fable-5-1","claude-mythos-5-1"],efforts:{xhigh:"xhigh",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude Fable 5.1 / Mythos 5.1\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u76EE\u5F55\u6863\u4F4D XHigh / Max\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF0C\u81EA\u9002\u5E94\u601D\u8003\u5E38\u5F00\uFF08\u4E0D\u63A5\u53D7 enabled/disabled\uFF09\u30021M \u4E0A\u4E0B\u6587 / 128K \u8F93\u51FA\uFF1BFable 5.1 \u652F\u6301\u4F1A\u8BDD\u4E2D\u9014\u6539\u6863\uFF08\u9700 beta header\uFF0C\u672C\u63D2\u4EF6\u4E0D\u6D89\u53CA\uFF09\u3002"},{id:"anthropic-claude-mythos-preview",patterns:["claude-mythos-preview"],efforts:{low:"low",medium:"medium",high:"high",max:"max"},defaultEffort:"high",compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude Mythos Preview\uFF1A\u5B98\u65B9\u6863\u4F4D Low / Medium / High / Max\uFF08\u65E0 XHigh\uFF09\uFF0C1M \u4E0A\u4E0B\u6587\u3002pi-ai 1.2.0 \u76EE\u5F55\u65E0 mythos \u6761\u76EE\uFF0C\u672C\u6863\u4F4D\u6CBF\u7528\u5B98\u65B9 effort \u77E9\u9635\u3002"},{id:"anthropic-claude-opus-4-high",patterns:["claude-opus-4-8","claude-opus-4-7"],efforts:{xhigh:"xhigh",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude Opus 4.7/4.8\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u6863\u4F4D\u4EC5 XHigh / Max\uFF08low/medium/high \u5DF2\u4ECE\u8BE5\u4EE3\u76EE\u5F55\u79FB\u9664\uFF1Bxhigh \u4E3A\u5B98\u65B9\u63A8\u8350\u7684\u7F16\u7801\u8D77\u6B65\u6863\uFF09\u30021M \u4E0A\u4E0B\u6587\u3002"},{id:"anthropic-claude-4-6",patterns:["claude-opus-4-6","claude-sonnet-4-6"],efforts:{max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude 4.6 \u4EE3\uFF08Opus 4.6 / Sonnet 4.6\uFF09\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u4EC5\u5269 Max \u4E00\u6863\uFF08low/medium/high/xhigh \u5747\u5DF2\u4ECE\u76EE\u5F55\u79FB\u9664\uFF09\u30021M \u4E0A\u4E0B\u6587\u3002"},{id:"anthropic-claude-opus-4-5",patterns:["claude-opus-4-5"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"high",compat:{supportsReasoningEffort:!0},input:["text","image"],contextWindow:2e5,maxTokens:64e3,note:"Claude Opus 4.5\uFF1A\u5B98\u65B9 effort \u652F\u6301\u5217\u8868\uFF0820251101 \u5FEB\u7167\uFF09\uFF0C\u6863\u4F4D Low / Medium / High\uFF08\u65E0 XHigh/Max\uFF09\uFF0C\u53EF\u4E0E budget_tokens \u5E76\u7528\uFF1B200K / 64K\u3002"},{id:"anthropic-claude",patterns:["claude"],efforts:!1,input:["text","image"],contextWindow:2e5,maxTokens:64e3,note:"Claude 3.x \u4E0E Sonnet 4.5 / Haiku 4.5\uFF1A\u5B98\u65B9 effort \u53C2\u6570\u4E0D\u652F\u6301\uFF08\u4EC5 5.5/5/5.1 \u4EE3\u3001Opus 4.5/4.6/4.7/4.8\u3001Sonnet 4.6 \u652F\u6301\uFF09\uFF0C\u601D\u8003\u7531 thinking.type \u63A7\u5236\u2014\u2014\u52FF\u52FE\u601D\u8003\u6863\u3002\u53C2\u8003\u5BB9\u91CF 200K / 64K\uFF08Haiku 3.5 \u4E3A\u7EAF\u6587\u672C\uFF0C\u6309\u9700\u53D6\u6D88\u56FE\u7247\uFF09\u3002Haiku 5.5 \u53CA\u6574\u4E2A 5.5 \u4EE3\u89C1\u4E0A\u65B9 anthropic-claude-5-5 \u6761\u76EE\u3002"},{id:"google-gemini",patterns:["gemini"],efforts:{low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:65536,note:"Gemini \u901A\u7528\u5B89\u5168\u6863\uFF1ALow / Medium / High\uFF08\u5B98\u65B9 OpenAI \u517C\u5BB9\u6620\u5C04\u8868\u53E6\u6536 minimal\uFF1A2.5 \u7CFB\u6620\u5C04\u4E3A 1,024 \u9884\u7B97\u30013.1 Flash-Lite/3 Flash \u539F\u751F minimal\u30013.1 Pro \u843D low\uFF09\u3002none \u4EC5\u80FD\u5173 2.5 \u975E Pro\uFF1B2.5 Pro \u4E0E 3 \u4EE3\u4E0D\u53EF\u5173\uFF1B\u5404\u578B\u9ED8\u8BA4\u4E0D\u4E00\uFF08flash-lite \u9ED8\u8BA4\u5173\uFF09\u3002\u5B98\u65B9\u53E6\u6536\u97F3\u9891/\u89C6\u9891/PDF\u3002Gemma-4 \u89C1\u4E0B\u6761\u3002"},{id:"google-gemma-4",patterns:["gemma-4"],efforts:{off:null,minimal:"MINIMAL",high:"HIGH"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,maxTokens:32768,note:"Gemma 4\uFF0826b/31b-it\uFF09\uFF1A\u4E09\u6863 Minimal / High\uFF08\u6863\u4F4D\u7EBF\u4E3A\u5B98\u65B9\u5927\u5199\u679A\u4E3E\u62FC\u5199\uFF09\uFF0Coff \u4EE5\u7701\u7565\u8868\u8FBE\uFF1BLow/Medium \u4E0D\u88AB\u63A5\u53D7\u3002\u5E26\u56FE\u8F93\u5165\uFF0C262,144 / 32,768\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF09\u3002"},{id:"xai-grok-4-7",patterns:["grok-4.7"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:5e5,maxTokens:5e5,note:'Grok 4.7\uFF1A\u6863\u4F4D Low / Medium / High / XHigh\uFF0C\u601D\u8003\u4E0D\u53EF\u5173\u95ED\uFF08off \u4EC5\u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF1B\u5E26\u56FE\u8F93\u5165\uFF0C500K \u4E0A\u4E0B\u6587 / 500K \u8F93\u51FA\uFF082026-10 \u6821\u51C6\uFF1Api-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u786E\u8BA4\u6863\u4F4D\u4E0E\u5BB9\u91CF\uFF0C"\u4E0A\u6E38 404"\u4E0E"\u6863\u4F4D\u672A\u8BC1\u5B9E"\u4E24\u6761\u65E7\u8BB0\u5F55\u4F5C\u5E9F\uFF09\u3002grok-4.5 \u4F20 xhigh \u88AB\u9759\u9ED8\u6309 High \u5904\u7406\u7684\u8BF4\u660E\u89C1\u5176\u6761\u76EE\u3002'},{id:"xai-grok-high",patterns:["grok-4.6"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"high",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:5e5,note:'Grok 4.6 \u6863\u4F4D\uFF1ALow / Medium / High(\u9ED8\u8BA4) / XHigh\uFF0C\u601D\u8003\u4E0D\u53EF\u5173\u95ED\uFF1B\u5E26\u56FE\u8F93\u5165\u3001500K \u4E0A\u4E0B\u6587\u3002Grok 4.7 \u89C1\u4E0A\u4E00\u6761\uFF08\u6B64\u524D\u8BB0\u4E3A"\u4E0D\u5B58\u5728"\uFF0C\u5DF2\u968F\u53D1\u5E03\u4F5C\u5E9F\uFF09\u3002'},{id:"xai-grok-4-5",patterns:["grok-4.5"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"high",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:5e5,note:"Grok 4.5 \u6863\u4F4D\uFF1ALow / Medium / High(\u9ED8\u8BA4)\uFF0C\u601D\u8003\u4E0D\u53EF\u5173\u95ED\uFF1B\u5E26\u56FE\u8F93\u5165\u3002\u4F20\u5165 xhigh \u4F1A\u88AB\u5B98\u65B9\u9759\u9ED8\u6309 High \u5904\u7406\u3002"},{id:"xai-grok-4-3",patterns:["grok-4.3"],efforts:{off:"none",low:"low",medium:"medium",high:"high"},defaultEffort:"low",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1e6,maxTokens:3e4,note:"Grok 4.3\uFF1A\u5B98\u65B9\u56DB\u7EA7 reasoning effort\uFF08None / Low(\u9ED8\u8BA4) / Medium / High\uFF09\uFF0C1M \u4E0A\u4E0B\u6587 / 30,000 \u8F93\u51FA\uFF082026-10 \u6821\u51C6\uFF1AXHigh \u6863\u6309 pi-ai 1.2.0 \u76EE\u5F55\u79FB\u9664\u2014\u2014\u5B83\u81EA 4.6 \u8D77\u624D\u52A0\u5165\uFF1B\u5E26\u56FE\u8F93\u5165\uFF09\u3002grok-4-fast \u7B49\u65E7 slug 2026-05-15 \u8D77\u81EA\u52A8\u91CD\u5B9A\u5411\u5230\u672C\u578B\u53F7\u3002"},{id:"xai-grok",patterns:["grok"],efforts:{low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],note:"Grok \u901A\u7528\u6863\u4F4D\uFF1ALow / Medium / High\u3002\u521D\u4EE3 grok-4\u3001grok-4.20 \u4E0E grok-build-0.1 \u4E0D\u63A5\u53D7\u8BE5\u53C2\u6570\uFF08grok-4 \u7CFB\u4E0E grok-3 \u5DF2\u4E8E 2026-05-15 \u9000\u5F79\u5E76\u91CD\u5B9A\u5411\u81F3 4.3\uFF09\uFF1Bgrok-4.20-multi-agent \u7684\u56DB\u6863\u63A7\u5236\u7684\u662F agent \u6570\u91CF\u800C\u975E\u601D\u8003\u6DF1\u5EA6\u3002\u65B0\u65E7\u4EE3\u9645\u8BF7\u4F18\u5148\u9009 4.5/4.6/4.3\uFF1B\u591A\u6A21\u6001\u53D8\u4F53\u6309\u9700\u52FE\u9009\u56FE\u7247\u3002"},{id:"mistral-magistral",patterns:["magistral"],efforts:{off:"none",high:"high"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,maxTokens:16384,note:'Magistral\uFF08magistral-medium-latest\uFF09\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u76EE\u5F55\u663E\u793A\u73B0\u5F79 magistral \u8D70 mistral-conversations \u534F\u8BAE\u5E76\u63A5\u53D7 effort\uFF08None / High \u4E24\u6863\uFF0C\u9ED8\u8BA4 None\uFF09\uFF0C\u5E26\u56FE\u8F93\u5165\uFF0C262,144 / 16,384\u3002\u65E9\u524D"\u8BE5\u7EBF\u65E0 effort \u53C2\u6570\u4E14\u5DF2\u5F03\u7528"\u7684\u8BB0\u5F55\u4F5C\u5E9F\u3002'},{id:"mistral-medium-3",patterns:["mistral-medium-3.5","mistral-large-4","mistral-medium-2604","mistral-medium-latest","mistral-small-latest","mistral-small-2603"],efforts:{off:"none",high:"high"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],note:"Mistral \u73B0\u5F79\u63A8\u7406\u6863\uFF082026-10 \u6269\u5145\uFF09\uFF1ANone / High \u4E24\u6863\uFF0C\u5B98\u65B9 reasoning_effort \u679A\u4E3E\u5373 none/high\uFF1B\u73B0\u5F79\u578B\u53F7 mistral-large-4\uFF081M\uFF09\u3001mistral-medium-3.5\uFF082604/latest\uFF09\u3001mistral-small-2603\uFF08Small 4\uFF09\u7ECF\u5B83\u63A7\u5236\uFF0C\u5747\u5E26\u89C6\u89C9\u3002\u5BB9\u91CF\uFF1Alarge-4 262,144 \u8F93\u51FA\u3001medium 262,144 \u8F93\u51FA\u3001small 256,000 \u8F93\u51FA\uFF08\u4E0A\u4E0B\u6587\u5747 262,144\uFF09\u3002\u975E\u63A8\u7406\u65E7\u6B3E\u89C1\u4E0B\u6761\u3002"},{id:"mistral-legacy",patterns:["mistral-large-2411","mistral-large-latest","mistral-large-2512","mistral-medium-2505","mistral-medium-2508","mistral-small-2506","mistral-nemo","devstral","ministral","codestral","pixtral","voxtral"],efforts:!1,input:["text","image"],note:"Mistral \u975E\u63A8\u7406\u7EBF\uFF082026-10 \u65B0\u589E\u6761\u76EE\uFF09\uFF1Alarge-2411/2512/latest\u3001medium-2505/2508\u3001small-2506\u3001nemo \u53CA devstral/ministral/codestral/pixtral/voxtral \u7B49\u4E13\u7528\u7EBF\u5747\u4E0D\u63A5\u53D7 effort \u53C2\u6570\uFF08\u52FF\u52FE\u601D\u8003\u6863\uFF09\u3002\u591A\u6570\u73B0\u5F79\u6B3E\u5E26\u89C6\u89C9\uFF08large-2411 \u4E3A\u7EAF\u6587\u672C\uFF09\u3002"},{id:"qwen-vision",patterns:["qwen-vl","qwen2-vl","qwen2-5-vl","qwen3-vl","qvq"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"qwen"},input:["text","image"],contextWindow:131072,maxTokens:8192,note:"\u901A\u4E49\u89C6\u89C9\u7EBF\uFF08Qwen-VL/QvQ\uFF09\uFF1Aenable_thinking \u5F00\u5173\uFF08\u5F00=High\uFF09\uFF0C\u6536\u56FE\u3002qwen3-vl \u5BB9\u91CF\u66F4\u5927\uFF0C\u6309\u9700\u4E0A\u8C03\u3002"},{id:"qwen-3-8",patterns:["qwen3.8"],efforts:{off:null,low:"low",medium:"medium",xhigh:"xhigh"},defaultEffort:"xhigh",compat:{thinkingFormat:"qwen",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1e6,note:"Qwen 3.8 \u7CFB\uFF1A\u5B98\u65B9 reasoning_effort \u6863\u4F4D XHigh(\u9ED8\u8BA4) / Medium / Low\uFF0Cthinking \u9ED8\u8BA4\u5F00\u3001\u53EF\u6309\u8BF7\u6C42\u5173\u95ED\uFF1B\u539F\u751F\u591A\u6A21\u6001\uFF08qwen3.8-max \u56FE\u50CF/\u89C6\u9891\u7406\u89E3\uFF0C\u89C6\u9891\u672A\u5165\u6838\u5FC3\u8BCD\u8868\uFF09\u30021M \u6863\u4E0A\u4E0B\u6587\u300227B \u4E0E Flash-Next \u5F00\u6E90\u6B3E\u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"qwen-3-8-27b",patterns:["qwen3.8-27b"],efforts:{off:null,low:"low",medium:"medium",xhigh:"xhigh"},defaultEffort:"xhigh",compat:{thinkingFormat:"qwen",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,note:"Qwen3.8-27B\uFF08dense\uFF0C2026-08-14 \u5F00\u6E90\uFF09\uFF1A\u5B98\u65B9 reasoning_effort \u6863\u4F4D XHigh(\u9ED8\u8BA4) / Medium / Low\uFF0Cthinking \u9ED8\u8BA4\u5F00\u3001\u53EF\u6309\u8BF7\u6C42\u5173\uFF1B\u539F\u751F\u56FE\u50CF+\u89C6\u9891\u7406\u89E3\uFF08\u89C6\u9891\u672A\u5165\u6838\u5FC3\u8BCD\u8868\uFF09\u3002262,144 \u539F\u751F\u4E0A\u4E0B\u6587\u3001\u5B98\u65B9\u58F0\u660E\u53EF\u6269\u81F3 1M\u3002\u6765\u6E90\uFF1AHF Qwen/Qwen3.8-27B \u6A21\u578B\u5361\u3002"},{id:"qwen-3-8-flash-next",patterns:["qwen3.8-flash-next"],efforts:{off:null,low:"low",medium:"medium",xhigh:"xhigh"},defaultEffort:"xhigh",compat:{thinkingFormat:"qwen",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,note:"Qwen3.8-Flash-Next\uFF08125B-A6B \u5B9E\u9A8C\u67B6\u6784\uFF0CQwen4 \u524D\u8EAB\uFF09\uFF1A\u5B98\u65B9 reasoning_effort \u6863\u4F4D XHigh(\u9ED8\u8BA4) / Medium / Low + enable_thinking \u5F00\u5173\uFF1B\u539F\u751F\u89C6\u89C9\uFF08Vision Encoder\uFF09\u3002262,144 \u539F\u751F\u4E0A\u4E0B\u6587\u3001\u53EF\u6269\u81F3 1M\u3002\u6765\u6E90\uFF1AHF \u6A21\u578B\u5361\u4E0E qwen.ai \u5B98\u65B9\u535A\u5BA2\u3002"},{id:"qwen",patterns:["qwen","qwq"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"qwen"},input:["text"],contextWindow:1e6,maxTokens:65536,note:"\u901A\u4E49\u5343\u95EE\uFF1Aenable_thinking \u5F00\u5173\uFF08\u65E0 effort \u6863\uFF09\uFF0C\u5F00=High\uFF1B\u73B0\u5F79\u65D7\u8230\u4E3A qwen3.8 \u7CFB\uFF081M \u6863\u4E0A\u4E0B\u6587\uFF0C\u89C1 qwen-3-8 \u6761\u76EE\uFF09\u30023.6/3.7 \u4EE3\u7684 Plus/Flash \u4EA6\u9ED8\u8BA4\u591A\u6A21\u6001\uFF08\u56FE\u7247/\u89C6\u9891\uFF09\uFF0C\u5982\u63A5\u5165\u8BF7\u6309\u9700\u52FE\u9009\u56FE\u7247\uFF1B\u89C6\u89C9\u7EBF\u89C1 qwen-vision \u6761\u76EE\u3002"},{id:"glm-vision",patterns:["glm-4v","glm-4-6v","glm-4-5v","glm-5v"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"zai"},input:["text","image"],contextWindow:131072,maxTokens:32768,note:"\u667A\u8C31\u89C6\u89C9\u7EBF\uFF08GLM-4V/4.5V/4.6V/5V\uFF09\uFF1Athinking \u5F00\u5173\uFF08\u5F00=High\uFF09\uFF0C\u6536\u56FE\u3002GLM-4.5V \u4E3A\u5F3A\u5236\u601D\u8003\uFF08\u4F20 disabled \u62A5\u9519\uFF0C\u8BF7\u624B\u52A8\u5220 Off \u6863\uFF09\u3002"},{id:"glm-5-3-flash",patterns:["glm-5.3-flash","glm-5.3-flashx"],efforts:{low:"low",high:"high",max:"max"},defaultEffort:"max",compat:{thinkingFormat:"zai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:131072,note:"GLM-5.3-Flash\uFF08320B\uFF0C\u5B98\u65B9\u6587\u6863 vlm \u5206\u7C7B\uFF09\uFF1A\u5F3A\u5236\u601D\u8003\uFF08thinking.type \u4EC5 enabled\uFF0C\u4E0D\u652F\u6301\u5173\u95ED\uFF09\uFF0C\u6587\u672C\u53C2\u6570\u4E0E GLM-5.3 \u4E00\u81F4\u2014\u2014\u6863\u4F4D Low / High / Max\u3002\u8F93\u5165\u6A21\u6001\uFF1A\u89C6\u9891\u3001\u56FE\u50CF\u3001\u6587\u672C\u3001\u6587\u4EF6\uFF08\u89C6\u9891/\u6587\u4EF6\u672A\u5165\u6838\u5FC3\u8BCD\u8868\uFF0C\u56FE\u7247\u53EF\u52FE\uFF09\u3002\u5B98\u65B9 1M \u4E0A\u4E0B\u6587 / 128K \u6700\u5927\u8F93\u51FA\u3002\u6765\u6E90\uFF1Adocs.bigmodel.cn \u6A21\u578B\u9875\u3002"},{id:"glm-5-3",patterns:["glm-5.3"],efforts:{low:"low",high:"high",max:"max"},defaultEffort:"max",compat:{thinkingFormat:"zai",supportsReasoningEffort:!0},input:["text"],contextWindow:1048576,maxTokens:131072,note:"GLM-5.3 \u6863\u4F4D\uFF1ALow / High / Max\uFF08\u5F3A\u5236\u601D\u8003\uFF0C\u5176\u4F59\u503C\u62A5\u9519\uFF09\u3002\u5B98\u65B9\u5BB9\u91CF 1M / 128K\u3002"},{id:"glm-5-2",patterns:["glm-5.2"],efforts:{off:"none",minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},defaultEffort:"max",compat:{thinkingFormat:"zai",supportsReasoningEffort:!0},input:["text"],contextWindow:1048576,maxTokens:131072,note:"GLM-5.2 \u6863\u4F4D\uFF1ANone / Minimal / Low / Medium / High / XHigh / Max\uFF08\u5B98\u65B9\u6620\u5C04\uFF1ALow\xB7Medium\u2192High\u3001XHigh\u2192Max\u3001None\xB7Minimal=\u505C\u6B62\u601D\u8003\uFF09\u3002\u89C6\u89C9\u7EBF\u89C1 glm-vision \u6761\u76EE\u3002"},{id:"glm",patterns:["glm","zhipu","chatglm"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"zai"},input:["text"],note:"GLM \u901A\u7528\uFF1Athinking \u5F00\u5173\uFF08\u65E0 effort \u6863\uFF09\uFF0C\u5F00=High\uFF1Beffort \u9636\u68AF\u4EC5 GLM-5.2+ \u652F\u6301\uFF08\u89C1\u4E0A\u4E24\u6761\u76EE\uFF09\u3002\u6CE8\u610F GLM-4.7/GLM-4.5V \u4E3A\u5F3A\u5236\u601D\u8003\uFF0C\u4F20 disabled \u4F1A\u62A5\u9519\uFF08\u8BF7\u624B\u52A8\u5220 Off \u6863\uFF09\u3002\u89C6\u89C9\u7EBF\u89C1 glm-vision \u6761\u76EE\u3002"},{id:"kimi-k3",patterns:["kimi-k3"],efforts:{low:"low",high:"high",max:"max"},defaultEffort:"max",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,note:"Kimi K3 \u6863\u4F4D\uFF1ALow / High / Max(\u9ED8\u8BA4 Max)\uFF0C\u8D70\u9876\u5C42 reasoning_effort\uFF1B\u59CB\u7EC8\u63A8\u7406\u3001\u52FF\u4F20 thinking \u5BF9\u8C61\u3002\u539F\u751F\u89C6\u89C9\u7406\u89E3\uFF0C1M \u4E0A\u4E0B\u6587\uFF08\u6700\u5927\u8F93\u51FA\u5B98\u65B9\u672A\u5355\u72EC\u5217\uFF0C\u4E0D\u63D0\u4F9B\uFF09\u3002"},{id:"kimi-k2-vision",patterns:["kimi-k2.6","kimi-k2.5"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"deepseek"},input:["text","image"],contextWindow:262144,note:"Kimi K2.5/K2.6 \u89C6\u89C9\u4EE3\uFF1Athinking.type \u5F00\u5173\uFF08\u9ED8\u8BA4\u5F00\u3001\u53EF\u5173\uFF09\uFF0C\u5F00=High\uFF1B\u5E26\u89C6\u89C9\uFF0C256K\u3002K2.7 Code \u59CB\u7EC8\u601D\u8003\uFF0C\u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"kimi-k27-code",patterns:["kimi-k2.7"],efforts:{high:"high"},defaultEffort:"high",compat:{thinkingFormat:"deepseek"},input:["text","image"],contextWindow:262144,note:"Kimi K2.7 Code\uFF08\u542B\u9AD8\u901F\u7248\uFF09\uFF1A\u59CB\u7EC8\u601D\u8003\u2014\u2014thinking.type \u4EC5\u63A5\u53D7 enabled\uFF08\u4F20 disabled \u62A5\u9519\uFF09\uFF0C\u65E0 Off \u6863\uFF1B\u5E26\u89C6\u89C9\uFF0C256K\u3002"},{id:"kimi-for-coding",patterns:["kimi-for-coding"],efforts:{low:"low",high:"high",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1048576,maxTokens:32768,note:"Kimi for Coding\uFF1AMoonshot \u7F16\u7801\u4E13\u7EBF\u8D70 anthropic-messages \u534F\u8BAE\u3001\u81EA\u9002\u5E94\u601D\u8003\uFF0C\u6863\u4F4D Low / High / Max\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF1B\u5E26\u56FE\u8F93\u5165\uFF0C1M \u4E0A\u4E0B\u6587 / 32,768 \u8F93\u51FA\u3002\u9AD8\u901F\u7248\uFF08-highspeed\uFF09\u65E0 effort \u63A7\u4EF6\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF09\u3002"},{id:"kimi-moonshot-v1-vision",patterns:["moonshot-v1-8k-vision","moonshot-v1-32k-vision","moonshot-v1-128k-vision"],efforts:!1,input:["text","image"],note:"Moonshot V1 \u89C6\u89C9\u65E7\u4EE3\uFF088k/32k/128k \u5404\u4E00\uFF09\uFF1A\u65E0\u601D\u8003\u63A7\u4EF6\uFF08\u751F\u6210\u6A21\u578B\uFF09\u3001\u652F\u6301\u56FE\u7247\u8F93\u5165\uFF1B\u8BE5\u7EBF\u5DF2\u505C\u6B62\u5BF9\u65B0\u7528\u6237\u5F00\u653E\uFF082026-08-31 \u5168\u91CF\u4E0B\u7EBF\uFF0C\u7F51\u5173\u6B8B\u7559\u4ECD\u53EF\u547D\u4E2D\uFF09\u3002"},{id:"kimi",patterns:["kimi","moonshot"],efforts:{off:null,high:"high"},compat:{thinkingFormat:"deepseek"},input:["text"],contextWindow:262144,note:"Kimi \u901A\u7528\uFF1Athinking \u5F00\u5173\uFF08\u65E0 effort \u6863\uFF09\uFF0C\u5F00=High\u3002k2 \u7CFB\u5217 2026-05-25 \u4E0B\u7EBF\u3001kimi-latest 2026-01-28 \u4E0B\u7EBF\u3001moonshot-v1 \u7CFB 2026-08-31 \u5168\u91CF\u4E0B\u7EBF\uFF08\u7F51\u5173\u6B8B\u7559\u4ECD\u53EF\u547D\u4E2D\uFF1Bmoonshot-v1 \u672C\u8EAB\u975E\u601D\u8003\u6A21\u578B\uFF09\u3002\u89C6\u89C9\u4EE3\u4E0E K2.7 Code \u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"hunyuan-hy3",patterns:["hy3"],efforts:{low:"low",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:262144,note:"\u6DF7\u5143 hy3\uFF1A\u5F00\u6E90\u5951\u7EA6\u7ECF chat_template_kwargs.reasoning_effort = no_think(\u9ED8\u8BA4)/low/high\uFF1B\u5B98\u65B9\u6A21\u578B\u5361 256K \u4E0A\u4E0B\u6587\uFF08295B MoE\uFF0C2026 \u5F00\u6E90\uFF09\u3002"},{id:"hunyuan-hy4",patterns:["hy4-preview","hy-4-preview"],efforts:{off:"no_think",high:"high"},defaultEffort:"high",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},contextWindow:1e6,note:"\u6DF7\u5143 Hy4 preview\uFF1A\u5B98\u65B9 README\u2014\u2014reasoning \u9ED8\u8BA4 high\uFF08\u6DF1\u5EA6\u601D\u8003\uFF09\uFF0C\u5173\u95ED\u7ECF chat_template_kwargs.reasoning_effort=no_think\uFF1B\u5B98\u65B9\u89C4\u683C\u8868 1M \u4E0A\u4E0B\u6587\uFF08770B-A49B MoE\uFF0CGated DSA\uFF09\u3002low \u6863\u5B98\u65B9\u672A\u5217\uFF0C\u5982\u6709\u8BF7\u624B\u8C03\uFF1B\u89C6\u89C9\u672A\u58F0\u660E\uFF0C\u6309\u9700\u624B\u52FE\u3002\u6765\u6E90\uFF1ATencent-Hunyuan/Hy4-preview \u5B98\u65B9 README\u3002"},{id:"step-5-preview",patterns:["step-5"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1e6,maxTokens:65536,note:'\u9636\u8DC3 Step-5-Preview\uFF08\u5B98\u65B9 id \u5373 step-5-preview\uFF0C\u65E0\u88F8 step-5\uFF1Bpattern \u53D6\u5BB6\u65CF\u4E3B\u5E72\u4EE5\u517C\u5BB9\u7F51\u5173\u5199\u6CD5\uFF09\uFF1A\u6863\u4F4D Low / Medium(\u5B98\u65B9\u6807"\u9ED8\u8BA4\u63A8\u8350") / High\uFF0C\u601D\u8003\u4E0D\u53EF\u5173\u95ED\uFF1B\u539F\u751F\u56FE\u7247 + \u89C6\u9891\u8F93\u5165\uFF1B1M \u4E0A\u4E0B\u6587\u300164K \u6700\u5927\u8F93\u51FA\uFF08\u5B98\u65B9\u53E6\u6CE8 max_tokens \u9ED8\u8BA4 INF\u3001\u4E0E 64K \u4E0A\u9650\u5E76\u5B58\uFF0C\u4EE5\u7AEF\u70B9\u5B9E\u6D4B\u4E3A\u51C6\uFF09\u3002'},{id:"step-3-7",patterns:["step-3.7","step-3.6"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,note:"\u9636\u8DC3 Step-3.6/3.7 \u6863\u4F4D\uFF1ALow / Medium(\u9ED8\u8BA4\u63A8\u8350) / High\uFF0C\u539F\u751F\u56FE\u7247+\u89C6\u9891\u7406\u89E3\u3002\u4E0A\u4E0B\u6587\u4E3A\u8F93\u5165+\u8F93\u51FA\u603B\u548C\u4E0A\u9650\u3002"},{id:"step-3-5",patterns:["step-3.5"],efforts:{low:"low",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:262144,note:"\u9636\u8DC3 Step-3.5 Flash \u6863\u4F4D\uFF1ALow / High\uFF08\u7EAF\u6587\u672C\u63A8\u7406\u65D7\u8230\uFF09\u3002\u4E0A\u4E0B\u6587\u4E3A\u8F93\u5165+\u8F93\u51FA\u603B\u548C\u4E0A\u9650\u3002"},{id:"step",patterns:["step-3","step-2"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],note:"\u9636\u8DC3 Step \u6863\u4F4D\uFF1ALow / Medium / High\uFF08\u9ED8\u8BA4 Medium\uFF0C\u4E0D\u53EF\u5173\u95ED\uFF09\u30023.6/3.7 \u89C6\u89C9\u4EE3\u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"doubao",patterns:["doubao","seed"],efforts:{off:null,low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],note:"\u8C46\u5305\u6863\u4F4D\uFF1AOff / Low / Medium / High\u2014\u2014effort \u9636\u68AF\u4ECD\u662F\u793E\u533A\u8BC1\u636E\u3001\u5B98\u65B9 Ark \u6587\u6863\u660E\u5217\u7684\u4E3A thinking.type \u5F00\u5173\uFF082026-08-24 \u590D\u6838\u4ECD\u672A\u89C1\u5230 effort \u5B98\u65B9\u660E\u6587\uFF09\u3002seed \u4EE3\u6536\u56FE\uFF081.5-pro \u4F8B\u5916\uFF09\u3002"},{id:"minimax-m2",patterns:["minimax-m2"],efforts:!1,input:["text"],contextWindow:204800,maxTokens:131072,note:"MiniMax-M2 / M2.5\uFF08\u542B -highspeed\uFF09\uFF1A\u65E0\u601D\u8003\u63A7\u4EF6\u3001\u65E0 effort \u53C2\u6570\uFF08M3 \u624D\u5F15\u5165 thinking \u53C2\u6570\uFF09\uFF0C\u7EAF\u6587\u672C\uFF0C204,800 / 131,072\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF1BM3 \u89C1\u4E0B\u6761\uFF09\u3002"},{id:"minimax-m3",patterns:["minimax-m3"],efforts:{off:null,high:"high"},compat:{thinkingFormat:"deepseek"},input:["text","image"],contextWindow:1048576,maxTokens:512e3,note:"MiniMax-M3\uFF1A\u5B98\u65B9 thinking \u53C2\u6570 enabled/adaptive/disabled\uFF08\u65E0 effort \u6863\uFF09\uFF0C\u5F00=High\u3001\u5173=disabled\uFF1B\u539F\u751F\u591A\u6A21\u6001\uFF08\u56FE/\u89C6\u9891\uFF0C\u6838\u5FC3\u8BCD\u8868\u4EC5\u542B\u56FE\uFF09\uFF0C1M \u4E0A\u4E0B\u6587 / 512,000 \u8F93\u51FA\uFF082026-10 \u6821\u51C6\u8865\u5BB9\u91CF\uFF09\u3002"},{id:"mimo-v2-6",patterns:["mimo-v2.6","mimo-v2.5"],efforts:{off:"none",low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:131072,note:"\u5C0F\u7C73 MiMo v2.6 \u7CFB\u5217\uFF08mimo-v2.6-pro / -flash / -pro-ultraspeed\uFF1B1M \u4E0A\u4E0B\u6587 / 128K \u6700\u5927\u8F93\u51FA\u3001\u539F\u751F\u5168\u6A21\u6001\uFF09\u4E0E\u5176\u524D\u4EE3 mimo-v2.5\u3002\u5B98\u65B9\u6587\u6863\uFF1Athinking.type\uFF08enabled/disabled\uFF0C\u9ED8\u8BA4 enabled\uFF09+ reasoning.effort\uFF08none \u5173\u95ED\uFF1B\u5176\u4F59\u5408\u6CD5\u503C\u5747\u5F00\u542F\uFF0C\u4E14**\u73B0\u9636\u6BB5\u6682\u672A\u533A\u5206\u63A8\u7406\u5F3A\u5EA6**\u2014\u2014minimal \u5F52\u4E00\u4E3A low\u3001xhigh/max/ultra \u5F52\u4E00\u4E3A high\uFF09\uFF0C\u56E0\u6B64\u8FD9\u91CC\u58F0\u660E\u7684\u662F\u7AEF\u70B9**\u63A5\u53D7**\u7684\u6863\u4F4D Off / Low / Medium / High\uFF08xhigh\u3001max \u4E0D\u58F0\u660E\uFF0C\u7AEF\u70B9\u53EA\u4F1A\u6298\u53E0\u4E3A high\uFF09\u3002\u601D\u8003\u6A21\u5F0F\u4E0B temperature / top_p \u4E0D\u53EF\u81EA\u5B9A\u4E49\uFF08\u5F3A\u5236 1.0 / 0.95\uFF09\uFF1B\u5E26\u5DE5\u5177\u8C03\u7528\u7684\u5386\u53F2\u8F6E\u5FC5\u987B\u5B8C\u6574\u56DE\u4F20 reasoning_content\uFF0C\u5426\u5219 400\u3002mimo-v2.5 \u4E0E v2.5-pro \u5B98\u65B9\u5B9A\u4E8E 2026-10-21 \u4E0B\u7EBF\u3002"},{id:"mimo-v2-5-pro",patterns:["mimo-v2.5-pro"],efforts:{off:"none",low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:1048576,maxTokens:131072,note:"\u5C0F\u7C73 MiMo v2.5-Pro\uFF1A\u8BE5\u5BB6\u65CF\u552F\u4E00\u7684**\u7EAF\u6587\u672C**\u6210\u5458\uFF08\u5B98\u65B9\u80FD\u529B\u8868\u672A\u5217\u5168\u6A21\u6001\u7406\u89E3\uFF09\uFF0C1M \u4E0A\u4E0B\u6587 / 128K \u6700\u5927\u8F93\u51FA\uFF0C\u63A8\u7406\u5951\u7EA6\u4E0E v2.6 \u7CFB\u5217\u76F8\u540C\uFF08thinking.type + reasoning.effort\uFF0Cnone \u5173\u95ED\u3001\u5176\u4F59\u6863\u4F4D\u6682\u4E0D\u533A\u5206\u5F3A\u5EA6\uFF09\u3002\u5B98\u65B9\u5B9A\u4E8E 2026-10-21 \u4E0B\u7EBF\u3002"},{id:"baidu-ernie",patterns:["ernie"],efforts:!1,input:["text"],contextWindow:131072,note:"\u767E\u5EA6\u5343\u5E06 ERNIE \u7CFB\uFF1A\u5B98\u65B9 OpenAI \u517C\u5BB9\u63A5\u53E3\u65E0 reasoning_effort \u53C2\u6570\u2014\u2014\u601D\u8003\u7531\u6A21\u578B\u53D8\u4F53\u51B3\u5B9A\uFF08-Thinking \u7CFB\u5217\u59CB\u7EC8\u601D\u8003\u3001\u666E\u901A\u7CFB\u5217\u4E0D\u601D\u8003\uFF09\uFF0C\u52FF\u52FE\u601D\u8003\u6863\u3002ERNIE 4.5 Turbo VL \u652F\u6301\u56FE\u7247\uFF0C\u6309\u9700\u624B\u52FE\uFF1B\u53C2\u8003\u5BB9\u91CF\u53D6 Turbo 128K \u6863\u3002"},{id:"fireworks-ember",patterns:["ember-1"],efforts:{off:"none",low:"low",medium:"medium",high:"high",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1048576,maxTokens:131072,note:"Fireworks ember-1\uFF1Aanthropic-messages \u534F\u8BAE\u81EA\u9002\u5E94\u601D\u8003\uFF0C\u6863\u4F4D None(\u5173) / Low / Medium / High / Max\uFF08off \u663E\u5F0F none \u62FC\u5199\uFF09\uFF1B\u5E26\u56FE\u8F93\u5165\uFF0C1M \u4E0A\u4E0B\u6587 / 131,072 \u8F93\u51FA\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF09\u3002"},{id:"thinkingmachines-inkling",patterns:["inkling"],efforts:{off:"none",minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:524288,maxTokens:131072,note:"Thinking Machines Inkling\uFF1A\u5168\u6863 Minimal / Low / Medium(\u9ED8\u8BA4) / High / XHigh / Max\uFF0Coff \u663E\u5F0F none\uFF1B\u5E26\u56FE\u8F93\u5165\uFF0C512K \u4E0A\u4E0B\u6587 / 131,072 \u8F93\u51FA\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF1Btogether \u4E2D\u7EE7\u4FA7 effort \u53C2\u6570\u672A\u5F00\u653E\uFF0C\u9700\u652F\u6301\u65B9\u8F6C\u53D1\uFF09\u3002"},{id:"antling-ring",patterns:["ring-2.6"],efforts:{high:"high",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:262144,maxTokens:65536,note:"\u8682\u8681 Ling Ring-2.6-1T\uFF1A\u6863\u4F4D High / XHigh\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF1B262,144 / 65,536\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF09\u3002"},{id:"antling-ling",patterns:["ling-2.6"],efforts:!1,input:["text"],note:"\u8682\u8681 Ling-2.6\uFF08\u542B -flash\uFF09\uFF1A\u975E\u601D\u8003\u6A21\u578B\uFF0C\u65E0 effort \u63A7\u4EF6\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF1BRing-2.6 \u601D\u8003\u7EBF\u89C1\u4E0A\u6761\uFF09\u3002"},{id:"openai-gpt-image",patterns:["gpt-image","dall-e","dalle"],efforts:!1,imageGen:!0,note:"OpenAI \u751F\u56FE\u7CFB\uFF08gpt-image-1 / DALL\xB7E 3\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"google-imagen",patterns:["imagen","flash-image","pro-image","nano-banana"],efforts:!1,imageGen:!0,note:'Google \u751F\u56FE\u7CFB\uFF08Imagen / Gemini-Image "nano banana"\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002'},{id:"black-forest-flux",patterns:["flux"],efforts:!1,imageGen:!0,note:"FLUX \u7CFB\uFF08FLUX.1 schnell/dev/pro \u7B49\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"stability-sd",patterns:["stable-diffusion","sdxl","sd3"],efforts:!1,imageGen:!0,note:"Stability \u751F\u56FE\u7CFB\uFF08Stable Diffusion / SDXL / SD3\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"zhipu-cogview",patterns:["cogview"],efforts:!1,imageGen:!0,note:"\u667A\u8C31 CogView \u751F\u56FE\u7CFB\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"aliyun-wanx",patterns:["wanx"],efforts:!1,imageGen:!0,note:"\u963F\u91CC\u4E07\u76F8 Wanx \u751F\u56FE\u7CFB\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"bytedance-seedream",patterns:["seedream","seededit"],efforts:!1,imageGen:!0,note:"\u5B57\u8282 Seedream / SeedEdit \u751F\u56FE\u7CFB\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"qwen-image",patterns:["qwen-image"],efforts:!1,imageGen:!0,note:"\u901A\u4E49\u5343\u95EE Qwen-Image \u751F\u56FE\u7CFB\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"midjourney",patterns:["midjourney","niji"],efforts:!1,imageGen:!0,note:"Midjourney / Niji \u751F\u56FE\u7CFB\uFF08\u4E2D\u8F6C\u5E38\u89C1\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"}],Sa={off:null,low:"low",medium:"medium",high:"high"},Pg={"openai-completions":Sa,"openai-responses":Sa,"anthropic-messages":Sa,deepseek:{off:"none",low:"low",high:"high",max:"max"}},_g={low:"low",medium:"medium",high:"high"};function Fn(e){return(e??"").toLowerCase().trim()}function ll(e){return e!==void 0&&/[a-z0-9]/.test(e)}function rn(e){return e.toLowerCase().trim().replace(/[^a-z0-9]+/g," ").replace(/([a-z])(\d)/g,"$1 $2")}function La(e,t,n){let r=t===0?void 0:e[t-1],o=e[t+n];return!ll(r)&&!ll(o)}function Aa(e,t){let n=rn(e)+" "+rn(t??""),r;for(let o of Dg)for(let i of o.patterns){let a=rn(i),s=n.indexOf(a);for(;s>=0;){if(La(n,s,a.length)){(r===void 0||a.length>r.length)&&(r={entry:o,length:a.length});break}s=n.indexOf(a,s+1)}}return r?.entry}var Fg={"deepseek.com":"deepseek","anthropic.com":"anthropic-messages"};function Kg(e){let t=Fn(e.api);if(t.length>0)return t;let n=e.baseURL;if(n!==void 0&&n.length>0)try{let o=new URL(n).hostname.toLowerCase().split(".");if(o.length>=2){let i=Fg[o.slice(-2).join(".")];if(i!==void 0)return i}}catch{}return"openai-completions"}var Sr="openai-completions",qg="openai-responses",Ca="anthropic-messages";function Ma(e){if(e===void 0||e.length===0)return!1;let t="";try{t=new URL(e).hostname.toLowerCase()}catch{return!1}if(t.startsWith("[")){let n=t.slice(1,-1);return n==="::1"||n==="::"||n.startsWith("fe80:")||n.startsWith("fc")||n.startsWith("fd")}return!!(t==="localhost"||t.endsWith(".local")||t.endsWith(".internal")||/^(127\.|10\.|192\.168\.)/.test(t)||/^172\.(1[6-9]|2[0-9]|3[01])\./.test(t))}function Bg(e,t){let n=Fn(t),r={...e};if(delete r.supportsMidConvoEffort,delete r.allowedFallbackModels,n===Ca){for(let o of["thinkingFormat","supportsReasoningEffort","thinkingTokenBudgetField","supportsThinkingTokenBudget","vllmPriority"])delete r[o];return r.forceAdaptiveThinking===void 0?void 0:{forceAdaptiveThinking:r.forceAdaptiveThinking}}if(n===Sr)return delete r.forceAdaptiveThinking,Object.keys(r).length===0?void 0:r}var cl=["supportsReasoningEffort","thinkingFormat","thinkingTokenBudgetField","supportsThinkingTokenBudget","vllmPriority"],ul=["forceAdaptiveThinking"];function Ra(e,t){let n=Fn(t),r;if(n===Sr)r=ul;else if(n===qg)r=[...cl,...ul];else if(n===Ca)r=cl;else return;let o=!1,i={...e};for(let a of r)a in i&&(delete i[a],o=!0);return o?i:void 0}function Wg(e,t){let n=Fn(t.api);if(n===Sr){let r=e.compat;r!==void 0&&(r=Bg(r,n)??void 0);let o=e.efforts!==!1;return r===void 0?o&&Ma(t.baseURL)?{thinkingTokenBudgetField:"thinking_token_budget"}:void 0:o&&r.thinkingTokenBudgetField===void 0&&r.supportsThinkingTokenBudget!==!0&&Ma(t.baseURL)?{...r,thinkingTokenBudgetField:"thinking_token_budget"}:r}if(n===Ca&&e.anthropicAdaptive===!0)return{forceAdaptiveThinking:!0}}var Gg=["openai.com","openai.azure.com","deepseek.com","openrouter.ai","z.ai","bigmodel.cn","moonshot.ai","moonshot.cn","aliyuncs.com","anthropic.com","x.ai","together.ai","together.xyz","nvidia.com","cerebras.ai","cloudflare.com","chutes.ai","opencode.ai","ant-ling.com"];function Ha(e){if(Fn(e.api)!==Sr)return!1;let t=e.baseURL;if(t===void 0||t.length===0)return!1;try{let n=new URL(t).hostname.toLowerCase();return n.includes(".")?!Gg.some(r=>n===r||n.endsWith("."+r)):!1}catch{return!1}}function fl(e,t,n){return e===void 0||!n||e.supportsDeveloperRole!==void 0||!Ha(t)?e:{...e,supportsDeveloperRole:!1}}var pl={off:null,low:"low",medium:"medium",high:"high"},Ug=["vl","vision","omni","4o","pixtral","internvl"];function Na(e){let t=rn(e);for(let n of Ug){let r=rn(n),o=t.indexOf(r);for(;o>=0;){if(La(t,o,r.length))return["text","image"];o=t.indexOf(r,o+1)}}}var jg=["dall-e","dalle","gpt-image","imagen","flux","stable-diffusion","sdxl","sd3","cogview","wanx","seedream","seededit","midjourney","niji","nano-banana","image-gen","imagegen","qwen-image","grok-2-image"];function zg(e){let t=rn(e);for(let n of jg){let r=rn(n),o=t.indexOf(r);for(;o>=0;){if(La(t,o,r.length))return!0;o=t.indexOf(r,o+1)}}return!1}function $g(e){if(e===void 0)return;let t=e.map(n=>n.toLowerCase());if(t.some(n=>Ig.includes(n)))return t.includes("image")?["text","image"]:["text"]}function xt(e,t,n){let r=Aa(e,t.displayName),o,i,a,s,d;r?.imageGen===!0&&(a=!0),r?.input!==void 0&&(o=r.input,i="knowledge"),r?.contextWindow!==void 0&&(s=r.contextWindow),r?.maxTokens!==void 0&&(d=r.maxTokens);let l=$g(n?.input);l!==void 0&&(o=l,i="endpoint");let c=n?.output;if(c!==void 0&&(a=c.includes("image")&&!c.includes("text")),n?.contextLength!==void 0&&Number.isFinite(n.contextLength)&&n.contextLength>0&&(s=n.contextLength),o===void 0){let x=Na(e);x!==void 0&&(o=x,i="heuristic")}a===void 0&&zg(e)&&(a=!0),a===!0&&(o=void 0,i=void 0);let f={...o===void 0?{}:{input:o},...i===void 0?{}:{inputSource:i},...a===void 0?{}:{imageGen:a},...s===void 0?{}:{contextWindow:s},...d===void 0?{}:{maxTokens:d}},h=n===void 0?{}:{endpoint:{reasoning:n.reasoning,source:n.source}};if(n?.reasoning===!1)return{efforts:!1,matched:!1,source:"endpoint:"+(n.source??"listing"),confidence:"high",...h,...f};if(r!==void 0){let x=fl(Wg(r,t),t,r.efforts!==!1);return{efforts:r.efforts,...r.efforts!==!1&&r.defaultEffort!==void 0&&r.efforts[r.defaultEffort]!==void 0?{defaultEffort:r.defaultEffort}:{},...x===void 0?{}:{compat:x},matched:!0,entryId:r.id,source:r.id,confidence:"high",...h,...f}}let p=Kg(t),g=Pg[p]??_g,b=Fn(t.api)===Sr?{thinkingFormat:"openai",supportsReasoningEffort:!0}:void 0,m=b!==void 0&&Ma(t.baseURL)?{...b,thinkingTokenBudgetField:"thinking_token_budget"}:b,v=fl(m,t,!0);return n?.reasoning===!0?{efforts:{...pl},...pl.medium!==void 0?{defaultEffort:"medium"}:{},...v===void 0?{}:{compat:v},matched:!1,source:"endpoint:"+(n.source??"listing"),confidence:"medium",...h,...f}:{efforts:g,...g.medium!==void 0?{defaultEffort:"medium"}:{},...v===void 0?{}:{compat:v},matched:!1,source:"protocol:"+p,confidence:"low",...h,...f}}var Bt=(e,t)=>typeof e[t]=="boolean";function Vg(e,t){if(Array.isArray(e)){for(let n of e)if(V(n)&&n.id===t)return n}}function Yg(e){if(!V(e))return{reasoning:"unknown",source:null};let t=e.supported_features;if(Array.isArray(t)&&t.includes("reasoning"))return{...Je(e),reasoning:!0,source:"supported_features"};let n=e.supported_parameters;if(Array.isArray(n)&&(n.includes("reasoning")||n.includes("include_reasoning")||n.includes("reasoning_effort")))return{...Je(e),reasoning:!0,source:"supported_parameters"};if(Bt(e,"supports_reasoning"))return{...Je(e),reasoning:e.supports_reasoning,source:"supports_reasoning"};if(Bt(e,"supportsReasoning"))return{...Je(e),reasoning:e.supportsReasoning,source:"supportsReasoning"};if(Bt(e,"can_reason"))return{...Je(e),reasoning:e.can_reason,source:"can_reason"};if(Bt(e,"reasoning"))return{...Je(e),reasoning:e.reasoning,source:"reasoning"};let r=e.reasoning_effort;if(r===!1)return{...Je(e),reasoning:!1,source:"reasoning_effort"};if(typeof r=="string"&&r.trim().length>0||e.supports_reasoning_effort===!0)return{...Je(e),reasoning:!0,source:"reasoning_effort"};let o=V(e.capabilities)?e.capabilities:void 0;if(o!==void 0){let i=o.thinking,a=V(i)&&typeof i.supported=="boolean"?i.supported:void 0,s=o.effort,d=V(s)&&typeof s.supported=="boolean"?s.supported:void 0;if(d===!0)return{...Je(e),reasoning:!0,source:"capabilities.effort.supported"};if(a===!0)return{...Je(e),reasoning:!0,source:"capabilities.thinking.supported"};if(a===!1)return{...Je(e),reasoning:!1,source:"capabilities.thinking.supported"};if(d===!1)return{...Je(e),reasoning:!1,source:"capabilities.effort.supported"}}return{...Je(e),reasoning:"unknown",source:null}}function Je(e){let t={},n=s=>{if(!Array.isArray(s))return;let d=s.filter(l=>typeof l=="string");return d.length>0?d.map(l=>l.toLowerCase()):[]},r=V(e.architecture)?e.architecture:void 0,o=n(r?.input_modalities);if(o===void 0&&(o=n(e.input_modalities)),o===void 0){let s=V(e.modalities)?e.modalities:void 0;o=n(s?.input)}if(o===void 0){let s=e.capabilities,d=l=>Array.isArray(l)&&l.some(c=>typeof c=="string"&&c.toLowerCase()==="vision");if(d(e.supported_features)||d(s))o=["image"];else if(V(s)){let l=[];for(let c of["image_input","video_input","pdf_input","file_input"]){let f=V(s[c])?s[c]:void 0;if(f===void 0||typeof f.supported!="boolean")continue;let h=c.replace(/_input$/,"");f.supported===!0?l.push(h):l.length===0&&l.push("text")}l.length>0&&(o=l)}}o===void 0&&(Bt(e,"supports_vision")?o=e.supports_vision===!0?["image"]:[]:Bt(e,"supportsVision")?o=e.supportsVision===!0?["image"]:[]:(Bt(e,"supports_images")||Bt(e,"supportsImages"))&&(o=e.supports_images===!0||e.supportsImages===!0?["image"]:[])),o!==void 0&&(t.input=o.length===0?["text"]:o);let i=n(r?.output_modalities);if(i===void 0&&(i=n(e.output_modalities)),i===void 0){let s=V(e.modalities)?e.modalities:void 0;i=n(s?.output)}i!==void 0&&(t.output=i);let a=e.context_length;if(typeof a=="number"&&Number.isFinite(a)&&a>0)t.contextLength=a;else{let d=(V(e.top_provider)?e.top_provider:void 0)?.context_length;if(typeof d=="number"&&Number.isFinite(d)&&d>0)t.contextLength=d;else{let l=e.max_input_tokens;if(typeof l=="number"&&Number.isFinite(l)&&l>0)t.contextLength=l;else{let f=(V(e.limit)?e.limit:void 0)?.context;typeof f=="number"&&Number.isFinite(f)&&f>0&&(t.contextLength=f)}}}return t}function gl(e,t){let n=Vg(e,t);return n===void 0?{found:!1,signal:{reasoning:"unknown",source:null}}:{found:!0,signal:Yg(n)}}function qe(e){let n=e?.value?.providers;return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(([,r])=>typeof r=="object"&&r!==null&&!Array.isArray(r)))}function So(e){if(!V(e))return;let t=e.providers;return V(t)?t:void 0}function bl(e,t){for(let n of[e?.user,e?.base]){let r=So(n)?.[t];if(V(r)&&r.models!==void 0)return r.models}}function on(e){return So(e?.user)}function Mo(e,t){let n=e.find(o=>o.id===t);if(n===void 0)return;let r=n.reasoningEfforts;if(r===!1)return!1;if(typeof r=="object"&&r!==null&&!Array.isArray(r))return r}function Lo(e,t){let r=e.find(i=>i.id===t)?.input;if(!Array.isArray(r))return;let o=r.filter(i=>typeof i=="string");return o.length>0?o:void 0}function Ao(e,t){let r=e.find(o=>o.id===t)?.compat;if(V(r))return{...r}}function Ia(e,t){return e.find(r=>r.id===t)?.[at]===!0}function Co(e,t){let r=e.find(o=>o.id===t)?.name;return typeof r=="string"&&r.length>0?r:void 0}function Ro(e,t){let r=e.find(o=>o.id===t)?.[Ln];return typeof r=="string"&&r.length>0?r:void 0}var Jg=3e4,Xg=15e3,Oa=new Map,To=new Map;async function Qg(e){let t=Oa.get(e);if(t!==void 0&&Date.now()-t.at<Jg)return t.data;let n=To.get(e);if(n!==void 0)return n;let r=(async()=>{try{let o=await fetch(`${Rd}?route=${encodeURIComponent(e)}`,{method:"GET",signal:AbortSignal.timeout(Xg)});if(!o.ok)return;let i=await o.json();return i?.ok?(Oa.set(e,{at:Date.now(),data:i.data}),i.data):void 0}catch{return}finally{To.delete(e)}})();return To.set(e,r),r}function Da(){Oa.clear(),To.clear()}async function Zg(e,t){let n=await Qg(e);return n===void 0?{reasoning:"unknown",source:null}:gl(n,t).signal}function Ho(e,t=()=>le(e),n,r,o,i){return{async suggest(a,s,d,l){let c=qe((await t()).namespace),f=nn(c,a),h={api:f.api??l?.api,baseURL:f.baseURL??l?.baseURL,displayName:d??f.displayName},p=c[a]===void 0?void 0:await Zg(a,s),g=xt(s,h,p);return g.efforts===void 0?{ok:!1,error:"no-suggestion"}:{ok:!0,suggestion:{efforts:g.efforts,...g.compat===void 0?{}:{compat:g.compat},...g.defaultEffort===void 0?{}:{defaultEffort:g.defaultEffort},...g.input===void 0?{}:{input:g.input},...g.inputSource===void 0?{}:{inputSource:g.inputSource},...g.imageGen===void 0?{}:{imageGen:g.imageGen},...g.contextWindow===void 0?{}:{contextWindow:g.contextWindow},...g.maxTokens===void 0?{}:{maxTokens:g.maxTokens},matched:g.matched,source:g.source,confidence:g.confidence,...g.endpoint===void 0?{}:{endpoint:g.endpoint}}}},commit(a,s,d){if(i?.()===!0){n?.(a,s,d.efforts,d.compat,d.input,d.defaultEffort,d.imageGen);return}r?.(a,s,{efforts:d.efforts,...d.compat===void 0?{}:{compat:d.compat},...d.input===void 0?{}:{input:d.input},...d.imageGen===void 0?{}:{imageGen:d.imageGen},...d.defaultEffort===void 0?{}:{defaultEffort:d.defaultEffort}})},withdraw(a,s){o?.(a,s)},stageEfforts(a,s,d,l,c,f,h){n?.(a,s,d,l,c,f,h)},async writeEfforts(a,s,d,l,c,f,h){if(r!==void 0)return r(a,s,{efforts:d,...l===void 0?{}:{compat:l},...c===void 0?{}:{input:c},...h===void 0?{}:{imageGen:h},...f===void 0?{}:{defaultEffort:f}}),{ok:!0,staged:!0};let g=(await Mr(e,a,[{modelId:s,efforts:d,...l===void 0?{}:{compat:l},...c===void 0?{}:{input:c},...h===void 0?{}:{imageGen:h},...f===void 0?{}:{defaultEffort:f}}],t))[0]??{ok:!1,error:"no-result"};return g.ok?{ok:!0}:g.modelNotFound===!0?{ok:!1,error:"model-not-found"}:{ok:!1,error:g.error??"conflict"}}}}async function Mr(e,t,n,r=()=>le(e),o){if(n.length===0)return[];let i=!1;for(let a=0;a<3;a++)try{let s=a===0?await r():await le(e,{fresh:!0});if(s.namespace===void 0)return n.map(()=>({ok:!1,error:"no-namespace"}));let d=bl(s.namespace,t);if(!Array.isArray(d))return n.map(()=>({ok:!1,modelNotFound:!0}));if(!d.every(V))return n.map(()=>({ok:!1,error:"invalid-models"}));let c=d.map(p=>p),f=[];for(let p of n){let g=c.findIndex(b=>b.id===p.modelId);if(g<0){f.push(p.modelId);continue}c[g]=eh(c[g],p,i?void 0:p.compat)}if(f.length>0)return n.map(p=>f.includes(p.modelId)?{ok:!1,modelNotFound:!0}:{ok:!1,error:"model-not-found"});if(o?.()===!0)return n.map(()=>({ok:!1,aborted:!0}));let h=await e.settings.mutate(De,[{op:"set",path:["providers",t,"models"],value:c}],s.namespace.revision);if(!h.ok){if(a===0&&h.error.code==="settings/conflict")continue;let p=h.error.code==="settings/rejected"&&dl(h.error.message);if(!i&&p&&n.some(g=>g.compat!==void 0)){i=!0;continue}return n.map(()=>({ok:!1,error:h.error.message}))}return n.map(()=>({ok:!0}))}catch(s){return n.map(()=>({ok:!1,error:s instanceof Error?s.message:String(s)}))}return n.map(()=>({ok:!1,error:"conflict"}))}function eh(e,t,n){let r={...e},o=t.efforts!=="keep",i=t.efforts==="keep"?void 0:t.efforts;if(o)if(i===void 0)delete r.reasoningEfforts,r[it]=!0;else if(delete r[it],delete r[Mn],i===!1)r.reasoningEfforts=!1;else{r.reasoningEfforts={...i};let s={...V(e.compat)?e.compat:{},...n??{}};Object.keys(s).length>0&&(r.compat=s)}return t.input!==void 0&&(t.input===null?(delete r.input,r[wt]=!0):(delete r[wt],r.input=[...t.input])),t.imageGen!==void 0&&(t.imageGen===!0?(r[at]=!0,delete r.input,delete r[wt]):delete r[at]),t.defaultEffort!==void 0&&(t.defaultEffort===null?delete r[Ln]:r[Ln]=t.defaultEffort),r}function Pa(e,t){for(let n of[e?.user,e?.base]){let r=So(n)?.[t];if(!V(r))continue;let o=r.headers;if(o===void 0)continue;if(!V(o))return;let i={};for(let[a,s]of Object.entries(o))typeof s=="string"&&(i[a]=s);return i}}async function Lr(e,t,n){if(typeof t!="string"||t.length===0)return{ok:!1,error:"no-route"};let r=!1;for(let o=0;o<2;o+=1)try{let i=o===0?await le(e):await le(e,{fresh:!0});if(i.namespace===void 0)return{ok:!1,error:"no-namespace"};if(i.writable!==!0)return{ok:!1,error:"read-only"};if(!st(i.namespace,t)){r=!0;continue}let a=await e.settings.mutate(De,[{op:"set",path:["providers",t,"headers"],value:{...n}}],i.namespace.revision);if(!a.ok){if(o===0&&a.error.code==="settings/conflict")continue;return{ok:!1,error:a.error.message}}return{ok:!0}}catch(i){return{ok:!1,error:i instanceof Error?i.message:String(i)}}return r?{ok:!1,error:"no-route"}:{ok:!1,error:"conflict"}}function st(e,t){if(Object.prototype.hasOwnProperty.call(qe(e),t))return!0;for(let n of[e?.user,e?.base]){let r=So(n);if(r!==void 0&&Object.prototype.hasOwnProperty.call(r,t))return!0}return!1}async function le(e,t={}){let n=t.fresh===!0?void 0:th(e,t.allowStale===!0);if(n!==void 0)return n;let r=await e.settings.describe();return r.ok?{namespace:r.value.namespaces.find(i=>i.ns===De),writable:r.value.writable,source:"wire"}:{namespace:void 0,writable:!1,source:"wire"}}var hl=new WeakMap;function th(e,t=!1){let n=e.scope;if(n===void 0)return;let r=n.getSnapshot();if(r===void 0)return;if(r.status==="ready"&&typeof r.revision=="number"){let i={namespace:{ns:De,schema:{},value:r.value,user:r.user,base:r.base,revision:r.revision,applies:"live",secrets:[]},writable:r.writable===!0,source:"scope"};return hl.set(n,i),i}if(!t||n===void 0)return;let o=hl.get(n);if(o!==void 0)return{...o,source:"scope-stale"}}var _a=new Map;function yl(e){let t=_a,n=!1,r,o=0,i=new Set,a=()=>{for(let d of[...i])d()},s=()=>{if(n)return Promise.resolve();if(r!==void 0)return r;let d=o;return r=le(e,{fresh:!0}).then(l=>{if(d!==o||l.namespace===void 0)return;let c=new Map;for(let[f,h]of Object.entries(qe(l.namespace))){let p=new Map,g=Array.isArray(h.models)?h.models:[];for(let b of g){if(!V(b)||typeof b.id!="string"||b.id.length===0)continue;let m={};if(Array.isArray(b.input)){let x=b.input.filter(E=>typeof E=="string");x.length>0&&(m.input=x)}b[at]===!0&&(m.imageGen=!0);let v=b.contextWindow;typeof v=="number"&&Number.isFinite(v)&&v>0&&(m.contextWindow=v),(m.input!==void 0||m.imageGen!==void 0||m.contextWindow!==void 0)&&p.set(b.id,m)}p.size>0&&c.set(f,p)}t=c,n=!0,a()}).catch(()=>{}).finally(()=>{d===o&&(r=void 0)}),r};return{getSnapshot:()=>t,subscribe(d){return i.add(d),()=>{i.delete(d)}},load:s,invalidate(){o+=1,n=!1,r=void 0,i.size>0&&s()}}}var nh=new Intl.NumberFormat("en-US"),rh=/^(\d+(?:\.\d+)?)([kmbt])?$/i,oh={k:1e3,m:1e6,b:1e9,t:1e12};function kt(e){let t=e.replace(/[,_\s]/g,"");if(t==="")return;let n=rh.exec(t);if(n===null)return;let r=n[2]===void 0?1:oh[n[2].toLowerCase()],o=Math.round(Number(n[1])*r);return Number.isFinite(o)&&o>0?o:void 0}function ht(e){return e===void 0?"":nh.format(e)}function vl(e){if(e===void 0||!Number.isFinite(e)||e<=0)return"";let t=1024,n=t*1024,r=n*1024,o=r*1024,i=s=>Number.isInteger(s)?String(s):s.toFixed(1).replace(/\.0$/,""),a=[{floor:1e12,binary:o,decimal:1e12,suffix:"T"},{floor:1e9,binary:r,decimal:1e9,suffix:"B"},{floor:1e6,binary:n,decimal:1e6,suffix:"M"},{floor:1e3,binary:t,decimal:1e3,suffix:"K"}];for(let s of a){if(e<s.floor)continue;if(e%s.binary===0)return`${e/s.binary}${s.suffix}`;if(e%s.decimal===0)return`${e/s.decimal}${s.suffix}`;let d=p=>Math.round(p*10)/10,l=e/s.binary,c=e/s.decimal,f=Math.abs(e-d(l)*s.binary),h=Math.abs(e-d(c)*s.decimal);return f<=h?`${i(l)}${s.suffix}`:`${i(c)}${s.suffix}`}return String(e)}var xl="dsh-model-think-level.slider.efforts",Fa="breSelectWired",ih=400;function ah(e){return e===void 0?Promise.resolve(void 0):new Promise(t=>{let n=!1,r=i=>{n||(n=!0,t(i))},o=setTimeout(()=>r(void 0),ih);e.then(i=>{clearTimeout(o),r(i)},()=>{clearTimeout(o),r(void 0)})})}function Ka(e){return typeof e=="object"&&e!==null&&e.ok===!1}function qa(e){if(!Ka(e))return;let t=e.error,n=typeof t?.code=="string"?t.code:"settings/rejected",r=typeof t?.message=="string"?t.message:"";return r.length>0?`${n}: ${r}`:n}function an(e,t){return`${e}/${t}`}function kl(){try{let e=window.localStorage.getItem(xl);if(e===null)return{};let t=JSON.parse(e);if(typeof t!="object"||t===null||Array.isArray(t))return{};let n={};for(let[r,o]of Object.entries(t))r.length>0&&typeof o=="string"&&o.trim().length>0&&(n[r]=o);return n}catch{return{}}}function sh(e){try{window.localStorage.setItem(xl,JSON.stringify(e))}catch{}}function dh(e,t,n){let r=kl();r[an(e,t)]=n,sh(r)}function lh(e,t){return kl()[an(e,t)]}function No(e,t,n){let o=e.groups.find(i=>i.id===t)?.models.find(i=>i.id===n)?.reasoning?.efforts;return o===void 0?[]:o.map(i=>i.id)}function ch(e,t,n){return e.groups.find(o=>o.id===t)?.models.find(o=>o.id===n)?.reasoning?.defaultEffort}function uh(e){if(!(e.length<2))return e[Math.floor((e.length-1)/2)]}function fh(e,t){return e===null||e.provider!==t.provider||e.model!==t.model}async function wl(e,t,n,r,o){let i=No(e,t,n);if(i.length===0)return;let a=an(t,n),s=r.get(a);if(s!==void 0&&i.includes(s))return s;let d=await ah(o?.configuredEffort===void 0?void 0:o.configuredEffort(t,n));if(d!==void 0&&i.includes(d))return d;let l=lh(t,n);if(l!==void 0&&i.includes(l))return l;let c=xt(n,{}).defaultEffort;if(c!==void 0&&i.includes(c))return c;let f=ch(e,t,n);return f!==void 0&&i.includes(f)?f:uh(i)}function El(e,t){let n=e;if(n[Fa]===!0)return()=>{};let r=Object.prototype.hasOwnProperty.call(n,"select"),o=e.select,i=new Map,a=new Set,s=new Map,d=3,l=0,c=0,f=async(b,m)=>{if(m.reasoningEffort!==void 0){let F=await o.call(e,m);return!Ka(F)&&mt()&&(i.set(an(m.provider,m.model),m.reasoningEffort),dh(m.provider,m.model,m.reasoningEffort)),F}let v=e.store.getSnapshot();if(!fh(v.current,m)){if(mt()){let F=an(m.provider,m.model);i.delete(F),a.add(F)}return o.call(e,m)}if(!mt())return o.call(e,m);let x=await wl(v,m.provider,m.model,i,t);if(l!==b)return;let E=e.store.getSnapshot(),N=E.current!==null&&E.current.provider===m.provider&&E.current.model===m.model;return!mt()||x===void 0||!No(E,m.provider,m.model).includes(x)?N?void 0:o.call(e,m):o.call(e,{...m,reasoningEffort:x})},h=async b=>{let m=++l;try{return await f(m,b)}finally{m>c&&(c=m)}},p=()=>{let b=e.store.getSnapshot(),m=b.current;if(m===null||m.reasoningEffort!==void 0||!mt())return;let v=an(m.provider,m.model);if(a.has(v))return;if(No(b,m.provider,m.model).length===0){a.add(v);return}a.add(v);let x=l;wl(b,m.provider,m.model,i,t).then(async E=>{if(E===void 0){a.delete(v);return}if(!mt()){a.delete(v);return}if(l!==x)return;if(l!==c){a.delete(v);return}let N=e.store.getSnapshot(),F=N.current;if(F===null||F.reasoningEffort!==void 0||an(F.provider,F.model)!==v||!No(N,F.provider,F.model).includes(E))return;let X=await o.call(e,{provider:F.provider,model:F.model,reasoningEffort:E});if(Ka(X))throw X}).catch(()=>{let E=(s.get(v)??0)+1;s.set(v,E),E<d&&(a.delete(v),p())})},g=e.store.subscribe(p);return p(),n[Fa]=!0,e.select=h,()=>{delete n[Fa],g(),r?e.select=o:delete n.select}}var ph=1e4;function Tl(e){if(e.current===null)return[];let r=e.groups.find(o=>o.id===e.current?.provider)?.models.find(o=>o.id===e.current?.model)?.reasoning?.efforts;return r!==void 0&&r.length>=2?r:[]}function mh(e){return e.current}function Sl(e,t){let n=mh(t),r=e.findIndex(s=>s.id===n?.reasoningEffort);if(r>=0)return r;let i=t.groups.find(s=>s.id===n?.provider)?.models.find(s=>s.id===n?.model)?.reasoning?.defaultEffort,a=i===void 0?-1:e.findIndex(s=>s.id===i);return a>=0?a:Math.floor((e.length-1)/2)}function gh(e){return e?.models??[]}function Wt(e){let t=e;return t.name??t.label??t.title??e.id}function Ba(e){if(typeof document>"u"||!e.isConnected||e.getClientRects().length===0)return!1;let t=e.getBoundingClientRect();return t.width>0||t.height>0}function hh(){let[e,t]=(0,O.useState)(null),n=(0,O.useRef)(0),r=(0,O.useCallback)(()=>{window.clearTimeout(n.current),t(null)},[]),o=(0,O.useCallback)((i,a)=>{window.clearTimeout(n.current);let s=i.currentTarget;s.scrollWidth<=s.clientWidth+1||(n.current=window.setTimeout(()=>{Ba(s)&&(s.scrollWidth<=s.clientWidth+1||t({target:s,text:a}))},300))},[]);return(0,O.useEffect)(()=>()=>{window.clearTimeout(n.current),t(null)},[]),(0,O.useEffect)(()=>{if(e===null)return;let i=e.target,a=()=>{t(null)};window.addEventListener("pointerdown",a,!0),window.addEventListener("keydown",a,!0),window.addEventListener("scroll",a,!0),window.addEventListener("wheel",a,{capture:!0,passive:!0}),window.addEventListener("resize",a);let s=typeof MutationObserver>"u"?null:new MutationObserver(()=>{Ba(i)||a()});return s?.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]}),()=>{window.removeEventListener("pointerdown",a,!0),window.removeEventListener("keydown",a,!0),window.removeEventListener("scroll",a,!0),window.removeEventListener("wheel",a,!0),window.removeEventListener("resize",a),s?.disconnect()}},[e]),{tip:e,onEnter:o,onLeave:r}}function bh({state:e}){if(typeof document>"u")return null;let t=e.target;if(!Ba(t))return null;let n=t.getBoundingClientRect();if(n.top>window.innerHeight||n.bottom<0)return null;let r=Math.max(12,Math.min(n.right,window.innerWidth-12));return(0,Al.createPortal)((0,O.createElement)("div",{className:"bre-tip",role:"tooltip",style:{top:Math.min(n.bottom+6,window.innerHeight-40),right:Math.max(12,window.innerWidth-r)}},e.text),document.body)}var Ml=new Map;function yh(e,t){let n=t??e.input;if(Array.isArray(n)&&n.length>0)return n.includes("image");let r=JSON.stringify([e.id,e.name]),o=Ml.get(r);if(o!==void 0)return o;let i=Aa(e.id,e.name)?.input,a=i!==void 0?i.includes("image"):(Na(e.id)??[]).includes("image");return Ml.set(r,a),a}function Ll(e,t){return t?.imageGen===!0?!0:e.inputImageGen===!0}function vh(e){let t=e.reasoning?.efforts;return Array.isArray(t)&&t.length>0}function wh(e){return(0,O.createElement)("svg",{className:"bre-tag-icon",width:13,height:13,viewBox:"0 0 16 16",fill:"none",role:"img","aria-label":e},(0,O.createElement)("path",{d:"M1.8 8s2.4-4.2 6.2-4.2S14.2 8 14.2 8s-2.4 4.2-6.2 4.2S1.8 8 1.8 8z",stroke:"currentColor",strokeWidth:1.3,strokeLinejoin:"round"}),(0,O.createElement)("circle",{cx:8,cy:8,r:1.8,fill:"currentColor"}))}function xh(e){return(0,O.createElement)("svg",{className:"bre-tag-icon",width:13,height:13,viewBox:"0 0 16 16",fill:"none",role:"img","aria-label":e},(0,O.createElement)("path",{d:"M8 1.9l1.35 3.75L13.1 7l-3.75 1.35L8 12.1 6.65 8.35 2.9 7l3.75-1.35z",fill:"currentColor"}))}function kh(e){return(0,O.createElement)("svg",{className:"bre-tag-icon",width:13,height:13,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.3,strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e},(0,O.createElement)("path",{d:"M9.4 12.7H3.6a1.7 1.7 0 0 1-1.7-1.7V5.1a1.7 1.7 0 0 1 1.7-1.7h4.2"}),(0,O.createElement)("path",{d:"M2.6 10.6 5.3 8.5l1.8 1.5 1.6-1.3 2.3 2"}),(0,O.createElement)("path",{d:"M12.4 2.2l.75 2.05L15.2 5l-2.05.75L12.4 7.8l-.75-2.05L9.6 5l2.05-.75Z",fill:"currentColor",stroke:"none"}))}var Eh=["#22c55e","#a3e635","#eab308","#f97316","#ef4444"],nE=Eh.map(e=>[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]);function Th(e,t,n,r=!1){let o=[];return yh(e,n)&&o.push((0,O.createElement)("span",{key:"vision",className:"bre-tag",title:t("tagVision")},wh(t("tagVision")))),vh(e)&&o.push((0,O.createElement)("span",{key:"thinking",className:"bre-tag",title:t("tagThinking")},xh(t("tagThinking")))),r&&o.push((0,O.createElement)("span",{key:"imageGen",className:"bre-tag",title:t("tagImageGen")},kh(t("tagImageGen")))),o.length===0?null:(0,O.createElement)("span",{className:"bre-option-tags"},...o)}function Sh(e,t){let n=vl(e);return n===""?null:(0,O.createElement)("span",{className:"bre-option-cap",title:t("contextWindowLabel")},n)}function Cl(e){let{directory:t,t:n,configuredInputs:r}=e,o=(0,O.useSyncExternalStore)(A=>t.store.subscribe(A),()=>t.store.getSnapshot()),i=(0,O.useSyncExternalStore)(A=>r?.subscribe(A)??(()=>{}),()=>r?.getSnapshot()??_a),a=Tl(o),[s,d]=(0,O.useState)(()=>{let A=t.store.getSnapshot(),G=Tl(A);return G[Sl(G,A)]?.id??""}),[l,c]=(0,O.useState)(""),[f,h]=(0,O.useState)(null),[p,g]=(0,O.useState)(!1),[b,m]=(0,O.useState)(null),v=(0,O.useRef)(null),x=(0,O.useRef)(""),E=(0,O.useRef)(!1),N=o.current!==null&&a.length>=2,F=p,X=b??o.error,U=t.select,T=(0,O.useCallback)(()=>setTimeout(()=>{E.current&&(E.current=!1,g(!1),m(n("sliderCommitSlow")))},ph),[n]);(0,O.useLayoutEffect)(()=>{if(E.current||H.current)return;let A=Sl(a,o),G=a[A]?.id??"";x.current=G,d(pe=>pe===G?pe:G),m(null)},[N,a,o]),(0,O.useEffect)(()=>{t.load().catch(()=>{})},[t]),(0,O.useEffect)(()=>{r?.load().catch(()=>{})},[r]);let y=o.current,M=o.groups.find(A=>A.id===y?.provider),k=M?.models.find(A=>A.id===y?.model)?.name??(y===null?n("triggerFallback"):y.model),C=y===null?"":Wt(M??{id:y.provider}),D=a.find(A=>A.id===s)?.name??n("effortDefault"),_=(0,O.useSyncExternalStore)(Hn,Rn),B=(0,O.useSyncExternalStore)(In,yr),te=(0,O.useSyncExternalStore)(Dn,vr),ee=(0,O.useCallback)((A,G)=>i.get(A)?.get(G),[i]),ie=(0,O.useCallback)((A,G)=>Ll(G,ee(A,G.id)),[ee]),oe=(0,O.useCallback)((A,G)=>gh(A).filter(pe=>!ie(G,pe)),[ie]),ae=o.groups.filter(A=>oe(A,A.id).length>0&&!B.includes(A.id)).map(A=>A.id),me=Nn(la(ae),_),ge=f!==null&&me.includes(f)?f:y!==null&&me.includes(y.provider)?y.provider:me[0]??null,ce=l.trim().toLowerCase(),Q=ce!=="",ue=Q?me.flatMap(A=>ba(oe(o.groups.find(G=>G.id===A),A),te[A]??[]).filter(G=>(G.name??G.id).toLowerCase().includes(ce)||G.id.toLowerCase().includes(ce)).map(G=>({provider:A,choice:G}))):[],ke=Q?ue:ge===null?[]:ba(oe(o.groups.find(A=>A.id===ge),ge),te[ge]??[]).map(A=>({provider:ge,choice:A})),Se=y===null?"":y.provider+"/"+y.model,Ce=n("sliderNoCurrent"),$=(0,O.useCallback)(()=>{let A=v.current?.closest('[role="menu"], [role="group"]');A!=null&&(A.tabIndex=-1,A.focus({preventScroll:!0}))},[]),K=(0,O.useCallback)(async(A,G)=>{if(E.current)return;let pe=t.store.getSnapshot().current;if(Q&&c(""),pe!==null&&pe.provider===A&&pe.model===G)return;E.current=!0,$(),g(!0),m(null);let je=T();try{let ze=await U({provider:A,model:G}),pt=qa(ze);if(pt!==void 0)throw new Error(pt)}catch(ze){m(ze instanceof Error?ze.message:String(ze))}finally{clearTimeout(je),E.current=!1,g(!1)}},[T,t,$,Q,U]),z=(0,O.useCallback)(async A=>{if(E.current||A===o.current?.reasoningEffort&&o.status!=="error")return;E.current=!0;let G=x.current;$(),g(!0),m(null),d(A);let pe=T();try{let je=o.current;if(je===null)throw new Error(n("sliderNoCurrent"));let ze=await U({provider:je.provider,model:je.model,reasoningEffort:A}),pt=qa(ze);if(pt!==void 0)throw new Error(pt);let tn=t.store.getSnapshot(),Ad=a.find(pg=>pg.id===tn.current?.reasoningEffort)?.id??A;x.current=Ad,d(Ad)}catch(je){x.current=G,d(G),m(je instanceof Error?je.message:String(je))}finally{clearTimeout(pe),E.current=!1,g(!1)}},[T,t,$,a,U,o.current,o.status,n]),u=(0,O.useRef)(null),S=(0,O.useRef)(null),P=(0,O.useRef)(null),H=(0,O.useRef)(!1),J=(0,O.useRef)(null),ne=(0,O.useRef)(null),ve=(0,O.useRef)(null),[Oe,_e]=(0,O.useState)(null),[R,Y]=(0,O.useState)(null),se=Math.max(0,a.findIndex(A=>A.id===s)),ye=Oe??se,Ee=(R??(a.length>1?ye/(a.length-1):0))*100,fe=A=>{let G=u.current;if(G===null)return 0;let pe=G.getBoundingClientRect();return pe.width<=0?0:Math.min(1,Math.max(0,(A-pe.left)/pe.width))},Ie=A=>a.length>1?Math.round(A*(a.length-1)):0,Ue=A=>{ne.current=A;let G=A*100;S.current!==null&&(S.current.style.clipPath=`inset(0 ${100-G}% 0 0)`),P.current!==null&&(P.current.style.left=`${G}%`)},ft=A=>{if(a.length===0)return;let G=fe(A);ve.current===null&&(ve.current=requestAnimationFrame(()=>{ve.current=null,H.current&&ne.current!==null&&Ue(ne.current)})),ne.current=G;let pe=Ie(G);pe!==J.current&&(J.current=pe,_e(pe),Y(G))},Zt=()=>{J.current=null,ne.current=null,ve.current!==null&&(cancelAnimationFrame(ve.current),ve.current=null),_e(null),Y(null)},Tn=A=>{if(N){if(A.preventDefault(),H.current=!0,typeof A.currentTarget.setPointerCapture=="function")try{A.currentTarget.setPointerCapture(A.pointerId)}catch{}J.current=Ie(fe(A.clientX)),ft(A.clientX),_e(J.current),Y(ne.current)}},Me=A=>{H.current&&ft(A.clientX)},co=A=>{if(!H.current)return;if(H.current=!1,typeof A.currentTarget.releasePointerCapture=="function"&&A.currentTarget.hasPointerCapture?.(A.pointerId)===!0)try{A.currentTarget.releasePointerCapture(A.pointerId)}catch{}let G=Ie(fe(A.clientX)),pe=a[G];if(pe===void 0){Zt();return}z(pe.id).finally(Zt)},Zi=A=>{if(!N)return;let G;if(A.key==="ArrowRight"||A.key==="ArrowUp"?G=Math.min(a.length-1,ye+1):A.key==="ArrowLeft"||A.key==="ArrowDown"?G=Math.max(0,ye-1):A.key==="Home"?G=0:A.key==="End"&&(G=a.length-1),G===void 0)return;A.preventDefault();let pe=a[G];pe!==void 0&&z(pe.id)},{tip:Sn,onEnter:en,onLeave:gr}=hh(),uo=(0,O.createElement)("div",{className:"bre-menu-head"},(0,O.createElement)("span",{className:"bre-row-label"},n("modelRowLabel")),(0,O.createElement)("span",{className:"bre-menu-cur"},(0,O.createElement)("span",{className:"bre-menu-name","aria-label":y===null?k:C+" \xB7 "+k,onMouseEnter:A=>{en(A,y===null?k:C+" \xB7 "+k)},onMouseLeave:gr},k),C===""?null:(0,O.createElement)("span",{className:"bre-menu-prov"},C))),I=(0,O.createElement)("div",{className:"bre-menu-search"},(0,O.createElement)("div",{className:"bre-menu-search-box"},(0,O.createElement)("span",{className:"bre-menu-search-icon","aria-hidden":!0},(0,O.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,O.createElement)("circle",{cx:"7",cy:"7",r:"4.5"}),(0,O.createElement)("path",{d:"M10.5 10.5L14 14",strokeLinecap:"round"}))),(0,O.createElement)("input",{type:"text",className:"bre-menu-search-input",role:"searchbox",placeholder:n("modelSearchPlaceholder"),"aria-label":n("modelSearchPlaceholder"),value:l,spellCheck:!1,autoComplete:"off",onChange:A=>{c(A.currentTarget.value)},onKeyDown:A=>{A.key!=="Escape"||l===""||(A.preventDefault(),A.stopPropagation(),c(""))}}),l===""?null:(0,O.createElement)("button",{type:"button",className:"bre-menu-search-clear",title:n("modelSearchClear"),"aria-label":n("modelSearchClear"),onClick:()=>{c("")}},(0,O.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,O.createElement)("path",{d:"M4 4L12 12M12 4L4 12",strokeLinecap:"round"}))))),de=(0,O.createElement)("div",{className:"bre-providers",role:"group","aria-label":n("modelRowLabel")},...me.map(A=>{let G=o.groups.find(pe=>pe.id===A);return(0,O.createElement)("button",{key:A,type:"button",className:"bre-provider"+(A===ge?" is-open":"")+(A===y?.provider?" is-current":""),disabled:F,"aria-expanded":A===ge,onMouseLeave:gr,onClick:()=>{h(A),c("")}},(0,O.createElement)("span",{className:"bre-option-name","aria-label":Wt(G),onMouseEnter:pe=>{en(pe,Wt(G))}},Wt(G)),(0,O.createElement)("span",{className:"bre-provider-count"},String(oe(G,A).length)))}),...me.length===0?[(0,O.createElement)("div",{key:"no-providers",className:"bre-empty"},Ce)]:[]),Le=(0,O.createElement)("div",{className:"bre-provider-models",role:"group","aria-label":n("modelRowLabel")},...ke.length===0?[(0,O.createElement)("div",{key:"no-models",className:"bre-empty"},Q?n("modelSearchNoMatches"):Ce)]:ke.map(({provider:A,choice:G})=>{let pe=A+"/"+G.id,je=pe===Se,ze=G.name??G.id,pt=Q?Wt(o.groups.find(tn=>tn.id===A))+" \xB7 "+ze:ze;return(0,O.createElement)("button",{key:pe,type:"button",className:"bre-option"+(je?" is-active":""),disabled:F,"aria-pressed":je,onMouseLeave:gr,onClick:()=>{K(A,G.id)}},(0,O.createElement)("span",{className:"bre-option-name","aria-label":pt,onMouseEnter:tn=>{en(tn,pt)}},Q?(0,O.createElement)("span",{className:"bre-option-origin"},Wt(o.groups.find(tn=>tn.id===A))+" \xB7 "):null,ze),Sh(ee(A,G.id)?.contextWindow,n),Th(G,n,ee(A,G.id)?.input,Ll(G,ee(A,G.id))))})),Fe=(0,O.createElement)("div",{className:"bre-menu-foot"},N?(0,O.createElement)("div",{className:"bre-menu-slider"},(0,O.createElement)("div",{className:"bre-effort-slider-head","aria-hidden":!0},(0,O.createElement)("span",{className:"bre-effort-slider-head-label"},n("effortRowLabel")),(0,O.createElement)("span",{className:"bre-effort-slider-head-value"},a[ye]?.name??D)),(0,O.createElement)("div",{className:"bre-effort-slider",ref:u,role:"slider",tabIndex:0,"aria-label":n("effortRowLabel"),"aria-valuemin":0,"aria-valuemax":a.length-1,"aria-valuenow":ye,"aria-valuetext":a[ye]?.name,"aria-disabled":F||void 0,"data-bre-dragging":Oe===null?void 0:"true",onPointerDown:Tn,onPointerMove:Me,onPointerUp:co,onPointerCancel:co,onKeyDown:Zi},(0,O.createElement)("span",{className:"bre-effort-slider-fill",ref:S,style:{clipPath:`inset(0 ${100-Ee}% 0 0)`}}),...a.map((A,G)=>G===ye?null:(0,O.createElement)("span",{key:"tick-"+A.id,className:"bre-effort-slider-tick",style:{left:a.length>1?`${G/(a.length-1)*100}%`:"0%"}})),(0,O.createElement)("span",{className:"bre-effort-slider-thumb",ref:P,style:{left:`${Ee}%`}})),(0,O.createElement)("div",{className:"bre-effort-slider-labels","aria-hidden":!0},...a.map((A,G)=>(0,O.createElement)("span",{key:A.id,className:"bre-effort-slider-label"+(G===0?" is-first":"")+(G===a.length-1?" is-last":"")+(G===ye?" is-on":""),style:{left:a.length>1?`${G/(a.length-1)*100}%`:"0%"}},A.name)))):(0,O.createElement)("span",{className:"bre-row-value is-muted"},n("sliderNoLevels")));return(0,O.createElement)("div",{className:"bre-slider-body",ref:v},(0,O.createElement)("div",{className:"bre-card"},uo,I,(0,O.createElement)("div",{className:"bre-panel bre-panel-models"},de,Le),Fe),X===null?null:(0,O.createElement)("div",{className:"bre-model-error",role:"status"},X),Sn===null?null:(0,O.createElement)(bh,{key:"tip",state:Sn}))}var xe=require("react"),Hl='section[role="group"]',Ga='button[role="menuitemradio"]';function Nl(e){return e.querySelector(Hl)!==null}function Wa(e){return Array.from(e.querySelectorAll(Ga)).filter(t=>!t.disabled&&t.style.display!=="none")}function Mh(e){let t=e.getAttribute("aria-labelledby");return(t===null?null:e.ownerDocument.getElementById(t))?.textContent?.toLowerCase()??""}function Rl(e,t,n=new Map){let r=d=>{n.has(d)||n.set(d,d.style.display),d.style.display="none"},o=d=>{let l=n.get(d);l!==void 0&&(d.style.display=l,n.delete(d))};for(let d of[...n.keys()])d.isConnected||n.delete(d);let i=t.trim().toLowerCase().split(/\s+/).filter(Boolean),a=Array.from(e.querySelectorAll(Hl)),s=0;if(i.length===0){for(let d of[...n.keys()])o(d);for(let d of a)s+=d.querySelectorAll(Ga).length;return s}for(let d of a){let l=Mh(d),c=Array.from(d.querySelectorAll(Ga)),f=0;for(let h of c){let p=(h.getAttribute("title")??"").toLowerCase(),g=(h.textContent??"").toLowerCase(),b=`${l} ${p} ${g}`;i.every(m=>b.includes(m))?(o(h),f+=1):r(h)}f>0?(o(d),s+=f):r(d)}return s}function Ol({menu:e,t}){let[n,r]=(0,xe.useState)(""),[o,i]=(0,xe.useState)(0),a=(0,xe.useRef)(null),s=(0,xe.useRef)(""),d=(0,xe.useRef)(new Map),l=(0,xe.useCallback)(p=>{s.current=p;let g=Rl(e,p,d.current);i(g)},[e]);(0,xe.useEffect)(()=>()=>{Rl(e,"",d.current)},[e]),(0,xe.useEffect)(()=>{let p=new MutationObserver(()=>{s.current.trim().length!==0&&l(s.current)});return p.observe(e,{childList:!0,subtree:!0}),()=>{p.disconnect()}},[e,l]),(0,xe.useEffect)(()=>{let p=g=>{if(s.current.trim().length===0)return;let b=g.key;if(!(b==="ArrowDown"||b==="ArrowUp")&&!(b==="Home"||b==="End"||b==="PageUp"||b==="PageDown")||g.target===a.current||g.target instanceof Node&&!e.contains(g.target))return;let x=Wa(e);if(x.length===0)return;let E=x.findIndex(F=>F===document.activeElement),N;b==="Home"||b==="PageUp"?N=0:b==="End"||b==="PageDown"?N=x.length-1:b==="ArrowDown"?N=E===-1?0:(E+1)%x.length:N=E===-1?x.length-1:(E-1+x.length)%x.length,g.preventDefault(),g.stopPropagation(),x[N]?.focus()};return e.addEventListener("keydown",p,!0),()=>{e.removeEventListener("keydown",p,!0)}},[e]);let c=p=>{let g=p.key;if(g==="ArrowDown"){p.preventDefault(),p.stopPropagation(),Wa(e)[0]?.focus();return}if(n.trim().length>0&&(g==="ArrowUp"||g==="Home"||g==="PageUp"||g==="End"||g==="PageDown")){let b=Wa(e);b.length>0&&(p.preventDefault(),p.stopPropagation(),b[g==="ArrowUp"||g==="End"||g==="PageDown"?b.length-1:0]?.focus());return}g==="Escape"&&n.length>0&&(p.preventDefault(),p.stopPropagation(),r(""),l(""))},f=()=>{r(""),l(""),a.current?.focus({preventScroll:!0})},h=o===0&&n.trim().length>0;return(0,xe.createElement)("div",{className:"bre-model-search-box"+(h?" has-empty":""),"data-bre-search":"1"},(0,xe.createElement)("div",{className:"bre-search-input-wrapper"},(0,xe.createElement)("span",{className:"bre-search-icon","aria-hidden":"true"},(0,xe.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,xe.createElement)("circle",{cx:"7",cy:"7",r:"4.5"}),(0,xe.createElement)("path",{d:"M10.5 10.5L14 14",strokeLinecap:"round"}))),(0,xe.createElement)("input",{ref:a,type:"text",className:"bre-search-input",role:"searchbox",placeholder:t("modelSearchPlaceholder"),"aria-label":t("modelSearchPlaceholder"),value:n,spellCheck:!1,autoComplete:"off",onChange:p=>{let g=p.currentTarget.value;r(g),l(g)},onKeyDown:c}),n.length>0?(0,xe.createElement)("button",{type:"button",className:"bre-search-clear",title:t("modelSearchClear"),"aria-label":t("modelSearchClear"),onClick:f},(0,xe.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,xe.createElement)("path",{d:"M4 4L12 12M12 4L4 12",strokeLinecap:"round"}))):null),h?(0,xe.createElement)("div",{className:"bre-search-empty",role:"status"},t("modelSearchNoMatches")):null)}var Oo=require("react"),Il=require("react-dom"),Dl=require("react-dom/client");function bt(){return document.body}function Xe(e,t,n){let r=(0,Dl.createRoot)(e);return n?.sync===!0?(0,Il.flushSync)(()=>{r.render(t)}):r.render(t),{wrapper:e,root:r}}function Re(e){e!==void 0&&(e.root.unmount(),e.wrapper.remove())}var Be=class extends Oo.Component{constructor(){super(...arguments);Ke(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n instanceof Error?n.message:String(n)}}componentDidCatch(n,r){console.error("[bre] editor render failed:",n,r.componentStack)}render(){return this.state.error!==null?(0,Oo.createElement)("div",{style:{color:"#c00",fontSize:"11px",whiteSpace:"pre-wrap",padding:"6px"}},`${this.props.fallbackText}: ${this.state.error}`):this.props.children}};var Lh="conversation.input.model";function Pl(e){return e.querySelector("[data-composer-card]")??void 0}function Ua(e){return e.querySelector(`[data-slot="${Lh}"]`)??void 0}function _l(e){let t=Ua(e)??e;return Array.from(t.querySelectorAll('button[aria-haspopup="menu"]'))}function ja(e){if(e==null)return!1;let t=e.getAttribute("role");return t==="menu"||t==="group"}function za(e){return e.getAttribute("role")==="group"}function Fl(e,t){let n=e.getAttribute("aria-controls");if(n===null||n.length===0)return;let r=t.getElementById(n);return ja(r)?r:void 0}function $a(e=document){let t=Pl(e);if(t===void 0)return;for(let r of _l(t)){let o=Fl(r,e);if(o!==void 0)return o}let n=Ua(t)??t;for(let r of Array.from(n.querySelectorAll('[role="menu"], [role="group"]')))if(r.previousElementSibling?.matches('button[aria-haspopup="menu"]')&&ja(r)&&!(r.getAttribute("role")==="group"&&r.querySelector('[role="menuitemradio"], section[role="group"]')===null))return r}function Va(e=document){let t=Pl(e);if(t===void 0)return;let n=Ua(t),r=_l(t),o=r[0];if(o!==void 0){for(let i of r)if(Fl(i,e)!==void 0)return i;for(let i of r)if(ja(i.nextElementSibling))return i;return n===void 0?r.at(-1):o}}function Kl(){return $a()}function ql(){return Va()}var Ah=()=>{(0,Bl.flushSync)(()=>{window.dispatchEvent(new Event("resize"))})};function Wl(e){let{menuOf:t,triggerOf:n,t:r,refreshed:o,sliderEnabled:i,directory:a}=e,s,d,l,c,f,h,p,g,b=()=>{g?.removeAttribute("data-bre-provider"),g=void 0},m=()=>{let w=n();g!==void 0&&g!==w&&b();let k=h?.store.getSnapshot(),C=k?.current;if(w===void 0||C===null||C===void 0){w===g&&b();return}let D=k?.groups.find(B=>B.id===C.provider),_=D===void 0?C.provider:Wt(D);if(_.trim()===""){w===g&&b();return}w.dataset.breProvider=_,g=w},v=()=>{let w=a();w!==h&&(p?.(),p=void 0,h=w,w!==void 0&&(p=w.store.subscribe(m))),m()},x=()=>{Re(l),l=void 0},E=new Map,N=()=>{for(let[k,C]of E)k.style.display=C;E.clear();let w=t();w!==void 0&&w.getAttribute("tabindex")==="-1"&&w.removeAttribute("tabindex")},F=w=>w.getAttribute("aria-hidden")!=="true"||w.childElementCount>0?!1:(w.textContent??"").trim()==="",X=(w,k)=>{for(let _ of Array.from(E.keys()))(!_.isConnected||_.parentElement!==w)&&E.delete(_);let C=[];for(let _ of Array.from(w.children))_!==k&&(F(_)||C.push(_));let D=document.activeElement;D!==null&&D!==k&&!k.contains(D)&&C.some(_=>_.contains(D))&&(w.tabIndex=-1,w.focus({preventScroll:!0}));for(let _ of C)E.has(_)||E.set(_,_.style.display),_.style.display!=="none"&&(_.style.display="none")},U=w=>{let k=w.querySelector('section[role="group"]'),C=k?.parentElement,D=C!=null&&C.parentElement===w?C:k;if(l===void 0){let _=document.createElement("div");_.dataset.plugin=we,_.dataset.breSearch="1",w.insertBefore(_,D),l=Xe(_,(0,Ar.createElement)(Be,{fallbackText:r("modelSearchFailed"),children:o(()=>(0,Ar.createElement)(Ol,{menu:w,t:r}))}),{sync:!0});return}if(l.wrapper.parentElement!==w){w.insertBefore(l.wrapper,D);return}D!==null&&l.wrapper.nextSibling!==D&&w.insertBefore(l.wrapper,D)},T=w=>{if(!i()){Re(s),s=void 0,d=void 0,w.classList.remove("bre-model-menu-host"),N();for(let B of Array.from(w.children))B.getAttribute("role")==="menuitem"&&(B.style.display="");return}let k=a();if(k===void 0)return;if(s!==void 0&&d!==k&&(Re(s),s=void 0,d=void 0),s===void 0){d=k;let B=document.createElement("div");B.dataset.plugin=we,B.dataset.breSlider="1",w.insertBefore(B,w.firstChild),s=Xe(B,(0,Ar.createElement)(Be,{fallbackText:r("renderFailed"),children:o(()=>(0,Ar.createElement)(Cl,{directory:k,configuredInputs:e.configuredInputs,t:r}))}),{sync:!0})}else(s.wrapper.parentElement!==w||w.firstChild!==s.wrapper)&&w.insertBefore(s.wrapper,w.firstChild);w.classList.add("bre-model-menu-host");let C=Array.from(w.children).filter(B=>B.getAttribute("role")==="menuitem"),D=s.wrapper;if(za(w)){D.style.display="",X(w,D);return}if(N(),Array.from(w.querySelectorAll('[role="menuitemradio"]')).some(B=>!D.contains(B)))s.wrapper.contains(document.activeElement)&&(w.tabIndex=-1,w.focus({preventScroll:!0})),s.wrapper.style.display="none";else{s.wrapper.style.display="";for(let B of C)B.style.display="none"}};return{reconcile:()=>{v();let w=t();if(w===void 0){s!==void 0&&(i()?s.wrapper.remove():(Re(s),s=void 0,d=void 0)),x(),c=void 0,f=void 0,N();return}let k=za(w),C=k&&i(),D=!k&&Nl(w);D?U(w):x(),T(w),(D!==c||C!==f)&&(c=D,f=C,(D||C||i())&&Ah())},dispose:()=>{p?.(),p=void 0,h=void 0,b(),Re(s),s=void 0,d=void 0,x(),N(),c=void 0,f=void 0}}}var Ch=350;function Gl(e){let t,n,r=0,o=()=>{if(t!==void 0)return Promise.resolve();let s=r;return n??(n=le(e.api).then(d=>{if(d.namespace===void 0){n=void 0;return}let l=new Map;for(let[c,f]of Object.entries(qe(d.namespace))){let h=Array.isArray(f.models)?f.models:[];for(let p of h){if(typeof p!="object"||p===null||Array.isArray(p))continue;let g=p.id,b=p[Ln];typeof g=="string"&&typeof b=="string"&&b.length>0&&l.set(`${c}/${g}`,b)}}s===r?t=l:n=void 0}).catch(()=>{s===r&&(n=void 0)})),n};return{of:async(s,d)=>{if(t===void 0){let l=o();await new Promise(c=>{let f=!1,h=()=>{f||(f=!0,c())},p=setTimeout(h,Ch);l.then(()=>{clearTimeout(p),h()},()=>{clearTimeout(p),h()})})}return t?.get(`${s}/${d}`)},invalidate:()=>{r+=1,t=void 0,n=void 0}}}function Rh(e){let t=e.input;return Array.isArray(t)&&t.length>0?!0:e[wt]===!0||e[at]===!0}function Ya(e,t=()=>!0,n={},r=0){let o=n.efforts!==!1,i=n.modalities!==!1;if(!V(e))return;let a={};for(let s of Object.keys(e)){if(!t(s))continue;let d=e[s],l=V(d)&&Array.isArray(d.models)?d.models:void 0;if(l===void 0||l.length===0)continue;let c=l,f=[],h=!1;for(let p of c){if(!V(p)){f.push(p);continue}let g=p,b=g.reasoningEfforts!==void 0||g[it]===!0,m=Rh(g);if((b||!o)&&(m||!i)){let U=Hh(g,e,s);U!==void 0?(h=!0,f.push(U)):f.push(g);continue}let v=typeof g.id=="string"?g.id:"";if(v.length===0){f.push(g);continue}let x=nn(e,s),E=typeof g.name=="string"?g.name:void 0,N=xt(v,{...x,displayName:E??x.displayName});if(N.efforts===void 0){f.push(g);continue}let F={...g},X=!1;if(!b&&o&&N.confidence!=="low"&&(X=!0,F.reasoningEfforts=N.efforts,F[Mn]=r,N.compat!==void 0)){let U=V(g.compat)?g.compat:{};F.compat={...U,...N.compat}}if(!m&&i&&(N.imageGen===!0?(X=!0,F[at]=!0):N.input!==void 0&&(X=!0,F.input=[...N.input])),!X){f.push(g);continue}h=!0,f.push(F)}h&&(a[s]={models:f})}return Object.keys(a).length===0?void 0:{providers:a}}function Ja(e){if(!V(e))return;let t={};for(let[n,r]of Object.entries(e)){if(!V(r))continue;let o=typeof r.api=="string"?r.api:"";if(o.length===0)continue;let i={},a=V(r.compat)?Ra(r.compat,o):void 0;a!==void 0&&(i.compat=a);let s=Array.isArray(r.models)?r.models:void 0;if(s!==void 0&&s.length>0){let d=[],l=!1;for(let c of s){if(!V(c)||!V(c.compat)){d.push(c);continue}let f=Ra(c.compat,o);if(f===void 0){d.push(c);continue}l=!0,d.push({...c,compat:f})}l&&(i.models=d)}Object.keys(i).length>0&&(t[n]=i)}return Object.keys(t).length===0?void 0:{providers:t}}function Hh(e,t,n){if(!V(e.reasoningEfforts)||e[it]===!0)return;let r=e.compat,o=V(r)?{...r}:{};if(o.supportsDeveloperRole===void 0&&Ha(nn(t,n)))return{...e,compat:{...o,supportsDeveloperRole:!1}}}function Ul(e){let t,n=0,r=()=>{if(t!==void 0)return t;let i=(async()=>{try{let a=await fetch(Nd,{method:"GET"});if(!a.ok)return;let s=await a.json();return s?.ok!==!0?void 0:{autofill:s.data?.autofill!==!1,modalityAutofill:s.data?.modalityAutofill!==!1}}catch{return}})().then(a=>(a===void 0&&t===i&&(t=void 0),a??{autofill:!0,modalityAutofill:!0}));return t=i,i},o=async i=>{let a=n;try{let s=await r();if(a!==n||!s.autofill)return;let d=i??await le(e.api),l=d.namespace;if(a!==n||l===void 0||d.writable!==!0)return;let c=on(l);if(c===void 0||Ya(c,()=>!0,{modalities:s.modalityAutofill},l.revision)===void 0)return;let h=d.source==="scope"?await le(e.api,{fresh:!0}):d,p=h.namespace;if(a!==n||p===void 0||h.writable!==!0)return;let g=on(p);if(g===void 0)return;let b=Ya(g,()=>!0,{modalities:s.modalityAutofill},p.revision);if(b===void 0)return;let m=b.providers,v=Object.entries(m).map(([E,N])=>({op:"set",path:["providers",E,"models"],value:N.models})),x=await e.api.settings.mutate(De,v,p.revision);x.ok||console.error(`[bre] idle autofill refused: ${x.error.message}`)}catch(s){console.error(`[bre] idle autofill failed: ${s instanceof Error?s.message:String(s)}`)}};return{run:()=>{o()},invalidate:()=>{n+=1,t=void 0}}}function jl(e){let t=async n=>{let r=n??await le(e.api),o=r.namespace;if(o===void 0||r.writable!==!0)return;let i=on(o);if(i===void 0||Ja(i)===void 0)return;let a=r.source==="scope"?await le(e.api,{fresh:!0}):r,s=a.namespace;if(s===void 0||a.writable!==!0)return;let d=on(s);if(d===void 0)return;let l=Ja(d);if(l===void 0)return;let c=l.providers,f=[];for(let[p,g]of Object.entries(c))for(let b of["compat","models"])g[b]!==void 0&&f.push({op:"set",path:["providers",p,b],value:g[b]});if(f.length===0)return;let h=await e.api.settings.mutate(De,f,s.revision);h.ok||console.error(`[bre] compat cleanup refused: ${h.error.message}`)};return{run:n=>{t(n).catch(r=>{console.error(`[bre] compat cleanup failed: ${r instanceof Error?r.message:String(r)}`)})}}}var md=require("react"),bm=require("react-dom"),ym=require("react-dom/client");var be=require("react");var Gt=ml;function sn(e){let t={};for(let n of Gt){if(e===void 0){t[n]={on:!1,wire:""};continue}if(e===!1){t[n]=n==="off"?{on:!0,wire:""}:{on:!1,wire:""};continue}let r=e[n];t[n]={on:r!==void 0,wire:r===null?"":typeof r=="string"?r:""}}return t}function Kn(e){let t=!1,n=!1,r={};for(let o of Gt){let i=e[o];if(!i.on)continue;if(o==="off"){t=!0;let s=i.wire.trim();r.off=s.length===0?null:s;continue}n=!0;let a=i.wire.trim();r[o]=a.length===0?o:a}return n?r:t?!1:void 0}function Cr(e,t){if(e===t)return!0;if(e===!1||e===void 0||t===!1||t===void 0)return!1;let n=Gt.filter(o=>e[o]!==void 0),r=Gt.filter(o=>t[o]!==void 0);return n.length!==r.length?!1:n.every(o=>e[o]===t[o])}function zl(e,t){if(!(e===void 0||e===!1)&&!("off"in e)){if(t==="zai"||t==="deepseek")return"thinking-disabled";if(t==="qwen")return"enable-thinking-false"}}var Xa="bre:auto-effort",$l=Promise.resolve();function Vl(e){$l=$l.then(e,e).then(()=>{},()=>{})}function Yl(e,t=document){t.dispatchEvent(new CustomEvent(Xa,{detail:{route:e}}))}function Jl(e,t=document){let n=r=>{let o=r.detail;typeof o?.route!="string"||o.route.length===0||e(o.route)};return t.addEventListener(Xa,n),()=>{t.removeEventListener(Xa,n)}}var q=require("react/jsx-runtime"),Nh=["M3.4 4.2h9.2","M8 4.2v8.2","M5.9 12.4h4.2"],Oh=["M4.4 3.4h7.2a1.9 1.9 0 0 1 1.9 1.9v5.4a1.9 1.9 0 0 1-1.9 1.9H4.4a1.9 1.9 0 0 1-1.9-1.9V5.3a1.9 1.9 0 0 1 1.9-1.9Z","M6.2 7.2a.9.9 0 1 0 0-1.8.9.9 0 0 0 0 1.8Z","M2.9 11.2 6.1 8.4l2.1 1.9 1.8-1.5 2.7 2.4"],Ih=["M9.4 12.7H3.6a1.7 1.7 0 0 1-1.7-1.7V5.1a1.7 1.7 0 0 1 1.7-1.7h4.2","M2.6 10.6 5.3 8.5l1.8 1.5 1.6-1.3 2.3 2","M12.4 2.2l.75 2.05L15.2 5l-2.05.75L12.4 7.8l-.75-2.05L9.6 5l2.05-.75Z"],Dh=["M8 3.2 13.6 12.8H2.4L8 3.2Z","M8 6.9v2.5","M8 11.3h.01"],Ph=["M8 2.6 9.1 6.4 12.9 7.5 9.1 8.6 8 12.4 6.9 8.6 3.1 7.5 6.9 6.4Z","M12.3 2.4v1.9M11.35 3.35h1.9"],_h=["M4.5 6.5 8 10 11.5 6.5"],Fh=["M6.5 4.5 10 8 6.5 11.5"];function qn({paths:e}){return(0,q.jsx)("svg",{viewBox:"0 0 16 16",width:12,height:12,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:e.map(t=>(0,q.jsx)("path",{d:t},t))})}function Ct(e,t){return t===!0?{declared:!1,image:!1,imageGen:!0}:e===void 0||e.length===0?{declared:!1,image:!1,imageGen:!1}:{declared:!0,image:e.includes("image"),imageGen:!1}}function Do(e){return e.imageGen?{input:null,imageGen:!0}:e.declared?{input:e.image?["text","image"]:["text"],imageGen:!1}:{input:null,imageGen:!1}}function Io(e,t,n){return e.imageGen!==(n===!0)?!1:e.imageGen?!0:e.declared?t===void 0?!1:e.image?t.includes("image"):!t.includes("image"):t===void 0}function Qa(e,t,n){let r=e?t:!1;return e&&r===void 0&&n===void 0?"keep":r}function Po(e){let t=e.appliedCompat;return e.initialCompat?.supportsThinkingTokenBudget===!0&&e.initialCompat?.thinkingTokenBudgetField===void 0&&t?.thinkingTokenBudgetField===void 0&&(e.routeApi??"").toLowerCase()==="openai-completions"&&(t={...t??{},thinkingTokenBudgetField:"thinking_token_budget"}),{efforts:e.efforts,...t===void 0?{}:{compat:t},...e.input===void 0?{}:{input:e.input},...e.imageGen===void 0?{}:{imageGen:e.imageGen},...e.defaultEffort===void 0?{}:{defaultEffort:e.defaultEffort}}}function _o({route:e,routeApi:t,routeBaseURL:n,modelId:r,modelName:o,efforts:i,effortsUnset:a=!1,input:s,imageGen:d,compat:l,defaultEffort:c,index:f,staged:h=!1,officialInputTypes:p=!1,api:g,readOnly:b,t:m}){let[v,x]=(0,be.useState)(()=>sn(i)),[E,N]=(0,be.useState)(()=>Ct(s,d)),[F,X]=(0,be.useState)(()=>i!==!1),[U,T]=(0,be.useState)(()=>c??""),[y,M]=(0,be.useState)(!1),[w,k]=(0,be.useState)(void 0),[C,D]=(0,be.useState)(()=>Gt.some(I=>v[I].on&&v[I].wire.trim()!==(I==="off"?"":I))),_=(0,be.useRef)(void 0),B=(0,be.useRef)(void 0);B.current===void 0&&(B.current=g.readCapacities?.()??{});let[te,ee]=(0,be.useState)(()=>ht(B.current?.contextWindow)),[ie,oe]=(0,be.useState)(()=>ht(B.current?.maxTokens)),[ae,me]=(0,be.useState)(void 0),ge=(0,be.useRef)(!1),ce=(0,be.useRef)(i),Q=(0,be.useRef)(s),ue=(0,be.useRef)(d),ke=(0,be.useRef)(c),Se=(0,be.useRef)(void 0),Ce=(0,be.useRef)(i);Ce.current=i;let $=(0,be.useRef)(a);$.current=a,(0,be.useEffect)(()=>Jl(I=>{if(I!==e||Ce.current!==void 0||$.current)return;let de=Se.current;de!==void 0&&Vl(de)}),[e]),(0,be.useEffect)(()=>{Cr(ce.current,i)||(ce.current=i,ge.current||(x(sn(i)),X(i!==!1))),(Q.current!==s||ue.current!==d)&&(Q.current=s,ue.current=d,ge.current||N(Ct(s,d))),ke.current!==c&&(ke.current=c,ge.current||T(c??""))},[i,s,d,c]);let K=Gt.filter(I=>v[I].on),z=U===(c??"")?void 0:U===""?null:U,u=F?Kn(v):!1,S=!Cr(u,i)||!Io(E,s,d)||z!==void 0,P=(0,be.useRef)(void 0),H=()=>{ge.current=!0},J=(I,de,Le,Fe=F)=>{let A=Qa(Fe,Kn(I),i),pe=!Io(de,s,d)?Do(de):void 0,je=Le===(c??"")?void 0:Le===""?null:Le,ze=Po({efforts:A,input:pe?.input,imageGen:pe?.imageGen,defaultEffort:je,appliedCompat:_.current,routeApi:t,initialCompat:l}),pt=JSON.stringify(ze);P.current!==pt&&(P.current=pt,g.commit(e,r,ze))},ne=(I,de)=>{H();let Le=!de&&U===I?"":U;Le!==U&&T(Le);let Fe={...v,[I]:{...v[I],on:de}};de&&I!=="off"&&Fe[I].wire.trim().length===0&&(Fe[I]={...Fe[I],wire:I}),x(Fe),J(Fe,E,Le),k(void 0)},ve=I=>{H(),X(I);let de=I?U:"";de!==U&&T(de),J(v,E,de,I),k(void 0)},Oe=(I,de)=>{H();let Le={...v,[I]:{...v[I],wire:de}};x(Le),J(Le,E,U),k(void 0)},_e=I=>{H();let de={declared:!0,image:I,imageGen:!1};N(de),J(v,de,U),k(void 0)},R=()=>{H();let I={declared:!1,image:!1,imageGen:!1};N(I),J(v,I,U),k(void 0)},Y=I=>{H();let de=I?{declared:!1,image:!1,imageGen:!0}:{declared:!1,image:!1,imageGen:!1};N(de),J(v,de,U),k(void 0)},se=I=>{H(),T(I),J(v,E,I),k(void 0)},ye=(I,de)=>{let Le=de.slice(0,20),Fe=I==="context"?Le:te,A=I==="output"?Le:ie;me(I),I==="context"?ee(Le):oe(Le),g.setCapacities?.({contextWindow:kt(Fe),maxTokens:kt(A)})},Ee=I=>{I==="context"?ee(de=>ht(kt(de))):oe(de=>ht(kt(de))),me(void 0)},fe=I=>{H();let de=I.efforts!==!1;X(de);let Le=sn(I.efforts);x(Le);let Fe=I.imageGen===!0?Ct(void 0,!0):I.input===void 0?E:Ct(I.input);Fe!==E&&N(Fe);let A=U===""&&I.defaultEffort!==void 0?I.defaultEffort:U;if(A!==U&&T(A),_.current=I.compat,I.contextWindow!==void 0||I.maxTokens!==void 0){g.fillCapacities?.(I.contextWindow,I.maxTokens);let G=g.readCapacities?.();ee(ht(G?.contextWindow)),oe(ht(G?.maxTokens))}k(void 0),J(Le,Fe,A,de)},Ie=async()=>{if(!(b||y)){M(!0),k(void 0);try{let I=h?await g.suggest(e,r,o,{...t===void 0?{}:{api:t},...n===void 0?{}:{baseURL:n}}):await g.suggest(e,r,o);if(!I.ok){k({kind:"error",text:I.error==="no-suggestion"?m("noSuggestion"):I.error});return}fe(I.suggestion)}catch(I){k({kind:"error",text:m("writeError",{message:String(I)})})}finally{M(!1)}}};(0,be.useEffect)(()=>{Se.current=Ie});let Ue=()=>{ge.current=!1,g.withdraw(e,r),x(sn(i)),X(i!==!1),N(Ct(s,d)),T(c??""),_.current=void 0;let I=B.current??{};ee(ht(I.contextWindow)),oe(ht(I.maxTokens)),me(void 0),g.setCapacities?.({contextWindow:I.contextWindow,maxTokens:I.maxTokens}),k(void 0),P.current=void 0},ft=(0,be.useMemo)(()=>xt(r,{...t===void 0?{}:{api:t},...n===void 0?{}:{baseURL:n}}).compat?.thinkingFormat,[r,t,n]),Zt=_.current?.thinkingFormat??ft,Tn=zl(i,Zt),Me=b||y,co=F?K.length===0?m("stateUndeclared"):m("stateDeclared",{count:K.length,default:m(U===""?"defaultEffortUnset":"level_"+U)}):m("thinkingModeOff"),Zi=U!==""&&!K.includes(U)?[...K,U]:K,Sn=kt(te),en=kt(ie),gr=Sn!==void 0&&en!==void 0&&en>Sn,uo=(0,q.jsxs)(q.Fragment,{children:[gr?(0,q.jsxs)("p",{className:"bre-effort-note bre-warn",children:[(0,q.jsx)(qn,{paths:Dh}),m("capacityRule")]}):null,(0,q.jsxs)("div",{className:"bre-effort-cols",children:[(0,q.jsxs)("div",{className:"bre-effort-sec",children:[(0,q.jsx)("span",{className:"bre-effort-label",children:m("contextWindowLabel")}),(0,q.jsxs)("span",{className:"bre-cap-box",children:[(0,q.jsx)("input",{type:"text",inputMode:"text",className:"bre-cap-input",value:ae==="context"?te:ht(Sn),disabled:Me,placeholder:m("capacityBlank"),"aria-label":m("contextWindowLabel")+" "+String(f+1),onFocus:()=>{me("context")},onBlur:()=>{Ee("context")},onChange:I=>{ye("context",I.target.value)}}),(0,q.jsx)("span",{className:"bre-cap-unit",children:m("tokensUnit")})]}),(0,q.jsx)("p",{className:"bre-effort-note",children:m("capacityInherit")})]}),(0,q.jsxs)("div",{className:"bre-effort-sec",children:[(0,q.jsx)("span",{className:"bre-effort-label",children:m("maxTokensLabel")}),(0,q.jsxs)("span",{className:"bre-cap-box",children:[(0,q.jsx)("input",{type:"text",inputMode:"text",className:"bre-cap-input",value:ae==="output"?ie:ht(en),disabled:Me,placeholder:m("capacityBlank"),"aria-label":m("maxTokensLabel")+" "+String(f+1),onFocus:()=>{me("output")},onBlur:()=>{Ee("output")},onChange:I=>{ye("output",I.target.value)}}),(0,q.jsx)("span",{className:"bre-cap-unit",children:m("tokensUnit")})]}),(0,q.jsx)("p",{className:"bre-effort-note",children:m("capacityUnitsHint")})]})]})]});return(0,q.jsxs)("div",{className:"bre-effort-editor","data-plugin":we,children:[(0,q.jsxs)("div",{className:"bre-effort-modality",children:[(0,q.jsx)("span",{className:"bre-effort-label",children:m("inputModality")}),(0,q.jsxs)("div",{className:"bre-pillrow",role:"group","aria-label":m("inputModality"),children:[(0,q.jsxs)("button",{type:"button",className:E.declared?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:Me,"aria-pressed":E.declared,"aria-label":m("modalityText")+" "+String(f+1),title:m("modalityText"),onClick:()=>{E.declared?R():_e(!1)},children:[(0,q.jsx)(qn,{paths:Nh}),m("modalityText")]}),(0,q.jsxs)("button",{type:"button",className:E.declared&&E.image?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:Me,"aria-pressed":E.declared&&E.image,"aria-label":m("modalityImage")+" "+String(f+1),title:m("modalityImage"),onClick:()=>{_e(!(E.declared&&E.image))},children:[(0,q.jsx)(qn,{paths:Oh}),m("modalityImage")]}),(0,q.jsxs)("button",{type:"button",className:E.imageGen?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:Me,"aria-pressed":E.imageGen,"aria-label":m("modalityImageGen")+" "+String(f+1),title:m("modalityImageGen"),onClick:()=>{Y(!E.imageGen)},children:[(0,q.jsx)(qn,{paths:Ih}),m("modalityImageGen")]})]}),(0,q.jsx)("p",{className:"bre-effort-note",children:E.imageGen?m("modalityImageGenHint"):E.declared?m("modalityDeclared"):m("modalityInherit")})]}),(0,q.jsxs)("div",{className:"bre-effort-top",children:[(0,q.jsxs)("label",{className:"bre-thinking-switch",children:[(0,q.jsx)("input",{type:"checkbox",checked:F,disabled:Me,"aria-label":m("thinkingMode")+" "+String(f+1),onChange:I=>{ve(I.target.checked)}}),(0,q.jsx)("span",{className:"bre-effort-switch-track","aria-hidden":"true"}),(0,q.jsx)("span",{className:"bre-effort-title",children:m("thinkingMode")})]}),(0,q.jsx)("span",{className:"bre-effort-state",children:co})]}),F?(0,q.jsxs)(q.Fragment,{children:[i===!1?(0,q.jsx)("p",{className:"bre-effort-note bre-effort-note--top",children:m("reasoningDisabled")}):null,Tn===void 0?null:(0,q.jsx)("p",{className:"bre-effort-note bre-effort-note--top",children:m(Tn==="thinking-disabled"?"defaultRiskDisabled":"defaultRiskQwen")})]}):null,F?(0,q.jsxs)("div",{className:"bre-effort-card",children:[(0,q.jsxs)("div",{className:"bre-effort-sec",children:[(0,q.jsxs)("div",{className:"bre-effort-labelrow",children:[(0,q.jsx)("span",{className:"bre-effort-label",children:m("levelsLabel")}),(0,q.jsx)("span",{className:"bre-effort-grow"}),(0,q.jsxs)("button",{type:"button",className:"bre-effort-adapt",disabled:Me,onClick:()=>{Ie()},children:[(0,q.jsx)(qn,{paths:Ph}),m("autoAdapt")]})]}),(0,q.jsx)("div",{className:"bre-pillrow",role:"group","aria-label":m("levelsLabel"),children:Gt.map(I=>{let de=v[I];return(0,q.jsx)("button",{type:"button",className:de.on?"bre-lvl is-on":"bre-lvl",disabled:Me,"aria-pressed":de.on,"aria-label":m("level_"+I)+" "+String(f+1),title:m("level_"+I),onClick:()=>{ne(I,!de.on)},children:m("level_"+I)},I)})}),(0,q.jsx)("p",{className:"bre-effort-hint",children:m("levelsHint")}),K.length===0?null:(0,q.jsxs)("button",{type:"button",className:"bre-effort-wiretoggle",disabled:Me,"aria-expanded":C,onClick:()=>{D(!C)},children:[(0,q.jsx)(qn,{paths:C?_h:Fh}),m(C?"wireHide":"wireShow")]}),K.length===0||!C?null:(0,q.jsxs)("div",{className:"bre-wire",children:[(0,q.jsx)("div",{className:"bre-wire-grid",children:K.map(I=>(0,q.jsxs)(be.Fragment,{children:[(0,q.jsx)("span",{className:"bre-wire-name",children:m("level_"+I)}),(0,q.jsx)("input",{type:"text",className:"bre-effort-wire",value:v[I].wire,disabled:Me,placeholder:m("wirePlaceholder"),"aria-label":m("level_"+I)+" "+m("wireValue"),onChange:de=>{Oe(I,de.target.value)}})]},I))}),(0,q.jsx)("p",{className:"bre-effort-note",children:m("wireHint")})]})]}),K.length===0?null:(0,q.jsx)("div",{className:"bre-effort-cols",children:(0,q.jsxs)("div",{className:"bre-effort-sec",children:[(0,q.jsx)("span",{className:"bre-effort-label",children:m("defaultEffortLabel")}),(0,q.jsxs)("select",{className:"bre-effort-select",value:U,disabled:Me,"aria-label":m("defaultEffortLabel"),onChange:I=>{se(I.target.value)},children:[(0,q.jsx)("option",{value:"",children:m("followMemory")}),Zi.map(I=>(0,q.jsx)("option",{value:I,children:m("level_"+I)},I))]}),(0,q.jsx)("p",{className:"bre-effort-note",children:m("defaultEffortHint")})]})}),h?(0,q.jsx)("p",{className:"bre-effort-note",children:m("stagedHint")}):null,Kn(v)===void 0&&i!==void 0?(0,q.jsx)("p",{className:"bre-effort-note",children:m("bareHint")}):null,(0,q.jsx)("span",{className:"bre-effort-sep"}),uo,w===void 0?null:(0,q.jsx)("p",{className:"bre-effort-message bre-"+w.kind,role:w.kind==="error"?"alert":"status",children:w.text}),(0,q.jsx)("div",{className:"bre-effort-actions",children:(0,q.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:Me||!S,onClick:Ue,children:m("reset")})})]}):(0,q.jsxs)("div",{className:"bre-effort-card bre-effort-card--capacity",children:[uo,w===void 0?null:(0,q.jsx)("p",{className:"bre-effort-message bre-"+w.kind,role:w.kind==="error"?"alert":"status",children:w.text})]})]})}function he(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function yt(e,t){e!==void 0&&e.hidden!==t&&(e.hidden=t)}function We(e,t,n){e.classList.contains(t)!==n&&(n?e.classList.add(t):e.classList.remove(t))}function Rr(e,t){e!==void 0&&e.textContent!==t&&(e.textContent=t)}var Ut="data-bre-auto-effort",Za='[class*="modelCatalog"]',Kh='[class*="modelListHead"]',qh='button[class*="linkButton"]',Bh="bre-auto-effort",Wh="bre-auto-effort-note",Gh="data-bre-auto-effort-phase",Ql="bre-auto-effort-note-text",Zl="bre-auto-effort-note-detail",Uh=3e3;function jh(e){return e.blocked==="busy"?null:e.failed!==void 0?{phase:"failed",count:0,missed:0,detail:e.failed}:e.blocked!==void 0?{phase:"blocked",count:0,missed:0,detail:""}:e.held>0?{phase:"done",count:e.held,missed:e.unsuggested,detail:""}:e.unsuggested>0?{phase:"unsuggested",count:0,missed:e.unsuggested,detail:""}:{phase:"empty",count:0,missed:0,detail:""}}function es(e){return Array.from(e.querySelectorAll(Za)).filter(t=>(t.parentElement?.closest(Za)??null)===null)}function Fo(e,t,n){let r=new Map;for(let s of t)s.route.length!==0&&s.catalogue.isConnected&&r.set(s.catalogue,s.route);let o=n.t("autoAdaptAll");for(let[s,d]of r){let l=s.querySelector(Kh)??s,c=l.querySelector(`[${Ut}]`)??$h();tc.set(c,n);let f=zh(l);f!==null?f.nextElementSibling!==c&&f.after(c):l.lastElementChild!==c&&l.append(c),Xh(c,d,o)}let i=new Set,a=new Set(r.values());for(let s of Array.from(e.querySelectorAll(`[${Ut}]`))){let d=s.closest(Za),l=s.getAttribute(Ut)??"";if(d===null||!r.has(d)||i.has(d)){s.remove(),l.length>0&&!a.has(l)&&ts(l);continue}i.add(d)}}function ts(e){let t=dn.get(e);t!==void 0&&(t.timer!==null&&clearTimeout(t.timer),t.note.remove(),dn.delete(e))}function ec(){for(let e of Array.from(document.querySelectorAll(`[${Ut}]`)))e.remove();for(let e of dn.values())e.timer!==null&&clearTimeout(e.timer),e.note.remove();dn.clear()}function zh(e){let t=Array.from(e.querySelectorAll(qh));return t.length===0?null:t[t.length-1]}function $h(){let e=document.createElement("button");return e.className=Bh,e.setAttribute("type","button"),e.setAttribute(Ut,""),e.addEventListener("click",()=>{let t=e.getAttribute(Ut)??"";if(t.length===0)return;let n=tc.get(e);n!==void 0&&(Yl(t),Vh(t,n))}),e}async function Vh(e,t){if(t.onRequest===void 0)return;Xl(e,{phase:"working",count:0,missed:0,detail:""},t,0);let n;try{n=await t.onRequest(e)}catch(o){n={held:0,unsuggested:0,failed:String(o)}}if(n===void 0){ts(e);return}let r=jh(n);r!==null&&Xl(e,r,t,Uh)}function Xl(e,t,n,r){let o=dn.get(e);o!==void 0&&!o.note.isConnected&&(o.timer!==null&&clearTimeout(o.timer),dn.delete(e),o=void 0),o!==void 0&&o.timer!==null&&clearTimeout(o.timer);let i=o?.note??Yh();i.setAttribute(Gh,t.phase);let a=i.querySelector(`.${Ql}`),s=i.querySelector(`.${Zl}`),d=Jh(t,n);a.textContent!==d.text&&(a.textContent=d.text),s.textContent!==d.detail&&(s.textContent=d.detail),yt(s,d.detail.length===0),o===void 0&&document.body.append(i);let l=r>0?setTimeout(()=>{ts(e)},r):null;i.style.setProperty("--bre-note-hold",`${r}ms`),dn.set(e,{note:i,timer:l})}function Yh(){let e=document.createElement("div");return e.className=Wh,e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.innerHTML=`<span class="${Ql}"></span><span class="${Zl}"></span>`,e}var tc=new WeakMap,dn=new Map;function Jh(e,t){switch(e.phase){case"working":return{text:t.t("autoAdaptWorking"),detail:""};case"done":return{text:t.t("autoAdaptDone",{count:e.count}),detail:e.missed>0?`${t.t("autoAdaptDoneHint",{count:e.count})} ${t.t("autoAdaptUnsuggestedHint")}`:t.t("autoAdaptDoneHint",{count:e.count})};case"empty":return{text:t.t("autoAdaptEmpty"),detail:t.t("autoAdaptEmptyHint")};case"unsuggested":return{text:t.t("autoAdaptUnsuggested"),detail:t.t("autoAdaptUnsuggestedHint")};case"blocked":return{text:t.t("autoAdaptBlocked"),detail:t.t("autoAdaptBlockedHint")};case"failed":return{text:t.t("autoAdaptFailed",{message:e.detail}),detail:e.detail}}}function Xh(e,t,n){e.getAttribute(Ut)!==t&&e.setAttribute(Ut,t),e.textContent!==n&&(e.textContent=n),e.getAttribute("title")!==null&&e.removeAttribute("title")}var Hr="data-bre-drag-handle",ns="data-bre-row-head",rs="data-bre-drop-side",Ko="bre-row-dragging",qo="bre-row-drop-target",sc="bre-drag-ghost",dc="bre-drop-line",nc="http://www.w3.org/2000/svg",rc=8,oc=28,ic=12,Qh="transform 180ms cubic-bezier(0.2, 0.7, 0.3, 1)",Zh='button, a, input, textarea, select, [contenteditable], [role="button"], [role="switch"], [role="checkbox"], [role="textbox"], [role="combobox"]';function Bo(){return{sources:new WeakSet,lists:new WeakSet,line:void 0,sighted:new WeakMap,drag:void 0}}function Ve(e){return Array.from(e.children).filter(t=>t instanceof HTMLElement)}function eb(e,t){let n=e.style.order;if(n==="")return t;let r=Number.parseInt(n,10);return Number.isNaN(r)?t:r}function ln(e){return Ve(e).map((t,n)=>({row:t,key:eb(t,n),index:n})).sort((t,n)=>t.key-n.key||t.index-n.index).map(t=>t.row)}function lc(e,t){let n=e.filter(a=>t.includes(a)),r=n.map(a=>e.indexOf(a)),o=t.filter(a=>n.includes(a)),i=new Map;e.forEach((a,s)=>i.set(a,s)),r.forEach((a,s)=>{let d=o[s];d!==void 0&&i.set(d,a)});for(let[a,s]of i){let d=String(s);a.style.order!==d&&(a.style.order=d)}}function Wo(e,t){lc(ln(e),t)}function os(e,t){let n=Ve(e),r=n.map(o=>o.offsetTop);t(),n.forEach((o,i)=>{let a=r[i]-o.offsetTop;a!==0&&(o.style.transition="none",o.style.transform=`translateY(${a}px)`,o.offsetHeight,o.style.transition=Qh,o.style.transform="")})}function Nr(e,t){return ln(e).map(n=>t(n)).filter(n=>n!==void 0)}function tb(e,t,n){let r=Nr(e,t);if(n===void 0||!nb(e,n))return r;let o=new Map;return n.ids.forEach((i,a)=>{o.has(i)||o.set(i,a)}),r.map((i,a)=>({id:i,key:o.get(i)??n.ids.length+a})).sort((i,a)=>i.key-a.key).map(i=>i.id)}function nb(e,t){return t.rows.some(n=>!e.contains(n))}function rb(e,t){let n=[];for(let o of ln(e)){let i=t(o);i!==void 0&&n.push(i)}let r=[];for(let o of Ve(e))t(o)!==void 0&&r.push(o);return{ids:n,rows:r}}function cc(e,t,n){let r=new Map;for(let[s,d]of t.entries())r.has(d)||r.set(d,s);let o=Ve(e),a=[...o.filter(s=>n(s)!==void 0)].sort((s,d)=>{let l=r.get(n(s))??Number.MAX_SAFE_INTEGER,c=r.get(n(d))??Number.MAX_SAFE_INTEGER;return l-c});lc(o,a)}function Or(e){for(let t of e)t.style.order="",t.style.transition="",t.style.transform=""}function uc(e,t,n,r){let i=e.filter(a=>a!==t).indexOf(n);return i<0?Math.max(0,e.indexOf(t)):r?i+1:i}function fc(e,t){let n,r=Number.POSITIVE_INFINITY;for(let o of e){let i=o.getBoundingClientRect(),a=t<i.top?i.top-t:t>i.bottom?t-i.bottom:0;a<r&&(r=a,n=o)}return n}function ob(e,t){let n=e.getBoundingClientRect();return n.height<=0?!0:t>n.top+n.height/2}function pc(e,t){let n=e.getBoundingClientRect();return t?n.bottom+rc/2-1:n.top-rc/2-1}function mc(){let e=document.createElementNS(nc,"svg");e.setAttribute("width","10"),e.setAttribute("height","14"),e.setAttribute("viewBox","0 0 10 14"),e.setAttribute("fill","none"),e.setAttribute("aria-hidden","true");let t=[[2.5,3],[7.5,3],[2.5,7],[7.5,7],[2.5,11],[7.5,11]];for(let[n,r]of t){let o=document.createElementNS(nc,"circle");o.setAttribute("cx",String(n)),o.setAttribute("cy",String(r)),o.setAttribute("r","1.2"),o.setAttribute("fill","currentColor"),e.appendChild(o)}return e}function gc(e,t){let n=document.createElement("div");n.className=sc,n.setAttribute("aria-hidden","true"),n.appendChild(mc());let r=document.createElement("span");r.className="bre-drag-ghost-name";let o=t??e.querySelector('[class*="rowName"]')?.textContent?.trim();return r.textContent=o===void 0?"":o,n.appendChild(r),n}function ib(e){return!(e instanceof Element)||e.closest(`[${Hr}]`)!==null?!1:e.closest(Zh)!==null}function hc(e){return e.parentElement??void 0}function bc(e){for(let t of Ve(e))t.classList.remove(qo),t.removeAttribute(rs)}function Go(e){let t=e.parentElement;for(;t!==null;){if(wc(t))return t;t=t.parentElement}let n=document.scrollingElement;return n instanceof HTMLElement&&n.scrollHeight>n.clientHeight?n:void 0}function yc(e){let t=[],n=e.parentElement;for(;n!==null;)wc(n)&&t.push(n),n=n.parentElement;let r=document.scrollingElement;return r instanceof HTMLElement&&r.scrollHeight>r.clientHeight&&!t.includes(r)&&t.push(r),t}function is(e){let t=[],n=e.parentElement;for(;n!==null;)vc(n)&&t.push(n),n=n.parentElement;let r=document.scrollingElement;return r instanceof HTMLElement&&!t.includes(r)&&t.push(r),t}function vc(e){let t=e.style.overflowY,n=t.length>0?t:window.getComputedStyle(e).overflowY;return n==="auto"||n==="scroll"||n==="overlay"}function wc(e){return e.scrollHeight>e.clientHeight&&vc(e)}function xc(e,t){let n=e.getBoundingClientRect();return n.height<=0?0:t<n.top+oc?-ic:t>n.bottom-oc?ic:0}function kc(e,t,n){if(t.scrollStep===n)return;if(t.scrollStep=n,n===0){t.frame!==void 0&&(window.cancelAnimationFrame(t.frame),t.frame=void 0);return}let r=t.scroller;if(r===void 0||t.frame!==void 0)return;let o=()=>{t.frame=void 0,!(e.drag!==t||t.scrollStep===0)&&(r.scrollTop+=t.scrollStep,t.frame=window.requestAnimationFrame(o))};t.frame=window.requestAnimationFrame(o)}function ab(e){let t=e.line;if(t!==void 0&&t.isConnected)return t;let n=document.createElement("div");return n.className=dc,n.setAttribute("aria-hidden","true"),document.body.appendChild(n),e.line=n,n}function sb(e,t,n){let r=ab(e),o=t.getBoundingClientRect();r.style.top=`${pc(t,n)}px`,r.style.left=`${o.left}px`,r.style.width=`${o.width}px`,r.style.display="block",r.setAttribute(rs,n?"after":"before")}function db(e){e.line!==void 0&&(e.line.style.display="none")}function lb(e){let t=e.drag;e.drag=void 0,t!==void 0&&(kc(e,t,0),db(e),t.row.classList.remove(Ko),bc(t.list),t.dropped||os(t.list,()=>{Wo(t.list,t.before)}))}function cb(e,t,n,r){if(ib(t.target)){t.preventDefault();return}let o=hc(e),i=n.idOf(e);if(o===void 0||i===void 0){t.preventDefault();return}let a={row:e,list:o,before:ln(o),scroller:Go(o),adapter:n,scrollStep:0,frame:void 0,dropped:!1};r.drag=a,e.classList.add(Ko);let s=gc(e,n.labelOf(e));Number.isFinite(t.clientX)&&Number.isFinite(t.clientY)&&(s.style.left=`${t.clientX}px`,s.style.top=`${t.clientY}px`),document.body.appendChild(s);let d=t.dataTransfer;if(d!=null)try{d.effectAllowed="move",d.setData("text/plain",i),d.setDragImage(s,Math.round(s.offsetWidth/2),Math.round(s.offsetHeight/2))}catch{}window.setTimeout(()=>{s.remove()},0)}function ub(e,t,n){let r=n.drag;if(r===void 0||r.list!==e)return;let o=t.target,i=o instanceof Element?r.adapter.rowOf(o,e):void 0,a=ln(e),s=i!==void 0&&a.includes(i)?i:fc(a,t.clientY);if(s===void 0)return;t.preventDefault();let d=t.dataTransfer;d!=null&&(d.dropEffect="move");let l=ob(s,t.clientY),c=uc(a,r.row,s,l);c!==a.indexOf(r.row)&&os(e,()=>{Wo(e,ca(a,r.row,c))}),bc(e),s.classList.add(qo),s.setAttribute(rs,l?"after":"before"),sb(n,s,l),kc(n,r,r.scroller===void 0?0:xc(r.scroller,t.clientY))}function fb(e,t){t.lists.has(e)||(t.lists.add(e),e.addEventListener("dragover",n=>{ub(e,n,t)}),e.addEventListener("drop",n=>{let r=t.drag;r===void 0||r.list!==e||(n.preventDefault(),r.dropped=!0,r.adapter.commit(e))}))}function pb(e,t,n,r){r.sources.has(e)||(r.sources.add(e),n.seatDrags&&(e.setAttribute(ns,"1"),e.setAttribute("draggable","true")),e.addEventListener("dragstart",o=>{cb(t,o,n,r)}),e.addEventListener("dragend",()=>{lb(r)}))}function mb(e,t,n,r){e.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation()}),e.addEventListener("keydown",o=>{if(o.key!=="ArrowUp"&&o.key!=="ArrowDown")return;let i=hc(t);if(i===void 0)return;let a=ln(i),s=a.indexOf(t);if(s<0)return;let d=s+(o.key==="ArrowUp"?-1:1);d<0||d>=a.length||(o.preventDefault(),os(i,()=>{Wo(i,ca(a,t,d))}),n.commit(i),e.focus())})}function ac(e,t,n,r){let o=r.gripLabel(t,n),i=r.gripHint();e.getAttribute(Hr)!==n&&e.setAttribute(Hr,n),e.getAttribute("aria-label")!==o&&e.setAttribute("aria-label",o),e.getAttribute("title")!==i&&e.setAttribute("title",i)}function gb(e,t,n,r,o){let i=t.querySelector(`[${Hr}]`);if(i!==null){ac(i,e,n,r);return}r.decorate?.(e,t);let a=document.createElement("span");a.className="bre-drag-grip",a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.setAttribute("draggable","true"),a.appendChild(mc()),ac(a,e,n,r),mb(a,e,r,o),pb(r.seatDrags?t:a,e,r,o),t.insertBefore(a,t.firstChild)}function Uo(e,t,n,r){if(!e.isConnected)return;fb(t,r);for(let i of Ve(t)){let a=n.idOf(i);if(a===void 0)continue;let s=n.seatOf(i);s!==void 0&&gb(i,s,a,n,r)}if(r.drag!==void 0)return;let o=tb(t,n.idOf,r.sighted.get(t));cc(t,n.order(o),n.idOf),r.sighted.set(t,rb(t,n.idOf))}function jo(e){e.drag=void 0;for(let t of Array.from(document.querySelectorAll(`[${Hr}]`)))t.remove();for(let t of Array.from(document.querySelectorAll(`[${ns}]`)))t.removeAttribute(ns),t.removeAttribute("draggable");for(let t of Array.from(document.querySelectorAll(`.${Ko}, .${qo}`)))t.classList.remove(Ko,qo);for(let t of Array.from(document.querySelectorAll(`.${dc}`)))t.remove();for(let t of Array.from(document.querySelectorAll(`.${sc}`)))t.remove();e.line=void 0}var Ec=["openai","anthropic"];function zo(e){return e==="anthropic-messages"?"anthropic":"openai"}function Tc(e){return e==="openai-completions"||e==="anthropic-messages"||e==="openai-responses"}var hb=40;function Sc(e){if(typeof e!="string")return;let t="";for(let n of e){let r=n.codePointAt(0)??0;r<32||r===127||(t+=n)}if(t=t.trim(),t.length!==0)return t.slice(0,hb)}function Rt(e){return typeof e=="string"&&/^[\x21-\x7E]+$/.test(e)}var bb=12;function Mc(e){return e.length===0?"":e.length<bb?"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022":`${e.slice(0,4)}...${e.slice(-4)}`}var Lc="dsh-model-think-level:key-lists:v1";function Ac(){try{return globalThis.localStorage??void 0}catch{return}}function $o(){let e=Ac();if(e===void 0)return{};try{let t=e.getItem(Lc);if(t===null)return{};let n=JSON.parse(t);if(typeof n!="object"||n===null)return{};let r={};for(let[o,i]of Object.entries(n))yb(i)&&(r[o]=i);return r}catch{return{}}}function yb(e){if(typeof e!="object"||e===null)return!1;let t=e;if(typeof t.savedAt!="number"||!Number.isFinite(t.savedAt))return!1;let n=t.state;if(typeof n!="object"||n===null)return!1;let r=n;return r.ok===!0&&typeof r.route=="string"&&Array.isArray(r.entries)}function Cc(e){let t=Ac();if(t===void 0)return;let n=Object.entries(e).sort((r,o)=>o[1].savedAt-r[1].savedAt).slice(0,64);try{t.setItem(Lc,JSON.stringify(Object.fromEntries(n)))}catch{}}function Rc(e){let t=$o()[e];if(t===void 0||t.state.route!==e)return;let n=Date.now()-t.savedAt;if(!(n>=0)||n>2592e6){vb(e);return}return t.state}function as(e,t){if(t.ok!==!0||t.route!==e)return;let n=$o();n[e]={savedAt:Date.now(),state:{...t,probing:void 0,addedRef:void 0}},Cc(n)}function vb(e){let t=$o();t[e]!==void 0&&(delete t[e],Cc(t))}function Hc(){return Object.entries($o()).map(([e,t])=>({route:e,savedAt:t.savedAt})).sort((e,t)=>t.savedAt-e.savedAt)}function Nc(e){for(let t of["error","message"]){let n=e[t];if(typeof n=="string"&&n.length>0)return n}}function Oc(e){if(!Array.isArray(e))return;let t=[];for(let n of e)typeof n=="string"&&n.length>0&&t.push(n);return t}function wb(e){if(!V(e))return;let t=e.ref;if(typeof t!="string"||t.length===0)return;let n=e.alias,r=e.configured,o=e.masked,i=Oc(e.models),a=e.protocol,s=e.auto,d=e.rest,l=V(d)&&typeof d.remainingMs=="number"?d.remainingMs:void 0,c=V(d)&&typeof d.failures=="number"?d.failures:void 0;return{ref:t,...typeof n=="string"&&n.length>0?{alias:n}:{},enabled:e.enabled!==!1,configured:typeof r=="boolean"?r:null,...typeof o=="string"&&o.length>0?{masked:o}:{},...i===void 0?{}:{models:i},...Tc(a)?{protocol:a}:{},...s===!0?{auto:!0}:{},...l!==void 0&&l>=0&&c!==void 0?{rest:{remainingMs:l,failures:c}}:{}}}function xb(e){let t=e.entries;if(!Array.isArray(t))return;let n=[];for(let l of t){let c=wb(l);c!==void 0&&n.push(c)}let r=e.addedRef,o=e.route,i=Oc(e.models),a=e.endpoints,s=V(a)&&typeof a.openai=="string"?a.openai:null,d=V(a)&&typeof a.anthropic=="string"?a.anthropic:null;return{ok:!0,route:typeof o=="string"?o:"",entries:n,...typeof r=="string"&&n.some(l=>l.ref===r)?{addedRef:r}:{},...i===void 0?{}:{models:i},...e.probing===!0?{probing:!0}:{},endpoints:{openai:s,anthropic:d}}}async function kb(e){let t;try{t=await e.json()}catch{t=void 0}if(!V(t))return{ok:!1};if(t.ok===!0){let r=xb(t);if(r!==void 0)return r}let n=Nc(t);return n===void 0?{ok:!1}:{ok:!1,error:n}}async function Ic(e,t){let n=`${mo}?route=${encodeURIComponent(e)}`;try{let r=await fetch(n,t===void 0?{method:"GET",cache:"no-store",credentials:"same-origin"}:{method:"POST",cache:"no-store",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify(t)});return await kb(r)}catch{return{ok:!1}}}var Ir=new Map,Eb=64,Tb=5e3;function ss(e){let t=Ir.get(e);if(t!==void 0)return t;if(Ir.size>=Eb){let r=Ir.keys().next().value;r!==void 0&&Ir.delete(r)}let n={state:Rc(e),updatedAt:0,revision:0};return Ir.set(e,n),n}function Sb(e){return ss(e).state}function Mb(e,t){let n=ss(e),r=Date.now()-n.updatedAt;if(t?.preferCache===!0&&n.state!==void 0&&r>=0&&r<Tb)return Promise.resolve(n.state);if(n.read!==void 0)return n.read;let o=n.revision,i=Ic(e).then(a=>n.revision!==o?n.state??a:(a.ok&&(n.state=a,n.updatedAt=Date.now(),as(e,a)),a)).finally(()=>{n.read===i&&(n.read=void 0)});return n.read=i,i}async function Et(e,t){let n=ss(e),r=++n.revision;n.read=void 0;let o=await Ic(e,t);return o.ok&&n.revision===r&&(n.revision+=1,n.read=void 0,n.state=o,n.updatedAt=Date.now(),as(e,o)),o}async function Lb(e){try{let t=await fetch(`${mo}?route=${encodeURIComponent(e)}&op=endpoints`,{method:"GET",cache:"no-store",credentials:"same-origin"});if(!t.ok)return{ok:!1};let n=await t.json().catch(()=>{});if(!V(n)||n.ok!==!0)return{ok:!1};let r=n.endpoints;return V(r)?{ok:!0,endpoints:{openai:typeof r.openai=="string"?r.openai:null,anthropic:typeof r.anthropic=="string"?r.anthropic:null}}:{ok:!0}}catch{return{ok:!1}}}async function Ab(e){try{let n=await(await fetch(`${mo}?route=${encodeURIComponent(e)}&op=balance`,{method:"GET",cache:"no-store",credentials:"same-origin"})).json().catch(()=>{});if(!V(n)||n.ok!==!0){let o=V(n)?Nc(n):void 0;return o===void 0?{ok:!1}:{ok:!1,error:o}}let r=n.endpoint;return{ok:!0,endpoint:typeof r=="string"&&r.length>0?r:null}}catch{return{ok:!1}}}var Ge={list:Mb,endpoints:Lb,balanceEndpoint:Ab,cached:Sb,add:(e,t,n)=>Et(e,{op:"add",value:t,...n===void 0?{}:{alias:n}}),rename:(e,t,n)=>Et(e,{op:"rename",ref:t,...n===void 0?{}:{alias:n}}),remove:(e,t)=>Et(e,{op:"remove",ref:t}),replace:(e,t,n)=>Et(e,{op:"value",ref:t,value:n}),setScope:(e,t,n)=>Et(e,{op:"scope",ref:t,...n===void 0?{}:{models:n}}),setEnabled:(e,t,n)=>Et(e,{op:"enable",ref:t,enabled:n}),setProtocol:(e,t,n)=>Et(e,{op:"protocol",ref:t,...n===void 0?{}:{protocol:n}}),setEndpoints:(e,t,n)=>Et(e,{op:"endpoints",openai:t??"",anthropic:n??""}),setBalanceEndpoint:(e,t)=>Et(e,{op:"balance",endpoint:t}),probe:e=>Et(e,{op:"probe"}),async reveal(e,t){try{let n=await fetch(`${po}?route=${encodeURIComponent(e)}&ref=${encodeURIComponent(t)}`,{method:"GET",cache:"no-store",credentials:"same-origin"});if(!n.ok)return;let r=await n.json();if(!V(r)||r.ok!==!0)return;let o=r.key;return typeof o=="string"&&o.length>0?o:void 0}catch{return}}};var Bn="data-bre-endpoint-rows",Ht="data-bre-endpoint-row",zn="data-bre-balance-row",Yo="data-bre-endpoint-family",Dc="data-bre-endpoint-filled",Jo="data-bre-endpoint-field",Xo="data-bre-endpoint-title",Gn="data-bre-endpoint-toggle",qc="data-bre-endpoint-count",Qo="data-bre-field-order",Dr="data-bre-endpoint-serving",Pc="data-bre-protocol-watch",_c=new WeakSet,Fc="data-bre-row-provider",ls="data-bre-protocol-cards",Un="data-bre-protocol-value",cs="data-bre-protocol-source";function dt(e,t){for(let n of t){let r=Array.from(e.querySelectorAll("input[aria-label], select[aria-label]")).find(o=>(o.getAttribute("aria-label")??"").startsWith(n));if(r!==void 0)return r}}function jn(e,t){let n=dt(e,t);if(n===void 0)return;let r=n.closest("label");return r!==null&&r.parentElement!==null?r:n.parentElement??void 0}function ds(e,t){let n=e;for(;n!==null&&n.parentElement!==t;)n=n.parentElement;return n===null||n===t?void 0:n}function Cb(e,t,n){for(let r=t.parentElement;r!==null;r=r.parentElement){if(!r.contains(n)||e!==void 0&&!r.contains(e))continue;let o=ds(t,r),i=ds(n,r);if(o===void 0||i===void 0||o===i)continue;let a=e===void 0?void 0:ds(e,r);return{container:r,protocol:o,url:i,name:a}}}function Bc(e,t){let n=dt(e,t);return n instanceof HTMLSelectElement||n instanceof HTMLInputElement?n.value.trim():""}function Rb(e,t){let n=Bc(e,t.apiProtocol);return n==="anthropic-messages"||n==="openai-completions"||n==="openai-responses"?n:void 0}function Tt(e,t){let n=Rb(e,t);return n===void 0?void 0:zo(n)}function un(e,t){let n=Bc(e,t.routeId);return n.length>0?n:(e.closest(`[${Fc}]`)?.getAttribute(Fc)??"").trim()}function Wc(e,t){return e==="anthropic"?t("keysEndpointAnthropic"):e==="openai"?t("keysEndpointOpenAI"):""}function Hb(e,t){let n=dt(e,t.modelName),r=dt(e,t.apiProtocol),o=dt(e,t.baseUrl);if(r===void 0||o===void 0)return;let i=Cb(n,r,o);if(i===void 0)return;let{container:a,protocol:s,url:d,name:l}=i,c=h=>Array.from(a.children).indexOf(h);if((l===void 0||c(l)<c(s))&&c(s)<c(d)){e.setAttribute(Qo,"1");return}a.insertBefore(s,d),l!==void 0&&a.insertBefore(l,s),e.setAttribute(Qo,"1")}function Gc(e,t){for(let n of Array.from(e.children))if(!(n===t||n.contains(t))&&!n.hasAttribute(Yo)&&!n.hasAttribute(Gn)&&n instanceof HTMLElement&&(n.textContent??"").trim().length>0)return n}function cn(e,t){let n=t?"1":"0";e.getAttribute(Dc)!==n&&e.setAttribute(Dc,n)}function Nb(e,t,n){let r=Gc(e,t);if(!n){e.removeAttribute(Jo),r?.removeAttribute(Xo);return}e.setAttribute(Jo,"1"),r?.setAttribute(Xo,"1")}function Uc(e,t,n){let r=dt(e,t.baseUrl);if(r===void 0)return;let o=jn(e,t.baseUrl);if(o===void 0)return;let i=Wc(Tt(e,t),n),a=o.querySelector(`[${Yo}]`);if(a===null&&i.length>0){a=document.createElement("span"),a.setAttribute(Yo,"1"),a.className="bre-endpoint-family";let d=r.closest("label");d!==null&&d.contains(r)?d.insertBefore(a,r):o.insertBefore(a,r)}a!==null&&(a.textContent!==i&&(a.textContent=i),yt(a,i.length===0),cn(a,r instanceof HTMLInputElement&&r.value.trim().length>0)),Nb(o,r,a!==null&&i.length>0);let s=Tt(e,t);s===void 0?o.removeAttribute(Dr):o.setAttribute(Dr,s)}function Ob(e,t){let n=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;n===void 0?e.value=t:n.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}function jc(e,t){for(let n of Array.from(t.querySelectorAll(`[${Un}]`))){let r=n.getAttribute(Un)===e.value;n.classList.toggle("is-selected",r),n.setAttribute("aria-checked",r?"true":"false"),n.tabIndex=r?0:-1}}function Ib(e,t,n){let r=Array.from(t.querySelectorAll(`[${Un}]`)),o=Array.from(e.options).filter(i=>i.value.length>0);return r.length!==o.length?!1:o.every((i,a)=>{let s=r[a];return s!==void 0&&s.getAttribute(Un)===i.value&&(s.textContent??"")===zc(i.value,(i.textContent??i.value).trim(),n.t)})}function zc(e,t,n){return e==="openai-completions"?n("keysProtocolShortChat"):e==="openai-responses"?n("keysProtocolShortResponses"):e==="anthropic-messages"?n("keysProtocolShortAnthropic"):t}function Kc(e,t,n){t.replaceChildren();for(let r of Array.from(e.options)){let o=r.value;if(o.length===0)continue;let i=document.createElement("button");i.type="button",i.className="bre-protocol-card",i.setAttribute("role","radio"),i.setAttribute(Un,o),i.textContent=zc(o,(r.textContent??o).trim(),n.t),i.title=(r.textContent??o).trim(),i.addEventListener("click",()=>{e.value!==o&&(Ob(e,o),jc(e,t))}),t.appendChild(i)}}function Db(e,t,n){let r=dt(e,t.apiProtocol);if(!(r instanceof HTMLSelectElement))return;let o=jn(e,t.apiProtocol);if(o===void 0)return;let i=o.querySelector(`[${ls}]`);if(i===null){let a=document.createElement("div");i=a,a.setAttribute(ls,"1"),a.className="bre-protocol-cards",a.setAttribute("role","radiogroup");let s=r.getAttribute("aria-label");s!==null&&a.setAttribute("aria-label",s),r.setAttribute(cs,"1"),r.after(a),Kc(r,a,n),a.addEventListener("keydown",d=>{let l=d.key==="ArrowRight"||d.key==="ArrowDown"?1:d.key==="ArrowLeft"||d.key==="ArrowUp"?-1:0,c=Array.from(a.querySelectorAll(`[${Un}]`));if(c.length===0)return;if(d.key==="Home"||d.key==="End"){d.preventDefault();let p=d.key==="Home"?c[0]:c[c.length-1];p?.click(),p?.focus();return}if(l===0)return;d.preventDefault();let f=c.findIndex(p=>p.classList.contains("is-selected")),h=c[(Math.max(f,0)+l+c.length)%c.length];h?.click(),h?.focus()})}else Ib(r,i,n)||Kc(r,i,n);yt(r,!0),jc(r,i)}function us(e,t,n){let r=e===null?0:e.querySelectorAll(`[${Ht}], [${zn}]`).length,o=r===0?"":n.t("keysEndpointsCount",{count:r});if(o.length===0){t.hasAttribute("title")&&t.removeAttribute("title");return}t.getAttribute("title")!==o&&t.setAttribute("title",o)}function Pb(e,t,n){let r=e.querySelector(`[${Gn}]`);if(jn(e,t.apiProtocol)===void 0){r?.remove(),e.querySelector(`[${qc}]`)?.remove();return}let o=jn(e,t.baseUrl);if(o===void 0)return;let i=dt(e,t.baseUrl);if(i===void 0)return;let a=Gc(o,i);if(a===void 0||a===r)return;let s=()=>e.querySelector(`[${Bn}]`),d=c=>{let f=n.t("keysMoreEndpoints");c.textContent!==f&&(c.textContent=f);let h=s();c.setAttribute("aria-expanded",h!==null&&!h.hidden?"true":"false"),us(h,c,n)};if(r!==null){r.parentElement!==a&&a.append(r),d(r);return}let l=document.createElement("button");l.type="button",l.setAttribute(Gn,"1"),l.className="bre-endpoint-toggle",l.textContent=n.t("keysMoreEndpoints"),l.addEventListener("click",()=>{let c=s();if(c!==null&&(c.hidden=!c.hidden,d(l),!c.hidden)){let f=un(e,t);f.length>0&&Kb(c,f,n,e,t)}}),a.append(l),d(l)}var Wn=new WeakMap,$c=1e3,Zo=new WeakMap,$n=0,Vo=new Map;function _b(e,t){$n+=1,typeof CustomEvent=="function"&&document.dispatchEvent(new CustomEvent(kr,{detail:{route:e,openai:t.openai??"",anthropic:t.anthropic??""}}))}function Fb(e,t){$n+=1,typeof CustomEvent=="function"&&document.dispatchEvent(new CustomEvent(Tr,{detail:{route:e,endpoint:t}}))}function Pr(e){let t=e.getAttribute(Ht);return t==="openai"||t==="anthropic"?t:void 0}async function Kb(e,t,n,r,o){for(let i of Array.from(e.querySelectorAll(`[${Ht}], [${zn}]`)))await Vc(i,t,n,r,o)}async function Vc(e,t,n,r,o){let i=e.querySelector(".bre-endpoint-url");if(i===null)return;if(e.hasAttribute(zn)){await Yc(e,i,t,n);return}let a=Pr(e);if(a===void 0)return;let s=(Wn.get(e)??0)+1;Wn.set(e,s),Zo.set(e,{at:Date.now(),epoch:$n});let d=n.client??Ge,l=await ei(t,d);if(l===void 0||Wn.get(e)!==s||Pr(e)!==a||document.activeElement===i)return;await Jc(r,o,n,t,Tt(r,o),l);let c=l[a];i.value!==c&&(i.value=c);let f=e.querySelector(".bre-endpoint-family");f!==null&&cn(f,c.length>0)}async function Yc(e,t,n,r){let o=(Wn.get(e)??0)+1;Wn.set(e,o),Zo.set(e,{at:Date.now(),epoch:$n});let i=r.client??Ge;if(i.balanceEndpoint===void 0)return;let a=await i.balanceEndpoint(n);if(!a.ok||Wn.get(e)!==o||document.activeElement===t)return;let s=a.endpoint??"";t.value!==s&&(t.value=s);let d=e.querySelector(".bre-endpoint-family");d!==null&&cn(d,s.length>0)}async function Jc(e,t,n,r,o,i,a=!1){if(o===void 0||!a&&i[o].length>0)return;let s=dt(e,t.baseUrl);if(!(s instanceof HTMLInputElement)||document.activeElement===s)return;let d=s.value.trim();if(d.length===0&&!a)return;let l=n.client??Ge;await ps(r,l,c=>{if(!(!a&&c[o].length>0)&&c[o]!==d)return{openai:o==="openai"?d:c.openai,anthropic:o==="anthropic"?d:c.anthropic}})}function fs(e,t,n){let r=jn(e,t.baseUrl);if(r===void 0||r.parentElement===null)return;let o=Tt(e,t);if(o===void 0)return;let i=r.querySelector(`:scope > [${Bn}]`);i===null&&(i=e.querySelector(`[${Bn}]`),i!==null&&r.appendChild(i)),i===null&&(i=document.createElement("div"),i.setAttribute(Bn,"1"),i.hidden=!0,r.appendChild(i));let a=Ec.filter(f=>f!==o),s=Array.from(i.children).filter(f=>f instanceof HTMLElement&&f.hasAttribute(Ht));if(!(a.length===s.length&&a.every((f,h)=>Pr(s[h])===f)))for(let f of a){let h=i.querySelector(`[${Ht}="${f}"]`);h===null&&(h=qb(e,t,n,f)),i.appendChild(h)}for(let f of Array.from(i.querySelectorAll(`[${Ht}]`))){let h=Pr(f);h!==void 0&&h!==o||f.remove()}let l=e.querySelector(`[${Gn}]`);l!==null&&(l.setAttribute("aria-expanded",i.hidden?"false":"true"),us(i,l,n));let c=un(e,t);if(c.length>0)for(let f of Array.from(i.querySelectorAll(`[${Ht}]`))){let h=Zo.get(f);(h===void 0||h.epoch!==$n||Date.now()-h.at>=$c)&&Vc(f,c,n,e,t)}}function qb(e,t,n,r){let o=document.createElement("div");o.setAttribute(Ht,r),o.className="bre-endpoint-row";let i=document.createElement("span");i.className="bre-endpoint-family",i.textContent=Wc(r,n.t),cn(i,!1);let a=document.createElement("input");a.type="url",a.className="bre-text-input bre-endpoint-url",a.spellcheck=!1,a.placeholder="https://\u2026";let s=n.client??Ge;return a.addEventListener("change",()=>{let d=un(e,t);if(d.length===0)return;let l=a.value.trim();if(l.length>0&&!/^https?:\/\//i.test(l)){a.setAttribute("aria-invalid","true"),a.title=n.t("keysEndpointInvalid");return}a.hasAttribute("aria-invalid")&&a.removeAttribute("aria-invalid"),a.hasAttribute("title")&&a.removeAttribute("title"),cn(i,l.length>0),(async()=>await ps(d,s,c=>{let f=Pr(o);if(f!==void 0)return{openai:f==="openai"?l:c.openai,anthropic:f==="anthropic"?l:c.anthropic}}))()}),o.append(i,a),o}function Xc(e,t,n){let r=e.querySelector(`[${Bn}]`),o=e.querySelector(`[${zn}]`),i=un(e,t);if(r===null||i.length===0){o?.remove();return}let a=o;a===null&&(a=Bb(e,t,n)),r.lastElementChild!==a&&r.appendChild(a);let s=e.querySelector(`[${Gn}]`);s!==null&&us(r,s,n);let d=Zo.get(a);if(d===void 0||d.epoch!==$n||Date.now()-d.at>=$c){let l=a.querySelector(".bre-endpoint-url");l!==null&&Yc(a,l,i,n)}}function Bb(e,t,n){let r=document.createElement("div");r.setAttribute(zn,"1"),r.className="bre-endpoint-row bre-balance-row";let o=document.createElement("span");o.className="bre-endpoint-family",o.textContent=n.t("keysEndpointBalance"),cn(o,!1);let i=document.createElement("input");i.type="url",i.className="bre-text-input bre-endpoint-url",i.spellcheck=!1,i.placeholder="https://\u2026",i.setAttribute("aria-label",n.t("keysEndpointBalance")),i.title=n.t("keysEndpointBalanceHint");let a=n.client??Ge,s=a.setBalanceEndpoint;return i.addEventListener("change",()=>{let d=un(e,t);if(d.length===0)return;let l=i.value.trim();if(l.length>0&&!/^https?:\/\//i.test(l)){i.setAttribute("aria-invalid","true"),i.title=n.t("keysEndpointInvalid");return}i.hasAttribute("aria-invalid")&&i.removeAttribute("aria-invalid"),i.title=n.t("keysEndpointBalanceHint"),cn(o,l.length>0),s!==void 0&&(async()=>(await s.call(a,d,l)).ok&&Fb(d,l))()}),r.append(o,i),r}async function Wb(e,t,n,r,o){let i=un(e,t),a=dt(e,t.baseUrl);if(i.length===0||!(a instanceof HTMLInputElement))return;let s=n.client??Ge,d=await ei(i,s);if(d===void 0||Tt(e,t)!==o)return;let l=a.value.trim();if(l.length>0&&l!==d[r]){let h=await ps(i,s,p=>{if(Tt(e,t)===o)return{openai:r==="openai"?l:p.openai,anthropic:r==="anthropic"?l:p.anthropic}});if(h===void 0||(d=h,Tt(e,t)!==o))return}let c=d[o];if(a.value===c)return;let f=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set;f===void 0?a.value=c:f.call(a,c),a.dispatchEvent(new Event("input",{bubbles:!0})),a.dispatchEvent(new Event("change",{bubbles:!0})),fs(e,t,n)}async function ps(e,t,n){let o=(Vo.get(e)??Promise.resolve()).then(async()=>{let i=await ei(e,t);if(i===void 0)return;let a=n(i);if(a===void 0)return;let s=t.setEndpoints;if(typeof s!="function")return;let d=await s.call(t,e,a.openai,a.anthropic);if(!d.ok)return;let l={openai:d.endpoints.openai??"",anthropic:d.endpoints.anthropic??""};return _b(e,d.endpoints),l});Vo.set(e,o);try{return await o}finally{Vo.get(e)===o&&Vo.delete(e)}}async function ei(e,t){if(t.endpoints!==void 0){let r=await t.endpoints(e);return r.ok?{openai:r.endpoints?.openai??"",anthropic:r.endpoints?.anthropic??""}:void 0}let n=await t.list(e);if(n.ok)return{openai:n.endpoints.openai??"",anthropic:n.endpoints.anthropic??""}}function Gb(e,t,n){let r=jn(e,t.baseUrl),o=Tt(e,t),i=r?.getAttribute(Dr);Uc(e,t,n.t),fs(e,t,n),Xc(e,t,n),!(r===void 0||i===void 0||o===void 0)&&i!==o&&(i!=="openai"&&i!=="anthropic"||Wb(e,t,n,i,o))}function Qc(e,t,n){Hb(e,t),Db(e,t,n),Uc(e,t,n.t),Pb(e,t,n),fs(e,t,n),Xc(e,t,n);let r=dt(e,t.apiProtocol);r instanceof HTMLSelectElement&&!r.hasAttribute(Pc)&&(r.setAttribute(Pc,"1"),r.addEventListener("change",()=>Gb(e,t,n)));let o=dt(e,t.baseUrl);o instanceof HTMLInputElement&&!_c.has(o)&&(_c.add(o),o.addEventListener("change",()=>{let i=un(e,t),a=Tt(e,t);if(i.length===0||a===void 0)return;let s=n.client??Ge;(async()=>{let d=await ei(i,s);d!==void 0&&Tt(e,t)===a&&await Jc(e,t,n,i,a,d,!0)})()}))}function Ub(){for(let e of Array.from(document.querySelectorAll(`select[${cs}]`)))e.hidden=!1,e.removeAttribute(cs)}function Zc(){Ub();for(let e of Array.from(document.querySelectorAll(`[${Bn}], [${Ht}], [${zn}], [${Gn}], [${qc}], [${ls}], [${Yo}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`[${Qo}], [${Jo}], [${Xo}], [${Dr}]`)))e.removeAttribute(Qo),e.removeAttribute(Jo),e.removeAttribute(Xo),e.removeAttribute(Dr)}function Vn(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var ms="__breLedgerDocument";function du(){let e=globalThis;return e[ms]??(e[ms]=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`)}var ri="bre:held-writes:v1";function ws(){try{return typeof sessionStorage>"u"?void 0:sessionStorage}catch{return}}function St(e){let t=ws();if(t!==void 0)try{if(e.pending.size===0&&e.queued.size===0){t.removeItem(ri);return}let n={document:du(),committed:[...e.committing].filter(r=>e.queued.has(r)),pending:[...e.pending].map(([r,o])=>[r,[...o]]),queued:[...e.queued].map(([r,o])=>[r,[...o]])};t.setItem(ri,JSON.stringify(n))}catch{}}function eu(e,t){if(!Array.isArray(e))return;let n=[];for(let r of e){if(!Array.isArray(r)||r.length!==2)return;let[o,i]=r;if(typeof o!="string"||!Array.isArray(i))return;let a=[];for(let s of i){if(!Array.isArray(s)||s.length!==2)return;let[d,l]=s;if(typeof d!="string"||!V(l)||t!==void 0&&!t(l))return;a.push([d,l])}n.push([o,a])}return n}function jb(e){let t=ws();if(t!==void 0)try{let n=t.getItem(ri);if(n===null)return;let r=JSON.parse(n);if(r.document!==du())return;let o=eu(r.pending),i=eu(r.queued,ey);if(o===void 0||i===void 0)return;let a=Array.isArray(r.committed)?r.committed.filter(s=>typeof s=="string"):[];for(let[s,d]of o)e.pending.set(s,new Map(d));for(let[s,d]of i)a.includes(s)&&(e.queued.set(s,new Map(d)),e.committing.add(s))}catch{}}function lu(e,t){(async()=>{try{await xs(t,e),await ks(t,e)}catch(n){console.error(`[bre] teardown flush failed: ${n instanceof Error?n.message:String(n)}`)}})()}function cu(e,t){(async()=>{try{await xs(t,e,!0),await ks(t,e,!0)}catch(n){console.error(`[bre] unload flush failed: ${n instanceof Error?n.message:String(n)}`)}finally{try{ws()?.removeItem(ri)}catch{}}})()}function uu(){let e={disposed:!1,mounted:new Map,describePromise:void 0,pending:new Map,missedScans:new Map,queued:new Map,editing:void 0,flushing:!1,flushFailures:0,nextFlushAt:0,committing:new Set,adapting:new Set,signalsUnavailable:!1,submitWired:new WeakSet,cancelWired:new WeakSet,disclosureWired:new WeakSet,editWired:new WeakSet,addModelWired:new WeakSet,addProviderWired:new WeakSet};return jb(e),e}async function zb(e,t,n=!1){if(t.flushing)return;t.flushing=!0;let r;try{r=n&&pu(t)?await le(e.api,{fresh:!0}):void 0;let o=await xs(e,t,!1,r),i=await ks(e,t,!1,r);o||i?tu(e,t):(t.flushFailures=0,t.nextFlushAt=0)}catch(o){tu(e,t),console.error(`[bre] idle flush failed: ${o instanceof Error?o.message:String(o)}`)}finally{t.flushing=!1}try{e.onIdle?.(r)}catch(o){console.error(`[bre] idle hook failed: ${o instanceof Error?o.message:String(o)}`)}}var fu=new Set(["no-namespace","invalid-models"]);function tu(e,t){t.flushFailures+=1;let n=Math.min(2**(t.flushFailures-1)*500,3e4);t.nextFlushAt=Date.now()+n,e.onBackoff?.(n)}function pu(e){return e.queued.size>0||e.pending.size>0}function Yn(e,t,n,r,o,i,a,s){try{let d=e.pending.get(t);if(r===void 0){if(d===void 0)return;d.delete(n),d.size===0&&e.pending.delete(t);return}e.pending.set(t,(d??new Map).set(n,{efforts:r,...o===void 0?{}:{compat:o},...i===void 0?{}:{input:i},...s===void 0?{}:{imageGen:s===!0},...a===void 0?{}:{defaultEffort:a}}))}finally{St(e)}}function mu(e,t,n,r){e.queued.set(t,(e.queued.get(t)??new Map).set(n,r)),St(e)}function $b(e,t,n){let r=e.pending.get(t);r!==void 0&&(r.delete(n),r.size===0&&e.pending.delete(t),St(e))}function Vb(e,t,n){let r=e.queued.get(t);r!==void 0&&(r.delete(n),r.size===0&&e.queued.delete(t),St(e))}function Yb(e,t,n){$b(e,t,n),Vb(e,t,n)}function Jb(e,t){e.queued.delete(t),e.pending.delete(t),e.missedScans.delete(t),e.committing.delete(t),St(e)}function Xb(e,t,n){if(t===void 0)return null;let i=t[it]!==!0&&t.reasoningEfforts!==void 0&&typeof t[Mn]=="number"||t[it]!==!0&&n?.efforts!==void 0&&Qb(t.reasoningEfforts,n.efforts)?!1:t.reasoningEfforts!==void 0||t[it]===!0||e.efforts==="keep",s=t[wt]!==!0&&n?.input!==void 0&&Zb(t.input,n.input)?!1:Array.isArray(t.input)&&t.input.length>0||t[wt]===!0,d=i?"keep":e.efforts,l=s?void 0:e.input,c=t[at]===!0,f=e.imageGen!==void 0&&e.imageGen!==c?e.imageGen:void 0,h=e.defaultEffort;return d==="keep"&&l===void 0&&f===void 0&&h===void 0?null:{efforts:d,...e.compat===void 0?{}:{compat:e.compat},...l===void 0?{}:{input:l},...f===void 0?{}:{imageGen:f},...h===void 0?{}:{defaultEffort:h}}}function Qb(e,t){if(e===t)return!0;if(!V(e)||!V(t))return!1;let n=Object.keys(t);if(Object.keys(e).length!==n.length)return!1;let r=t;return n.every(o=>e[o]===r[o])}function Zb(e,t){if(!Array.isArray(e)||e.length!==t.length)return!1;let n=new Set(t);return e.every(r=>typeof r=="string"&&n.has(r))}function ey(e){if(!V(e))return!1;let t=e.efforts;return t===!1||t==="keep"||V(t)}async function ty(e,t,n,r,o=!1,i){let a=i??await e.describeNamespace(),s=qe(a.namespace),d=[];for(let[h,p]of[...r]){let g=_n(s,n).find(E=>E.id===h);if(g===void 0||t.pending.get(n)?.get(h)!==p)continue;let b=nn(s,n),m=typeof g.name=="string"?g.name:void 0,v=xt(h,m===void 0?b:{...b,displayName:m}),x=Xb(p,g,{...v.efforts===void 0?{}:{efforts:v.efforts},...v.input===void 0?{}:{input:v.input}});if(x===null){Yn(t,n,h,void 0);continue}d.push({modelId:h,efforts:x.efforts,...x.compat===void 0?{}:{compat:x.compat},...x.input===void 0?{}:{input:x.input},...x.imageGen===void 0?{}:{imageGen:x.imageGen},...x.defaultEffort===void 0?{}:{defaultEffort:x.defaultEffort}})}if(d.length===0)return!1;let l=!1,c=await Mr(e.api,n,d,()=>l?e.describeNamespace():(l=!0,Promise.resolve(a)),o?void 0:Ku),f=!1;return d.forEach((h,p)=>{let g=c[p];if(g?.aborted!==!0){if(g?.ok===!0||g?.modelNotFound===!0){Yn(t,n,h.modelId,void 0);return}if(g?.error!==void 0&&fu.has(g.error)){Yn(t,n,h.modelId,void 0),console.error(`[bre] staged flush withdrew "${n}"/"${h.modelId}": ${g.error}`);return}f=!0,console.error(`[bre] staged flush write failed for "${n}"/"${h.modelId}": ${g?.error??"unknown"}`)}}),(t.pending.get(n)?.size??0)===0&&t.pending.delete(n),f}async function xs(e,t,n=!1,r){for(let s of[...t.committing])t.queued.has(s)||t.committing.delete(s);if(![...t.queued.keys()].some(s=>t.committing.has(s)||t.signalsUnavailable))return St(t),!1;let i=r??await e.describeNamespace();if(i.writable!==!0)return St(t),!1;let a=!1;for(let[s,d]of[...t.queued]){if(!t.committing.has(s)&&!t.signalsUnavailable)continue;let c=[...d].map(([p,g])=>({modelId:p,efforts:g.efforts,...g.compat===void 0?{}:{compat:g.compat},...g.input===void 0?{}:{input:g.input},...g.imageGen===void 0?{}:{imageGen:g.imageGen},...g.defaultEffort===void 0?{}:{defaultEffort:g.defaultEffort}})),f=await Mr(e.api,s,c,()=>Promise.resolve(i),n?void 0:Ku),h=!1;c.forEach((p,g)=>{let b=f[g];if(b?.aborted===!0){h=!0;return}if(b?.ok===!0||b?.modelNotFound===!0){d.delete(p.modelId);return}if(b?.error!==void 0&&fu.has(b.error)){d.delete(p.modelId),console.error(`[bre] held write withdrawn for "${s}"/"${p.modelId}": ${b.error}`);return}console.error(`[bre] held write failed for "${s}"/"${p.modelId}": ${b?.error??"unknown"}`)}),d.size===0?(t.queued.delete(s),t.committing.delete(s)):h||(a=!0)}return St(t),a}async function ks(e,t,n=!1,r){if(t.pending.size===0)return!1;let o=r??await e.describeNamespace();if(o.writable!==!0)return!1;let i=qe(o.namespace),a=!1;for(let[s,d]of[...t.pending]){if(d.size===0){t.pending.delete(s);continue}Vn(i,s)&&await ty(e,t,s,d,n,o)&&(a=!0)}return St(t),a}function Qe(e,t){for(let n of t){let r=Array.from(e.querySelectorAll("input[aria-label], select[aria-label]")).find(o=>(o.getAttribute("aria-label")??"").startsWith(n));if(r!==void 0&&r.value.trim().length>0)return r.value.trim()}return""}function Kr(e){return e.closest('[class*="editor"], [class*="rowCard"], [class*="addCard"]')??void 0}function ny(e){let t=e.closest('[class*="modelEntry"]');if(t===null){let r=Kr(e);if(r===void 0)return;let o=Array.from(r.querySelectorAll('[class*="modelAdvanced"]'));return o.length===1?o[0]:o.find(i=>i.offsetParent!==null)??o[0]}let n=Array.from(t.querySelectorAll('[class*="modelAdvanced"]'));return n.length===1?n[0]:n.find(r=>r.offsetParent!==null)??n[0]}function gu(e,t){return Array.from(e.querySelectorAll("button[aria-label]")).find(n=>t.some(r=>(n.getAttribute("aria-label")??"").startsWith(r)))}function nu(){return new Promise(e=>{if(typeof window.requestAnimationFrame!="function"){e();return}let t,n=()=>{window.clearTimeout(r),t!==void 0&&window.cancelAnimationFrame(t),e()},r=window.setTimeout(n,100);t=window.requestAnimationFrame(n)})}function ni(e){return e.querySelector('[class*="modelInputTypes"]')!==null}var ry="modelReasoning",bs="data-bre-reasoning-hidden";function hu(e){return e.querySelector(`[class*="${ry}"]`)??void 0}function Es(e){let t=hu(e);t!==void 0&&t.style.display!=="none"&&(t.setAttribute(bs,"1"),t.style.display="none")}function _r(e){let t=hu(e);t!==void 0&&t.getAttribute(bs)==="1"&&(t.removeAttribute(bs),t.style.display==="none"&&(t.style.display=""))}var oi="data-bre-capacity-hidden";function bu(e,t){return Array.from(e.children).filter(n=>n.nodeType!==1?!1:n.matches(`[class*="${t}"]`))}function oy(e){return bu(e,"modelField")}function iy(e){return bu(e,"modelInputTypes")}function yu(e){return[...oy(e),...iy(e)]}function ay(e){for(let t of e)t.style.display!=="none"&&(t.setAttribute(oi,"1"),t.style.display="none")}function sy(e){for(let t of e)t.getAttribute(oi)==="1"&&(t.removeAttribute(oi),t.style.display==="none"&&(t.style.display=""))}function dy(e){ay(yu(e))}function gs(e){sy(yu(e))}function vu(e){let t=e.querySelector('[class*="modelInputTypes"]');return t===null||t.getAttribute(oi)==="1"?!1:!t.hidden&&t.style.display!=="none"}function wu(e,t){let n=e.querySelector('[class*="modelInputTypes"]');if(n===null)return;let r=Array.from(n.querySelectorAll('input[type="checkbox"]')),o=r.find(i=>{let a=i.closest("label")?.textContent?.trim();return a!==void 0&&t.includes(a)});return o!==void 0?o:r.length===2?r[1]:void 0}function qr(e,t,n){if(!vu(e))return!1;let r=wu(e,n);return r===void 0||r.disabled?!1:(r.checked!==t&&r.click(),!0)}function ys(e,t,n){return t==null||e===void 0||vu(e)&&qr(e,t.includes("image"),n),t}function ru(e,t){let n=e.getAttribute("aria-label")??"";if(t.some(o=>n.startsWith(o)))return!0;let r=e.closest("label")?.textContent?.trim()??"";return r.length>0&&t.some(o=>r.includes(o))}function Ts(e,t){let n=[...t.modelId,...t.modelName],r=Array.from(e.querySelectorAll("input")).filter(s=>s.type!=="checkbox"&&s.type!=="radio").filter(s=>s.closest("[data-plugin]")===null).filter(s=>!n.some(d=>(s.getAttribute("aria-label")??"").startsWith(d))),o=r.find(s=>ru(s,t.contextWindow)),i=r.find(s=>ru(s,t.maxOutput));if(o!==void 0&&i!==void 0)return{contextWindow:o,maxOutput:i};let a=r.filter(s=>s!==o&&s!==i);return{contextWindow:o??a[0],maxOutput:i??(o!==void 0?a[0]:a[1])}}function xu(e,t,n){let r=Ts(e,t),o=(i,a)=>i===void 0||i.disabled||a===void 0||!Number.isFinite(a)||a<=0||kt(i.value)!==void 0?!1:ku(i,String(a));return{contextWindow:o(r.contextWindow,n.contextWindow),maxOutput:o(r.maxOutput,n.maxTokens)}}function ku(e,t){return e.disabled?!1:(e.value===t||(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set?.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0}))),!0)}function ly(e,t){let n=Ts(e,t),r=a=>{if(a!==void 0)return kt(a.value)},o=r(n.contextWindow),i=r(n.maxOutput);return{...o===void 0?{}:{contextWindow:o},...i===void 0?{}:{maxTokens:i}}}function cy(e,t,n){let r=Ts(e,t),o=(i,a)=>i===void 0?!1:ku(i,a===void 0||!Number.isFinite(a)||a<=0?"":String(a));return{contextWindow:"contextWindow"in n?o(r.contextWindow,n.contextWindow):!1,maxOutput:"maxTokens"in n?o(r.maxOutput,n.maxTokens):!1}}async function Eu(e,t){let n=e,r=n.offsetHeight;if(r<=0)return t();let o=n.style.height,i=n.style.overflow,a=n.style.boxSizing;n.style.boxSizing="border-box",n.style.height=`${r}px`,n.style.overflow="hidden";try{return await t()}finally{n.style.height=o,n.style.overflow=i,n.style.boxSizing=a}}async function uy(e,t,n){if(e===void 0)return!1;let r=t.inputImage;if(ni(e))return qr(e,!0,r);let o=e.closest('[class*="modelEntry"]')??e;if(o.querySelector('[class*="modelAdvanced"]')!==null)return!1;let i=gu(o,t.capacity);return i===void 0||i.disabled?!1:Eu(o,async()=>{i.click(),ni(o)||await n();try{return ni(o)&&qr(o,!0,r)}finally{i.click()}})}async function fy(e,t,n,r){if(e.matches('[class*="modelAdvanced"]'))return r(e);let o=e.closest('[class*="modelEntry"]')??e;if(o.querySelector('[class*="modelAdvanced"]')!==null)return r(o);let i=gu(o,t.capacity);return i===void 0||i.disabled?!1:Eu(o,async()=>{i.click(),o.querySelector('[class*="modelAdvanced"]')===null&&await n();try{return o.querySelector('[class*="modelAdvanced"]')!==null?r(o):!1}finally{i.click()}})}function py(e,t,n,r,o){n.disposed||!e.isConnected||Fu(e)===void 0||Array.from(e.querySelectorAll("button[aria-label]")).some(a=>o.capacity.some(s=>(a.getAttribute("aria-label")??"").startsWith(s)))||Fo(e,my(e,qe(r.namespace),o),{t:t.t,onRequest:a=>Tu(n,t,a)})}function my(e,t,n){let r=[];for(let o of es(e)){let i=Kr(o);if(i===void 0)continue;let a=fn(i,t,n);a===void 0||a.staged||r.push({catalogue:o,route:a.route})}return r}function gy(e,t,n){let r=[],o=new Set;for(let i of e){if(o.has(i.card))continue;o.add(i.card);let a=fn(i.card,t,n);if(a===void 0)continue;let[s]=es(i.card);s!==void 0&&r.push({catalogue:s,route:a.route})}return r}function hy(e,t,n,r){let o=[],i=new Set;for(let a of r.capacity){let s=Array.from(e.querySelectorAll("button[aria-label]")).filter(d=>(d.getAttribute("aria-label")??"").startsWith(a));for(let d of s){let l=Kr(d);if(l===void 0)continue;let c=d.closest('[class*="modelEntry"]')??l,f=Qe(c,r.modelId);f.length===0||i.has(f)||fn(l,n,r)?.route===t&&(i.add(f),o.push({id:f,name:Qe(c,r.modelName),row:c}))}}return o}async function Tu(e,t,n,r=[]){if(n.length===0)return{held:0,unsuggested:0,blocked:"unknown-route"};if(e.adapting.has(n))return{held:0,unsuggested:0,blocked:"busy"};e.adapting.add(n);let o=0,i=0;try{Da();let a,s=()=>a??(a=t.describeNamespace()),d=await s(),l=qe(d.namespace);if(d.writable!==!0)return{held:0,unsuggested:0,blocked:"unwritable"};if(!Vn(l,n)&&r.length===0)return{held:0,unsuggested:0,blocked:"unknown-route"};let f=_n(l,n),h=new Set;for(let T of f){let y=typeof T.id=="string"?T.id:"";y.length>0&&h.add(y)}let p=f.slice();for(let T of r)T.id.length===0||h.has(T.id)||p.push({id:T.id,name:T.name});if(p.length===0)return{held:0,unsuggested:0,blocked:"no-models"};let g=l[n]??{},b=typeof g.api=="string"?g.api:void 0,m=new Set,v=new Map;for(let[T,y]of e.mounted)y.props.route===n&&(v.set(y.props.modelId,T),y.props.efforts!==void 0&&m.add(y.props.modelId));let x=new Map;for(let T of r)T.row!==void 0&&x.set(T.id,T.row);let E=!1,N=(T,y)=>ys(v.get(T),y,t.labels().inputImage),F=async(T,y)=>{if(y.image!==!0)return;let M=v.get(T)??x.get(T);M!==void 0&&await uy(M,t.labels(),nu)},X=async(T,y,M)=>{let w=y.image===!0,k=M.contextWindow!==void 0||M.maxTokens!==void 0;if(!w&&!k)return;let C=v.get(T)??x.get(T);if(C===void 0)return;let D=t.labels();await fy(C,D,nu,_=>{w&&qr(_,!0,D.inputImage),k&&xu(_,D,M)})},U=Ho(t.api,s,(T,y,M,w,k,C,D)=>{Yn(e,T,y,M,w,N(y,k),C,D)},(T,y,M)=>{mu(e,T,y,{...M,input:N(y,M.input)})},void 0,()=>E);for(let T of p){let y=typeof T.id=="string"?T.id:"";if(y.length===0)continue;let M=Mo(p,y),w=Lo(p,y),k=T[at]===!0,C=M!==void 0||T[it]===!0,D=Array.isArray(w)&&w.length>0||T[wt]===!0||k;if(m.has(y)&&!C)continue;if(C&&D){let ce=v.get(y)??x.get(y);if(Array.isArray(w)&&w.includes("image")&&ce!==void 0){let Q=t.labels().inputImage,ue=wu(ce,Q);ue!==void 0&&!ue.disabled&&!ue.checked&&qr(ce,!0,Q)}continue}let _=Ao(p,y),B=Ro(p,y)??"",te=await U.suggest(n,y,Co(p,y));if(!te.ok){i+=1;continue}let ee=te.suggestion,ie=ee.efforts!==!1,oe=ee.imageGen===!0?Ct(void 0,!0):ee.input===void 0?Ct(w,k):Ct(ee.input);if(C){if(!oe.image&&!oe.imageGen||e.queued.get(n)?.has(y)===!0)continue;await F(y,oe),E=!h.has(y),U.commit(n,y,Po({efforts:"keep",...Do(oe)})),E&&t.onPendingChanged?.(),E=!1,o+=1;continue}let ae=B!==""?B:ee.defaultEffort??B,me=ae===B?void 0:ae===""?null:ae;E=!h.has(y),await X(y,oe,{...ee.contextWindow===void 0?{}:{contextWindow:ee.contextWindow},...ee.maxTokens===void 0?{}:{maxTokens:ee.maxTokens}});let ge=Io(oe,w,k)?void 0:Do(oe);U.commit(n,y,Po({efforts:Qa(ie,Kn(sn(ee.efforts)),M),input:ge?.input,imageGen:ge?.imageGen,defaultEffort:me,appliedCompat:ee.compat,routeApi:b,initialCompat:_})),E&&t.onPendingChanged?.(),E=!1,o+=1}return{held:o,unsuggested:i}}catch(a){return console.warn("[bre] provider-wide adapt failed:",a),{held:o,unsuggested:i,failed:a instanceof Error?a.message:String(a)}}finally{e.adapting.delete(n)}}function by(e){return e.querySelector(`[data-plugin="${we}"]`)!==null}function yy(e,t){return e.route===t.route&&e.routeDisplayName===t.routeDisplayName&&e.routeApi===t.routeApi&&e.routeBaseURL===t.routeBaseURL&&e.modelId===t.modelId&&e.modelName===t.modelName&&e.index===t.index&&e.readOnly===t.readOnly&&e.defaultEffort===t.defaultEffort&&e.staged===t.staged&&e.officialInputTypes===t.officialInputTypes&&e.effortsUnset===t.effortsUnset&&Cr(e.efforts,t.efforts)&&wy(e.input,t.input)&&e.imageGen===t.imageGen&&vy(e.compat,t.compat)}function vy(e,t){return e===t?!0:e===void 0||t===void 0?!1:JSON.stringify({...e},Object.keys({...e,...t}).sort())===JSON.stringify({...t},Object.keys({...e,...t}).sort())}function wy(e,t){if(e===t)return!0;if(e===void 0||t===void 0)return!1;let n=new Set(e);return e.length===t.length&&t.every(r=>n.has(r))}function xy(e,t){return Array.from(e.querySelectorAll("input[aria-label], select[aria-label]")).some(n=>t.some(r=>(n.getAttribute("aria-label")??"").startsWith(r)))}function fn(e,t,n){let r=e.querySelector('[class*="editorRoute"]')?.textContent?.trim();if(r!==void 0&&r.length>0&&Vn(t,r))return{route:r,staged:!1};if(xy(e,n.routeId)){let a=Qe(e,n.routeId);return a.length>0&&!Vn(t,a)?{route:a,staged:!0}:void 0}let o=e.querySelector('[class*="editorTitle"], [class*="rowName"]')?.textContent?.trim();if(o===void 0||o.length===0)return;let i=Object.entries(t).find(([,a])=>a.displayName===o);if(i!==void 0)return{route:i[0],staged:!1};if(Vn(t,o))return{route:o,staged:!1}}function ky(e,t){let n=e.querySelector('[class*="editorActions"]');if(n===null)return;let r=Array.from(n.querySelectorAll("button"));if(r.length<2)return;let o=(f,h)=>(f.textContent??"").trim()===h,i=n.querySelector('[class*="primaryButton"]'),a=n.querySelector('[class*="secondaryButton"]');if(i!==null&&a!==null)return{submit:i,cancel:a};let s=[...r].reverse().find(f=>t.apply.some(h=>o(f,h))),d=[...r].reverse().find(f=>t.cancel.some(h=>o(f,h)));if(s!==void 0&&d!==void 0)return{submit:s,cancel:d};let l=r[r.length-1],c=r[r.length-2];if(!(l===void 0||c===void 0))return{submit:l,cancel:c}}function Xn(e,t,n){t.has(e)||(t.add(e),e.addEventListener("click",n,{capture:!0}))}var hs=new WeakMap,vs=new Set;function Su(){for(let e of Array.from(vs))e.release()}var Br=420,Mu=320,Ey=160,ou=2e3,Ty=150,Lu=new Set(["PageUp","PageDown","Home","End","ArrowUp","ArrowDown"," "]);function Ss(e,t=Mu){for(let n of is(e)){let r=ii.get(n);if(r!==void 0){window.clearTimeout(r.timer),r.timer=window.setTimeout(()=>iu(n),t);continue}n.style.overflowAnchor!=="none"&&(ii.set(n,{saved:n.style.overflowAnchor,timer:window.setTimeout(()=>iu(n),t)}),n.style.overflowAnchor="none")}}var ii=new Map;function iu(e){let t=ii.get(e);t!==void 0&&(ii.delete(e),e.style.overflowAnchor=t.saved)}function Qn(e,t,n=!1){let r=is(e),o=r[0];if(o===void 0||!e.isConnected)return;let i=performance.now(),a=hs.get(o);if(a!==void 0)if(n)a.release();else{a.deadline=Math.min(Math.max(a.deadline,i+t),a.startedAt+ou);return}let s=e.getBoundingClientRect(),d=s.top,l=s.height,c=new Map,f=new Map;for(let E of r){c.set(E,E.scrollTop);let N=E.style.overflowAnchor;N!=="none"&&f.set(E,N),E.style.overflowAnchor="none"}let h=new Set(r),p={deadline:i+t,startedAt:i,frame:void 0,release:()=>{}},g=()=>{if(vs.delete(p)){p.frame!==void 0&&(window.cancelAnimationFrame(p.frame),p.frame=void 0);for(let[E,N]of f)E.style.overflowAnchor=N;hs.delete(o),document.removeEventListener("wheel",b,!0),document.removeEventListener("touchstart",b,!0),document.removeEventListener("pointerdown",b,!0),document.removeEventListener("keydown",m,!0)}};function b(){g()}function m(E){Lu.has(E.key)&&g()}p.release=g,hs.set(o,p),vs.add(p),document.addEventListener("wheel",b,{capture:!0,passive:!0}),document.addEventListener("touchstart",b,{capture:!0,passive:!0}),document.addEventListener("pointerdown",b,{capture:!0}),document.addEventListener("keydown",m,{capture:!0});let v=0,x=()=>{if(p.frame=void 0,v+=1,!e.isConnected||v>=Ty){g();return}let E=e.getBoundingClientRect(),N=Math.abs(E.height-l)>.5;if(!N&&[...h].some(T=>T.scrollTop!==c.get(T))){g();return}let F=[];if(N){for(let T of r){let y=c.get(T);y===void 0||T.scrollTop===y||(F.push(T),T.scrollTop=y,c.set(T,T.scrollTop))}E=e.getBoundingClientRect()}let X=E.top-d;X!==0&&Sy(r,h,c,X,F);let U=performance.now();if(N&&(l=E.height,p.deadline=Math.min(Math.max(p.deadline,U+Ey),p.startedAt+ou)),U>=p.deadline){g();return}p.frame=window.requestAnimationFrame(x)};p.frame=window.requestAnimationFrame(x)}function Sy(e,t,n,r,o=[]){let i=r;for(let a of new Set([...o,...t,...e])){if(i===0)break;let s=a.scrollTop;if(s!==n.get(a))continue;a.scrollTop=s+i;let d=a.scrollTop;d!==s&&(n.set(a,d),t.add(a),i-=d-s)}}var Ms='[class*="modelList"]',My="bre-list-slack",Au=3e3,Ly='button[class*="iconButtonDanger"]',Wr,jt=new WeakMap,Jn=new Set;function Cu(e){if(!(e instanceof Element))return;let t=e.closest(Ms);if(t===null)return;let n=yc(t).map(r=>({host:r,top:r.scrollTop}));n.length!==0&&(Wr={targets:n,at:performance.now()})}function Nt(){Wr=void 0}function Ru(e){Cu(e.target),Du(e.target)}function Hu(e){if(Lu.has(e.key)){Nt();return}Cu(e.target),Du(e.target)}var Fr=0;function Nu(){Fr+=1,!(Fr>1)&&(document.addEventListener("click",Ru,!0),document.addEventListener("keydown",Hu,!0),document.addEventListener("focusin",Nt,!0),document.addEventListener("pointerdown",Nt,!0),document.addEventListener("wheel",Nt,{capture:!0,passive:!0}),document.addEventListener("touchstart",Nt,{capture:!0,passive:!0}))}function ai(e){let t=jt.get(e);t!==void 0&&(jt.delete(e),Jn.delete(t),t.scrollTarget.removeEventListener("scroll",t.onScroll),t.spacer.remove())}function Ay(e){return e===document.scrollingElement?document:e}function Cy(){if(Jn.size!==0)for(let e of Array.from(Jn)){let t=e.host;if(!e.spacer.isConnected){jt.delete(t),Jn.delete(e),e.scrollTarget.removeEventListener("scroll",e.onScroll);continue}t.scrollTop<=t.scrollHeight-t.clientHeight-e.height&&ai(t)}}function Ou(e,t){return e.scrollTop>e.scrollHeight-e.clientHeight-t}function Iu(e,t){let n=jt.get(e);if(n!==void 0)return n.height!==t&&(n.height=t,n.spacer.style.height=`${t}px`),n;let r=document.createElement("div");r.className=My,r.dataset.plugin=we,r.setAttribute("aria-hidden","true"),r.style.height=`${t}px`,(e===document.scrollingElement?document.body??e:e).appendChild(r);let i=()=>{let s=jt.get(e);s!==void 0&&!Ou(e,s.height)&&ai(e)},a={host:e,spacer:r,height:t,onScroll:i,scrollTarget:Ay(e)};return jt.set(e,a),Jn.add(a),a.scrollTarget.addEventListener("scroll",i,{passive:!0}),a}function Du(e){if(!(e instanceof Element))return;let t=e.closest(Ly);if(t===null)return;let n=t.closest(Ms);if(n===null)return;let r=t.closest('[class*="modelEntry"]');if(r===null)return;let o=Wr;if(o===void 0||performance.now()-o.at>Au)return;let i=Number.parseFloat(getComputedStyle(n).rowGap)||0,a=r.getBoundingClientRect().height+i;if(!(a<=0))for(let{host:s,top:d}of o.targets){if(!s.isConnected)continue;let l=jt.get(s),c=l===void 0?0:l.height,f=s.scrollHeight-s.clientHeight-c-d;f>=a||Iu(s,Math.max(c,a-f))}}function Ry(e=performance.now()){let t=Wr;if(!(t===void 0||e-t.at>Au))for(let n of t.targets){let r=n.host;if(!r.isConnected)continue;let o=jt.get(r),i=o===void 0?0:o.height,a=r.scrollHeight-r.clientHeight-i,s=n.top-a;if(s<=0){o!==void 0&&!Ou(r,o.height)&&ai(r);continue}Iu(r,s),r.scrollTop!==n.top&&(r.scrollTop=n.top)}}function Pu(){if(Fr=Math.max(0,Fr-1),!(Fr>0)){document.removeEventListener("click",Ru,!0),document.removeEventListener("keydown",Hu,!0),document.removeEventListener("focusin",Nt,!0),document.removeEventListener("pointerdown",Nt,!0),document.removeEventListener("wheel",Nt,!0),document.removeEventListener("touchstart",Nt,!0),Wr=void 0;for(let e of Array.from(Jn))ai(e.host)}}function _u(e,t=Br){Ry(),Cy();let n=new Set;for(let r of Array.from(e.querySelectorAll(Ms))){let o=r.closest('[class*="rowCard"], [class*="setupCard"], [class*="addCard"]');o===null||n.has(o)||(n.add(o),Qn(o,t))}}function Hy(e,t){Xn(e,t,()=>{let n=e.closest('[class*="modelEntry"]')??e.closest('[class*="rowCard"]');n!==null&&Qn(e.closest('[class*="rowCard"]')??n,Br)})}var au="{provider}";function Ny(e,t){let n=t.editProvider.map(o=>{let i=o.indexOf(au);return i<0?void 0:{prefix:o.slice(0,i),suffix:o.slice(i+au.length)}}).filter(o=>o!==void 0);if(n.length===0)return[];let r=[];for(let o of Array.from(e.querySelectorAll("button[aria-label]"))){let i=o.getAttribute("aria-label")??"";n.some(a=>i.length>a.prefix.length+a.suffix.length&&i.startsWith(a.prefix)&&i.endsWith(a.suffix))&&o.closest("[data-plugin]")===null&&r.push(o)}return r}function Oy(e,t){Xn(e,t,()=>{let n=e.closest('[class*="rowCard"], [class*="setupCard"], [class*="addCard"]');n!==null&&Qn(n,Br)})}function Iy(e,t){let n=[];for(let r of Array.from(e.querySelectorAll("button"))){if(r.closest("[data-plugin]")!==null)continue;let o=r.getAttribute("aria-label")??"";if(t.addModel.some(a=>o.startsWith(a))){n.push(r);continue}let i=(r.textContent??"").trim();i.length>0&&t.addModel.some(a=>i===a||i===`+ ${a}`)&&n.push(r)}return n}function Dy(e,t,n){Xn(e,n,()=>{t.isConnected&&Qn(t,Br)})}function Py(e,t){Xn(e,t,()=>{let n=e.closest('[class*="addBlock"]');n!==null&&Qn(n,Br,!0)})}function Fu(e){return e.querySelector('[class*="editorActions"]')??e.querySelector('[class*="modelEntry"]')??void 0}function Ku(){return Fu(bt())!==void 0}function _y(e,t,n){let r={routeId:t.routeId,modelName:t.modelName,baseUrl:t.baseUrl,apiProtocol:t.apiProtocol},o=new Set;for(let i of e){let a=Array.from(i.querySelectorAll("input[aria-label], select[aria-label]")),s=d=>a.some(l=>d.some(c=>(l.getAttribute("aria-label")??"").startsWith(c)));s(t.apiProtocol)&&s(t.baseUrl)&&o.add(i)}for(let i of o)Qc(i,r,{t:n})}var ti=new WeakMap;function su(e,t,n,r=!1){let o=e.describePromise;if(o===void 0)return;let i=ti.get(e);if(i?.promise===o){i.run=t,i.phase=n,i.reportReadFailure=r;return}let a={promise:o,run:t,phase:n,reportReadFailure:r};ti.set(e,a);let s=()=>{ti.get(e)===a&&ti.delete(e)};o.then(d=>{s(),!e.disposed&&e.describePromise===o&&a.run(d)},d=>{s(),e.describePromise===o&&(e.describePromise=void 0,a.reportReadFailure&&console.error(`[bre] ${a.phase} failed: ${d instanceof Error?d.message:String(d)}`))}).catch(d=>{console.error(`[bre] ${a.phase} failed: ${d instanceof Error?d.message:String(d)}`)})}var Fy=['[class*="editor"]','[class*="modelEntry"]','[class*="rowCard"]','[class*="setupCard"]','[class*="addCard"]','button[class*="addButton"]',"button[aria-label]"].join(", ");function Ls(e,t,n){if(n.disposed||!e.isConnected)return;let r=t.labels(),o=Array.from(e.querySelectorAll(Fy)),i=!1,a=[],s=[],d=[],l=[],c=[];for(let p of o)!i&&p.matches('[class*="editorActions"], [class*="modelEntry"]')&&(i=!0),p.matches('[class*="rowCard"], [class*="setupCard"]')?(a.push(p),s.push(p)):p.matches('[class*="addCard"]')&&s.push(p),p.matches('[class*="editor"], [class*="addCard"], [class*="rowCard"]')&&l.push(p),p.matches('button[class*="addButton"]')&&p.closest("[data-plugin]")===null&&d.push(p),p.matches("button[aria-label]")&&r.capacity.some(g=>(p.getAttribute("aria-label")??"").startsWith(g))&&c.push(p);for(let p of a)for(let g of Ny(p,r))Oy(g,n.editWired);for(let p of s)for(let g of Iy(p,r))Dy(g,p,n.addModelWired);for(let p of d)Py(p,n.addProviderWired);_y(l,r,t.t);let f=c.length>0;if(!i){if(Fo(e,[],{t:t.t}),n.mounted.size>0){for(let[g,b]of n.mounted)_r(g),gs(g),b.editor.unmount();n.mounted.clear()}let p=n.editing;n.editing=!1,(p!==!1||pu(n)&&Date.now()>=n.nextFlushAt)&&zb(t,n,p===!0).catch(g=>{console.error(`[bre] idle pass failed: ${g instanceof Error?g.message:String(g)}`)});return}if(n.editing=!0,!f){for(let[g,b]of n.mounted)_r(g),gs(g),b.editor.unmount();n.mounted.clear(),n.describePromise??(n.describePromise=t.describeNamespace({allowStale:!0}));let p=r;su(n,g=>{py(e,t,n,g,p)},"empty-catalog seat",!0);return}for(let p of c)Hy(p,n.disclosureWired);n.describePromise??(n.describePromise=t.describeNamespace({allowStale:!0})),su(n,p=>{if(n.disposed||!e.isConnected)return;let g=p.namespace,b=qe(g),m=new Map,v=T=>(m.has(T)||m.set(T,fn(T,b,r)),m.get(T)),x=new Map,E=T=>{let y=x.get(T);if(y!==void 0)return y;let M=_n(b,T),w=new Set,k=new Set,C=new Map;for(let _ of M){let B=_.id;w.add(B),C.has(B)||C.set(B,[_]),_[it]===!0&&k.add(B)}let D={models:M,savedModelIds:w,unsetModelIds:k,singletonById:C};return x.set(T,D),D},N=[],F=Array.from(e.querySelectorAll("button[aria-label]")).filter(T=>r.capacity.some(y=>(T.getAttribute("aria-label")??"").startsWith(y)));for(let T of F){let y=Kr(T);if(y===void 0)continue;let M=T.closest('[class*="modelEntry"]')??y,w=Qe(M,r.modelId);w.length!==0&&N.push({container:ny(T),row:M,modelId:w,card:y})}Fo(e,gy(N,b,r),{t:t.t,onRequest:T=>Tu(n,t,T,hy(e,T,b,r))});let X=new Set(N.map(T=>T.container));for(let[T,y]of n.mounted)X.has(T)||(_r(T),gs(T),y.editor.unmount(),n.mounted.delete(T));if(n.pending.size>0){let T=new Map;for(let M of N){let w=v(M.card);if(w===void 0)continue;let k=T.get(w.route);k===void 0&&T.set(w.route,k=new Set),k.add(M.modelId)}let y=new Map;for(let[M,w]of n.pending){if(!Vn(b,M))continue;let k=T.get(M),C=[...w.keys()].filter(D=>!k?.has(D));C.length>0&&y.set(M,new Set(C))}for(let[M,w]of y){let k=n.missedScans.get(M);if(k!==void 0)for(let C of w)k.has(C)&&(Yn(n,M,C,void 0),k.delete(C),w.delete(C))}n.missedScans=y}else n.missedScans=new Map;let U=new Set(N.map(T=>T.card));for(let T of U){let y=v(T);if(y===void 0)continue;let M=y.route,w=ky(T,r);w===void 0?n.signalsUnavailable=!0:(n.signalsUnavailable=!1,Xn(w.submit,n.submitWired,()=>{let k=fn(T,b,r)?.route??M;n.committing.add(k),St(n)}),Xn(w.cancel,n.cancelWired,()=>{let k=fn(T,b,r)?.route??M;Jb(n,k)}))}N.forEach((T,y)=>{let M=T.container;if(M===void 0)return;let w=v(T.card);if(w===void 0)return;let{route:k,staged:C}=w,D=b[k]??{},{savedModelIds:_,unsetModelIds:B,singletonById:te}=E(k),ee=te.get(T.modelId)??[],ie=C||!_.has(T.modelId),oe=ie?n.pending.get(k)?.get(T.modelId)?.efforts:void 0,ae=ie?oe==="keep"?void 0:oe:Mo(ee,T.modelId),me=!ie&&B.has(T.modelId),ge=ie?n.pending.get(k)?.get(T.modelId)?.input:Lo(ee,T.modelId),ce=ie?n.pending.get(k)?.get(T.modelId)?.imageGen:Ia(ee,T.modelId),Q=ie?n.pending.get(k)?.get(T.modelId)?.compat:Ao(ee,T.modelId),ue=ie?n.pending.get(k)?.get(T.modelId)?.defaultEffort??void 0:Ro(ee,T.modelId),ke=ie?Qe(T.row,r.modelName):"",Se=ie?ke.length>0?ke:void 0:Co(ee,T.modelId),Ce=C?Qe(T.card,r.apiProtocol):"",$=C?Qe(T.card,r.baseUrl):"",K=C&&Ce.length>0?Ce:typeof D.api=="string"?D.api:void 0,z=C&&$.length>0?$:typeof D.baseURL=="string"?D.baseURL:void 0,u={route:k,routeDisplayName:C?k:typeof D.displayName=="string"?D.displayName:k,...K===void 0?{}:{routeApi:K},...z===void 0?{}:{routeBaseURL:z},modelId:T.modelId,...Se===void 0?{}:{modelName:Se},...ae===void 0?{}:{efforts:ae},...me?{effortsUnset:me}:{},...ge===void 0?{}:{input:ge},...ce?{imageGen:!0}:{},...Q===void 0?{}:{compat:Q},...ue===void 0?{}:{defaultEffort:ue},index:y,staged:ie,officialInputTypes:ni(M),api:{...Ho(t.api,void 0,(H,J,ne,ve,Oe,_e,R)=>{Yn(n,H,J,ne,ve,ys(M,Oe,r.inputImage),_e,R)},(H,J,ne)=>{mu(n,H,J,{...ne,input:ys(M,ne.input,r.inputImage)})},H=>{Yb(n,H,T.modelId)},()=>(fn(T.card,b,r)?.staged??C)||!_.has(T.modelId)),fillCapacities:(H,J)=>{xu(M,r,{...H===void 0?{}:{contextWindow:H},...J===void 0?{}:{maxTokens:J}})},readCapacities:()=>ly(M,r),setCapacities:H=>{cy(M,r,H)}},readOnly:p.writable!==!0,t:t.t};Es(M),dy(M);let S=n.mounted.get(M);if(S!==void 0){yy(S.props,u)||(S.props=u,S.editor.render(u));return}if(by(M))return;Qn(Kr(M)??T.card,Mu);let P=t.mount(M,u);n.mounted.set(M,{editor:P,props:u})})},"editor reconcile")}var si=['[class*="rowCard"]','[class*="setupCard"]','[class*="addCard"]','[class*="modelEntry"]','[class*="modelAdvanced"]','[class*="modelList"]','[class*="addBlock"]','p[class*="savedNotice"]'].join(","),Ky=[`[data-plugin="${we}"]`,".bre-effort-slot",".bre-keys-host",".bre-create-host",".bre-editor-tabs",".bre-provider-balance",".bre-auto-effort",".bre-auto-effort-note",".bre-config-host",".bre-drag-ghost",".bre-drop-line",".bre-drag-grip",".bre-provider-switch"].join(",");function Bu(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function As(e){let t=Bu(e);return t!==null&&t.closest(Ky)!==null}function qu(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=e;return As(t)?!1:t.matches(si)||t.querySelector(si)!==null}function Wu(e){return e.some(t=>{if(As(t.target))return!1;let n=Bu(t.target);if(t.type==="childList"){let r=[...Array.from(t.addedNodes),...Array.from(t.removedNodes)];return r.length>0&&r.every(As)?!1:n!==null&&n.closest(si)!==null?!0:r.some(qu)}return n!==null&&n.closest(si)!==null?!0:t.type==="attributes"&&qu(t.target)})}var Rs=require("react");var re=require("react"),Xu=require("react-dom");var lt=require("react"),ju=require("react-dom"),Mt=require("react/jsx-runtime"),Gu=6,qy=292,di=8,By=52;function Uu(e,t){let n=e.getBoundingClientRect(),r=t*By+46,o=window.innerWidth||0,i=window.innerHeight||0,a=Math.max(di,Math.min(n.left,o-qy-di)),s=n.bottom+Gu,d=n.top-Gu-r,l=i>0&&s+r>i-di&&d>di?d:s;return{left:a,top:l}}function zu(e){let{anchor:t,label:n,options:r,selected:o,onPick:i,onClose:a}=e,[s,d]=(0,lt.useState)(()=>Uu(t,r.length)),l=(0,lt.useRef)(null),c=(0,lt.useRef)([]);(0,lt.useLayoutEffect)(()=>{let p=()=>{d(Uu(t,r.length))};return p(),window.addEventListener("resize",p),window.addEventListener("scroll",p,!0),()=>{window.removeEventListener("resize",p),window.removeEventListener("scroll",p,!0)}},[t,r.length]),(0,lt.useEffect)(()=>{let p=Math.max(0,r.findIndex(g=>g.value===o));c.current[p]?.focus()},[r,o]),(0,lt.useEffect)(()=>{let p=g=>{let b=g.target;b instanceof Node&&l.current?.contains(b)!==!0&&(t.contains(b)||a())};return document.addEventListener("pointerdown",p,!0),()=>{document.removeEventListener("pointerdown",p,!0)}},[t,a]);let f=(0,lt.useCallback)(p=>{if(r.length===0)return;let g=(p+r.length)%r.length;c.current[g]?.focus()},[r.length]),h=p=>{let g=c.current.findIndex(b=>b===document.activeElement);if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),a();return}if(p.key==="ArrowDown"){p.preventDefault(),f(g+1);return}if(p.key==="ArrowUp"){p.preventDefault(),f(g<0?r.length-1:g-1);return}if(p.key==="Home"){p.preventDefault(),f(0);return}p.key==="End"&&(p.preventDefault(),f(r.length-1))};return(0,ju.createPortal)((0,Mt.jsxs)("div",{ref:l,className:"bre-protocol-menu",style:{left:s.left,top:s.top},onKeyDown:h,children:[(0,Mt.jsx)("p",{className:"bre-protocol-menu-title",children:n}),(0,Mt.jsx)("ul",{className:"bre-protocol-menu-list",role:"listbox","aria-label":n,children:r.map((p,g)=>{let b=p.value===o;return(0,Mt.jsx)("li",{children:(0,Mt.jsx)("button",{ref:m=>{c.current[g]=m},type:"button",role:"option","aria-selected":b,"data-protocol-value":p.value,className:"bre-protocol-option",tabIndex:-1,onClick:()=>{i(p.value)},children:(0,Mt.jsxs)("span",{className:"bre-protocol-option-text",children:[(0,Mt.jsx)("span",{className:"bre-protocol-option-title",children:p.title}),(0,Mt.jsx)("span",{className:"bre-protocol-option-hint",children:p.hint})]})})},p.value)})})]}),document.body)}var W=require("react/jsx-runtime"),Wy=200,Gy=["M8 3.9v8.2","M3.9 8h8.2"],$u="M3.9 8.35 6.6 11.05 12.1 5.5",Uy=["M5.75 5.75V4.1A1.6 1.6 0 0 1 7.35 2.5h4.55a1.6 1.6 0 0 1 1.6 1.6v4.55a1.6 1.6 0 0 1-1.6 1.6h-1.65","M4.1 5.75h4.55a1.6 1.6 0 0 1 1.6 1.6v4.55a1.6 1.6 0 0 1-1.6 1.6H4.1a1.6 1.6 0 0 1-1.6-1.6V7.35a1.6 1.6 0 0 1 1.6-1.6Z"],jy=1600;async function zy(e){try{if(navigator.clipboard?.writeText!==void 0)return await navigator.clipboard.writeText(e),!0}catch{}if(typeof document>"u")return!1;try{let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="-1000px",t.style.opacity="0",document.body.appendChild(t),t.select();let n=document.execCommand("copy");return t.remove(),n}catch{return!1}}function Cs({paths:e}){return(0,W.jsx)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:e.map(t=>(0,W.jsx)("path",{d:t},t))})}function $y(e,t){return e.masked!==void 0?e.masked:e.configured===!1?t("keysMissing"):"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}function Vu(e){return e.alias??e.masked??e.ref}function Vy(e,t){return e.models===void 0?t("keysScopeAll"):e.models.length===0?t("keysScopeNone"):t("keysScopeCount",{count:e.models.length})}var Qu=["openai-completions","openai-responses","anthropic-messages"],Yu={openai:null,anthropic:null},Yy=2e3,Jy=150,Xy=300,Qy=1500,Zy=new Intl.Collator("en",{numeric:!0,sensitivity:"base"});function ev(e,t){return Qu.filter(n=>n===t?!0:(e[zo(n)]??"").length>0)}function Zu(e,t){return t(e==="anthropic-messages"?"keysProtocolAnthropic":e==="openai-responses"?"keysProtocolResponses":e==="openai-completions"?"keysProtocolOpenAI":"keysProtocolDefault")}function tv(e,t){return t(e==="anthropic-messages"?"keysProtocolAnthropicHint":e==="openai-responses"?"keysProtocolResponsesHint":e==="openai-completions"?"keysProtocolOpenAIHint":"keysProtocolDefaultHint")}function Ju(e,t,n,r=!1){return[void 0,...r?Qu:ev(e,t)].map(i=>({value:i??"",title:Zu(i,n),hint:tv(i,n)}))}function li(e){let{route:t,t:n,draft:r}=e,o=e.client??Ge,[i,a]=(0,re.useState)(()=>o.cached?.(t)?.entries),[s,d]=(0,re.useState)(()=>o.cached?.(t)?.models??[]),[l,c]=(0,re.useState)(void 0),[f,h]=(0,re.useState)(!1),p=i===void 0&&l===void 0;(0,re.useEffect)(()=>{if(h(!1),!p)return;let R=setTimeout(()=>h(!0),Wy);return()=>clearTimeout(R)},[p,t]);let[g,b]=(0,re.useState)(!1),[m,v]=(0,re.useState)(void 0),[x,E]=(0,re.useState)(""),[N,F]=(0,re.useState)(""),[X,U]=(0,re.useState)([]),[T,y]=(0,re.useState)(void 0);(0,re.useEffect)(()=>{r===!0&&v({kind:"add"})},[r]);let[M,w]=(0,re.useState)(void 0),[k,C]=(0,re.useState)(void 0),[D,_]=(0,re.useState)(void 0),B=(0,re.useRef)(void 0);(0,re.useEffect)(()=>()=>{B.current!==void 0&&clearTimeout(B.current)},[]);let[te,ee]=(0,re.useState)(void 0),[ie,oe]=(0,re.useState)(()=>o.cached?.(t)?.endpoints??Yu),[ae,me]=(0,re.useState)(!1),ge=(0,re.useRef)(!1);(0,re.useEffect)(()=>{ge.current=ae},[ae]);let ce=(0,re.useRef)(0),Q=(0,re.useCallback)((R,Y)=>{if(!R.ok){c({kind:"error",text:R.error??n("keysUnreachable")});return}a(R.entries),d(R.models??[]),oe(R.endpoints),me(R.probing===!0),c(Y===void 0?void 0:{kind:"status",text:Y})},[n]),ue=(0,re.useRef)(t);ue.current=t,(0,re.useEffect)(()=>(ue.current=t,()=>{ue.current=void 0}),[t]);let ke=(0,re.useCallback)(async(R,Y=!1)=>{let se=o.cached?.(R)!==void 0,ye=await o.list(R,Y?{preferCache:!0}:void 0);ue.current===R&&(se&&!ye.ok||Q(ye,void 0))},[Q,o]);(0,re.useEffect)(()=>{ke(t,!0)},[ke,t]),(0,re.useEffect)(()=>{let R,Y,se=()=>{R===void 0&&(R=setTimeout(()=>{R=void 0,ke(t),Y===void 0&&(Y=setTimeout(()=>{Y=void 0,!ge.current&&ke(t)},Qy))},Xy))};return document.addEventListener(Er,se),()=>{document.removeEventListener(Er,se),R!==void 0&&clearTimeout(R),Y!==void 0&&clearTimeout(Y)}},[ke,t]),(0,re.useEffect)(()=>{if(!ae){ce.current=0;return}let R=!0,Y=setInterval(()=>{if(ce.current+=1,ce.current>Jy){me(!1);return}(async()=>{let se=await o.list(t);!R||ue.current!==t||(se.ok?(Q(se,void 0),se.probing!==!0&&c({kind:"status",text:n("keysProbeDone")})):me(!1))})()},Yy);return()=>{R=!1,clearInterval(Y)}},[Q,o,ae,t]),(0,re.useEffect)(()=>{let R=!0,Y=0,se=ye=>{let Ee=ye.detail,fe=Ee?.route;if(!R||ue.current!==t||fe!==void 0&&fe!==t)return;let Ie=++Y;if(typeof Ee?.openai=="string"&&typeof Ee.anthropic=="string"){oe({openai:Ee.openai||null,anthropic:Ee.anthropic||null});return}(async()=>{let Ue=o.endpoints!==void 0?await o.endpoints(t):await o.list(t);!R||ue.current!==t||Y!==Ie||Ue.ok&&oe(Ue.endpoints??Yu)})().catch(()=>{})};return document.addEventListener(kr,se),()=>{R=!1,document.removeEventListener(kr,se)}},[o,t]);let Se=()=>{v(void 0),E(""),F(""),U([]),y(void 0)},Ce=(0,re.useCallback)(async(R,Y)=>{let se=m,ye=t;b(!0),w(void 0);try{let Ee=await R();if(ue.current!==ye)return;Q(Ee,Y),Ee.ok&&se!==void 0&&se.kind!=="add"&&!Ee.entries.some(fe=>fe.ref===se.ref)&&Se()}finally{b(!1)}},[Q,m,t]),$=(R,Y)=>{v({kind:R,ref:Y.ref}),E(R==="alias"?Y.alias??"":""),F(""),U((Y.models??[]).filter(se=>s.includes(se))),y(void 0),w(void 0)},K=()=>{if(g||m===void 0)return;let R=m.kind,Y=m.ref;if(R!=="alias"&&R!=="scope"&&!Rt(N))return;let se=Sc(x),ye=T,Ee=t,fe=()=>ue.current!==Ee;b(!0),(async()=>{try{if(R==="add"){let Ue=new Set((i??[]).map(Me=>Me.ref)),ft=await o.add(t,N,se);if(fe())return;if(!ft.ok){Q(ft,n("keysAdded"));return}if(Q(ft,n("keysAdded")),Se(),ye===void 0)return;let Zt=ft.entries.find(Me=>Me.ref===ft.addedRef)??ft.entries.find(Me=>!Ue.has(Me.ref)),Tn=Zt===void 0?{ok:!1}:await o.setProtocol(t,Zt.ref,ye);fe()||Q(Tn,n("keysAdded"));return}if(Y===void 0)return;if(R==="scope"){let Ue=await o.setScope(t,Y,X.length===0?void 0:X);fe()||(Q(Ue,n("keysScopeSaved")),Ue.ok&&Se());return}let Ie=R==="alias"?await o.rename(t,Y,se):await o.replace(t,Y,N);fe()||(Q(Ie,n(R==="alias"?"keysRenamed":"keysReplaced")),Ie.ok&&Se())}finally{b(!1)}})()},z=R=>{U(Y=>Y.includes(R)?Y.filter(se=>se!==R):[...Y,R])},u=(0,re.useMemo)(()=>[...new Set(s)].sort(Zy.compare),[s]),S=(0,re.useMemo)(()=>new Set(X),[X]),P=()=>{if(m===void 0)return null;let R=m.kind,Y=R==="add"||R==="value",se=R==="scope",ye=R==="scope"&&m?.ref!==void 0?i?.find(fe=>fe.ref===m.ref)?.auto===!0:!1,Ee=Y&&N.length>0&&!Rt(N);return(0,W.jsxs)("div",{className:"bre-keys-form",children:[se?(0,W.jsx)("div",{className:"bre-keys-chips",role:"group","aria-label":n("keysScope"),children:u.length===0?(0,W.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeEmpty")}):u.map(fe=>{let Ie=S.has(fe);return(0,W.jsx)("button",{type:"button",className:Ie?"bre-keys-chip is-selected":"bre-keys-chip","aria-pressed":Ie,disabled:g,onClick:()=>z(fe),children:fe},fe)})}):(0,W.jsxs)("div",{className:"bre-keys-form-fields",children:[R==="value"?null:(0,W.jsx)("input",{className:"bre-text-input bre-keys-name",type:"text",value:x,placeholder:n("keysAliasPlaceholder"),"aria-label":n("keysAlias"),disabled:g,autoFocus:R==="alias",onChange:fe=>E(fe.target.value)}),Y?(0,W.jsx)("input",{className:"bre-text-input bre-keys-secret",type:"password",autoComplete:"new-password",spellCheck:!1,value:N,placeholder:n(R==="add"?"keysValuePlaceholder":"keysNewValuePlaceholder"),"aria-label":n("keysValue"),"aria-invalid":Ee,disabled:g,autoFocus:!0,onChange:fe=>F(fe.target.value)}):null]}),R==="add"?(0,W.jsx)("div",{className:"bre-keys-chips",role:"group","aria-label":n("keysProtocolCreate"),children:Ju(ie,void 0,n,r===!0).map(fe=>{let Ie=fe.value===""?void 0:fe.value,Ue=T===Ie;return(0,W.jsx)("button",{type:"button",className:Ue?"bre-keys-chip is-selected":"bre-keys-chip","aria-pressed":Ue,title:fe.hint,disabled:g,onClick:()=>y(Ie),children:fe.title},fe.value)})}):null,R==="add"?(0,W.jsx)("p",{className:"bre-keys-hint",children:n("keysProtocolCreateHint")}):null,se?(0,W.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeHint")}):null,se&&ye?(0,W.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeAutoHint")}):null,Ee?(0,W.jsx)("p",{className:"bre-effort-message bre-error",role:"alert",children:n("keysAddIllegal")}):null,(0,W.jsxs)("div",{className:"bre-keys-form-actions",children:[se?(0,W.jsx)("button",{type:"button",className:"bre-link-button bre-keys-allmodels",disabled:g,onClick:()=>U([]),children:n("keysScopeAll")}):null,(0,W.jsx)("button",{type:"button",className:"bre-link-button",disabled:g,onClick:Se,children:n("keysCancel")}),(0,W.jsx)("button",{type:"button",className:"bre-primary-button",disabled:g||Y&&!Rt(N),onClick:K,children:n(R==="add"?"keysAddConfirm":"keysSave")})]})]})},H=()=>m?.kind==="add"?(0,W.jsx)("li",{className:"bre-keys-form-row",children:P()}):(0,W.jsx)("li",{className:"bre-keys-add-row",children:(0,W.jsxs)("button",{type:"button",className:"bre-keys-add",disabled:g,onClick:()=>{v({kind:"add"}),E(""),F(""),U([]),w(void 0)},children:[(0,W.jsx)("span",{className:"bre-keys-add-mark","aria-hidden":"true",children:(0,W.jsx)(Cs,{paths:Gy})}),n("keysAdd")]})}),J=async R=>{if(D!==void 0)return;let Y=t;_(R.ref);try{let se=await o.reveal(t,R.ref);if(ue.current!==Y)return;if(se===void 0){c({kind:"error",text:n("keysCopyFailed")});return}let ye=await zy(se);if(ue.current!==Y)return;if(!ye){c({kind:"error",text:n("keysCopyFailed")});return}c(void 0),C(R.ref),B.current!==void 0&&clearTimeout(B.current),B.current=setTimeout(()=>{B.current=void 0,C(void 0)},jy)}finally{_(void 0)}},ne=(R,Y)=>{let se=Y===""?void 0:Y;ee(void 0),Ce(()=>o.setProtocol(t,R.ref,se),n("keysProtocolSaved"))},ve=te===void 0?void 0:i?.find(R=>R.ref===te.ref);if(i===void 0)return l===void 0?(0,W.jsx)("div",{className:"bre-keys","aria-busy":"true",children:f?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)("ul",{className:"bre-keys-list bre-keys-skeleton","aria-hidden":"true",children:[(0,W.jsxs)("li",{className:"bre-keys-skeleton-row",children:[(0,W.jsx)("span",{className:"bre-keys-skeleton-dot"}),(0,W.jsx)("span",{className:"bre-keys-skeleton-bar is-name"}),(0,W.jsx)("span",{className:"bre-keys-skeleton-bar is-mask"})]}),(0,W.jsx)("li",{className:"bre-keys-skeleton-row is-add",children:(0,W.jsx)("span",{className:"bre-keys-skeleton-bar"})})]}),(0,W.jsx)("p",{className:"bre-keys-sr",role:"status",children:n("keysLoading")})]}):null}):(0,W.jsxs)("div",{className:"bre-keys",children:[(0,W.jsx)("p",{className:"bre-effort-message bre-"+l.kind,role:l.kind==="error"?"alert":"status",children:l.text}),(0,W.jsx)("ul",{className:"bre-keys-list",children:H()})]});let Oe=i.reduce((R,Y)=>Y.enabled?R+1:R,0),_e=r===!0?null:(0,W.jsx)("button",{type:"button",className:"bre-link-button bre-keys-probe",disabled:g||ae||i.length<2,title:i.length<2?n("keysProbeSingle"):n("keysProbeHint"),onClick:()=>{Ce(()=>o.probe(t),void 0)},children:n(ae?"keysProbing":"keysProbe")});return(0,W.jsxs)("div",{className:"bre-keys",children:[_e===null?null:e.probeHost===void 0?(0,W.jsx)("div",{className:"bre-keys-probe-row",children:_e}):(0,Xu.createPortal)(_e,e.probeHost),(0,W.jsxs)("ul",{className:"bre-keys-list",children:[i.map(R=>{let Y=Vu(R),se=R.enabled&&Oe<=1;return(0,W.jsxs)(re.Fragment,{children:[(0,W.jsxs)("li",{className:R.enabled?"bre-keys-row":"bre-keys-row is-off","data-state":R.configured===!1?"missing":"ready",children:[(0,W.jsx)("button",{type:"button",className:R.enabled?"bre-keys-toggle is-on":"bre-keys-toggle","aria-pressed":R.enabled,"aria-label":n(R.enabled?"keysDisable":"keysEnable",{name:Y}),title:n(R.enabled?"keysDisable":"keysEnable",{name:Y}),disabled:g||se,onClick:()=>{Ce(()=>o.setEnabled(t,R.ref,!R.enabled),void 0)},children:(0,W.jsx)("span",{className:"bre-keys-toggle-mark","aria-hidden":"true",children:(0,W.jsx)(Cs,{paths:[$u]})})}),(0,W.jsxs)("span",{className:"bre-keys-value",children:[R.alias===void 0?null:(0,W.jsx)("span",{className:"bre-keys-alias",children:R.alias}),(0,W.jsx)("span",{className:R.alias===void 0?"bre-keys-mask bre-keys-mask-plain":"bre-keys-mask",children:$y(R,n)}),(0,W.jsx)("button",{type:"button",className:k===R.ref?"bre-keys-copy is-copied":"bre-keys-copy","aria-label":n("keysCopy",{name:Y}),title:k===R.ref?n("keysCopied"):n("keysCopy",{name:Y}),disabled:g||D===R.ref||R.configured===!1,onClick:()=>{J(R)},children:(0,W.jsx)(Cs,{paths:k===R.ref?[$u]:Uy})})]}),(0,W.jsx)("span",{className:M===R.ref?"bre-keys-actions is-confirming":"bre-keys-actions",children:M===R.ref?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("button",{type:"button",className:"bre-link-button bre-keys-danger",disabled:g,onClick:()=>{Ce(()=>o.remove(t,R.ref),n("keysRemoved"))},children:n("keysConfirmRemove")}),(0,W.jsx)("button",{type:"button",className:"bre-link-button",disabled:g,onClick:()=>w(void 0),children:n("keysCancel")})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("span",{className:"bre-keys-protocol-wrap",children:(0,W.jsxs)("button",{type:"button",className:"bre-keys-protocol","aria-haspopup":"listbox","aria-expanded":te?.ref===R.ref,"aria-label":n("keysProtocolLabel",{name:Y}),title:n("keysProtocolLabel",{name:Y}),disabled:g,onClick:ye=>{let Ee=ye.currentTarget;ee(fe=>fe?.ref===R.ref?void 0:{ref:R.ref,anchor:Ee}),w(void 0)},children:[(0,W.jsx)("span",{className:"bre-keys-protocol-label",children:Zu(R.protocol,n)}),(0,W.jsx)("span",{className:"bre-keys-protocol-caret","aria-hidden":"true",children:"\u203A"})]})}),r===!0?null:(0,W.jsx)("button",{type:"button",className:"bre-link-button bre-keys-scope",disabled:g,title:n("keysScope",{name:Y}),onClick:()=>$("scope",R),children:Vy(R,n)}),(0,W.jsx)("button",{type:"button",className:"bre-link-button",disabled:g,onClick:()=>$("alias",R),children:n("keysAlias")}),(0,W.jsx)("button",{type:"button",className:"bre-link-button",disabled:g,onClick:()=>$("value",R),children:n("keysEdit")}),(0,W.jsx)("button",{type:"button",className:"bre-link-button",disabled:g,onClick:()=>{w(R.ref),v(void 0)},children:n("keysRemove")})]})})]}),m!==void 0&&m.ref===R.ref?(0,W.jsx)("li",{className:"bre-keys-form-row",children:P()}):null]},R.ref)}),H()]}),r===!0?(0,W.jsx)("p",{className:"bre-keys-note",children:n("keysDraftHint")}):null,l===void 0?null:(0,W.jsx)("p",{className:"bre-effort-message bre-"+l.kind,role:l.kind==="error"?"alert":"status",children:l.text}),te===void 0||ve===void 0?null:(0,W.jsx)(zu,{anchor:te.anchor,label:n("keysProtocolLabel",{name:Vu(ve)}),options:Ju(ie,ve.protocol,n,r===!0),selected:ve.protocol??"",onPick:R=>ne(ve,R),onClose:()=>ee(void 0)})]})}var pn="bre-key-managed",nv="bre-keys-host",ef="bre-keys-probe-host",Hs="data-bre-key-host",rv="data-bre-key-input",ci="data-bre-region",zt=new WeakMap;function ov(e){let t=e.querySelector(`input[${rv}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function tf(e){let t=zt.get(e)?.host;if(t!==void 0&&t.isConnected)return t;let n=e.nextElementSibling;return n instanceof HTMLElement&&n.hasAttribute(Hs)?n:void 0}function nf(e,t){let n=t.route;if(n===void 0||n.length===0||ov(e)===void 0||e.parentElement===null)return;We(e,pn,!0);let r=zt.get(e),o=tf(e);o===void 0&&(r!==void 0&&rf(e,r),o=e.ownerDocument.createElement("div"),o.className=nv,e.after(o)),he(o,Hs,n);let i=e.getAttribute(ci);i===null?o.hasAttribute(ci)&&o.removeAttribute(ci):he(o,ci,i);let a=zt.get(e),s=a?.probeHost??e.ownerDocument.createElement("span");a===void 0&&(s.className=ef),s.parentElement!==e&&e.appendChild(s);let d=()=>(0,Rs.createElement)(Be,{fallbackText:t.t("keysPanelFailed")},(0,Rs.createElement)(li,{route:n,t:t.t,client:t.client,probeHost:s}));if(a!==void 0&&a.route===n){(a.t!==t.t||a.client!==t.client)&&(a.t=t.t,a.client=t.client,a.mount.root.render(d()));return}a!==void 0&&(zt.delete(e),a.mount.root.unmount()),zt.set(e,{route:n,host:o,probeHost:s,mount:Xe(o,d(),{sync:!0}),t:t.t,client:t.client})}function rf(e,t){zt.delete(e),Re(t.mount),t.probeHost.remove()}function ui(e){We(e,pn,!1);let t=zt.get(e);t!==void 0&&rf(e,t),tf(e)?.remove();for(let n of Array.from(e.children))n.classList.contains(ef)&&n.remove()}function of(){for(let e of Array.from(document.querySelectorAll(`[${Hs}]`))){let t=e.previousElementSibling;t instanceof HTMLElement&&zt.has(t)?ui(t):e.remove()}}var af="http://www.w3.org/2000/svg",iv="data-bre-icon";function av(e){let t=document.createElementNS(af,"path");return t.setAttribute("d",e),t}function fi(e,t){let n=document.createElementNS(af,"svg");return n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("width","16"),n.setAttribute("height","16"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.5"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),n.setAttribute(iv,e),n.append(...t.map(av)),n}var gn="bre-key-field",lf="bre-key-eye",Gr="data-bre-key-input",cf="data-bre-eye-show",uf="data-bre-eye-hide",sf=["M1.5 8S4 3.75 8 3.75 14.5 8 14.5 8 12 12.25 8 12.25 1.5 8 1.5 8Z","M6.2 8a1.8 1.8 0 1 0 3.6 0 1.8 1.8 0 0 0-3.6 0Z"],pi=new WeakMap,mn=new WeakMap;function mi(e){let t=e.querySelector(`input[${Gr}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function Os(e){for(let t of Array.from(e.children))if(t instanceof HTMLButtonElement&&t.classList.contains(lf))return t}function ff(e){let t=mi(e);t!==void 0&&(he(t,Gr,""),We(e,gn,!0))}function pf(e,t){let n=mi(e);if(n===void 0){Zn(e);return}pi.get(e)?.route!==t.route&&mn.delete(e),pi.set(e,t),he(n,Gr,""),We(e,gn,!0);let r=Os(e)??dv(e);he(r,cf,t.t("keyRevealShow")),he(r,uf,t.t("keyRevealHide")),Ns(r,n)}function Zn(e){let t=Os(e);t!==void 0&&t.remove(),pi.delete(e),We(e,gn,!1);let n=e.querySelector(`input[${Gr}]`);n instanceof HTMLInputElement&&(n.removeAttribute(Gr),n.type="password");let r=mn.get(e);mn.delete(e),r!==void 0&&n instanceof HTMLInputElement&&n.value===r&&Ur(n,"")}async function sv(e){try{let t=await fetch(`${po}?route=${encodeURIComponent(e)}`,{method:"GET",cache:"no-store",credentials:"same-origin"});if(!t.ok)return;let n=await t.json();return n===null||typeof n!="object"||n.ok!==!0?void 0:typeof n.key=="string"&&n.key.length>0?n.key:void 0}catch{return}}function Ns(e,t){let n=t.type!=="password";he(e,"aria-pressed",n?"true":"false");let r=e.getAttribute(n?uf:cf);r!==null&&(he(e,"aria-label",r),he(e,"title",r)),yt(e,t.disabled)}function Ur(e,t){let n=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");n?.set===void 0?e.value=t:n.set.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0}))}function dv(e){let t=document.createElement("button");t.type="button",t.className=lf,t.append(df("eye"),df("eye-off"));let n=async()=>{let r=mi(e),o=pi.get(e);if(r===void 0||o===void 0||t.hasAttribute("aria-busy"))return;if(r.type!=="password"){let a=mn.get(e);mn.delete(e),a!==void 0&&r.value===a&&Ur(r,""),r.type="password",Ns(t,r);return}let i=o.route;if(i!==void 0&&mn.get(e)===void 0&&r.value.length===0){he(t,"aria-busy","true");let a;try{a=await(o.loadKey??sv)(i)}catch{a=void 0}if(t.hasAttribute("aria-busy")&&t.removeAttribute("aria-busy"),a===void 0){let s=o.t("keyRevealFailed");he(t,"aria-label",s),he(t,"title",s);return}if(Os(e)!==t||!t.isConnected||mi(e)!==r||r.value.length>0)return;mn.set(e,a),Ur(r,a)}r.type="text",Ns(t,r)};return t.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation(),n()}),e.append(t),t}function df(e){let t=e==="eye-off"?[...sf,"M2.5 13.5 13.5 2.5"]:sf;return fi(e,t)}var Ps="bre-editor-tabs",lv="bre-editor-tab",gi="data-bre-tab-id",zr="bre-tabbed",Ot="data-bre-tab",mf="data-bre-provider",ct="data-bre-region",jr="data-bre-editor-body",rr="data-bre-footer",cv="row",uv="path",$r="data-bre-details";var fv=".bre-headers",pv=".bre-fingerprint",mv="data-bre-fingerprint",$t="provider",er="models",tr="fingerprint",nr="advanced",gv=[$t,er,nr,tr],hv="none",gf=gv,hf=Ps,bf=lv,yf=gi,hi='[class*="editorActions"], [class*="modelList"], [class*="modelCatalog"], [class*="modelEntry"]',bv='[class*="modelCatalog"], [class*="modelList"], [class*="modelEntry"]',vf='[class*="rowCard"], [class*="addCard"], li',yv='[class*="addPanel"]',Is=".bre-create-host";function wf(){return{warned:new WeakSet}}function or(e){return e===null?null:e.closest(vf)}function xf(e){let t=or(e);return t!==null&&t.querySelector(Is)!==null}function kf(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.matches(yv)&&!t.hidden)return t;return e}function Ef(e,t){if(e.getAttribute(Ot)===t){Ds(e);return}let n=Go(e),r=e.getBoundingClientRect().top,o=n?.scrollTop??0;n!==void 0&&(n.style.overflowAnchor="none"),he(e,Ot,t),Ds(e),n!==void 0&&requestAnimationFrame(()=>{if(n.style.overflowAnchor="",n.scrollTop!==o)return;let i=e.getBoundingClientRect().top-r;i!==0&&(n.scrollTop+=i)})}function _s(e,t,n){if(!e.isConnected)return;let r=new Set;for(let o of Array.from(e.querySelectorAll(hi))){let i=o.closest(vf);i!==null&&r.add(i)}for(let o of Array.from(e.querySelectorAll(`.${zr}`)))r.has(o)||bi(o);for(let o of r)try{Tv(o,t)}catch(i){n.warned.has(o)||(n.warned.add(o),console.warn("[bre] editor tabs: rolled a provider card back to the official layout:",i)),bi(o)}}function Tf(){for(let e of Array.from(document.querySelectorAll(`.${zr}`))){e.classList.remove(zr),e.removeAttribute(Ot),e.removeAttribute(jr);for(let t of Array.from(e.querySelectorAll(`[${ct}]`)))t.removeAttribute(ct)}for(let e of Array.from(document.querySelectorAll(`[${Ot}]`)))e.removeAttribute(Ot);for(let e of Array.from(document.querySelectorAll(`[${ct}]`)))e.removeAttribute(ct);for(let e of Array.from(document.querySelectorAll(`[${jr}]`)))e.removeAttribute(jr);for(let e of Array.from(document.querySelectorAll(`[${rr}]`)))e.removeAttribute(rr);for(let e of Array.from(document.querySelectorAll(`details[${$r}]`)))e.removeAttribute("open"),e.removeAttribute($r);for(let e of Array.from(document.querySelectorAll(`.${gn}`)))Zn(e);for(let e of Array.from(document.querySelectorAll(`.${pn}`)))ui(e);of()}function vv(e){for(let n of Array.from(e.children))if(n instanceof HTMLElement&&!n.matches('[class*="editorHeader"], [class*="editorTitle"], [class*="editorActions"], [class*="editorRoute"]')&&n.matches('[class*="editor"]')&&(n.querySelector(hi)!==null||n.querySelector("input, select")!==null))return n;let t=e.querySelector(hi);for(;t!==null&&t.parentElement!==e;)t=t.parentElement;return t!==null&&t!==e?t:void 0}function wv(e){let t={header:void 0,models:void 0,actions:void 0,fields:[]};Sf(e,t,0);let{actions:n,fields:r,header:o,models:i}=t;if(!(n===void 0||r.length===0)&&r.some(a=>a.querySelector("input, select, textarea")!==null))return{header:o,models:i,actions:n,fields:r}}var xv=4;function Sf(e,t,n){if(!(n>xv)){for(let r of Array.from(e.children))if(r instanceof HTMLElement&&!r.matches('[class*="bre-"], [data-plugin]')){if(t.header===void 0&&r.matches('[class*="editorHeader"], [class*="editorTitle"]')){t.header=r;continue}if(r.matches('[class*="editorActions"]')){t.actions??(t.actions=r);continue}if(r.matches(bv)){t.models??(t.models=r);continue}if(r.querySelector(hi)!==null){Sf(r,t,n+1);continue}if(r.querySelector('[class*="editorActions"]')!==null){t.actions??(t.actions=r);continue}if(r.querySelector("input, select, textarea")!==null){t.fields.push(r);continue}(r.matches("p, small, em, i")||r.matches('[class*="Hint"], [class*="error"]'))&&t.fields.push(r)}}}function kv(e,t){if(!t.contains(e))return;he(e,rr,cv);let n=e.parentElement;for(;n!==null&&(he(n,rr,uv),n!==t);)n=n.parentElement}function Ev(e){let n=e.querySelector(`[${mf}]`)?.getAttribute(mf);return n==null||n===""?void 0:n}function Tv(e,t){let n=kf(e),r=vv(n);if(r===void 0){bi(e);return}let o=wv(r);if(o===void 0){bi(e);return}let i=Array.from(n.querySelectorAll(fv)),a=i[0]??null,s=Ev(n);for(let h of o.fields)he(h,ct,$t),pf(h,{t:t.t,route:s}),nf(h,{t:t.t,route:s});o.header!==void 0&&he(o.header,ct,hv),o.models!==void 0&&he(o.models,ct,er),he(r,jr,""),n.querySelector(Is)!==null&&kv(o.actions,r);for(let h of i)he(h,ct,nr);let d=n.querySelector(pv);d!==null&&he(d,ct,tr),Mv(r);let l=new Set([$t]);o.models!==void 0&&l.add(er),a!==null&&l.add(nr);let c=n.querySelector(Is)!==null;d!==null&&!c&&d.getAttribute(mv)==="ready"&&l.add(tr);let f=e.getAttribute(Ot)??$t;he(e,Ot,l.has(f)?f:$t),We(e,zr,!0),Sv(e,n,t,l)}function Sv(e,t,n,r){let o=t.querySelector(`.${Ps}`);o!==null&&(he(o,"aria-label",n.t("editorTabsLabel")),Rr(hn(o,$t),n.t("editorTabProvider")),Rr(hn(o,er),n.t("editorTabModels")),Rr(hn(o,nr),n.t("editorTabAdvanced")),Rr(hn(o,tr),n.t("editorTabFingerprint")),yt(hn(o,er),!r.has(er)),yt(hn(o,nr),!r.has(nr)),yt(hn(o,tr),!r.has(tr)),Ds(e,o))}function Ds(e,t){let n=t??kf(e).querySelector(`.${Ps}`);if(n===null)return;let r=e.getAttribute(Ot)??$t;for(let o of Array.from(n.querySelectorAll(`[${gi}]`)))he(o,"aria-selected",o.getAttribute(gi)===r?"true":"false")}function hn(e,t){for(let n of Array.from(e.children))if(n instanceof HTMLElement&&n.getAttribute(gi)===t)return n}function bi(e){e.classList.remove(zr),e.removeAttribute(Ot),e.removeAttribute(jr);for(let t of Array.from(e.querySelectorAll(`[${ct}]`)))t.getAttribute(ct)===$t&&(Zn(t),ui(t)),t.removeAttribute(ct);for(let t of Array.from(e.querySelectorAll(`[${rr}]`)))t.removeAttribute(rr);Lv(e)}function Mv(e){for(let t of Array.from(e.querySelectorAll("details")))t.hasAttribute("open")||(he(t,$r,"closed"),he(t,"open",""))}function Lv(e){for(let t of Array.from(e.querySelectorAll(`details[${$r}]`)))t.removeAttribute("open"),t.removeAttribute($r)}var fp=require("react");var et=require("react");var Te=require("react");var Av='p[class*="savedNotice"]',Af="data-bre-saved-hidden",Cv="bre-auto-effort-note",Rv="data-bre-auto-effort-phase",Mf="bre-auto-effort-note-text",ir=new Map,Lf=new WeakMap,ar=null,yi=null;function Cf(e){let t=Array.from(e.querySelectorAll(Av));for(let n of t){let r=n.textContent?.trim()??"";Lf.get(n)!==r&&(Lf.set(n,r),r.length>0&&Of(r)),!ir.has(n)&&(ir.set(n,n.style.display),n.setAttribute(Af,""),n.style.display="none")}for(let[n,r]of Array.from(ir))n.isConnected&&t.includes(n)||(Hf(n,r),ir.delete(n))}function Rf(){for(let[e,t]of Array.from(ir))Hf(e,t);ir.clear(),Fs()}function Hf(e,t){e.style.display=t,e.removeAttribute(Af)}function Nf(e){Of(e)}function Of(e){if(ar!==null&&ar.isConnected&&ar.textContent===e)return;Fs();let t=document.createElement("div");t.className=Cv,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute(Rv,"done"),t.innerHTML=`<span class="${Mf}"></span>`;let n=t.querySelector(`.${Mf}`);n!==null&&(n.textContent=e),t.style.setProperty("--bre-note-hold","3000ms"),document.body.append(t),ar=t,yi=setTimeout(()=>{Fs()},3e3)}function Fs(){yi!==null&&(clearTimeout(yi),yi=null),ar?.remove(),ar=null}var bn="data-bre-settle",If='[class*="rowActions"] > button:not(.bre-provider-switch):not(.bre-provider-delete)';var Lt=null,Ks=0,vi=0,Vr=!1,sr=null;function Df(e){return e.className.includes("dangerButton")?"remove":"edit"}function qs(e,t){return Array.from(e.querySelectorAll(If)).find(r=>Df(r)===t)??null}function Hv(e){return typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function Nv(e){typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):clearTimeout(e)}function Pf(e=document){Yr();let t=[];for(let n of Array.from(e.querySelectorAll(If))){if(n.disabled)continue;let r=n.closest("li")??n.parentElement;if(r===null)continue;let o=Df(n);t.some(i=>i.row===r&&i.role===o)||t.push({row:r,role:o})}t.length!==0&&(Lt=t,vi=Date.now(),Ks=vi+8e3,Ov(),_f())}function Bs(){if(Lt===null)return;let e=Date.now();if(e>Ks){Yr();return}let t=0;if(Lt=Lt.filter(n=>{if(!n.row.isConnected)return!1;let r=qs(n.row,n.role);return r===null||(r.disabled?(Vr=!0,t+=1,r.hasAttribute(bn)||r.setAttribute(bn,"")):Vr&&r.hasAttribute(bn)&&r.removeAttribute(bn)),!0}),Vr&&t===0){Yr();return}if(!Vr&&e-vi>1500){Yr();return}_f()}function _f(){sr!==null||Lt===null||(sr=Hv(()=>{sr=null,Bs()}))}function Ov(){if(Lt!==null)for(let e of Lt){let t=qs(e.row,e.role);t!==null&&!t.hasAttribute(bn)&&t.setAttribute(bn,"")}}function Ff(){Yr()}function Yr(){if(sr!==null&&(Nv(sr),sr=null),Lt!==null)for(let e of Lt){let t=qs(e.row,e.role);t!==null&&t.removeAttribute(bn)}Lt=null,Vr=!1,Ks=0,vi=0}var Z=require("react/jsx-runtime"),Iv=["claude-cli/2.1.161 (external, cli)","claude-code/1.0.0","Kilo-Code/1.0"];function Kf(e,t){let n=()=>t.current+=1,r=Object.entries(e??{}).map(([o,i])=>({id:n(),name:o,value:i}));return r.length===0&&r.push({id:n(),name:"",value:""}),{rows:r}}function qf(e){let t={},n=!1;for(let o of e.rows){let i=o.name.trim();i.length!==0&&(t[i]=o.value,i.toLowerCase()==="user-agent"&&(n=!0))}let r=e.userAgent?.trim();return!n&&r!==void 0&&r.length>0&&(t["user-agent"]=r),t}function Dv(e,t){let n=e??{},r=Object.keys(n);return r.length!==Object.keys(t).length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&t[o]===n[o])}function wi({route:e,api:t,t:n,onDismiss:r,deferred:o,extras:i,onCommitExtras:a,onResetExtras:s}){let d=(0,Te.useId)(),[l,c]=(0,Te.useState)(void 0),[f,h]=(0,Te.useState)({rows:[]}),[p,g]=(0,Te.useState)(!1),[b,m]=(0,Te.useState)(!1),[v,x]=(0,Te.useState)(!0),[E,N]=(0,Te.useState)(!1),[F,X]=(0,Te.useState)(!1),[U,T]=(0,Te.useState)(void 0),[y,M]=(0,Te.useState)(void 0),[w,k]=(0,Te.useState)(!1),C=(0,Te.useRef)(0),D=(0,Te.useRef)(null),_=o!==void 0,B=o?.onDraft,te=(0,Te.useRef)(void 0);(0,Te.useEffect)(()=>{if(_&&te.current!==void 0)return;te.current=e;let $=!0;return(async()=>{try{let K=await le(t);if(!$)return;let z=Pa(K.namespace,e);c(z),h(Kf(z,C)),X(K.writable!==!0)}catch{$&&X(!0)}finally{$&&x(!1)}})(),()=>{$=!1}},[t,e,_]),(0,Te.useEffect)(()=>{B!==void 0&&B(qf(f))},[f,B]),(0,Te.useEffect)(()=>{let $=!0;return(async()=>{try{let z=await(await fetch(Od,{method:"GET"})).json();$&&z.ok===!0&&z.data!==void 0&&M(z.data)}catch{}})(),()=>{$=!1}},[]),(0,Te.useEffect)(()=>{let $=D.current;if($===null)return;let K=()=>{k($.dataset.breRegion==="advanced")};K();let z=new MutationObserver(K);return z.observe($,{attributes:!0,attributeFilter:["data-bre-region"]}),()=>{z.disconnect()}},[]);let ee=()=>{h($=>({...$,rows:[...$.rows,{id:C.current+=1,name:"",value:""}]})),T(void 0)},ie=($,K)=>{h(z=>({...z,rows:z.rows.map(u=>u.id===$?{...u,...K}:u)})),T(void 0)},oe=$=>{h(K=>({...K,rows:K.rows.filter(z=>z.id!==$)})),T(void 0)},ae=()=>{h({rows:[{id:C.current+=1,name:"",value:""}]}),T(void 0)},me=()=>{if(s?.(),h(Kf(l,C)),m(!1),T(void 0),o!==void 0){o.onCancel();return}w&&r?.()},ge=async $=>{if(N(!0),T(void 0),!Dv(l,$)){Pf();let S;try{S=await Lr(t,e,$)}catch(P){S={ok:!1,error:P instanceof Error?P.message:String(P)}}if(!S.ok){N(!1),T({kind:"error",text:S.error==="no-route"?n("headersNoRoute"):S.error==="read-only"?n("headersReadOnly"):n("headersError",{error:S.error})});return}c($)}if(m(!1),a!==void 0)try{await a()}catch{N(!1),T({kind:"error",text:n("camouflageError")});return}N(!1);let z=Object.keys(l??{}).length>0,u=Object.keys($).length===0&&z?n("headersCleared"):n("headersSaved");if(w){Nf(u),r?.();return}T({kind:"success",text:u})},ce=Object.entries(l??{}),Q=F||E,ue=w||_,ke=b||ue?f.rows.filter($=>$.name.trim().length>0).length:ce.length,Se=f.rows.some($=>$.name.trim().length>0||$.value.length>0),Ce=p||b||ue;return(0,Z.jsxs)("div",{className:"bre-headers",ref:D,"data-plugin":we,"data-open":p?"1":"0",children:[(0,Z.jsx)("div",{className:"bre-headers-head",children:b||ue?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)("span",{className:"bre-effort-title",children:n("headersTitle")}),ke===0?null:(0,Z.jsx)("span",{className:"bre-headers-count",children:ke}),F||!Se?null:(0,Z.jsx)("button",{type:"button",className:"bre-headers-clear",disabled:Q,onClick:ae,children:n("headersClear")})]}):(0,Z.jsxs)("button",{type:"button",className:"bre-headers-disclosure","aria-expanded":p,"aria-label":`${n("headersTitle")} ${e}`,onClick:()=>{g(!p),T(void 0)},children:[(0,Z.jsx)("span",{className:"bre-effort-title",children:n("headersTitle")}),v||ke===0?null:(0,Z.jsx)("span",{className:"bre-headers-count",children:ke}),(0,Z.jsx)("span",{className:"bre-headers-chevron","aria-hidden":"true",children:"\u203A"})]})}),Ce?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)("p",{className:"bre-effort-note",children:n("headersHint")}),y===void 0?null:(0,Z.jsxs)(Z.Fragment,{children:[y.environment.preferOfficialLayer?(0,Z.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictPatched")}):null,y.conflicts.length===0&&(y.headerConflicts?.length??0)===0?null:(0,Z.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictOrigin")}),y.environment.siblings.length===0?null:(0,Z.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictSiblings",{names:y.environment.siblings.map($=>$.name).join(", ")})})]}),v?null:b||ue?(0,Z.jsxs)("div",{className:"bre-headers-edit",children:[(0,Z.jsxs)("div",{className:"bre-headers-columns","aria-hidden":"true",children:[(0,Z.jsx)("span",{children:n("headersName")}),(0,Z.jsx)("span",{children:n("headersValue")}),(0,Z.jsx)("span",{})]}),f.rows.map($=>(0,Z.jsxs)("div",{className:"bre-headers-row",children:[(0,Z.jsx)("input",{type:"text",className:"bre-text-input bre-headers-name",value:$.name,disabled:Q,placeholder:n("headersNamePlaceholder"),"aria-label":n("headersName"),onChange:K=>{ie($.id,{name:K.target.value})}}),(0,Z.jsx)("input",{type:"text",className:"bre-text-input bre-headers-value",value:$.value,disabled:Q,list:$.name.trim().toLowerCase()==="user-agent"?d:void 0,placeholder:n("headersValue"),"aria-label":n("headersValue"),onChange:K=>{ie($.id,{value:K.target.value})}}),(0,Z.jsx)("button",{type:"button",className:"bre-headers-remove",disabled:Q,"aria-label":`${n("headersRemove")} ${$.name}`,title:n("headersRemove"),onClick:()=>{oe($.id)},children:"\xD7"})]},$.id)),(0,Z.jsx)("button",{type:"button",className:"bre-headers-add",disabled:Q,onClick:ee,children:n("headersAdd")}),(0,Z.jsx)("datalist",{id:d,children:Iv.map($=>(0,Z.jsx)("option",{value:$},$))})]}):(0,Z.jsxs)("div",{className:"bre-headers-rows",children:[ce.length===0?(0,Z.jsx)("p",{className:"bre-effort-note",children:n("headersEmpty")}):ce.map(([$,K])=>(0,Z.jsxs)("div",{className:"bre-headers-row",children:[(0,Z.jsx)("span",{className:"bre-headers-name",children:$}),(0,Z.jsx)("span",{className:"bre-headers-value bre-headers-masked",children:"\u2022".repeat(Math.min(K.length,24))})]},$)),F?null:(0,Z.jsx)("div",{className:"bre-effort-actions",children:(0,Z.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:Q,onClick:()=>{m(!0),T(void 0)},children:n("headersEdit")})})]})]}):null,!v&&(ue||b)?(0,Z.jsxs)(Z.Fragment,{children:[i,(0,Z.jsxs)("div",{className:"bre-effort-actions bre-headers-actions",children:[(0,Z.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:E,onClick:me,children:n("headersCancel")}),_?null:(0,Z.jsx)("button",{type:"button",className:"bre-primary-button",disabled:Q,onClick:()=>{ge(qf(f))},children:n("headersSave")})]})]}):null,U===void 0?null:(0,Z.jsx)("p",{className:"bre-effort-message bre-"+U.kind,role:U.kind==="error"?"alert":"status",children:U.text})]})}var Ae=require("react");var Ze=require("react/jsx-runtime"),Pv=[{value:void 0,labelKey:"camouflageOff"},{value:"codex",labelKey:"camouflageCodex"},{value:"claude",labelKey:"camouflageClaude"}];function _v(e){return e==="codex"||e==="claude"}function Bf(e){let t=e.data;if(typeof t!="object"||t===null)return;let n=t,r={},o=n.providers;if(typeof o=="object"&&o!==null&&!Array.isArray(o))for(let[i,a]of Object.entries(o))_v(a)&&(r[i]=a);return{presets:["codex","claude"],providers:r,installed:n.installed===!0}}function Ws({t:e,value:t,installed:n,disabled:r=!1,onChange:o}){let i=(0,Ae.useId)(),a=`${i}-title`,s=`${i}-hint`;return(0,Ze.jsxs)("div",{className:"bre-camouflage","data-plugin":we,"data-open":"1",title:e("camouflageHint"),children:[(0,Ze.jsx)("span",{className:"bre-effort-title",id:a,children:e("camouflageTitle")}),(0,Ze.jsx)("div",{className:"bre-camouflage-options",role:"radiogroup","aria-labelledby":a,"aria-describedby":s,children:Pv.map(d=>(0,Ze.jsx)("button",{type:"button",role:"radio","aria-checked":t===d.value,className:"bre-camouflage-option","data-active":t===d.value?"1":"0",disabled:r,onClick:()=>{o(d.value)},children:e(d.labelKey)},d.value??"off"))}),(0,Ze.jsx)("span",{className:"bre-sr-only",id:s,children:e("camouflageHint")}),n?null:(0,Ze.jsx)("p",{className:"bre-camouflage-warn",children:e("camouflageUnavailable")})]})}function Gs(e,t){let[n,r]=(0,Ae.useState)(void 0),[o,i]=(0,Ae.useState)(void 0),[a,s]=(0,Ae.useState)(!0),[d,l]=(0,Ae.useState)(!0),c=(0,Ae.useRef)(void 0),f=(0,Ae.useRef)(void 0),h=(0,Ae.useRef)(!0);(0,Ae.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]),(0,Ae.useEffect)(()=>{if(e===""){l(!1);return}let m=!1;return l(!0),fetch(na,{method:"GET"}).then(async v=>await v.json()).then(v=>{if(m||!h.current)return;let x=Bf(v);if(x===void 0)return;let E=x.providers[e];c.current=E,f.current=E,r(E),i(E),s(x.installed)}).catch(()=>{}).finally(()=>{!m&&h.current&&l(!1)}),()=>{m=!0}},[e]);let p=(0,Ae.useCallback)(m=>{f.current=m,i(m)},[]),g=(0,Ae.useCallback)(()=>{f.current=c.current,i(c.current)},[]),b=(0,Ae.useCallback)(async m=>{let v=m===void 0?f.current:m.preset;if(e===""||v===c.current)return;let x=await fetch(na,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({route:e,preset:v??null})}),E=await x.json();if(!x.ok||E.ok!==!0)throw new Error("camouflage write rejected");let N=Bf(E);c.current=v,f.current=v,r(v),i(v),N!==void 0&&s(N.installed)},[e]);return{value:o,saved:n,installed:a,loading:d,setValue:p,reset:g,commit:b}}function Wf({route:e,t}){let n=Gs(e,t),[r,o]=(0,Ae.useState)(void 0),i=(0,Ae.useCallback)(a=>{n.setValue(a),o(void 0),n.commit({preset:a}).then(()=>{o(void 0)}).catch(()=>{n.setValue(void 0),o({kind:"error",text:t("camouflageError")})})},[n,t]);return(0,Ze.jsxs)(Ze.Fragment,{children:[(0,Ze.jsx)(Ws,{t,value:n.value,installed:n.installed,disabled:n.loading||e==="",onChange:i}),r===void 0?null:(0,Ze.jsx)("p",{className:"bre-effort-message bre-"+r.kind,role:r.kind==="error"?"alert":"status",children:r.text})]})}var Us=require("react");var Fv={provider:"editorTabProvider",models:"editorTabModels",fingerprint:"editorTabFingerprint",advanced:"editorTabAdvanced"};function xi({host:e,t}){return(0,Us.createElement)("div",{className:hf,role:"tablist","aria-label":t("editorTabsLabel")},...gf.map(n=>(0,Us.createElement)("button",{key:n,type:"button",role:"tab",className:bf,[yf]:n,onClick:r=>{r.preventDefault(),r.stopPropagation();let o=or(e.current);o!==null&&Ef(o,n)}},t(Fv[n]))))}var Kv=15e3;function Uf(){return{intents:new Map,baseline:new Map,flushing:!1}}function js(e,t,n){if(t.length===0)return;let r={...n};if(Object.keys(r).length===0){e.intents.delete(t);return}let o=e.intents.get(t);if(o===void 0){e.intents.set(t,{headers:r,declaredBefore:e.baseline.get(t)});return}o.headers=r}function zs(e,t){e.intents.delete(t)}function jf(e,t){let n=e.intents.get(t);n!==void 0&&(n.releasedAt=Date.now())}function zf(e,t,n){if(t.length===0)return;e.baseline.set(t,n);let r=e.intents.get(t);r!==void 0&&(r.declaredBefore=n)}function $f(e,t){return t.length>0&&!e.baseline.has(t)}async function Vf(e,t){if(e.flushing)return Gf(e);if(e.intents.size===0)return 0;e.flushing=!0;try{let n=await le(t),r,o=async a=>st(n.namespace,a)?!0:(r??(r=await le(t,{fresh:!0})),st(r.namespace,a)),i=Date.now();for(let[a,s]of Array.from(e.intents)){if(s.declaredBefore===void 0){s.releasedAt!==void 0&&s.noted!==!0&&(s.noted=!0,console.warn("[bre] deferred request headers: nobody said whether this id existed before, so the draft is held:",a));continue}if(s.declaredBefore){e.intents.delete(a);continue}if(!await o(a)){s.releasedAt!==void 0&&i-s.releasedAt>Kv?(e.intents.delete(a),console.info("[bre] deferred request headers: gave up on a draft whose card closed first:",a)):s.releasedAt!==void 0&&console.info("[bre] deferred request headers: waiting for the closed card to declare",a);continue}console.info("[bre] deferred request headers: the route is declared, writing the held draft:",a);let d;try{d=await Lr(t,a,s.headers)}catch(l){d={ok:!1,error:l instanceof Error?l.message:String(l)}}if(d.ok){e.intents.delete(a),console.info("[bre] deferred request headers: saved",a,Object.keys(s.headers).length,"header(s)");continue}d.error!=="no-route"&&(e.intents.delete(a),console.error("[bre] deferred request headers: the write was refused:",d.error,a))}}catch(n){console.error("[bre] deferred request headers: could not read the settings document:",n)}finally{e.flushing=!1}return Gf(e)}function Gf(e){let t=0;for(let n of e.intents.values())n.releasedAt!==void 0&&(t+=1);return t}var Vt=require("react/jsx-runtime");function Jf({host:e,api:t,t:n,routeIdLabels:r,staged:o}){let[i,a]=(0,et.useState)(()=>Jr(e.current,r)),s=(0,et.useRef)(i),d=(0,et.useRef)(void 0),l=(0,et.useRef)(new Set),c=(0,et.useRef)(!1),f=(0,et.useRef)(null);return f.current===null&&(f.current={onDraft:h=>{d.current=h;let p=s.current;if(p.length===0){!c.current&&Object.keys(h).length>0&&(c.current=!0,console.info("[bre] deferred request headers: holding a draft until the provider id is typed"));return}js(o,p,h),Yf(t,o,p,l.current)},onCancel:()=>{d.current=void 0,zs(o,s.current)}}),(0,et.useEffect)(()=>{let h=ki(e.current);if(h===null)return;let p=()=>{a(Jr(e.current,r))};return h.addEventListener("input",p,!0),()=>{h.removeEventListener("input",p,!0)}},[e,r]),(0,et.useEffect)(()=>{i.length>0&&Yf(t,o,i,l.current)},[t,o,i]),(0,et.useEffect)(()=>{let h=s.current;if(h===i)return;zs(o,h),s.current=i;let p=d.current;p!==void 0&&i.length>0&&js(o,i,p)},[i,o]),(0,et.useEffect)(()=>()=>{jf(o,s.current)},[o]),(0,Vt.jsxs)(Vt.Fragment,{children:[(0,Vt.jsx)(xi,{host:e,t:n}),(0,Vt.jsx)(wi,{route:i,api:t,t:n,deferred:f.current,extras:(0,Vt.jsx)(Wf,{route:i,t:n})})]})}function Yf(e,t,n,r){!$f(t,n)||r.has(n)||(r.add(n),(async()=>{try{let o=await le(e);zf(t,n,st(o.namespace,n))}catch(o){r.delete(n),console.warn("[bre] deferred request headers: could not read the settings document for this route:",o)}})())}function ki(e){let t=e?.parentElement;return t==null?null:t.parentElement?.closest('[class*="addCard"]')??t}function Jr(e,t){let n=e?.parentElement;if(n==null)return"";let r=t(),o=Qe(n,r).trim();if(o.length>0)return o;let i=ki(e);return i===null||i===n?"":Qe(i,r).trim()}var Js=require("react");var tt=require("react");var Xr=15e3,qv=3;function Qf(){return{intents:new Map,baseline:new Map,baselinePending:new Set,baselineFailures:new Set,activeIntents:new Map,draining:!1,drainAgain:!1}}function $s(e,t,n){if(t.length===0)return;if(n.length===0){Vs(e,t);return}let r=e.intents.get(t);if(r===void 0){let o=e.activeIntents.get(t);e.intents.set(t,{drafts:[...n],landed:o?.landed??[],revision:0,declaredBefore:e.baseline.get(t),attempts:0}),e.draining&&(e.drainAgain=!0);return}Bv(r.drafts,n)||(r.drafts=[...n],r.revision+=1,r.baselineMissing=!1,e.draining&&(e.drainAgain=!0))}function Bv(e,t){return e.length===t.length&&e.every((n,r)=>{let o=t[r];return o!==void 0&&n.ref===o.ref&&n.value===o.value&&n.alias===o.alias&&n.protocol===o.protocol&&n.enabled===o.enabled})}function Vs(e,t){e.intents.delete(t),e.draining&&(e.drainAgain=!0)}function Zf(e,t){let n=e.intents.get(t);n!==void 0&&(n.releasedAt=Date.now())}function Ys(e,t,n){if(t.length===0)return;e.baseline.has(t)||e.baseline.set(t,n),e.baselinePending.delete(t),e.baselineFailures.delete(t);let r=e.intents.get(t);r!==void 0&&(r.declaredBefore=e.baseline.get(t),r.baselineMissing=!1),e.draining&&(e.drainAgain=!0)}function ep(e,t){return Wv(e,t)?(e.baselinePending.add(t),!0):!1}function tp(e,t){e.baselinePending.delete(t),e.baseline.has(t)||e.baselineFailures.add(t),e.draining&&(e.drainAgain=!0)}function Wv(e,t){return t.length>0&&!e.baseline.has(t)&&!e.baselinePending.has(t)&&!e.baselineFailures.has(t)}async function np(e,t,n){if(e.draining)return Xf(e);if(e.intents.size===0)return 0;e.draining=!0;try{do{e.drainAgain=!1;let r=await le(t),o,i=async s=>st(r.namespace,s)?!0:(o??(o=await le(t,{fresh:!0})),st(o.namespace,s)),a=Date.now();for(let[s,d]of Array.from(e.intents)){if(e.intents.get(s)!==d)continue;let l=d.revision;e.activeIntents.set(s,d);try{if(d.declaredBefore===void 0){if(e.baselinePending.has(s)){d.releasedAt!==void 0&&a-d.releasedAt>Xr&&(e.intents.delete(s),console.error("[bre] deferred api keys: the pre-save baseline timed out; refusing to write held keys:",s));continue}if(e.baselineFailures.has(s)){let h=await i(s);if(e.intents.get(s)!==d)continue;if(d.revision!==l||d.declaredBefore!==void 0){e.drainAgain=!0;continue}h?(d.baselineMissing=!0,d.noted!==!0&&(d.noted=!0,console.error("[bre] deferred api keys: the pre-save baseline failed and this route now exists; refusing to guess ownership:",s)),d.releasedAt!==void 0&&a-d.releasedAt>Xr&&(e.intents.delete(s),console.error("[bre] deferred api keys: the pre-save baseline remained unknown; refusing to write held keys:",s))):(Ys(e,s,!1),d.releasedAt!==void 0&&a-d.releasedAt>Xr&&(e.intents.delete(s),console.info("[bre] deferred api keys: gave up on drafts whose card closed first:",s)));continue}d.baselineMissing=!0,d.noted!==!0&&(d.noted=!0,console.error("[bre] deferred api keys: no pre-save baseline is available; refusing to write held keys:",s)),d.releasedAt!==void 0&&a-d.releasedAt>Xr&&e.intents.delete(s);continue}if(d.declaredBefore){e.intents.delete(s);continue}let c=await i(s);if(e.intents.get(s)!==d)continue;if(d.revision!==l){e.drainAgain=!0;continue}if(!c){d.releasedAt!==void 0&&a-d.releasedAt>Xr&&(e.intents.delete(s),console.info("[bre] deferred api keys: gave up on drafts whose card closed first:",s));continue}let f=await Gv(e,s,d,n);if(e.intents.get(s)!==d||d.revision!==l)continue;f&&(e.intents.delete(s),console.info("[bre] deferred api keys: the route is declared, saved the held key list:",s))}finally{e.activeIntents.get(s)===d&&e.activeIntents.delete(s)}}}while(e.drainAgain&&e.intents.size>0)}catch(r){console.error("[bre] deferred api keys: could not read the settings document:",r)}finally{e.draining=!1}return Xf(e)}async function Gv(e,t,n,r){let o=n.revision,i=[...n.drafts],a=!1,s=!1,d=()=>e.intents.get(t)!==n?!0:n.revision!==o?(e.drainAgain=!0,!0):!1,l=()=>{a=!0,n.attempts+=1};for(let c of i){if(d())return!1;let f=n.landed.find(h=>h.ref===c.ref);if(f===void 0){let h=await r.add(t,c.value,c.alias);if(!h.ok){if(d())return!1;l();break}let g=(h.addedRef!==void 0&&h.entries.some(E=>E.ref===h.addedRef)?h.addedRef:void 0)??h.entries.map(E=>E.ref).find(E=>!n.landed.some(N=>N.hostRef===E));if(g===void 0){if(d())return!1;l();break}let b=h.entries.find(E=>E.ref===g),{alias:m,protocol:v,...x}=c;if(f={ref:c.ref,hostRef:g,draft:{...x,...b?.alias===void 0?{}:{alias:b.alias},...b?.protocol===void 0?{}:{protocol:b.protocol},enabled:b?.enabled??!0}},n.landed.push(f),s=!0,d())return!1;continue}if(f.draft.value!==c.value){if(!(await r.replace(t,f.hostRef,c.value)).ok){if(d())return!1;l();break}if(f.draft={...f.draft,value:c.value},s=!0,d())return!1}if(f.draft.alias!==c.alias){let{alias:h,...p}=f.draft;if(!(await r.rename(t,f.hostRef,c.alias)).ok){if(d())return!1;l();break}if(f.draft={...p,...c.alias===void 0?{}:{alias:c.alias}},s=!0,d())return!1}}if(!a)for(let c of i){if(d())return!1;let f=n.landed.find(b=>b.ref===c.ref);if(f===void 0||f.draft.protocol===c.protocol)continue;if(!(await r.setProtocol(t,f.hostRef,c.protocol)).ok){if(d())return!1;l();break}let{protocol:p,...g}=f.draft;if(f.draft={...g,...c.protocol===void 0?{}:{protocol:c.protocol}},s=!0,d())return!1}if(!a)for(let c of[!0,!1]){for(let f of i){if(d())return!1;if(f.enabled!==c)continue;let h=n.landed.find(g=>g.ref===f.ref);if(h===void 0||h.draft.enabled===c)continue;if(!(await r.setEnabled(t,h.hostRef,c)).ok){if(d())return!1;l();break}if(h.draft={...h.draft,enabled:c},s=!0,d())return!1}if(a)break}return a?(s&&(n.attempts=0),n.attempts>=qv?(console.error("[bre] deferred api keys: the write was refused; giving up on the held key list:",t),!0):!1):(n.attempts=0,!d())}function Xf(e){let t=0;for(let n of e.intents.values())n.releasedAt!==void 0&&(t+=1);return t}var Uv={openai:null,anthropic:null};function jv(e){let t=new Set(e.map(n=>n.ref));for(let n=1;n<=999;n+=1){let r=`key-${n}`;if(!t.has(r))return r}return`key-${Date.now()}`}function rp(e,t){let n=()=>({ok:!0,route:"",entries:e.drafts.map(a=>({ref:a.ref,...a.alias===void 0?{}:{alias:a.alias},enabled:a.enabled,configured:!0,masked:Mc(a.value),...a.protocol===void 0?{}:{protocol:a.protocol}})),endpoints:Uv}),r=a=>(t.onChange(e.drafts),{...n(),...a===void 0?{}:{addedRef:a}}),o=a=>e.drafts.find(s=>s.ref===a),i=(a,s)=>(e.drafts=e.drafts.map(d=>d.ref===a?s:d),r());return{list:async()=>n(),cached:()=>n(),add:async(a,s,d)=>{if(!Rt(s))return{ok:!1,error:t.t("keysAddIllegal")};let l=jv(e.drafts);return e.drafts=[...e.drafts,{ref:l,value:s,enabled:!0,...d===void 0?{}:{alias:d}}],r(l)},rename:async(a,s,d)=>{let l=o(s);if(l===void 0)return{ok:!1};let{alias:c,...f}=l;return i(s,{...f,...d===void 0?{}:{alias:d}})},replace:async(a,s,d)=>{let l=o(s);return l===void 0||!Rt(d)?{ok:!1,error:t.t("keysAddIllegal")}:i(s,{...l,value:d})},remove:async(a,s)=>(e.drafts=e.drafts.filter(d=>d.ref!==s),r()),setScope:async()=>n(),setEnabled:async(a,s,d)=>{let l=o(s);return l===void 0?{ok:!1}:!d&&!e.drafts.some(c=>c.ref!==s&&c.enabled)?{ok:!1,error:t.t("keysLastEnabledOff")}:i(s,{...l,enabled:d})},setProtocol:async(a,s,d)=>{let l=o(s);if(l===void 0)return{ok:!1};let{protocol:c,...f}=l;return i(s,{...f,...d===void 0?{}:{protocol:d}})},setEndpoints:async()=>n(),probe:async()=>n(),reveal:async(a,s)=>o(s)?.value}}var ip=require("react/jsx-runtime");function op({host:e,store:t,api:n,t:r,routeIdLabels:o,staged:i,onChange:a}){let[s,d]=(0,tt.useState)(()=>Jr(e.current,o)),l=(0,tt.useRef)(s),c=(0,tt.useRef)(new Set),f=(0,tt.useRef)(!1),h=(0,tt.useMemo)(()=>rp(t,{t:r,onChange:p=>{a?.(p);let g=l.current;if(g.length===0){!f.current&&p.length>0&&(f.current=!0,console.info("[bre] deferred api keys: holding the list until the provider id is typed"));return}$s(i,g,p)}}),[a,i,t,r]);return(0,tt.useEffect)(()=>{let p=ki(e.current);if(p===null)return;let g=()=>{d(Jr(e.current,o))};return p.addEventListener("input",g,!0),()=>{p.removeEventListener("input",g,!0)}},[e,o]),(0,tt.useEffect)(()=>{s.length>0&&zv(n,i,s,c.current)},[n,i,s]),(0,tt.useEffect)(()=>{let p=l.current;p!==s&&(Vs(i,p),l.current=s),t.drafts.length>0&&s.length>0&&$s(i,s,t.drafts)},[s,i,t]),(0,tt.useEffect)(()=>()=>{Zf(i,l.current)},[i]),(0,ip.jsx)(li,{route:s,t:r,client:h,draft:!0})}function zv(e,t,n,r){r.has(n)||!ep(t,n)||(r.add(n),(async()=>{try{let o=await le(e);Ys(t,n,st(o.namespace,n))}catch(o){tp(t,n),console.warn("[bre] deferred api keys: could not read the settings document for this route:",o)}})())}var Ti="data-bre-create-keys",$v="bre-keys-host",Vv="data-bre-key-input",Ei="data-bre-region",dr=new WeakMap;function ap(e){let t=e.querySelector(`input[${Vv}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function sp(e){let t=dr.get(e)?.host;if(t!==void 0&&t.isConnected)return t;let n=e.nextElementSibling;return n instanceof HTMLDivElement&&n.hasAttribute(Ti)?n:void 0}function dp(e,t){if(e.closest(`[${Ti}]`)!==null){lr(e);return}let n=ap(e);if(n===void 0){lr(e);return}if(e.parentElement===null)return;We(e,pn,!0);let r=dr.get(e),o=sp(e);o===void 0&&(r!==void 0&&Xs(e,r),o=e.ownerDocument.createElement("div"),o.className=$v,e.after(o)),he(o,Ti,"");let i=e.getAttribute(Ei);if(i===null?o.hasAttribute(Ei)&&o.removeAttribute(Ei):he(o,Ei,i),r!==void 0&&r.host===o)return;r!==void 0&&Xs(e,r);let a={drafts:Rt(n.value)?[{ref:"key-1",value:n.value,enabled:!0}]:[]},s=o,d=Xe(o,t.refreshed(()=>(0,Js.createElement)(Be,{fallbackText:t.t("keysPanelFailed")},(0,Js.createElement)(op,{host:{current:s},store:a,api:t.api,t:t.t,routeIdLabels:t.routeIdLabels,staged:t.staged,onChange:l=>{let c=ap(e);if(c===void 0||c.disabled)return;let f=l.find(h=>h.enabled)?.value??"";c.value!==f&&Ur(c,f)}}))),{sync:!0});dr.set(e,{host:o,mount:d})}function Xs(e,t){dr.delete(e),Re(t.mount)}function lr(e){We(e,pn,!1);let t=dr.get(e);t!==void 0&&Xs(e,t),sp(e)?.remove()}function lp(){for(let e of Array.from(document.querySelectorAll(`[${Ti}]`))){let t=e.previousElementSibling;t instanceof HTMLElement&&dr.has(t)?lr(t):e.remove()}}var Zs="bre-create-host",Qs="bre-add-mode-picker",Yv='[class*="addCard"]',Jv='[class*="addPanel"]',Xv='[class*="addModes"]',cp="-custom-panel",Qv="-custom";function pp(){return{hosts:new Map}}function ed(e,t,n){if(!e.isConnected)return;let r=new Set;for(let o of Array.from(e.querySelectorAll(Yv)))if(o.isConnected)try{Zv(o,t,n),r.add(o)}catch(i){Si(o,n);for(let a of td(o))try{lr(a)}catch{}mp(o,!1),console.warn("[bre] add provider card: left the official form in place:",i)}for(let o of Array.from(n.hosts.keys()))(!r.has(o)||!o.isConnected)&&Si(o,n)}function Zv(e,t,n){let r=up(e,cp);(r===void 0||r.hidden)&&(ow(e,()=>Ss(e)),r=up(e,cp),r===void 0||r.hidden)||(e.getAttribute("data-bre-add-card")!=="1"&&e.setAttribute("data-bre-add-card","1"),aw(e,r,t,n),nw(e),rw(r,t),mp(e,!0))}var ew=".field, label",tw=".bre-keys-host, .bre-keys, .bre-create-host";function td(e){let t=[],n=e.querySelectorAll('input[type="password"], input[data-bre-key-input]');for(let r of Array.from(n)){if(r.closest(tw)!==null)continue;let o=r.closest(ew)??r.parentElement;o!==null&&!t.includes(o)&&t.push(o)}return t}function nw(e){for(let t of td(e))try{ff(t)}catch(n){console.warn("[bre] add provider card: could not mark a key field:",n)}}function rw(e,t){for(let n of td(e))try{dp(n,{t:t.t,api:t.api,routeIdLabels:t.routeIdLabels,staged:t.stagedKeys,refreshed:t.refreshed})}catch(r){lr(n),console.warn("[bre] add provider card: could not mount the key list:",r)}}function mp(e,t){let n=gp(e);n!==void 0&&We(n,Qs,t)}function up(e,t){for(let n of Array.from(e.querySelectorAll(Jv)))if(n.id.endsWith(t))return n}function gp(e){let t=e.querySelector(Xv);if(t!==null){for(let n of Array.from(t.children))if(n instanceof HTMLElement&&n.getAttribute("role")==="tablist")return n}}function ow(e,t){let n=gp(e);if(n!==void 0){for(let r of Array.from(n.querySelectorAll('[role="tab"]')))if(r.id.endsWith(Qv)){if(r.disabled)return;r.getAttribute("aria-selected")!=="true"&&(t(),r.click());return}}}function iw(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.classList.contains(Zs))return t}function aw(e,t,n,r){let o=r.hosts.get(e),i=iw(t);if(i!==void 0&&o!==void 0&&o.host===i)return;Si(e,r),i!==void 0&&i.remove();let a=e.ownerDocument.createElement("div");a.className=Zs,t.insertBefore(a,t.firstChild),Ss(e);let s=Xe(a,n.refreshed(()=>(0,fp.createElement)(Jf,{host:{current:a},api:n.api,t:n.t,routeIdLabels:n.routeIdLabels,staged:n.staged})),{sync:!0});r.hosts.set(e,{host:a,mount:s})}function Si(e,t){let n=t.hosts.get(e);n!==void 0&&(t.hosts.delete(e),Re(n.mount))}function hp(e){for(let t of Array.from(e.hosts.keys()))Si(t,e);for(let t of Array.from(document.querySelectorAll(`.${Zs}`)))t.remove();for(let t of Array.from(document.querySelectorAll(`.${Qs}`)))We(t,Qs,!1);for(let t of Array.from(document.querySelectorAll(`.${gn}`)))Zn(t);lp()}var Qr="data-bre-row-provider",bp="{provider}",sw=["rowCard","setupCard"];function yp(){return Bo()}function nt(e){for(let t of sw)for(let n of Array.from(e.querySelectorAll(`[class*="${t}"]`))){let r=n.parentElement;if(!(r===null||r.tagName!=="UL")&&Ve(r).length!==0)return r}}function yn(e){return e.querySelector('[class*="rowHead"]')??void 0}function cr(e){let t=e.querySelector('[class*="rowName"]')?.textContent?.trim();return t!==void 0&&t.length>0?t:void 0}function dw(e){let t=e.indexOf(bp);if(!(t<0))return{prefix:e.slice(0,t),suffix:e.slice(t+bp.length)}}function lw(e){let t=e.trim();if(t.length===0)return;let n=/^(.*) \(([^()]*)\)$/.exec(t);if(n!==null){let r=n[2];return r.length===0?void 0:r}return/\s/.test(t)?void 0:t}var cw='[class*="rowCard"], [class*="setupCard"], [class*="addCard"]';function uw(e){let t=e.closest(cw);for(let n=e;n!==null&&n!==t;n=n.parentElement)if(n.matches('[data-plugin], [class*="bre-"]'))return!0;return!1}function rt(e,t){let n=e.querySelector("[data-bre-provider]")?.getAttribute("data-bre-provider");if(typeof n=="string"&&n.length>0)return n;for(let r of t.editProvider){let o=dw(r);if(o!==void 0)for(let i of Array.from(e.querySelectorAll("button[aria-label]"))){if(uw(i))continue;let a=i.getAttribute("aria-label")??"";if(a.length<=o.prefix.length+o.suffix.length||!a.startsWith(o.prefix)||!a.endsWith(o.suffix))continue;let s=lw(a.slice(o.prefix.length,a.length-o.suffix.length));if(s!==void 0)return s}}}function nd(e){let t=e.getAttribute(Qr);return t===null||t.length===0?void 0:t}function fw(e){return Nr(e,nd)}function vp(e,t,n,r=nt(e)){if(!e.isConnected||r===void 0)return;let o=t.labels();for(let i of Ve(r)){let a=rt(i,o);if(a===void 0){i.removeAttribute(Qr);continue}nd(i)!==a&&i.setAttribute(Qr,a)}Uo(e,r,pw(t),n)}function pw(e){return{rowOf:t=>{let n=t.closest("li");return n instanceof HTMLElement?n:void 0},idOf:nd,labelOf:cr,order:t=>Ud(t),commit:t=>{yo(fw(t))},seatOf:yn,seatDrags:!0,gripLabel:(t,n)=>e.t("providerReorderAria",{provider:cr(t)??n}),gripHint:()=>e.t("providerReorderHint")}}function wp(e){jo(e);let t=Array.from(document.querySelectorAll(`[${Qr}]`));Or(t);for(let n of t)n.removeAttribute(Qr)}var ur="data-bre-provider-switch",Mi="bre-row-disabled";function kp(){return{switches:new WeakSet}}function Ep(e,t,n,r=nt(e)){if(!e.isConnected||r===void 0)return;let o=t.labels();for(let i of Array.from(r.children)){if(!(i instanceof HTMLElement))continue;let a=rt(i,o);if(a===void 0)continue;let s=yn(i);s!==void 0&&(mw(i,s,a,t,n),i.classList.toggle(Mi,!On(a)))}}function Tp(){for(let e of Array.from(document.querySelectorAll(`[${ur}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`.${Mi}`)))e.classList.remove(Mi)}function mw(e,t,n,r,o){let i=t.querySelector(`[${ur}]`);if(i!==null){xp(i,e,n,r);return}let a=document.createElement("button");a.className="bre-provider-switch",a.setAttribute("type","button"),a.setAttribute("role","switch"),a.setAttribute(ur,n),xp(a,e,n,r),gw(a,e,o);let s=t.querySelector('[class*="rowActions"]');s===null?t.appendChild(a):s.insertBefore(a,s.firstChild)}function xp(e,t,n,r){let o=r.t("providerToggleAria",{provider:cr(t)??n}),i=r.t("providerToggleHint"),a=On(n)?"true":"false";e.getAttribute(ur)!==n&&e.setAttribute(ur,n),e.getAttribute("aria-checked")!==a&&e.setAttribute("aria-checked",a),e.getAttribute("aria-label")!==o&&e.setAttribute("aria-label",o),e.getAttribute("title")!==i&&e.setAttribute("title",i)}function gw(e,t,n){n.switches.has(e)||(n.switches.add(e),e.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation();let o=e.getAttribute(ur);if(o===null)return;let i=!On(o);zd(o,i),e.setAttribute("aria-checked",i?"true":"false"),t.classList.toggle(Mi,!i)}))}var hw=["balance","totalbalance","availablebalance","remainingbalance","creditbalance","balanceusd","totalavailable","available","remaining","credits","credit","amount","left","remain","remainingquota","quotaremaining","remainquota","availablequota","points"],bw=new Map(hw.map((e,t)=>[e,t])),PT=(bw.get("totalavailable")??0)+.5;var yw=new Map([["USD","$"],["US$","$"],["$","$"],["CNY","\xA5"],["RMB","\xA5"],["\xA5","\xA5"],["EUR","\u20AC"],["\u20AC","\u20AC"],["GBP","\xA3"],["\xA3","\xA3"],["JPY","\xA5"],["KRW","\u20A9"],["HKD","HK$"],["TWD","NT$"]]);function vw(e){let t=e<0?"-":"",n=Math.abs(e),r=Number.isInteger(n)?String(n):n.toFixed(2).replace(/0+$/,"").replace(/\.$/,""),[o="0",i]=r.split("."),a=o.replace(/\B(?=(\d{3})+(?!\d))/g,",");return`${t}${a}${i===void 0?"":`.${i}`}`}function Sp(e){let t=vw(e.amount),n=e.currency?.trim()??"";if(n.length===0)return t;let r=yw.get(n.toUpperCase());return r!==void 0?`${r}${t}`:`${t} ${n}`}async function ww(e){try{let t=await fetch(`${Hd}?route=${encodeURIComponent(e)}`,{method:"GET",cache:"no-store",credentials:"same-origin"}),n;try{n=await t.json()}catch{n=void 0}if(!V(n))return{ok:!1};if(n.ok===!0){let i=n.configured!==!1,a=typeof n.amount=="number"&&Number.isFinite(n.amount)?n.amount:void 0,s=typeof n.currency=="string"&&n.currency.length>0?n.currency:void 0;return{ok:!0,configured:i,...a===void 0?{}:{amount:a},...s===void 0?{}:{currency:s}}}let r=typeof n.error=="string"&&n.error.length>0?n.error:void 0,o=typeof n.configured=="boolean"?n.configured:void 0;return{ok:!1,...o===void 0?{}:{configured:o},...r===void 0?{}:{error:r}}}catch{return{ok:!1}}}var Mp={read:ww};var It="data-bre-provider-balance",xw="data-bre-provider-switch",Li="data-bre-provider-balance-refresh",kw=["M13.4 8a5.4 5.4 0 1 1-1.6-3.8","M13.8 2.2v3.5h-3.5"];function Ap(){return{readings:new Map,errors:new Map,requested:new Set,inflight:new Set,pending:new Set,queued:[],visible:!1}}var Cp=3;function rd(e,t,n,r=nt(e)){if(r===void 0){n.visible=!1,n.queued.length=0;return}n.visible||(n.visible=!0,n.requested.clear());let o=t.labels();for(let i of Array.from(r.children)){if(!(i instanceof HTMLElement))continue;let a=rt(i,o);if(a===void 0)continue;let s=yn(i);s!==void 0&&(Np(s,a,t,n),Fp(s,a,t,n))}}function Rp(e,t){e.requested.delete(t),e.readings.delete(t),e.errors.delete(t),e.inflight.has(t)&&e.pending.add(t);for(let n=e.queued.length-1;n>=0;n-=1)e.queued[n]?.route===t&&e.queued.splice(n,1)}function Hp(){for(let e of Array.from(document.querySelectorAll(`[${It}]`)))e.remove()}function Np(e,t,n,r){let o=r.readings.get(t);if(o!==void 0){Op(e,t,o,n,r);return}let i=r.errors.get(t);if(i!==void 0){Ew(e,t,i,n,r);return}_p(e)}function Op(e,t,n,r,o){let i=Ip(e,t,r,o);Dp(i,`${r.t("providerBalanceLabel")} ${Sp(n)}`,r.t("providerBalanceHint"),r),Pp(e,i)}function Ew(e,t,n,r,o){let i=Ip(e,t,r,o),a=n.length>0?n:r.t("providerBalanceHint");Dp(i,r.t("providerBalanceUnavailable"),a,r),Pp(e,i)}function Ip(e,t,n,r){let o=e.querySelector(`[${It}]`);return o===null?(o=document.createElement("span"),o.className="bre-provider-balance",o.setAttribute(It,t)):o.getAttribute(It)!==t&&o.setAttribute(It,t),(o.querySelector(".bre-provider-balance-text")===null||o.querySelector(`[${Li}]`)===null)&&(o.replaceChildren(),Tw(o,e,n,r)),o}function Tw(e,t,n,r){let o=document.createElement("span");o.className="bre-provider-balance-text";let i=document.createElement("button");i.type="button",i.className="bre-provider-balance-refresh",i.setAttribute(Li,"1"),i.setAttribute("aria-label",n.t("providerBalanceRefresh")),i.title=n.t("providerBalanceRefresh"),i.append(fi("balance-refresh",kw)),i.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation();let s=e.getAttribute(It);if(!(s===null||s.length===0)){if(r.inflight.has(s)){r.pending.add(s);return}r.requested.delete(s),Fp(t,s,n,r)}}),e.append(o,i)}function Dp(e,t,n,r){let o=e.querySelector(".bre-provider-balance-text");o!==null&&o.textContent!==t&&(o.textContent=t),e.getAttribute("title")!==n&&e.setAttribute("title",n);let i=e.querySelector(`[${Li}]`);if(i!==null){let a=r.t("providerBalanceRefresh");i.getAttribute("aria-label")!==a&&i.setAttribute("aria-label",a),i.getAttribute("title")!==a&&i.setAttribute("title",a)}}function Lp(e,t,n){let r=e.querySelector(`[${It}]`);if(r===null||r.getAttribute(It)!==t)return;let o=r.querySelector(`[${Li}]`);o!==null&&(o.classList.toggle("is-spinning",n),n?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))}function Pp(e,t){let n=e.querySelector(`[${xw}]`);if(n!==null){t.nextElementSibling!==n&&n.before(t);return}if(t.parentElement!==null)return;let r=e.querySelector('[class*="rowActions"]');r!==null?r.insertBefore(t,r.firstChild):e.appendChild(t)}function _p(e){for(let t of Array.from(e.querySelectorAll(`[${It}]`)))t.remove()}function Fp(e,t,n,r){r.requested.has(t)||r.inflight.has(t)||(r.requested.add(t),Kp(e,t,n,r))}function Kp(e,t,n,r){if(r.inflight.size>=Cp){r.queued.some(o=>o.route===t)||r.queued.push({head:e,route:t});return}qp(e,t,n,r)}function Sw(e,t){for(;t.inflight.size<Cp&&t.queued.length>0;){let n=t.queued.shift();if(n===void 0)return;qp(n.head,n.route,e,t)}}function qp(e,t,n,r){r.inflight.add(t),Lp(e,t,!0),(n.client??Mp).read(t).then(i=>{if(i.ok&&i.configured!==!1&&typeof i.amount=="number"&&Number.isFinite(i.amount)){r.errors.delete(t);let a={amount:i.amount,...i.currency===void 0?{}:{currency:i.currency}};r.readings.set(t,a),e.isConnected&&Op(e,t,a,n,r);return}if(i.ok&&i.configured===!1){r.readings.delete(t),r.errors.delete(t),e.isConnected&&_p(e);return}i.configured===!0&&r.errors.set(t,i.error??""),e.isConnected&&Np(e,t,n,r)}).catch(()=>{}).finally(()=>{r.inflight.delete(t),Lp(e,t,!1),e.isConnected||n.repaint?.(),r.pending.delete(t)&&(r.requested.delete(t),Kp(e,t,n,r)),Sw(n,r)})}function Bp(){return{requested:new Set,pending:[],running:new Set,visible:!1}}var Mw=2;function Wp(e){for(;e.visible&&e.running.size<Mw;){let t=e.pending.shift();if(t===void 0)return;e.running.add(t.route),Promise.resolve().then(()=>t.client.list(t.route,{preferCache:!0})).catch(()=>{}).finally(()=>{e.running.delete(t.route),Wp(e)})}}function od(e,t,n,r=nt(e)){if(r===void 0){n.visible=!1,n.pending.length=0;return}n.visible||(n.visible=!0,n.requested.clear());let o=t.client;if(o===void 0)return;let i=t.labels();for(let a of Array.from(r.children)){if(!(a instanceof HTMLElement))continue;let s=rt(a,i);s===void 0||n.requested.has(s)||(n.requested.add(s),n.running.has(s)||n.pending.push({route:s,client:o}))}Wp(n)}var Ai="data-bre-provider-delete",Gp='[class*="rowActions"]',Up='[class*="dangerButton"]',Lw="bre-provider-delete";function jp(e,t,n=nt(e)){if(!e.isConnected||n===void 0)return;let r=t.labels(),o=Aw(n)??t.t("providerRemoveDisabled");for(let i of Array.from(n.children)){if(!(i instanceof HTMLElement))continue;let a=rt(i,r);if(a===void 0)continue;let s=yn(i);if(s===void 0)continue;let d=s.querySelector(Gp);if(d===null)continue;let l=d.querySelector(`[${Ai}]`);if(d.querySelector(Up)!==null){l!==null&&l.remove();continue}let c=l??Cw();d.lastElementChild!==c&&d.appendChild(c),Rw(c,a,o,t.t("providerRemoveLocked",{provider:cr(i)??a}))}}function zp(){for(let e of Array.from(document.querySelectorAll(`[${Ai}]`)))e.remove()}function Aw(e){let n=e.querySelector(`${Gp} ${Up}`)?.textContent?.trim()??"";return n.length>0?n:void 0}function Cw(){let e=document.createElement("button");return e.className=Lw,e.setAttribute("type","button"),e.setAttribute("disabled",""),e}function Rw(e,t,n,r){e.getAttribute(Ai)!==t&&e.setAttribute(Ai,t),e.textContent!==n&&(e.textContent=n),e.getAttribute("aria-label")!==r&&e.setAttribute("aria-label",r),e.getAttribute("title")!==r&&e.setAttribute("title",r)}var Ci="data-bre-provider-disabled-group",Hw="bre-provider-disabled-seat",$p="bre-provider-disabled-group",id="bre-row-folded",ad="bre-row-hidden";function Vp(){return{expanded:!1}}function Yp(e,t,n,r=nt(e)){if(!e.isConnected||r===void 0)return;let o=Xp(r,t.labels()),i=o.filter(l=>!l.enabled).length,a=Qp(r);if(i===0){a!==void 0&&a.remove(),sd(o,n);return}let s=a??Nw(r,t,n);(s.parentElement!==r||r.lastElementChild!==s)&&r.append(s),sd(o,n);let d=Zp(s);d!==void 0&&em(d,i,t,n)}function Jp(){for(let e of Array.from(document.querySelectorAll(`[${Ci}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`.${ad}, .${id}`)))e.classList.remove(ad,id)}function Xp(e,t){let n=[];for(let r of Array.from(e.children)){if(!(r instanceof HTMLElement)||r.getAttribute(Ci)!==null)continue;let o=rt(r,t);o!==void 0&&n.push({row:r,id:o,enabled:On(o)})}return n}function sd(e,t){for(let n of e){let r=!n.enabled;n.row.classList.toggle(id,r),n.row.classList.toggle(ad,r&&!t.expanded)}}function Qp(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.getAttribute(Ci)!==null)return t}function Zp(e){return e.querySelector(`button.${$p}`)??void 0}function Nw(e,t,n){let r=document.createElement("li");r.className=Hw,r.setAttribute(Ci,"");let o=document.createElement("button");return o.className=$p,o.setAttribute("type","button"),o.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),n.expanded=!n.expanded,Ow(e,t,n)}),r.appendChild(o),e.append(r),r}function Ow(e,t,n){let r=Xp(e,t.labels());sd(r,n);let o=Qp(e);if(o===void 0)return;let i=r.filter(s=>!s.enabled).length;if(i===0){o.remove();return}let a=Zp(o);a!==void 0&&em(a,i,t,n)}function em(e,t,n,r){let o=n.t(r.expanded?"providerDisabledGroupHide":"providerDisabledGroupShow",{count:t}),i=n.t("providerDisabledGroupHint"),a=r.expanded?"true":"false";e.textContent!==o&&(e.textContent=o),e.getAttribute("aria-expanded")!==a&&e.setAttribute("aria-expanded",a),e.getAttribute("aria-label")!==o&&e.setAttribute("aria-label",o),e.getAttribute("title")!==i&&e.setAttribute("title",i)}var vn="data-bre-row-model",Zr="bre-model-grid";function nm(){return Bo()}function ld(e){let t=[];for(let n of Array.from(e.querySelectorAll('[class*="modelList"]')))Ve(n).filter(o=>o.matches('[class*="modelEntry"]')).length!==0&&t.push(n);return t}function rm(e){for(let t of e){if(t.type!=="childList")continue;let n=t.target;if(n instanceof HTMLElement&&n.matches('[class*="modelList"]')&&Ve(n).some(r=>r.matches('[class*="modelEntry"]')))return!0;for(let r of[t.addedNodes,t.removedNodes])for(let o of Array.from(r))if(o instanceof HTMLElement&&o.matches('[class*="modelEntry"]'))return!0}return!1}function Ri(e){let t=e.getAttribute(vn);return t===null||t.length===0?void 0:t}function dd(e,t){let n=e.closest("li");if(n!==null)return rt(n,t.labels())}function tm(e,t){let n=Qe(e,t.labels().modelName);return n.length>0?n:Ri(e)}function Iw(e,t){return{rowOf:n=>{let r=n.closest('[class*="modelEntry"]');return r instanceof HTMLElement?r:void 0},idOf:Ri,labelOf:n=>tm(n,t),order:n=>{let r=dd(e,t);return r===void 0?n:el(r,n)},commit:n=>{let r=dd(n,t);r!==void 0&&Xd(r,Nr(n,Ri))},seatOf:n=>n.querySelector('[class*="modelRow"]')??void 0,seatDrags:!1,gripLabel:(n,r)=>t.t("modelReorderAria",{model:tm(n,t)??r}),gripHint:()=>t.t("modelReorderHint"),decorate:(n,r)=>{r.classList.add(Zr)}}}function om(e,t,n,r=ld(e)){if(!e.isConnected)return;let o=t.labels();for(let i of r){if(i.querySelector('[class*="modelDragHandle"]')!==null){for(let s of Array.from(i.querySelectorAll(`.${Zr}`))){for(let d of Array.from(s.querySelectorAll("[data-bre-drag-handle]")))d.remove();s.classList.remove(Zr)}let a=Array.from(i.querySelectorAll(`[${vn}]`));Or(a);for(let s of a)s.removeAttribute(vn);continue}if(dd(i,t)!==void 0){for(let a of Ve(i)){let s=Qe(a,o.modelId);if(s.length===0){a.removeAttribute(vn);continue}Ri(a)!==s&&a.setAttribute(vn,s)}Uo(e,i,Iw(i,t),n)}}}function im(e){jo(e);for(let n of Array.from(document.querySelectorAll(`.${Zr}`)))n.classList.remove(Zr);let t=Array.from(document.querySelectorAll(`[${vn}]`));Or(t);for(let n of t)n.removeAttribute(vn)}var At=require("react");async function am(e){try{let t=await e.json();if(typeof t.error=="string"&&t.error.length>0)return t.error}catch{}return`image request failed (${e.status})`}async function Dw(e,t){try{let n=await fetch(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));return n.ok&&r.ok===!0?{ok:!0,data:r}:{ok:!1,error:typeof r.error=="string"?r.error:await am(n)}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}}var fr,Pw=0;var cd=new Set;function sm(e){return cd.add(e),()=>{cd.delete(e)}}function Hi(){return fr}function dm(){Yt()}async function Yt(){try{let e=await fetch(oa,{method:"GET"}),t=await e.json();if(e.ok&&t.ok===!0&&typeof t.models<"u"){let n={...t,enabled:t.enabled!==!1};return fr=n,{ok:!0,data:n}}return{ok:!1,error:typeof t.error=="string"?t.error:await am(e)}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function wn(e){let t=await Dw(oa,{op:"save",...e});if(!t.ok)return t;Pw+=1,fr!==void 0&&(fr={...fr,...e,defaults:{...fr.defaults,...e.defaults}});for(let n of cd)try{n()}catch{}return{ok:!0,data:void 0}}var _w=["\u6A21\u578B","Models","models"],cm='[class*="rowCard"], [class*="setupCard"], [class*="addCard"]',Fw='h1,h2,h3,h4,h5,h6,[role="heading"]',Kw=/title|heading/i,qw='nav, button, [role="menu"], [role="menuitem"], [class*="rowName"], [class*="rowCard"]',Bw=4;function Ww(e,t){let n="";for(let r of e.childNodes)if(r.nodeType===r.TEXT_NODE)n+=r.textContent??"";else if(r.nodeType===r.ELEMENT_NODE){if(r.classList?.contains(eo))continue;return!1}return n.replace(/\s+/g," ").trim()===t}function Gw(e,t){for(let n=e;n!==null;n=n.parentElement){if(n.matches(Fw)||Kw.test(String(n.className??"")))return n;if(n===t)break}return null}function Uw(e,t){for(let n of _w)for(let r of e.querySelectorAll("*")){if(!Ww(r,n)||r.closest(qw)!==null||(r.compareDocumentPosition(t)&Bw)===0)continue;let o=Gw(r,e);if(o!==null)return o}return null}var ud;function um(e){let t=ud;if(t!==void 0&&t.root===e&&t.row.isConnected)return t.row;let n=e.querySelector(cm);if(n===null)return null;let r=n.ownerDocument?.body??null;for(let o=n.parentElement;o!==null&&o!==r;o=o.parentElement){let i=Uw(o,n);if(i!==null){let a=jw(i,o);return a!==null&&(ud={root:e,row:a}),a}}return null}function jw(e,t){let n=e,r=n.parentElement;for(;r!==null&&r!==t;){let o=Array.from(r.childNodes).filter(a=>a.nodeType===a.TEXT_NODE).map(a=>a.textContent??"").join("").replace(/\s+/g," ").trim();if(Array.from(r.children).filter(a=>!a.classList?.contains(eo)).length>1||o.length>0)return r.querySelector(cm)!==null?n:r;n=r,r=r.parentElement}return r===t?n:null}var eo="bre-config-host",pd="bre-config-title-line",fd={display:"flex",alignItems:"center"},Ni=new WeakMap;function lm(e){e.classList.add(pd),Ni.has(e)||Ni.set(e,{display:e.style.display,alignItems:e.style.alignItems}),e.style.display=fd.display,e.style.alignItems=fd.alignItems}function zw(e){return e.classList.contains(pd)&&e.style.display===fd.display}function fm(e){e.classList.remove(pd);let t=Ni.get(e);Ni.delete(e),e.style.display=t?.display??"",e.style.alignItems=t?.alignItems??""}function pm(){return{mounts:new Map}}function mm(e,t,n){let r=n.mounts.get(e),o=e.querySelector(`:scope > .${eo}`);if(o!==null&&r!==void 0&&r.wrapper===o){zw(e)||lm(e);return}gm(e,n),o?.remove(),lm(e);let i=e.ownerDocument.createElement("div");i.className=eo,e.appendChild(i);let a=Xe(i,(0,At.createElement)(Vw,{t:t.t,onOpen:t.onOpen}),{sync:!0});n.mounts.set(e,a)}function gm(e,t){fm(e);let n=t.mounts.get(e);n!==void 0&&(t.mounts.delete(e),Re(n))}function hm(e){for(let t of Array.from(e.mounts.keys()))gm(t,e);for(let t of Array.from(document.querySelectorAll(`.${eo}`))){let n=t.parentElement;n!==null&&fm(n),t.remove()}ud=void 0}function $w(){return(0,At.createElement)("svg",{className:"bre-config-btn-icon",width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"},(0,At.createElement)("path",{d:"M4 6h8m4 0h4M4 12h2m4 0h10M4 18h10m4 0h2"}),(0,At.createElement)("circle",{cx:14,cy:6,r:2}),(0,At.createElement)("circle",{cx:8,cy:12,r:2}),(0,At.createElement)("circle",{cx:16,cy:18,r:2}))}function Vw(e){return(0,At.useEffect)(()=>{dm()},[]),(0,At.createElement)("button",{className:"bre-config-btn",type:"button",title:e.t("configButtonHint"),"aria-label":e.t("configButton"),onClick:()=>e.onOpen()},$w())}var Yw="settings.models",ot={capacity:["modelAdvanced","Model options","Capacities"],modelId:["modelId","Model ID"],modelName:["modelName","Display name"],routeId:["customRoute","Provider ID"],baseUrl:["baseUrl","Base URL"],apiProtocol:["customApi","API protocol"],apply:["apply","Apply"],cancel:["cancel","Cancel"],editProvider:["editProvider","Edit {provider}"],inputImage:["modelInputImage","Image"],contextWindow:["modelContextWindow","contextWindow","Context window","\u4E0A\u4E0B\u6587\u7A97\u53E3"],maxOutput:["modelMaxOutput","maxOutput","maxTokens","Max output","\u6700\u5927\u8F93\u51FA"],addModel:["addModel","Add model","\u6DFB\u52A0\u6A21\u578B"]};function vm(e){let{ctx:t,api:n,t:r,onIdle:o,refreshed:i}=e,a=()=>{let K=t.locale.bind(Yw),z=u=>{let S=[];for(let P of u){let H=K(P);H!==P&&H.trim()!==""&&!S.includes(H)&&S.push(H)}return S.length===0?u:[...S,...u.filter(P=>!S.includes(P))]};return{capacity:z(ot.capacity),modelId:z(ot.modelId),modelName:z(ot.modelName),routeId:z(ot.routeId),baseUrl:z(ot.baseUrl),apiProtocol:z(ot.apiProtocol),apply:z(ot.apply),cancel:z(ot.cancel),editProvider:z(ot.editProvider),inputImage:z(ot.inputImage),contextWindow:z(ot.contextWindow),maxOutput:z(ot.maxOutput),addModel:z(ot.addModel)}},s=120,d=1e3,l=uu(),c=yp(),f={t:r,labels:a},h=kp(),p={t:r,labels:a},g=Ap(),b={t:r,labels:a,repaint:()=>Q()},m=Bp(),v={labels:a,client:Ge},x={t:r,labels:a},E=Vp(),N={t:r,labels:a},F=nm(),X={t:r,labels:a},U=wf(),T={t:r},y=pp(),M=pm(),w=Uf(),k=Qf(),C={t:r,api:n,routeIdLabels:()=>a().routeId,staged:w,stagedKeys:k,refreshed:i},D,_,B,te,ee=K=>{for(let z of K)for(let u of Array.from(z.addedNodes)){if(!(u instanceof HTMLElement))continue;let S=u.matches('[class*="modelAdvanced"]')?[u]:Array.from(u.querySelectorAll('[class*="modelAdvanced"]'));for(let P of S)Es(P)}},ie=!1,oe={api:n,describeNamespace:K=>le(n,K),t:r,labels:a,onIdle:o,onBackoff:K=>{me(K)},onPendingChanged:()=>{Q()},mount(K,z){let u=document.createElement("div");u.className="bre-effort-slot",u.dataset.plugin=we,K.appendChild(u);let S=(0,ym.createRoot)(u),P=H=>{S.render((0,md.createElement)(Be,{fallbackText:r("renderFailed"),children:i(()=>(0,md.createElement)(_o,H))}))};return(0,bm.flushSync)(()=>{P(z)}),{unmount:()=>{try{S.unmount()}finally{u.remove()}},render:P}}},ae=0;function me(K){if(ie)return;let z=Date.now()+K;_!==void 0&&z>=ae||(_!==void 0&&window.clearTimeout(_),ae=z,_=window.setTimeout(()=>{_=void 0,ae=0,Q()},K))}let ge=()=>{let K=bt(),z=nt(K);if(z===void 0){rd(K,b,g,void 0),od(K,v,m,void 0);return}if(vp(K,f,c,z),Ep(K,p,h,z),rd(K,b,g,z),od(K,v,m,z),jp(K,x,z),Yp(K,N,E,z),om(K,X,F,ld(K)),e.configSeat!==void 0){let u=um(K);u!==null&&mm(u,{t:e.configSeat.t,onOpen:e.configSeat.onOpen},M)}Bs(),Cf(K)},ce=(K,z)=>{try{z()}catch(u){console.error(`[bre] ${K} failed:`,u)}};function Q(){ie||D!==void 0||(D=window.setTimeout(()=>{D=void 0,ce("composer mutation",()=>{te?.()}),ce("editor reconcile",()=>{Ls(bt(),oe,l)}),ce("add-card reconcile",()=>{ed(bt(),C,y)}),ce("editor tabs reconcile",()=>{_s(bt(),T,U)}),ce("dom decorations",()=>{ge()}),Vf(w,n).then(K=>{K>0&&me(d)}),np(k,n,Ge).then(K=>{K>0&&me(d)})},s))}let ue=K=>{let u=K.detail?.route;typeof u!="string"||u.length===0||(Rp(g,u),Q())},ke=K=>{if(ie||B!==void 0)return;te=K,ce("models page startup",()=>{K(),ge()}),Nu();let z=(u,S)=>{K(),S&&(ce("editor reconcile",()=>{Ls(bt(),oe,l)}),ed(bt(),C,y),_s(bt(),T,U),ge(),rm(u)&&_u(bt()))};B=new MutationObserver(u=>{let S=Wu(u);ce("models mutation",()=>{z(u,S)}),S&&(ce("early reasoning hide",()=>{ee(u)}),Q())}),B.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden"]}),document.addEventListener(Tr,ue),Q()},Se=()=>{ie=!0,D!==void 0&&(window.clearTimeout(D),D=void 0),_!==void 0&&(window.clearTimeout(_),_=void 0),document.removeEventListener(Tr,ue),B?.disconnect(),B=void 0};return{state:l,labels:a,start:ke,stopObserver:Se,teardown:()=>{if(!l.disposed){Se(),l.disposed=!0,Su(),lu(l,oe);for(let[K,z]of l.mounted)_r(K),z.editor.unmount();l.mounted.clear(),wp(c),Tp(),Hp(),zp(),Jp(),ec(),hm(M),Rf(),Ff(),im(F),hp(y),Tf(),Zc(),Pu()}},flushOnUnload:()=>{cu(l,oe)},schedule:Q}}var Jw=1500,Xw=2,Qw=8,Zw=6e4;function wm(e,t={}){let n=t.delayMs??Jw,r=Math.max(1,t.concurrency??Xw),o=Math.max(1,t.limit??Qw),i=t.minAgeMs??Zw,s=(t.now??Date.now)(),d=Hc().filter(p=>s-p.savedAt>=i).slice(0,o).map(p=>p.route),l=!1,c=0,f=()=>{for(;!l&&c<r;){let p=d.shift();if(p===void 0)return;c+=1,Promise.resolve().then(()=>e.list(p,{preferCache:!0})).catch(()=>{}).finally(()=>{c-=1,f()})}},h=setTimeout(()=>{l||f()},n);return()=>{l=!0,clearTimeout(h)}}var km=e=>`?route=${encodeURIComponent(e)}`;async function Em(e){try{let t=await e.json();if(typeof t.error=="string"&&t.error.length>0)return t.error}catch{}return`fingerprint request failed (${e.status})`}async function gd(e){try{let t=await fetch(`${ea}${km(e)}`,{method:"GET"}),n=await t.json();if(t.ok&&n.ok===!0){let r=n.data;return{ok:!0,data:{bank:r?.bank??{},records:Array.isArray(r?.records)?r.records:[]}}}return{ok:!1,error:typeof n.error=="string"?n.error:await Em(t)}}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}}function Tm(e,t,n){let r=new AbortController,o=!1;return{done:(async()=>{let a;try{let s=await fetch(`${ea}${km(e)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({model:t}),signal:r.signal});if(!s.ok)return{ok:!1,error:await Em(s)};let d=s.body?.getReader();if(d===void 0)return{ok:!1,error:"the fingerprint route sent no body"};let l=new TextDecoder,c="";for(;;){let{done:h,value:p}=await d.read();if(h)break;c+=l.decode(p,{stream:!0});let g=c.indexOf(`
5307
- `);for(;g>=0;){let b=c.slice(0,g).trim();if(c=c.slice(g+1),b.length>0){let m=xm(b);m!==void 0&&(n(m),m.type==="result"?a={ok:!0,record:m.record}:m.type==="error"&&(a={ok:!1,error:m.error}))}g=c.indexOf(`
5308
- `)}}let f=c.trim();if(f.length>0){let h=xm(f);h!==void 0&&(n(h),h.type==="result"?a={ok:!0,record:h.record}:h.type==="error"&&(a={ok:!1,error:h.error}))}}catch(s){return o?{ok:!1,error:"cancelled"}:{ok:!1,error:s instanceof Error?s.message:String(s)}}return a!==void 0?a:o?{ok:!1,error:"cancelled"}:{ok:!1,error:"the fingerprint route ended without a verdict"}})(),abort:()=>{o=!0,r.abort()}}}function xm(e){let t;try{t=JSON.parse(e)}catch{return}if(typeof t!="object"||t===null)return;let n=t,r=n.type;if(r==="progress")return{type:"progress",index:Number(n.index??0),ok:n.ok===!0,...typeof n.error=="string"?{error:n.error}:{}};if(r==="result"){let o=n.record;return typeof o!="object"||o===null?void 0:{type:"result",record:o}}if(r==="error")return{type:"error",error:typeof n.error=="string"?n.error:"fingerprint route failed"}}var ex=3,tx=2,nx=15e3,rx=/\b429\b|rate.?limit|too many requests/i,hd=new Map;function ox(e){return hd.get(e)??{run:(t,n,r)=>Tm(t,n,r)}}var bd=class{constructor(t,n=tx,r=nx){Ke(this,"route",t);Ke(this,"concurrency",n);Ke(this,"backoffMs",r);Ke(this,"listeners",new Set);Ke(this,"recordListeners",new Set);Ke(this,"failureListeners",new Set);Ke(this,"state",{running:new Map,queued:[]});Ke(this,"handles",new Set);Ke(this,"draining",!1);Ke(this,"disposed",!1);Ke(this,"throttled",!1);Ke(this,"backoffUntil",0)}getState(){return this.state}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onRecord(t){return this.recordListeners.add(t),()=>{this.recordListeners.delete(t)}}onFailure(t){return this.failureListeners.add(t),()=>{this.failureListeners.delete(t)}}idle(){return this.state.running.size===0&&this.state.queued.length===0}check(t){this.checkAll([t])}checkAll(t){if(this.disposed)return;let n=[...this.state.queued];for(let r of t)n.includes(r)||this.state.running.has(r)||n.push(r);n.length!==this.state.queued.length&&(this.publish({...this.state,queued:n}),this.drain())}abort(){this.publish({running:new Map,queued:[]});for(let t of[...this.handles])t.abort();this.handles.clear(),this.throttled=!1,this.backoffUntil=0}dispose(){this.disposed||(this.disposed=!0,this.abort(),this.listeners.clear(),this.recordListeners.clear(),this.failureListeners.clear(),Oi.delete(this.route),hd.delete(this.route))}setSender(t){hd.set(this.route,t)}publish(t){this.state=t;for(let n of[...this.listeners])n()}limit(){return this.throttled?1:Math.max(1,this.concurrency)}async drain(){if(this.draining||this.disposed)return;this.draining=!0;let t=new Set;try{for(;!this.disposed;){for(;!this.disposed&&t.size<this.limit()&&this.state.queued.length>0&&Date.now()>=this.backoffUntil;){let r=this.state.queued[0];if(r===void 0)break;this.publish({running:new Map(this.state.running).set(r,0),queued:this.state.queued.slice(1)});let o=this.runOne(r).finally(()=>{t.delete(o)});t.add(o)}if(this.disposed||t.size===0||(await Promise.race(t),this.disposed))break;let n=this.backoffUntil-Date.now();n>0&&await new Promise(r=>setTimeout(r,n))}}finally{t.clear(),this.throttled=!1,this.backoffUntil=0,this.draining=!1}}async runOne(t){let n=ox(this.route),r=0,o=n.run(this.route,t,i=>{i.type==="progress"&&(r+=1,this.publish({running:new Map(this.state.running).set(t,Math.min(r,ex)),queued:this.state.queued}))});this.handles.add(o);try{let i=await o.done;if(this.disposed)return;if(i.ok)for(let a of[...this.recordListeners])a(i.record);else{rx.test(i.error)&&(this.throttled=!0,this.backoffUntil=Date.now()+this.backoffMs);for(let a of[...this.failureListeners])a(t,i.error)}}finally{if(this.handles.delete(o),this.state.running.has(t)){let i=new Map(this.state.running);i.delete(t),this.publish({running:i,queued:this.state.queued})}}}},Oi=new Map;function Sm(e,t){let n=Oi.get(e);return n===void 0&&(n=new bd(e,t?.concurrency,t?.backoffMs),Oi.set(e,n)),n}function Mm(){for(let e of[...Oi.values()])e.dispose()}function pr(e,t){let n=e?.list?.getSnapshot(),r=n?.current;if(typeof r=="string"&&r.length>0)return r;let o=t?.adapter?.current?.getSnapshot?.()?.key;if(typeof o=="string"&&o.length>0)return o;for(let[i,a]of Object.entries(n?.byId??{}))if(!(a===void 0||(a.retainedBy?.mainView??0)<=0))return typeof a.id=="string"&&a.id.length>0?a.id:i}function Lm(e){let t,n=new Map,r=(a,s)=>{for(let[d,l]of n){if(d===s)continue;let c;try{c=a.directoryFor(l.sessionId)===d}catch{c=!1}c||(l.restore(),n.delete(d))}};return{ensure:()=>{let a=e.ctx,s=a.get?.("sessions"),d=a.get?.("uiSession"),l=a.get?.("modelDirectories"),c=pr(s,d);if(!(c===void 0||l===void 0))try{let f=l.directoryFor(c);return r(l,f),t!==void 0&&t.sessionId===c&&t.directory===f||(n.has(f)||n.set(f,{sessionId:c,restore:El(f,{configuredEffort:e.configuredEffort})}),t={sessionId:c,directory:f}),f}catch{t=void 0;return}},dispose:()=>{for(let[,a]of n)a.restore();n.clear()}}}var to=Object.freeze(["EMPTY_RESPONSE","RATE_LIMIT","SERVER","TIMEOUT","TRANSPORT"]),Ii=Object.freeze(["PI_AI_ERROR","INVALID_REQUEST","AUTH","LEGACY_CLI_OUTCOME_UNKNOWN","UNSUPPORTED_REASONING_EFFORT","MALFORMED_RESPONSE","UNKNOWN_MODEL"]),Di=Object.freeze([...to,...Ii]);function Am(){let e={};for(let t of to)e[t]=!0;for(let t of Ii)e[t]=!1;return e}var xn=Object.freeze({maxTokens:!0,httpStatus:!0,codes:Object.freeze(Am())});function Cm(e){let t=e!==null&&typeof e=="object"?e:{},n=t.codes!==null&&typeof t.codes=="object"?t.codes:{},r=Am();for(let o of Di){let i=n[o];typeof i=="boolean"&&(r[o]=i)}return Object.freeze({maxTokens:typeof t.maxTokens=="boolean"?t.maxTokens:xn.maxTokens,httpStatus:typeof t.httpStatus=="boolean"?t.httpStatus:xn.httpStatus,codes:Object.freeze(r)})}function ix(e,t){let n=t.codes[e];return typeof n=="boolean"?n:to.includes(e)?!0:void 0}function ax(e){return e===408||e===425||e===429||e>=500&&e<=599}var sx=new Set(["user/message","developer/message","system/message","request/header","request/context","step/start","assistant/message","assistant/attempt","tool/call","tool/result"]);function dx(e){let t=!1;for(let n of e.turnEvents)if(n.type!=="turn/end"){if(n.type==="turn/start"){t=!0;continue}if(sx.has(n.type))return!0}return t?!1:"unknown"}function lx(e){let t=e.data;if(typeof t!="object"||t===null)return;let n=t.reason;if(typeof n!="object"||n===null)return typeof n=="string"?n:void 0;let r=n.kind;return typeof r=="string"?r:void 0}function cx(e){let t=e.data;if(typeof t!="object"||t===null)return;let n=t.reason;if(typeof n!="object"||n===null)return;let r=n.error;if(!(typeof r!="object"||r===null))return r}function ux(e){let t=e?.providerRetryAfterMs;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0}function yd(e,t=xn){let n=lx(e.turnEnd);if(dx(e)===!1)return{kind:"refuse",detail:`${n??"unreadable reason"}: empty turn`};switch(n){case"max-tokens":return t.maxTokens?{kind:"continue",reason:"max-tokens",detail:"max-tokens"}:{kind:"refuse",detail:"max-tokens (not enabled)"};case"error":{let r=cx(e.turnEnd),o=typeof r?.code=="string"?r.code:void 0,i=typeof r?.status=="number"?r.status:void 0;if(o!==void 0){let a=ix(o,t);if(a===!0){let s=ux(r);return{kind:"continue",reason:"transient-error",detail:o,...s!==void 0?{waitMs:s}:{}}}if(a===!1)return{kind:"refuse",detail:`${o} (not enabled)`}}return i!==void 0&&t.httpStatus&&ax(i)?{kind:"continue",reason:"transient-error",detail:`status ${i}`}:{kind:"refuse",detail:o??(i!==void 0?`status ${i}`:"unknown error")}}case"completed":return{kind:"settled",detail:"completed"};case"aborted":return{kind:"settled",detail:"aborted"};case"interrupted":return{kind:"settled",detail:"interrupted"};case"blocked":return{kind:"settled",detail:"blocked"};case"forked":case"orphaned":return{kind:"refuse",detail:n};default:return{kind:"refuse",detail:n===void 0?"unreadable reason":`unknown reason ${n}`}}}var Fi="dsh-model-think-level.auto-continue.enabled",Ki="dsh-model-think-level.auto-continue.config",qi=1,Bi=3600,Wi=1,Gi=100,vd=Object.freeze({waitSeconds:2,maxRetries:5,policy:xn}),fx="dsh-model-think-level.auto-continue.claim.",px=10*6e4;function Hm(e){try{return window.localStorage.getItem(e)}catch{return null}}function Rm(e,t,n,r){return typeof e!="number"||!Number.isFinite(e)?t:Math.min(r,Math.max(n,Math.trunc(e)))}function wd(e){let t=e!==null&&typeof e=="object"?e:{};return Object.freeze({waitSeconds:Rm(t.waitSeconds,vd.waitSeconds,qi,Bi),maxRetries:Rm(t.maxRetries,vd.maxRetries,Wi,Gi),policy:Cm(t.policy)})}function Ui(e){try{return wd(e===null?void 0:JSON.parse(e))}catch{return vd}}var no=Hm(Fi)==="true",mr=Ui(Hm(Ki)),Pi=new Set,_i=new Set;function ji(e){for(let t of[...e])t()}function Jt(){return no}function Ye(){return mr}function Nm(e){if(no!==e){no=e;try{window.localStorage.setItem(Fi,String(e))}catch{}ji(Pi)}}function Om(e,t){return JSON.stringify(e)===JSON.stringify(t)}function kn(e){let t=wd({...mr,...e});if(!Om(mr,t)){mr=t;try{window.localStorage.setItem(Ki,JSON.stringify(t))}catch{}ji(_i)}}function xd(e){no!==e&&(no=e,ji(Pi))}function kd(e){let t=wd(e);Om(mr,t)||(mr=t,ji(_i))}function zi(e){return Pi.add(e),()=>{Pi.delete(e)}}function $i(e){return _i.add(e),()=>{_i.delete(e)}}function Im(e,t){let n=`${fx}${e}.${t}`;try{let r=window.localStorage.getItem(n);if(r!==null){let o=JSON.parse(r);if(typeof o=="number"&&Number.isFinite(o)&&Date.now()-o<px)return!1}return window.localStorage.setItem(n,JSON.stringify(Date.now())),!0}catch{return!0}}var mx=1e3,gx=500,hx=600,Dm=6e3,bx=12e4,yx=3e4,vx=1440*60*1e3;function Pm(e){let{ctx:t,t:n}=e,r,o=!1,i=new Set,a=new Set,s=new Set,d,l=()=>{let u=r,S=Ye();return u===void 0?{sessionId:void 0,phase:"idle",consecutive:0,maxRetries:S.maxRetries,nextSendAt:0,detail:"",muted:!1}:{sessionId:u.sessionId,phase:u.phase,consecutive:u.consecutive,maxRetries:S.maxRetries,nextSendAt:u.nextSendAt,detail:u.detail,muted:a.has(u.sessionId)}},c=(u,S)=>u.sessionId===S.sessionId&&u.phase===S.phase&&u.consecutive===S.consecutive&&u.maxRetries===S.maxRetries&&u.nextSendAt===S.nextSendAt&&u.detail===S.detail&&u.muted===S.muted,f=()=>{let u=l();if(!(d!==void 0&&c(d,u))){d=u;for(let S of[...s])S()}},h=()=>(d??(d=l()),d),p=u=>{u.phase="idle",u.nextSendAt=0,u.detail="",f()},g=(u,S)=>{let P=setTimeout(()=>{i.delete(P),u()},S);i.add(P)},b=u=>{let S=[];try{S=u.getSnapshot().entries??[]}catch{return[]}let P=[];for(let H of S)H.type!=="event"||H.event===void 0||P.push(H.event);return P},m=u=>b(u.eventSource),v=u=>{if(u.type!=="user/message")return!1;let S=u.data;if(typeof S!="object"||S===null)return!0;let P=S.message??S;if(typeof P!="object"||P===null)return!0;let H=P.source;if(typeof H!="object"||H===null)return!0;let J=H.kind;return J!=="model-selection"&&J!=="time-context"},x=u=>{let S=m(u),P=u.lastUserSeq;for(let H of S){if(H.type!=="user/message"||H.seq<=P||(u.lastUserSeq=Math.max(u.lastUserSeq,H.seq),!v(H)))continue;let J=E(u,H);u.lastAutoSentText=void 0,!J&&(a.delete(u.sessionId),u.consecutive=0,X(u),p(u))}},E=(u,S)=>{if(u.lastAutoSentText===void 0)return!1;let P=S.data;if(typeof P!="object"||P===null)return!1;let H=P.content??P.message?.content;if(!Array.isArray(H)||H.map(ve=>typeof ve=="object"&&ve!==null&&ve.type==="text"?ve.text:void 0).filter(ve=>typeof ve=="string").join("")!==u.lastAutoSentText)return!1;let ne=typeof S.time=="number"?S.time:u.lastAutoSentAt;return Math.abs(ne-u.lastAutoSentAt)<=yx},N=(u,S)=>{let P=-1;for(let H=S-1;H>=0;H-=1)if(u[H].type==="turn/end"){P=H;break}return u.slice(P+1,S+1)},F=u=>{let S=Ye().waitSeconds*1e3;return u===void 0?S:Math.max(S,Math.min(u,bx))},X=u=>{let S=u.sendTimer!==void 0||u.pendingSendTurnEndSeq!==void 0;u.sendTimer!==void 0&&(clearTimeout(u.sendTimer),i.delete(u.sendTimer),u.sendTimer=void 0),u.pendingSendTurnEndSeq=void 0,S&&(u.nextSendAt=0,u.phase==="waiting"&&p(u))},U=u=>{u.sendTimer!==void 0&&(clearTimeout(u.sendTimer),i.delete(u.sendTimer));let S=Math.max(0,F(u.pendingRetryAfterMs)-(Date.now()-u.pendingSendScheduledAt)),P=setTimeout(()=>{i.delete(P),u.sendTimer=void 0,_(u,n("autoContinueMessage"))},S);u.sendTimer=P,u.nextSendAt=Date.now()+S,u.phase="waiting",f(),i.add(P)},T=u=>{try{let S=u.getSnapshot();return{running:S.running===!0,open:S.openState===void 0||S.openState==="open",pending:S.pendingSubmissions?.length??0,subagent:S.subagent!=null}}catch{return}},y=u=>{let S=t.get?.("sessions"),P=t.get?.("uiSession");return pr(S,P)===u.sessionId},M=u=>{if(u.evalTimer!==void 0){u.evalDeadline=Date.now()+Dm;return}u.evalDeadline=Date.now()+Dm,w(u,gx)},w=(u,S)=>{o||r!==u||(u.evalTimer=setTimeout(()=>{u.evalTimer=void 0,D(u)},S),i.add(u.evalTimer))},k=u=>{if(u.historyReady)return;let S=T(u.session);if(S===void 0||!S.open)return;u.historyReady=!0;let P=ie(u.eventSource);u.lastHandledTurnEndSeq=Math.max(u.lastHandledTurnEndSeq,P??ce(u.eventSource,"turn/end"))},C=u=>{if(!u.historyReady)return;let S=T(u.session);if(S===void 0||S.running)return;let P=m(u);for(let H=P.length-1;H>=0;H-=1){let J=P[H];if(J.type==="turn/end"){J.seq>u.lastHandledTurnEndSeq&&M(u);return}}},D=u=>{if(o||r!==u||!Jt()||a.has(u.sessionId))return;let S=T(u.session);if(!u.historyReady||S===void 0||!S.open||S.subagent||S.running||S.pending>0)return;let P=m(u),H=-1;for(let Oe=P.length-1;Oe>=0;Oe-=1){let _e=P[Oe];if(_e.type==="turn/end"&&_e.seq>u.lastHandledTurnEndSeq){H=Oe;break}}if(H<0){Date.now()<u.evalDeadline&&w(u,hx);return}let J=P[H];if(u.lastHandledTurnEndSeq=J.seq,x(u),P.some(Oe=>Oe.seq>J.seq&&(v(Oe)||Oe.type==="turn/start")))return;let ne=yd({turnEnd:J,turnEvents:N(P,H)},Ye().policy);if(ne.kind==="settled"){u.consecutive=0,p(u);return}if(ne.kind==="refuse"){u.phase!=="exhausted"&&p(u);return}let ve=Ye().maxRetries;if(u.consecutive>=ve){console.info(`[dsh-model-think-level] auto-continue: streak cap (${ve}) reached, standing down (${ne.detail})`),u.phase="exhausted",u.nextSendAt=0,u.detail=ne.detail,f();return}Im(u.sessionId,J.seq)&&(u.pendingSendTurnEndSeq=J.seq,u.pendingSendScheduledAt=Date.now(),u.pendingRetryAfterMs=ne.waitMs,u.detail=ne.detail,U(u))},_=async(u,S)=>{if(o||r!==u)return;x(u);let P=u.pendingSendTurnEndSeq;if(u.pendingSendTurnEndSeq=void 0,P===void 0||P!==u.lastHandledTurnEndSeq||!Jt()||a.has(u.sessionId)||u.consecutive>=Ye().maxRetries)return;let H=T(u.session);if(!(H===void 0||!H.open||H.subagent||H.running||H.pending>0||!y(u)||m(u).some(ne=>ne.seq>P&&(v(ne)||ne.type==="turn/start"||ne.type==="turn/end")))){u.lastAutoSentAt=Date.now(),u.lastAutoSentText=S;try{let ne=await u.session.prompt([{type:"text",text:S}],"queue");if(ne?.ok!==!0){u.consecutive+=1,u.lastAutoSentText=void 0,u.nextSendAt=0,u.phase=u.consecutive>=Ye().maxRetries?"exhausted":"idle",f(),console.warn(`[dsh-model-think-level] auto-continue: prompt refused ${B(ne)}`);return}u.consecutive+=1,u.phase="sent",u.nextSendAt=0,f()}catch(ne){u.consecutive+=1,u.lastAutoSentText=void 0,u.nextSendAt=0,u.phase=u.consecutive>=Ye().maxRetries?"exhausted":"idle",f(),console.warn("[dsh-model-think-level] auto-continue: prompt failed:",ne)}}},B=u=>{let S=u?.error;if(S===void 0)return"without an error";let P=typeof S.code=="string"?S.code:"unknown",H=typeof S.message=="string"?S.message:"";return H.length>0?`${P}: ${H}`:P},te=u=>{let S=T(u.session);S!==void 0&&(k(u),(!S.open||S.subagent||S.running||S.pending>0)&&X(u),S.pending>0&&(u.lastHandledTurnEndSeq=Math.max(u.lastHandledTurnEndSeq,ce(u.eventSource,"turn/end")),u.evalTimer!==void 0&&(clearTimeout(u.evalTimer),i.delete(u.evalTimer),u.evalTimer=void 0),u.evalDeadline=0),u.wasRunning&&!S.running&&M(u),u.wasRunning=S.running)},ee=u=>{let S=[];for(let P of b(u))P.type==="turn/end"&&S.push(P.seq);return S.length<2?0:(S.sort((P,H)=>P-H),S[S.length-2])},ie=u=>{let S=b(u),P=-1;for(let ne=S.length-1;ne>=0;ne-=1)if(S[ne].type==="turn/end"){P=ne;break}if(P<0)return;let H=S[P],J=typeof H.time=="number"?H.time:Date.now();if(!(Date.now()-J>vx)&&!S.some(ne=>ne.seq>H.seq&&(v(ne)||ne.type==="turn/start")))return yd({turnEnd:H,turnEvents:N(S,P)},Ye().policy).kind==="continue"?ee(u):void 0},oe=u=>{if(o||r!==u||u.evalTimer!==void 0||!Jt()||a.has(u.sessionId)||!u.historyReady)return;let S=T(u.session);if(S===void 0||!S.open||S.subagent||S.running||S.pending>0)return;let P=m(u);for(let H=P.length-1;H>=0;H-=1){let J=P[H];if(J.type==="turn/end"&&J.seq>u.lastHandledTurnEndSeq){M(u);return}}},ae=()=>{let u=r;if(u!==void 0){r=void 0;for(let S of u.unsubs)try{S()}catch{}u.evalTimer!==void 0&&(clearTimeout(u.evalTimer),i.delete(u.evalTimer),u.evalTimer=void 0),u.sendTimer!==void 0&&(clearTimeout(u.sendTimer),i.delete(u.sendTimer),u.sendTimer=void 0),f()}},me=u=>{let S=T(u.session);if(S===void 0||S.subagent)return;let P=S.open?ie(u.eventSource):void 0,H={sessionId:u.sessionId,session:u.session,eventSource:u.eventSource,wasRunning:ge(u.session),lastUserSeq:ce(u.eventSource,"user/message"),historyReady:S.open,lastHandledTurnEndSeq:S.open?P??ce(u.eventSource,"turn/end"):0,consecutive:0,phase:"idle",nextSendAt:0,detail:"",pendingSendTurnEndSeq:void 0,pendingSendScheduledAt:0,pendingRetryAfterMs:void 0,lastAutoSentAt:0,lastAutoSentText:void 0,unsubs:[],evalDeadline:0,evalTimer:void 0,sendTimer:void 0};r=H,f();try{H.unsubs.push(u.session.subscribe(()=>te(H)))}catch{ae();return}try{H.unsubs.push(u.eventSource.subscribe(()=>{x(H),k(H),C(H)}))}catch(J){ae(),console.warn("[dsh-model-think-level] auto-continue: event source unusable:",J);return}},ge=u=>{try{return u.getSnapshot().running===!0}catch{return!1}},ce=(u,S)=>{let P=0,H=[];try{H=u.getSnapshot().entries??[]}catch{return 0}for(let J of H)J.type!=="event"||J.event===void 0||J.event.type===S&&J.event.seq>P&&(P=J.event.seq);return P},Q=()=>{if(o)return;let u=t.get?.("sessions"),S=t.get?.("uiSession"),P=pr(u,S);if(P===void 0||u===void 0||typeof u.binding!="function"){ae();return}let H;try{H=u.binding(P)}catch{H=void 0}if(H===void 0||H.session===void 0){ae();return}if(r!==void 0&&r.session===H.session){oe(r);return}ae(),me(H),r!==void 0&&oe(r)},ue=setInterval(Q,mx);Q();let ke;try{ke=t.on?.("connection/reset",()=>{ae()})}catch{}let Se=zi(()=>{let u=r;Jt()||u===void 0||(X(u),p(u),u.evalTimer!==void 0&&(clearTimeout(u.evalTimer),i.delete(u.evalTimer),u.evalTimer=void 0))}),Ce=$i(()=>{let u=r;f(),u?.pendingSendTurnEndSeq!==void 0&&(!Jt()||u.consecutive>=Ye().maxRetries?X(u):U(u))});return{status:h,subscribe:u=>(s.add(u),()=>{s.delete(u)}),stop:()=>{let u=r;u!==void 0&&(X(u),u.evalTimer!==void 0&&(clearTimeout(u.evalTimer),i.delete(u.evalTimer),u.evalTimer=void 0),u.evalDeadline=0,u.consecutive=0,a.add(u.sessionId),p(u))},reset:()=>{let u=r;u!==void 0&&(u.consecutive=0,a.delete(u.sessionId),p(u))},resumeNow:()=>{let u=r;u!==void 0&&u.pendingSendTurnEndSeq!==void 0&&(u.sendTimer!==void 0&&(clearTimeout(u.sendTimer),i.delete(u.sendTimer),u.sendTimer=void 0),_(u,n("autoContinueMessage")))},dispose:()=>{o=!0,Se(),Ce(),ke?.(),clearInterval(ue),ae(),s.clear();for(let u of i)clearTimeout(u);i.clear()}}}var wx=[[/\b(sk|rk|ak)-[A-Za-z0-9_-]{8,}/g,"$1-***"],[/("?(?:api[_-]?key|apikey|authorization|access[_-]?token|token|x-api-key)"?\s*[:=]\s*"?)[^",}\s]+/gi,"$1***"],[/\bBearer\s+[A-Za-z0-9._-]{10,}/gi,"Bearer ***"]];function xx(e){let t=String(e??"");for(let[n,r]of wx)t=t.replace(n,r);return t}function kx(e,t,n){let r=xx(typeof e.message=="string"?e.message:JSON.stringify(e)),o,i=r,a=/^\s*(\d{3})\s*:\s*([\s\S]*)$/.exec(r);a!==null&&(o=Number(a[1]),i=a[2]??"");let s;try{let l=JSON.parse(i);l!==null&&typeof l=="object"&&(s=l)}catch{s=void 0}let d=typeof s?.message=="string"&&s.message.length>0?s.message:i.trim().length>0?i.trim():r;return{sessionId:t,seq:n,code:typeof e.code=="string"?e.code:"UNKNOWN",http:o,reason:d,providerCode:typeof s?.code=="string"?s.code:void 0,traceId:typeof s?.traceId=="string"?s.traceId:void 0,raw:r}}var Vi=e=>`${e.sessionId}:${e.seq}`;function Ex(e,t){let n=[];try{n=e.getSnapshot().entries??[]}catch{return[]}let r=[],o=new Set;for(let i of n){if(i?.type!=="event"||i.event===void 0)continue;let a=i.event;if(a.type!=="turn/end")continue;let s=a.data?.reason;if(s?.kind!=="error"||s.error===void 0)continue;let d=a.seq??0;o.has(d)||(o.add(d),r.push(kx(s.error,t,d)))}return r}var Tx='[class*="turnErrorRow"]',Sx='code[class*="turnErrorCode"]',Ed='[class*="turnErrorMessage"]',oo="data-bre-error-detail",Fm={AUTH:"API \u5BC6\u94A5\u65E0\u6548",QUOTA:"\u989D\u5EA6\u4E0D\u8DB3",ACCOUNT_QUOTA:"\u989D\u5EA6\u4E0D\u8DB3",ACCOUNT_SIGNED_OUT:"\u8D26\u53F7\u5DF2\u9000\u51FA",ACCOUNT_SIGN_IN_REQUIRED:"\u9700\u8981\u767B\u5F55",INTERRUPTED:"\u5DF2\u4E2D\u65AD"};function _m(e,t){return(e.querySelector(t)?.textContent??"").trim()}function Mx(e){let t=e.querySelector(Ed);if(t===null)return"";let n="";for(let r of t.childNodes)r instanceof HTMLElement&&r.hasAttribute(oo)||(n+=r.textContent??"");return n.trim()}function Lx(e,t,n){if(t.length===0)return;let r=_m(e,Sx),o=_m(e,Ed),i=t.filter(l=>!n.has(Vi(l))),a=r.length===0?i:i.filter(l=>l.code===r);if(a.length===0)return;let s=Fm[r];return s!==void 0&&o===s?a[0]:a.find(l=>{if(l.http!==void 0&&o.startsWith(`${l.http}:`))return!0;let c=l.raw;return c.length===0||o.length===0?!1:c.startsWith(o.slice(0,40))||o.startsWith(c.slice(0,40))})??a[0]}var ro="bre-error-detail-popover";function He(e,t,n){let r=document.createElement(e);return t!==void 0&&(r.className=t),n!==void 0&&(r.textContent=n),r}async function Ax(e){try{return await navigator.clipboard.writeText(e),!0}catch{try{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.append(t),t.select();let n=document.execCommand("copy");return t.remove(),n}catch{return!1}}}function Km(e){let{ctx:t,t:n}=e,r=[],o=!1,i,a=(M,w)=>{let k=He("button","bre-ed-copy",w);return k.type="button",k.addEventListener("click",()=>{Ax(M).then(C=>{C&&(k.textContent=n("errorDetailCopied"),window.setTimeout(()=>{k.textContent=w},1400))})}),k},s=(M,w,k={})=>{if(w===void 0||w.length===0)return null;let C=He("div","bre-ed-row");C.append(He("span","bre-ed-label",M));let D=["bre-ed-value"];return k.mono===!0&&D.push("bre-ed-mono"),k.muted===!0&&D.push("bre-ed-muted"),C.append(He("span",D.join(" "),w)),k.copy===!0&&C.append(a(w,n("errorDetailCopy"))),C},d=(M,w)=>{let k=Fm[M];return k===void 0?`${w} \u2014 ${n("errorDetailUnwrapped")}`:w===k?`${w} \u2014 ${n("errorDetailFixedLabel")}`:k},l=()=>{let M=document.getElementById(ro);if(M instanceof HTMLDivElement)return M;let w=He("div","bre-ed-pop");return w.id=ro,w.setAttribute("role","dialog"),w.setAttribute("aria-label",n("errorDetailTitle")),document.body.append(w),w},c=()=>{let M=document.getElementById(ro);M!==null&&(M.style.display="none"),document.removeEventListener("pointerdown",f,!0),document.removeEventListener("keydown",h,!0),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c,!0)};function f(M){let w=document.getElementById(ro);w!==null&&(M.target instanceof Node&&w.contains(M.target)||M.target instanceof Element&&M.target.closest(`[${oo}]`)!==null||c())}function h(M){M.key==="Escape"&&c()}let p=(M,w)=>{let k=w.getBoundingClientRect();M.style.visibility="hidden",M.style.left="0px",M.style.top="0px";let C=M.offsetWidth,D=M.offsetHeight,_=8;if(k.bottom<_||k.top>window.innerHeight-_){let ee=Math.max(_,(window.innerWidth-C)/2),ie=Math.max(_,(window.innerHeight-D)/2);M.style.left=`${Math.round(ee)}px`,M.style.top=`${Math.round(ie)}px`,M.style.visibility="";return}let B=Math.min(Math.max(_,k.left),Math.max(_,window.innerWidth-C-_)),te=k.bottom+_;te+D>window.innerHeight-_&&(te=Math.max(_,k.top-D-_)),M.style.left=`${Math.round(B)}px`,M.style.top=`${Math.round(te)}px`,M.style.visibility=""},g=(M,w,k)=>{let C=l();C.textContent="";let D=He("div","bre-ed-head");D.append(He("span","bre-ed-dot")),D.append(He("span","bre-ed-title",n("errorDetailTitle")));let _=He("span","bre-ed-chips");M.http!==void 0&&_.append(He("code","bre-ed-chip",`HTTP ${M.http}`)),M.providerCode!==void 0&&_.append(He("code","bre-ed-chip bre-ed-chip-strong",M.providerCode)),D.append(_);let B=He("button","bre-ed-x","\xD7");B.type="button",B.setAttribute("aria-label",n("errorDetailClose")),B.addEventListener("click",()=>c()),D.append(B),C.append(D);let te=He("div","bre-ed-body"),ee=[s(n("errorDetailReason"),M.reason),s(n("errorDetailTrace"),M.traceId,{mono:!0,copy:!0}),s(n("errorDetailCode"),M.code,{mono:!0}),s(n("errorDetailShown"),d(M.code,k),{muted:!0})];for(let ge of ee)ge!==null&&te.append(ge);C.append(te);let ie=He("div","bre-ed-raw"),oe=He("button","bre-ed-raw-toggle",`\u25B8 ${n("errorDetailRaw")}`);oe.type="button";let ae=He("pre","bre-ed-pre",M.raw);ae.hidden=!0,oe.addEventListener("click",()=>{ae.hidden=!ae.hidden,oe.textContent=`${ae.hidden?"\u25B8":"\u25BE"} ${n("errorDetailRaw")}`}),ie.append(oe,ae),C.append(ie);let me=He("div","bre-ed-foot");me.append(He("span","bre-ed-src",n("errorDetailSource"))),me.append(a(M.raw,n("errorDetailCopyRaw"))),C.append(me),C.style.display="block",p(C,w),document.addEventListener("pointerdown",f,!0),document.addEventListener("keydown",h,!0),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c,!0)},b=()=>{let M=document.querySelectorAll(Tx);if(M.length===0)return;let w=new Set,k=n("errorDetailButton");for(let C of M){let D=Lx(C,r,w);if(D===void 0)continue;w.add(Vi(D));let _=Mx(C),B=C.querySelector(Ed)??C,te=B.querySelector(`:scope > button[${oo}]`);te===null&&(te=document.createElement("button"),te.type="button",te.className="bre-ed-view",te.setAttribute(oo,"1"),B.append(te)),te.textContent!==k&&(te.textContent=k),te.onclick=ee=>{ee.preventDefault(),ee.stopPropagation(),g(D,te,_)}}},m=()=>{i===void 0&&(i=window.setTimeout(()=>{i=void 0,b()},120))},v,x,E=(M,w)=>{if(o)return;let k=Ex(w,M);k.length===r.length&&k.every((D,_)=>Vi(D)===Vi(r[_]))||(r=k,m())},N=()=>{x?.(),x=void 0},F=M=>{let w=t.get?.("sessions"),k;try{k=w?.binding?.(M)}catch{k=void 0}let C=k?.eventSource;if(C!==void 0)try{E(M,C),x=C.subscribe(()=>{try{E(M,C)}catch{}})}catch{x=void 0}},X=()=>{if(o)return;let M=t.get?.("sessions"),w=t.get?.("uiSession"),k=pr(M,w);k===v&&x!==void 0||(k!==v&&(N(),v=k,r=[],c(),m()),k!==void 0&&F(k))},U=window.setInterval(X,1e3);X();let T=new MutationObserver(m);T.observe(document.body,{childList:!0,subtree:!0});let y=window.setInterval(b,1500);return b(),{dispose:()=>{o=!0,window.clearInterval(U),window.clearInterval(y),i!==void 0&&window.clearTimeout(i),i=void 0,T.disconnect(),N(),v=void 0,r=[],c();for(let M of document.querySelectorAll(`[${oo}]`))M.remove();document.getElementById(ro)?.remove()}}}var Yi="dsh-model-think-level.error-detail.enabled";function Cx(e){try{return window.localStorage.getItem(e)}catch{return null}}var io=Cx(Yi)!=="false",Td=new Set;function qm(){for(let e of[...Td])e()}function Ji(){return io}function Bm(e){if(io!==e){io=e;try{window.localStorage.setItem(Yi,String(e))}catch{}qm()}}function Sd(e){io!==e&&(io=e,qm())}function Xi(e){return Td.add(e),()=>{Td.delete(e)}}var Xt=require("react");var Dt=require("react/jsx-runtime"),Rx="[data-composer-stat]",Hx="data-bre-autocontinue";function Nx(){let e=Array.from(document.querySelectorAll(Rx)).filter(r=>r.isConnected&&r.getClientRects().length>0),t=e[0];if(t===void 0)return;let n=t.parentElement??void 0;for(let r=0;n!==void 0&&r<8&&!e.every(o=>n!==void 0&&n.contains(o));r+=1)n=n.parentElement??void 0;return n}function Ox(e){let{runner:t,t:n}=e,r=(0,Xt.useSyncExternalStore)(t.subscribe,t.status),[o,i]=(0,Xt.useState)(!1),[a,s]=(0,Xt.useState)(()=>Date.now());if((0,Xt.useEffect)(()=>{if(r.phase!=="waiting")return;s(Date.now());let p=window.setInterval(()=>s(Date.now()),500);return()=>window.clearInterval(p)},[r.phase,r.nextSendAt]),(0,Xt.useEffect)(()=>{r.phase==="idle"&&i(!1)},[r.phase]),r.sessionId===void 0||r.phase==="idle")return null;let d=Math.max(0,Math.ceil((r.nextSendAt-a)/1e3)),l=r.phase==="waiting"?n("autoContinueControllerWaiting",{n:r.consecutive+1,max:r.maxRetries,seconds:d}):r.phase==="sent"?n("autoContinueControllerSent",{n:r.consecutive,max:r.maxRetries}):n("autoContinueControllerExhausted",{max:r.maxRetries}),c=r.detail===""?void 0:n("autoContinueControllerDetail",{detail:r.detail}),f=(p,g)=>(0,Dt.jsx)("button",{type:"button",role:"menuitem",className:"bre-ac-action",onClick:()=>{i(!1),g()},children:p},p),h=[];return r.phase==="waiting"&&h.push(f(n("autoContinueControllerResume"),()=>t.resumeNow())),(r.phase==="waiting"||r.phase==="sent")&&h.push(f(n("autoContinueControllerStop"),()=>t.stop())),r.phase==="exhausted"&&h.push(f(n("autoContinueControllerReset"),()=>t.reset())),h.push(f(n("autoContinueControllerSettings"),e.onSettings)),(0,Dt.jsxs)("span",{className:"bre-ac",children:[(0,Dt.jsxs)("button",{type:"button",className:`bre-ac-chip bre-ac-chip-${r.phase}`,"aria-label":n("autoContinueControllerAria"),"aria-expanded":o,title:c??l,onClick:()=>i(p=>!p),children:[(0,Dt.jsx)("span",{className:"bre-ac-dot","aria-hidden":"true"}),(0,Dt.jsx)("span",{className:"bre-ac-text",children:l})]}),o&&(0,Dt.jsx)("div",{className:"bre-ac-pop",role:"menu",children:h})]})}function Wm(e){let t,n,r=0,o=0,i=()=>{Re(n),n=void 0,t?.remove(),t=void 0},a=()=>{let c=Nx();if(c===void 0){i();return}t!==void 0&&t.parentElement===c&&t.isConnected||(i(),t=document.createElement("span"),t.className="bre-ac-host",t.setAttribute(Hx,""),c.append(t),n=Xe(t,(0,Dt.jsx)(Ox,{runner:e.runner,t:e.t,onSettings:e.onSettings})))},s=()=>{if(r!==0)return;let c=Math.max(0,400-(Date.now()-o));r=window.setTimeout(()=>{r=0,o=Date.now(),a()},c)},d=new MutationObserver(s);d.observe(document.body,{childList:!0,subtree:!0});let l=window.setInterval(a,2e3);return a(),()=>{d.disconnect(),window.clearInterval(l),r!==0&&window.clearTimeout(r),i()}}var vt=require("react");var Ne=require("react");var Pt=require("react/jsx-runtime");function Gm(e){let t=e.data;if(typeof t!="object"||t===null)return;let n=t,r={},o=n.providers;if(typeof o=="object"&&o!==null&&!Array.isArray(o))for(let[a,s]of Object.entries(o))s===!0&&(r[a]=!0);let i=n.installed;return typeof i=="boolean"?{providers:r,installed:i}:{providers:r}}function Um({t:e,value:t,installed:n,disabled:r=!1,onChange:o}){let i=(0,Ne.useId)(),a=`${i}-title`,s=`${i}-hint`,d=e("historyCompatHint")+" "+e("historyCompatCost");return(0,Pt.jsxs)("div",{className:"bre-camouflage","data-plugin":we,"data-open":"1","data-section":"history-compat",title:d,children:[(0,Pt.jsx)("span",{className:"bre-effort-title",id:a,children:e("historyCompatTitle")}),(0,Pt.jsxs)("label",{className:"bre-thinking-switch bre-camouflage-toggle",children:[(0,Pt.jsx)("input",{type:"checkbox",role:"switch",checked:t,disabled:r,"aria-labelledby":a,"aria-describedby":s,onChange:l=>{o(l.target.checked)}}),(0,Pt.jsx)("span",{className:"bre-effort-switch-track","aria-hidden":"true"})]}),(0,Pt.jsx)("span",{className:"bre-sr-only",id:s,children:d}),n?null:(0,Pt.jsx)("p",{className:"bre-camouflage-warn",children:e("historyCompatUnavailable")})]})}function jm(e){let[t,n]=(0,Ne.useState)(!1),[r,o]=(0,Ne.useState)(!1),[i,a]=(0,Ne.useState)(!0),[s,d]=(0,Ne.useState)(!0),l=(0,Ne.useRef)(!1),c=(0,Ne.useRef)(!1),f=(0,Ne.useRef)(!0);(0,Ne.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]),(0,Ne.useEffect)(()=>{if(e===""){d(!1);return}let b=!1;return d(!0),fetch(ra,{method:"GET"}).then(async m=>await m.json()).then(m=>{if(b||!f.current)return;let v=Gm(m);if(v===void 0)return;let x=v.providers[e]===!0;l.current=x,c.current=x,n(x),o(x),v.installed!==void 0&&a(v.installed)}).catch(()=>{}).finally(()=>{!b&&f.current&&d(!1)}),()=>{b=!0}},[e]);let h=(0,Ne.useCallback)(b=>{c.current=b,o(b)},[]),p=(0,Ne.useCallback)(()=>{c.current=l.current,o(l.current)},[]),g=(0,Ne.useCallback)(async()=>{if(e===""||c.current===l.current)return;let b=c.current,m=await fetch(ra,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({route:e,enabled:b})}),v=await m.json();if(!m.ok||v.ok!==!0)throw new Error("history-compat write rejected");let x=Gm(v);l.current=b,c.current=b,n(b),o(b),x!==void 0&&x.installed!==void 0&&a(x.installed)},[e]);return{value:r,saved:t,installed:i,loading:s,setValue:h,reset:p,commit:g}}var Qt=require("react/jsx-runtime");function zm({route:e,api:t,t:n,onDismiss:r}){let o=Gs(e,n),i=jm(e);return(0,Qt.jsx)(wi,{route:e,api:t,t:n,onDismiss:r,extras:(0,Qt.jsxs)(Qt.Fragment,{children:[(0,Qt.jsx)(Ws,{t:n,value:o.value,installed:o.installed,disabled:o.loading,onChange:o.setValue}),(0,Qt.jsx)(Um,{t:n,value:i.value,installed:i.installed,disabled:i.loading,onChange:i.setValue})]}),onCommitExtras:async()=>{let s=(await Promise.allSettled([o.commit(),i.commit()])).find(d=>d.status==="rejected");if(s!==void 0)throw s.reason},onResetExtras:()=>{o.reset(),i.reset()}})}var j=require("react");function $m(e){let t=[];for(let i of e){let a=i.timing?.durationMs;typeof a=="number"&&Number.isFinite(a)&&a>0&&t.push(a)}if(t.length===0)return;t.sort((i,a)=>i-a);let n=t.length>>1,o=(t.length%2===1?t[n]:(t[n-1]+t[n])/2)/1e3;return o>=75?{unit:"minutes",value:Math.max(1,Math.round(o/60))}:{unit:"seconds",value:Math.max(5,Math.round(o/5)*5)}}var Ix=/^(gpt-|chatgpt-|o[134](-|$)|claude-)/;function Dx(e){let t=String(e??"").trim(),n=t.lastIndexOf("/");return n===-1?t:t.slice(n+1)}function Vm(e){let t=Dx(e).toLowerCase();return t.length>0&&Ix.test(t)}var Ym={running:new Map,queued:[]};function so(e){return typeof e!="number"||!Number.isFinite(e)?"\u2014":`${Math.round(e*100)}%`}function Px(e){return!Number.isFinite(e)||e<=0?"\u2014":new Date(e).toLocaleString()}function Jm(e){return typeof e!="number"||!Number.isFinite(e)||e<0?"\u2014":(Math.round(e/100)/10).toFixed(1)}function _x(e,t){return t===void 0?e("fpCostUnknown",{count:3}):t.unit==="minutes"?e("fpCostMinutes",{count:3,minutes:t.value}):e("fpCost",{count:3,seconds:t.value})}function Xm({route:e,api:t,t:n,ctx:r,host:o}){let[i]=(0,j.useState)(()=>xf(o.current)),[a,s]=(0,j.useState)([]),[d,l]=(0,j.useState)(new Map),[c,f]=(0,j.useState)(void 0),[h,p]=(0,j.useState)(void 0),[g,b]=(0,j.useState)(new Set),m=(0,j.useCallback)(k=>{b(C=>{let D=new Set(C);return D.has(k)?D.delete(k):D.add(k),D})},[]),v=(0,j.useMemo)(()=>i?void 0:Sm(e),[i,e]),x=(0,j.useSyncExternalStore)((0,j.useCallback)(k=>v?.subscribe(k)??(()=>{}),[v]),(0,j.useCallback)(()=>v?.getState()??Ym,[v]),(0,j.useCallback)(()=>Ym,[]));(0,j.useEffect)(()=>{if(v!==void 0)return v.onRecord(k=>{p(void 0),l(C=>{let D=new Map(C);return D.set(k.model,k),D})})},[v]),(0,j.useEffect)(()=>{if(v!==void 0)return v.onFailure((k,C)=>{p({model:k,error:C})})},[v]);let E=(0,j.useCallback)(async()=>{if(i)return;let C=(await le(t)).namespace?.value?.providers,D=_n(C,e).map(B=>B.id).filter(B=>typeof B=="string"&&B.length>0).filter(Vm);s(D.map(B=>({model:B})));let _=await gd(e);_.ok?(f(void 0),l(new Map(_.data.records.map(B=>[B.model,B])))):f(_.error)},[t,i,e]);if((0,j.useEffect)(()=>{i||E()},[i,E]),(0,j.useEffect)(()=>{if(!(i||r===void 0))return r.remote.$on("settings/document-updated",()=>{E()})},[i,r,E]),i)return null;let N=a.length,F=a.filter(k=>d.has(k.model)).length,X=a.filter(k=>d.get(k.model)?.status==="identified").length,U=a.filter(k=>d.get(k.model)?.status==="doubtful").length,T=a.filter(k=>d.get(k.model)?.status==="failed").length,y=x.running.size>0,M=x.running.size+x.queued.length,w=(0,j.useMemo)(()=>$m([...d.values()]),[d]);return(0,j.createElement)("div",{className:"bre-fingerprint","data-bre-fingerprint":N>0?"ready":"none"},(0,j.createElement)("div",{className:"bre-fp-head"},(0,j.createElement)("span",{className:"bre-fp-title"},n("fpTitle")),(0,j.createElement)("span",{className:"bre-fp-count"},n("fpCount",{count:N})),(0,j.createElement)("span",{className:"bre-fp-summary",role:"status","aria-live":"polite"},y?n("fpRunning",{done:x.running.size,total:M}):F===0?n("fpSummaryNone"):n("fpSummary",{identified:X,doubtful:U,failed:T})),(0,j.createElement)("span",{className:"grow"}),(0,j.createElement)("button",{type:"button",className:"bre-fp-all",disabled:y||N===0,onClick:()=>{v?.checkAll(a.map(k=>k.model))}},n("fpDetectAll"))),(0,j.createElement)("p",{className:"bre-fp-intro"},n("fpIntro")),c!==void 0?(0,j.createElement)("p",{className:"bre-fp-error"},n("fpLoadFailed",{error:c})):null,h!==void 0?(0,j.createElement)("p",{className:"bre-fp-error",role:"alert"},n("fpRunFailed",{error:`${h.model}: ${h.error}`})):null,(0,j.createElement)("div",{className:"bre-fp-rows"},...a.map(k=>Kx(k,{t:n,runner:v,runnerState:x,records:d,route:e,expanded:g,estimate:w,onToggle:m}))))}function Fx(e){return(0,j.createElement)("svg",{className:"bre-fp-chev"+(e?" is-open":""),viewBox:"0 0 16 16",width:12,height:12,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:!1},(0,j.createElement)("path",{d:e?"M4.5 6.5 8 10 11.5 6.5":"M6.5 4.5 10 8 6.5 11.5"}))}function Kx(e,t){let{t:n,runner:r,runnerState:o,records:i,expanded:a,estimate:s,onToggle:d}=t,l=i.get(e.model),c=o.running.get(e.model),f=o.queued.indexOf(e.model),h=c!==void 0,p=f>=0,g=a.has(e.model),b=h?{className:"is-running",text:n("fpStateRunning",{done:c,total:3})}:p?{className:"is-queued",text:n("fpQueued",{position:f+1})}:l===void 0?{className:"is-idle",text:n("fpStateUnchecked")}:l.status==="failed"?{className:"is-failed",text:n("fpStateFailed")}:l.status==="doubtful"?{className:"is-doubtful",text:n("fpStateDoubtful",{probability:so(l.probability)})}:{className:"is-identified",text:n("fpStateIdentified",{model:l.predictionName??l.prediction??e.model,probability:so(l.probability)})},m=l===void 0?"fpDetect":l.status==="failed"?"fpRetry":"fpRetest";return(0,j.createElement)("div",{className:"bre-fp-row",key:e.model,"data-bre-fp-open":g?"1":void 0},(0,j.createElement)("div",{className:"bre-fp-row-head"},(0,j.createElement)("button",{type:"button",className:"bre-fp-fold","aria-expanded":g,"aria-label":n(g?"fpDetailHide":"fpDetailShow")+" "+e.model,title:n(g?"fpDetailHide":"fpDetailShow"),onClick:()=>{d(e.model)}},Fx(g),(0,j.createElement)("span",{className:"bre-fp-model"},e.model)),(0,j.createElement)("span",{className:`bre-fp-badge ${b.className}`},b.text),(0,j.createElement)("span",{className:"grow"}),(0,j.createElement)("span",{className:"bre-fp-evidence"},l===void 0?_x(n,s):n("fpEvidence",{used:l.usedOutputs,total:3})),(0,j.createElement)("button",{type:"button",className:"bre-fp-action",disabled:h||p,onClick:()=>{r?.check(e.model)}},n(m))),!g||l===void 0?null:l.status!=="failed"?Bx(l,n):qx(l,n))}function Qm(e,t){return e===void 0||e.length===0?null:(0,j.createElement)("div",{className:"bre-fp-chals",title:t("fpChallengeTitle")},...e.map(n=>{let r=n.skipped===!0?" is-skipped":n.accepted?" is-counted":" is-rejected",o=n.skipped===!0?t("fpChallengeSkipped",{index:n.index,numbers:n.expected}):n.accepted?t("fpChallengeCounted",{index:n.index,numbers:n.expected}):t("fpChallengeRejected",{index:n.index,parsed:n.parsed,numbers:n.expected});return(0,j.createElement)("span",{className:`bre-fp-chal${r}`,key:n.index},o)}))}function qx(e,t){let n=e.challenges,r=n!==void 0&&n.length>0;return e.error===void 0&&!r?null:(0,j.createElement)("div",{className:"bre-fp-body"},e.error===void 0?null:(0,j.createElement)("p",{className:"bre-fp-error"},e.error),Qm(n,t))}function Bx(e,t){let n=e.top??[],r=e.timing;return(0,j.createElement)("div",{className:"bre-fp-body"},(0,j.createElement)("div",{className:"bre-fp-family"},(0,j.createElement)("span",{className:"bre-fp-k"},t("fpFamily")),(0,j.createElement)("span",{className:"bre-fp-v"},`${e.familyPrediction??"\u2014"} \xB7 ${so(e.familyProbability)}`),(0,j.createElement)("span",{className:"bre-fp-k"},t("fpSimilarity")),(0,j.createElement)("span",{className:"bre-fp-v"},so(e.top?.[0]?.similarity)),(0,j.createElement)("span",{className:"grow"}),(0,j.createElement)("span",{className:"bre-fp-k"},t("fpCheckedAt",{time:Px(e.checkedAt)}))),Qm(e.challenges,t),r!==void 0?(0,j.createElement)("p",{className:"bre-fp-timing"},t("fpTiming",{first:Jm(r.firstTokenMs),total:Jm(r.durationMs),rate:r.charsPerSecond===void 0?"\u2014":String(Math.round(r.charsPerSecond))})):null,(0,j.createElement)("div",{className:"bre-fp-k",style:{marginTop:"8px"}},t("fpCandidates")),(0,j.createElement)("div",{className:"bre-fp-bars"},...n.map((o,i)=>(0,j.createElement)("div",{className:"bre-fp-bar",key:o.model},(0,j.createElement)("span",{className:"bre-fp-bar-name"},o.model),(0,j.createElement)("span",{className:`bre-fp-bar-fill${i===0?" is-top":""}`,style:{width:`${Math.max(2,Math.round(o.probability*100))}%`}}),(0,j.createElement)("span",{className:"bre-fp-bar-value"},so(o.probability))))),(0,j.createElement)("p",{className:"bre-fp-note"},t("fpClosedSet")))}var Zm="settings.models.provider-card";function Wx(e){if(e===null)return;let t=e.querySelector('[class*="editorActions"]');if(t===null)return;let n=Array.from(t.querySelectorAll("button")),r=t.querySelector('button[class*="secondaryButton"]')??n.at(-2)??null;r!==null&&(r instanceof HTMLButtonElement&&r.disabled||r.click())}function Gx({provider:e,api:t,t:n,ctx:r}){let o=(0,vt.useRef)(null),i=e?.provider,a=(0,vt.useCallback)(()=>{Wx(or(o.current))},[]);return(0,vt.useLayoutEffect)(()=>{let s=o.current,d=or(s);if(s===null||d===null)return;let l=d,c=()=>d.querySelector('[class*="_editor"]')!==null,f=()=>{let p=c()?"1":"0";s.dataset.edit!==p&&(s.dataset.edit=p)};f();let h=new MutationObserver(f);return h.observe(l,{childList:!0,subtree:!0}),()=>{h.disconnect()}},[i]),typeof i!="string"||i.length===0?null:(0,vt.createElement)("div",{ref:o,className:"bre-headers-host","data-bre-provider":i},(0,vt.createElement)(xi,{host:o,t:n}),(0,vt.createElement)(zm,{route:i,api:t,t:n,onDismiss:a}),(0,vt.createElement)(Xm,{route:i,api:t,t:n,ctx:r,host:o}))}function eg(e,t,n){let r=e,o=r.slots?.inject(Zm,()=>{r.slots?.register({name:Zm,key:De,inject:()=>({api:t,t:n,ctx:e})},Gx)});return typeof o=="function"?o:()=>{}}var ut=require("react");function tg(e){let{t}=e,n=(0,ut.useSyncExternalStore)(ho,mt),r=()=>{Fd(!n)};return(0,ut.createElement)("div",{className:"bre-slider-setting"},(0,ut.createElement)("div",{className:"bre-slider-setting-row"},(0,ut.createElement)("div",{className:"bre-slider-setting-copy"},(0,ut.createElement)("div",{className:"bre-slider-setting-title"},t("sliderToggleTitle")),(0,ut.createElement)("div",{className:"bre-slider-setting-description"},t("sliderToggleDescription"))),(0,ut.createElement)("div",{className:"bre-slider-setting-control"},(0,ut.createElement)("span",{className:"bre-slider-setting-state"},t(n?"settingOn":"settingOff")),(0,ut.createElement)("button",{type:"button",role:"switch","aria-label":t("sliderToggleAria"),"aria-checked":n,className:"bre-slider-setting-switch"+(n?" is-on":""),onClick:r},(0,ut.createElement)("span",{className:"bre-slider-setting-switch-knob","aria-hidden":!0})))))}function ng(e,t){let n=e,r=n.slots?.inject("settings.models.footer",()=>{n.slots?.register({name:"settings.models.footer",id:we+"-slider-toggle",order:15,inject:()=>({t})},tg)});return typeof r=="function"?r:()=>{}}var L=require("react"),ig=require("react-dom/client");var Qi=[{label:"1K",value:"1024x1024",edge:1024},{label:"2K",value:"2048x2048",edge:2048},{label:"4K",value:"4096x4096",edge:4096}];function Ux(e){let t=/^(\d{2,5})x(\d{2,5})$/.exec(e.trim());if(t!==null)return Math.max(Number(t[1]),Number(t[2]))}function jx(e){let t=Ux(e),n=Qi[0];if(t===void 0)return n;let r=Number.POSITIVE_INFINITY;for(let o of Qi){let i=Math.abs(o.edge-t);i<r&&(n=o,r=i)}return n}function rg(e){return jx(e).value}var zx=[5,10,15,30,60];function $x(e){let t=zx.map(n=>n*6e4);return t.includes(e)?t:[e,...t]}function Vx(e){let{api:t,t:n}=e,[r,o]=(0,L.useState)(()=>Hi()),[i,a]=(0,L.useState)(void 0),[s,d]=(0,L.useState)(void 0),[l,c]=(0,L.useState)(void 0),[f,h]=(0,L.useState)(!1);(0,L.useEffect)(()=>{let y=!0;return Yt().then(M=>{y&&(M.ok?o(M.data):a(M.error))}),()=>{y=!1}},[]);let[p,g]=(0,L.useState)({});(0,L.useEffect)(()=>{let y=!0;return le(t).then(M=>{let w={};for(let[k,C]of Object.entries(qe(M.namespace))){let D=typeof C.displayName=="string"?C.displayName.trim():"";D.length>0&&(w[k]=D)}y&&g(w)}).catch(()=>{}),()=>{y=!1}},[t]);let b=(0,L.useCallback)(()=>{Yt().then(y=>{y.ok&&o(y.data)})},[]),m=(0,L.useCallback)(y=>{y.length!==0&&(d("default"),wn({defaultModel:y}).then(M=>{d(void 0),M.ok?(c(void 0),b()):c(M.error)}))},[b]),v=(0,L.useCallback)(y=>{d("enabled"),wn({enabled:y}).then(M=>{d(void 0),M.ok?(c(void 0),b()):c(M.error)})},[b]),x=(0,L.useCallback)(y=>{if(r===void 0)return;let M=Number(y);!Number.isFinite(M)||M<6e4||M>36e5||M!==r.defaults.timeoutMs&&wn({defaults:{timeoutMs:M}}).then(w=>{w.ok?(c(void 0),b()):c(w.error)})},[r,b]);if(r===void 0)return(0,L.createElement)("div",{className:"bre-config-loading","aria-busy":!0},(0,L.createElement)("div",{className:"bre-config-loading-text"},i===void 0?n("imagegenLoading"):`${n("imagegenLoadFailed")}: ${i}`),(0,L.createElement)("div",{className:"bre-config-skeleton"},...[0,1,2].map(y=>(0,L.createElement)("div",{key:y,className:"bre-config-skeleton-row"}))));let E=r.models,N=E.length===0,F="bre-config-imagegen-body",X=r.enabled?r.tool.error:void 0,U=new Map;for(let y of E)U.set(y.label,(U.get(y.label)??0)+1);let T=y=>{if((U.get(y.label)??0)<2)return y.label;let M=p[y.route]??y.providerLabel??y.route;return`${y.label} \xB7 ${M}`};return(0,L.createElement)("div",{className:"bre-config-card"},(0,L.createElement)("div",{className:"bre-config-card-head"},(0,L.createElement)("button",{type:"button",className:"bre-config-expand","aria-expanded":f,"aria-controls":F,title:n(f?"imagegenCollapse":"imagegenExpand"),onClick:()=>h(y=>!y)},(0,L.createElement)("span",{className:"bre-config-card-title"},n("imagegenSectionTitle")),(0,L.createElement)("span",{className:"bre-config-card-hint"},r.enabled?n("imagegenEnabledHint"):n("imagegenDisabledHint"))),(0,L.createElement)("span",{className:"bre-config-card-state"},r.enabled?n("cardStateOn"):n("cardStateOff")),(0,L.createElement)("label",{className:"bre-config-switch",title:n("imagegenEnable")},(0,L.createElement)("input",{type:"checkbox",className:"bre-config-switch-input",role:"switch","aria-label":n("imagegenEnable"),checked:r.enabled,disabled:s==="enabled",onChange:y=>v(y.target.checked)}),(0,L.createElement)("span",{className:"bre-config-switch-track","aria-hidden":!0})),(0,L.createElement)("span",{className:"bre-config-chevron","aria-hidden":!0,"data-open":String(f),onClick:()=>h(y=>!y)},"\u203A")),l!==void 0&&(0,L.createElement)("div",{className:"bre-config-notice"},l),f&&(0,L.createElement)("div",{className:"bre-config-card-body",id:F},X!==void 0&&(0,L.createElement)("div",{className:"bre-config-notice bre-config-notice-warn"},(0,L.createElement)("div",null,n("imagegenToolMissing")),(0,L.createElement)("div",{className:"bre-config-notice-why"},n("imagegenToolMissingWhy",{reason:X}))),(0,L.createElement)("div",{className:"bre-config-defaults"},(0,L.createElement)("label",null,n("imagegenDefaultsLabel")),(0,L.createElement)("select",{className:"bre-config-select",value:rg(r.defaults.size),"aria-label":n("imagegenSizeLabel"),onChange:y=>{wn({defaults:{size:y.target.value}}).then(b)}},Qi.map(y=>(0,L.createElement)("option",{key:y.label,value:y.value},y.label))),(0,L.createElement)("select",{className:"bre-config-select",value:r.defaults.quality,"aria-label":n("imagegenQualityLabel"),onChange:y=>{wn({defaults:{quality:y.target.value}}).then(b)}},["low","medium","high","auto"].map(y=>(0,L.createElement)("option",{key:y,value:y},y))),(0,L.createElement)("select",{className:"bre-config-select",value:String(r.defaults.n),"aria-label":n("imagegenCountLabel"),onChange:y=>{wn({defaults:{n:Number(y.target.value)}}).then(b)}},[1,2,3,4].map(y=>(0,L.createElement)("option",{key:y,value:String(y)},`n=${y}`))),(0,L.createElement)("label",{className:"bre-config-timeout",title:n("imagegenTimeoutHint")},(0,L.createElement)("span",{className:"bre-config-timeout-label"},n("imagegenTimeoutLabel")),(0,L.createElement)("select",{className:"bre-config-select",value:String(r.defaults.timeoutMs),"aria-label":n("imagegenTimeoutLabel"),onChange:y=>{x(y.target.value)}},$x(r.defaults.timeoutMs).map(y=>(0,L.createElement)("option",{key:y,value:String(y)},n("imagegenTimeoutMinutes",{minutes:Math.round(y/6e4)})))))),!N&&(0,L.createElement)("div",{className:"bre-config-default-row"},(0,L.createElement)("label",{className:"bre-config-default-label"},n("imagegenDefaultModelLabel")),(0,L.createElement)("select",{className:"bre-config-select bre-config-default-select",value:r.defaultModel??"","aria-label":n("imagegenDefaultModelLabel"),disabled:s==="default",onChange:y=>m(y.target.value)},r.defaultModel===null&&(0,L.createElement)("option",{value:"",disabled:!0},n("imagegenDefaultModelNone")),E.map(y=>(0,L.createElement)("option",{key:y.id,value:y.id},T(y)))))))}var og={EMPTY_RESPONSE:"continue",RATE_LIMIT:"continue",SERVER:"continue",TIMEOUT:"continue",TRANSPORT:"continue",INVALID_REQUEST:"useless",AUTH:"useless",UNKNOWN_MODEL:"useless",UNSUPPORTED_REASONING_EFFORT:"useless",PI_AI_ERROR:"depends",MALFORMED_RESPONSE:"depends",LEGACY_CLI_OUTCOME_UNKNOWN:"depends"},Yx={continue:"autoContinueTagContinue",useless:"autoContinueTagUseless",depends:"autoContinueTagDepends"};function Jx(e){let{t,policy:n}=e,[r,o]=(0,L.useState)(!1),i=(0,L.useRef)(null),a=(0,L.useRef)(null),[s,d]=(0,L.useState)(null);(0,L.useEffect)(()=>{if(!r)return;let m=x=>{let E=i.current;E!==null&&x.target instanceof Node&&!E.contains(x.target)&&o(!1)},v=()=>o(!1);return document.addEventListener("mousedown",m),window.addEventListener("resize",v),window.addEventListener("scroll",v,!0),()=>{document.removeEventListener("mousedown",m),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0)}},[r]);let l=()=>{if(r){o(!1);return}let m=a.current;if(m===null){o(!0);return}let v=m.getBoundingClientRect(),x=Math.min(Math.max(v.width,400),window.innerWidth-24),E=Math.min(Math.max(8,v.right-x),window.innerWidth-x-8),N=window.innerHeight-v.bottom-12,F=470;d(N>=F?{left:E,width:x,top:v.bottom+6}:v.top>F?{left:E,width:x,bottom:window.innerHeight-v.top+6}:{left:E,width:x,top:Math.max(8,window.innerHeight-8-460)}),o(!0)},c=Di.filter(m=>n.codes[m]===!0),f=[];n.maxTokens&&f.push((0,L.createElement)("span",{className:"bre-config-chip",key:"max-tokens"},t("autoContinueMaxTokens"))),n.httpStatus&&f.push((0,L.createElement)("span",{className:"bre-config-chip",key:"http"},t("autoContinueChipHttp")));for(let m of c)f.push((0,L.createElement)("span",{className:"bre-config-chip",key:m},m));let h=f.slice(0,3),p=f.length-h.length,g=(m,v,x,E,N,F)=>(0,L.createElement)("label",{className:"bre-config-code-row",key:m},(0,L.createElement)("input",{type:"checkbox",className:"bre-config-code-input",checked:v,onChange:X=>F(X.target.checked)}),(0,L.createElement)("span",{className:`bre-config-check${v?" bre-config-check-on":""}`,"aria-hidden":!0}),(0,L.createElement)("span",{className:"bre-config-code-name"},x),(0,L.createElement)("span",{className:"bre-config-code-why",title:E},E),(0,L.createElement)("span",{className:`bre-config-code-tag bre-config-code-tag-${N}`},t(Yx[N]))),b=(m,v)=>(0,L.createElement)("div",{className:"bre-config-code-group",key:m},(0,L.createElement)("div",{className:"bre-config-code-group-title"},t(m)),v);return(0,L.createElement)("div",{className:"bre-config-trigger-control",ref:i},(0,L.createElement)("button",{type:"button",className:"bre-config-trigger-button",ref:a,"aria-expanded":r,"aria-label":t("autoContinueTriggers"),onClick:l},h,p>0&&(0,L.createElement)("span",{className:"bre-config-chip bre-config-chip-more"},t("autoContinueCodesMore",{count:p})),f.length===0&&(0,L.createElement)("span",{className:"bre-config-multiselect-empty"},"\u2014"),(0,L.createElement)("span",{className:"bre-config-multiselect-caret","aria-hidden":!0},"\u25BE")),r&&(0,L.createElement)("div",{className:"bre-config-multiselect-pop",role:"group","aria-label":t("autoContinueErrorTypes"),style:s===null?void 0:{left:`${s.left}px`,width:`${s.width}px`,...s.top===void 0?{}:{top:`${s.top}px`},...s.bottom===void 0?{}:{bottom:`${s.bottom}px`}}},b("autoContinueGroupFlags",[g("flag:max-tokens",n.maxTokens,t("autoContinueMaxTokens"),t("autoContinueWhyMaxTokens"),"continue",m=>e.onFlag("maxTokens",m)),g("flag:http",n.httpStatus,t("autoContinueHttpStatus"),t("autoContinueWhyHttpStatus"),"continue",m=>e.onFlag("httpStatus",m))]),b("autoContinueGroupTransient",to.map(m=>g(m,n.codes[m]===!0,(0,L.createElement)("code",{className:"bre-config-code-name-inner"},m),t(`autoContinueWhy${m}`),og[m]??"depends",v=>e.onToggle(m,v)))),b("autoContinueGroupOther",Ii.map(m=>g(m,n.codes[m]===!0,(0,L.createElement)("code",{className:"bre-config-code-name-inner"},m),t(`autoContinueWhy${m}`),og[m]??"depends",v=>e.onToggle(m,v)))),(0,L.createElement)("div",{className:"bre-config-multiselect-foot"},(0,L.createElement)("button",{type:"button",className:"bre-config-link",onClick:()=>e.onBulk(!0)},t("autoContinueCodesAll")),(0,L.createElement)("button",{type:"button",className:"bre-config-link",onClick:()=>e.onBulk(!1)},t("autoContinueCodesNone")),(0,L.createElement)("button",{type:"button",className:"bre-config-link bre-config-link-quiet",onClick:e.onRestore},t("autoContinueRestore")))))}function Xx(e){let{t}=e,n=(0,L.useSyncExternalStore)(zi,Jt),r=(0,L.useSyncExternalStore)($i,Ye),[o,i]=(0,L.useState)(String(r.waitSeconds)),[a,s]=(0,L.useState)(String(r.maxRetries));(0,L.useEffect)(()=>{i(String(r.waitSeconds))},[r.waitSeconds]),(0,L.useEffect)(()=>{s(String(r.maxRetries))},[r.maxRetries]);let d=()=>{kn({waitSeconds:o.trim()===""?r.waitSeconds:Number(o)}),i(String(Ye().waitSeconds))},l=()=>{kn({maxRetries:a.trim()===""?r.maxRetries:Number(a)}),s(String(Ye().maxRetries))},[c,f]=(0,L.useState)(!1),h="bre-config-auto-continue-body",p=r.policy,g=x=>{kn({policy:{...p,...x}})},b=(x,E)=>{kn({policy:{...p,codes:{...p.codes,[x]:E}}})},m=x=>{let E={...p.codes};for(let N of Di)E[N]=x;kn({policy:{...p,codes:E}})},v=()=>{kn({policy:xn})};return(0,L.createElement)("div",{className:"bre-config-card bre-config-auto-card"},(0,L.createElement)("div",{className:"bre-config-card-head"},(0,L.createElement)("button",{type:"button",className:"bre-config-expand","aria-expanded":c,"aria-controls":h,title:t(c?"autoContinueCollapse":"autoContinueExpand"),onClick:()=>f(x=>!x)},(0,L.createElement)("span",{className:"bre-config-card-title"},t("autoContinueSectionTitle")),!c&&(0,L.createElement)("span",{className:"bre-config-card-hint bre-config-auto-summary"},t("autoContinueHint",{seconds:r.waitSeconds,count:r.maxRetries}))),(0,L.createElement)("span",{className:"bre-config-card-state"},t(n?"cardStateOn":"cardStateOff")),(0,L.createElement)("label",{className:"bre-config-switch",title:t("autoContinueAria")},(0,L.createElement)("input",{type:"checkbox",className:"bre-config-switch-input",role:"switch","aria-label":t("autoContinueAria"),checked:n,onChange:x=>{Nm(x.target.checked)}}),(0,L.createElement)("span",{className:"bre-config-switch-track","aria-hidden":!0})),(0,L.createElement)("span",{className:"bre-config-chevron","aria-hidden":!0,"data-open":String(c),onClick:()=>f(x=>!x)},"\u203A")),c&&(0,L.createElement)("div",{className:"bre-config-card-body",id:h},(0,L.createElement)("div",{className:"bre-config-auto-fields"},(0,L.createElement)("label",{className:"bre-config-auto-field"},(0,L.createElement)("span",{className:"bre-config-auto-label"},t("autoContinueWaitLabel")),(0,L.createElement)("span",{className:"bre-config-auto-control"},(0,L.createElement)("input",{type:"number",className:"bre-config-auto-input",min:qi,max:Bi,step:1,value:o,"aria-label":`${t("autoContinueWaitLabel")} (${t("autoContinueSecondsUnit")})`,title:`${qi}\u2013${Bi} ${t("autoContinueSecondsUnit")}`,onChange:x=>i(x.target.value),onBlur:d,onKeyDown:x=>{x.key==="Enter"&&x.currentTarget.blur()}}),(0,L.createElement)("span",{className:"bre-config-auto-unit","aria-hidden":!0},t("autoContinueSecondsUnit")))),(0,L.createElement)("label",{className:"bre-config-auto-field"},(0,L.createElement)("span",{className:"bre-config-auto-label"},t("autoContinueRetriesLabel")),(0,L.createElement)("span",{className:"bre-config-auto-control"},(0,L.createElement)("input",{type:"number",className:"bre-config-auto-input",min:Wi,max:Gi,step:1,value:a,"aria-label":`${t("autoContinueRetriesLabel")} (${t("autoContinueRetriesUnit")})`,title:`${Wi}\u2013${Gi} ${t("autoContinueRetriesUnit")}`,onChange:x=>s(x.target.value),onBlur:l,onKeyDown:x=>{x.key==="Enter"&&x.currentTarget.blur()}}),(0,L.createElement)("span",{className:"bre-config-auto-unit","aria-hidden":!0},t("autoContinueRetriesUnit"))))),(0,L.createElement)("div",{className:"bre-config-trigger-field"},(0,L.createElement)("span",{className:"bre-config-auto-label"},t("autoContinueTriggers")),(0,L.createElement)(Jx,{t,policy:p,onFlag:(x,E)=>g({[x]:E}),onToggle:b,onBulk:m,onRestore:v}))))}function Qx(e){let{t}=e,n=(0,L.useSyncExternalStore)(Xi,Ji),[r,o]=(0,L.useState)(!1),i="bre-config-error-detail-body";return(0,L.createElement)("div",{className:"bre-config-card"},(0,L.createElement)("div",{className:"bre-config-card-head"},(0,L.createElement)("button",{type:"button",className:"bre-config-expand","aria-expanded":r,"aria-controls":i,title:t(r?"autoContinueCollapse":"autoContinueExpand"),onClick:()=>o(a=>!a)},(0,L.createElement)("span",{className:"bre-config-card-title"},t("errorDetailSectionTitle")),!r&&(0,L.createElement)("span",{className:"bre-config-card-hint"},t("errorDetailSummary"))),(0,L.createElement)("span",{className:"bre-config-card-state"},t(n?"cardStateOn":"cardStateOff")),(0,L.createElement)("label",{className:"bre-config-switch",title:t("errorDetailAria")},(0,L.createElement)("input",{type:"checkbox",className:"bre-config-switch-input",role:"switch","aria-label":t("errorDetailAria"),checked:n,onChange:a=>{Bm(a.target.checked)}}),(0,L.createElement)("span",{className:"bre-config-switch-track","aria-hidden":!0})),(0,L.createElement)("span",{className:"bre-config-chevron","aria-hidden":!0,"data-open":String(r),onClick:()=>o(a=>!a)},"\u203A")),r&&(0,L.createElement)("div",{className:"bre-config-card-body",id:i},(0,L.createElement)("p",{className:"bre-config-card-hint bre-config-error-detail-copy"},t("errorDetailHint"))))}function Zx(e){let{t,onClose:n}=e,r=(0,L.useRef)(null);return(0,L.useEffect)(()=>{let o=i=>{i.key==="Escape"&&n()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n]),(0,L.createElement)("div",{className:"bre-config-backdrop",onMouseDown:o=>{o.target===o.currentTarget&&n()}},(0,L.createElement)("div",{className:"bre-config-pane",ref:r},(0,L.createElement)("div",{className:"bre-config-head"},(0,L.createElement)("span",{className:"bre-config-title"},t("configPaneTitle")),(0,L.createElement)("button",{className:"bre-config-close",type:"button","aria-label":t("configPaneClose"),onClick:n},"\u2715")),(0,L.createElement)("div",{className:"bre-config-body"},(0,L.createElement)(Be,{fallbackText:t("configPaneFailed")},(0,L.createElement)(Vx,{api:e.api,t:e.t})),(0,L.createElement)(Be,{fallbackText:t("configPaneFailed")},(0,L.createElement)(Xx,{t:e.t})),(0,L.createElement)(Be,{fallbackText:t("configPaneFailed")},(0,L.createElement)(Qx,{t:e.t})))))}function Md(e){let t=document.createElement("div");t.className="bre-config-pane-host",document.body.appendChild(t);let n=(0,ig.createRoot)(t),r=!0,o=()=>{r&&(r=!1,Re({wrapper:t,root:n}))};return n.render((0,L.createElement)(Zx,{api:e.api,t:e.t,onClose:o})),{close:o}}function ag(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return r.length===0||n.includes(r)}function sg(e,t){let n=e.replace(/^\s+/,"");if(n.length===0)return t.map(a=>({label:a.isDefault?`${a.label}\uFF08\u9ED8\u8BA4\uFF09`:a.label,insertText:a.id,kind:"model",hint:a.id}));let r=n.match(/^(\S+)(\s+[\s\S]*)?$/);if(r===null)return[];let o=r[1];return t.filter(a=>ag(a.id,o)||ag(a.label,o)).map(a=>({label:a.isDefault?`${a.label}\uFF08\u9ED8\u8BA4\uFF09`:a.label,insertText:a.id,kind:"model",hint:a.id}))}var ek="imagegen",tk=3e4,lo;function Ld(){lo=void 0}async function nk(){if(lo!==void 0&&Date.now()-lo.at<tk)return lo.models;let e=await Yt(),t=e.ok&&e.data.enabled?e.data.models.map(n=>({id:n.id,label:n.label,isDefault:e.data.defaultModel===n.id})):[];return lo={at:Date.now(),models:t},t}function dg(e){let t;try{t=e.inputTriggers}catch{t=void 0}let n=sm(Ld);if(t===void 0||typeof t.registerSource!="function")return n;let r=!0;try{t.registerSource({trigger:"/",name:ek,order:900,candidates:o=>{let i=typeof o?.text=="string"?o.text:"";return/^\/?生图(?:\s|$)/.test(i)?nk().then(a=>sg(i.replace(/^\/?生图/,""),a)):[]}})}catch{r=!1}return()=>{r=!1,n()}}var En=require("react");var lg="tool.call.images",rk="generate_image";function ok(e){if(e===void 0||typeof e!="object")return[];let t=e.content??e.resultView?.content;if(!Array.isArray(t))return[];let n=[];for(let r of t)if(r!==null&&typeof r=="object"&&r.type==="image"){let o=r.attachment;o!==void 0&&typeof o.attachmentId=="string"&&n.push({attachment:o})}return n}function ik(e){let t=Array.isArray(e.content)?e.content:[];for(let n of t)if(n!==null&&typeof n=="object"&&n.type==="text"&&typeof n.text=="string")return n.text;return null}function ak(e){let t=e.meta;if(t===void 0||typeof t!="object")return null;let n=[],r=t.paramsUsed;typeof t.model=="string"&&t.model.length>0&&n.push(r===void 0?t.model:`${t.model} \xB7 ${r.size} \xB7 ${r.quality} \xB7 n ${r.n}`);let o=(t.images??[]).map(i=>i.filePath).filter(i=>typeof i=="string");return o.length>0&&n.push(o.join(`
5306
+ `;var Er="bre:endpoints-changed",Tr="bre:settings-changed",Sr="bre:balance-changed";var Rr=require("react"),Wl=require("react-dom");var O=require("react"),Rl=require("react-dom");var X=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function ll(e){let t=e.toLowerCase();return t.includes("compat")||t.includes("thinkingtokenbudget")||t.includes("vllmpriority")||t.includes("supportsmaxoutput")}function Dn(e,t){if(!X(e))return[];let n=e[t];return!X(n)||!Array.isArray(n.models)?[]:n.models.filter(X)}function tn(e,t){if(!X(e))return{};let n=e[t];if(!X(n))return{};let r=typeof n.api=="string"?n.api:void 0,o=typeof n.baseURL=="string"?n.baseURL:void 0,i=typeof n.displayName=="string"?n.displayName:void 0;return{api:r,baseURL:o,displayName:i}}var gl=["off","minimal","low","medium","high","xhigh","max"],Pg=["text","image"];var Dg=[{id:"deepseek-v4-vision",patterns:["deepseek-v4-flash-vision","deepseek-v4-vision"],efforts:{off:"none",low:"low",high:"high",max:"max"},defaultEffort:"high",compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:384e3,note:"DeepSeek \u89C6\u89C9\u5B9E\u9A8C\u7248 id\uFF08deepseek-v4-flash-vision-exp\uFF09\u3002\u5B98\u65B9\u76EE\u5F55\u5DF2\u6807\u6CE8\u8BE5\u6A21\u578B\u9000\u5F79\uFF0C\u540D\u5B57\u4ECD\u88AB\u63A5\u53D7\u3001\u7531\u73B0\u884C deepseek-flash \u63D0\u4F9B\u670D\u52A1\u2014\u2014\u56FE\u7247\u8F93\u5165\u73B0\u5DF2\u7531 deepseek-flash \u539F\u751F\u63D0\u4F9B\u3002"},{id:"deepseek-v4-1-flash",patterns:["deepseek-v4.1-flash","deepseek-flash"],efforts:{off:"none",low:"low",high:"high",max:"max"},defaultEffort:"high",compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:384e3,note:'DeepSeek-V4.1-Flash\uFF082026-09-10 \u53D1\u5E03\u7684\u73B0\u884C\u5B98\u65B9\u6A21\u578B\uFF0C\u5B98\u65B9 id \u4E3A deepseek-flash\uFF1B25 \u4E07\u5E76\u53D1\u3001**\u539F\u751F\u56FE\u7247\u8F93\u5165**\uFF09\u3002V4.1 \u7684\u5404\u5199\u6CD5\uFF08deepseek-flash\u3001deepseek-v4.1-flash\u3001deepseek-v4-1-flash\uFF0C\u4EE5\u53CA\u5E26\u65E5\u671F\u540E\u7F00\u7684\u7B2C\u4E09\u65B9\u53D8\u4F53\uFF09\u90FD\u5F52\u6B64\u6761\u2014\u2014\u7EAF\u6587\u672C\u7684 deepseek-v4 \u4E3B\u5E72\u4E0D\u518D\u541E\u6389\u5B83\u4EEC\u3002\u5B98\u65B9\u679A\u4E3E\u540C V4 \u7CFB\uFF1AOff\uFF08thinking:"disabled"\uFF09/ Low / High / Max\uFF0C\u9ED8\u8BA4 High\uFF1B\u5BB9\u91CF 1,048,576 \u4E0A\u4E0B\u6587 / \u6700\u5927\u8F93\u51FA 384K\u3002'},{id:"deepseek-v4",patterns:["deepseek-v4"],efforts:{off:"none",low:"low",high:"high",max:"max"},defaultEffort:"high",compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text"],contextWindow:1048576,maxTokens:384e3,note:'DeepSeek \u5B98\u65B9\u679A\u4E3E Low / High / Max\uFF08\u9ED8\u8BA4 High\uFF1Bminimal\u3001medium\u3001xhigh \u517C\u5BB9\u6620\u5C04\uFF0Cultra\u2192max\uFF09\uFF0COff \u5373 thinking:"disabled"\uFF08Responses API \u4E0B off \u4EE5 reasoning.effort:"none" \u8868\u793A\uFF09\u3002\u672C\u6761\u76EE\u662F V4 \u5BB6\u65CF\u7684**\u7EAF\u6587\u672C**\u6210\u5458\uFF1Adeepseek-v4-pro\uFF08= DeepSeek-V4-Pro-0813\uFF0C\u5B98\u65B9\u4E0D\u652F\u6301\u56FE\u7247\uFF09\u4E0E\u5DF2\u9000\u5F79\u6A21\u578B\u7684\u517C\u5BB9\u522B\u540D deepseek-v4-flash\uFF08deepseek-v4-flash-vision-exp \u53E6\u6709\u89C6\u89C9\u6761\u76EE\uFF09\u3002**\u6536\u56FE\u7684 V4.1-Flash\uFF08\u5B98\u65B9 id deepseek-flash\uFF09\u53E6\u6709\u4E13\u95E8\u6761\u76EE**\uFF0C\u5176 input \u542B image\u3002\u5BB9\u91CF\uFF1A1,048,576 \u4E0A\u4E0B\u6587 / \u6700\u5927\u8F93\u51FA 384K\uFF08393,216\uFF1B\u9ED8\u8BA4\u975E\u601D\u8003 8K\u3001\u601D\u8003 64K\u3001effort=max \u65F6 128K\uFF09\u3002'},{id:"deepseek-v3",patterns:["deepseek-v3","deepseek-chat"],efforts:{off:"none",high:"high",max:"max"},compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text"],contextWindow:163840,maxTokens:65536,note:"DeepSeek V3 \u6863\u4F4D\uFF1AOff / High / Max\u3002\u5B98\u65B9\u5DF2\u505C\u552E V3 \u4EE3\uFF08\u5B9A\u4EF7\u9875\u4EC5\u5269 V4 \u4E09\u578B\uFF09\uFF0C\u5BB9\u91CF\u53D6\u76EE\u5F55\u73B0\u5F79\u503C\u3002"},{id:"deepseek-r1",patterns:["deepseek-r1","deepseek-reasoner"],efforts:{high:"high"},defaultEffort:"high",compat:{thinkingFormat:"deepseek",supportsReasoningEffort:!0},input:["text"],contextWindow:163840,maxTokens:32768,note:"DeepSeek-R1 \u4E3A\u63A8\u7406\u6A21\u578B\uFF0C\u4EC5\u63D0\u4F9B High\u3002\u5B98\u65B9\u5DF2\u4E0B\u67B6 R1 \u4EE3\uFF0C\u5BB9\u91CF\u53D6\u76EE\u5F55 r1-0528 \u503C\u3002"},{id:"openai-gpt-5-2",patterns:["gpt-5.2"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.2 \u6863\u4F4D\uFF1ANone / Low / Medium / High / XHigh\uFF08\u9ED8\u8BA4 None\uFF09\u3002\u5B98\u65B9\u53E6\u652F\u6301 PDF \u8F93\u5165\uFF08\u6838\u5FC3\u8BCD\u8868\u6682\u4E0D\u542B\uFF09\u3002gpt-5.2-pro \u5B98\u65B9\u9875\u672A\u5355\u5217\u6863\u4F4D\u884C\uFF0C\u6309\u672C\u6761\u76EE\u540C\u6863\u5904\u7406\uFF1Bgpt-5.2-codex \u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"openai-gpt-5-2-codex",patterns:["gpt-5.2-codex"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.2-Codex \u6863\u4F4D\uFF1ALow / Medium / High / XHigh\uFF08\u65E0 None \u6863\uFF0C\u52FF\u52FE Off\uFF09\uFF0C\u5E26\u56FE\u8F93\u5165\u3001400K\u3002"},{id:"openai-gpt-5-6",patterns:["gpt-5.6"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:"GPT-5.6\uFF08\u522B\u540D\u5373 sol\uFF09\u6863\u4F4D\uFF1ANone / Low / Medium(\u9ED8\u8BA4) / High / XHigh / Max\uFF1Bsol/luna/terra \u540C\u6863\uFF0C\u5E26\u56FE\u8F93\u5165\u30022026-10 \u6821\u51C6\uFF1A\u4E0A\u4E0B\u6587\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8BB0 272,000\uFF08\u6B64\u524D\u8BEF\u8BB0 1,050,000\uFF09\u3002"},{id:"openai-gpt-5-5",patterns:["gpt-5.5"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:"GPT-5.5 \u6863\u4F4D\uFF1ANone / Low / Medium(\u9ED8\u8BA4) / High / XHigh\uFF08\u65E0 Max \u6863\uFF09\uFF0C\u5E26\u56FE\u8F93\u5165\u3002pro \u53D8\u4F53\u4EC5 High(\u9ED8\u8BA4) / XHigh\u30011.05M \u4E0A\u4E0B\u6587\u4E14\u4EC5 Responses API\u30022026-10 \u6821\u51C6\uFF1A\u4E0A\u4E0B\u6587\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8BB0 272,000\uFF08\u6B64\u524D\u8BEF\u8BB0 1,050,000\uFF09\u3002"},{id:"openai-gpt-5-4",patterns:["gpt-5.4"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:"GPT-5.4 \u6863\u4F4D\uFF1ANone(\u9ED8\u8BA4) / Low / Medium / High / XHigh\uFF0C\u5E26\u56FE\u8F93\u5165\u3002pro \u53D8\u4F53\u4EC5 Medium/High/XHigh\uFF081.05M\uFF09\uFF1Bmini/nano \u4E3A 400K \u4E0A\u4E0B\u6587\u30022026-10 \u6821\u51C6\uFF1A\u4E0A\u4E0B\u6587\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8BB0 272,000\uFF08\u6B64\u524D\u8BEF\u8BB0 1,050,000\uFF09\u3002"},{id:"openai-gpt-5-3",patterns:["gpt-5.3"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.3-Codex \u6863\u4F4D\uFF1ANone / Low / Medium(\u9ED8\u8BA4) / High / XHigh\uFF0C\u5E26\u56FE\u8F93\u5165\u3001400K\uFF1B2026-10 \u6821\u51C6\uFF1ANone \u6863\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8865\u56DE\uFF08\u6B64\u524D\u6309\u65E7\u6A21\u578B\u9875\u8BB0\u4E3A\u65E0 None\uFF09\u3002gpt-5.3-chat \u4E3A\u975E\u63A8\u7406\u804A\u5929\u6A21\u578B\uFF08\u89C1 chat \u6761\u76EE\uFF09\u3002"},{id:"openai-gpt-5-1",patterns:["gpt-5.1"],efforts:{off:"none",low:"low",medium:"medium",high:"high"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.1 \u6863\u4F4D\uFF1ANone / Low / Medium / High\uFF08\u9ED8\u8BA4 None\uFF09\u3002"},{id:"openai-gpt-5-1-codex",patterns:["gpt-5.1-codex"],efforts:{low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.1-Codex \u7CFB\u5217\uFF1A\u5B98\u65B9\u6A21\u578B\u9875\u672A\u5355\u5217 effort \u503C\u57DF\uFF0C\u6309\u540C\u4EE3\u4FDD\u5B88\u6863 Low / Medium / High\uFF08\u65E0 None\uFF1Bxhigh \u672A\u8BC1\u5B9E\uFF09\u3002\u5982\u7AEF\u70B9\u652F\u6301 xhigh/none \u53EF\u624B\u8C03\u3002"},{id:"openai-gpt-5",patterns:["gpt-5"],efforts:{minimal:"minimal",low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5 \u521D\u4EE3\u6863\u4F4D\uFF1AMinimal / Low / Medium / High\uFF0C\u65E0\u5173\u95ED\u6863\u3002"},{id:"openai-gpt-5-2-chat",patterns:["gpt-5.2-chat"],efforts:{off:null,medium:"medium",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:128e3,maxTokens:16384,note:"GPT-5.2-Chat\uFF08\u5B98\u65B9 id gpt-5.2-chat-latest\uFF09\uFF1Api-ai 1.2.0 \u76EE\u5F55\u8BB0\u4E3A\u63A8\u7406\u6A21\u578B\uFF0C\u4EC5 Medium / XHigh \u4E24\u6863\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF0C\u975E\u663E\u5F0F\u5173\u95ED\uFF09\uFF0C128K / 16,384 \u8F93\u51FA\u30022026-10 \u65B0\u589E\u6761\u76EE\u3002"},{id:"openai-chat",patterns:["gpt-5.1-chat-latest","gpt-5.3-chat-latest","gpt-5-chat-latest","gpt-chat-latest","gpt-5-chat","gpt-5.1-chat","gpt-5.3-chat"],efforts:!1,input:["text","image"],contextWindow:128e3,maxTokens:16384,note:"-chat \u7CFB\u5217\uFF08\u5B98\u65B9 id \u4E3A gpt-5.x-chat-latest\uFF09\u4E3A\u975E\u63A8\u7406\u804A\u5929\u6A21\u578B\uFF0C\u4E0D\u652F\u6301 effort \u53C2\u6570\uFF08\u52FF\u52FE\u601D\u8003\u6863\uFF09\uFF1B\u5B98\u65B9\u652F\u6301\u56FE\u7247\u8F93\u5165\uFF0C128K / 16,384 \u8F93\u51FA\u3002gpt-5-chat-latest \u5DF2\u4E8E 2026-07-23 \u4E0B\u67B6\u3001gpt-chat-latest \u5DF2\u65E0\u5B98\u65B9\u9875\u9762\uFF08\u4FDD\u7559\u6A21\u5F0F\u4F9B\u7F51\u5173\uFF09\u3002gpt-5.2-chat \u53E6\u6709\u63A8\u7406\u6761\u76EE\u3002"},{id:"openai-o",patterns:["o1","o3","o4"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:2e5,maxTokens:1e5,note:"OpenAI o \u7CFB\u6863\u4F4D\uFF1ALow / Medium / High\u3002\u5B98\u65B9\u5DF2\u4E8E 2026-06 \u516C\u544A\u9000\u5F79\uFF08o1/o1-pro/o3-mini/o4-mini 2026-10-23 \u79FB\u9664\u3001o3/o3-pro 2026-12-11\uFF09\uFF0C\u7F51\u5173\u6B8B\u7559\u4ECD\u53EF\u547D\u4E2D\uFF1B\u591A\u6570 o \u7CFB\u7AEF\u70B9\u6536\u56FE\uFF08o3-mini \u4F8B\u5916\uFF09\u3002"},{id:"openai-gpt-oss",patterns:["gpt-oss"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"low",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:131072,maxTokens:131072,note:"GPT-OSS \u5F00\u6E90\u6743\u91CD\uFF08Ollama/vLLM \u5E38\u89C1\uFF09\uFF1Areasoning effort Low / Medium / High\uFF0C\u7EAF\u6587\u672C\uFF0C131K \u4E0A\u4E0B\u6587 / 131K \u8F93\u51FA\u30022026-09 \u590D\u6838\uFF1A\u5B98\u65B9\u6A21\u578B\u9875\u73B0\u5728\u5199 Chat Completions = Not supported\u3001\u65E0\u56FE\u7247\u8F93\u5165\uFF08\u9ED8\u8BA4 Low \u6765\u81EA\u5B98\u65B9 CLI\uFF0C\u4E0D\u662F API \u9875\uFF09\uFF0C\u56E0\u6B64\u8FD9\u91CC\u4E0D\u518D\u58F0\u660E Off\u3002"},{id:"openai-gpt-6",patterns:["gpt-6-luna","gpt-6-sol","gpt-6-terra","gpt-6.1"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:'GPT-6 \u7CFB\uFF08luna/sol/terra\uFF0C2026-10 \u6821\u51C6\u65B0\u589E\uFF09\uFF1Api-ai 1.2.0 \u76EE\u5F55\u5168\u6863 None / Low / Medium / High / XHigh / Max\uFF0C\u5E26\u56FE\u8F93\u5165\uFF0C272,000 \u4E0A\u4E0B\u6587 / 128,000 \u8F93\u51FA\u3002gpt-6-astra \u89C1\u5355\u72EC\u6761\u76EE\uFF08\u88F8 "gpt-6" \u4E0E 6.1-sol \u7531 astra \u6761\u76EE\u627F\u63A5\uFF0Coff \u4EE5\u7701\u7565\u8868\u8FBE\uFF0C"none" \u672A\u8BC1\u5B9E\u53EF\u624B\u8C03\uFF09\u3002'},{id:"openai-gpt-6-astra",patterns:["gpt-6-astra","gpt-6","gpt-6.1-sol"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:272e3,maxTokens:128e3,note:'GPT-6 Astra \u6863\u4F4D\uFF1ALow / Medium / High / XHigh / Max\u2014\u2014**\u6CA1\u6709 None \u6863**\uFF08\u5B98\u65B9\u539F\u6587\uFF1A\u8BBE\u4E3A none \u8FD4\u56DE HTTP 400\uFF09\uFF0C\u56E0\u6B64\u672C\u6761\u76EE\u4E0D\u58F0\u660E Off\u3002\u5E26\u56FE\u8F93\u5165\uFF1B2026-10 \u6821\u51C6\uFF1A\u4E0A\u4E0B\u6587\u6309 pi-ai 1.2.0 \u76EE\u5F55\u8BB0 272,000\uFF08\u6B64\u524D\u8BEF\u8BB0 1,050,000\uFF09\u3002\u5DE5\u5177\u8C03\u7528\u9700\u8D70 Responses API\u3002gpt-6 luna/sol/terra \u89C1\u5355\u72EC\u6761\u76EE\uFF1B\u88F8 "gpt-6" \u4E0E 6.1-sol\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\u7531\u672C\u6761\u76EE\u627F\u63A5\u3002'},{id:"openai-gpt-daybreak",patterns:["gpt-daybreak"],efforts:{off:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:105e4,maxTokens:128e3,note:"GPT-Daybreak\uFF08blue-latest 1.05M / red-latest 400K\uFF0C2026-10 \u65B0\u589E\uFF09\uFF1Api-ai 1.2.0 \u76EE\u5F55\u5168\u6863 None / Low / Medium / High / XHigh / Max\uFF0C\u5E26\u56FE\u8F93\u5165 / 128,000 \u8F93\u51FA\u3002"},{id:"openai-gpt-realtime",patterns:["gpt-realtime"],efforts:{minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:128e3,maxTokens:32e3,note:"GPT-Realtime 2.1\uFF082026-10 \u65B0\u589E\uFF09\uFF1Api-ai 1.2.0 \u76EE\u5F55\u6863\u4F4D Minimal / Low / Medium / High / XHigh\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF0C128,000 \u4E0A\u4E0B\u6587 / 32,000 \u8F93\u51FA\u3002"},{id:"openai-gpt-5-6-cyber",patterns:["gpt-5.6-cyber"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:4e5,maxTokens:128e3,note:"GPT-5.6-Cyber\uFF1A\u5B98\u65B9\u6A21\u578B\u9875\u672A\u5355\u5217 effort \u503C\u57DF\uFF08\u4E0D\u7B49\u4E8E\u4E0D\u652F\u6301\uFF09\uFF0C\u6545\u6309\u540C\u4EE3\u4FDD\u5B88\u6863 Low / Medium / High / XHigh\uFF1B\u8BE5\u578B\u53F7\u4EC5 Responses API\uFF0C\u5E26\u56FE\u8F93\u5165\u3001400K \u4E0A\u4E0B\u6587\u3002\u5B98\u65B9\u652F\u6301\u7684\u5176\u4ED6\u6863\u4F4D\u53EF\u624B\u8C03\u540E\u5E94\u7528\u3002"},{id:"openai-gpt-4o",patterns:["gpt-4o"],efforts:!1,input:["text","image"],contextWindow:128e3,maxTokens:16384,note:"GPT-4o \u4EE3\u9645\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u4E0D\u652F\u6301 effort \u53C2\u6570\uFF08\u52FF\u52FE\u601D\u8003\u6863\uFF09\uFF1B\u56FE\u7247\u8F93\u5165\u5168\u7CFB\u6807\u914D\uFF0C128K / 16,384 \u8F93\u51FA\u3002"},{id:"openai-gpt-4-1",patterns:["gpt-4.1"],efforts:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,note:"GPT-4.1 \u5168\u7CFB\uFF08\u542B mini/nano\uFF09\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u4E0D\u652F\u6301 effort \u53C2\u6570\uFF1B\u5B98\u65B9 1,047,576 \u4E0A\u4E0B\u6587 / 32,768 \u8F93\u51FA\uFF0C\u5168\u7CFB\u5E26\u56FE\u8F93\u5165\u3002"},{id:"openai-gpt-4-turbo-preview",patterns:["gpt-4-turbo-preview"],efforts:!1,input:["text"],contextWindow:128e3,maxTokens:4096,note:"GPT-4 Turbo Preview\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u7EAF\u6587\u672C\u8F93\u5165\uFF08\u6B63\u5F0F turbo \u5FEB\u7167\u652F\u6301\u56FE\u7247\uFF0C\u89C1\u4E0B\u6761\uFF09\uFF0C128K\u3002"},{id:"openai-gpt-4-turbo",patterns:["gpt-4-turbo"],efforts:!1,input:["text","image"],contextWindow:128e3,maxTokens:4096,note:"GPT-4 Turbo\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u5B98\u65B9\u652F\u6301\u56FE\u7247\u8F93\u5165\uFF0C128K / 4,096 \u8F93\u51FA\u3002"},{id:"openai-gpt",patterns:["gpt-4","gpt-3.5"],efforts:!1,input:["text"],note:"GPT-4/3.5 \u4EE3\u9645\uFF1A\u975E\u63A8\u7406\u6A21\u578B\uFF0C\u4E0D\u652F\u6301 effort \u53C2\u6570\uFF08\u52FF\u52FE\u601D\u8003\u6863\uFF09\u3002gpt-4-turbo/4.1 \u8D77\u652F\u6301\u56FE\u7247\uFF0C\u89C1\u5355\u72EC\u6761\u76EE\uFF1B\u65B0\u4EE3\u8BF7\u7528 GPT-5 \u7CFB\uFF08\u89C1 openai-chat/gpt-5.x \u6761\u76EE\uFF09\u3002"},{id:"anthropic-claude-5-5",patterns:["claude-haiku-5.5","claude-opus-5-5","claude-sonnet-5-5","haiku-5.5","claude-5-5"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},defaultEffort:"high",compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude 5.5 \u4EE3\uFF08Haiku 5.5 / Opus 5.5 / Sonnet 5.5\uFF09\uFF1Api-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u5168\u6863 Low / Medium / High(\u9ED8\u8BA4) / XHigh / Max\uFF0C\u81EA\u9002\u5E94\u601D\u8003\uFF0C1M \u4E0A\u4E0B\u6587 / 128K \u8F93\u51FA\u3002off/minimal \u4EE5\u7701\u7565\u8868\u8FBE\uFF08\u76EE\u5F55\u5C06\u4E24\u952E\u8BB0\u4E3A null\uFF0C\u975E\u663E\u5F0F\u5173\u95ED\uFF09\u3002"},{id:"anthropic-claude-5",patterns:["claude-fable-5","claude-mythos-5","claude-opus-5","claude-sonnet-5"],efforts:{xhigh:"xhigh",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude 5 \u4EE3\uFF08Fable 5 / Mythos 5 / Opus 5 / Sonnet 5\uFF09\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u5DF2\u6536\u7D27\u4E3A XHigh / Max\uFF08low/medium/high \u6863\u5DF2\u4ECE\u8BE5\u4EE3 effort \u76EE\u5F55\u79FB\u9664\uFF1BFable 5 \u4E0E Opus 5 \u53E6\u63A5\u53D7\u4EE5\u7701\u7565\u8868\u8FBE\u7684 off\uFF0CSonnet 5 \u65E0 off\uFF09\u30021M \u4E0A\u4E0B\u6587 / 128K \u8F93\u51FA\uFF08Batch 300K\uFF09\u3002\u5B98\u65B9\u652F\u6301 PDF \u8F93\u5165\u3002\u6CE8\u610F\uFF1AAnthropic \u5B98\u65B9 OpenAI \u517C\u5BB9\u5C42\u4F1A\u5FFD\u7565 effort \u53C2\u6570\uFF0C\u58F0\u660E\u5728\u7B2C\u4E09\u65B9\u7F51\u5173\u6620\u5C04\u65F6\u751F\u6548\u3002"},{id:"anthropic-claude-5-1",patterns:["claude-fable-5-1","claude-mythos-5-1"],efforts:{xhigh:"xhigh",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude Fable 5.1 / Mythos 5.1\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u76EE\u5F55\u6863\u4F4D XHigh / Max\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF0C\u81EA\u9002\u5E94\u601D\u8003\u5E38\u5F00\uFF08\u4E0D\u63A5\u53D7 enabled/disabled\uFF09\u30021M \u4E0A\u4E0B\u6587 / 128K \u8F93\u51FA\uFF1BFable 5.1 \u652F\u6301\u4F1A\u8BDD\u4E2D\u9014\u6539\u6863\uFF08\u9700 beta header\uFF0C\u672C\u63D2\u4EF6\u4E0D\u6D89\u53CA\uFF09\u3002"},{id:"anthropic-claude-mythos-preview",patterns:["claude-mythos-preview"],efforts:{low:"low",medium:"medium",high:"high",max:"max"},defaultEffort:"high",compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude Mythos Preview\uFF1A\u5B98\u65B9\u6863\u4F4D Low / Medium / High / Max\uFF08\u65E0 XHigh\uFF09\uFF0C1M \u4E0A\u4E0B\u6587\u3002pi-ai 1.2.0 \u76EE\u5F55\u65E0 mythos \u6761\u76EE\uFF0C\u672C\u6863\u4F4D\u6CBF\u7528\u5B98\u65B9 effort \u77E9\u9635\u3002"},{id:"anthropic-claude-opus-4-high",patterns:["claude-opus-4-8","claude-opus-4-7"],efforts:{xhigh:"xhigh",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude Opus 4.7/4.8\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u6863\u4F4D\u4EC5 XHigh / Max\uFF08low/medium/high \u5DF2\u4ECE\u8BE5\u4EE3\u76EE\u5F55\u79FB\u9664\uFF1Bxhigh \u4E3A\u5B98\u65B9\u63A8\u8350\u7684\u7F16\u7801\u8D77\u6B65\u6863\uFF09\u30021M \u4E0A\u4E0B\u6587\u3002"},{id:"anthropic-claude-4-6",patterns:["claude-opus-4-6","claude-sonnet-4-6"],efforts:{max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1e6,maxTokens:128e3,note:"Claude 4.6 \u4EE3\uFF08Opus 4.6 / Sonnet 4.6\uFF09\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u4EC5\u5269 Max \u4E00\u6863\uFF08low/medium/high/xhigh \u5747\u5DF2\u4ECE\u76EE\u5F55\u79FB\u9664\uFF09\u30021M \u4E0A\u4E0B\u6587\u3002"},{id:"anthropic-claude-opus-4-5",patterns:["claude-opus-4-5"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"high",compat:{supportsReasoningEffort:!0},input:["text","image"],contextWindow:2e5,maxTokens:64e3,note:"Claude Opus 4.5\uFF1A\u5B98\u65B9 effort \u652F\u6301\u5217\u8868\uFF0820251101 \u5FEB\u7167\uFF09\uFF0C\u6863\u4F4D Low / Medium / High\uFF08\u65E0 XHigh/Max\uFF09\uFF0C\u53EF\u4E0E budget_tokens \u5E76\u7528\uFF1B200K / 64K\u3002"},{id:"anthropic-claude",patterns:["claude"],efforts:!1,input:["text","image"],contextWindow:2e5,maxTokens:64e3,note:"Claude 3.x \u4E0E Sonnet 4.5 / Haiku 4.5\uFF1A\u5B98\u65B9 effort \u53C2\u6570\u4E0D\u652F\u6301\uFF08\u4EC5 5.5/5/5.1 \u4EE3\u3001Opus 4.5/4.6/4.7/4.8\u3001Sonnet 4.6 \u652F\u6301\uFF09\uFF0C\u601D\u8003\u7531 thinking.type \u63A7\u5236\u2014\u2014\u52FF\u52FE\u601D\u8003\u6863\u3002\u53C2\u8003\u5BB9\u91CF 200K / 64K\uFF08Haiku 3.5 \u4E3A\u7EAF\u6587\u672C\uFF0C\u6309\u9700\u53D6\u6D88\u56FE\u7247\uFF09\u3002Haiku 5.5 \u53CA\u6574\u4E2A 5.5 \u4EE3\u89C1\u4E0A\u65B9 anthropic-claude-5-5 \u6761\u76EE\u3002"},{id:"google-gemini",patterns:["gemini"],efforts:{low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:65536,note:"Gemini \u901A\u7528\u5B89\u5168\u6863\uFF1ALow / Medium / High\uFF08\u5B98\u65B9 OpenAI \u517C\u5BB9\u6620\u5C04\u8868\u53E6\u6536 minimal\uFF1A2.5 \u7CFB\u6620\u5C04\u4E3A 1,024 \u9884\u7B97\u30013.1 Flash-Lite/3 Flash \u539F\u751F minimal\u30013.1 Pro \u843D low\uFF09\u3002none \u4EC5\u80FD\u5173 2.5 \u975E Pro\uFF1B2.5 Pro \u4E0E 3 \u4EE3\u4E0D\u53EF\u5173\uFF1B\u5404\u578B\u9ED8\u8BA4\u4E0D\u4E00\uFF08flash-lite \u9ED8\u8BA4\u5173\uFF09\u3002\u5B98\u65B9\u53E6\u6536\u97F3\u9891/\u89C6\u9891/PDF\u3002Gemma-4 \u89C1\u4E0B\u6761\u3002"},{id:"google-gemma-4",patterns:["gemma-4"],efforts:{off:null,minimal:"MINIMAL",high:"HIGH"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,maxTokens:32768,note:"Gemma 4\uFF0826b/31b-it\uFF09\uFF1A\u4E09\u6863 Minimal / High\uFF08\u6863\u4F4D\u7EBF\u4E3A\u5B98\u65B9\u5927\u5199\u679A\u4E3E\u62FC\u5199\uFF09\uFF0Coff \u4EE5\u7701\u7565\u8868\u8FBE\uFF1BLow/Medium \u4E0D\u88AB\u63A5\u53D7\u3002\u5E26\u56FE\u8F93\u5165\uFF0C262,144 / 32,768\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF09\u3002"},{id:"xai-grok-4-7",patterns:["grok-4.7"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:5e5,maxTokens:5e5,note:'Grok 4.7\uFF1A\u6863\u4F4D Low / Medium / High / XHigh\uFF0C\u601D\u8003\u4E0D\u53EF\u5173\u95ED\uFF08off \u4EC5\u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF1B\u5E26\u56FE\u8F93\u5165\uFF0C500K \u4E0A\u4E0B\u6587 / 500K \u8F93\u51FA\uFF082026-10 \u6821\u51C6\uFF1Api-ai 1.2.0 \u5B98\u65B9\u76EE\u5F55\u786E\u8BA4\u6863\u4F4D\u4E0E\u5BB9\u91CF\uFF0C"\u4E0A\u6E38 404"\u4E0E"\u6863\u4F4D\u672A\u8BC1\u5B9E"\u4E24\u6761\u65E7\u8BB0\u5F55\u4F5C\u5E9F\uFF09\u3002grok-4.5 \u4F20 xhigh \u88AB\u9759\u9ED8\u6309 High \u5904\u7406\u7684\u8BF4\u660E\u89C1\u5176\u6761\u76EE\u3002'},{id:"xai-grok-high",patterns:["grok-4.6"],efforts:{low:"low",medium:"medium",high:"high",xhigh:"xhigh"},defaultEffort:"high",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:5e5,note:'Grok 4.6 \u6863\u4F4D\uFF1ALow / Medium / High(\u9ED8\u8BA4) / XHigh\uFF0C\u601D\u8003\u4E0D\u53EF\u5173\u95ED\uFF1B\u5E26\u56FE\u8F93\u5165\u3001500K \u4E0A\u4E0B\u6587\u3002Grok 4.7 \u89C1\u4E0A\u4E00\u6761\uFF08\u6B64\u524D\u8BB0\u4E3A"\u4E0D\u5B58\u5728"\uFF0C\u5DF2\u968F\u53D1\u5E03\u4F5C\u5E9F\uFF09\u3002'},{id:"xai-grok-4-5",patterns:["grok-4.5"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"high",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:5e5,note:"Grok 4.5 \u6863\u4F4D\uFF1ALow / Medium / High(\u9ED8\u8BA4)\uFF0C\u601D\u8003\u4E0D\u53EF\u5173\u95ED\uFF1B\u5E26\u56FE\u8F93\u5165\u3002\u4F20\u5165 xhigh \u4F1A\u88AB\u5B98\u65B9\u9759\u9ED8\u6309 High \u5904\u7406\u3002"},{id:"xai-grok-4-3",patterns:["grok-4.3"],efforts:{off:"none",low:"low",medium:"medium",high:"high"},defaultEffort:"low",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1e6,maxTokens:3e4,note:"Grok 4.3\uFF1A\u5B98\u65B9\u56DB\u7EA7 reasoning effort\uFF08None / Low(\u9ED8\u8BA4) / Medium / High\uFF09\uFF0C1M \u4E0A\u4E0B\u6587 / 30,000 \u8F93\u51FA\uFF082026-10 \u6821\u51C6\uFF1AXHigh \u6863\u6309 pi-ai 1.2.0 \u76EE\u5F55\u79FB\u9664\u2014\u2014\u5B83\u81EA 4.6 \u8D77\u624D\u52A0\u5165\uFF1B\u5E26\u56FE\u8F93\u5165\uFF09\u3002grok-4-fast \u7B49\u65E7 slug 2026-05-15 \u8D77\u81EA\u52A8\u91CD\u5B9A\u5411\u5230\u672C\u578B\u53F7\u3002"},{id:"xai-grok",patterns:["grok"],efforts:{low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],note:"Grok \u901A\u7528\u6863\u4F4D\uFF1ALow / Medium / High\u3002\u521D\u4EE3 grok-4\u3001grok-4.20 \u4E0E grok-build-0.1 \u4E0D\u63A5\u53D7\u8BE5\u53C2\u6570\uFF08grok-4 \u7CFB\u4E0E grok-3 \u5DF2\u4E8E 2026-05-15 \u9000\u5F79\u5E76\u91CD\u5B9A\u5411\u81F3 4.3\uFF09\uFF1Bgrok-4.20-multi-agent \u7684\u56DB\u6863\u63A7\u5236\u7684\u662F agent \u6570\u91CF\u800C\u975E\u601D\u8003\u6DF1\u5EA6\u3002\u65B0\u65E7\u4EE3\u9645\u8BF7\u4F18\u5148\u9009 4.5/4.6/4.3\uFF1B\u591A\u6A21\u6001\u53D8\u4F53\u6309\u9700\u52FE\u9009\u56FE\u7247\u3002"},{id:"mistral-magistral",patterns:["magistral"],efforts:{off:"none",high:"high"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,maxTokens:16384,note:'Magistral\uFF08magistral-medium-latest\uFF09\uFF1A2026-10 \u6821\u51C6\u2014\u2014pi-ai 1.2.0 \u76EE\u5F55\u663E\u793A\u73B0\u5F79 magistral \u8D70 mistral-conversations \u534F\u8BAE\u5E76\u63A5\u53D7 effort\uFF08None / High \u4E24\u6863\uFF0C\u9ED8\u8BA4 None\uFF09\uFF0C\u5E26\u56FE\u8F93\u5165\uFF0C262,144 / 16,384\u3002\u65E9\u524D"\u8BE5\u7EBF\u65E0 effort \u53C2\u6570\u4E14\u5DF2\u5F03\u7528"\u7684\u8BB0\u5F55\u4F5C\u5E9F\u3002'},{id:"mistral-medium-3",patterns:["mistral-medium-3.5","mistral-large-4","mistral-medium-2604","mistral-medium-latest","mistral-small-latest","mistral-small-2603"],efforts:{off:"none",high:"high"},defaultEffort:"off",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],note:"Mistral \u73B0\u5F79\u63A8\u7406\u6863\uFF082026-10 \u6269\u5145\uFF09\uFF1ANone / High \u4E24\u6863\uFF0C\u5B98\u65B9 reasoning_effort \u679A\u4E3E\u5373 none/high\uFF1B\u73B0\u5F79\u578B\u53F7 mistral-large-4\uFF081M\uFF09\u3001mistral-medium-3.5\uFF082604/latest\uFF09\u3001mistral-small-2603\uFF08Small 4\uFF09\u7ECF\u5B83\u63A7\u5236\uFF0C\u5747\u5E26\u89C6\u89C9\u3002\u5BB9\u91CF\uFF1Alarge-4 262,144 \u8F93\u51FA\u3001medium 262,144 \u8F93\u51FA\u3001small 256,000 \u8F93\u51FA\uFF08\u4E0A\u4E0B\u6587\u5747 262,144\uFF09\u3002\u975E\u63A8\u7406\u65E7\u6B3E\u89C1\u4E0B\u6761\u3002"},{id:"mistral-legacy",patterns:["mistral-large-2411","mistral-large-latest","mistral-large-2512","mistral-medium-2505","mistral-medium-2508","mistral-small-2506","mistral-nemo","devstral","ministral","codestral","pixtral","voxtral"],efforts:!1,input:["text","image"],note:"Mistral \u975E\u63A8\u7406\u7EBF\uFF082026-10 \u65B0\u589E\u6761\u76EE\uFF09\uFF1Alarge-2411/2512/latest\u3001medium-2505/2508\u3001small-2506\u3001nemo \u53CA devstral/ministral/codestral/pixtral/voxtral \u7B49\u4E13\u7528\u7EBF\u5747\u4E0D\u63A5\u53D7 effort \u53C2\u6570\uFF08\u52FF\u52FE\u601D\u8003\u6863\uFF09\u3002\u591A\u6570\u73B0\u5F79\u6B3E\u5E26\u89C6\u89C9\uFF08large-2411 \u4E3A\u7EAF\u6587\u672C\uFF09\u3002"},{id:"qwen-vision",patterns:["qwen-vl","qwen2-vl","qwen2-5-vl","qwen3-vl","qvq"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"qwen"},input:["text","image"],contextWindow:131072,maxTokens:8192,note:"\u901A\u4E49\u89C6\u89C9\u7EBF\uFF08Qwen-VL/QvQ\uFF09\uFF1Aenable_thinking \u5F00\u5173\uFF08\u5F00=High\uFF09\uFF0C\u6536\u56FE\u3002qwen3-vl \u5BB9\u91CF\u66F4\u5927\uFF0C\u6309\u9700\u4E0A\u8C03\u3002"},{id:"qwen-3-8",patterns:["qwen3.8"],efforts:{off:null,low:"low",medium:"medium",xhigh:"xhigh"},defaultEffort:"xhigh",compat:{thinkingFormat:"qwen",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1e6,note:"Qwen 3.8 \u7CFB\uFF1A\u5B98\u65B9 reasoning_effort \u6863\u4F4D XHigh(\u9ED8\u8BA4) / Medium / Low\uFF0Cthinking \u9ED8\u8BA4\u5F00\u3001\u53EF\u6309\u8BF7\u6C42\u5173\u95ED\uFF1B\u539F\u751F\u591A\u6A21\u6001\uFF08qwen3.8-max \u56FE\u50CF/\u89C6\u9891\u7406\u89E3\uFF0C\u89C6\u9891\u672A\u5165\u6838\u5FC3\u8BCD\u8868\uFF09\u30021M \u6863\u4E0A\u4E0B\u6587\u300227B \u4E0E Flash-Next \u5F00\u6E90\u6B3E\u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"qwen-3-8-27b",patterns:["qwen3.8-27b"],efforts:{off:null,low:"low",medium:"medium",xhigh:"xhigh"},defaultEffort:"xhigh",compat:{thinkingFormat:"qwen",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,note:"Qwen3.8-27B\uFF08dense\uFF0C2026-08-14 \u5F00\u6E90\uFF09\uFF1A\u5B98\u65B9 reasoning_effort \u6863\u4F4D XHigh(\u9ED8\u8BA4) / Medium / Low\uFF0Cthinking \u9ED8\u8BA4\u5F00\u3001\u53EF\u6309\u8BF7\u6C42\u5173\uFF1B\u539F\u751F\u56FE\u50CF+\u89C6\u9891\u7406\u89E3\uFF08\u89C6\u9891\u672A\u5165\u6838\u5FC3\u8BCD\u8868\uFF09\u3002262,144 \u539F\u751F\u4E0A\u4E0B\u6587\u3001\u5B98\u65B9\u58F0\u660E\u53EF\u6269\u81F3 1M\u3002\u6765\u6E90\uFF1AHF Qwen/Qwen3.8-27B \u6A21\u578B\u5361\u3002"},{id:"qwen-3-8-flash-next",patterns:["qwen3.8-flash-next"],efforts:{off:null,low:"low",medium:"medium",xhigh:"xhigh"},defaultEffort:"xhigh",compat:{thinkingFormat:"qwen",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,note:"Qwen3.8-Flash-Next\uFF08125B-A6B \u5B9E\u9A8C\u67B6\u6784\uFF0CQwen4 \u524D\u8EAB\uFF09\uFF1A\u5B98\u65B9 reasoning_effort \u6863\u4F4D XHigh(\u9ED8\u8BA4) / Medium / Low + enable_thinking \u5F00\u5173\uFF1B\u539F\u751F\u89C6\u89C9\uFF08Vision Encoder\uFF09\u3002262,144 \u539F\u751F\u4E0A\u4E0B\u6587\u3001\u53EF\u6269\u81F3 1M\u3002\u6765\u6E90\uFF1AHF \u6A21\u578B\u5361\u4E0E qwen.ai \u5B98\u65B9\u535A\u5BA2\u3002"},{id:"qwen",patterns:["qwen","qwq"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"qwen"},input:["text"],contextWindow:1e6,maxTokens:65536,note:"\u901A\u4E49\u5343\u95EE\uFF1Aenable_thinking \u5F00\u5173\uFF08\u65E0 effort \u6863\uFF09\uFF0C\u5F00=High\uFF1B\u73B0\u5F79\u65D7\u8230\u4E3A qwen3.8 \u7CFB\uFF081M \u6863\u4E0A\u4E0B\u6587\uFF0C\u89C1 qwen-3-8 \u6761\u76EE\uFF09\u30023.6/3.7 \u4EE3\u7684 Plus/Flash \u4EA6\u9ED8\u8BA4\u591A\u6A21\u6001\uFF08\u56FE\u7247/\u89C6\u9891\uFF09\uFF0C\u5982\u63A5\u5165\u8BF7\u6309\u9700\u52FE\u9009\u56FE\u7247\uFF1B\u89C6\u89C9\u7EBF\u89C1 qwen-vision \u6761\u76EE\u3002"},{id:"glm-vision",patterns:["glm-4v","glm-4-6v","glm-4-5v","glm-5v"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"zai"},input:["text","image"],contextWindow:131072,maxTokens:32768,note:"\u667A\u8C31\u89C6\u89C9\u7EBF\uFF08GLM-4V/4.5V/4.6V/5V\uFF09\uFF1Athinking \u5F00\u5173\uFF08\u5F00=High\uFF09\uFF0C\u6536\u56FE\u3002GLM-4.5V \u4E3A\u5F3A\u5236\u601D\u8003\uFF08\u4F20 disabled \u62A5\u9519\uFF0C\u8BF7\u624B\u52A8\u5220 Off \u6863\uFF09\u3002"},{id:"glm-5-3-flash",patterns:["glm-5.3-flash","glm-5.3-flashx"],efforts:{low:"low",high:"high",max:"max"},defaultEffort:"max",compat:{thinkingFormat:"zai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:131072,note:"GLM-5.3-Flash\uFF08320B\uFF0C\u5B98\u65B9\u6587\u6863 vlm \u5206\u7C7B\uFF09\uFF1A\u5F3A\u5236\u601D\u8003\uFF08thinking.type \u4EC5 enabled\uFF0C\u4E0D\u652F\u6301\u5173\u95ED\uFF09\uFF0C\u6587\u672C\u53C2\u6570\u4E0E GLM-5.3 \u4E00\u81F4\u2014\u2014\u6863\u4F4D Low / High / Max\u3002\u8F93\u5165\u6A21\u6001\uFF1A\u89C6\u9891\u3001\u56FE\u50CF\u3001\u6587\u672C\u3001\u6587\u4EF6\uFF08\u89C6\u9891/\u6587\u4EF6\u672A\u5165\u6838\u5FC3\u8BCD\u8868\uFF0C\u56FE\u7247\u53EF\u52FE\uFF09\u3002\u5B98\u65B9 1M \u4E0A\u4E0B\u6587 / 128K \u6700\u5927\u8F93\u51FA\u3002\u6765\u6E90\uFF1Adocs.bigmodel.cn \u6A21\u578B\u9875\u3002"},{id:"glm-5-3",patterns:["glm-5.3"],efforts:{low:"low",high:"high",max:"max"},defaultEffort:"max",compat:{thinkingFormat:"zai",supportsReasoningEffort:!0},input:["text"],contextWindow:1048576,maxTokens:131072,note:"GLM-5.3 \u6863\u4F4D\uFF1ALow / High / Max\uFF08\u5F3A\u5236\u601D\u8003\uFF0C\u5176\u4F59\u503C\u62A5\u9519\uFF09\u3002\u5B98\u65B9\u5BB9\u91CF 1M / 128K\u3002"},{id:"glm-5-2",patterns:["glm-5.2"],efforts:{off:"none",minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},defaultEffort:"max",compat:{thinkingFormat:"zai",supportsReasoningEffort:!0},input:["text"],contextWindow:1048576,maxTokens:131072,note:"GLM-5.2 \u6863\u4F4D\uFF1ANone / Minimal / Low / Medium / High / XHigh / Max\uFF08\u5B98\u65B9\u6620\u5C04\uFF1ALow\xB7Medium\u2192High\u3001XHigh\u2192Max\u3001None\xB7Minimal=\u505C\u6B62\u601D\u8003\uFF09\u3002\u89C6\u89C9\u7EBF\u89C1 glm-vision \u6761\u76EE\u3002"},{id:"glm",patterns:["glm","zhipu","chatglm"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"zai"},input:["text"],note:"GLM \u901A\u7528\uFF1Athinking \u5F00\u5173\uFF08\u65E0 effort \u6863\uFF09\uFF0C\u5F00=High\uFF1Beffort \u9636\u68AF\u4EC5 GLM-5.2+ \u652F\u6301\uFF08\u89C1\u4E0A\u4E24\u6761\u76EE\uFF09\u3002\u6CE8\u610F GLM-4.7/GLM-4.5V \u4E3A\u5F3A\u5236\u601D\u8003\uFF0C\u4F20 disabled \u4F1A\u62A5\u9519\uFF08\u8BF7\u624B\u52A8\u5220 Off \u6863\uFF09\u3002\u89C6\u89C9\u7EBF\u89C1 glm-vision \u6761\u76EE\u3002"},{id:"kimi-k3",patterns:["kimi-k3"],efforts:{low:"low",high:"high",max:"max"},defaultEffort:"max",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,note:"Kimi K3 \u6863\u4F4D\uFF1ALow / High / Max(\u9ED8\u8BA4 Max)\uFF0C\u8D70\u9876\u5C42 reasoning_effort\uFF1B\u59CB\u7EC8\u63A8\u7406\u3001\u52FF\u4F20 thinking \u5BF9\u8C61\u3002\u539F\u751F\u89C6\u89C9\u7406\u89E3\uFF0C1M \u4E0A\u4E0B\u6587\uFF08\u6700\u5927\u8F93\u51FA\u5B98\u65B9\u672A\u5355\u72EC\u5217\uFF0C\u4E0D\u63D0\u4F9B\uFF09\u3002"},{id:"kimi-k2-vision",patterns:["kimi-k2.6","kimi-k2.5"],efforts:{off:null,high:"high"},defaultEffort:"high",compat:{thinkingFormat:"deepseek"},input:["text","image"],contextWindow:262144,note:"Kimi K2.5/K2.6 \u89C6\u89C9\u4EE3\uFF1Athinking.type \u5F00\u5173\uFF08\u9ED8\u8BA4\u5F00\u3001\u53EF\u5173\uFF09\uFF0C\u5F00=High\uFF1B\u5E26\u89C6\u89C9\uFF0C256K\u3002K2.7 Code \u59CB\u7EC8\u601D\u8003\uFF0C\u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"kimi-k27-code",patterns:["kimi-k2.7"],efforts:{high:"high"},defaultEffort:"high",compat:{thinkingFormat:"deepseek"},input:["text","image"],contextWindow:262144,note:"Kimi K2.7 Code\uFF08\u542B\u9AD8\u901F\u7248\uFF09\uFF1A\u59CB\u7EC8\u601D\u8003\u2014\u2014thinking.type \u4EC5\u63A5\u53D7 enabled\uFF08\u4F20 disabled \u62A5\u9519\uFF09\uFF0C\u65E0 Off \u6863\uFF1B\u5E26\u89C6\u89C9\uFF0C256K\u3002"},{id:"kimi-for-coding",patterns:["kimi-for-coding"],efforts:{low:"low",high:"high",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1048576,maxTokens:32768,note:"Kimi for Coding\uFF1AMoonshot \u7F16\u7801\u4E13\u7EBF\u8D70 anthropic-messages \u534F\u8BAE\u3001\u81EA\u9002\u5E94\u601D\u8003\uFF0C\u6863\u4F4D Low / High / Max\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF1B\u5E26\u56FE\u8F93\u5165\uFF0C1M \u4E0A\u4E0B\u6587 / 32,768 \u8F93\u51FA\u3002\u9AD8\u901F\u7248\uFF08-highspeed\uFF09\u65E0 effort \u63A7\u4EF6\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF09\u3002"},{id:"kimi-moonshot-v1-vision",patterns:["moonshot-v1-8k-vision","moonshot-v1-32k-vision","moonshot-v1-128k-vision"],efforts:!1,input:["text","image"],note:"Moonshot V1 \u89C6\u89C9\u65E7\u4EE3\uFF088k/32k/128k \u5404\u4E00\uFF09\uFF1A\u65E0\u601D\u8003\u63A7\u4EF6\uFF08\u751F\u6210\u6A21\u578B\uFF09\u3001\u652F\u6301\u56FE\u7247\u8F93\u5165\uFF1B\u8BE5\u7EBF\u5DF2\u505C\u6B62\u5BF9\u65B0\u7528\u6237\u5F00\u653E\uFF082026-08-31 \u5168\u91CF\u4E0B\u7EBF\uFF0C\u7F51\u5173\u6B8B\u7559\u4ECD\u53EF\u547D\u4E2D\uFF09\u3002"},{id:"kimi",patterns:["kimi","moonshot"],efforts:{off:null,high:"high"},compat:{thinkingFormat:"deepseek"},input:["text"],contextWindow:262144,note:"Kimi \u901A\u7528\uFF1Athinking \u5F00\u5173\uFF08\u65E0 effort \u6863\uFF09\uFF0C\u5F00=High\u3002k2 \u7CFB\u5217 2026-05-25 \u4E0B\u7EBF\u3001kimi-latest 2026-01-28 \u4E0B\u7EBF\u3001moonshot-v1 \u7CFB 2026-08-31 \u5168\u91CF\u4E0B\u7EBF\uFF08\u7F51\u5173\u6B8B\u7559\u4ECD\u53EF\u547D\u4E2D\uFF1Bmoonshot-v1 \u672C\u8EAB\u975E\u601D\u8003\u6A21\u578B\uFF09\u3002\u89C6\u89C9\u4EE3\u4E0E K2.7 Code \u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"hunyuan-hy3",patterns:["hy3"],efforts:{low:"low",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:262144,note:"\u6DF7\u5143 hy3\uFF1A\u5F00\u6E90\u5951\u7EA6\u7ECF chat_template_kwargs.reasoning_effort = no_think(\u9ED8\u8BA4)/low/high\uFF1B\u5B98\u65B9\u6A21\u578B\u5361 256K \u4E0A\u4E0B\u6587\uFF08295B MoE\uFF0C2026 \u5F00\u6E90\uFF09\u3002"},{id:"hunyuan-hy4",patterns:["hy4-preview","hy-4-preview"],efforts:{off:"no_think",high:"high"},defaultEffort:"high",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},contextWindow:1e6,note:"\u6DF7\u5143 Hy4 preview\uFF1A\u5B98\u65B9 README\u2014\u2014reasoning \u9ED8\u8BA4 high\uFF08\u6DF1\u5EA6\u601D\u8003\uFF09\uFF0C\u5173\u95ED\u7ECF chat_template_kwargs.reasoning_effort=no_think\uFF1B\u5B98\u65B9\u89C4\u683C\u8868 1M \u4E0A\u4E0B\u6587\uFF08770B-A49B MoE\uFF0CGated DSA\uFF09\u3002low \u6863\u5B98\u65B9\u672A\u5217\uFF0C\u5982\u6709\u8BF7\u624B\u8C03\uFF1B\u89C6\u89C9\u672A\u58F0\u660E\uFF0C\u6309\u9700\u624B\u52FE\u3002\u6765\u6E90\uFF1ATencent-Hunyuan/Hy4-preview \u5B98\u65B9 README\u3002"},{id:"step-5-preview",patterns:["step-5"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1e6,maxTokens:65536,note:'\u9636\u8DC3 Step-5-Preview\uFF08\u5B98\u65B9 id \u5373 step-5-preview\uFF0C\u65E0\u88F8 step-5\uFF1Bpattern \u53D6\u5BB6\u65CF\u4E3B\u5E72\u4EE5\u517C\u5BB9\u7F51\u5173\u5199\u6CD5\uFF09\uFF1A\u6863\u4F4D Low / Medium(\u5B98\u65B9\u6807"\u9ED8\u8BA4\u63A8\u8350") / High\uFF0C\u601D\u8003\u4E0D\u53EF\u5173\u95ED\uFF1B\u539F\u751F\u56FE\u7247 + \u89C6\u9891\u8F93\u5165\uFF1B1M \u4E0A\u4E0B\u6587\u300164K \u6700\u5927\u8F93\u51FA\uFF08\u5B98\u65B9\u53E6\u6CE8 max_tokens \u9ED8\u8BA4 INF\u3001\u4E0E 64K \u4E0A\u9650\u5E76\u5B58\uFF0C\u4EE5\u7AEF\u70B9\u5B9E\u6D4B\u4E3A\u51C6\uFF09\u3002'},{id:"step-3-7",patterns:["step-3.7","step-3.6"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:262144,note:"\u9636\u8DC3 Step-3.6/3.7 \u6863\u4F4D\uFF1ALow / Medium(\u9ED8\u8BA4\u63A8\u8350) / High\uFF0C\u539F\u751F\u56FE\u7247+\u89C6\u9891\u7406\u89E3\u3002\u4E0A\u4E0B\u6587\u4E3A\u8F93\u5165+\u8F93\u51FA\u603B\u548C\u4E0A\u9650\u3002"},{id:"step-3-5",patterns:["step-3.5"],efforts:{low:"low",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:262144,note:"\u9636\u8DC3 Step-3.5 Flash \u6863\u4F4D\uFF1ALow / High\uFF08\u7EAF\u6587\u672C\u63A8\u7406\u65D7\u8230\uFF09\u3002\u4E0A\u4E0B\u6587\u4E3A\u8F93\u5165+\u8F93\u51FA\u603B\u548C\u4E0A\u9650\u3002"},{id:"step",patterns:["step-3","step-2"],efforts:{low:"low",medium:"medium",high:"high"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],note:"\u9636\u8DC3 Step \u6863\u4F4D\uFF1ALow / Medium / High\uFF08\u9ED8\u8BA4 Medium\uFF0C\u4E0D\u53EF\u5173\u95ED\uFF09\u30023.6/3.7 \u89C6\u89C9\u4EE3\u89C1\u5355\u72EC\u6761\u76EE\u3002"},{id:"doubao",patterns:["doubao","seed"],efforts:{off:null,low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],note:"\u8C46\u5305\u6863\u4F4D\uFF1AOff / Low / Medium / High\u2014\u2014effort \u9636\u68AF\u4ECD\u662F\u793E\u533A\u8BC1\u636E\u3001\u5B98\u65B9 Ark \u6587\u6863\u660E\u5217\u7684\u4E3A thinking.type \u5F00\u5173\uFF082026-08-24 \u590D\u6838\u4ECD\u672A\u89C1\u5230 effort \u5B98\u65B9\u660E\u6587\uFF09\u3002seed \u4EE3\u6536\u56FE\uFF081.5-pro \u4F8B\u5916\uFF09\u3002"},{id:"minimax-m2",patterns:["minimax-m2"],efforts:!1,input:["text"],contextWindow:204800,maxTokens:131072,note:"MiniMax-M2 / M2.5\uFF08\u542B -highspeed\uFF09\uFF1A\u65E0\u601D\u8003\u63A7\u4EF6\u3001\u65E0 effort \u53C2\u6570\uFF08M3 \u624D\u5F15\u5165 thinking \u53C2\u6570\uFF09\uFF0C\u7EAF\u6587\u672C\uFF0C204,800 / 131,072\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF1BM3 \u89C1\u4E0B\u6761\uFF09\u3002"},{id:"minimax-m3",patterns:["minimax-m3"],efforts:{off:null,high:"high"},compat:{thinkingFormat:"deepseek"},input:["text","image"],contextWindow:1048576,maxTokens:512e3,note:"MiniMax-M3\uFF1A\u5B98\u65B9 thinking \u53C2\u6570 enabled/adaptive/disabled\uFF08\u65E0 effort \u6863\uFF09\uFF0C\u5F00=High\u3001\u5173=disabled\uFF1B\u539F\u751F\u591A\u6A21\u6001\uFF08\u56FE/\u89C6\u9891\uFF0C\u6838\u5FC3\u8BCD\u8868\u4EC5\u542B\u56FE\uFF09\uFF0C1M \u4E0A\u4E0B\u6587 / 512,000 \u8F93\u51FA\uFF082026-10 \u6821\u51C6\u8865\u5BB9\u91CF\uFF09\u3002"},{id:"mimo-v2-6",patterns:["mimo-v2.6","mimo-v2.5"],efforts:{off:"none",low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:1048576,maxTokens:131072,note:"\u5C0F\u7C73 MiMo v2.6 \u7CFB\u5217\uFF08mimo-v2.6-pro / -flash / -pro-ultraspeed\uFF1B1M \u4E0A\u4E0B\u6587 / 128K \u6700\u5927\u8F93\u51FA\u3001\u539F\u751F\u5168\u6A21\u6001\uFF09\u4E0E\u5176\u524D\u4EE3 mimo-v2.5\u3002\u5B98\u65B9\u6587\u6863\uFF1Athinking.type\uFF08enabled/disabled\uFF0C\u9ED8\u8BA4 enabled\uFF09+ reasoning.effort\uFF08none \u5173\u95ED\uFF1B\u5176\u4F59\u5408\u6CD5\u503C\u5747\u5F00\u542F\uFF0C\u4E14**\u73B0\u9636\u6BB5\u6682\u672A\u533A\u5206\u63A8\u7406\u5F3A\u5EA6**\u2014\u2014minimal \u5F52\u4E00\u4E3A low\u3001xhigh/max/ultra \u5F52\u4E00\u4E3A high\uFF09\uFF0C\u56E0\u6B64\u8FD9\u91CC\u58F0\u660E\u7684\u662F\u7AEF\u70B9**\u63A5\u53D7**\u7684\u6863\u4F4D Off / Low / Medium / High\uFF08xhigh\u3001max \u4E0D\u58F0\u660E\uFF0C\u7AEF\u70B9\u53EA\u4F1A\u6298\u53E0\u4E3A high\uFF09\u3002\u601D\u8003\u6A21\u5F0F\u4E0B temperature / top_p \u4E0D\u53EF\u81EA\u5B9A\u4E49\uFF08\u5F3A\u5236 1.0 / 0.95\uFF09\uFF1B\u5E26\u5DE5\u5177\u8C03\u7528\u7684\u5386\u53F2\u8F6E\u5FC5\u987B\u5B8C\u6574\u56DE\u4F20 reasoning_content\uFF0C\u5426\u5219 400\u3002mimo-v2.5 \u4E0E v2.5-pro \u5B98\u65B9\u5B9A\u4E8E 2026-10-21 \u4E0B\u7EBF\u3002"},{id:"mimo-v2-5-pro",patterns:["mimo-v2.5-pro"],efforts:{off:"none",low:"low",medium:"medium",high:"high"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:1048576,maxTokens:131072,note:"\u5C0F\u7C73 MiMo v2.5-Pro\uFF1A\u8BE5\u5BB6\u65CF\u552F\u4E00\u7684**\u7EAF\u6587\u672C**\u6210\u5458\uFF08\u5B98\u65B9\u80FD\u529B\u8868\u672A\u5217\u5168\u6A21\u6001\u7406\u89E3\uFF09\uFF0C1M \u4E0A\u4E0B\u6587 / 128K \u6700\u5927\u8F93\u51FA\uFF0C\u63A8\u7406\u5951\u7EA6\u4E0E v2.6 \u7CFB\u5217\u76F8\u540C\uFF08thinking.type + reasoning.effort\uFF0Cnone \u5173\u95ED\u3001\u5176\u4F59\u6863\u4F4D\u6682\u4E0D\u533A\u5206\u5F3A\u5EA6\uFF09\u3002\u5B98\u65B9\u5B9A\u4E8E 2026-10-21 \u4E0B\u7EBF\u3002"},{id:"baidu-ernie",patterns:["ernie"],efforts:!1,input:["text"],contextWindow:131072,note:"\u767E\u5EA6\u5343\u5E06 ERNIE \u7CFB\uFF1A\u5B98\u65B9 OpenAI \u517C\u5BB9\u63A5\u53E3\u65E0 reasoning_effort \u53C2\u6570\u2014\u2014\u601D\u8003\u7531\u6A21\u578B\u53D8\u4F53\u51B3\u5B9A\uFF08-Thinking \u7CFB\u5217\u59CB\u7EC8\u601D\u8003\u3001\u666E\u901A\u7CFB\u5217\u4E0D\u601D\u8003\uFF09\uFF0C\u52FF\u52FE\u601D\u8003\u6863\u3002ERNIE 4.5 Turbo VL \u652F\u6301\u56FE\u7247\uFF0C\u6309\u9700\u624B\u52FE\uFF1B\u53C2\u8003\u5BB9\u91CF\u53D6 Turbo 128K \u6863\u3002"},{id:"fireworks-ember",patterns:["ember-1"],efforts:{off:"none",low:"low",medium:"medium",high:"high",max:"max"},compat:{supportsReasoningEffort:!0},anthropicAdaptive:!0,input:["text","image"],contextWindow:1048576,maxTokens:131072,note:"Fireworks ember-1\uFF1Aanthropic-messages \u534F\u8BAE\u81EA\u9002\u5E94\u601D\u8003\uFF0C\u6863\u4F4D None(\u5173) / Low / Medium / High / Max\uFF08off \u663E\u5F0F none \u62FC\u5199\uFF09\uFF1B\u5E26\u56FE\u8F93\u5165\uFF0C1M \u4E0A\u4E0B\u6587 / 131,072 \u8F93\u51FA\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF09\u3002"},{id:"thinkingmachines-inkling",patterns:["inkling"],efforts:{off:"none",minimal:"minimal",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},defaultEffort:"medium",compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text","image"],contextWindow:524288,maxTokens:131072,note:"Thinking Machines Inkling\uFF1A\u5168\u6863 Minimal / Low / Medium(\u9ED8\u8BA4) / High / XHigh / Max\uFF0Coff \u663E\u5F0F none\uFF1B\u5E26\u56FE\u8F93\u5165\uFF0C512K \u4E0A\u4E0B\u6587 / 131,072 \u8F93\u51FA\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF1Btogether \u4E2D\u7EE7\u4FA7 effort \u53C2\u6570\u672A\u5F00\u653E\uFF0C\u9700\u652F\u6301\u65B9\u8F6C\u53D1\uFF09\u3002"},{id:"antling-ring",patterns:["ring-2.6"],efforts:{high:"high",xhigh:"xhigh"},compat:{thinkingFormat:"openai",supportsReasoningEffort:!0},input:["text"],contextWindow:262144,maxTokens:65536,note:"\u8682\u8681 Ling Ring-2.6-1T\uFF1A\u6863\u4F4D High / XHigh\uFF08off \u4EE5\u7701\u7565\u8868\u8FBE\uFF09\uFF1B262,144 / 65,536\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF09\u3002"},{id:"antling-ling",patterns:["ling-2.6"],efforts:!1,input:["text"],note:"\u8682\u8681 Ling-2.6\uFF08\u542B -flash\uFF09\uFF1A\u975E\u601D\u8003\u6A21\u578B\uFF0C\u65E0 effort \u63A7\u4EF6\uFF082026-10 \u6821\u51C6\u65B0\u589E\uFF1BRing-2.6 \u601D\u8003\u7EBF\u89C1\u4E0A\u6761\uFF09\u3002"},{id:"openai-gpt-image",patterns:["gpt-image","dall-e","dalle"],efforts:!1,imageGen:!0,note:"OpenAI \u751F\u56FE\u7CFB\uFF08gpt-image-1 / DALL\xB7E 3\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"google-imagen",patterns:["imagen","flash-image","pro-image","nano-banana"],efforts:!1,imageGen:!0,note:'Google \u751F\u56FE\u7CFB\uFF08Imagen / Gemini-Image "nano banana"\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002'},{id:"black-forest-flux",patterns:["flux"],efforts:!1,imageGen:!0,note:"FLUX \u7CFB\uFF08FLUX.1 schnell/dev/pro \u7B49\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"stability-sd",patterns:["stable-diffusion","sdxl","sd3"],efforts:!1,imageGen:!0,note:"Stability \u751F\u56FE\u7CFB\uFF08Stable Diffusion / SDXL / SD3\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"zhipu-cogview",patterns:["cogview"],efforts:!1,imageGen:!0,note:"\u667A\u8C31 CogView \u751F\u56FE\u7CFB\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"aliyun-wanx",patterns:["wanx"],efforts:!1,imageGen:!0,note:"\u963F\u91CC\u4E07\u76F8 Wanx \u751F\u56FE\u7CFB\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"bytedance-seedream",patterns:["seedream","seededit"],efforts:!1,imageGen:!0,note:"\u5B57\u8282 Seedream / SeedEdit \u751F\u56FE\u7CFB\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"qwen-image",patterns:["qwen-image"],efforts:!1,imageGen:!0,note:"\u901A\u4E49\u5343\u95EE Qwen-Image \u751F\u56FE\u7CFB\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"},{id:"midjourney",patterns:["midjourney","niji"],efforts:!1,imageGen:!0,note:"Midjourney / Niji \u751F\u56FE\u7CFB\uFF08\u4E2D\u8F6C\u5E38\u89C1\uFF09\uFF1A\u56FE\u50CF\u751F\u6210\u6A21\u578B\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u5BF9\u8BDD\u6A21\u578B\u4F7F\u7528\u2014\u2014\u5728\u8F93\u5165\u6846\u6A21\u578B\u5207\u6362\u5217\u8868\u4E2D\u5E26\u300C\u751F\u56FE\u300D\u6807\u8BB0\u5C55\u793A\u3002\u8BF7\u52FF\u52FE\u601D\u8003\u6863\u3002"}],Ma={off:null,low:"low",medium:"medium",high:"high"},_g={"openai-completions":Ma,"openai-responses":Ma,"anthropic-messages":Ma,deepseek:{off:"none",low:"low",high:"high",max:"max"}},Fg={low:"low",medium:"medium",high:"high"};function _n(e){return(e??"").toLowerCase().trim()}function cl(e){return e!==void 0&&/[a-z0-9]/.test(e)}function nn(e){return e.toLowerCase().trim().replace(/[^a-z0-9]+/g," ").replace(/([a-z])(\d)/g,"$1 $2")}function Aa(e,t,n){let r=t===0?void 0:e[t-1],o=e[t+n];return!cl(r)&&!cl(o)}function Ra(e,t){let n=nn(e)+" "+nn(t??""),r;for(let o of Dg)for(let i of o.patterns){let a=nn(i),s=n.indexOf(a);for(;s>=0;){if(Aa(n,s,a.length)){(r===void 0||a.length>r.length)&&(r={entry:o,length:a.length});break}s=n.indexOf(a,s+1)}}return r?.entry}var qg={"deepseek.com":"deepseek","anthropic.com":"anthropic-messages"};function Kg(e){let t=_n(e.api);if(t.length>0)return t;let n=e.baseURL;if(n!==void 0&&n.length>0)try{let o=new URL(n).hostname.toLowerCase().split(".");if(o.length>=2){let i=qg[o.slice(-2).join(".")];if(i!==void 0)return i}}catch{}return"openai-completions"}var Mr="openai-completions",Bg="openai-responses",Ca="anthropic-messages";function La(e){if(e===void 0||e.length===0)return!1;let t="";try{t=new URL(e).hostname.toLowerCase()}catch{return!1}if(t.startsWith("[")){let n=t.slice(1,-1);return n==="::1"||n==="::"||n.startsWith("fe80:")||n.startsWith("fc")||n.startsWith("fd")}return!!(t==="localhost"||t.endsWith(".local")||t.endsWith(".internal")||/^(127\.|10\.|192\.168\.)/.test(t)||/^172\.(1[6-9]|2[0-9]|3[01])\./.test(t))}function Wg(e,t){let n=_n(t),r={...e};if(delete r.supportsMidConvoEffort,delete r.allowedFallbackModels,n===Ca){for(let o of["thinkingFormat","supportsReasoningEffort","thinkingTokenBudgetField","supportsThinkingTokenBudget","vllmPriority"])delete r[o];return r.forceAdaptiveThinking===void 0?void 0:{forceAdaptiveThinking:r.forceAdaptiveThinking}}if(n===Mr)return delete r.forceAdaptiveThinking,Object.keys(r).length===0?void 0:r}var ul=["supportsReasoningEffort","thinkingFormat","thinkingTokenBudgetField","supportsThinkingTokenBudget","vllmPriority"],fl=["forceAdaptiveThinking"];function Ha(e,t){let n=_n(t),r;if(n===Mr)r=fl;else if(n===Bg)r=[...ul,...fl];else if(n===Ca)r=ul;else return;let o=!1,i={...e};for(let a of r)a in i&&(delete i[a],o=!0);return o?i:void 0}function Gg(e,t){let n=_n(t.api);if(n===Mr){let r=e.compat;r!==void 0&&(r=Wg(r,n)??void 0);let o=e.efforts!==!1;return r===void 0?o&&La(t.baseURL)?{thinkingTokenBudgetField:"thinking_token_budget"}:void 0:o&&r.thinkingTokenBudgetField===void 0&&r.supportsThinkingTokenBudget!==!0&&La(t.baseURL)?{...r,thinkingTokenBudgetField:"thinking_token_budget"}:r}if(n===Ca&&e.anthropicAdaptive===!0)return{forceAdaptiveThinking:!0}}var Ug=["openai.com","openai.azure.com","deepseek.com","openrouter.ai","z.ai","bigmodel.cn","moonshot.ai","moonshot.cn","aliyuncs.com","anthropic.com","x.ai","together.ai","together.xyz","nvidia.com","cerebras.ai","cloudflare.com","chutes.ai","opencode.ai","ant-ling.com"];function Na(e){if(_n(e.api)!==Mr)return!1;let t=e.baseURL;if(t===void 0||t.length===0)return!1;try{let n=new URL(t).hostname.toLowerCase();return n.includes(".")?!Ug.some(r=>n===r||n.endsWith("."+r)):!1}catch{return!1}}function pl(e,t,n){return e===void 0||!n||e.supportsDeveloperRole!==void 0||!Na(t)?e:{...e,supportsDeveloperRole:!1}}var ml={off:null,low:"low",medium:"medium",high:"high"},jg=["vl","vision","omni","4o","pixtral","internvl"];function Oa(e){let t=nn(e);for(let n of jg){let r=nn(n),o=t.indexOf(r);for(;o>=0;){if(Aa(t,o,r.length))return["text","image"];o=t.indexOf(r,o+1)}}}var zg=["dall-e","dalle","gpt-image","imagen","flux","stable-diffusion","sdxl","sd3","cogview","wanx","seedream","seededit","midjourney","niji","nano-banana","image-gen","imagegen","qwen-image","grok-2-image"];function $g(e){let t=nn(e);for(let n of zg){let r=nn(n),o=t.indexOf(r);for(;o>=0;){if(Aa(t,o,r.length))return!0;o=t.indexOf(r,o+1)}}return!1}function Vg(e){if(e===void 0)return;let t=e.map(n=>n.toLowerCase());if(t.some(n=>Pg.includes(n)))return t.includes("image")?["text","image"]:["text"]}function xt(e,t,n){let r=Ra(e,t.displayName),o,i,a,s,d;r?.imageGen===!0&&(a=!0),r?.input!==void 0&&(o=r.input,i="knowledge"),r?.contextWindow!==void 0&&(s=r.contextWindow),r?.maxTokens!==void 0&&(d=r.maxTokens);let l=Vg(n?.input);l!==void 0&&(o=l,i="endpoint");let c=n?.output;if(c!==void 0&&(a=c.includes("image")&&!c.includes("text")),n?.contextLength!==void 0&&Number.isFinite(n.contextLength)&&n.contextLength>0&&(s=n.contextLength),o===void 0){let v=Oa(e);v!==void 0&&(o=v,i="heuristic")}a===void 0&&$g(e)&&(a=!0),a===!0&&(o=void 0,i=void 0);let f={...o===void 0?{}:{input:o},...i===void 0?{}:{inputSource:i},...a===void 0?{}:{imageGen:a},...s===void 0?{}:{contextWindow:s},...d===void 0?{}:{maxTokens:d}},h=n===void 0?{}:{endpoint:{reasoning:n.reasoning,source:n.source}};if(n?.reasoning===!1)return{efforts:!1,matched:!1,source:"endpoint:"+(n.source??"listing"),confidence:"high",...h,...f};if(r!==void 0){let v=pl(Gg(r,t),t,r.efforts!==!1);return{efforts:r.efforts,...r.efforts!==!1&&r.defaultEffort!==void 0&&r.efforts[r.defaultEffort]!==void 0?{defaultEffort:r.defaultEffort}:{},...v===void 0?{}:{compat:v},matched:!0,entryId:r.id,source:r.id,confidence:"high",...h,...f}}let p=Kg(t),m=_g[p]??Fg,b=_n(t.api)===Mr?{thinkingFormat:"openai",supportsReasoningEffort:!0}:void 0,g=b!==void 0&&La(t.baseURL)?{...b,thinkingTokenBudgetField:"thinking_token_budget"}:b,y=pl(g,t,!0);return n?.reasoning===!0?{efforts:{...ml},...ml.medium!==void 0?{defaultEffort:"medium"}:{},...y===void 0?{}:{compat:y},matched:!1,source:"endpoint:"+(n.source??"listing"),confidence:"medium",...h,...f}:{efforts:m,...m.medium!==void 0?{defaultEffort:"medium"}:{},...y===void 0?{}:{compat:y},matched:!1,source:"protocol:"+p,confidence:"low",...h,...f}}var Bt=(e,t)=>typeof e[t]=="boolean";function Yg(e,t){if(Array.isArray(e)){for(let n of e)if(X(n)&&n.id===t)return n}}function Jg(e){if(!X(e))return{reasoning:"unknown",source:null};let t=e.supported_features;if(Array.isArray(t)&&t.includes("reasoning"))return{...Je(e),reasoning:!0,source:"supported_features"};let n=e.supported_parameters;if(Array.isArray(n)&&(n.includes("reasoning")||n.includes("include_reasoning")||n.includes("reasoning_effort")))return{...Je(e),reasoning:!0,source:"supported_parameters"};if(Bt(e,"supports_reasoning"))return{...Je(e),reasoning:e.supports_reasoning,source:"supports_reasoning"};if(Bt(e,"supportsReasoning"))return{...Je(e),reasoning:e.supportsReasoning,source:"supportsReasoning"};if(Bt(e,"can_reason"))return{...Je(e),reasoning:e.can_reason,source:"can_reason"};if(Bt(e,"reasoning"))return{...Je(e),reasoning:e.reasoning,source:"reasoning"};let r=e.reasoning_effort;if(r===!1)return{...Je(e),reasoning:!1,source:"reasoning_effort"};if(typeof r=="string"&&r.trim().length>0||e.supports_reasoning_effort===!0)return{...Je(e),reasoning:!0,source:"reasoning_effort"};let o=X(e.capabilities)?e.capabilities:void 0;if(o!==void 0){let i=o.thinking,a=X(i)&&typeof i.supported=="boolean"?i.supported:void 0,s=o.effort,d=X(s)&&typeof s.supported=="boolean"?s.supported:void 0;if(d===!0)return{...Je(e),reasoning:!0,source:"capabilities.effort.supported"};if(a===!0)return{...Je(e),reasoning:!0,source:"capabilities.thinking.supported"};if(a===!1)return{...Je(e),reasoning:!1,source:"capabilities.thinking.supported"};if(d===!1)return{...Je(e),reasoning:!1,source:"capabilities.effort.supported"}}return{...Je(e),reasoning:"unknown",source:null}}function Je(e){let t={},n=s=>{if(!Array.isArray(s))return;let d=s.filter(l=>typeof l=="string");return d.length>0?d.map(l=>l.toLowerCase()):[]},r=X(e.architecture)?e.architecture:void 0,o=n(r?.input_modalities);if(o===void 0&&(o=n(e.input_modalities)),o===void 0){let s=X(e.modalities)?e.modalities:void 0;o=n(s?.input)}if(o===void 0){let s=e.capabilities,d=l=>Array.isArray(l)&&l.some(c=>typeof c=="string"&&c.toLowerCase()==="vision");if(d(e.supported_features)||d(s))o=["image"];else if(X(s)){let l=[];for(let c of["image_input","video_input","pdf_input","file_input"]){let f=X(s[c])?s[c]:void 0;if(f===void 0||typeof f.supported!="boolean")continue;let h=c.replace(/_input$/,"");f.supported===!0?l.push(h):l.length===0&&l.push("text")}l.length>0&&(o=l)}}o===void 0&&(Bt(e,"supports_vision")?o=e.supports_vision===!0?["image"]:[]:Bt(e,"supportsVision")?o=e.supportsVision===!0?["image"]:[]:(Bt(e,"supports_images")||Bt(e,"supportsImages"))&&(o=e.supports_images===!0||e.supportsImages===!0?["image"]:[])),o!==void 0&&(t.input=o.length===0?["text"]:o);let i=n(r?.output_modalities);if(i===void 0&&(i=n(e.output_modalities)),i===void 0){let s=X(e.modalities)?e.modalities:void 0;i=n(s?.output)}i!==void 0&&(t.output=i);let a=e.context_length;if(typeof a=="number"&&Number.isFinite(a)&&a>0)t.contextLength=a;else{let d=(X(e.top_provider)?e.top_provider:void 0)?.context_length;if(typeof d=="number"&&Number.isFinite(d)&&d>0)t.contextLength=d;else{let l=e.max_input_tokens;if(typeof l=="number"&&Number.isFinite(l)&&l>0)t.contextLength=l;else{let f=(X(e.limit)?e.limit:void 0)?.context;typeof f=="number"&&Number.isFinite(f)&&f>0&&(t.contextLength=f)}}}return t}function hl(e,t){let n=Yg(e,t);return n===void 0?{found:!1,signal:{reasoning:"unknown",source:null}}:{found:!0,signal:Jg(n)}}function Ke(e){let n=e?.value?.providers;return typeof n!="object"||n===null||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(([,r])=>typeof r=="object"&&r!==null&&!Array.isArray(r)))}function So(e){if(!X(e))return;let t=e.providers;return X(t)?t:void 0}function yl(e,t){for(let n of[e?.user,e?.base]){let r=So(n)?.[t];if(X(r)&&r.models!==void 0)return r.models}}function rn(e){return So(e?.user)}function Mo(e,t){let n=e.find(o=>o.id===t);if(n===void 0)return;let r=n.reasoningEfforts;if(r===!1)return!1;if(typeof r=="object"&&r!==null&&!Array.isArray(r))return r}function Lo(e,t){let r=e.find(i=>i.id===t)?.input;if(!Array.isArray(r))return;let o=r.filter(i=>typeof i=="string");return o.length>0?o:void 0}function Ao(e,t){let r=e.find(o=>o.id===t)?.compat;if(X(r))return{...r}}function Pa(e,t){return e.find(r=>r.id===t)?.[at]===!0}function Ro(e,t){let r=e.find(o=>o.id===t)?.name;return typeof r=="string"&&r.length>0?r:void 0}function Co(e,t){let r=e.find(o=>o.id===t)?.[Mn];return typeof r=="string"&&r.length>0?r:void 0}var Xg=3e4,Qg=15e3,Ia=new Map,To=new Map;async function Zg(e){let t=Ia.get(e);if(t!==void 0&&Date.now()-t.at<Xg)return t.data;let n=To.get(e);if(n!==void 0)return n;let r=(async()=>{try{let o=await fetch(`${Hd}?route=${encodeURIComponent(e)}`,{method:"GET",signal:AbortSignal.timeout(Qg)});if(!o.ok)return;let i=await o.json();return i?.ok?(Ia.set(e,{at:Date.now(),data:i.data}),i.data):void 0}catch{return}finally{To.delete(e)}})();return To.set(e,r),r}function Da(){Ia.clear(),To.clear()}async function eh(e,t){let n=await Zg(e);return n===void 0?{reasoning:"unknown",source:null}:hl(n,t).signal}function Ho(e,t=()=>pe(e),n,r,o,i){return{async suggest(a,s,d,l){let c=Ke((await t()).namespace),f=tn(c,a),h={api:f.api??l?.api,baseURL:f.baseURL??l?.baseURL,displayName:d??f.displayName},p=c[a]===void 0?void 0:await eh(a,s),m=xt(s,h,p);return m.efforts===void 0?{ok:!1,error:"no-suggestion"}:{ok:!0,suggestion:{efforts:m.efforts,...m.compat===void 0?{}:{compat:m.compat},...m.defaultEffort===void 0?{}:{defaultEffort:m.defaultEffort},...m.input===void 0?{}:{input:m.input},...m.inputSource===void 0?{}:{inputSource:m.inputSource},...m.imageGen===void 0?{}:{imageGen:m.imageGen},...m.contextWindow===void 0?{}:{contextWindow:m.contextWindow},...m.maxTokens===void 0?{}:{maxTokens:m.maxTokens},matched:m.matched,source:m.source,confidence:m.confidence,...m.endpoint===void 0?{}:{endpoint:m.endpoint}}}},commit(a,s,d){if(i?.()===!0){n?.(a,s,d.efforts,d.compat,d.input,d.defaultEffort,d.imageGen);return}r?.(a,s,{efforts:d.efforts,...d.compat===void 0?{}:{compat:d.compat},...d.input===void 0?{}:{input:d.input},...d.imageGen===void 0?{}:{imageGen:d.imageGen},...d.defaultEffort===void 0?{}:{defaultEffort:d.defaultEffort}})},withdraw(a,s){o?.(a,s)},stageEfforts(a,s,d,l,c,f,h){n?.(a,s,d,l,c,f,h)},async writeEfforts(a,s,d,l,c,f,h){if(r!==void 0)return r(a,s,{efforts:d,...l===void 0?{}:{compat:l},...c===void 0?{}:{input:c},...h===void 0?{}:{imageGen:h},...f===void 0?{}:{defaultEffort:f}}),{ok:!0,staged:!0};let m=(await Lr(e,a,[{modelId:s,efforts:d,...l===void 0?{}:{compat:l},...c===void 0?{}:{input:c},...h===void 0?{}:{imageGen:h},...f===void 0?{}:{defaultEffort:f}}],t))[0]??{ok:!1,error:"no-result"};return m.ok?{ok:!0}:m.modelNotFound===!0?{ok:!1,error:"model-not-found"}:{ok:!1,error:m.error??"conflict"}}}}async function Lr(e,t,n,r=()=>pe(e),o){if(n.length===0)return[];let i=!1;for(let a=0;a<3;a++)try{let s=a===0?await r():await pe(e,{fresh:!0});if(s.namespace===void 0)return n.map(()=>({ok:!1,error:"no-namespace"}));let d=yl(s.namespace,t);if(!Array.isArray(d))return n.map(()=>({ok:!1,modelNotFound:!0}));if(!d.every(X))return n.map(()=>({ok:!1,error:"invalid-models"}));let c=d.map(p=>p),f=[];for(let p of n){let m=c.findIndex(b=>b.id===p.modelId);if(m<0){f.push(p.modelId);continue}c[m]=th(c[m],p,i?void 0:p.compat)}if(f.length>0)return n.map(p=>f.includes(p.modelId)?{ok:!1,modelNotFound:!0}:{ok:!1,error:"model-not-found"});if(o?.()===!0)return n.map(()=>({ok:!1,aborted:!0}));let h=await e.settings.mutate(De,[{op:"set",path:["providers",t,"models"],value:c}],s.namespace.revision);if(!h.ok){if(a===0&&h.error.code==="settings/conflict")continue;let p=h.error.code==="settings/rejected"&&ll(h.error.message);if(!i&&p&&n.some(m=>m.compat!==void 0)){i=!0;continue}return n.map(()=>({ok:!1,error:h.error.message}))}return n.map(()=>({ok:!0}))}catch(s){return n.map(()=>({ok:!1,error:s instanceof Error?s.message:String(s)}))}return n.map(()=>({ok:!1,error:"conflict"}))}function th(e,t,n){let r={...e},o=t.efforts!=="keep",i=t.efforts==="keep"?void 0:t.efforts;if(o)if(i===void 0)delete r.reasoningEfforts,r[it]=!0;else if(delete r[it],delete r[Sn],i===!1)r.reasoningEfforts=!1;else{r.reasoningEfforts={...i};let s={...X(e.compat)?e.compat:{},...n??{}};Object.keys(s).length>0&&(r.compat=s)}return t.input!==void 0&&(t.input===null?(delete r.input,r[wt]=!0):(delete r[wt],r.input=[...t.input])),t.imageGen!==void 0&&(t.imageGen===!0?(r[at]=!0,delete r.input,delete r[wt]):delete r[at]),t.defaultEffort!==void 0&&(t.defaultEffort===null?delete r[Mn]:r[Mn]=t.defaultEffort),r}function _a(e,t){for(let n of[e?.user,e?.base]){let r=So(n)?.[t];if(!X(r))continue;let o=r.headers;if(o===void 0)continue;if(!X(o))return;let i={};for(let[a,s]of Object.entries(o))typeof s=="string"&&(i[a]=s);return i}}async function Ar(e,t,n){if(typeof t!="string"||t.length===0)return{ok:!1,error:"no-route"};let r=!1;for(let o=0;o<2;o+=1)try{let i=o===0?await pe(e):await pe(e,{fresh:!0});if(i.namespace===void 0)return{ok:!1,error:"no-namespace"};if(i.writable!==!0)return{ok:!1,error:"read-only"};if(!st(i.namespace,t)){r=!0;continue}let a=await e.settings.mutate(De,[{op:"set",path:["providers",t,"headers"],value:{...n}}],i.namespace.revision);if(!a.ok){if(o===0&&a.error.code==="settings/conflict")continue;return{ok:!1,error:a.error.message}}return{ok:!0}}catch(i){return{ok:!1,error:i instanceof Error?i.message:String(i)}}return r?{ok:!1,error:"no-route"}:{ok:!1,error:"conflict"}}function st(e,t){if(Object.prototype.hasOwnProperty.call(Ke(e),t))return!0;for(let n of[e?.user,e?.base]){let r=So(n);if(r!==void 0&&Object.prototype.hasOwnProperty.call(r,t))return!0}return!1}async function pe(e,t={}){let n=t.fresh===!0?void 0:nh(e,t.allowStale===!0);if(n!==void 0)return n;let r=await e.settings.describe();return r.ok?{namespace:r.value.namespaces.find(i=>i.ns===De),writable:r.value.writable,source:"wire"}:{namespace:void 0,writable:!1,source:"wire"}}var bl=new WeakMap;function nh(e,t=!1){let n=e.scope;if(n===void 0)return;let r=n.getSnapshot();if(r===void 0)return;if(r.status==="ready"&&typeof r.revision=="number"){let i={namespace:{ns:De,schema:{},value:r.value,user:r.user,base:r.base,revision:r.revision,applies:"live",secrets:[]},writable:r.writable===!0,source:"scope"};return bl.set(n,i),i}if(!t||n===void 0)return;let o=bl.get(n);if(o!==void 0)return{...o,source:"scope-stale"}}var Fa=new Map;function vl(e){let t=Fa,n=!1,r,o=0,i=new Set,a=()=>{for(let d of[...i])d()},s=()=>{if(n)return Promise.resolve();if(r!==void 0)return r;let d=o;return r=pe(e,{fresh:!0}).then(l=>{if(d!==o||l.namespace===void 0)return;let c=new Map;for(let[f,h]of Object.entries(Ke(l.namespace))){let p=new Map,m=Array.isArray(h.models)?h.models:[];for(let b of m){if(!X(b)||typeof b.id!="string"||b.id.length===0)continue;let g={};if(Array.isArray(b.input)){let v=b.input.filter(x=>typeof x=="string");v.length>0&&(g.input=v)}b[at]===!0&&(g.imageGen=!0);let y=b.contextWindow;typeof y=="number"&&Number.isFinite(y)&&y>0&&(g.contextWindow=y),(g.input!==void 0||g.imageGen!==void 0||g.contextWindow!==void 0)&&p.set(b.id,g)}p.size>0&&c.set(f,p)}t=c,n=!0,a()}).catch(()=>{}).finally(()=>{d===o&&(r=void 0)}),r};return{getSnapshot:()=>t,subscribe(d){return i.add(d),()=>{i.delete(d)}},load:s,invalidate(){o+=1,n=!1,r=void 0,i.size>0&&s()}}}var rh=new Intl.NumberFormat("en-US"),oh=/^(\d+(?:\.\d+)?)([kmbt])?$/i,ih={k:1e3,m:1e6,b:1e9,t:1e12};function kt(e){let t=e.replace(/[,_\s]/g,"");if(t==="")return;let n=oh.exec(t);if(n===null)return;let r=n[2]===void 0?1:ih[n[2].toLowerCase()],o=Math.round(Number(n[1])*r);return Number.isFinite(o)&&o>0?o:void 0}function ht(e){return e===void 0?"":rh.format(e)}function wl(e){if(e===void 0||!Number.isFinite(e)||e<=0)return"";let t=1024,n=t*1024,r=n*1024,o=r*1024,i=s=>Number.isInteger(s)?String(s):s.toFixed(1).replace(/\.0$/,""),a=[{floor:1e12,binary:o,decimal:1e12,suffix:"T"},{floor:1e9,binary:r,decimal:1e9,suffix:"B"},{floor:1e6,binary:n,decimal:1e6,suffix:"M"},{floor:1e3,binary:t,decimal:1e3,suffix:"K"}];for(let s of a){if(e<s.floor)continue;if(e%s.binary===0)return`${e/s.binary}${s.suffix}`;if(e%s.decimal===0)return`${e/s.decimal}${s.suffix}`;let d=p=>Math.round(p*10)/10,l=e/s.binary,c=e/s.decimal,f=Math.abs(e-d(l)*s.binary),h=Math.abs(e-d(c)*s.decimal);return f<=h?`${i(l)}${s.suffix}`:`${i(c)}${s.suffix}`}return String(e)}var kl="dsh-model-think-level.slider.efforts",qa="breSelectWired",ah=400;function sh(e){return e===void 0?Promise.resolve(void 0):new Promise(t=>{let n=!1,r=i=>{n||(n=!0,t(i))},o=setTimeout(()=>r(void 0),ah);e.then(i=>{clearTimeout(o),r(i)},()=>{clearTimeout(o),r(void 0)})})}function Ka(e){return typeof e=="object"&&e!==null&&e.ok===!1}function Ba(e){if(!Ka(e))return;let t=e.error,n=typeof t?.code=="string"?t.code:"settings/rejected",r=typeof t?.message=="string"?t.message:"";return r.length>0?`${n}: ${r}`:n}function on(e,t){return`${e}/${t}`}function El(){try{let e=window.localStorage.getItem(kl);if(e===null)return{};let t=JSON.parse(e);if(typeof t!="object"||t===null||Array.isArray(t))return{};let n={};for(let[r,o]of Object.entries(t))r.length>0&&typeof o=="string"&&o.trim().length>0&&(n[r]=o);return n}catch{return{}}}function dh(e){try{window.localStorage.setItem(kl,JSON.stringify(e))}catch{}}function lh(e,t,n){let r=El();r[on(e,t)]=n,dh(r)}function ch(e,t){return El()[on(e,t)]}function No(e,t,n){let o=e.groups.find(i=>i.id===t)?.models.find(i=>i.id===n)?.reasoning?.efforts;return o===void 0?[]:o.map(i=>i.id)}function uh(e,t,n){return e.groups.find(o=>o.id===t)?.models.find(o=>o.id===n)?.reasoning?.defaultEffort}function fh(e){if(!(e.length<2))return e[Math.floor((e.length-1)/2)]}function ph(e,t){return e===null||e.provider!==t.provider||e.model!==t.model}async function xl(e,t,n,r,o){let i=No(e,t,n);if(i.length===0)return;let a=on(t,n),s=r.get(a);if(s!==void 0&&i.includes(s))return s;let d=await sh(o?.configuredEffort===void 0?void 0:o.configuredEffort(t,n));if(d!==void 0&&i.includes(d))return d;let l=ch(t,n);if(l!==void 0&&i.includes(l))return l;let c=xt(n,{}).defaultEffort;if(c!==void 0&&i.includes(c))return c;let f=uh(e,t,n);return f!==void 0&&i.includes(f)?f:fh(i)}function Tl(e,t){let n=e;if(n[qa]===!0)return()=>{};let r=Object.prototype.hasOwnProperty.call(n,"select"),o=e.select,i=new Map,a=new Set,s=new Map,d=3,l=0,c=0,f=async(b,g)=>{if(g.reasoningEffort!==void 0){let q=await o.call(e,g);return!Ka(q)&&mt()&&(i.set(on(g.provider,g.model),g.reasoningEffort),lh(g.provider,g.model,g.reasoningEffort)),q}let y=e.store.getSnapshot();if(!ph(y.current,g)){if(mt()){let q=on(g.provider,g.model);i.delete(q),a.add(q)}return o.call(e,g)}if(!mt())return o.call(e,g);let v=await xl(y,g.provider,g.model,i,t);if(l!==b)return;let x=e.store.getSnapshot(),H=x.current!==null&&x.current.provider===g.provider&&x.current.model===g.model;return!mt()||v===void 0||!No(x,g.provider,g.model).includes(v)?H?void 0:o.call(e,g):o.call(e,{...g,reasoningEffort:v})},h=async b=>{let g=++l;try{return await f(g,b)}finally{g>c&&(c=g)}},p=()=>{let b=e.store.getSnapshot(),g=b.current;if(g===null||g.reasoningEffort!==void 0||!mt())return;let y=on(g.provider,g.model);if(a.has(y))return;if(No(b,g.provider,g.model).length===0){a.add(y);return}a.add(y);let v=l;xl(b,g.provider,g.model,i,t).then(async x=>{if(x===void 0){a.delete(y);return}if(!mt()){a.delete(y);return}if(l!==v)return;if(l!==c){a.delete(y);return}let H=e.store.getSnapshot(),q=H.current;if(q===null||q.reasoningEffort!==void 0||on(q.provider,q.model)!==y||!No(H,q.provider,q.model).includes(x))return;let ne=await o.call(e,{provider:q.provider,model:q.model,reasoningEffort:x});if(Ka(ne))throw ne}).catch(()=>{let x=(s.get(y)??0)+1;s.set(y,x),x<d&&(a.delete(y),p())})},m=e.store.subscribe(p);return p(),n[qa]=!0,e.select=h,()=>{delete n[qa],m(),r?e.select=o:delete n.select}}var mh=1e4;function Sl(e){if(e.current===null)return[];let r=e.groups.find(o=>o.id===e.current?.provider)?.models.find(o=>o.id===e.current?.model)?.reasoning?.efforts;return r!==void 0&&r.length>=2?r:[]}function gh(e){return e.current}function Ml(e,t){let n=gh(t),r=e.findIndex(s=>s.id===n?.reasoningEffort);if(r>=0)return r;let i=t.groups.find(s=>s.id===n?.provider)?.models.find(s=>s.id===n?.model)?.reasoning?.defaultEffort,a=i===void 0?-1:e.findIndex(s=>s.id===i);return a>=0?a:Math.floor((e.length-1)/2)}function hh(e){return e?.models??[]}function Wt(e){let t=e;return t.name??t.label??t.title??e.id}function Wa(e){if(typeof document>"u"||!e.isConnected||e.getClientRects().length===0)return!1;let t=e.getBoundingClientRect();return t.width>0||t.height>0}function bh(){let[e,t]=(0,O.useState)(null),n=(0,O.useRef)(0),r=(0,O.useCallback)(()=>{window.clearTimeout(n.current),t(null)},[]),o=(0,O.useCallback)((i,a)=>{window.clearTimeout(n.current);let s=i.currentTarget;s.scrollWidth<=s.clientWidth+1||(n.current=window.setTimeout(()=>{Wa(s)&&(s.scrollWidth<=s.clientWidth+1||t({target:s,text:a}))},300))},[]);return(0,O.useEffect)(()=>()=>{window.clearTimeout(n.current),t(null)},[]),(0,O.useEffect)(()=>{if(e===null)return;let i=e.target,a=()=>{t(null)};window.addEventListener("pointerdown",a,!0),window.addEventListener("keydown",a,!0),window.addEventListener("scroll",a,!0),window.addEventListener("wheel",a,{capture:!0,passive:!0}),window.addEventListener("resize",a);let s=typeof MutationObserver>"u"?null:new MutationObserver(()=>{Wa(i)||a()});return s?.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]}),()=>{window.removeEventListener("pointerdown",a,!0),window.removeEventListener("keydown",a,!0),window.removeEventListener("scroll",a,!0),window.removeEventListener("wheel",a,!0),window.removeEventListener("resize",a),s?.disconnect()}},[e]),{tip:e,onEnter:o,onLeave:r}}function yh({state:e}){if(typeof document>"u")return null;let t=e.target;if(!Wa(t))return null;let n=t.getBoundingClientRect();if(n.top>window.innerHeight||n.bottom<0)return null;let r=Math.max(12,Math.min(n.right,window.innerWidth-12));return(0,Rl.createPortal)((0,O.createElement)("div",{className:"bre-tip",role:"tooltip",style:{top:Math.min(n.bottom+6,window.innerHeight-40),right:Math.max(12,window.innerWidth-r)}},e.text),document.body)}var Ll=new Map;function vh(e,t){let n=t??e.input;if(Array.isArray(n)&&n.length>0)return n.includes("image");let r=JSON.stringify([e.id,e.name]),o=Ll.get(r);if(o!==void 0)return o;let i=Ra(e.id,e.name)?.input,a=i!==void 0?i.includes("image"):(Oa(e.id)??[]).includes("image");return Ll.set(r,a),a}function Al(e,t){return t?.imageGen===!0?!0:e.inputImageGen===!0}function wh(e){let t=e.reasoning?.efforts;return Array.isArray(t)&&t.length>0}function xh(e){return(0,O.createElement)("svg",{className:"bre-tag-icon",width:13,height:13,viewBox:"0 0 16 16",fill:"none",role:"img","aria-label":e},(0,O.createElement)("path",{d:"M1.8 8s2.4-4.2 6.2-4.2S14.2 8 14.2 8s-2.4 4.2-6.2 4.2S1.8 8 1.8 8z",stroke:"currentColor",strokeWidth:1.3,strokeLinejoin:"round"}),(0,O.createElement)("circle",{cx:8,cy:8,r:1.8,fill:"currentColor"}))}function kh(e){return(0,O.createElement)("svg",{className:"bre-tag-icon",width:13,height:13,viewBox:"0 0 16 16",fill:"none",role:"img","aria-label":e},(0,O.createElement)("path",{d:"M8 1.9l1.35 3.75L13.1 7l-3.75 1.35L8 12.1 6.65 8.35 2.9 7l3.75-1.35z",fill:"currentColor"}))}function Eh(e){return(0,O.createElement)("svg",{className:"bre-tag-icon",width:13,height:13,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.3,strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e},(0,O.createElement)("path",{d:"M9.4 12.7H3.6a1.7 1.7 0 0 1-1.7-1.7V5.1a1.7 1.7 0 0 1 1.7-1.7h4.2"}),(0,O.createElement)("path",{d:"M2.6 10.6 5.3 8.5l1.8 1.5 1.6-1.3 2.3 2"}),(0,O.createElement)("path",{d:"M12.4 2.2l.75 2.05L15.2 5l-2.05.75L12.4 7.8l-.75-2.05L9.6 5l2.05-.75Z",fill:"currentColor",stroke:"none"}))}var Th=["#22c55e","#a3e635","#eab308","#f97316","#ef4444"],iE=Th.map(e=>[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]);function Sh(e,t,n,r=!1){let o=[];return vh(e,n)&&o.push((0,O.createElement)("span",{key:"vision",className:"bre-tag",title:t("tagVision")},xh(t("tagVision")))),wh(e)&&o.push((0,O.createElement)("span",{key:"thinking",className:"bre-tag",title:t("tagThinking")},kh(t("tagThinking")))),r&&o.push((0,O.createElement)("span",{key:"imageGen",className:"bre-tag",title:t("tagImageGen")},Eh(t("tagImageGen")))),o.length===0?null:(0,O.createElement)("span",{className:"bre-option-tags"},...o)}function Mh(e,t){let n=wl(e);return n===""?null:(0,O.createElement)("span",{className:"bre-option-cap",title:t("contextWindowLabel")},n)}function Cl(e){let{directory:t,t:n,configuredInputs:r}=e,o=(0,O.useSyncExternalStore)(L=>t.store.subscribe(L),()=>t.store.getSnapshot()),i=(0,O.useSyncExternalStore)(L=>r?.subscribe(L)??(()=>{}),()=>r?.getSnapshot()??Fa),a=Sl(o),[s,d]=(0,O.useState)(()=>{let L=t.store.getSnapshot(),j=Sl(L);return j[Ml(j,L)]?.id??""}),[l,c]=(0,O.useState)(""),[f,h]=(0,O.useState)(null),[p,m]=(0,O.useState)(!1),[b,g]=(0,O.useState)(null),y=(0,O.useRef)(null),v=(0,O.useRef)(""),x=(0,O.useRef)(!1),H=o.current!==null&&a.length>=2,q=p,ne=b??o.error,K=t.select,S=(0,O.useCallback)(()=>setTimeout(()=>{x.current&&(x.current=!1,m(!1),g(n("sliderCommitSlow")))},mh),[n]);(0,O.useLayoutEffect)(()=>{if(x.current||T.current)return;let L=Ml(a,o),j=a[L]?.id??"";v.current=j,d(ge=>ge===j?ge:j),g(null)},[H,a,o]),(0,O.useEffect)(()=>{t.load().catch(()=>{})},[t]),(0,O.useEffect)(()=>{r?.load().catch(()=>{})},[r]);let C=o.current,M=o.groups.find(L=>L.id===C?.provider),k=M?.models.find(L=>L.id===C?.model)?.name??(C===null?n("triggerFallback"):C.model),R=C===null?"":Wt(M??{id:C.provider}),I=a.find(L=>L.id===s)?.name??n("effortDefault"),D=(0,O.useSyncExternalStore)(Cn,Rn),W=(0,O.useSyncExternalStore)(On,vr),N=(0,O.useSyncExternalStore)(In,wr),V=(0,O.useCallback)((L,j)=>i.get(L)?.get(j),[i]),ie=(0,O.useCallback)((L,j)=>Al(j,V(L,j.id)),[V]),re=(0,O.useCallback)((L,j)=>hh(L).filter(ge=>!ie(j,ge)),[ie]),oe=o.groups.filter(L=>re(L,L.id).length>0&&!W.includes(L.id)).map(L=>L.id),ae=Hn(ca(oe),D),de=f!==null&&ae.includes(f)?f:C!==null&&ae.includes(C.provider)?C.provider:ae[0]??null,he=l.trim().toLowerCase(),te=he!=="",ue=te?ae.flatMap(L=>ya(re(o.groups.find(j=>j.id===L),L),N[L]??[]).filter(j=>(j.name??j.id).toLowerCase().includes(he)||j.id.toLowerCase().includes(he)).map(j=>({provider:L,choice:j}))):[],Te=te?ue:de===null?[]:ya(re(o.groups.find(L=>L.id===de),de),N[de]??[]).map(L=>({provider:de,choice:L})),Le=C===null?"":C.provider+"/"+C.model,He=n("sliderNoCurrent"),Y=(0,O.useCallback)(()=>{let L=y.current?.closest('[role="menu"], [role="group"]');L!=null&&(L.tabIndex=-1,L.focus({preventScroll:!0}))},[]),B=(0,O.useCallback)(async(L,j)=>{if(x.current)return;let ge=t.store.getSnapshot().current;if(te&&c(""),ge!==null&&ge.provider===L&&ge.model===j)return;x.current=!0,Y(),m(!0),g(null);let ze=S();try{let $e=await K({provider:L,model:j}),pt=Ba($e);if(pt!==void 0)throw new Error(pt)}catch($e){g($e instanceof Error?$e.message:String($e))}finally{clearTimeout(ze),x.current=!1,m(!1)}},[S,t,Y,te,K]),J=(0,O.useCallback)(async L=>{if(x.current||L===o.current?.reasoningEffort&&o.status!=="error")return;x.current=!0;let j=v.current;Y(),m(!0),g(null),d(L);let ge=S();try{let ze=o.current;if(ze===null)throw new Error(n("sliderNoCurrent"));let $e=await K({provider:ze.provider,model:ze.model,reasoningEffort:L}),pt=Ba($e);if(pt!==void 0)throw new Error(pt);let en=t.store.getSnapshot(),Rd=a.find(mg=>mg.id===en.current?.reasoningEffort)?.id??L;v.current=Rd,d(Rd)}catch(ze){v.current=j,d(j),g(ze instanceof Error?ze.message:String(ze))}finally{clearTimeout(ge),x.current=!1,m(!1)}},[S,t,Y,a,K,o.current,o.status,n]),Z=(0,O.useRef)(null),fe=(0,O.useRef)(null),u=(0,O.useRef)(null),T=(0,O.useRef)(!1),_=(0,O.useRef)(null),F=(0,O.useRef)(null),Q=(0,O.useRef)(null),[ve,we]=(0,O.useState)(null),[A,z]=(0,O.useState)(null),le=Math.max(0,a.findIndex(L=>L.id===s)),xe=ve??le,Se=(A??(a.length>1?xe/(a.length-1):0))*100,me=L=>{let j=Z.current;if(j===null)return 0;let ge=j.getBoundingClientRect();return ge.width<=0?0:Math.min(1,Math.max(0,(L-ge.left)/ge.width))},Pe=L=>a.length>1?Math.round(L*(a.length-1)):0,je=L=>{F.current=L;let j=L*100;fe.current!==null&&(fe.current.style.clipPath=`inset(0 ${100-j}% 0 0)`),u.current!==null&&(u.current.style.left=`${j}%`)},ft=L=>{if(a.length===0)return;let j=me(L);Q.current===null&&(Q.current=requestAnimationFrame(()=>{Q.current=null,T.current&&F.current!==null&&je(F.current)})),F.current=j;let ge=Pe(j);ge!==_.current&&(_.current=ge,we(ge),z(j))},Qt=()=>{_.current=null,F.current=null,Q.current!==null&&(cancelAnimationFrame(Q.current),Q.current=null),we(null),z(null)},En=L=>{if(H){if(L.preventDefault(),T.current=!0,typeof L.currentTarget.setPointerCapture=="function")try{L.currentTarget.setPointerCapture(L.pointerId)}catch{}_.current=Pe(me(L.clientX)),ft(L.clientX),we(_.current),z(F.current)}},Ae=L=>{T.current&&ft(L.clientX)},co=L=>{if(!T.current)return;if(T.current=!1,typeof L.currentTarget.releasePointerCapture=="function"&&L.currentTarget.hasPointerCapture?.(L.pointerId)===!0)try{L.currentTarget.releasePointerCapture(L.pointerId)}catch{}let j=Pe(me(L.clientX)),ge=a[j];if(ge===void 0){Qt();return}J(ge.id).finally(Qt)},ea=L=>{if(!H)return;let j;if(L.key==="ArrowRight"||L.key==="ArrowUp"?j=Math.min(a.length-1,xe+1):L.key==="ArrowLeft"||L.key==="ArrowDown"?j=Math.max(0,xe-1):L.key==="Home"?j=0:L.key==="End"&&(j=a.length-1),j===void 0)return;L.preventDefault();let ge=a[j];ge!==void 0&&J(ge.id)},{tip:Tn,onEnter:Zt,onLeave:hr}=bh(),uo=(0,O.createElement)("div",{className:"bre-menu-head"},(0,O.createElement)("span",{className:"bre-row-label"},n("modelRowLabel")),(0,O.createElement)("span",{className:"bre-menu-cur"},(0,O.createElement)("span",{className:"bre-menu-name","aria-label":C===null?k:R+" \xB7 "+k,onMouseEnter:L=>{Zt(L,C===null?k:R+" \xB7 "+k)},onMouseLeave:hr},k),R===""?null:(0,O.createElement)("span",{className:"bre-menu-prov"},R))),P=(0,O.createElement)("div",{className:"bre-menu-search"},(0,O.createElement)("div",{className:"bre-menu-search-box"},(0,O.createElement)("span",{className:"bre-menu-search-icon","aria-hidden":!0},(0,O.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,O.createElement)("circle",{cx:"7",cy:"7",r:"4.5"}),(0,O.createElement)("path",{d:"M10.5 10.5L14 14",strokeLinecap:"round"}))),(0,O.createElement)("input",{type:"text",className:"bre-menu-search-input",role:"searchbox",placeholder:n("modelSearchPlaceholder"),"aria-label":n("modelSearchPlaceholder"),value:l,spellCheck:!1,autoComplete:"off",onChange:L=>{c(L.currentTarget.value)},onKeyDown:L=>{L.key!=="Escape"||l===""||(L.preventDefault(),L.stopPropagation(),c(""))}}),l===""?null:(0,O.createElement)("button",{type:"button",className:"bre-menu-search-clear",title:n("modelSearchClear"),"aria-label":n("modelSearchClear"),onClick:()=>{c("")}},(0,O.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,O.createElement)("path",{d:"M4 4L12 12M12 4L4 12",strokeLinecap:"round"}))))),ce=(0,O.createElement)("div",{className:"bre-providers",role:"group","aria-label":n("modelRowLabel")},...ae.map(L=>{let j=o.groups.find(ge=>ge.id===L);return(0,O.createElement)("button",{key:L,type:"button",className:"bre-provider"+(L===de?" is-open":"")+(L===C?.provider?" is-current":""),disabled:q,"aria-expanded":L===de,onMouseLeave:hr,onClick:()=>{h(L),c("")}},(0,O.createElement)("span",{className:"bre-option-name","aria-label":Wt(j),onMouseEnter:ge=>{Zt(ge,Wt(j))}},Wt(j)),(0,O.createElement)("span",{className:"bre-provider-count"},String(re(j,L).length)))}),...ae.length===0?[(0,O.createElement)("div",{key:"no-providers",className:"bre-empty"},He)]:[]),Re=(0,O.createElement)("div",{className:"bre-provider-models",role:"group","aria-label":n("modelRowLabel")},...Te.length===0?[(0,O.createElement)("div",{key:"no-models",className:"bre-empty"},te?n("modelSearchNoMatches"):He)]:Te.map(({provider:L,choice:j})=>{let ge=L+"/"+j.id,ze=ge===Le,$e=j.name??j.id,pt=te?Wt(o.groups.find(en=>en.id===L))+" \xB7 "+$e:$e;return(0,O.createElement)("button",{key:ge,type:"button",className:"bre-option"+(ze?" is-active":""),disabled:q,"aria-pressed":ze,onMouseLeave:hr,onClick:()=>{B(L,j.id)}},(0,O.createElement)("span",{className:"bre-option-name","aria-label":pt,onMouseEnter:en=>{Zt(en,pt)}},te?(0,O.createElement)("span",{className:"bre-option-origin"},Wt(o.groups.find(en=>en.id===L))+" \xB7 "):null,$e),Mh(V(L,j.id)?.contextWindow,n),Sh(j,n,V(L,j.id)?.input,Al(j,V(L,j.id))))})),Fe=(0,O.createElement)("div",{className:"bre-menu-foot"},H?(0,O.createElement)("div",{className:"bre-menu-slider"},(0,O.createElement)("div",{className:"bre-effort-slider-head","aria-hidden":!0},(0,O.createElement)("span",{className:"bre-effort-slider-head-label"},n("effortRowLabel")),(0,O.createElement)("span",{className:"bre-effort-slider-head-value"},a[xe]?.name??I)),(0,O.createElement)("div",{className:"bre-effort-slider",ref:Z,role:"slider",tabIndex:0,"aria-label":n("effortRowLabel"),"aria-valuemin":0,"aria-valuemax":a.length-1,"aria-valuenow":xe,"aria-valuetext":a[xe]?.name,"aria-disabled":q||void 0,"data-bre-dragging":ve===null?void 0:"true",onPointerDown:En,onPointerMove:Ae,onPointerUp:co,onPointerCancel:co,onKeyDown:ea},(0,O.createElement)("span",{className:"bre-effort-slider-fill",ref:fe,style:{clipPath:`inset(0 ${100-Se}% 0 0)`}}),...a.map((L,j)=>j===xe?null:(0,O.createElement)("span",{key:"tick-"+L.id,className:"bre-effort-slider-tick",style:{left:a.length>1?`${j/(a.length-1)*100}%`:"0%"}})),(0,O.createElement)("span",{className:"bre-effort-slider-thumb",ref:u,style:{left:`${Se}%`}})),(0,O.createElement)("div",{className:"bre-effort-slider-labels","aria-hidden":!0},...a.map((L,j)=>(0,O.createElement)("span",{key:L.id,className:"bre-effort-slider-label"+(j===0?" is-first":"")+(j===a.length-1?" is-last":"")+(j===xe?" is-on":""),style:{left:a.length>1?`${j/(a.length-1)*100}%`:"0%"}},L.name)))):(0,O.createElement)("span",{className:"bre-row-value is-muted"},n("sliderNoLevels")));return(0,O.createElement)("div",{className:"bre-slider-body",ref:y},(0,O.createElement)("div",{className:"bre-card"},uo,P,(0,O.createElement)("div",{className:"bre-panel bre-panel-models"},ce,Re),Fe),ne===null?null:(0,O.createElement)("div",{className:"bre-model-error",role:"status"},ne),Tn===null?null:(0,O.createElement)(yh,{key:"tip",state:Tn}))}var Ee=require("react"),Nl='section[role="group"]',Ua='button[role="menuitemradio"]';function Ol(e){return e.querySelector(Nl)!==null}function Ga(e){return Array.from(e.querySelectorAll(Ua)).filter(t=>!t.disabled&&t.style.display!=="none")}function Lh(e){let t=e.getAttribute("aria-labelledby");return(t===null?null:e.ownerDocument.getElementById(t))?.textContent?.toLowerCase()??""}function Hl(e,t,n=new Map){let r=d=>{n.has(d)||n.set(d,d.style.display),d.style.display="none"},o=d=>{let l=n.get(d);l!==void 0&&(d.style.display=l,n.delete(d))};for(let d of[...n.keys()])d.isConnected||n.delete(d);let i=t.trim().toLowerCase().split(/\s+/).filter(Boolean),a=Array.from(e.querySelectorAll(Nl)),s=0;if(i.length===0){for(let d of[...n.keys()])o(d);for(let d of a)s+=d.querySelectorAll(Ua).length;return s}for(let d of a){let l=Lh(d),c=Array.from(d.querySelectorAll(Ua)),f=0;for(let h of c){let p=(h.getAttribute("title")??"").toLowerCase(),m=(h.textContent??"").toLowerCase(),b=`${l} ${p} ${m}`;i.every(g=>b.includes(g))?(o(h),f+=1):r(h)}f>0?(o(d),s+=f):r(d)}return s}function Il({menu:e,t}){let[n,r]=(0,Ee.useState)(""),[o,i]=(0,Ee.useState)(0),a=(0,Ee.useRef)(null),s=(0,Ee.useRef)(""),d=(0,Ee.useRef)(new Map),l=(0,Ee.useCallback)(p=>{s.current=p;let m=Hl(e,p,d.current);i(m)},[e]);(0,Ee.useEffect)(()=>()=>{Hl(e,"",d.current)},[e]),(0,Ee.useEffect)(()=>{let p=new MutationObserver(()=>{s.current.trim().length!==0&&l(s.current)});return p.observe(e,{childList:!0,subtree:!0}),()=>{p.disconnect()}},[e,l]),(0,Ee.useEffect)(()=>{let p=m=>{if(s.current.trim().length===0)return;let b=m.key;if(!(b==="ArrowDown"||b==="ArrowUp")&&!(b==="Home"||b==="End"||b==="PageUp"||b==="PageDown")||m.target===a.current||m.target instanceof Node&&!e.contains(m.target))return;let v=Ga(e);if(v.length===0)return;let x=v.findIndex(q=>q===document.activeElement),H;b==="Home"||b==="PageUp"?H=0:b==="End"||b==="PageDown"?H=v.length-1:b==="ArrowDown"?H=x===-1?0:(x+1)%v.length:H=x===-1?v.length-1:(x-1+v.length)%v.length,m.preventDefault(),m.stopPropagation(),v[H]?.focus()};return e.addEventListener("keydown",p,!0),()=>{e.removeEventListener("keydown",p,!0)}},[e]);let c=p=>{let m=p.key;if(m==="ArrowDown"){p.preventDefault(),p.stopPropagation(),Ga(e)[0]?.focus();return}if(n.trim().length>0&&(m==="ArrowUp"||m==="Home"||m==="PageUp"||m==="End"||m==="PageDown")){let b=Ga(e);b.length>0&&(p.preventDefault(),p.stopPropagation(),b[m==="ArrowUp"||m==="End"||m==="PageDown"?b.length-1:0]?.focus());return}m==="Escape"&&n.length>0&&(p.preventDefault(),p.stopPropagation(),r(""),l(""))},f=()=>{r(""),l(""),a.current?.focus({preventScroll:!0})},h=o===0&&n.trim().length>0;return(0,Ee.createElement)("div",{className:"bre-model-search-box"+(h?" has-empty":""),"data-bre-search":"1"},(0,Ee.createElement)("div",{className:"bre-search-input-wrapper"},(0,Ee.createElement)("span",{className:"bre-search-icon","aria-hidden":"true"},(0,Ee.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,Ee.createElement)("circle",{cx:"7",cy:"7",r:"4.5"}),(0,Ee.createElement)("path",{d:"M10.5 10.5L14 14",strokeLinecap:"round"}))),(0,Ee.createElement)("input",{ref:a,type:"text",className:"bre-search-input",role:"searchbox",placeholder:t("modelSearchPlaceholder"),"aria-label":t("modelSearchPlaceholder"),value:n,spellCheck:!1,autoComplete:"off",onChange:p=>{let m=p.currentTarget.value;r(m),l(m)},onKeyDown:c}),n.length>0?(0,Ee.createElement)("button",{type:"button",className:"bre-search-clear",title:t("modelSearchClear"),"aria-label":t("modelSearchClear"),onClick:f},(0,Ee.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,Ee.createElement)("path",{d:"M4 4L12 12M12 4L4 12",strokeLinecap:"round"}))):null),h?(0,Ee.createElement)("div",{className:"bre-search-empty",role:"status"},t("modelSearchNoMatches")):null)}var Oo=require("react"),Pl=require("react-dom"),Dl=require("react-dom/client");function bt(){return document.body}function Xe(e,t,n){let r=(0,Dl.createRoot)(e);return n?.sync===!0?(0,Pl.flushSync)(()=>{r.render(t)}):r.render(t),{wrapper:e,root:r}}function Ne(e){e!==void 0&&(e.root.unmount(),e.wrapper.remove())}var Be=class extends Oo.Component{constructor(){super(...arguments);qe(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n instanceof Error?n.message:String(n)}}componentDidCatch(n,r){console.error("[bre] editor render failed:",n,r.componentStack)}render(){return this.state.error!==null?(0,Oo.createElement)("div",{style:{color:"#c00",fontSize:"11px",whiteSpace:"pre-wrap",padding:"6px"}},`${this.props.fallbackText}: ${this.state.error}`):this.props.children}};var Ah="conversation.input.model";function _l(e){return e.querySelector("[data-composer-card]")??void 0}function ja(e){return e.querySelector(`[data-slot="${Ah}"]`)??void 0}function Fl(e){let t=ja(e)??e;return Array.from(t.querySelectorAll('button[aria-haspopup="menu"]'))}function za(e){if(e==null)return!1;let t=e.getAttribute("role");return t==="menu"||t==="group"}function $a(e){return e.getAttribute("role")==="group"}function ql(e,t){let n=e.getAttribute("aria-controls");if(n===null||n.length===0)return;let r=t.getElementById(n);return za(r)?r:void 0}function Va(e=document){let t=_l(e);if(t===void 0)return;for(let r of Fl(t)){let o=ql(r,e);if(o!==void 0)return o}let n=ja(t)??t;for(let r of Array.from(n.querySelectorAll('[role="menu"], [role="group"]')))if(r.previousElementSibling?.matches('button[aria-haspopup="menu"]')&&za(r)&&!(r.getAttribute("role")==="group"&&r.querySelector('[role="menuitemradio"], section[role="group"]')===null))return r}function Ya(e=document){let t=_l(e);if(t===void 0)return;let n=ja(t),r=Fl(t),o=r[0];if(o!==void 0){for(let i of r)if(ql(i,e)!==void 0)return i;for(let i of r)if(za(i.nextElementSibling))return i;return n===void 0?r.at(-1):o}}function Kl(){return Va()}function Bl(){return Ya()}var Rh=()=>{(0,Wl.flushSync)(()=>{window.dispatchEvent(new Event("resize"))})};function Gl(e){let{menuOf:t,triggerOf:n,t:r,refreshed:o,sliderEnabled:i,directory:a}=e,s,d,l,c,f,h,p,m,b=()=>{m?.removeAttribute("data-bre-provider"),m=void 0},g=()=>{let w=n();m!==void 0&&m!==w&&b();let k=h?.store.getSnapshot(),R=k?.current;if(w===void 0||R===null||R===void 0){w===m&&b();return}let I=k?.groups.find(W=>W.id===R.provider),D=I===void 0?R.provider:Wt(I);if(D.trim()===""){w===m&&b();return}w.dataset.breProvider=D,m=w},y=()=>{let w=a();w!==h&&(p?.(),p=void 0,h=w,w!==void 0&&(p=w.store.subscribe(g))),g()},v=()=>{Ne(l),l=void 0},x=new Map,H=()=>{for(let[k,R]of x)k.style.display=R;x.clear();let w=t();w!==void 0&&w.getAttribute("tabindex")==="-1"&&w.removeAttribute("tabindex")},q=w=>w.getAttribute("aria-hidden")!=="true"||w.childElementCount>0?!1:(w.textContent??"").trim()==="",ne=(w,k)=>{for(let D of Array.from(x.keys()))(!D.isConnected||D.parentElement!==w)&&x.delete(D);let R=[];for(let D of Array.from(w.children))D!==k&&(q(D)||R.push(D));let I=document.activeElement;I!==null&&I!==k&&!k.contains(I)&&R.some(D=>D.contains(I))&&(w.tabIndex=-1,w.focus({preventScroll:!0}));for(let D of R)x.has(D)||x.set(D,D.style.display),D.style.display!=="none"&&(D.style.display="none")},K=w=>{let k=w.querySelector('section[role="group"]'),R=k?.parentElement,I=R!=null&&R.parentElement===w?R:k;if(l===void 0){let D=document.createElement("div");D.dataset.plugin=ke,D.dataset.breSearch="1",w.insertBefore(D,I),l=Xe(D,(0,Rr.createElement)(Be,{fallbackText:r("modelSearchFailed"),children:o(()=>(0,Rr.createElement)(Il,{menu:w,t:r}))}),{sync:!0});return}if(l.wrapper.parentElement!==w){w.insertBefore(l.wrapper,I);return}I!==null&&l.wrapper.nextSibling!==I&&w.insertBefore(l.wrapper,I)},S=w=>{if(!i()){Ne(s),s=void 0,d=void 0,w.classList.remove("bre-model-menu-host"),H();for(let W of Array.from(w.children))W.getAttribute("role")==="menuitem"&&(W.style.display="");return}let k=a();if(k===void 0)return;if(s!==void 0&&d!==k&&(Ne(s),s=void 0,d=void 0),s===void 0){d=k;let W=document.createElement("div");W.dataset.plugin=ke,W.dataset.breSlider="1",w.insertBefore(W,w.firstChild),s=Xe(W,(0,Rr.createElement)(Be,{fallbackText:r("renderFailed"),children:o(()=>(0,Rr.createElement)(Cl,{directory:k,configuredInputs:e.configuredInputs,t:r}))}),{sync:!0})}else(s.wrapper.parentElement!==w||w.firstChild!==s.wrapper)&&w.insertBefore(s.wrapper,w.firstChild);w.classList.add("bre-model-menu-host");let R=Array.from(w.children).filter(W=>W.getAttribute("role")==="menuitem"),I=s.wrapper;if($a(w)){I.style.display="",ne(w,I);return}if(H(),Array.from(w.querySelectorAll('[role="menuitemradio"]')).some(W=>!I.contains(W)))s.wrapper.contains(document.activeElement)&&(w.tabIndex=-1,w.focus({preventScroll:!0})),s.wrapper.style.display="none";else{s.wrapper.style.display="";for(let W of R)W.style.display="none"}};return{reconcile:()=>{y();let w=t();if(w===void 0){s!==void 0&&(i()?s.wrapper.remove():(Ne(s),s=void 0,d=void 0)),v(),c=void 0,f=void 0,H();return}let k=$a(w),R=k&&i(),I=!k&&Ol(w);I?K(w):v(),S(w),(I!==c||R!==f)&&(c=I,f=R,(I||R||i())&&Rh())},dispose:()=>{p?.(),p=void 0,h=void 0,b(),Ne(s),s=void 0,d=void 0,v(),H(),c=void 0,f=void 0}}}var Ch=350;function Ul(e){let t,n,r=0,o=()=>{if(t!==void 0)return Promise.resolve();let s=r;return n??(n=pe(e.api).then(d=>{if(d.namespace===void 0){n=void 0;return}let l=new Map;for(let[c,f]of Object.entries(Ke(d.namespace))){let h=Array.isArray(f.models)?f.models:[];for(let p of h){if(typeof p!="object"||p===null||Array.isArray(p))continue;let m=p.id,b=p[Mn];typeof m=="string"&&typeof b=="string"&&b.length>0&&l.set(`${c}/${m}`,b)}}s===r?t=l:n=void 0}).catch(()=>{s===r&&(n=void 0)})),n};return{of:async(s,d)=>{if(t===void 0){let l=o();await new Promise(c=>{let f=!1,h=()=>{f||(f=!0,c())},p=setTimeout(h,Ch);l.then(()=>{clearTimeout(p),h()},()=>{clearTimeout(p),h()})})}return t?.get(`${s}/${d}`)},invalidate:()=>{r+=1,t=void 0,n=void 0}}}function Hh(e){let t=e.input;return Array.isArray(t)&&t.length>0?!0:e[wt]===!0||e[at]===!0}function Ja(e,t=()=>!0,n={},r=0){let o=n.efforts!==!1,i=n.modalities!==!1;if(!X(e))return;let a={};for(let s of Object.keys(e)){if(!t(s))continue;let d=e[s],l=X(d)&&Array.isArray(d.models)?d.models:void 0;if(l===void 0||l.length===0)continue;let c=l,f=[],h=!1;for(let p of c){if(!X(p)){f.push(p);continue}let m=p,b=m.reasoningEfforts!==void 0||m[it]===!0,g=Hh(m);if((b||!o)&&(g||!i)){let K=Nh(m,e,s);K!==void 0?(h=!0,f.push(K)):f.push(m);continue}let y=typeof m.id=="string"?m.id:"";if(y.length===0){f.push(m);continue}let v=tn(e,s),x=typeof m.name=="string"?m.name:void 0,H=xt(y,{...v,displayName:x??v.displayName});if(H.efforts===void 0){f.push(m);continue}let q={...m},ne=!1;if(!b&&o&&H.confidence!=="low"&&(ne=!0,q.reasoningEfforts=H.efforts,q[Sn]=r,H.compat!==void 0)){let K=X(m.compat)?m.compat:{};q.compat={...K,...H.compat}}if(!g&&i&&(H.imageGen===!0?(ne=!0,q[at]=!0):H.input!==void 0&&(ne=!0,q.input=[...H.input])),!ne){f.push(m);continue}h=!0,f.push(q)}h&&(a[s]={models:f})}return Object.keys(a).length===0?void 0:{providers:a}}function Xa(e){if(!X(e))return;let t={};for(let[n,r]of Object.entries(e)){if(!X(r))continue;let o=typeof r.api=="string"?r.api:"";if(o.length===0)continue;let i={},a=X(r.compat)?Ha(r.compat,o):void 0;a!==void 0&&(i.compat=a);let s=Array.isArray(r.models)?r.models:void 0;if(s!==void 0&&s.length>0){let d=[],l=!1;for(let c of s){if(!X(c)||!X(c.compat)){d.push(c);continue}let f=Ha(c.compat,o);if(f===void 0){d.push(c);continue}l=!0,d.push({...c,compat:f})}l&&(i.models=d)}Object.keys(i).length>0&&(t[n]=i)}return Object.keys(t).length===0?void 0:{providers:t}}function Nh(e,t,n){if(!X(e.reasoningEfforts)||e[it]===!0)return;let r=e.compat,o=X(r)?{...r}:{};if(o.supportsDeveloperRole===void 0&&Na(tn(t,n)))return{...e,compat:{...o,supportsDeveloperRole:!1}}}function jl(e){let t,n=0,r=()=>{if(t!==void 0)return t;let i=(async()=>{try{let a=await fetch(Od,{method:"GET"});if(!a.ok)return;let s=await a.json();return s?.ok!==!0?void 0:{autofill:s.data?.autofill!==!1,modalityAutofill:s.data?.modalityAutofill!==!1}}catch{return}})().then(a=>(a===void 0&&t===i&&(t=void 0),a??{autofill:!0,modalityAutofill:!0}));return t=i,i},o=async i=>{let a=n;try{let s=await r();if(a!==n||!s.autofill)return;let d=i??await pe(e.api),l=d.namespace;if(a!==n||l===void 0||d.writable!==!0)return;let c=rn(l);if(c===void 0||Ja(c,()=>!0,{modalities:s.modalityAutofill},l.revision)===void 0)return;let h=d.source==="scope"?await pe(e.api,{fresh:!0}):d,p=h.namespace;if(a!==n||p===void 0||h.writable!==!0)return;let m=rn(p);if(m===void 0)return;let b=Ja(m,()=>!0,{modalities:s.modalityAutofill},p.revision);if(b===void 0)return;let g=b.providers,y=Object.entries(g).map(([x,H])=>({op:"set",path:["providers",x,"models"],value:H.models})),v=await e.api.settings.mutate(De,y,p.revision);v.ok||console.error(`[bre] idle autofill refused: ${v.error.message}`)}catch(s){console.error(`[bre] idle autofill failed: ${s instanceof Error?s.message:String(s)}`)}};return{run:()=>{o()},invalidate:()=>{n+=1,t=void 0}}}function zl(e){let t=async n=>{let r=n??await pe(e.api),o=r.namespace;if(o===void 0||r.writable!==!0)return;let i=rn(o);if(i===void 0||Xa(i)===void 0)return;let a=r.source==="scope"?await pe(e.api,{fresh:!0}):r,s=a.namespace;if(s===void 0||a.writable!==!0)return;let d=rn(s);if(d===void 0)return;let l=Xa(d);if(l===void 0)return;let c=l.providers,f=[];for(let[p,m]of Object.entries(c))for(let b of["compat","models"])m[b]!==void 0&&f.push({op:"set",path:["providers",p,b],value:m[b]});if(f.length===0)return;let h=await e.api.settings.mutate(De,f,s.revision);h.ok||console.error(`[bre] compat cleanup refused: ${h.error.message}`)};return{run:n=>{t(n).catch(r=>{console.error(`[bre] compat cleanup failed: ${r instanceof Error?r.message:String(r)}`)})}}}var gd=require("react"),ym=require("react-dom"),vm=require("react-dom/client");var ye=require("react");var Gt=gl;function an(e){let t={};for(let n of Gt){if(e===void 0){t[n]={on:!1,wire:""};continue}if(e===!1){t[n]=n==="off"?{on:!0,wire:""}:{on:!1,wire:""};continue}let r=e[n];t[n]={on:r!==void 0,wire:r===null?"":typeof r=="string"?r:""}}return t}function Fn(e){let t=!1,n=!1,r={};for(let o of Gt){let i=e[o];if(!i.on)continue;if(o==="off"){t=!0;let s=i.wire.trim();r.off=s.length===0?null:s;continue}n=!0;let a=i.wire.trim();r[o]=a.length===0?o:a}return n?r:t?!1:void 0}function Cr(e,t){if(e===t)return!0;if(e===!1||e===void 0||t===!1||t===void 0)return!1;let n=Gt.filter(o=>e[o]!==void 0),r=Gt.filter(o=>t[o]!==void 0);return n.length!==r.length?!1:n.every(o=>e[o]===t[o])}function $l(e,t){if(!(e===void 0||e===!1)&&!("off"in e)){if(t==="zai"||t==="deepseek")return"thinking-disabled";if(t==="qwen")return"enable-thinking-false"}}var Qa="bre:auto-effort",Vl=Promise.resolve();function Yl(e){Vl=Vl.then(e,e).then(()=>{},()=>{})}function Jl(e,t=document){t.dispatchEvent(new CustomEvent(Qa,{detail:{route:e}}))}function Xl(e,t=document){let n=r=>{let o=r.detail;typeof o?.route!="string"||o.route.length===0||e(o.route)};return t.addEventListener(Qa,n),()=>{t.removeEventListener(Qa,n)}}var G=require("react/jsx-runtime"),Oh=["M3.4 4.2h9.2","M8 4.2v8.2","M5.9 12.4h4.2"],Ih=["M4.4 3.4h7.2a1.9 1.9 0 0 1 1.9 1.9v5.4a1.9 1.9 0 0 1-1.9 1.9H4.4a1.9 1.9 0 0 1-1.9-1.9V5.3a1.9 1.9 0 0 1 1.9-1.9Z","M6.2 7.2a.9.9 0 1 0 0-1.8.9.9 0 0 0 0 1.8Z","M2.9 11.2 6.1 8.4l2.1 1.9 1.8-1.5 2.7 2.4"],Ph=["M9.4 12.7H3.6a1.7 1.7 0 0 1-1.7-1.7V5.1a1.7 1.7 0 0 1 1.7-1.7h4.2","M2.6 10.6 5.3 8.5l1.8 1.5 1.6-1.3 2.3 2","M12.4 2.2l.75 2.05L15.2 5l-2.05.75L12.4 7.8l-.75-2.05L9.6 5l2.05-.75Z"],Dh=["M8 3.2 13.6 12.8H2.4L8 3.2Z","M8 6.9v2.5","M8 11.3h.01"],_h=["M8 2.6 9.1 6.4 12.9 7.5 9.1 8.6 8 12.4 6.9 8.6 3.1 7.5 6.9 6.4Z","M12.3 2.4v1.9M11.35 3.35h1.9"],Fh=["M4.5 6.5 8 10 11.5 6.5"],qh=["M6.5 4.5 10 8 6.5 11.5"];function qn({paths:e}){return(0,G.jsx)("svg",{viewBox:"0 0 16 16",width:12,height:12,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:e.map(t=>(0,G.jsx)("path",{d:t},t))})}function Rt(e,t){return t===!0?{declared:!1,image:!1,imageGen:!0}:e===void 0||e.length===0?{declared:!1,image:!1,imageGen:!1}:{declared:!0,image:e.includes("image"),imageGen:!1}}function Po(e){return e.imageGen?{input:null,imageGen:!0}:e.declared?{input:e.image?["text","image"]:["text"],imageGen:!1}:{input:null,imageGen:!1}}function Io(e,t,n){return e.imageGen!==(n===!0)?!1:e.imageGen?!0:e.declared?t===void 0?!1:e.image?t.includes("image"):!t.includes("image"):t===void 0}function Za(e,t,n){let r=e?t:!1;return e&&r===void 0&&n===void 0?"keep":r}function Do(e){let t=e.appliedCompat;return e.initialCompat?.supportsThinkingTokenBudget===!0&&e.initialCompat?.thinkingTokenBudgetField===void 0&&t?.thinkingTokenBudgetField===void 0&&(e.routeApi??"").toLowerCase()==="openai-completions"&&(t={...t??{},thinkingTokenBudgetField:"thinking_token_budget"}),{efforts:e.efforts,...t===void 0?{}:{compat:t},...e.input===void 0?{}:{input:e.input},...e.imageGen===void 0?{}:{imageGen:e.imageGen},...e.defaultEffort===void 0?{}:{defaultEffort:e.defaultEffort}}}function _o({route:e,routeApi:t,routeBaseURL:n,modelId:r,modelName:o,efforts:i,effortsUnset:a=!1,input:s,imageGen:d,compat:l,defaultEffort:c,index:f,staged:h=!1,officialInputTypes:p=!1,api:m,readOnly:b,t:g}){let[y,v]=(0,ye.useState)(()=>an(i)),[x,H]=(0,ye.useState)(()=>Rt(s,d)),[q,ne]=(0,ye.useState)(()=>i!==!1),[K,S]=(0,ye.useState)(()=>c??""),[C,M]=(0,ye.useState)(!1),[w,k]=(0,ye.useState)(void 0),[R,I]=(0,ye.useState)(()=>Gt.some(P=>y[P].on&&y[P].wire.trim()!==(P==="off"?"":P))),D=(0,ye.useRef)(void 0),W=(0,ye.useRef)(void 0);W.current===void 0&&(W.current=m.readCapacities?.()??{});let[N,V]=(0,ye.useState)(()=>ht(W.current?.contextWindow)),[ie,re]=(0,ye.useState)(()=>ht(W.current?.maxTokens)),[oe,ae]=(0,ye.useState)(void 0),de=(0,ye.useRef)(!1),he=(0,ye.useRef)(i),te=(0,ye.useRef)(s),ue=(0,ye.useRef)(d),Te=(0,ye.useRef)(c),Le=(0,ye.useRef)(void 0),He=(0,ye.useRef)(i);He.current=i;let Y=(0,ye.useRef)(a);Y.current=a,(0,ye.useEffect)(()=>Xl(P=>{if(P!==e||He.current!==void 0||Y.current)return;let ce=Le.current;ce!==void 0&&Yl(ce)}),[e]),(0,ye.useEffect)(()=>{Cr(he.current,i)||(he.current=i,de.current||(v(an(i)),ne(i!==!1))),(te.current!==s||ue.current!==d)&&(te.current=s,ue.current=d,de.current||H(Rt(s,d))),Te.current!==c&&(Te.current=c,de.current||S(c??""))},[i,s,d,c]);let B=Gt.filter(P=>y[P].on),J=K===(c??"")?void 0:K===""?null:K,Z=q?Fn(y):!1,fe=!Cr(Z,i)||!Io(x,s,d)||J!==void 0,u=(0,ye.useRef)(void 0),T=()=>{de.current=!0},_=(P,ce,Re,Fe=q)=>{let L=Za(Fe,Fn(P),i),ge=!Io(ce,s,d)?Po(ce):void 0,ze=Re===(c??"")?void 0:Re===""?null:Re,$e=Do({efforts:L,input:ge?.input,imageGen:ge?.imageGen,defaultEffort:ze,appliedCompat:D.current,routeApi:t,initialCompat:l}),pt=JSON.stringify($e);u.current!==pt&&(u.current=pt,m.commit(e,r,$e))},F=(P,ce)=>{T();let Re=!ce&&K===P?"":K;Re!==K&&S(Re);let Fe={...y,[P]:{...y[P],on:ce}};ce&&P!=="off"&&Fe[P].wire.trim().length===0&&(Fe[P]={...Fe[P],wire:P}),v(Fe),_(Fe,x,Re),k(void 0)},Q=P=>{T(),ne(P);let ce=P?K:"";ce!==K&&S(ce),_(y,x,ce,P),k(void 0)},ve=(P,ce)=>{T();let Re={...y,[P]:{...y[P],wire:ce}};v(Re),_(Re,x,K),k(void 0)},we=P=>{T();let ce={declared:!0,image:P,imageGen:!1};H(ce),_(y,ce,K),k(void 0)},A=()=>{T();let P={declared:!1,image:!1,imageGen:!1};H(P),_(y,P,K),k(void 0)},z=P=>{T();let ce=P?{declared:!1,image:!1,imageGen:!0}:{declared:!1,image:!1,imageGen:!1};H(ce),_(y,ce,K),k(void 0)},le=P=>{T(),S(P),_(y,x,P),k(void 0)},xe=(P,ce)=>{let Re=ce.slice(0,20),Fe=P==="context"?Re:N,L=P==="output"?Re:ie;ae(P),P==="context"?V(Re):re(Re),m.setCapacities?.({contextWindow:kt(Fe),maxTokens:kt(L)})},Se=P=>{P==="context"?V(ce=>ht(kt(ce))):re(ce=>ht(kt(ce))),ae(void 0)},me=P=>{T();let ce=P.efforts!==!1;ne(ce);let Re=an(P.efforts);v(Re);let Fe=P.imageGen===!0?Rt(void 0,!0):P.input===void 0?x:Rt(P.input);Fe!==x&&H(Fe);let L=K===""&&P.defaultEffort!==void 0?P.defaultEffort:K;if(L!==K&&S(L),D.current=P.compat,P.contextWindow!==void 0||P.maxTokens!==void 0){m.fillCapacities?.(P.contextWindow,P.maxTokens);let j=m.readCapacities?.();V(ht(j?.contextWindow)),re(ht(j?.maxTokens))}k(void 0),_(Re,Fe,L,ce)},Pe=async()=>{if(!(b||C)){M(!0),k(void 0);try{let P=h?await m.suggest(e,r,o,{...t===void 0?{}:{api:t},...n===void 0?{}:{baseURL:n}}):await m.suggest(e,r,o);if(!P.ok){k({kind:"error",text:P.error==="no-suggestion"?g("noSuggestion"):P.error});return}me(P.suggestion)}catch(P){k({kind:"error",text:g("writeError",{message:String(P)})})}finally{M(!1)}}};(0,ye.useEffect)(()=>{Le.current=Pe});let je=()=>{de.current=!1,m.withdraw(e,r),v(an(i)),ne(i!==!1),H(Rt(s,d)),S(c??""),D.current=void 0;let P=W.current??{};V(ht(P.contextWindow)),re(ht(P.maxTokens)),ae(void 0),m.setCapacities?.({contextWindow:P.contextWindow,maxTokens:P.maxTokens}),k(void 0),u.current=void 0},ft=(0,ye.useMemo)(()=>xt(r,{...t===void 0?{}:{api:t},...n===void 0?{}:{baseURL:n}}).compat?.thinkingFormat,[r,t,n]),Qt=D.current?.thinkingFormat??ft,En=$l(i,Qt),Ae=b||C,co=q?B.length===0?g("stateUndeclared"):g("stateDeclared",{count:B.length,default:g(K===""?"defaultEffortUnset":"level_"+K)}):g("thinkingModeOff"),ea=K!==""&&!B.includes(K)?[...B,K]:B,Tn=kt(N),Zt=kt(ie),hr=Tn!==void 0&&Zt!==void 0&&Zt>Tn,uo=(0,G.jsxs)(G.Fragment,{children:[hr?(0,G.jsxs)("p",{className:"bre-effort-note bre-warn",children:[(0,G.jsx)(qn,{paths:Dh}),g("capacityRule")]}):null,(0,G.jsxs)("div",{className:"bre-effort-cols",children:[(0,G.jsxs)("div",{className:"bre-effort-sec",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:g("contextWindowLabel")}),(0,G.jsxs)("span",{className:"bre-cap-box",children:[(0,G.jsx)("input",{type:"text",inputMode:"text",className:"bre-cap-input",value:oe==="context"?N:ht(Tn),disabled:Ae,placeholder:g("capacityBlank"),"aria-label":g("contextWindowLabel")+" "+String(f+1),onFocus:()=>{ae("context")},onBlur:()=>{Se("context")},onChange:P=>{xe("context",P.target.value)}}),(0,G.jsx)("span",{className:"bre-cap-unit",children:g("tokensUnit")})]}),(0,G.jsx)("p",{className:"bre-effort-note",children:g("capacityInherit")})]}),(0,G.jsxs)("div",{className:"bre-effort-sec",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:g("maxTokensLabel")}),(0,G.jsxs)("span",{className:"bre-cap-box",children:[(0,G.jsx)("input",{type:"text",inputMode:"text",className:"bre-cap-input",value:oe==="output"?ie:ht(Zt),disabled:Ae,placeholder:g("capacityBlank"),"aria-label":g("maxTokensLabel")+" "+String(f+1),onFocus:()=>{ae("output")},onBlur:()=>{Se("output")},onChange:P=>{xe("output",P.target.value)}}),(0,G.jsx)("span",{className:"bre-cap-unit",children:g("tokensUnit")})]}),(0,G.jsx)("p",{className:"bre-effort-note",children:g("capacityUnitsHint")})]})]})]});return(0,G.jsxs)("div",{className:"bre-effort-editor","data-plugin":ke,children:[(0,G.jsxs)("div",{className:"bre-effort-modality",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:g("inputModality")}),(0,G.jsxs)("div",{className:"bre-pillrow",role:"group","aria-label":g("inputModality"),children:[(0,G.jsxs)("button",{type:"button",className:x.declared?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:Ae,"aria-pressed":x.declared,"aria-label":g("modalityText")+" "+String(f+1),title:g("modalityText"),onClick:()=>{x.declared?A():we(!1)},children:[(0,G.jsx)(qn,{paths:Oh}),g("modalityText")]}),(0,G.jsxs)("button",{type:"button",className:x.declared&&x.image?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:Ae,"aria-pressed":x.declared&&x.image,"aria-label":g("modalityImage")+" "+String(f+1),title:g("modalityImage"),onClick:()=>{we(!(x.declared&&x.image))},children:[(0,G.jsx)(qn,{paths:Ih}),g("modalityImage")]}),(0,G.jsxs)("button",{type:"button",className:x.imageGen?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:Ae,"aria-pressed":x.imageGen,"aria-label":g("modalityImageGen")+" "+String(f+1),title:g("modalityImageGen"),onClick:()=>{z(!x.imageGen)},children:[(0,G.jsx)(qn,{paths:Ph}),g("modalityImageGen")]})]}),(0,G.jsx)("p",{className:"bre-effort-note",children:x.imageGen?g("modalityImageGenHint"):x.declared?g("modalityDeclared"):g("modalityInherit")})]}),(0,G.jsxs)("div",{className:"bre-effort-top",children:[(0,G.jsxs)("label",{className:"bre-thinking-switch",children:[(0,G.jsx)("input",{type:"checkbox",checked:q,disabled:Ae,"aria-label":g("thinkingMode")+" "+String(f+1),onChange:P=>{Q(P.target.checked)}}),(0,G.jsx)("span",{className:"bre-effort-switch-track","aria-hidden":"true"}),(0,G.jsx)("span",{className:"bre-effort-title",children:g("thinkingMode")})]}),(0,G.jsx)("span",{className:"bre-effort-state",children:co})]}),q?(0,G.jsxs)(G.Fragment,{children:[i===!1?(0,G.jsx)("p",{className:"bre-effort-note bre-effort-note--top",children:g("reasoningDisabled")}):null,En===void 0?null:(0,G.jsx)("p",{className:"bre-effort-note bre-effort-note--top",children:g(En==="thinking-disabled"?"defaultRiskDisabled":"defaultRiskQwen")})]}):null,q?(0,G.jsxs)("div",{className:"bre-effort-card",children:[(0,G.jsxs)("div",{className:"bre-effort-sec",children:[(0,G.jsxs)("div",{className:"bre-effort-labelrow",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:g("levelsLabel")}),(0,G.jsx)("span",{className:"bre-effort-grow"}),(0,G.jsxs)("button",{type:"button",className:"bre-effort-adapt",disabled:Ae,onClick:()=>{Pe()},children:[(0,G.jsx)(qn,{paths:_h}),g("autoAdapt")]})]}),(0,G.jsx)("div",{className:"bre-pillrow",role:"group","aria-label":g("levelsLabel"),children:Gt.map(P=>{let ce=y[P];return(0,G.jsx)("button",{type:"button",className:ce.on?"bre-lvl is-on":"bre-lvl",disabled:Ae,"aria-pressed":ce.on,"aria-label":g("level_"+P)+" "+String(f+1),title:g("level_"+P),onClick:()=>{F(P,!ce.on)},children:g("level_"+P)},P)})}),(0,G.jsx)("p",{className:"bre-effort-hint",children:g("levelsHint")}),B.length===0?null:(0,G.jsxs)("button",{type:"button",className:"bre-effort-wiretoggle",disabled:Ae,"aria-expanded":R,onClick:()=>{I(!R)},children:[(0,G.jsx)(qn,{paths:R?Fh:qh}),g(R?"wireHide":"wireShow")]}),B.length===0||!R?null:(0,G.jsxs)("div",{className:"bre-wire",children:[(0,G.jsx)("div",{className:"bre-wire-grid",children:B.map(P=>(0,G.jsxs)(ye.Fragment,{children:[(0,G.jsx)("span",{className:"bre-wire-name",children:g("level_"+P)}),(0,G.jsx)("input",{type:"text",className:"bre-effort-wire",value:y[P].wire,disabled:Ae,placeholder:g("wirePlaceholder"),"aria-label":g("level_"+P)+" "+g("wireValue"),onChange:ce=>{ve(P,ce.target.value)}})]},P))}),(0,G.jsx)("p",{className:"bre-effort-note",children:g("wireHint")})]})]}),B.length===0?null:(0,G.jsx)("div",{className:"bre-effort-cols",children:(0,G.jsxs)("div",{className:"bre-effort-sec",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:g("defaultEffortLabel")}),(0,G.jsxs)("select",{className:"bre-effort-select",value:K,disabled:Ae,"aria-label":g("defaultEffortLabel"),onChange:P=>{le(P.target.value)},children:[(0,G.jsx)("option",{value:"",children:g("followMemory")}),ea.map(P=>(0,G.jsx)("option",{value:P,children:g("level_"+P)},P))]}),(0,G.jsx)("p",{className:"bre-effort-note",children:g("defaultEffortHint")})]})}),h?(0,G.jsx)("p",{className:"bre-effort-note",children:g("stagedHint")}):null,Fn(y)===void 0&&i!==void 0?(0,G.jsx)("p",{className:"bre-effort-note",children:g("bareHint")}):null,(0,G.jsx)("span",{className:"bre-effort-sep"}),uo,w===void 0?null:(0,G.jsx)("p",{className:"bre-effort-message bre-"+w.kind,role:w.kind==="error"?"alert":"status",children:w.text}),(0,G.jsx)("div",{className:"bre-effort-actions",children:(0,G.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:Ae||!fe,onClick:je,children:g("reset")})})]}):(0,G.jsxs)("div",{className:"bre-effort-card bre-effort-card--capacity",children:[uo,w===void 0?null:(0,G.jsx)("p",{className:"bre-effort-message bre-"+w.kind,role:w.kind==="error"?"alert":"status",children:w.text})]})]})}function be(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function yt(e,t){e!==void 0&&e.hidden!==t&&(e.hidden=t)}function We(e,t,n){e.classList.contains(t)!==n&&(n?e.classList.add(t):e.classList.remove(t))}function Hr(e,t){e!==void 0&&e.textContent!==t&&(e.textContent=t)}var Ut="data-bre-auto-effort",es='[class*="modelCatalog"]',Kh='[class*="modelListHead"]',Bh='button[class*="linkButton"]',Wh="bre-auto-effort",Gh="bre-auto-effort-note",Uh="data-bre-auto-effort-phase",Zl="bre-auto-effort-note-text",ec="bre-auto-effort-note-detail",jh=3e3;function zh(e){return e.blocked==="busy"?null:e.failed!==void 0?{phase:"failed",count:0,missed:0,detail:e.failed}:e.blocked!==void 0?{phase:"blocked",count:0,missed:0,detail:""}:e.held>0?{phase:"done",count:e.held,missed:e.unsuggested,detail:""}:e.unsuggested>0?{phase:"unsuggested",count:0,missed:e.unsuggested,detail:""}:{phase:"empty",count:0,missed:0,detail:""}}function ts(e){return Array.from(e.querySelectorAll(es)).filter(t=>(t.parentElement?.closest(es)??null)===null)}function Fo(e,t,n){let r=new Map;for(let s of t)s.route.length!==0&&s.catalogue.isConnected&&r.set(s.catalogue,s.route);let o=n.t("autoAdaptAll");for(let[s,d]of r){let l=s.querySelector(Kh)??s,c=l.querySelector(`[${Ut}]`)??Vh();nc.set(c,n);let f=$h(l);f!==null?f.nextElementSibling!==c&&f.after(c):l.lastElementChild!==c&&l.append(c),Qh(c,d,o)}let i=new Set,a=new Set(r.values());for(let s of Array.from(e.querySelectorAll(`[${Ut}]`))){let d=s.closest(es),l=s.getAttribute(Ut)??"";if(d===null||!r.has(d)||i.has(d)){s.remove(),l.length>0&&!a.has(l)&&ns(l);continue}i.add(d)}}function ns(e){let t=sn.get(e);t!==void 0&&(t.timer!==null&&clearTimeout(t.timer),t.note.remove(),sn.delete(e))}function tc(){for(let e of Array.from(document.querySelectorAll(`[${Ut}]`)))e.remove();for(let e of sn.values())e.timer!==null&&clearTimeout(e.timer),e.note.remove();sn.clear()}function $h(e){let t=Array.from(e.querySelectorAll(Bh));return t.length===0?null:t[t.length-1]}function Vh(){let e=document.createElement("button");return e.className=Wh,e.setAttribute("type","button"),e.setAttribute(Ut,""),e.addEventListener("click",()=>{let t=e.getAttribute(Ut)??"";if(t.length===0)return;let n=nc.get(e);n!==void 0&&(Jl(t),Yh(t,n))}),e}async function Yh(e,t){if(t.onRequest===void 0)return;Ql(e,{phase:"working",count:0,missed:0,detail:""},t,0);let n;try{n=await t.onRequest(e)}catch(o){n={held:0,unsuggested:0,failed:String(o)}}if(n===void 0){ns(e);return}let r=zh(n);r!==null&&Ql(e,r,t,jh)}function Ql(e,t,n,r){let o=sn.get(e);o!==void 0&&!o.note.isConnected&&(o.timer!==null&&clearTimeout(o.timer),sn.delete(e),o=void 0),o!==void 0&&o.timer!==null&&clearTimeout(o.timer);let i=o?.note??Jh();i.setAttribute(Uh,t.phase);let a=i.querySelector(`.${Zl}`),s=i.querySelector(`.${ec}`),d=Xh(t,n);a.textContent!==d.text&&(a.textContent=d.text),s.textContent!==d.detail&&(s.textContent=d.detail),yt(s,d.detail.length===0),o===void 0&&document.body.append(i);let l=r>0?setTimeout(()=>{ns(e)},r):null;i.style.setProperty("--bre-note-hold",`${r}ms`),sn.set(e,{note:i,timer:l})}function Jh(){let e=document.createElement("div");return e.className=Gh,e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.innerHTML=`<span class="${Zl}"></span><span class="${ec}"></span>`,e}var nc=new WeakMap,sn=new Map;function Xh(e,t){switch(e.phase){case"working":return{text:t.t("autoAdaptWorking"),detail:""};case"done":return{text:t.t("autoAdaptDone",{count:e.count}),detail:e.missed>0?`${t.t("autoAdaptDoneHint",{count:e.count})} ${t.t("autoAdaptUnsuggestedHint")}`:t.t("autoAdaptDoneHint",{count:e.count})};case"empty":return{text:t.t("autoAdaptEmpty"),detail:t.t("autoAdaptEmptyHint")};case"unsuggested":return{text:t.t("autoAdaptUnsuggested"),detail:t.t("autoAdaptUnsuggestedHint")};case"blocked":return{text:t.t("autoAdaptBlocked"),detail:t.t("autoAdaptBlockedHint")};case"failed":return{text:t.t("autoAdaptFailed",{message:e.detail}),detail:e.detail}}}function Qh(e,t,n){e.getAttribute(Ut)!==t&&e.setAttribute(Ut,t),e.textContent!==n&&(e.textContent=n),e.getAttribute("title")!==null&&e.removeAttribute("title")}var Nr="data-bre-drag-handle",rs="data-bre-row-head",os="data-bre-drop-side",qo="bre-row-dragging",Ko="bre-row-drop-target",dc="bre-drag-ghost",lc="bre-drop-line",rc="http://www.w3.org/2000/svg",oc=8,ic=28,ac=12,Zh="transform 180ms cubic-bezier(0.2, 0.7, 0.3, 1)",eb='button, a, input, textarea, select, [contenteditable], [role="button"], [role="switch"], [role="checkbox"], [role="textbox"], [role="combobox"]';function Bo(){return{sources:new WeakSet,lists:new WeakSet,line:void 0,sighted:new WeakMap,drag:void 0}}function Ye(e){return Array.from(e.children).filter(t=>t instanceof HTMLElement)}function tb(e,t){let n=e.style.order;if(n==="")return t;let r=Number.parseInt(n,10);return Number.isNaN(r)?t:r}function dn(e){return Ye(e).map((t,n)=>({row:t,key:tb(t,n),index:n})).sort((t,n)=>t.key-n.key||t.index-n.index).map(t=>t.row)}function cc(e,t){let n=e.filter(a=>t.includes(a)),r=n.map(a=>e.indexOf(a)),o=t.filter(a=>n.includes(a)),i=new Map;e.forEach((a,s)=>i.set(a,s)),r.forEach((a,s)=>{let d=o[s];d!==void 0&&i.set(d,a)});for(let[a,s]of i){let d=String(s);a.style.order!==d&&(a.style.order=d)}}function Wo(e,t){cc(dn(e),t)}function is(e,t){let n=Ye(e),r=n.map(o=>o.offsetTop);t(),n.forEach((o,i)=>{let a=r[i]-o.offsetTop;a!==0&&(o.style.transition="none",o.style.transform=`translateY(${a}px)`,o.offsetHeight,o.style.transition=Zh,o.style.transform="")})}function Or(e,t){return dn(e).map(n=>t(n)).filter(n=>n!==void 0)}function nb(e,t,n){let r=Or(e,t);if(n===void 0||!rb(e,n))return r;let o=new Map;return n.ids.forEach((i,a)=>{o.has(i)||o.set(i,a)}),r.map((i,a)=>({id:i,key:o.get(i)??n.ids.length+a})).sort((i,a)=>i.key-a.key).map(i=>i.id)}function rb(e,t){return t.rows.some(n=>!e.contains(n))}function ob(e,t){let n=[];for(let o of dn(e)){let i=t(o);i!==void 0&&n.push(i)}let r=[];for(let o of Ye(e))t(o)!==void 0&&r.push(o);return{ids:n,rows:r}}function uc(e,t,n){let r=new Map;for(let[s,d]of t.entries())r.has(d)||r.set(d,s);let o=Ye(e),a=[...o.filter(s=>n(s)!==void 0)].sort((s,d)=>{let l=r.get(n(s))??Number.MAX_SAFE_INTEGER,c=r.get(n(d))??Number.MAX_SAFE_INTEGER;return l-c});cc(o,a)}function Ir(e){for(let t of e)t.style.order="",t.style.transition="",t.style.transform=""}function fc(e,t,n,r){let i=e.filter(a=>a!==t).indexOf(n);return i<0?Math.max(0,e.indexOf(t)):r?i+1:i}function pc(e,t){let n,r=Number.POSITIVE_INFINITY;for(let o of e){let i=o.getBoundingClientRect(),a=t<i.top?i.top-t:t>i.bottom?t-i.bottom:0;a<r&&(r=a,n=o)}return n}function ib(e,t){let n=e.getBoundingClientRect();return n.height<=0?!0:t>n.top+n.height/2}function mc(e,t){let n=e.getBoundingClientRect();return t?n.bottom+oc/2-1:n.top-oc/2-1}function gc(){let e=document.createElementNS(rc,"svg");e.setAttribute("width","10"),e.setAttribute("height","14"),e.setAttribute("viewBox","0 0 10 14"),e.setAttribute("fill","none"),e.setAttribute("aria-hidden","true");let t=[[2.5,3],[7.5,3],[2.5,7],[7.5,7],[2.5,11],[7.5,11]];for(let[n,r]of t){let o=document.createElementNS(rc,"circle");o.setAttribute("cx",String(n)),o.setAttribute("cy",String(r)),o.setAttribute("r","1.2"),o.setAttribute("fill","currentColor"),e.appendChild(o)}return e}function hc(e,t){let n=document.createElement("div");n.className=dc,n.setAttribute("aria-hidden","true"),n.appendChild(gc());let r=document.createElement("span");r.className="bre-drag-ghost-name";let o=t??e.querySelector('[class*="rowName"]')?.textContent?.trim();return r.textContent=o===void 0?"":o,n.appendChild(r),n}function ab(e){return!(e instanceof Element)||e.closest(`[${Nr}]`)!==null?!1:e.closest(eb)!==null}function bc(e){return e.parentElement??void 0}function yc(e){for(let t of Ye(e))t.classList.remove(Ko),t.removeAttribute(os)}function Go(e){let t=e.parentElement;for(;t!==null;){if(xc(t))return t;t=t.parentElement}let n=document.scrollingElement;return n instanceof HTMLElement&&n.scrollHeight>n.clientHeight?n:void 0}function vc(e){let t=[],n=e.parentElement;for(;n!==null;)xc(n)&&t.push(n),n=n.parentElement;let r=document.scrollingElement;return r instanceof HTMLElement&&r.scrollHeight>r.clientHeight&&!t.includes(r)&&t.push(r),t}function as(e){let t=[],n=e.parentElement;for(;n!==null;)wc(n)&&t.push(n),n=n.parentElement;let r=document.scrollingElement;return r instanceof HTMLElement&&!t.includes(r)&&t.push(r),t}function wc(e){let t=e.style.overflowY,n=t.length>0?t:window.getComputedStyle(e).overflowY;return n==="auto"||n==="scroll"||n==="overlay"}function xc(e){return e.scrollHeight>e.clientHeight&&wc(e)}function kc(e,t){let n=e.getBoundingClientRect();return n.height<=0?0:t<n.top+ic?-ac:t>n.bottom-ic?ac:0}function Ec(e,t,n){if(t.scrollStep===n)return;if(t.scrollStep=n,n===0){t.frame!==void 0&&(window.cancelAnimationFrame(t.frame),t.frame=void 0);return}let r=t.scroller;if(r===void 0||t.frame!==void 0)return;let o=()=>{t.frame=void 0,!(e.drag!==t||t.scrollStep===0)&&(r.scrollTop+=t.scrollStep,t.frame=window.requestAnimationFrame(o))};t.frame=window.requestAnimationFrame(o)}function sb(e){let t=e.line;if(t!==void 0&&t.isConnected)return t;let n=document.createElement("div");return n.className=lc,n.setAttribute("aria-hidden","true"),document.body.appendChild(n),e.line=n,n}function db(e,t,n){let r=sb(e),o=t.getBoundingClientRect();r.style.top=`${mc(t,n)}px`,r.style.left=`${o.left}px`,r.style.width=`${o.width}px`,r.style.display="block",r.setAttribute(os,n?"after":"before")}function lb(e){e.line!==void 0&&(e.line.style.display="none")}function cb(e){let t=e.drag;e.drag=void 0,t!==void 0&&(Ec(e,t,0),lb(e),t.row.classList.remove(qo),yc(t.list),t.dropped||is(t.list,()=>{Wo(t.list,t.before)}))}function ub(e,t,n,r){if(ab(t.target)){t.preventDefault();return}let o=bc(e),i=n.idOf(e);if(o===void 0||i===void 0){t.preventDefault();return}let a={row:e,list:o,before:dn(o),scroller:Go(o),adapter:n,scrollStep:0,frame:void 0,dropped:!1};r.drag=a,e.classList.add(qo);let s=hc(e,n.labelOf(e));Number.isFinite(t.clientX)&&Number.isFinite(t.clientY)&&(s.style.left=`${t.clientX}px`,s.style.top=`${t.clientY}px`),document.body.appendChild(s);let d=t.dataTransfer;if(d!=null)try{d.effectAllowed="move",d.setData("text/plain",i),d.setDragImage(s,Math.round(s.offsetWidth/2),Math.round(s.offsetHeight/2))}catch{}window.setTimeout(()=>{s.remove()},0)}function fb(e,t,n){let r=n.drag;if(r===void 0||r.list!==e)return;let o=t.target,i=o instanceof Element?r.adapter.rowOf(o,e):void 0,a=dn(e),s=i!==void 0&&a.includes(i)?i:pc(a,t.clientY);if(s===void 0)return;t.preventDefault();let d=t.dataTransfer;d!=null&&(d.dropEffect="move");let l=ib(s,t.clientY),c=fc(a,r.row,s,l);c!==a.indexOf(r.row)&&is(e,()=>{Wo(e,ua(a,r.row,c))}),yc(e),s.classList.add(Ko),s.setAttribute(os,l?"after":"before"),db(n,s,l),Ec(n,r,r.scroller===void 0?0:kc(r.scroller,t.clientY))}function pb(e,t){t.lists.has(e)||(t.lists.add(e),e.addEventListener("dragover",n=>{fb(e,n,t)}),e.addEventListener("drop",n=>{let r=t.drag;r===void 0||r.list!==e||(n.preventDefault(),r.dropped=!0,r.adapter.commit(e))}))}function mb(e,t,n,r){r.sources.has(e)||(r.sources.add(e),n.seatDrags&&(e.setAttribute(rs,"1"),e.setAttribute("draggable","true")),e.addEventListener("dragstart",o=>{ub(t,o,n,r)}),e.addEventListener("dragend",()=>{cb(r)}))}function gb(e,t,n,r){e.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation()}),e.addEventListener("keydown",o=>{if(o.key!=="ArrowUp"&&o.key!=="ArrowDown")return;let i=bc(t);if(i===void 0)return;let a=dn(i),s=a.indexOf(t);if(s<0)return;let d=s+(o.key==="ArrowUp"?-1:1);d<0||d>=a.length||(o.preventDefault(),is(i,()=>{Wo(i,ua(a,t,d))}),n.commit(i),e.focus())})}function sc(e,t,n,r){let o=r.gripLabel(t,n),i=r.gripHint();e.getAttribute(Nr)!==n&&e.setAttribute(Nr,n),e.getAttribute("aria-label")!==o&&e.setAttribute("aria-label",o),e.getAttribute("title")!==i&&e.setAttribute("title",i)}function hb(e,t,n,r,o){let i=t.querySelector(`[${Nr}]`);if(i!==null){sc(i,e,n,r);return}r.decorate?.(e,t);let a=document.createElement("span");a.className="bre-drag-grip",a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.setAttribute("draggable","true"),a.appendChild(gc()),sc(a,e,n,r),gb(a,e,r,o),mb(r.seatDrags?t:a,e,r,o),t.insertBefore(a,t.firstChild)}function Uo(e,t,n,r){if(!e.isConnected)return;pb(t,r);for(let i of Ye(t)){let a=n.idOf(i);if(a===void 0)continue;let s=n.seatOf(i);s!==void 0&&hb(i,s,a,n,r)}if(r.drag!==void 0)return;let o=nb(t,n.idOf,r.sighted.get(t));uc(t,n.order(o),n.idOf),r.sighted.set(t,ob(t,n.idOf))}function jo(e){e.drag=void 0;for(let t of Array.from(document.querySelectorAll(`[${Nr}]`)))t.remove();for(let t of Array.from(document.querySelectorAll(`[${rs}]`)))t.removeAttribute(rs),t.removeAttribute("draggable");for(let t of Array.from(document.querySelectorAll(`.${qo}, .${Ko}`)))t.classList.remove(qo,Ko);for(let t of Array.from(document.querySelectorAll(`.${lc}`)))t.remove();for(let t of Array.from(document.querySelectorAll(`.${dc}`)))t.remove();e.line=void 0}var Tc=["openai","anthropic"];function zo(e){return e==="anthropic-messages"?"anthropic":"openai"}function Sc(e){return e==="openai-completions"||e==="anthropic-messages"||e==="openai-responses"}var bb=40;function Mc(e){if(typeof e!="string")return;let t="";for(let n of e){let r=n.codePointAt(0)??0;r<32||r===127||(t+=n)}if(t=t.trim(),t.length!==0)return t.slice(0,bb)}function Ct(e){return typeof e=="string"&&/^[\x21-\x7E]+$/.test(e)}var yb=12;function Lc(e){return e.length===0?"":e.length<yb?"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022":`${e.slice(0,4)}...${e.slice(-4)}`}var Ac="dsh-model-think-level:key-lists:v1";function Rc(){try{return globalThis.localStorage??void 0}catch{return}}function $o(){let e=Rc();if(e===void 0)return{};try{let t=e.getItem(Ac);if(t===null)return{};let n=JSON.parse(t);if(typeof n!="object"||n===null)return{};let r={};for(let[o,i]of Object.entries(n))vb(i)&&(r[o]=i);return r}catch{return{}}}function vb(e){if(typeof e!="object"||e===null)return!1;let t=e;if(typeof t.savedAt!="number"||!Number.isFinite(t.savedAt))return!1;let n=t.state;if(typeof n!="object"||n===null)return!1;let r=n;return r.ok===!0&&typeof r.route=="string"&&Array.isArray(r.entries)}function Cc(e){let t=Rc();if(t===void 0)return;let n=Object.entries(e).sort((r,o)=>o[1].savedAt-r[1].savedAt).slice(0,64);try{t.setItem(Ac,JSON.stringify(Object.fromEntries(n)))}catch{}}function Hc(e){let t=$o()[e];if(t===void 0||t.state.route!==e)return;let n=Date.now()-t.savedAt;if(!(n>=0)||n>2592e6){wb(e);return}return t.state}function ss(e,t){if(t.ok!==!0||t.route!==e)return;let n=$o();n[e]={savedAt:Date.now(),state:{...t,probing:void 0,addedRef:void 0}},Cc(n)}function wb(e){let t=$o();t[e]!==void 0&&(delete t[e],Cc(t))}function Nc(){return Object.entries($o()).map(([e,t])=>({route:e,savedAt:t.savedAt})).sort((e,t)=>t.savedAt-e.savedAt)}function Oc(e){for(let t of["error","message"]){let n=e[t];if(typeof n=="string"&&n.length>0)return n}}function Ic(e){if(!Array.isArray(e))return;let t=[];for(let n of e)typeof n=="string"&&n.length>0&&t.push(n);return t}function xb(e){if(!X(e))return;let t=e.ref;if(typeof t!="string"||t.length===0)return;let n=e.alias,r=e.configured,o=e.masked,i=Ic(e.models),a=e.protocol,s=e.auto,d=e.rest,l=X(d)&&typeof d.remainingMs=="number"?d.remainingMs:void 0,c=X(d)&&typeof d.failures=="number"?d.failures:void 0;return{ref:t,...typeof n=="string"&&n.length>0?{alias:n}:{},enabled:e.enabled!==!1,configured:typeof r=="boolean"?r:null,...typeof o=="string"&&o.length>0?{masked:o}:{},...i===void 0?{}:{models:i},...Sc(a)?{protocol:a}:{},...s===!0?{auto:!0}:{},...l!==void 0&&l>=0&&c!==void 0?{rest:{remainingMs:l,failures:c}}:{}}}function kb(e){let t=e.entries;if(!Array.isArray(t))return;let n=[];for(let l of t){let c=xb(l);c!==void 0&&n.push(c)}let r=e.addedRef,o=e.route,i=Ic(e.models),a=e.endpoints,s=X(a)&&typeof a.openai=="string"?a.openai:null,d=X(a)&&typeof a.anthropic=="string"?a.anthropic:null;return{ok:!0,route:typeof o=="string"?o:"",entries:n,...typeof r=="string"&&n.some(l=>l.ref===r)?{addedRef:r}:{},...i===void 0?{}:{models:i},...e.probing===!0?{probing:!0}:{},endpoints:{openai:s,anthropic:d}}}async function Eb(e){let t;try{t=await e.json()}catch{t=void 0}if(!X(t))return{ok:!1};if(t.ok===!0){let r=kb(t);if(r!==void 0)return r}let n=Oc(t);return n===void 0?{ok:!1}:{ok:!1,error:n}}async function Pc(e,t){let n=`${mo}?route=${encodeURIComponent(e)}`;try{let r=await fetch(n,t===void 0?{method:"GET",cache:"no-store",credentials:"same-origin"}:{method:"POST",cache:"no-store",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify(t)});return await Eb(r)}catch{return{ok:!1}}}var Pr=new Map,Tb=64,Sb=5e3;function ds(e){let t=Pr.get(e);if(t!==void 0)return t;if(Pr.size>=Tb){let r=Pr.keys().next().value;r!==void 0&&Pr.delete(r)}let n={state:Hc(e),updatedAt:0,revision:0};return Pr.set(e,n),n}function Mb(e){return ds(e).state}function Lb(e,t){let n=ds(e),r=Date.now()-n.updatedAt;if(t?.preferCache===!0&&n.state!==void 0&&r>=0&&r<Sb)return Promise.resolve(n.state);if(n.read!==void 0)return n.read;let o=n.revision,i=Pc(e).then(a=>n.revision!==o?n.state??a:(a.ok&&(n.state=a,n.updatedAt=Date.now(),ss(e,a)),a)).finally(()=>{n.read===i&&(n.read=void 0)});return n.read=i,i}async function Et(e,t){let n=ds(e),r=++n.revision;n.read=void 0;let o=await Pc(e,t);return o.ok&&n.revision===r&&(n.revision+=1,n.read=void 0,n.state=o,n.updatedAt=Date.now(),ss(e,o)),o}async function Ab(e){try{let t=await fetch(`${mo}?route=${encodeURIComponent(e)}&op=endpoints`,{method:"GET",cache:"no-store",credentials:"same-origin"});if(!t.ok)return{ok:!1};let n=await t.json().catch(()=>{});if(!X(n)||n.ok!==!0)return{ok:!1};let r=n.endpoints;return X(r)?{ok:!0,endpoints:{openai:typeof r.openai=="string"?r.openai:null,anthropic:typeof r.anthropic=="string"?r.anthropic:null}}:{ok:!0}}catch{return{ok:!1}}}async function Rb(e){try{let n=await(await fetch(`${mo}?route=${encodeURIComponent(e)}&op=balance`,{method:"GET",cache:"no-store",credentials:"same-origin"})).json().catch(()=>{});if(!X(n)||n.ok!==!0){let o=X(n)?Oc(n):void 0;return o===void 0?{ok:!1}:{ok:!1,error:o}}let r=n.endpoint;return{ok:!0,endpoint:typeof r=="string"&&r.length>0?r:null}}catch{return{ok:!1}}}var Ge={list:Lb,endpoints:Ab,balanceEndpoint:Rb,cached:Mb,add:(e,t,n)=>Et(e,{op:"add",value:t,...n===void 0?{}:{alias:n}}),rename:(e,t,n)=>Et(e,{op:"rename",ref:t,...n===void 0?{}:{alias:n}}),remove:(e,t)=>Et(e,{op:"remove",ref:t}),replace:(e,t,n)=>Et(e,{op:"value",ref:t,value:n}),setScope:(e,t,n)=>Et(e,{op:"scope",ref:t,...n===void 0?{}:{models:n}}),setEnabled:(e,t,n)=>Et(e,{op:"enable",ref:t,enabled:n}),setProtocol:(e,t,n)=>Et(e,{op:"protocol",ref:t,...n===void 0?{}:{protocol:n}}),setEndpoints:(e,t,n)=>Et(e,{op:"endpoints",openai:t??"",anthropic:n??""}),setBalanceEndpoint:(e,t)=>Et(e,{op:"balance",endpoint:t}),probe:e=>Et(e,{op:"probe"}),async reveal(e,t){try{let n=await fetch(`${po}?route=${encodeURIComponent(e)}&ref=${encodeURIComponent(t)}`,{method:"GET",cache:"no-store",credentials:"same-origin"});if(!n.ok)return;let r=await n.json();if(!X(r)||r.ok!==!0)return;let o=r.key;return typeof o=="string"&&o.length>0?o:void 0}catch{return}}};var Kn="data-bre-endpoint-rows",Ht="data-bre-endpoint-row",jn="data-bre-balance-row",Yo="data-bre-endpoint-family",Dc="data-bre-endpoint-filled",Jo="data-bre-endpoint-field",Xo="data-bre-endpoint-title",Wn="data-bre-endpoint-toggle",Bc="data-bre-endpoint-count",Qo="data-bre-field-order",Dr="data-bre-endpoint-serving",_c="data-bre-protocol-watch",Fc=new WeakSet,qc="data-bre-row-provider",cs="data-bre-protocol-cards",Gn="data-bre-protocol-value",us="data-bre-protocol-source";function dt(e,t){for(let n of t){let r=Array.from(e.querySelectorAll("input[aria-label], select[aria-label]")).find(o=>(o.getAttribute("aria-label")??"").startsWith(n));if(r!==void 0)return r}}function Un(e,t){let n=dt(e,t);if(n===void 0)return;let r=n.closest("label");return r!==null&&r.parentElement!==null?r:n.parentElement??void 0}function ls(e,t){let n=e;for(;n!==null&&n.parentElement!==t;)n=n.parentElement;return n===null||n===t?void 0:n}function Cb(e,t,n){for(let r=t.parentElement;r!==null;r=r.parentElement){if(!r.contains(n)||e!==void 0&&!r.contains(e))continue;let o=ls(t,r),i=ls(n,r);if(o===void 0||i===void 0||o===i)continue;let a=e===void 0?void 0:ls(e,r);return{container:r,protocol:o,url:i,name:a}}}function Wc(e,t){let n=dt(e,t);return n instanceof HTMLSelectElement||n instanceof HTMLInputElement?n.value.trim():""}function Hb(e,t){let n=Wc(e,t.apiProtocol);return n==="anthropic-messages"||n==="openai-completions"||n==="openai-responses"?n:void 0}function Tt(e,t){let n=Hb(e,t);return n===void 0?void 0:zo(n)}function cn(e,t){let n=Wc(e,t.routeId);return n.length>0?n:(e.closest(`[${qc}]`)?.getAttribute(qc)??"").trim()}function Gc(e,t){return e==="anthropic"?t("keysEndpointAnthropic"):e==="openai"?t("keysEndpointOpenAI"):""}function Nb(e,t){let n=dt(e,t.modelName),r=dt(e,t.apiProtocol),o=dt(e,t.baseUrl);if(r===void 0||o===void 0)return;let i=Cb(n,r,o);if(i===void 0)return;let{container:a,protocol:s,url:d,name:l}=i,c=h=>Array.from(a.children).indexOf(h);if((l===void 0||c(l)<c(s))&&c(s)<c(d)){e.setAttribute(Qo,"1");return}a.insertBefore(s,d),l!==void 0&&a.insertBefore(l,s),e.setAttribute(Qo,"1")}function Uc(e,t){for(let n of Array.from(e.children))if(!(n===t||n.contains(t))&&!n.hasAttribute(Yo)&&!n.hasAttribute(Wn)&&n instanceof HTMLElement&&(n.textContent??"").trim().length>0)return n}function ln(e,t){let n=t?"1":"0";e.getAttribute(Dc)!==n&&e.setAttribute(Dc,n)}function Ob(e,t,n){let r=Uc(e,t);if(!n){e.removeAttribute(Jo),r?.removeAttribute(Xo);return}e.setAttribute(Jo,"1"),r?.setAttribute(Xo,"1")}function jc(e,t,n){let r=dt(e,t.baseUrl);if(r===void 0)return;let o=Un(e,t.baseUrl);if(o===void 0)return;let i=Gc(Tt(e,t),n),a=o.querySelector(`[${Yo}]`);if(a===null&&i.length>0){a=document.createElement("span"),a.setAttribute(Yo,"1"),a.className="bre-endpoint-family";let d=r.closest("label");d!==null&&d.contains(r)?d.insertBefore(a,r):o.insertBefore(a,r)}a!==null&&(a.textContent!==i&&(a.textContent=i),yt(a,i.length===0),ln(a,r instanceof HTMLInputElement&&r.value.trim().length>0)),Ob(o,r,a!==null&&i.length>0);let s=Tt(e,t);s===void 0?o.removeAttribute(Dr):o.setAttribute(Dr,s)}function Ib(e,t){let n=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;n===void 0?e.value=t:n.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}function zc(e,t){for(let n of Array.from(t.querySelectorAll(`[${Gn}]`))){let r=n.getAttribute(Gn)===e.value;n.classList.toggle("is-selected",r),n.setAttribute("aria-checked",r?"true":"false"),n.tabIndex=r?0:-1}}function Pb(e,t,n){let r=Array.from(t.querySelectorAll(`[${Gn}]`)),o=Array.from(e.options).filter(i=>i.value.length>0);return r.length!==o.length?!1:o.every((i,a)=>{let s=r[a];return s!==void 0&&s.getAttribute(Gn)===i.value&&(s.textContent??"")===$c(i.value,(i.textContent??i.value).trim(),n.t)})}function $c(e,t,n){return e==="openai-completions"?n("keysProtocolShortChat"):e==="openai-responses"?n("keysProtocolShortResponses"):e==="anthropic-messages"?n("keysProtocolShortAnthropic"):t}function Kc(e,t,n){t.replaceChildren();for(let r of Array.from(e.options)){let o=r.value;if(o.length===0)continue;let i=document.createElement("button");i.type="button",i.className="bre-protocol-card",i.setAttribute("role","radio"),i.setAttribute(Gn,o),i.textContent=$c(o,(r.textContent??o).trim(),n.t),i.title=(r.textContent??o).trim(),i.addEventListener("click",()=>{e.value!==o&&(Ib(e,o),zc(e,t))}),t.appendChild(i)}}function Db(e,t,n){let r=dt(e,t.apiProtocol);if(!(r instanceof HTMLSelectElement))return;let o=Un(e,t.apiProtocol);if(o===void 0)return;let i=o.querySelector(`[${cs}]`);if(i===null){let a=document.createElement("div");i=a,a.setAttribute(cs,"1"),a.className="bre-protocol-cards",a.setAttribute("role","radiogroup");let s=r.getAttribute("aria-label");s!==null&&a.setAttribute("aria-label",s),r.setAttribute(us,"1"),r.after(a),Kc(r,a,n),a.addEventListener("keydown",d=>{let l=d.key==="ArrowRight"||d.key==="ArrowDown"?1:d.key==="ArrowLeft"||d.key==="ArrowUp"?-1:0,c=Array.from(a.querySelectorAll(`[${Gn}]`));if(c.length===0)return;if(d.key==="Home"||d.key==="End"){d.preventDefault();let p=d.key==="Home"?c[0]:c[c.length-1];p?.click(),p?.focus();return}if(l===0)return;d.preventDefault();let f=c.findIndex(p=>p.classList.contains("is-selected")),h=c[(Math.max(f,0)+l+c.length)%c.length];h?.click(),h?.focus()})}else Pb(r,i,n)||Kc(r,i,n);yt(r,!0),zc(r,i)}function fs(e,t,n){let r=e===null?0:e.querySelectorAll(`[${Ht}], [${jn}]`).length,o=r===0?"":n.t("keysEndpointsCount",{count:r});if(o.length===0){t.hasAttribute("title")&&t.removeAttribute("title");return}t.getAttribute("title")!==o&&t.setAttribute("title",o)}function _b(e,t,n){let r=e.querySelector(`[${Wn}]`);if(Un(e,t.apiProtocol)===void 0){r?.remove(),e.querySelector(`[${Bc}]`)?.remove();return}let o=Un(e,t.baseUrl);if(o===void 0)return;let i=dt(e,t.baseUrl);if(i===void 0)return;let a=Uc(o,i);if(a===void 0||a===r)return;let s=()=>e.querySelector(`[${Kn}]`),d=c=>{let f=n.t("keysMoreEndpoints");c.textContent!==f&&(c.textContent=f);let h=s();c.setAttribute("aria-expanded",h!==null&&!h.hidden?"true":"false"),fs(h,c,n)};if(r!==null){r.parentElement!==a&&a.append(r),d(r);return}let l=document.createElement("button");l.type="button",l.setAttribute(Wn,"1"),l.className="bre-endpoint-toggle",l.textContent=n.t("keysMoreEndpoints"),l.addEventListener("click",()=>{let c=s();if(c!==null&&(c.hidden=!c.hidden,d(l),!c.hidden)){let f=cn(e,t);f.length>0&&Kb(c,f,n,e,t)}}),a.append(l),d(l)}var Bn=new WeakMap,Vc=1e3,Zo=new WeakMap,zn=0,Vo=new Map;function Fb(e,t){zn+=1,typeof CustomEvent=="function"&&document.dispatchEvent(new CustomEvent(Er,{detail:{route:e,openai:t.openai??"",anthropic:t.anthropic??""}}))}function qb(e,t){zn+=1,typeof CustomEvent=="function"&&document.dispatchEvent(new CustomEvent(Sr,{detail:{route:e,endpoint:t}}))}function _r(e){let t=e.getAttribute(Ht);return t==="openai"||t==="anthropic"?t:void 0}async function Kb(e,t,n,r,o){for(let i of Array.from(e.querySelectorAll(`[${Ht}], [${jn}]`)))await Yc(i,t,n,r,o)}async function Yc(e,t,n,r,o){let i=e.querySelector(".bre-endpoint-url");if(i===null)return;if(e.hasAttribute(jn)){await Jc(e,i,t,n);return}let a=_r(e);if(a===void 0)return;let s=(Bn.get(e)??0)+1;Bn.set(e,s),Zo.set(e,{at:Date.now(),epoch:zn});let d=n.client??Ge,l=await ei(t,d);if(l===void 0||Bn.get(e)!==s||_r(e)!==a||document.activeElement===i)return;await Xc(r,o,n,t,Tt(r,o),l);let c=l[a];i.value!==c&&(i.value=c);let f=e.querySelector(".bre-endpoint-family");f!==null&&ln(f,c.length>0)}async function Jc(e,t,n,r){let o=(Bn.get(e)??0)+1;Bn.set(e,o),Zo.set(e,{at:Date.now(),epoch:zn});let i=r.client??Ge;if(i.balanceEndpoint===void 0)return;let a=await i.balanceEndpoint(n);if(!a.ok||Bn.get(e)!==o||document.activeElement===t)return;let s=a.endpoint??"";t.value!==s&&(t.value=s);let d=e.querySelector(".bre-endpoint-family");d!==null&&ln(d,s.length>0)}async function Xc(e,t,n,r,o,i,a=!1){if(o===void 0||!a&&i[o].length>0)return;let s=dt(e,t.baseUrl);if(!(s instanceof HTMLInputElement)||document.activeElement===s)return;let d=s.value.trim();if(d.length===0&&!a)return;let l=n.client??Ge;await ms(r,l,c=>{if(!(!a&&c[o].length>0)&&c[o]!==d)return{openai:o==="openai"?d:c.openai,anthropic:o==="anthropic"?d:c.anthropic}})}function ps(e,t,n){let r=Un(e,t.baseUrl);if(r===void 0||r.parentElement===null)return;let o=Tt(e,t);if(o===void 0)return;let i=r.querySelector(`:scope > [${Kn}]`);i===null&&(i=e.querySelector(`[${Kn}]`),i!==null&&r.appendChild(i)),i===null&&(i=document.createElement("div"),i.setAttribute(Kn,"1"),i.hidden=!0,r.appendChild(i));let a=Tc.filter(f=>f!==o),s=Array.from(i.children).filter(f=>f instanceof HTMLElement&&f.hasAttribute(Ht));if(!(a.length===s.length&&a.every((f,h)=>_r(s[h])===f)))for(let f of a){let h=i.querySelector(`[${Ht}="${f}"]`);h===null&&(h=Bb(e,t,n,f)),i.appendChild(h)}for(let f of Array.from(i.querySelectorAll(`[${Ht}]`))){let h=_r(f);h!==void 0&&h!==o||f.remove()}let l=e.querySelector(`[${Wn}]`);l!==null&&(l.setAttribute("aria-expanded",i.hidden?"false":"true"),fs(i,l,n));let c=cn(e,t);if(c.length>0)for(let f of Array.from(i.querySelectorAll(`[${Ht}]`))){let h=Zo.get(f);(h===void 0||h.epoch!==zn||Date.now()-h.at>=Vc)&&Yc(f,c,n,e,t)}}function Bb(e,t,n,r){let o=document.createElement("div");o.setAttribute(Ht,r),o.className="bre-endpoint-row";let i=document.createElement("span");i.className="bre-endpoint-family",i.textContent=Gc(r,n.t),ln(i,!1);let a=document.createElement("input");a.type="url",a.className="bre-text-input bre-endpoint-url",a.spellcheck=!1,a.placeholder="https://\u2026";let s=n.client??Ge;return a.addEventListener("change",()=>{let d=cn(e,t);if(d.length===0)return;let l=a.value.trim();if(l.length>0&&!/^https?:\/\//i.test(l)){a.setAttribute("aria-invalid","true"),a.title=n.t("keysEndpointInvalid");return}a.hasAttribute("aria-invalid")&&a.removeAttribute("aria-invalid"),a.hasAttribute("title")&&a.removeAttribute("title"),ln(i,l.length>0),(async()=>await ms(d,s,c=>{let f=_r(o);if(f!==void 0)return{openai:f==="openai"?l:c.openai,anthropic:f==="anthropic"?l:c.anthropic}}))()}),o.append(i,a),o}function Qc(e,t,n){let r=e.querySelector(`[${Kn}]`),o=e.querySelector(`[${jn}]`),i=cn(e,t);if(r===null||i.length===0){o?.remove();return}let a=o;a===null&&(a=Wb(e,t,n)),r.lastElementChild!==a&&r.appendChild(a);let s=e.querySelector(`[${Wn}]`);s!==null&&fs(r,s,n);let d=Zo.get(a);if(d===void 0||d.epoch!==zn||Date.now()-d.at>=Vc){let l=a.querySelector(".bre-endpoint-url");l!==null&&Jc(a,l,i,n)}}function Wb(e,t,n){let r=document.createElement("div");r.setAttribute(jn,"1"),r.className="bre-endpoint-row bre-balance-row";let o=document.createElement("span");o.className="bre-endpoint-family",o.textContent=n.t("keysEndpointBalance"),ln(o,!1);let i=document.createElement("input");i.type="url",i.className="bre-text-input bre-endpoint-url",i.spellcheck=!1,i.placeholder="https://\u2026",i.setAttribute("aria-label",n.t("keysEndpointBalance")),i.title=n.t("keysEndpointBalanceHint");let a=n.client??Ge,s=a.setBalanceEndpoint;return i.addEventListener("change",()=>{let d=cn(e,t);if(d.length===0)return;let l=i.value.trim();if(l.length>0&&!/^https?:\/\//i.test(l)){i.setAttribute("aria-invalid","true"),i.title=n.t("keysEndpointInvalid");return}i.hasAttribute("aria-invalid")&&i.removeAttribute("aria-invalid"),i.title=n.t("keysEndpointBalanceHint"),ln(o,l.length>0),s!==void 0&&(async()=>(await s.call(a,d,l)).ok&&qb(d,l))()}),r.append(o,i),r}async function Gb(e,t,n,r,o){let i=cn(e,t),a=dt(e,t.baseUrl);if(i.length===0||!(a instanceof HTMLInputElement))return;let s=n.client??Ge,d=await ei(i,s);if(d===void 0||Tt(e,t)!==o)return;let l=a.value.trim();if(l.length>0&&l!==d[r]){let h=await ms(i,s,p=>{if(Tt(e,t)===o)return{openai:r==="openai"?l:p.openai,anthropic:r==="anthropic"?l:p.anthropic}});if(h===void 0||(d=h,Tt(e,t)!==o))return}let c=d[o];if(a.value===c)return;let f=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set;f===void 0?a.value=c:f.call(a,c),a.dispatchEvent(new Event("input",{bubbles:!0})),a.dispatchEvent(new Event("change",{bubbles:!0})),ps(e,t,n)}async function ms(e,t,n){let o=(Vo.get(e)??Promise.resolve()).then(async()=>{let i=await ei(e,t);if(i===void 0)return;let a=n(i);if(a===void 0)return;let s=t.setEndpoints;if(typeof s!="function")return;let d=await s.call(t,e,a.openai,a.anthropic);if(!d.ok)return;let l={openai:d.endpoints.openai??"",anthropic:d.endpoints.anthropic??""};return Fb(e,d.endpoints),l});Vo.set(e,o);try{return await o}finally{Vo.get(e)===o&&Vo.delete(e)}}async function ei(e,t){if(t.endpoints!==void 0){let r=await t.endpoints(e);return r.ok?{openai:r.endpoints?.openai??"",anthropic:r.endpoints?.anthropic??""}:void 0}let n=await t.list(e);if(n.ok)return{openai:n.endpoints.openai??"",anthropic:n.endpoints.anthropic??""}}function Ub(e,t,n){let r=Un(e,t.baseUrl),o=Tt(e,t),i=r?.getAttribute(Dr);jc(e,t,n.t),ps(e,t,n),Qc(e,t,n),!(r===void 0||i===void 0||o===void 0)&&i!==o&&(i!=="openai"&&i!=="anthropic"||Gb(e,t,n,i,o))}function Zc(e,t,n){Nb(e,t),Db(e,t,n),jc(e,t,n.t),_b(e,t,n),ps(e,t,n),Qc(e,t,n);let r=dt(e,t.apiProtocol);r instanceof HTMLSelectElement&&!r.hasAttribute(_c)&&(r.setAttribute(_c,"1"),r.addEventListener("change",()=>Ub(e,t,n)));let o=dt(e,t.baseUrl);o instanceof HTMLInputElement&&!Fc.has(o)&&(Fc.add(o),o.addEventListener("change",()=>{let i=cn(e,t),a=Tt(e,t);if(i.length===0||a===void 0)return;let s=n.client??Ge;(async()=>{let d=await ei(i,s);d!==void 0&&Tt(e,t)===a&&await Xc(e,t,n,i,a,d,!0)})()}))}function jb(){for(let e of Array.from(document.querySelectorAll(`select[${us}]`)))e.hidden=!1,e.removeAttribute(us)}function eu(){jb();for(let e of Array.from(document.querySelectorAll(`[${Kn}], [${Ht}], [${jn}], [${Wn}], [${Bc}], [${cs}], [${Yo}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`[${Qo}], [${Jo}], [${Xo}], [${Dr}]`)))e.removeAttribute(Qo),e.removeAttribute(Jo),e.removeAttribute(Xo),e.removeAttribute(Dr)}function $n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var gs="__breLedgerDocument";function lu(){let e=globalThis;return e[gs]??(e[gs]=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`)}var ri="bre:held-writes:v1";function xs(){try{return typeof sessionStorage>"u"?void 0:sessionStorage}catch{return}}function St(e){let t=xs();if(t!==void 0)try{if(e.pending.size===0&&e.queued.size===0){t.removeItem(ri);return}let n={document:lu(),committed:[...e.committing].filter(r=>e.queued.has(r)),pending:[...e.pending].map(([r,o])=>[r,[...o]]),queued:[...e.queued].map(([r,o])=>[r,[...o]])};t.setItem(ri,JSON.stringify(n))}catch{}}function tu(e,t){if(!Array.isArray(e))return;let n=[];for(let r of e){if(!Array.isArray(r)||r.length!==2)return;let[o,i]=r;if(typeof o!="string"||!Array.isArray(i))return;let a=[];for(let s of i){if(!Array.isArray(s)||s.length!==2)return;let[d,l]=s;if(typeof d!="string"||!X(l)||t!==void 0&&!t(l))return;a.push([d,l])}n.push([o,a])}return n}function zb(e){let t=xs();if(t!==void 0)try{let n=t.getItem(ri);if(n===null)return;let r=JSON.parse(n);if(r.document!==lu())return;let o=tu(r.pending),i=tu(r.queued,ty);if(o===void 0||i===void 0)return;let a=Array.isArray(r.committed)?r.committed.filter(s=>typeof s=="string"):[];for(let[s,d]of o)e.pending.set(s,new Map(d));for(let[s,d]of i)a.includes(s)&&(e.queued.set(s,new Map(d)),e.committing.add(s))}catch{}}function cu(e,t){(async()=>{try{await ks(t,e),await Es(t,e)}catch(n){console.error(`[bre] teardown flush failed: ${n instanceof Error?n.message:String(n)}`)}})()}function uu(e,t){(async()=>{try{await ks(t,e,!0),await Es(t,e,!0)}catch(n){console.error(`[bre] unload flush failed: ${n instanceof Error?n.message:String(n)}`)}finally{try{xs()?.removeItem(ri)}catch{}}})()}function fu(){let e={disposed:!1,mounted:new Map,describePromise:void 0,pending:new Map,missedScans:new Map,queued:new Map,editing:void 0,flushing:!1,flushFailures:0,nextFlushAt:0,committing:new Set,adapting:new Set,signalsUnavailable:!1,submitWired:new WeakSet,cancelWired:new WeakSet,disclosureWired:new WeakSet,editWired:new WeakSet,addModelWired:new WeakSet,addProviderWired:new WeakSet};return zb(e),e}async function $b(e,t,n=!1){if(t.flushing)return;t.flushing=!0;let r;try{r=n&&mu(t)?await pe(e.api,{fresh:!0}):void 0;let o=await ks(e,t,!1,r),i=await Es(e,t,!1,r);o||i?nu(e,t):(t.flushFailures=0,t.nextFlushAt=0)}catch(o){nu(e,t),console.error(`[bre] idle flush failed: ${o instanceof Error?o.message:String(o)}`)}finally{t.flushing=!1}try{e.onIdle?.(r)}catch(o){console.error(`[bre] idle hook failed: ${o instanceof Error?o.message:String(o)}`)}}var pu=new Set(["no-namespace","invalid-models"]);function nu(e,t){t.flushFailures+=1;let n=Math.min(2**(t.flushFailures-1)*500,3e4);t.nextFlushAt=Date.now()+n,e.onBackoff?.(n)}function mu(e){return e.queued.size>0||e.pending.size>0}function Vn(e,t,n,r,o,i,a,s){try{let d=e.pending.get(t);if(r===void 0){if(d===void 0)return;d.delete(n),d.size===0&&e.pending.delete(t);return}e.pending.set(t,(d??new Map).set(n,{efforts:r,...o===void 0?{}:{compat:o},...i===void 0?{}:{input:i},...s===void 0?{}:{imageGen:s===!0},...a===void 0?{}:{defaultEffort:a}}))}finally{St(e)}}function gu(e,t,n,r){e.queued.set(t,(e.queued.get(t)??new Map).set(n,r)),St(e)}function Vb(e,t,n){let r=e.pending.get(t);r!==void 0&&(r.delete(n),r.size===0&&e.pending.delete(t),St(e))}function Yb(e,t,n){let r=e.queued.get(t);r!==void 0&&(r.delete(n),r.size===0&&e.queued.delete(t),St(e))}function Jb(e,t,n){Vb(e,t,n),Yb(e,t,n)}function Xb(e,t){e.queued.delete(t),e.pending.delete(t),e.missedScans.delete(t),e.committing.delete(t),St(e)}function Qb(e,t,n){if(t===void 0)return null;let i=t[it]!==!0&&t.reasoningEfforts!==void 0&&typeof t[Sn]=="number"||t[it]!==!0&&n?.efforts!==void 0&&Zb(t.reasoningEfforts,n.efforts)?!1:t.reasoningEfforts!==void 0||t[it]===!0||e.efforts==="keep",s=t[wt]!==!0&&n?.input!==void 0&&ey(t.input,n.input)?!1:Array.isArray(t.input)&&t.input.length>0||t[wt]===!0,d=i?"keep":e.efforts,l=s?void 0:e.input,c=t[at]===!0,f=e.imageGen!==void 0&&e.imageGen!==c?e.imageGen:void 0,h=e.defaultEffort;return d==="keep"&&l===void 0&&f===void 0&&h===void 0?null:{efforts:d,...e.compat===void 0?{}:{compat:e.compat},...l===void 0?{}:{input:l},...f===void 0?{}:{imageGen:f},...h===void 0?{}:{defaultEffort:h}}}function Zb(e,t){if(e===t)return!0;if(!X(e)||!X(t))return!1;let n=Object.keys(t);if(Object.keys(e).length!==n.length)return!1;let r=t;return n.every(o=>e[o]===r[o])}function ey(e,t){if(!Array.isArray(e)||e.length!==t.length)return!1;let n=new Set(t);return e.every(r=>typeof r=="string"&&n.has(r))}function ty(e){if(!X(e))return!1;let t=e.efforts;return t===!1||t==="keep"||X(t)}async function ny(e,t,n,r,o=!1,i){let a=i??await e.describeNamespace(),s=Ke(a.namespace),d=[];for(let[h,p]of[...r]){let m=Dn(s,n).find(x=>x.id===h);if(m===void 0||t.pending.get(n)?.get(h)!==p)continue;let b=tn(s,n),g=typeof m.name=="string"?m.name:void 0,y=xt(h,g===void 0?b:{...b,displayName:g}),v=Qb(p,m,{...y.efforts===void 0?{}:{efforts:y.efforts},...y.input===void 0?{}:{input:y.input}});if(v===null){Vn(t,n,h,void 0);continue}d.push({modelId:h,efforts:v.efforts,...v.compat===void 0?{}:{compat:v.compat},...v.input===void 0?{}:{input:v.input},...v.imageGen===void 0?{}:{imageGen:v.imageGen},...v.defaultEffort===void 0?{}:{defaultEffort:v.defaultEffort}})}if(d.length===0)return!1;let l=!1,c=await Lr(e.api,n,d,()=>l?e.describeNamespace():(l=!0,Promise.resolve(a)),o?void 0:Ku),f=!1;return d.forEach((h,p)=>{let m=c[p];if(m?.aborted!==!0){if(m?.ok===!0||m?.modelNotFound===!0){Vn(t,n,h.modelId,void 0);return}if(m?.error!==void 0&&pu.has(m.error)){Vn(t,n,h.modelId,void 0),console.error(`[bre] staged flush withdrew "${n}"/"${h.modelId}": ${m.error}`);return}f=!0,console.error(`[bre] staged flush write failed for "${n}"/"${h.modelId}": ${m?.error??"unknown"}`)}}),(t.pending.get(n)?.size??0)===0&&t.pending.delete(n),f}async function ks(e,t,n=!1,r){for(let s of[...t.committing])t.queued.has(s)||t.committing.delete(s);if(![...t.queued.keys()].some(s=>t.committing.has(s)||t.signalsUnavailable))return St(t),!1;let i=r??await e.describeNamespace();if(i.writable!==!0)return St(t),!1;let a=!1;for(let[s,d]of[...t.queued]){if(!t.committing.has(s)&&!t.signalsUnavailable)continue;let c=[...d].map(([p,m])=>({modelId:p,efforts:m.efforts,...m.compat===void 0?{}:{compat:m.compat},...m.input===void 0?{}:{input:m.input},...m.imageGen===void 0?{}:{imageGen:m.imageGen},...m.defaultEffort===void 0?{}:{defaultEffort:m.defaultEffort}})),f=await Lr(e.api,s,c,()=>Promise.resolve(i),n?void 0:Ku),h=!1;c.forEach((p,m)=>{let b=f[m];if(b?.aborted===!0){h=!0;return}if(b?.ok===!0||b?.modelNotFound===!0){d.delete(p.modelId);return}if(b?.error!==void 0&&pu.has(b.error)){d.delete(p.modelId),console.error(`[bre] held write withdrawn for "${s}"/"${p.modelId}": ${b.error}`);return}console.error(`[bre] held write failed for "${s}"/"${p.modelId}": ${b?.error??"unknown"}`)}),d.size===0?(t.queued.delete(s),t.committing.delete(s)):h||(a=!0)}return St(t),a}async function Es(e,t,n=!1,r){if(t.pending.size===0)return!1;let o=r??await e.describeNamespace();if(o.writable!==!0)return!1;let i=Ke(o.namespace),a=!1;for(let[s,d]of[...t.pending]){if(d.size===0){t.pending.delete(s);continue}$n(i,s)&&await ny(e,t,s,d,n,o)&&(a=!0)}return St(t),a}function Qe(e,t){for(let n of t){let r=Array.from(e.querySelectorAll("input[aria-label], select[aria-label]")).find(o=>(o.getAttribute("aria-label")??"").startsWith(n));if(r!==void 0&&r.value.trim().length>0)return r.value.trim()}return""}function Kr(e){return e.closest('[class*="editor"], [class*="rowCard"], [class*="addCard"]')??void 0}function ry(e){let t=e.closest('[class*="modelEntry"]');if(t===null){let r=Kr(e);if(r===void 0)return;let o=Array.from(r.querySelectorAll('[class*="modelAdvanced"]'));return o.length===1?o[0]:o.find(i=>i.offsetParent!==null)??o[0]}let n=Array.from(t.querySelectorAll('[class*="modelAdvanced"]'));return n.length===1?n[0]:n.find(r=>r.offsetParent!==null)??n[0]}function hu(e,t){return Array.from(e.querySelectorAll("button[aria-label]")).find(n=>t.some(r=>(n.getAttribute("aria-label")??"").startsWith(r)))}function ru(){return new Promise(e=>{if(typeof window.requestAnimationFrame!="function"){e();return}let t,n=()=>{window.clearTimeout(r),t!==void 0&&window.cancelAnimationFrame(t),e()},r=window.setTimeout(n,100);t=window.requestAnimationFrame(n)})}function ni(e){return e.querySelector('[class*="modelInputTypes"]')!==null}var oy="modelReasoning",ys="data-bre-reasoning-hidden";function bu(e){return e.querySelector(`[class*="${oy}"]`)??void 0}function Ts(e){let t=bu(e);t!==void 0&&t.style.display!=="none"&&(t.setAttribute(ys,"1"),t.style.display="none")}function Fr(e){let t=bu(e);t!==void 0&&t.getAttribute(ys)==="1"&&(t.removeAttribute(ys),t.style.display==="none"&&(t.style.display=""))}var oi="data-bre-capacity-hidden";function yu(e,t){return Array.from(e.children).filter(n=>n.nodeType!==1?!1:n.matches(`[class*="${t}"]`))}function iy(e){return yu(e,"modelField")}function ay(e){return yu(e,"modelInputTypes")}function vu(e){return[...iy(e),...ay(e)]}function sy(e){for(let t of e)t.style.display!=="none"&&(t.setAttribute(oi,"1"),t.style.display="none")}function dy(e){for(let t of e)t.getAttribute(oi)==="1"&&(t.removeAttribute(oi),t.style.display==="none"&&(t.style.display=""))}function ly(e){sy(vu(e))}function hs(e){dy(vu(e))}function wu(e){let t=e.querySelector('[class*="modelInputTypes"]');return t===null||t.getAttribute(oi)==="1"?!1:!t.hidden&&t.style.display!=="none"}function xu(e,t){let n=e.querySelector('[class*="modelInputTypes"]');if(n===null)return;let r=Array.from(n.querySelectorAll('input[type="checkbox"]')),o=r.find(i=>{let a=i.closest("label")?.textContent?.trim();return a!==void 0&&t.includes(a)});return o!==void 0?o:r.length===2?r[1]:void 0}function Br(e,t,n){if(!wu(e))return!1;let r=xu(e,n);return r===void 0||r.disabled?!1:(r.checked!==t&&r.click(),!0)}function vs(e,t,n){return t==null||e===void 0||wu(e)&&Br(e,t.includes("image"),n),t}function ou(e,t){let n=e.getAttribute("aria-label")??"";if(t.some(o=>n.startsWith(o)))return!0;let r=e.closest("label")?.textContent?.trim()??"";return r.length>0&&t.some(o=>r.includes(o))}function Ss(e,t){let n=[...t.modelId,...t.modelName],r=Array.from(e.querySelectorAll("input")).filter(s=>s.type!=="checkbox"&&s.type!=="radio").filter(s=>s.closest("[data-plugin]")===null).filter(s=>!n.some(d=>(s.getAttribute("aria-label")??"").startsWith(d))),o=r.find(s=>ou(s,t.contextWindow)),i=r.find(s=>ou(s,t.maxOutput));if(o!==void 0&&i!==void 0)return{contextWindow:o,maxOutput:i};let a=r.filter(s=>s!==o&&s!==i);return{contextWindow:o??a[0],maxOutput:i??(o!==void 0?a[0]:a[1])}}function ku(e,t,n){let r=Ss(e,t),o=(i,a)=>i===void 0||i.disabled||a===void 0||!Number.isFinite(a)||a<=0||kt(i.value)!==void 0?!1:Eu(i,String(a));return{contextWindow:o(r.contextWindow,n.contextWindow),maxOutput:o(r.maxOutput,n.maxTokens)}}function Eu(e,t){return e.disabled?!1:(e.value===t||(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set?.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0}))),!0)}function cy(e,t){let n=Ss(e,t),r=a=>{if(a!==void 0)return kt(a.value)},o=r(n.contextWindow),i=r(n.maxOutput);return{...o===void 0?{}:{contextWindow:o},...i===void 0?{}:{maxTokens:i}}}function uy(e,t,n){let r=Ss(e,t),o=(i,a)=>i===void 0?!1:Eu(i,a===void 0||!Number.isFinite(a)||a<=0?"":String(a));return{contextWindow:"contextWindow"in n?o(r.contextWindow,n.contextWindow):!1,maxOutput:"maxTokens"in n?o(r.maxOutput,n.maxTokens):!1}}async function Tu(e,t){let n=e,r=n.offsetHeight;if(r<=0)return t();let o=n.style.height,i=n.style.overflow,a=n.style.boxSizing;n.style.boxSizing="border-box",n.style.height=`${r}px`,n.style.overflow="hidden";try{return await t()}finally{n.style.height=o,n.style.overflow=i,n.style.boxSizing=a}}async function fy(e,t,n){if(e===void 0)return!1;let r=t.inputImage;if(ni(e))return Br(e,!0,r);let o=e.closest('[class*="modelEntry"]')??e;if(o.querySelector('[class*="modelAdvanced"]')!==null)return!1;let i=hu(o,t.capacity);return i===void 0||i.disabled?!1:Tu(o,async()=>{i.click(),ni(o)||await n();try{return ni(o)&&Br(o,!0,r)}finally{i.click()}})}async function py(e,t,n,r){if(e.matches('[class*="modelAdvanced"]'))return r(e);let o=e.closest('[class*="modelEntry"]')??e;if(o.querySelector('[class*="modelAdvanced"]')!==null)return r(o);let i=hu(o,t.capacity);return i===void 0||i.disabled?!1:Tu(o,async()=>{i.click(),o.querySelector('[class*="modelAdvanced"]')===null&&await n();try{return o.querySelector('[class*="modelAdvanced"]')!==null?r(o):!1}finally{i.click()}})}function my(e,t,n,r,o){n.disposed||!e.isConnected||qu(e)===void 0||Array.from(e.querySelectorAll("button[aria-label]")).some(a=>o.capacity.some(s=>(a.getAttribute("aria-label")??"").startsWith(s)))||Fo(e,gy(e,Ke(r.namespace),o),{t:t.t,onRequest:a=>Su(n,t,a)})}function gy(e,t,n){let r=[];for(let o of ts(e)){let i=Kr(o);if(i===void 0)continue;let a=un(i,t,n);a===void 0||a.staged||r.push({catalogue:o,route:a.route})}return r}function hy(e,t,n){let r=[],o=new Set;for(let i of e){if(o.has(i.card))continue;o.add(i.card);let a=un(i.card,t,n);if(a===void 0)continue;let[s]=ts(i.card);s!==void 0&&r.push({catalogue:s,route:a.route})}return r}function by(e,t,n,r){let o=[],i=new Set;for(let a of r.capacity){let s=Array.from(e.querySelectorAll("button[aria-label]")).filter(d=>(d.getAttribute("aria-label")??"").startsWith(a));for(let d of s){let l=Kr(d);if(l===void 0)continue;let c=d.closest('[class*="modelEntry"]')??l,f=Qe(c,r.modelId);f.length===0||i.has(f)||un(l,n,r)?.route===t&&(i.add(f),o.push({id:f,name:Qe(c,r.modelName),row:c}))}}return o}async function Su(e,t,n,r=[]){if(n.length===0)return{held:0,unsuggested:0,blocked:"unknown-route"};if(e.adapting.has(n))return{held:0,unsuggested:0,blocked:"busy"};e.adapting.add(n);let o=0,i=0;try{Da();let a,s=()=>a??(a=t.describeNamespace()),d=await s(),l=Ke(d.namespace);if(d.writable!==!0)return{held:0,unsuggested:0,blocked:"unwritable"};if(!$n(l,n)&&r.length===0)return{held:0,unsuggested:0,blocked:"unknown-route"};let f=Dn(l,n),h=new Set;for(let S of f){let C=typeof S.id=="string"?S.id:"";C.length>0&&h.add(C)}let p=f.slice();for(let S of r)S.id.length===0||h.has(S.id)||p.push({id:S.id,name:S.name});if(p.length===0)return{held:0,unsuggested:0,blocked:"no-models"};let m=l[n]??{},b=typeof m.api=="string"?m.api:void 0,g=new Set,y=new Map;for(let[S,C]of e.mounted)C.props.route===n&&(y.set(C.props.modelId,S),C.props.efforts!==void 0&&g.add(C.props.modelId));let v=new Map;for(let S of r)S.row!==void 0&&v.set(S.id,S.row);let x=!1,H=(S,C)=>vs(y.get(S),C,t.labels().inputImage),q=async(S,C)=>{if(C.image!==!0)return;let M=y.get(S)??v.get(S);M!==void 0&&await fy(M,t.labels(),ru)},ne=async(S,C,M)=>{let w=C.image===!0,k=M.contextWindow!==void 0||M.maxTokens!==void 0;if(!w&&!k)return;let R=y.get(S)??v.get(S);if(R===void 0)return;let I=t.labels();await py(R,I,ru,D=>{w&&Br(D,!0,I.inputImage),k&&ku(D,I,M)})},K=Ho(t.api,s,(S,C,M,w,k,R,I)=>{Vn(e,S,C,M,w,H(C,k),R,I)},(S,C,M)=>{gu(e,S,C,{...M,input:H(C,M.input)})},void 0,()=>x);for(let S of p){let C=typeof S.id=="string"?S.id:"";if(C.length===0)continue;let M=Mo(p,C),w=Lo(p,C),k=S[at]===!0,R=M!==void 0||S[it]===!0,I=Array.isArray(w)&&w.length>0||S[wt]===!0||k;if(g.has(C)&&!R)continue;if(R&&I){let he=y.get(C)??v.get(C);if(Array.isArray(w)&&w.includes("image")&&he!==void 0){let te=t.labels().inputImage,ue=xu(he,te);ue!==void 0&&!ue.disabled&&!ue.checked&&Br(he,!0,te)}continue}let D=Ao(p,C),W=Co(p,C)??"",N=await K.suggest(n,C,Ro(p,C));if(!N.ok){i+=1;continue}let V=N.suggestion,ie=V.efforts!==!1,re=V.imageGen===!0?Rt(void 0,!0):V.input===void 0?Rt(w,k):Rt(V.input);if(R){if(!re.image&&!re.imageGen||e.queued.get(n)?.has(C)===!0)continue;await q(C,re),x=!h.has(C),K.commit(n,C,Do({efforts:"keep",...Po(re)})),x&&t.onPendingChanged?.(),x=!1,o+=1;continue}let oe=W!==""?W:V.defaultEffort??W,ae=oe===W?void 0:oe===""?null:oe;x=!h.has(C),await ne(C,re,{...V.contextWindow===void 0?{}:{contextWindow:V.contextWindow},...V.maxTokens===void 0?{}:{maxTokens:V.maxTokens}});let de=Io(re,w,k)?void 0:Po(re);K.commit(n,C,Do({efforts:Za(ie,Fn(an(V.efforts)),M),input:de?.input,imageGen:de?.imageGen,defaultEffort:ae,appliedCompat:V.compat,routeApi:b,initialCompat:D})),x&&t.onPendingChanged?.(),x=!1,o+=1}return{held:o,unsuggested:i}}catch(a){return console.warn("[bre] provider-wide adapt failed:",a),{held:o,unsuggested:i,failed:a instanceof Error?a.message:String(a)}}finally{e.adapting.delete(n)}}function yy(e){return e.querySelector(`[data-plugin="${ke}"]`)!==null}function vy(e,t){return e.route===t.route&&e.routeDisplayName===t.routeDisplayName&&e.routeApi===t.routeApi&&e.routeBaseURL===t.routeBaseURL&&e.modelId===t.modelId&&e.modelName===t.modelName&&e.index===t.index&&e.readOnly===t.readOnly&&e.defaultEffort===t.defaultEffort&&e.staged===t.staged&&e.officialInputTypes===t.officialInputTypes&&e.effortsUnset===t.effortsUnset&&Cr(e.efforts,t.efforts)&&xy(e.input,t.input)&&e.imageGen===t.imageGen&&wy(e.compat,t.compat)}function wy(e,t){return e===t?!0:e===void 0||t===void 0?!1:JSON.stringify({...e},Object.keys({...e,...t}).sort())===JSON.stringify({...t},Object.keys({...e,...t}).sort())}function xy(e,t){if(e===t)return!0;if(e===void 0||t===void 0)return!1;let n=new Set(e);return e.length===t.length&&t.every(r=>n.has(r))}function ky(e,t){return Array.from(e.querySelectorAll("input[aria-label], select[aria-label]")).some(n=>t.some(r=>(n.getAttribute("aria-label")??"").startsWith(r)))}function un(e,t,n){let r=e.querySelector('[class*="editorRoute"]')?.textContent?.trim();if(r!==void 0&&r.length>0&&$n(t,r))return{route:r,staged:!1};if(ky(e,n.routeId)){let a=Qe(e,n.routeId);return a.length>0&&!$n(t,a)?{route:a,staged:!0}:void 0}let o=e.querySelector('[class*="editorTitle"], [class*="rowName"]')?.textContent?.trim();if(o===void 0||o.length===0)return;let i=Object.entries(t).find(([,a])=>a.displayName===o);if(i!==void 0)return{route:i[0],staged:!1};if($n(t,o))return{route:o,staged:!1}}function Ey(e,t){let n=e.querySelector('[class*="editorActions"]');if(n===null)return;let r=Array.from(n.querySelectorAll("button"));if(r.length<2)return;let o=(f,h)=>(f.textContent??"").trim()===h,i=n.querySelector('[class*="primaryButton"]'),a=n.querySelector('[class*="secondaryButton"]');if(i!==null&&a!==null)return{submit:i,cancel:a};let s=[...r].reverse().find(f=>t.apply.some(h=>o(f,h))),d=[...r].reverse().find(f=>t.cancel.some(h=>o(f,h)));if(s!==void 0&&d!==void 0)return{submit:s,cancel:d};let l=r[r.length-1],c=r[r.length-2];if(!(l===void 0||c===void 0))return{submit:l,cancel:c}}function Jn(e,t,n){t.has(e)||(t.add(e),e.addEventListener("click",n,{capture:!0}))}var bs=new WeakMap,ws=new Set;function Mu(){for(let e of Array.from(ws))e.release()}var Wr=420,Lu=320,Ty=160,iu=2e3,Sy=150,Au=new Set(["PageUp","PageDown","Home","End","ArrowUp","ArrowDown"," "]);function Ms(e,t=Lu){for(let n of as(e)){let r=ii.get(n);if(r!==void 0){window.clearTimeout(r.timer),r.timer=window.setTimeout(()=>au(n),t);continue}n.style.overflowAnchor!=="none"&&(ii.set(n,{saved:n.style.overflowAnchor,timer:window.setTimeout(()=>au(n),t)}),n.style.overflowAnchor="none")}}var ii=new Map;function au(e){let t=ii.get(e);t!==void 0&&(ii.delete(e),e.style.overflowAnchor=t.saved)}function Xn(e,t,n=!1){let r=as(e),o=r[0];if(o===void 0||!e.isConnected)return;let i=performance.now(),a=bs.get(o);if(a!==void 0)if(n)a.release();else{a.deadline=Math.min(Math.max(a.deadline,i+t),a.startedAt+iu);return}let s=e.getBoundingClientRect(),d=s.top,l=s.height,c=new Map,f=new Map;for(let x of r){c.set(x,x.scrollTop);let H=x.style.overflowAnchor;H!=="none"&&f.set(x,H),x.style.overflowAnchor="none"}let h=new Set(r),p={deadline:i+t,startedAt:i,frame:void 0,release:()=>{}},m=()=>{if(ws.delete(p)){p.frame!==void 0&&(window.cancelAnimationFrame(p.frame),p.frame=void 0);for(let[x,H]of f)x.style.overflowAnchor=H;bs.delete(o),document.removeEventListener("wheel",b,!0),document.removeEventListener("touchstart",b,!0),document.removeEventListener("pointerdown",b,!0),document.removeEventListener("keydown",g,!0)}};function b(){m()}function g(x){Au.has(x.key)&&m()}p.release=m,bs.set(o,p),ws.add(p),document.addEventListener("wheel",b,{capture:!0,passive:!0}),document.addEventListener("touchstart",b,{capture:!0,passive:!0}),document.addEventListener("pointerdown",b,{capture:!0}),document.addEventListener("keydown",g,{capture:!0});let y=0,v=()=>{if(p.frame=void 0,y+=1,!e.isConnected||y>=Sy){m();return}let x=e.getBoundingClientRect(),H=Math.abs(x.height-l)>.5;if(!H&&[...h].some(S=>S.scrollTop!==c.get(S))){m();return}let q=[];if(H){for(let S of r){let C=c.get(S);C===void 0||S.scrollTop===C||(q.push(S),S.scrollTop=C,c.set(S,S.scrollTop))}x=e.getBoundingClientRect()}let ne=x.top-d;ne!==0&&My(r,h,c,ne,q);let K=performance.now();if(H&&(l=x.height,p.deadline=Math.min(Math.max(p.deadline,K+Ty),p.startedAt+iu)),K>=p.deadline){m();return}p.frame=window.requestAnimationFrame(v)};p.frame=window.requestAnimationFrame(v)}function My(e,t,n,r,o=[]){let i=r;for(let a of new Set([...o,...t,...e])){if(i===0)break;let s=a.scrollTop;if(s!==n.get(a))continue;a.scrollTop=s+i;let d=a.scrollTop;d!==s&&(n.set(a,d),t.add(a),i-=d-s)}}var Ls='[class*="modelList"]',Ly="bre-list-slack",Ru=3e3,Ay='button[class*="iconButtonDanger"]',Gr,jt=new WeakMap,Yn=new Set;function Cu(e){if(!(e instanceof Element))return;let t=e.closest(Ls);if(t===null)return;let n=vc(t).map(r=>({host:r,top:r.scrollTop}));n.length!==0&&(Gr={targets:n,at:performance.now()})}function Nt(){Gr=void 0}function Hu(e){Cu(e.target),Du(e.target)}function Nu(e){if(Au.has(e.key)){Nt();return}Cu(e.target),Du(e.target)}var qr=0;function Ou(){qr+=1,!(qr>1)&&(document.addEventListener("click",Hu,!0),document.addEventListener("keydown",Nu,!0),document.addEventListener("focusin",Nt,!0),document.addEventListener("pointerdown",Nt,!0),document.addEventListener("wheel",Nt,{capture:!0,passive:!0}),document.addEventListener("touchstart",Nt,{capture:!0,passive:!0}))}function ai(e){let t=jt.get(e);t!==void 0&&(jt.delete(e),Yn.delete(t),t.scrollTarget.removeEventListener("scroll",t.onScroll),t.spacer.remove())}function Ry(e){return e===document.scrollingElement?document:e}function Cy(){if(Yn.size!==0)for(let e of Array.from(Yn)){let t=e.host;if(!e.spacer.isConnected){jt.delete(t),Yn.delete(e),e.scrollTarget.removeEventListener("scroll",e.onScroll);continue}t.scrollTop<=t.scrollHeight-t.clientHeight-e.height&&ai(t)}}function Iu(e,t){return e.scrollTop>e.scrollHeight-e.clientHeight-t}function Pu(e,t){let n=jt.get(e);if(n!==void 0)return n.height!==t&&(n.height=t,n.spacer.style.height=`${t}px`),n;let r=document.createElement("div");r.className=Ly,r.dataset.plugin=ke,r.setAttribute("aria-hidden","true"),r.style.height=`${t}px`,(e===document.scrollingElement?document.body??e:e).appendChild(r);let i=()=>{let s=jt.get(e);s!==void 0&&!Iu(e,s.height)&&ai(e)},a={host:e,spacer:r,height:t,onScroll:i,scrollTarget:Ry(e)};return jt.set(e,a),Yn.add(a),a.scrollTarget.addEventListener("scroll",i,{passive:!0}),a}function Du(e){if(!(e instanceof Element))return;let t=e.closest(Ay);if(t===null)return;let n=t.closest(Ls);if(n===null)return;let r=t.closest('[class*="modelEntry"]');if(r===null)return;let o=Gr;if(o===void 0||performance.now()-o.at>Ru)return;let i=Number.parseFloat(getComputedStyle(n).rowGap)||0,a=r.getBoundingClientRect().height+i;if(!(a<=0))for(let{host:s,top:d}of o.targets){if(!s.isConnected)continue;let l=jt.get(s),c=l===void 0?0:l.height,f=s.scrollHeight-s.clientHeight-c-d;f>=a||Pu(s,Math.max(c,a-f))}}function Hy(e=performance.now()){let t=Gr;if(!(t===void 0||e-t.at>Ru))for(let n of t.targets){let r=n.host;if(!r.isConnected)continue;let o=jt.get(r),i=o===void 0?0:o.height,a=r.scrollHeight-r.clientHeight-i,s=n.top-a;if(s<=0){o!==void 0&&!Iu(r,o.height)&&ai(r);continue}Pu(r,s),r.scrollTop!==n.top&&(r.scrollTop=n.top)}}function _u(){if(qr=Math.max(0,qr-1),!(qr>0)){document.removeEventListener("click",Hu,!0),document.removeEventListener("keydown",Nu,!0),document.removeEventListener("focusin",Nt,!0),document.removeEventListener("pointerdown",Nt,!0),document.removeEventListener("wheel",Nt,!0),document.removeEventListener("touchstart",Nt,!0),Gr=void 0;for(let e of Array.from(Yn))ai(e.host)}}function Fu(e,t=Wr){Hy(),Cy();let n=new Set;for(let r of Array.from(e.querySelectorAll(Ls))){let o=r.closest('[class*="rowCard"], [class*="setupCard"], [class*="addCard"]');o===null||n.has(o)||(n.add(o),Xn(o,t))}}function Ny(e,t){Jn(e,t,()=>{let n=e.closest('[class*="modelEntry"]')??e.closest('[class*="rowCard"]');n!==null&&Xn(e.closest('[class*="rowCard"]')??n,Wr)})}var su="{provider}";function Oy(e,t){let n=t.editProvider.map(o=>{let i=o.indexOf(su);return i<0?void 0:{prefix:o.slice(0,i),suffix:o.slice(i+su.length)}}).filter(o=>o!==void 0);if(n.length===0)return[];let r=[];for(let o of Array.from(e.querySelectorAll("button[aria-label]"))){let i=o.getAttribute("aria-label")??"";n.some(a=>i.length>a.prefix.length+a.suffix.length&&i.startsWith(a.prefix)&&i.endsWith(a.suffix))&&o.closest("[data-plugin]")===null&&r.push(o)}return r}function Iy(e,t){Jn(e,t,()=>{let n=e.closest('[class*="rowCard"], [class*="setupCard"], [class*="addCard"]');n!==null&&Xn(n,Wr)})}function Py(e,t){let n=[];for(let r of Array.from(e.querySelectorAll("button"))){if(r.closest("[data-plugin]")!==null)continue;let o=r.getAttribute("aria-label")??"";if(t.addModel.some(a=>o.startsWith(a))){n.push(r);continue}let i=(r.textContent??"").trim();i.length>0&&t.addModel.some(a=>i===a||i===`+ ${a}`)&&n.push(r)}return n}function Dy(e,t,n){Jn(e,n,()=>{t.isConnected&&Xn(t,Wr)})}function _y(e,t){Jn(e,t,()=>{let n=e.closest('[class*="addBlock"]');n!==null&&Xn(n,Wr,!0)})}function qu(e){return e.querySelector('[class*="editorActions"]')??e.querySelector('[class*="modelEntry"]')??void 0}function Ku(){return qu(bt())!==void 0}function Fy(e,t,n){let r={routeId:t.routeId,modelName:t.modelName,baseUrl:t.baseUrl,apiProtocol:t.apiProtocol},o=new Set;for(let i of e){let a=Array.from(i.querySelectorAll("input[aria-label], select[aria-label]")),s=d=>a.some(l=>d.some(c=>(l.getAttribute("aria-label")??"").startsWith(c)));s(t.apiProtocol)&&s(t.baseUrl)&&o.add(i)}for(let i of o)Zc(i,r,{t:n})}var ti=new WeakMap;function du(e,t,n,r=!1){let o=e.describePromise;if(o===void 0)return;let i=ti.get(e);if(i?.promise===o){i.run=t,i.phase=n,i.reportReadFailure=r;return}let a={promise:o,run:t,phase:n,reportReadFailure:r};ti.set(e,a);let s=()=>{ti.get(e)===a&&ti.delete(e)};o.then(d=>{s(),!e.disposed&&e.describePromise===o&&a.run(d)},d=>{s(),e.describePromise===o&&(e.describePromise=void 0,a.reportReadFailure&&console.error(`[bre] ${a.phase} failed: ${d instanceof Error?d.message:String(d)}`))}).catch(d=>{console.error(`[bre] ${a.phase} failed: ${d instanceof Error?d.message:String(d)}`)})}var qy=['[class*="editor"]','[class*="modelEntry"]','[class*="rowCard"]','[class*="setupCard"]','[class*="addCard"]','button[class*="addButton"]',"button[aria-label]"].join(", ");function As(e,t,n){if(n.disposed||!e.isConnected)return;let r=t.labels(),o=Array.from(e.querySelectorAll(qy)),i=!1,a=[],s=[],d=[],l=[],c=[];for(let p of o)!i&&p.matches('[class*="editorActions"], [class*="modelEntry"]')&&(i=!0),p.matches('[class*="rowCard"], [class*="setupCard"]')?(a.push(p),s.push(p)):p.matches('[class*="addCard"]')&&s.push(p),p.matches('[class*="editor"], [class*="addCard"], [class*="rowCard"]')&&l.push(p),p.matches('button[class*="addButton"]')&&p.closest("[data-plugin]")===null&&d.push(p),p.matches("button[aria-label]")&&r.capacity.some(m=>(p.getAttribute("aria-label")??"").startsWith(m))&&c.push(p);for(let p of a)for(let m of Oy(p,r))Iy(m,n.editWired);for(let p of s)for(let m of Py(p,r))Dy(m,p,n.addModelWired);for(let p of d)_y(p,n.addProviderWired);Fy(l,r,t.t);let f=c.length>0;if(!i){if(Fo(e,[],{t:t.t}),n.mounted.size>0){for(let[m,b]of n.mounted)Fr(m),hs(m),b.editor.unmount();n.mounted.clear()}let p=n.editing;n.editing=!1,(p!==!1||mu(n)&&Date.now()>=n.nextFlushAt)&&$b(t,n,p===!0).catch(m=>{console.error(`[bre] idle pass failed: ${m instanceof Error?m.message:String(m)}`)});return}if(n.editing=!0,!f){for(let[m,b]of n.mounted)Fr(m),hs(m),b.editor.unmount();n.mounted.clear(),n.describePromise??(n.describePromise=t.describeNamespace({allowStale:!0}));let p=r;du(n,m=>{my(e,t,n,m,p)},"empty-catalog seat",!0);return}for(let p of c)Ny(p,n.disclosureWired);n.describePromise??(n.describePromise=t.describeNamespace({allowStale:!0})),du(n,p=>{if(n.disposed||!e.isConnected)return;let m=p.namespace,b=Ke(m),g=new Map,y=S=>(g.has(S)||g.set(S,un(S,b,r)),g.get(S)),v=new Map,x=S=>{let C=v.get(S);if(C!==void 0)return C;let M=Dn(b,S),w=new Set,k=new Set,R=new Map;for(let D of M){let W=D.id;w.add(W),R.has(W)||R.set(W,[D]),D[it]===!0&&k.add(W)}let I={models:M,savedModelIds:w,unsetModelIds:k,singletonById:R};return v.set(S,I),I},H=[],q=Array.from(e.querySelectorAll("button[aria-label]")).filter(S=>r.capacity.some(C=>(S.getAttribute("aria-label")??"").startsWith(C)));for(let S of q){let C=Kr(S);if(C===void 0)continue;let M=S.closest('[class*="modelEntry"]')??C,w=Qe(M,r.modelId);w.length!==0&&H.push({container:ry(S),row:M,modelId:w,card:C})}Fo(e,hy(H,b,r),{t:t.t,onRequest:S=>Su(n,t,S,by(e,S,b,r))});let ne=new Set(H.map(S=>S.container));for(let[S,C]of n.mounted)ne.has(S)||(Fr(S),hs(S),C.editor.unmount(),n.mounted.delete(S));if(n.pending.size>0){let S=new Map;for(let M of H){let w=y(M.card);if(w===void 0)continue;let k=S.get(w.route);k===void 0&&S.set(w.route,k=new Set),k.add(M.modelId)}let C=new Map;for(let[M,w]of n.pending){if(!$n(b,M))continue;let k=S.get(M),R=[...w.keys()].filter(I=>!k?.has(I));R.length>0&&C.set(M,new Set(R))}for(let[M,w]of C){let k=n.missedScans.get(M);if(k!==void 0)for(let R of w)k.has(R)&&(Vn(n,M,R,void 0),k.delete(R),w.delete(R))}n.missedScans=C}else n.missedScans=new Map;let K=new Set(H.map(S=>S.card));for(let S of K){let C=y(S);if(C===void 0)continue;let M=C.route,w=Ey(S,r);w===void 0?n.signalsUnavailable=!0:(n.signalsUnavailable=!1,Jn(w.submit,n.submitWired,()=>{let k=un(S,b,r)?.route??M;n.committing.add(k),St(n)}),Jn(w.cancel,n.cancelWired,()=>{let k=un(S,b,r)?.route??M;Xb(n,k)}))}H.forEach((S,C)=>{let M=S.container;if(M===void 0)return;let w=y(S.card);if(w===void 0)return;let{route:k,staged:R}=w,I=b[k]??{},{savedModelIds:D,unsetModelIds:W,singletonById:N}=x(k),V=N.get(S.modelId)??[],ie=R||!D.has(S.modelId),re=ie?n.pending.get(k)?.get(S.modelId)?.efforts:void 0,oe=ie?re==="keep"?void 0:re:Mo(V,S.modelId),ae=!ie&&W.has(S.modelId),de=ie?n.pending.get(k)?.get(S.modelId)?.input:Lo(V,S.modelId),he=ie?n.pending.get(k)?.get(S.modelId)?.imageGen:Pa(V,S.modelId),te=ie?n.pending.get(k)?.get(S.modelId)?.compat:Ao(V,S.modelId),ue=ie?n.pending.get(k)?.get(S.modelId)?.defaultEffort??void 0:Co(V,S.modelId),Te=ie?Qe(S.row,r.modelName):"",Le=ie?Te.length>0?Te:void 0:Ro(V,S.modelId),He=R?Qe(S.card,r.apiProtocol):"",Y=R?Qe(S.card,r.baseUrl):"",B=R&&He.length>0?He:typeof I.api=="string"?I.api:void 0,J=R&&Y.length>0?Y:typeof I.baseURL=="string"?I.baseURL:void 0,Z={route:k,routeDisplayName:R?k:typeof I.displayName=="string"?I.displayName:k,...B===void 0?{}:{routeApi:B},...J===void 0?{}:{routeBaseURL:J},modelId:S.modelId,...Le===void 0?{}:{modelName:Le},...oe===void 0?{}:{efforts:oe},...ae?{effortsUnset:ae}:{},...de===void 0?{}:{input:de},...he?{imageGen:!0}:{},...te===void 0?{}:{compat:te},...ue===void 0?{}:{defaultEffort:ue},index:C,staged:ie,officialInputTypes:ni(M),api:{...Ho(t.api,void 0,(T,_,F,Q,ve,we,A)=>{Vn(n,T,_,F,Q,vs(M,ve,r.inputImage),we,A)},(T,_,F)=>{gu(n,T,_,{...F,input:vs(M,F.input,r.inputImage)})},T=>{Jb(n,T,S.modelId)},()=>(un(S.card,b,r)?.staged??R)||!D.has(S.modelId)),fillCapacities:(T,_)=>{ku(M,r,{...T===void 0?{}:{contextWindow:T},..._===void 0?{}:{maxTokens:_}})},readCapacities:()=>cy(M,r),setCapacities:T=>{uy(M,r,T)}},readOnly:p.writable!==!0,t:t.t};Ts(M),ly(M);let fe=n.mounted.get(M);if(fe!==void 0){vy(fe.props,Z)||(fe.props=Z,fe.editor.render(Z));return}if(yy(M))return;Xn(Kr(M)??S.card,Lu);let u=t.mount(M,Z);n.mounted.set(M,{editor:u,props:Z})})},"editor reconcile")}var si=['[class*="rowCard"]','[class*="setupCard"]','[class*="addCard"]','[class*="modelEntry"]','[class*="modelAdvanced"]','[class*="modelList"]','[class*="addBlock"]','p[class*="savedNotice"]'].join(","),Ky=[`[data-plugin="${ke}"]`,".bre-effort-slot",".bre-keys-host",".bre-create-host",".bre-editor-tabs",".bre-provider-balance",".bre-auto-effort",".bre-auto-effort-note",".bre-config-host",".bre-drag-ghost",".bre-drop-line",".bre-drag-grip",".bre-provider-switch"].join(",");function Wu(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function Rs(e){let t=Wu(e);return t!==null&&t.closest(Ky)!==null}function Bu(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=e;return Rs(t)?!1:t.matches(si)||t.querySelector(si)!==null}function Gu(e){return e.some(t=>{if(Rs(t.target))return!1;let n=Wu(t.target);if(t.type==="childList"){let r=[...Array.from(t.addedNodes),...Array.from(t.removedNodes)];return r.length>0&&r.every(Rs)?!1:n!==null&&n.closest(si)!==null?!0:r.some(Bu)}return n!==null&&n.closest(si)!==null?!0:t.type==="attributes"&&Bu(t.target)})}var Hs=require("react");var se=require("react"),Qu=require("react-dom");var lt=require("react"),zu=require("react-dom"),Mt=require("react/jsx-runtime"),Uu=6,By=292,di=8,Wy=52;function ju(e,t){let n=e.getBoundingClientRect(),r=t*Wy+46,o=window.innerWidth||0,i=window.innerHeight||0,a=Math.max(di,Math.min(n.left,o-By-di)),s=n.bottom+Uu,d=n.top-Uu-r,l=i>0&&s+r>i-di&&d>di?d:s;return{left:a,top:l}}function $u(e){let{anchor:t,label:n,options:r,selected:o,onPick:i,onClose:a}=e,[s,d]=(0,lt.useState)(()=>ju(t,r.length)),l=(0,lt.useRef)(null),c=(0,lt.useRef)([]);(0,lt.useLayoutEffect)(()=>{let p=()=>{d(ju(t,r.length))};return p(),window.addEventListener("resize",p),window.addEventListener("scroll",p,!0),()=>{window.removeEventListener("resize",p),window.removeEventListener("scroll",p,!0)}},[t,r.length]),(0,lt.useEffect)(()=>{let p=Math.max(0,r.findIndex(m=>m.value===o));c.current[p]?.focus()},[r,o]),(0,lt.useEffect)(()=>{let p=m=>{let b=m.target;b instanceof Node&&l.current?.contains(b)!==!0&&(t.contains(b)||a())};return document.addEventListener("pointerdown",p,!0),()=>{document.removeEventListener("pointerdown",p,!0)}},[t,a]);let f=(0,lt.useCallback)(p=>{if(r.length===0)return;let m=(p+r.length)%r.length;c.current[m]?.focus()},[r.length]),h=p=>{let m=c.current.findIndex(b=>b===document.activeElement);if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),a();return}if(p.key==="ArrowDown"){p.preventDefault(),f(m+1);return}if(p.key==="ArrowUp"){p.preventDefault(),f(m<0?r.length-1:m-1);return}if(p.key==="Home"){p.preventDefault(),f(0);return}p.key==="End"&&(p.preventDefault(),f(r.length-1))};return(0,zu.createPortal)((0,Mt.jsxs)("div",{ref:l,className:"bre-protocol-menu",style:{left:s.left,top:s.top},onKeyDown:h,children:[(0,Mt.jsx)("p",{className:"bre-protocol-menu-title",children:n}),(0,Mt.jsx)("ul",{className:"bre-protocol-menu-list",role:"listbox","aria-label":n,children:r.map((p,m)=>{let b=p.value===o;return(0,Mt.jsx)("li",{children:(0,Mt.jsx)("button",{ref:g=>{c.current[m]=g},type:"button",role:"option","aria-selected":b,"data-protocol-value":p.value,className:"bre-protocol-option",tabIndex:-1,onClick:()=>{i(p.value)},children:(0,Mt.jsxs)("span",{className:"bre-protocol-option-text",children:[(0,Mt.jsx)("span",{className:"bre-protocol-option-title",children:p.title}),(0,Mt.jsx)("span",{className:"bre-protocol-option-hint",children:p.hint})]})})},p.value)})})]}),document.body)}var U=require("react/jsx-runtime"),Gy=200,Uy=["M8 3.9v8.2","M3.9 8h8.2"],Vu="M3.9 8.35 6.6 11.05 12.1 5.5",jy=["M5.75 5.75V4.1A1.6 1.6 0 0 1 7.35 2.5h4.55a1.6 1.6 0 0 1 1.6 1.6v4.55a1.6 1.6 0 0 1-1.6 1.6h-1.65","M4.1 5.75h4.55a1.6 1.6 0 0 1 1.6 1.6v4.55a1.6 1.6 0 0 1-1.6 1.6H4.1a1.6 1.6 0 0 1-1.6-1.6V7.35a1.6 1.6 0 0 1 1.6-1.6Z"],zy=1600;async function $y(e){try{if(navigator.clipboard?.writeText!==void 0)return await navigator.clipboard.writeText(e),!0}catch{}if(typeof document>"u")return!1;try{let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="-1000px",t.style.opacity="0",document.body.appendChild(t),t.select();let n=document.execCommand("copy");return t.remove(),n}catch{return!1}}function Cs({paths:e}){return(0,U.jsx)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:e.map(t=>(0,U.jsx)("path",{d:t},t))})}function Vy(e,t){return e.masked!==void 0?e.masked:e.configured===!1?t("keysMissing"):"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}function Yu(e){return e.alias??e.masked??e.ref}function Yy(e,t){return e.models===void 0?t("keysScopeAll"):e.models.length===0?t("keysScopeNone"):t("keysScopeCount",{count:e.models.length})}var Zu=["openai-completions","openai-responses","anthropic-messages"],Ju={openai:null,anthropic:null},Jy=2e3,Xy=150,Qy=300,Zy=1500,ev=new Intl.Collator("en",{numeric:!0,sensitivity:"base"});function tv(e,t){return Zu.filter(n=>n===t?!0:(e[zo(n)]??"").length>0)}function ef(e,t){return t(e==="anthropic-messages"?"keysProtocolAnthropic":e==="openai-responses"?"keysProtocolResponses":e==="openai-completions"?"keysProtocolOpenAI":"keysProtocolDefault")}function nv(e,t){return t(e==="anthropic-messages"?"keysProtocolAnthropicHint":e==="openai-responses"?"keysProtocolResponsesHint":e==="openai-completions"?"keysProtocolOpenAIHint":"keysProtocolDefaultHint")}function Xu(e,t,n,r=!1){return[void 0,...r?Zu:tv(e,t)].map(i=>({value:i??"",title:ef(i,n),hint:nv(i,n)}))}function li(e){let{route:t,t:n,draft:r}=e,o=e.client??Ge,[i,a]=(0,se.useState)(()=>o.cached?.(t)?.entries),[s,d]=(0,se.useState)(()=>o.cached?.(t)?.models??[]),[l,c]=(0,se.useState)(void 0),[f,h]=(0,se.useState)(!1),p=i===void 0&&l===void 0;(0,se.useEffect)(()=>{if(h(!1),!p)return;let A=setTimeout(()=>h(!0),Gy);return()=>clearTimeout(A)},[p,t]);let[m,b]=(0,se.useState)(!1),[g,y]=(0,se.useState)(void 0),[v,x]=(0,se.useState)(""),[H,q]=(0,se.useState)(""),[ne,K]=(0,se.useState)([]),[S,C]=(0,se.useState)(void 0);(0,se.useEffect)(()=>{r===!0&&y({kind:"add"})},[r]);let[M,w]=(0,se.useState)(void 0),[k,R]=(0,se.useState)(void 0),[I,D]=(0,se.useState)(void 0),W=(0,se.useRef)(void 0);(0,se.useEffect)(()=>()=>{W.current!==void 0&&clearTimeout(W.current)},[]);let[N,V]=(0,se.useState)(void 0),[ie,re]=(0,se.useState)(()=>o.cached?.(t)?.endpoints??Ju),[oe,ae]=(0,se.useState)(!1),de=(0,se.useRef)(!1);(0,se.useEffect)(()=>{de.current=oe},[oe]);let he=(0,se.useRef)(0),te=(0,se.useCallback)((A,z)=>{if(!A.ok){c({kind:"error",text:A.error??n("keysUnreachable")});return}a(A.entries),d(A.models??[]),re(A.endpoints),ae(A.probing===!0),c(z===void 0?void 0:{kind:"status",text:z})},[n]),ue=(0,se.useRef)(t);ue.current=t,(0,se.useEffect)(()=>(ue.current=t,()=>{ue.current=void 0}),[t]);let Te=(0,se.useCallback)(async(A,z=!1)=>{let le=o.cached?.(A)!==void 0,xe=await o.list(A,z?{preferCache:!0}:void 0);ue.current===A&&(le&&!xe.ok||te(xe,void 0))},[te,o]);(0,se.useEffect)(()=>{Te(t,!0)},[Te,t]),(0,se.useEffect)(()=>{let A,z,le=()=>{A===void 0&&(A=setTimeout(()=>{A=void 0,Te(t),z===void 0&&(z=setTimeout(()=>{z=void 0,!de.current&&Te(t)},Zy))},Qy))};return document.addEventListener(Tr,le),()=>{document.removeEventListener(Tr,le),A!==void 0&&clearTimeout(A),z!==void 0&&clearTimeout(z)}},[Te,t]),(0,se.useEffect)(()=>{if(!oe){he.current=0;return}let A=!0,z=setInterval(()=>{if(he.current+=1,he.current>Xy){ae(!1);return}(async()=>{let le=await o.list(t);!A||ue.current!==t||(le.ok?(te(le,void 0),le.probing!==!0&&c({kind:"status",text:n("keysProbeDone")})):ae(!1))})()},Jy);return()=>{A=!1,clearInterval(z)}},[te,o,oe,t]),(0,se.useEffect)(()=>{let A=!0,z=0,le=xe=>{let Se=xe.detail,me=Se?.route;if(!A||ue.current!==t||me!==void 0&&me!==t)return;let Pe=++z;if(typeof Se?.openai=="string"&&typeof Se.anthropic=="string"){re({openai:Se.openai||null,anthropic:Se.anthropic||null});return}(async()=>{let je=o.endpoints!==void 0?await o.endpoints(t):await o.list(t);!A||ue.current!==t||z!==Pe||je.ok&&re(je.endpoints??Ju)})().catch(()=>{})};return document.addEventListener(Er,le),()=>{A=!1,document.removeEventListener(Er,le)}},[o,t]);let Le=()=>{y(void 0),x(""),q(""),K([]),C(void 0)},He=(0,se.useCallback)(async(A,z)=>{let le=g,xe=t;b(!0),w(void 0);try{let Se=await A();if(ue.current!==xe)return;te(Se,z),Se.ok&&le!==void 0&&le.kind!=="add"&&!Se.entries.some(me=>me.ref===le.ref)&&Le()}finally{b(!1)}},[te,g,t]),Y=(A,z)=>{y({kind:A,ref:z.ref}),x(A==="alias"?z.alias??"":""),q(""),K((z.models??[]).filter(le=>s.includes(le))),C(void 0),w(void 0)},B=()=>{if(m||g===void 0)return;let A=g.kind,z=g.ref;if(A!=="alias"&&A!=="scope"&&!Ct(H))return;let le=Mc(v),xe=S,Se=t,me=()=>ue.current!==Se;b(!0),(async()=>{try{if(A==="add"){let je=new Set((i??[]).map(Ae=>Ae.ref)),ft=await o.add(t,H,le);if(me())return;if(!ft.ok){te(ft,n("keysAdded"));return}if(te(ft,n("keysAdded")),Le(),xe===void 0)return;let Qt=ft.entries.find(Ae=>Ae.ref===ft.addedRef)??ft.entries.find(Ae=>!je.has(Ae.ref)),En=Qt===void 0?{ok:!1}:await o.setProtocol(t,Qt.ref,xe);me()||te(En,n("keysAdded"));return}if(z===void 0)return;if(A==="scope"){let je=await o.setScope(t,z,ne.length===0?void 0:ne);me()||(te(je,n("keysScopeSaved")),je.ok&&Le());return}let Pe=A==="alias"?await o.rename(t,z,le):await o.replace(t,z,H);me()||(te(Pe,n(A==="alias"?"keysRenamed":"keysReplaced")),Pe.ok&&Le())}finally{b(!1)}})()},J=A=>{K(z=>z.includes(A)?z.filter(le=>le!==A):[...z,A])},Z=(0,se.useMemo)(()=>[...new Set(s)].sort(ev.compare),[s]),fe=(0,se.useMemo)(()=>new Set(ne),[ne]),u=()=>{if(g===void 0)return null;let A=g.kind,z=A==="add"||A==="value",le=A==="scope",xe=A==="scope"&&g?.ref!==void 0?i?.find(me=>me.ref===g.ref)?.auto===!0:!1,Se=z&&H.length>0&&!Ct(H);return(0,U.jsxs)("div",{className:"bre-keys-form",children:[le?(0,U.jsx)("div",{className:"bre-keys-chips",role:"group","aria-label":n("keysScope"),children:Z.length===0?(0,U.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeEmpty")}):Z.map(me=>{let Pe=fe.has(me);return(0,U.jsx)("button",{type:"button",className:Pe?"bre-keys-chip is-selected":"bre-keys-chip","aria-pressed":Pe,disabled:m,onClick:()=>J(me),children:me},me)})}):(0,U.jsxs)("div",{className:"bre-keys-form-fields",children:[A==="value"?null:(0,U.jsx)("input",{className:"bre-text-input bre-keys-name",type:"text",value:v,placeholder:n("keysAliasPlaceholder"),"aria-label":n("keysAlias"),disabled:m,autoFocus:A==="alias",onChange:me=>x(me.target.value)}),z?(0,U.jsx)("input",{className:"bre-text-input bre-keys-secret",type:"password",autoComplete:"new-password",spellCheck:!1,value:H,placeholder:n(A==="add"?"keysValuePlaceholder":"keysNewValuePlaceholder"),"aria-label":n("keysValue"),"aria-invalid":Se,disabled:m,autoFocus:!0,onChange:me=>q(me.target.value)}):null]}),A==="add"?(0,U.jsx)("div",{className:"bre-keys-chips",role:"group","aria-label":n("keysProtocolCreate"),children:Xu(ie,void 0,n,r===!0).map(me=>{let Pe=me.value===""?void 0:me.value,je=S===Pe;return(0,U.jsx)("button",{type:"button",className:je?"bre-keys-chip is-selected":"bre-keys-chip","aria-pressed":je,title:me.hint,disabled:m,onClick:()=>C(Pe),children:me.title},me.value)})}):null,A==="add"?(0,U.jsx)("p",{className:"bre-keys-hint",children:n("keysProtocolCreateHint")}):null,le?(0,U.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeHint")}):null,le&&xe?(0,U.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeAutoHint")}):null,Se?(0,U.jsx)("p",{className:"bre-effort-message bre-error",role:"alert",children:n("keysAddIllegal")}):null,(0,U.jsxs)("div",{className:"bre-keys-form-actions",children:[le?(0,U.jsx)("button",{type:"button",className:"bre-link-button bre-keys-allmodels",disabled:m,onClick:()=>K([]),children:n("keysScopeAll")}):null,(0,U.jsx)("button",{type:"button",className:"bre-link-button",disabled:m,onClick:Le,children:n("keysCancel")}),(0,U.jsx)("button",{type:"button",className:"bre-primary-button",disabled:m||z&&!Ct(H),onClick:B,children:n(A==="add"?"keysAddConfirm":"keysSave")})]})]})},T=()=>g?.kind==="add"?(0,U.jsx)("li",{className:"bre-keys-form-row",children:u()}):(0,U.jsx)("li",{className:"bre-keys-add-row",children:(0,U.jsxs)("button",{type:"button",className:"bre-keys-add",disabled:m,onClick:()=>{y({kind:"add"}),x(""),q(""),K([]),w(void 0)},children:[(0,U.jsx)("span",{className:"bre-keys-add-mark","aria-hidden":"true",children:(0,U.jsx)(Cs,{paths:Uy})}),n("keysAdd")]})}),_=async A=>{if(I!==void 0)return;let z=t;D(A.ref);try{let le=await o.reveal(t,A.ref);if(ue.current!==z)return;if(le===void 0){c({kind:"error",text:n("keysCopyFailed")});return}let xe=await $y(le);if(ue.current!==z)return;if(!xe){c({kind:"error",text:n("keysCopyFailed")});return}c(void 0),R(A.ref),W.current!==void 0&&clearTimeout(W.current),W.current=setTimeout(()=>{W.current=void 0,R(void 0)},zy)}finally{D(void 0)}},F=(A,z)=>{let le=z===""?void 0:z;V(void 0),He(()=>o.setProtocol(t,A.ref,le),n("keysProtocolSaved"))},Q=N===void 0?void 0:i?.find(A=>A.ref===N.ref);if(i===void 0)return l===void 0?(0,U.jsx)("div",{className:"bre-keys","aria-busy":"true",children:f?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)("ul",{className:"bre-keys-list bre-keys-skeleton","aria-hidden":"true",children:[(0,U.jsxs)("li",{className:"bre-keys-skeleton-row",children:[(0,U.jsx)("span",{className:"bre-keys-skeleton-dot"}),(0,U.jsx)("span",{className:"bre-keys-skeleton-bar is-name"}),(0,U.jsx)("span",{className:"bre-keys-skeleton-bar is-mask"})]}),(0,U.jsx)("li",{className:"bre-keys-skeleton-row is-add",children:(0,U.jsx)("span",{className:"bre-keys-skeleton-bar"})})]}),(0,U.jsx)("p",{className:"bre-keys-sr",role:"status",children:n("keysLoading")})]}):null}):(0,U.jsxs)("div",{className:"bre-keys",children:[(0,U.jsx)("p",{className:"bre-effort-message bre-"+l.kind,role:l.kind==="error"?"alert":"status",children:l.text}),(0,U.jsx)("ul",{className:"bre-keys-list",children:T()})]});let ve=i.reduce((A,z)=>z.enabled?A+1:A,0),we=r===!0?null:(0,U.jsx)("button",{type:"button",className:"bre-link-button bre-keys-probe",disabled:m||oe||i.length<2,title:i.length<2?n("keysProbeSingle"):n("keysProbeHint"),onClick:()=>{He(()=>o.probe(t),void 0)},children:n(oe?"keysProbing":"keysProbe")});return(0,U.jsxs)("div",{className:"bre-keys",children:[we===null?null:e.probeHost===void 0?(0,U.jsx)("div",{className:"bre-keys-probe-row",children:we}):(0,Qu.createPortal)(we,e.probeHost),(0,U.jsxs)("ul",{className:"bre-keys-list",children:[i.map(A=>{let z=Yu(A),le=A.enabled&&ve<=1;return(0,U.jsxs)(se.Fragment,{children:[(0,U.jsxs)("li",{className:A.enabled?"bre-keys-row":"bre-keys-row is-off","data-state":A.configured===!1?"missing":"ready",children:[(0,U.jsx)("button",{type:"button",className:A.enabled?"bre-keys-toggle is-on":"bre-keys-toggle","aria-pressed":A.enabled,"aria-label":n(A.enabled?"keysDisable":"keysEnable",{name:z}),title:n(A.enabled?"keysDisable":"keysEnable",{name:z}),disabled:m||le,onClick:()=>{He(()=>o.setEnabled(t,A.ref,!A.enabled),void 0)},children:(0,U.jsx)("span",{className:"bre-keys-toggle-mark","aria-hidden":"true",children:(0,U.jsx)(Cs,{paths:[Vu]})})}),(0,U.jsxs)("span",{className:"bre-keys-value",children:[A.alias===void 0?null:(0,U.jsx)("span",{className:"bre-keys-alias",children:A.alias}),(0,U.jsx)("span",{className:A.alias===void 0?"bre-keys-mask bre-keys-mask-plain":"bre-keys-mask",children:Vy(A,n)}),(0,U.jsx)("button",{type:"button",className:k===A.ref?"bre-keys-copy is-copied":"bre-keys-copy","aria-label":n("keysCopy",{name:z}),title:k===A.ref?n("keysCopied"):n("keysCopy",{name:z}),disabled:m||I===A.ref||A.configured===!1,onClick:()=>{_(A)},children:(0,U.jsx)(Cs,{paths:k===A.ref?[Vu]:jy})})]}),(0,U.jsx)("span",{className:M===A.ref?"bre-keys-actions is-confirming":"bre-keys-actions",children:M===A.ref?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("button",{type:"button",className:"bre-link-button bre-keys-danger",disabled:m,onClick:()=>{He(()=>o.remove(t,A.ref),n("keysRemoved"))},children:n("keysConfirmRemove")}),(0,U.jsx)("button",{type:"button",className:"bre-link-button",disabled:m,onClick:()=>w(void 0),children:n("keysCancel")})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("span",{className:"bre-keys-protocol-wrap",children:(0,U.jsxs)("button",{type:"button",className:"bre-keys-protocol","aria-haspopup":"listbox","aria-expanded":N?.ref===A.ref,"aria-label":n("keysProtocolLabel",{name:z}),title:n("keysProtocolLabel",{name:z}),disabled:m,onClick:xe=>{let Se=xe.currentTarget;V(me=>me?.ref===A.ref?void 0:{ref:A.ref,anchor:Se}),w(void 0)},children:[(0,U.jsx)("span",{className:"bre-keys-protocol-label",children:ef(A.protocol,n)}),(0,U.jsx)("span",{className:"bre-keys-protocol-caret","aria-hidden":"true",children:"\u203A"})]})}),r===!0?null:(0,U.jsx)("button",{type:"button",className:"bre-link-button bre-keys-scope",disabled:m,title:n("keysScope",{name:z}),onClick:()=>Y("scope",A),children:Yy(A,n)}),(0,U.jsx)("button",{type:"button",className:"bre-link-button",disabled:m,onClick:()=>Y("alias",A),children:n("keysAlias")}),(0,U.jsx)("button",{type:"button",className:"bre-link-button",disabled:m,onClick:()=>Y("value",A),children:n("keysEdit")}),(0,U.jsx)("button",{type:"button",className:"bre-link-button",disabled:m,onClick:()=>{w(A.ref),y(void 0)},children:n("keysRemove")})]})})]}),g!==void 0&&g.ref===A.ref?(0,U.jsx)("li",{className:"bre-keys-form-row",children:u()}):null]},A.ref)}),T()]}),r===!0?(0,U.jsx)("p",{className:"bre-keys-note",children:n("keysDraftHint")}):null,l===void 0?null:(0,U.jsx)("p",{className:"bre-effort-message bre-"+l.kind,role:l.kind==="error"?"alert":"status",children:l.text}),N===void 0||Q===void 0?null:(0,U.jsx)($u,{anchor:N.anchor,label:n("keysProtocolLabel",{name:Yu(Q)}),options:Xu(ie,Q.protocol,n,r===!0),selected:Q.protocol??"",onPick:A=>F(Q,A),onClose:()=>V(void 0)})]})}var fn="bre-key-managed",rv="bre-keys-host",tf="bre-keys-probe-host",Ns="data-bre-key-host",ov="data-bre-key-input",ci="data-bre-region",zt=new WeakMap;function iv(e){let t=e.querySelector(`input[${ov}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function nf(e){let t=zt.get(e)?.host;if(t!==void 0&&t.isConnected)return t;let n=e.nextElementSibling;return n instanceof HTMLElement&&n.hasAttribute(Ns)?n:void 0}function rf(e,t){let n=t.route;if(n===void 0||n.length===0||iv(e)===void 0||e.parentElement===null)return;We(e,fn,!0);let r=zt.get(e),o=nf(e);o===void 0&&(r!==void 0&&of(e,r),o=e.ownerDocument.createElement("div"),o.className=rv,e.after(o)),be(o,Ns,n);let i=e.getAttribute(ci);i===null?o.hasAttribute(ci)&&o.removeAttribute(ci):be(o,ci,i);let a=zt.get(e),s=a?.probeHost??e.ownerDocument.createElement("span");a===void 0&&(s.className=tf),s.parentElement!==e&&e.appendChild(s);let d=()=>(0,Hs.createElement)(Be,{fallbackText:t.t("keysPanelFailed")},(0,Hs.createElement)(li,{route:n,t:t.t,client:t.client,probeHost:s}));if(a!==void 0&&a.route===n){(a.t!==t.t||a.client!==t.client)&&(a.t=t.t,a.client=t.client,a.mount.root.render(d()));return}a!==void 0&&(zt.delete(e),a.mount.root.unmount()),zt.set(e,{route:n,host:o,probeHost:s,mount:Xe(o,d(),{sync:!0}),t:t.t,client:t.client})}function of(e,t){zt.delete(e),Ne(t.mount),t.probeHost.remove()}function ui(e){We(e,fn,!1);let t=zt.get(e);t!==void 0&&of(e,t),nf(e)?.remove();for(let n of Array.from(e.children))n.classList.contains(tf)&&n.remove()}function af(){for(let e of Array.from(document.querySelectorAll(`[${Ns}]`))){let t=e.previousElementSibling;t instanceof HTMLElement&&zt.has(t)?ui(t):e.remove()}}var sf="http://www.w3.org/2000/svg",av="data-bre-icon";function sv(e){let t=document.createElementNS(sf,"path");return t.setAttribute("d",e),t}function fi(e,t){let n=document.createElementNS(sf,"svg");return n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("width","16"),n.setAttribute("height","16"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.5"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true"),n.setAttribute("focusable","false"),n.setAttribute(av,e),n.append(...t.map(sv)),n}var mn="bre-key-field",cf="bre-key-eye",Ur="data-bre-key-input",uf="data-bre-eye-show",ff="data-bre-eye-hide",df=["M1.5 8S4 3.75 8 3.75 14.5 8 14.5 8 12 12.25 8 12.25 1.5 8 1.5 8Z","M6.2 8a1.8 1.8 0 1 0 3.6 0 1.8 1.8 0 0 0-3.6 0Z"],pi=new WeakMap,pn=new WeakMap;function mi(e){let t=e.querySelector(`input[${Ur}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function Is(e){for(let t of Array.from(e.children))if(t instanceof HTMLButtonElement&&t.classList.contains(cf))return t}function pf(e){let t=mi(e);t!==void 0&&(be(t,Ur,""),We(e,mn,!0))}function mf(e,t){let n=mi(e);if(n===void 0){Qn(e);return}pi.get(e)?.route!==t.route&&pn.delete(e),pi.set(e,t),be(n,Ur,""),We(e,mn,!0);let r=Is(e)??lv(e);be(r,uf,t.t("keyRevealShow")),be(r,ff,t.t("keyRevealHide")),Os(r,n)}function Qn(e){let t=Is(e);t!==void 0&&t.remove(),pi.delete(e),We(e,mn,!1);let n=e.querySelector(`input[${Ur}]`);n instanceof HTMLInputElement&&(n.removeAttribute(Ur),n.type="password");let r=pn.get(e);pn.delete(e),r!==void 0&&n instanceof HTMLInputElement&&n.value===r&&jr(n,"")}async function dv(e){try{let t=await fetch(`${po}?route=${encodeURIComponent(e)}`,{method:"GET",cache:"no-store",credentials:"same-origin"});if(!t.ok)return;let n=await t.json();return n===null||typeof n!="object"||n.ok!==!0?void 0:typeof n.key=="string"&&n.key.length>0?n.key:void 0}catch{return}}function Os(e,t){let n=t.type!=="password";be(e,"aria-pressed",n?"true":"false");let r=e.getAttribute(n?ff:uf);r!==null&&(be(e,"aria-label",r),be(e,"title",r)),yt(e,t.disabled)}function jr(e,t){let n=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");n?.set===void 0?e.value=t:n.set.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0}))}function lv(e){let t=document.createElement("button");t.type="button",t.className=cf,t.append(lf("eye"),lf("eye-off"));let n=async()=>{let r=mi(e),o=pi.get(e);if(r===void 0||o===void 0||t.hasAttribute("aria-busy"))return;if(r.type!=="password"){let a=pn.get(e);pn.delete(e),a!==void 0&&r.value===a&&jr(r,""),r.type="password",Os(t,r);return}let i=o.route;if(i!==void 0&&pn.get(e)===void 0&&r.value.length===0){be(t,"aria-busy","true");let a;try{a=await(o.loadKey??dv)(i)}catch{a=void 0}if(t.hasAttribute("aria-busy")&&t.removeAttribute("aria-busy"),a===void 0){let s=o.t("keyRevealFailed");be(t,"aria-label",s),be(t,"title",s);return}if(Is(e)!==t||!t.isConnected||mi(e)!==r||r.value.length>0)return;pn.set(e,a),jr(r,a)}r.type="text",Os(t,r)};return t.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation(),n()}),e.append(t),t}function lf(e){let t=e==="eye-off"?[...df,"M2.5 13.5 13.5 2.5"]:df;return fi(e,t)}var _s="bre-editor-tabs",cv="bre-editor-tab",gi="data-bre-tab-id",$r="bre-tabbed",Ot="data-bre-tab",gf="data-bre-provider",ct="data-bre-region",zr="data-bre-editor-body",nr="data-bre-footer",uv="row",fv="path",Vr="data-bre-details";var pv=".bre-headers",mv=".bre-fingerprint",gv="data-bre-fingerprint",$t="provider",Zn="models",er="fingerprint",tr="advanced",hv=[$t,Zn,tr,er],bv="none",hf=hv,bf=_s,yf=cv,vf=gi,hi='[class*="editorActions"], [class*="modelList"], [class*="modelCatalog"], [class*="modelEntry"]',yv='[class*="modelCatalog"], [class*="modelList"], [class*="modelEntry"]',wf='[class*="rowCard"], [class*="addCard"], li',vv='[class*="addPanel"]',Ps=".bre-create-host";function xf(){return{warned:new WeakSet}}function rr(e){return e===null?null:e.closest(wf)}function kf(e){let t=rr(e);return t!==null&&t.querySelector(Ps)!==null}function Ef(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.matches(vv)&&!t.hidden)return t;return e}function Tf(e,t){if(e.getAttribute(Ot)===t){Ds(e);return}let n=Go(e),r=e.getBoundingClientRect().top,o=n?.scrollTop??0;n!==void 0&&(n.style.overflowAnchor="none"),be(e,Ot,t),Ds(e),n!==void 0&&requestAnimationFrame(()=>{if(n.style.overflowAnchor="",n.scrollTop!==o)return;let i=e.getBoundingClientRect().top-r;i!==0&&(n.scrollTop+=i)})}function Fs(e,t,n){if(!e.isConnected)return;let r=new Set;for(let o of Array.from(e.querySelectorAll(hi))){let i=o.closest(wf);i!==null&&r.add(i)}for(let o of Array.from(e.querySelectorAll(`.${$r}`)))r.has(o)||bi(o);for(let o of r)try{Sv(o,t)}catch(i){n.warned.has(o)||(n.warned.add(o),console.warn("[bre] editor tabs: rolled a provider card back to the official layout:",i)),bi(o)}}function Sf(){for(let e of Array.from(document.querySelectorAll(`.${$r}`))){e.classList.remove($r),e.removeAttribute(Ot),e.removeAttribute(zr);for(let t of Array.from(e.querySelectorAll(`[${ct}]`)))t.removeAttribute(ct)}for(let e of Array.from(document.querySelectorAll(`[${Ot}]`)))e.removeAttribute(Ot);for(let e of Array.from(document.querySelectorAll(`[${ct}]`)))e.removeAttribute(ct);for(let e of Array.from(document.querySelectorAll(`[${zr}]`)))e.removeAttribute(zr);for(let e of Array.from(document.querySelectorAll(`[${nr}]`)))e.removeAttribute(nr);for(let e of Array.from(document.querySelectorAll(`details[${Vr}]`)))e.removeAttribute("open"),e.removeAttribute(Vr);for(let e of Array.from(document.querySelectorAll(`.${mn}`)))Qn(e);for(let e of Array.from(document.querySelectorAll(`.${fn}`)))ui(e);af()}function wv(e){for(let n of Array.from(e.children))if(n instanceof HTMLElement&&!n.matches('[class*="editorHeader"], [class*="editorTitle"], [class*="editorActions"], [class*="editorRoute"]')&&n.matches('[class*="editor"]')&&(n.querySelector(hi)!==null||n.querySelector("input, select")!==null))return n;let t=e.querySelector(hi);for(;t!==null&&t.parentElement!==e;)t=t.parentElement;return t!==null&&t!==e?t:void 0}function xv(e){let t={header:void 0,models:void 0,actions:void 0,fields:[]};Mf(e,t,0);let{actions:n,fields:r,header:o,models:i}=t;if(!(n===void 0||r.length===0)&&r.some(a=>a.querySelector("input, select, textarea")!==null))return{header:o,models:i,actions:n,fields:r}}var kv=4;function Mf(e,t,n){if(!(n>kv)){for(let r of Array.from(e.children))if(r instanceof HTMLElement&&!r.matches('[class*="bre-"], [data-plugin]')){if(t.header===void 0&&r.matches('[class*="editorHeader"], [class*="editorTitle"]')){t.header=r;continue}if(r.matches('[class*="editorActions"]')){t.actions??(t.actions=r);continue}if(r.matches(yv)){t.models??(t.models=r);continue}if(r.querySelector(hi)!==null){Mf(r,t,n+1);continue}if(r.querySelector('[class*="editorActions"]')!==null){t.actions??(t.actions=r);continue}if(r.querySelector("input, select, textarea")!==null){t.fields.push(r);continue}(r.matches("p, small, em, i")||r.matches('[class*="Hint"], [class*="error"]'))&&t.fields.push(r)}}}function Ev(e,t){if(!t.contains(e))return;be(e,nr,uv);let n=e.parentElement;for(;n!==null&&(be(n,nr,fv),n!==t);)n=n.parentElement}function Tv(e){let n=e.querySelector(`[${gf}]`)?.getAttribute(gf);return n==null||n===""?void 0:n}function Sv(e,t){let n=Ef(e),r=wv(n);if(r===void 0){bi(e);return}let o=xv(r);if(o===void 0){bi(e);return}let i=Array.from(n.querySelectorAll(pv)),a=i[0]??null,s=Tv(n);for(let h of o.fields)be(h,ct,$t),mf(h,{t:t.t,route:s}),rf(h,{t:t.t,route:s});o.header!==void 0&&be(o.header,ct,bv),o.models!==void 0&&be(o.models,ct,Zn),be(r,zr,""),n.querySelector(Ps)!==null&&Ev(o.actions,r);for(let h of i)be(h,ct,tr);let d=n.querySelector(mv);d!==null&&be(d,ct,er),Lv(r);let l=new Set([$t]);o.models!==void 0&&l.add(Zn),a!==null&&l.add(tr);let c=n.querySelector(Ps)!==null;d!==null&&!c&&d.getAttribute(gv)==="ready"&&l.add(er);let f=e.getAttribute(Ot)??$t;be(e,Ot,l.has(f)?f:$t),We(e,$r,!0),Mv(e,n,t,l)}function Mv(e,t,n,r){let o=t.querySelector(`.${_s}`);o!==null&&(be(o,"aria-label",n.t("editorTabsLabel")),Hr(gn(o,$t),n.t("editorTabProvider")),Hr(gn(o,Zn),n.t("editorTabModels")),Hr(gn(o,tr),n.t("editorTabAdvanced")),Hr(gn(o,er),n.t("editorTabFingerprint")),yt(gn(o,Zn),!r.has(Zn)),yt(gn(o,tr),!r.has(tr)),yt(gn(o,er),!r.has(er)),Ds(e,o))}function Ds(e,t){let n=t??Ef(e).querySelector(`.${_s}`);if(n===null)return;let r=e.getAttribute(Ot)??$t;for(let o of Array.from(n.querySelectorAll(`[${gi}]`)))be(o,"aria-selected",o.getAttribute(gi)===r?"true":"false")}function gn(e,t){for(let n of Array.from(e.children))if(n instanceof HTMLElement&&n.getAttribute(gi)===t)return n}function bi(e){e.classList.remove($r),e.removeAttribute(Ot),e.removeAttribute(zr);for(let t of Array.from(e.querySelectorAll(`[${ct}]`)))t.getAttribute(ct)===$t&&(Qn(t),ui(t)),t.removeAttribute(ct);for(let t of Array.from(e.querySelectorAll(`[${nr}]`)))t.removeAttribute(nr);Av(e)}function Lv(e){for(let t of Array.from(e.querySelectorAll("details")))t.hasAttribute("open")||(be(t,Vr,"closed"),be(t,"open",""))}function Av(e){for(let t of Array.from(e.querySelectorAll(`details[${Vr}]`)))t.removeAttribute("open"),t.removeAttribute(Vr)}var pp=require("react");var et=require("react");var Me=require("react");var Rv='p[class*="savedNotice"]',Rf="data-bre-saved-hidden",Cv="bre-auto-effort-note",Hv="data-bre-auto-effort-phase",Lf="bre-auto-effort-note-text",or=new Map,Af=new WeakMap,ir=null,yi=null;function Cf(e){let t=Array.from(e.querySelectorAll(Rv));for(let n of t){let r=n.textContent?.trim()??"";Af.get(n)!==r&&(Af.set(n,r),r.length>0&&If(r)),!or.has(n)&&(or.set(n,n.style.display),n.setAttribute(Rf,""),n.style.display="none")}for(let[n,r]of Array.from(or))n.isConnected&&t.includes(n)||(Nf(n,r),or.delete(n))}function Hf(){for(let[e,t]of Array.from(or))Nf(e,t);or.clear(),qs()}function Nf(e,t){e.style.display=t,e.removeAttribute(Rf)}function Of(e){If(e)}function If(e){if(ir!==null&&ir.isConnected&&ir.textContent===e)return;qs();let t=document.createElement("div");t.className=Cv,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute(Hv,"done"),t.innerHTML=`<span class="${Lf}"></span>`;let n=t.querySelector(`.${Lf}`);n!==null&&(n.textContent=e),t.style.setProperty("--bre-note-hold","3000ms"),document.body.append(t),ir=t,yi=setTimeout(()=>{qs()},3e3)}function qs(){yi!==null&&(clearTimeout(yi),yi=null),ir?.remove(),ir=null}var hn="data-bre-settle",Pf='[class*="rowActions"] > button:not(.bre-provider-switch):not(.bre-provider-delete)';var Lt=null,Ks=0,vi=0,Yr=!1,ar=null;function Df(e){return e.className.includes("dangerButton")?"remove":"edit"}function Bs(e,t){return Array.from(e.querySelectorAll(Pf)).find(r=>Df(r)===t)??null}function Nv(e){return typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function Ov(e){typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):clearTimeout(e)}function _f(e=document){Jr();let t=[];for(let n of Array.from(e.querySelectorAll(Pf))){if(n.disabled)continue;let r=n.closest("li")??n.parentElement;if(r===null)continue;let o=Df(n);t.some(i=>i.row===r&&i.role===o)||t.push({row:r,role:o})}t.length!==0&&(Lt=t,vi=Date.now(),Ks=vi+8e3,Iv(),Ff())}function Ws(){if(Lt===null)return;let e=Date.now();if(e>Ks){Jr();return}let t=0;if(Lt=Lt.filter(n=>{if(!n.row.isConnected)return!1;let r=Bs(n.row,n.role);return r===null||(r.disabled?(Yr=!0,t+=1,r.hasAttribute(hn)||r.setAttribute(hn,"")):Yr&&r.hasAttribute(hn)&&r.removeAttribute(hn)),!0}),Yr&&t===0){Jr();return}if(!Yr&&e-vi>1500){Jr();return}Ff()}function Ff(){ar!==null||Lt===null||(ar=Nv(()=>{ar=null,Ws()}))}function Iv(){if(Lt!==null)for(let e of Lt){let t=Bs(e.row,e.role);t!==null&&!t.hasAttribute(hn)&&t.setAttribute(hn,"")}}function qf(){Jr()}function Jr(){if(ar!==null&&(Ov(ar),ar=null),Lt!==null)for(let e of Lt){let t=Bs(e.row,e.role);t!==null&&t.removeAttribute(hn)}Lt=null,Yr=!1,Ks=0,vi=0}var ee=require("react/jsx-runtime"),Pv=["claude-cli/2.1.161 (external, cli)","claude-code/1.0.0","Kilo-Code/1.0"];function Kf(e,t){let n=()=>t.current+=1,r=Object.entries(e??{}).map(([o,i])=>({id:n(),name:o,value:i}));return r.length===0&&r.push({id:n(),name:"",value:""}),{rows:r}}function Bf(e){let t={},n=!1;for(let o of e.rows){let i=o.name.trim();i.length!==0&&(t[i]=o.value,i.toLowerCase()==="user-agent"&&(n=!0))}let r=e.userAgent?.trim();return!n&&r!==void 0&&r.length>0&&(t["user-agent"]=r),t}function Dv(e,t){let n=e??{},r=Object.keys(n);return r.length!==Object.keys(t).length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&t[o]===n[o])}function wi({route:e,api:t,t:n,onDismiss:r,deferred:o,extras:i,onCommitExtras:a,onResetExtras:s}){let d=(0,Me.useId)(),[l,c]=(0,Me.useState)(void 0),[f,h]=(0,Me.useState)({rows:[]}),[p,m]=(0,Me.useState)(!1),[b,g]=(0,Me.useState)(!1),[y,v]=(0,Me.useState)(!0),[x,H]=(0,Me.useState)(!1),[q,ne]=(0,Me.useState)(!1),[K,S]=(0,Me.useState)(void 0),[C,M]=(0,Me.useState)(void 0),[w,k]=(0,Me.useState)(!1),R=(0,Me.useRef)(0),I=(0,Me.useRef)(null),D=o!==void 0,W=o?.onDraft,N=(0,Me.useRef)(void 0);(0,Me.useEffect)(()=>{if(D&&N.current!==void 0)return;N.current=e;let Y=!0;return(async()=>{try{let B=await pe(t);if(!Y)return;let J=_a(B.namespace,e);c(J),h(Kf(J,R)),ne(B.writable!==!0)}catch{Y&&ne(!0)}finally{Y&&v(!1)}})(),()=>{Y=!1}},[t,e,D]),(0,Me.useEffect)(()=>{W!==void 0&&W(Bf(f))},[f,W]),(0,Me.useEffect)(()=>{let Y=!0;return(async()=>{try{let J=await(await fetch(Id,{method:"GET"})).json();Y&&J.ok===!0&&J.data!==void 0&&M(J.data)}catch{}})(),()=>{Y=!1}},[]),(0,Me.useEffect)(()=>{let Y=I.current;if(Y===null)return;let B=()=>{k(Y.dataset.breRegion==="advanced")};B();let J=new MutationObserver(B);return J.observe(Y,{attributes:!0,attributeFilter:["data-bre-region"]}),()=>{J.disconnect()}},[]);let V=()=>{h(Y=>({...Y,rows:[...Y.rows,{id:R.current+=1,name:"",value:""}]})),S(void 0)},ie=(Y,B)=>{h(J=>({...J,rows:J.rows.map(Z=>Z.id===Y?{...Z,...B}:Z)})),S(void 0)},re=Y=>{h(B=>({...B,rows:B.rows.filter(J=>J.id!==Y)})),S(void 0)},oe=()=>{h({rows:[{id:R.current+=1,name:"",value:""}]}),S(void 0)},ae=()=>{if(s?.(),h(Kf(l,R)),g(!1),S(void 0),o!==void 0){o.onCancel();return}w&&r?.()},de=async Y=>{if(H(!0),S(void 0),!Dv(l,Y)){_f();let fe;try{fe=await Ar(t,e,Y)}catch(u){fe={ok:!1,error:u instanceof Error?u.message:String(u)}}if(!fe.ok){H(!1),S({kind:"error",text:fe.error==="no-route"?n("headersNoRoute"):fe.error==="read-only"?n("headersReadOnly"):n("headersError",{error:fe.error})});return}c(Y)}if(g(!1),a!==void 0)try{await a()}catch{H(!1),S({kind:"error",text:n("camouflageError")});return}H(!1);let J=Object.keys(l??{}).length>0,Z=Object.keys(Y).length===0&&J?n("headersCleared"):n("headersSaved");if(w){Of(Z),r?.();return}S({kind:"success",text:Z})},he=Object.entries(l??{}),te=q||x,ue=w||D,Te=b||ue?f.rows.filter(Y=>Y.name.trim().length>0).length:he.length,Le=f.rows.some(Y=>Y.name.trim().length>0||Y.value.length>0),He=p||b||ue;return(0,ee.jsxs)("div",{className:"bre-headers",ref:I,"data-plugin":ke,"data-open":p?"1":"0",children:[(0,ee.jsx)("div",{className:"bre-headers-head",children:b||ue?(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)("span",{className:"bre-effort-title",children:n("headersTitle")}),Te===0?null:(0,ee.jsx)("span",{className:"bre-headers-count",children:Te}),q||!Le?null:(0,ee.jsx)("button",{type:"button",className:"bre-headers-clear",disabled:te,onClick:oe,children:n("headersClear")})]}):(0,ee.jsxs)("button",{type:"button",className:"bre-headers-disclosure","aria-expanded":p,"aria-label":`${n("headersTitle")} ${e}`,onClick:()=>{m(!p),S(void 0)},children:[(0,ee.jsx)("span",{className:"bre-effort-title",children:n("headersTitle")}),y||Te===0?null:(0,ee.jsx)("span",{className:"bre-headers-count",children:Te}),(0,ee.jsx)("span",{className:"bre-headers-chevron","aria-hidden":"true",children:"\u203A"})]})}),He?(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)("p",{className:"bre-effort-note",children:n("headersHint")}),C===void 0?null:(0,ee.jsxs)(ee.Fragment,{children:[C.environment.preferOfficialLayer?(0,ee.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictPatched")}):null,C.conflicts.length===0&&(C.headerConflicts?.length??0)===0?null:(0,ee.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictOrigin")}),C.environment.siblings.length===0?null:(0,ee.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictSiblings",{names:C.environment.siblings.map(Y=>Y.name).join(", ")})})]}),y?null:b||ue?(0,ee.jsxs)("div",{className:"bre-headers-edit",children:[(0,ee.jsxs)("div",{className:"bre-headers-columns","aria-hidden":"true",children:[(0,ee.jsx)("span",{children:n("headersName")}),(0,ee.jsx)("span",{children:n("headersValue")}),(0,ee.jsx)("span",{})]}),f.rows.map(Y=>(0,ee.jsxs)("div",{className:"bre-headers-row",children:[(0,ee.jsx)("input",{type:"text",className:"bre-text-input bre-headers-name",value:Y.name,disabled:te,placeholder:n("headersNamePlaceholder"),"aria-label":n("headersName"),onChange:B=>{ie(Y.id,{name:B.target.value})}}),(0,ee.jsx)("input",{type:"text",className:"bre-text-input bre-headers-value",value:Y.value,disabled:te,list:Y.name.trim().toLowerCase()==="user-agent"?d:void 0,placeholder:n("headersValue"),"aria-label":n("headersValue"),onChange:B=>{ie(Y.id,{value:B.target.value})}}),(0,ee.jsx)("button",{type:"button",className:"bre-headers-remove",disabled:te,"aria-label":`${n("headersRemove")} ${Y.name}`,title:n("headersRemove"),onClick:()=>{re(Y.id)},children:"\xD7"})]},Y.id)),(0,ee.jsx)("button",{type:"button",className:"bre-headers-add",disabled:te,onClick:V,children:n("headersAdd")}),(0,ee.jsx)("datalist",{id:d,children:Pv.map(Y=>(0,ee.jsx)("option",{value:Y},Y))})]}):(0,ee.jsxs)("div",{className:"bre-headers-rows",children:[he.length===0?(0,ee.jsx)("p",{className:"bre-effort-note",children:n("headersEmpty")}):he.map(([Y,B])=>(0,ee.jsxs)("div",{className:"bre-headers-row",children:[(0,ee.jsx)("span",{className:"bre-headers-name",children:Y}),(0,ee.jsx)("span",{className:"bre-headers-value bre-headers-masked",children:"\u2022".repeat(Math.min(B.length,24))})]},Y)),q?null:(0,ee.jsx)("div",{className:"bre-effort-actions",children:(0,ee.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:te,onClick:()=>{g(!0),S(void 0)},children:n("headersEdit")})})]})]}):null,!y&&(ue||b)?(0,ee.jsxs)(ee.Fragment,{children:[i,(0,ee.jsxs)("div",{className:"bre-effort-actions bre-headers-actions",children:[(0,ee.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:x,onClick:ae,children:n("headersCancel")}),D?null:(0,ee.jsx)("button",{type:"button",className:"bre-primary-button",disabled:te,onClick:()=>{de(Bf(f))},children:n("headersSave")})]})]}):null,K===void 0?null:(0,ee.jsx)("p",{className:"bre-effort-message bre-"+K.kind,role:K.kind==="error"?"alert":"status",children:K.text})]})}var Ce=require("react");var Ze=require("react/jsx-runtime"),_v=[{value:void 0,labelKey:"camouflageOff"},{value:"codex",labelKey:"camouflageCodex"},{value:"claude",labelKey:"camouflageClaude"}];function Fv(e){return e==="codex"||e==="claude"}function Wf(e){let t=e.data;if(typeof t!="object"||t===null)return;let n=t,r={},o=n.providers;if(typeof o=="object"&&o!==null&&!Array.isArray(o))for(let[i,a]of Object.entries(o))Fv(a)&&(r[i]=a);return{presets:["codex","claude"],providers:r,installed:n.installed===!0}}function Gs({t:e,value:t,installed:n,disabled:r=!1,onChange:o}){let i=(0,Ce.useId)(),a=`${i}-title`,s=`${i}-hint`;return(0,Ze.jsxs)("div",{className:"bre-camouflage","data-plugin":ke,"data-open":"1",title:e("camouflageHint"),children:[(0,Ze.jsx)("span",{className:"bre-effort-title",id:a,children:e("camouflageTitle")}),(0,Ze.jsx)("div",{className:"bre-camouflage-options",role:"radiogroup","aria-labelledby":a,"aria-describedby":s,children:_v.map(d=>(0,Ze.jsx)("button",{type:"button",role:"radio","aria-checked":t===d.value,className:"bre-camouflage-option","data-active":t===d.value?"1":"0",disabled:r,onClick:()=>{o(d.value)},children:e(d.labelKey)},d.value??"off"))}),(0,Ze.jsx)("span",{className:"bre-sr-only",id:s,children:e("camouflageHint")}),n?null:(0,Ze.jsx)("p",{className:"bre-camouflage-warn",children:e("camouflageUnavailable")})]})}function Us(e,t){let[n,r]=(0,Ce.useState)(void 0),[o,i]=(0,Ce.useState)(void 0),[a,s]=(0,Ce.useState)(!0),[d,l]=(0,Ce.useState)(!0),c=(0,Ce.useRef)(void 0),f=(0,Ce.useRef)(void 0),h=(0,Ce.useRef)(!0);(0,Ce.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]),(0,Ce.useEffect)(()=>{if(e===""){l(!1);return}let g=!1;return l(!0),fetch(ra,{method:"GET"}).then(async y=>await y.json()).then(y=>{if(g||!h.current)return;let v=Wf(y);if(v===void 0)return;let x=v.providers[e];c.current=x,f.current=x,r(x),i(x),s(v.installed)}).catch(()=>{}).finally(()=>{!g&&h.current&&l(!1)}),()=>{g=!0}},[e]);let p=(0,Ce.useCallback)(g=>{f.current=g,i(g)},[]),m=(0,Ce.useCallback)(()=>{f.current=c.current,i(c.current)},[]),b=(0,Ce.useCallback)(async g=>{let y=g===void 0?f.current:g.preset;if(e===""||y===c.current)return;let v=await fetch(ra,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({route:e,preset:y??null})}),x=await v.json();if(!v.ok||x.ok!==!0)throw new Error("camouflage write rejected");let H=Wf(x);c.current=y,f.current=y,r(y),i(y),H!==void 0&&s(H.installed)},[e]);return{value:o,saved:n,installed:a,loading:d,setValue:p,reset:m,commit:b}}function Gf({route:e,t}){let n=Us(e,t),[r,o]=(0,Ce.useState)(void 0),i=(0,Ce.useCallback)(a=>{n.setValue(a),o(void 0),n.commit({preset:a}).then(()=>{o(void 0)}).catch(()=>{n.setValue(void 0),o({kind:"error",text:t("camouflageError")})})},[n,t]);return(0,Ze.jsxs)(Ze.Fragment,{children:[(0,Ze.jsx)(Gs,{t,value:n.value,installed:n.installed,disabled:n.loading||e==="",onChange:i}),r===void 0?null:(0,Ze.jsx)("p",{className:"bre-effort-message bre-"+r.kind,role:r.kind==="error"?"alert":"status",children:r.text})]})}var js=require("react");var qv={provider:"editorTabProvider",models:"editorTabModels",fingerprint:"editorTabFingerprint",advanced:"editorTabAdvanced"};function xi({host:e,t}){return(0,js.createElement)("div",{className:bf,role:"tablist","aria-label":t("editorTabsLabel")},...hf.map(n=>(0,js.createElement)("button",{key:n,type:"button",role:"tab",className:yf,[vf]:n,onClick:r=>{r.preventDefault(),r.stopPropagation();let o=rr(e.current);o!==null&&Tf(o,n)}},t(qv[n]))))}var Kv=15e3;function jf(){return{intents:new Map,baseline:new Map,flushing:!1}}function zs(e,t,n){if(t.length===0)return;let r={...n};if(Object.keys(r).length===0){e.intents.delete(t);return}let o=e.intents.get(t);if(o===void 0){e.intents.set(t,{headers:r,declaredBefore:e.baseline.get(t)});return}o.headers=r}function $s(e,t){e.intents.delete(t)}function zf(e,t){let n=e.intents.get(t);n!==void 0&&(n.releasedAt=Date.now())}function $f(e,t,n){if(t.length===0)return;e.baseline.set(t,n);let r=e.intents.get(t);r!==void 0&&(r.declaredBefore=n)}function Vf(e,t){return t.length>0&&!e.baseline.has(t)}async function Yf(e,t){if(e.flushing)return Uf(e);if(e.intents.size===0)return 0;e.flushing=!0;try{let n=await pe(t),r,o=async a=>st(n.namespace,a)?!0:(r??(r=await pe(t,{fresh:!0})),st(r.namespace,a)),i=Date.now();for(let[a,s]of Array.from(e.intents)){if(s.declaredBefore===void 0){s.releasedAt!==void 0&&s.noted!==!0&&(s.noted=!0,console.warn("[bre] deferred request headers: nobody said whether this id existed before, so the draft is held:",a));continue}if(s.declaredBefore){e.intents.delete(a);continue}if(!await o(a)){s.releasedAt!==void 0&&i-s.releasedAt>Kv?(e.intents.delete(a),console.info("[bre] deferred request headers: gave up on a draft whose card closed first:",a)):s.releasedAt!==void 0&&console.info("[bre] deferred request headers: waiting for the closed card to declare",a);continue}console.info("[bre] deferred request headers: the route is declared, writing the held draft:",a);let d;try{d=await Ar(t,a,s.headers)}catch(l){d={ok:!1,error:l instanceof Error?l.message:String(l)}}if(d.ok){e.intents.delete(a),console.info("[bre] deferred request headers: saved",a,Object.keys(s.headers).length,"header(s)");continue}d.error!=="no-route"&&(e.intents.delete(a),console.error("[bre] deferred request headers: the write was refused:",d.error,a))}}catch(n){console.error("[bre] deferred request headers: could not read the settings document:",n)}finally{e.flushing=!1}return Uf(e)}function Uf(e){let t=0;for(let n of e.intents.values())n.releasedAt!==void 0&&(t+=1);return t}var Vt=require("react/jsx-runtime");function Xf({host:e,api:t,t:n,routeIdLabels:r,staged:o}){let[i,a]=(0,et.useState)(()=>Xr(e.current,r)),s=(0,et.useRef)(i),d=(0,et.useRef)(void 0),l=(0,et.useRef)(new Set),c=(0,et.useRef)(!1),f=(0,et.useRef)(null);return f.current===null&&(f.current={onDraft:h=>{d.current=h;let p=s.current;if(p.length===0){!c.current&&Object.keys(h).length>0&&(c.current=!0,console.info("[bre] deferred request headers: holding a draft until the provider id is typed"));return}zs(o,p,h),Jf(t,o,p,l.current)},onCancel:()=>{d.current=void 0,$s(o,s.current)}}),(0,et.useEffect)(()=>{let h=ki(e.current);if(h===null)return;let p=()=>{a(Xr(e.current,r))};return h.addEventListener("input",p,!0),()=>{h.removeEventListener("input",p,!0)}},[e,r]),(0,et.useEffect)(()=>{i.length>0&&Jf(t,o,i,l.current)},[t,o,i]),(0,et.useEffect)(()=>{let h=s.current;if(h===i)return;$s(o,h),s.current=i;let p=d.current;p!==void 0&&i.length>0&&zs(o,i,p)},[i,o]),(0,et.useEffect)(()=>()=>{zf(o,s.current)},[o]),(0,Vt.jsxs)(Vt.Fragment,{children:[(0,Vt.jsx)(xi,{host:e,t:n}),(0,Vt.jsx)(wi,{route:i,api:t,t:n,deferred:f.current,extras:(0,Vt.jsx)(Gf,{route:i,t:n})})]})}function Jf(e,t,n,r){!Vf(t,n)||r.has(n)||(r.add(n),(async()=>{try{let o=await pe(e);$f(t,n,st(o.namespace,n))}catch(o){r.delete(n),console.warn("[bre] deferred request headers: could not read the settings document for this route:",o)}})())}function ki(e){let t=e?.parentElement;return t==null?null:t.parentElement?.closest('[class*="addCard"]')??t}function Xr(e,t){let n=e?.parentElement;if(n==null)return"";let r=t(),o=Qe(n,r).trim();if(o.length>0)return o;let i=ki(e);return i===null||i===n?"":Qe(i,r).trim()}var Xs=require("react");var tt=require("react");var Qr=15e3,Bv=3;function Zf(){return{intents:new Map,baseline:new Map,baselinePending:new Set,baselineFailures:new Set,activeIntents:new Map,draining:!1,drainAgain:!1}}function Vs(e,t,n){if(t.length===0)return;if(n.length===0){Ys(e,t);return}let r=e.intents.get(t);if(r===void 0){let o=e.activeIntents.get(t);e.intents.set(t,{drafts:[...n],landed:o?.landed??[],revision:0,declaredBefore:e.baseline.get(t),attempts:0}),e.draining&&(e.drainAgain=!0);return}Wv(r.drafts,n)||(r.drafts=[...n],r.revision+=1,r.baselineMissing=!1,e.draining&&(e.drainAgain=!0))}function Wv(e,t){return e.length===t.length&&e.every((n,r)=>{let o=t[r];return o!==void 0&&n.ref===o.ref&&n.value===o.value&&n.alias===o.alias&&n.protocol===o.protocol&&n.enabled===o.enabled})}function Ys(e,t){e.intents.delete(t),e.draining&&(e.drainAgain=!0)}function ep(e,t){let n=e.intents.get(t);n!==void 0&&(n.releasedAt=Date.now())}function Js(e,t,n){if(t.length===0)return;e.baseline.has(t)||e.baseline.set(t,n),e.baselinePending.delete(t),e.baselineFailures.delete(t);let r=e.intents.get(t);r!==void 0&&(r.declaredBefore=e.baseline.get(t),r.baselineMissing=!1),e.draining&&(e.drainAgain=!0)}function tp(e,t){return Gv(e,t)?(e.baselinePending.add(t),!0):!1}function np(e,t){e.baselinePending.delete(t),e.baseline.has(t)||e.baselineFailures.add(t),e.draining&&(e.drainAgain=!0)}function Gv(e,t){return t.length>0&&!e.baseline.has(t)&&!e.baselinePending.has(t)&&!e.baselineFailures.has(t)}async function rp(e,t,n){if(e.draining)return Qf(e);if(e.intents.size===0)return 0;e.draining=!0;try{do{e.drainAgain=!1;let r=await pe(t),o,i=async s=>st(r.namespace,s)?!0:(o??(o=await pe(t,{fresh:!0})),st(o.namespace,s)),a=Date.now();for(let[s,d]of Array.from(e.intents)){if(e.intents.get(s)!==d)continue;let l=d.revision;e.activeIntents.set(s,d);try{if(d.declaredBefore===void 0){if(e.baselinePending.has(s)){d.releasedAt!==void 0&&a-d.releasedAt>Qr&&(e.intents.delete(s),console.error("[bre] deferred api keys: the pre-save baseline timed out; refusing to write held keys:",s));continue}if(e.baselineFailures.has(s)){let h=await i(s);if(e.intents.get(s)!==d)continue;if(d.revision!==l||d.declaredBefore!==void 0){e.drainAgain=!0;continue}h?(d.baselineMissing=!0,d.noted!==!0&&(d.noted=!0,console.error("[bre] deferred api keys: the pre-save baseline failed and this route now exists; refusing to guess ownership:",s)),d.releasedAt!==void 0&&a-d.releasedAt>Qr&&(e.intents.delete(s),console.error("[bre] deferred api keys: the pre-save baseline remained unknown; refusing to write held keys:",s))):(Js(e,s,!1),d.releasedAt!==void 0&&a-d.releasedAt>Qr&&(e.intents.delete(s),console.info("[bre] deferred api keys: gave up on drafts whose card closed first:",s)));continue}d.baselineMissing=!0,d.noted!==!0&&(d.noted=!0,console.error("[bre] deferred api keys: no pre-save baseline is available; refusing to write held keys:",s)),d.releasedAt!==void 0&&a-d.releasedAt>Qr&&e.intents.delete(s);continue}if(d.declaredBefore){e.intents.delete(s);continue}let c=await i(s);if(e.intents.get(s)!==d)continue;if(d.revision!==l){e.drainAgain=!0;continue}if(!c){d.releasedAt!==void 0&&a-d.releasedAt>Qr&&(e.intents.delete(s),console.info("[bre] deferred api keys: gave up on drafts whose card closed first:",s));continue}let f=await Uv(e,s,d,n);if(e.intents.get(s)!==d||d.revision!==l)continue;f&&(e.intents.delete(s),console.info("[bre] deferred api keys: the route is declared, saved the held key list:",s))}finally{e.activeIntents.get(s)===d&&e.activeIntents.delete(s)}}}while(e.drainAgain&&e.intents.size>0)}catch(r){console.error("[bre] deferred api keys: could not read the settings document:",r)}finally{e.draining=!1}return Qf(e)}async function Uv(e,t,n,r){let o=n.revision,i=[...n.drafts],a=!1,s=!1,d=()=>e.intents.get(t)!==n?!0:n.revision!==o?(e.drainAgain=!0,!0):!1,l=()=>{a=!0,n.attempts+=1};for(let c of i){if(d())return!1;let f=n.landed.find(h=>h.ref===c.ref);if(f===void 0){let h=await r.add(t,c.value,c.alias);if(!h.ok){if(d())return!1;l();break}let m=(h.addedRef!==void 0&&h.entries.some(x=>x.ref===h.addedRef)?h.addedRef:void 0)??h.entries.map(x=>x.ref).find(x=>!n.landed.some(H=>H.hostRef===x));if(m===void 0){if(d())return!1;l();break}let b=h.entries.find(x=>x.ref===m),{alias:g,protocol:y,...v}=c;if(f={ref:c.ref,hostRef:m,draft:{...v,...b?.alias===void 0?{}:{alias:b.alias},...b?.protocol===void 0?{}:{protocol:b.protocol},enabled:b?.enabled??!0}},n.landed.push(f),s=!0,d())return!1;continue}if(f.draft.value!==c.value){if(!(await r.replace(t,f.hostRef,c.value)).ok){if(d())return!1;l();break}if(f.draft={...f.draft,value:c.value},s=!0,d())return!1}if(f.draft.alias!==c.alias){let{alias:h,...p}=f.draft;if(!(await r.rename(t,f.hostRef,c.alias)).ok){if(d())return!1;l();break}if(f.draft={...p,...c.alias===void 0?{}:{alias:c.alias}},s=!0,d())return!1}}if(!a)for(let c of i){if(d())return!1;let f=n.landed.find(b=>b.ref===c.ref);if(f===void 0||f.draft.protocol===c.protocol)continue;if(!(await r.setProtocol(t,f.hostRef,c.protocol)).ok){if(d())return!1;l();break}let{protocol:p,...m}=f.draft;if(f.draft={...m,...c.protocol===void 0?{}:{protocol:c.protocol}},s=!0,d())return!1}if(!a)for(let c of[!0,!1]){for(let f of i){if(d())return!1;if(f.enabled!==c)continue;let h=n.landed.find(m=>m.ref===f.ref);if(h===void 0||h.draft.enabled===c)continue;if(!(await r.setEnabled(t,h.hostRef,c)).ok){if(d())return!1;l();break}if(h.draft={...h.draft,enabled:c},s=!0,d())return!1}if(a)break}return a?(s&&(n.attempts=0),n.attempts>=Bv?(console.error("[bre] deferred api keys: the write was refused; giving up on the held key list:",t),!0):!1):(n.attempts=0,!d())}function Qf(e){let t=0;for(let n of e.intents.values())n.releasedAt!==void 0&&(t+=1);return t}var jv={openai:null,anthropic:null};function zv(e){let t=new Set(e.map(n=>n.ref));for(let n=1;n<=999;n+=1){let r=`key-${n}`;if(!t.has(r))return r}return`key-${Date.now()}`}function op(e,t){let n=()=>({ok:!0,route:"",entries:e.drafts.map(a=>({ref:a.ref,...a.alias===void 0?{}:{alias:a.alias},enabled:a.enabled,configured:!0,masked:Lc(a.value),...a.protocol===void 0?{}:{protocol:a.protocol}})),endpoints:jv}),r=a=>(t.onChange(e.drafts),{...n(),...a===void 0?{}:{addedRef:a}}),o=a=>e.drafts.find(s=>s.ref===a),i=(a,s)=>(e.drafts=e.drafts.map(d=>d.ref===a?s:d),r());return{list:async()=>n(),cached:()=>n(),add:async(a,s,d)=>{if(!Ct(s))return{ok:!1,error:t.t("keysAddIllegal")};let l=zv(e.drafts);return e.drafts=[...e.drafts,{ref:l,value:s,enabled:!0,...d===void 0?{}:{alias:d}}],r(l)},rename:async(a,s,d)=>{let l=o(s);if(l===void 0)return{ok:!1};let{alias:c,...f}=l;return i(s,{...f,...d===void 0?{}:{alias:d}})},replace:async(a,s,d)=>{let l=o(s);return l===void 0||!Ct(d)?{ok:!1,error:t.t("keysAddIllegal")}:i(s,{...l,value:d})},remove:async(a,s)=>(e.drafts=e.drafts.filter(d=>d.ref!==s),r()),setScope:async()=>n(),setEnabled:async(a,s,d)=>{let l=o(s);return l===void 0?{ok:!1}:!d&&!e.drafts.some(c=>c.ref!==s&&c.enabled)?{ok:!1,error:t.t("keysLastEnabledOff")}:i(s,{...l,enabled:d})},setProtocol:async(a,s,d)=>{let l=o(s);if(l===void 0)return{ok:!1};let{protocol:c,...f}=l;return i(s,{...f,...d===void 0?{}:{protocol:d}})},setEndpoints:async()=>n(),probe:async()=>n(),reveal:async(a,s)=>o(s)?.value}}var ap=require("react/jsx-runtime");function ip({host:e,store:t,api:n,t:r,routeIdLabels:o,staged:i,onChange:a}){let[s,d]=(0,tt.useState)(()=>Xr(e.current,o)),l=(0,tt.useRef)(s),c=(0,tt.useRef)(new Set),f=(0,tt.useRef)(!1),h=(0,tt.useMemo)(()=>op(t,{t:r,onChange:p=>{a?.(p);let m=l.current;if(m.length===0){!f.current&&p.length>0&&(f.current=!0,console.info("[bre] deferred api keys: holding the list until the provider id is typed"));return}Vs(i,m,p)}}),[a,i,t,r]);return(0,tt.useEffect)(()=>{let p=ki(e.current);if(p===null)return;let m=()=>{d(Xr(e.current,o))};return p.addEventListener("input",m,!0),()=>{p.removeEventListener("input",m,!0)}},[e,o]),(0,tt.useEffect)(()=>{s.length>0&&$v(n,i,s,c.current)},[n,i,s]),(0,tt.useEffect)(()=>{let p=l.current;p!==s&&(Ys(i,p),l.current=s),t.drafts.length>0&&s.length>0&&Vs(i,s,t.drafts)},[s,i,t]),(0,tt.useEffect)(()=>()=>{ep(i,l.current)},[i]),(0,ap.jsx)(li,{route:s,t:r,client:h,draft:!0})}function $v(e,t,n,r){r.has(n)||!tp(t,n)||(r.add(n),(async()=>{try{let o=await pe(e);Js(t,n,st(o.namespace,n))}catch(o){np(t,n),console.warn("[bre] deferred api keys: could not read the settings document for this route:",o)}})())}var Ti="data-bre-create-keys",Vv="bre-keys-host",Yv="data-bre-key-input",Ei="data-bre-region",sr=new WeakMap;function sp(e){let t=e.querySelector(`input[${Yv}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function dp(e){let t=sr.get(e)?.host;if(t!==void 0&&t.isConnected)return t;let n=e.nextElementSibling;return n instanceof HTMLDivElement&&n.hasAttribute(Ti)?n:void 0}function lp(e,t){if(e.closest(`[${Ti}]`)!==null){dr(e);return}let n=sp(e);if(n===void 0){dr(e);return}if(e.parentElement===null)return;We(e,fn,!0);let r=sr.get(e),o=dp(e);o===void 0&&(r!==void 0&&Qs(e,r),o=e.ownerDocument.createElement("div"),o.className=Vv,e.after(o)),be(o,Ti,"");let i=e.getAttribute(Ei);if(i===null?o.hasAttribute(Ei)&&o.removeAttribute(Ei):be(o,Ei,i),r!==void 0&&r.host===o)return;r!==void 0&&Qs(e,r);let a={drafts:Ct(n.value)?[{ref:"key-1",value:n.value,enabled:!0}]:[]},s=o,d=Xe(o,t.refreshed(()=>(0,Xs.createElement)(Be,{fallbackText:t.t("keysPanelFailed")},(0,Xs.createElement)(ip,{host:{current:s},store:a,api:t.api,t:t.t,routeIdLabels:t.routeIdLabels,staged:t.staged,onChange:l=>{let c=sp(e);if(c===void 0||c.disabled)return;let f=l.find(h=>h.enabled)?.value??"";c.value!==f&&jr(c,f)}}))),{sync:!0});sr.set(e,{host:o,mount:d})}function Qs(e,t){sr.delete(e),Ne(t.mount)}function dr(e){We(e,fn,!1);let t=sr.get(e);t!==void 0&&Qs(e,t),dp(e)?.remove()}function cp(){for(let e of Array.from(document.querySelectorAll(`[${Ti}]`))){let t=e.previousElementSibling;t instanceof HTMLElement&&sr.has(t)?dr(t):e.remove()}}var ed="bre-create-host",Zs="bre-add-mode-picker",Jv='[class*="addCard"]',Xv='[class*="addPanel"]',Qv='[class*="addModes"]',up="-custom-panel",Zv="-custom";function mp(){return{hosts:new Map}}function td(e,t,n){if(!e.isConnected)return;let r=new Set;for(let o of Array.from(e.querySelectorAll(Jv)))if(o.isConnected)try{ew(o,t,n),r.add(o)}catch(i){Si(o,n);for(let a of nd(o))try{dr(a)}catch{}gp(o,!1),console.warn("[bre] add provider card: left the official form in place:",i)}for(let o of Array.from(n.hosts.keys()))(!r.has(o)||!o.isConnected)&&Si(o,n)}function ew(e,t,n){let r=fp(e,up);(r===void 0||r.hidden)&&(iw(e,()=>Ms(e)),r=fp(e,up),r===void 0||r.hidden)||(e.getAttribute("data-bre-add-card")!=="1"&&e.setAttribute("data-bre-add-card","1"),sw(e,r,t,n),rw(e),ow(r,t),gp(e,!0))}var tw=".field, label",nw=".bre-keys-host, .bre-keys, .bre-create-host";function nd(e){let t=[],n=e.querySelectorAll('input[type="password"], input[data-bre-key-input]');for(let r of Array.from(n)){if(r.closest(nw)!==null)continue;let o=r.closest(tw)??r.parentElement;o!==null&&!t.includes(o)&&t.push(o)}return t}function rw(e){for(let t of nd(e))try{pf(t)}catch(n){console.warn("[bre] add provider card: could not mark a key field:",n)}}function ow(e,t){for(let n of nd(e))try{lp(n,{t:t.t,api:t.api,routeIdLabels:t.routeIdLabels,staged:t.stagedKeys,refreshed:t.refreshed})}catch(r){dr(n),console.warn("[bre] add provider card: could not mount the key list:",r)}}function gp(e,t){let n=hp(e);n!==void 0&&We(n,Zs,t)}function fp(e,t){for(let n of Array.from(e.querySelectorAll(Xv)))if(n.id.endsWith(t))return n}function hp(e){let t=e.querySelector(Qv);if(t!==null){for(let n of Array.from(t.children))if(n instanceof HTMLElement&&n.getAttribute("role")==="tablist")return n}}function iw(e,t){let n=hp(e);if(n!==void 0){for(let r of Array.from(n.querySelectorAll('[role="tab"]')))if(r.id.endsWith(Zv)){if(r.disabled)return;r.getAttribute("aria-selected")!=="true"&&(t(),r.click());return}}}function aw(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.classList.contains(ed))return t}function sw(e,t,n,r){let o=r.hosts.get(e),i=aw(t);if(i!==void 0&&o!==void 0&&o.host===i)return;Si(e,r),i!==void 0&&i.remove();let a=e.ownerDocument.createElement("div");a.className=ed,t.insertBefore(a,t.firstChild),Ms(e);let s=Xe(a,n.refreshed(()=>(0,pp.createElement)(Xf,{host:{current:a},api:n.api,t:n.t,routeIdLabels:n.routeIdLabels,staged:n.staged})),{sync:!0});r.hosts.set(e,{host:a,mount:s})}function Si(e,t){let n=t.hosts.get(e);n!==void 0&&(t.hosts.delete(e),Ne(n.mount))}function bp(e){for(let t of Array.from(e.hosts.keys()))Si(t,e);for(let t of Array.from(document.querySelectorAll(`.${ed}`)))t.remove();for(let t of Array.from(document.querySelectorAll(`.${Zs}`)))We(t,Zs,!1);for(let t of Array.from(document.querySelectorAll(`.${mn}`)))Qn(t);cp()}var Zr="data-bre-row-provider",yp="{provider}",dw=["rowCard","setupCard"];function vp(){return Bo()}function nt(e){for(let t of dw)for(let n of Array.from(e.querySelectorAll(`[class*="${t}"]`))){let r=n.parentElement;if(!(r===null||r.tagName!=="UL")&&Ye(r).length!==0)return r}}function bn(e){return e.querySelector('[class*="rowHead"]')??void 0}function lr(e){let t=e.querySelector('[class*="rowName"]')?.textContent?.trim();return t!==void 0&&t.length>0?t:void 0}function lw(e){let t=e.indexOf(yp);if(!(t<0))return{prefix:e.slice(0,t),suffix:e.slice(t+yp.length)}}function cw(e){let t=e.trim();if(t.length===0)return;let n=/^(.*) \(([^()]*)\)$/.exec(t);if(n!==null){let r=n[2];return r.length===0?void 0:r}return/\s/.test(t)?void 0:t}var uw='[class*="rowCard"], [class*="setupCard"], [class*="addCard"]';function fw(e){let t=e.closest(uw);for(let n=e;n!==null&&n!==t;n=n.parentElement)if(n.matches('[data-plugin], [class*="bre-"]'))return!0;return!1}function rt(e,t){let n=e.querySelector("[data-bre-provider]")?.getAttribute("data-bre-provider");if(typeof n=="string"&&n.length>0)return n;for(let r of t.editProvider){let o=lw(r);if(o!==void 0)for(let i of Array.from(e.querySelectorAll("button[aria-label]"))){if(fw(i))continue;let a=i.getAttribute("aria-label")??"";if(a.length<=o.prefix.length+o.suffix.length||!a.startsWith(o.prefix)||!a.endsWith(o.suffix))continue;let s=cw(a.slice(o.prefix.length,a.length-o.suffix.length));if(s!==void 0)return s}}}function rd(e){let t=e.getAttribute(Zr);return t===null||t.length===0?void 0:t}function pw(e){return Or(e,rd)}function wp(e,t,n,r=nt(e)){if(!e.isConnected||r===void 0)return;let o=t.labels();for(let i of Ye(r)){let a=rt(i,o);if(a===void 0){i.removeAttribute(Zr);continue}rd(i)!==a&&i.setAttribute(Zr,a)}Uo(e,r,mw(t),n)}function mw(e){return{rowOf:t=>{let n=t.closest("li");return n instanceof HTMLElement?n:void 0},idOf:rd,labelOf:lr,order:t=>jd(t),commit:t=>{yo(pw(t))},seatOf:bn,seatDrags:!0,gripLabel:(t,n)=>e.t("providerReorderAria",{provider:lr(t)??n}),gripHint:()=>e.t("providerReorderHint")}}function xp(e){jo(e);let t=Array.from(document.querySelectorAll(`[${Zr}]`));Ir(t);for(let n of t)n.removeAttribute(Zr)}var cr="data-bre-provider-switch",Mi="bre-row-disabled";function Ep(){return{switches:new WeakSet}}function Tp(e,t,n,r=nt(e)){if(!e.isConnected||r===void 0)return;let o=t.labels();for(let i of Array.from(r.children)){if(!(i instanceof HTMLElement))continue;let a=rt(i,o);if(a===void 0)continue;let s=bn(i);s!==void 0&&(gw(i,s,a,t,n),i.classList.toggle(Mi,!Nn(a)))}}function Sp(){for(let e of Array.from(document.querySelectorAll(`[${cr}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`.${Mi}`)))e.classList.remove(Mi)}function gw(e,t,n,r,o){let i=t.querySelector(`[${cr}]`);if(i!==null){kp(i,e,n,r);return}let a=document.createElement("button");a.className="bre-provider-switch",a.setAttribute("type","button"),a.setAttribute("role","switch"),a.setAttribute(cr,n),kp(a,e,n,r),hw(a,e,o);let s=t.querySelector('[class*="rowActions"]');s===null?t.appendChild(a):s.insertBefore(a,s.firstChild)}function kp(e,t,n,r){let o=r.t("providerToggleAria",{provider:lr(t)??n}),i=r.t("providerToggleHint"),a=Nn(n)?"true":"false";e.getAttribute(cr)!==n&&e.setAttribute(cr,n),e.getAttribute("aria-checked")!==a&&e.setAttribute("aria-checked",a),e.getAttribute("aria-label")!==o&&e.setAttribute("aria-label",o),e.getAttribute("title")!==i&&e.setAttribute("title",i)}function hw(e,t,n){n.switches.has(e)||(n.switches.add(e),e.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation();let o=e.getAttribute(cr);if(o===null)return;let i=!Nn(o);$d(o,i),e.setAttribute("aria-checked",i?"true":"false"),t.classList.toggle(Mi,!i)}))}var bw=["balance","totalbalance","availablebalance","remainingbalance","creditbalance","balanceusd","totalavailable","available","remaining","credits","credit","amount","left","remain","remainingquota","quotaremaining","remainquota","availablequota","points"],yw=new Map(bw.map((e,t)=>[e,t])),qT=(yw.get("totalavailable")??0)+.5;var vw=new Map([["USD","$"],["US$","$"],["$","$"],["CNY","\xA5"],["RMB","\xA5"],["\xA5","\xA5"],["EUR","\u20AC"],["\u20AC","\u20AC"],["GBP","\xA3"],["\xA3","\xA3"],["JPY","\xA5"],["KRW","\u20A9"],["HKD","HK$"],["TWD","NT$"]]);function ww(e){let t=e<0?"-":"",n=Math.abs(e),r=Number.isInteger(n)?String(n):n.toFixed(2).replace(/0+$/,"").replace(/\.$/,""),[o="0",i]=r.split("."),a=o.replace(/\B(?=(\d{3})+(?!\d))/g,",");return`${t}${a}${i===void 0?"":`.${i}`}`}function Mp(e){let t=ww(e.amount),n=e.currency?.trim()??"";if(n.length===0)return t;let r=vw.get(n.toUpperCase());return r!==void 0?`${r}${t}`:`${t} ${n}`}async function xw(e){try{let t=await fetch(`${Nd}?route=${encodeURIComponent(e)}`,{method:"GET",cache:"no-store",credentials:"same-origin"}),n;try{n=await t.json()}catch{n=void 0}if(!X(n))return{ok:!1};if(n.ok===!0){let i=n.configured!==!1,a=typeof n.amount=="number"&&Number.isFinite(n.amount)?n.amount:void 0,s=typeof n.currency=="string"&&n.currency.length>0?n.currency:void 0;return{ok:!0,configured:i,...a===void 0?{}:{amount:a},...s===void 0?{}:{currency:s}}}let r=typeof n.error=="string"&&n.error.length>0?n.error:void 0,o=typeof n.configured=="boolean"?n.configured:void 0;return{ok:!1,...o===void 0?{}:{configured:o},...r===void 0?{}:{error:r}}}catch{return{ok:!1}}}var Lp={read:xw};var It="data-bre-provider-balance",kw="data-bre-provider-switch",Li="data-bre-provider-balance-refresh",Ew=["M13.4 8a5.4 5.4 0 1 1-1.6-3.8","M13.8 2.2v3.5h-3.5"];function Rp(){return{readings:new Map,errors:new Map,requested:new Set,inflight:new Set,pending:new Set,queued:[],visible:!1}}var Cp=3;function od(e,t,n,r=nt(e)){if(r===void 0){n.visible=!1,n.queued.length=0;return}n.visible||(n.visible=!0,n.requested.clear());let o=t.labels();for(let i of Array.from(r.children)){if(!(i instanceof HTMLElement))continue;let a=rt(i,o);if(a===void 0)continue;let s=bn(i);s!==void 0&&(Op(s,a,t,n),qp(s,a,t,n))}}function Hp(e,t){e.requested.delete(t),e.readings.delete(t),e.errors.delete(t),e.inflight.has(t)&&e.pending.add(t);for(let n=e.queued.length-1;n>=0;n-=1)e.queued[n]?.route===t&&e.queued.splice(n,1)}function Np(){for(let e of Array.from(document.querySelectorAll(`[${It}]`)))e.remove()}function Op(e,t,n,r){let o=r.readings.get(t);if(o!==void 0){Ip(e,t,o,n,r);return}let i=r.errors.get(t);if(i!==void 0){Tw(e,t,i,n,r);return}Fp(e)}function Ip(e,t,n,r,o){let i=Pp(e,t,r,o);Dp(i,`${r.t("providerBalanceLabel")} ${Mp(n)}`,r.t("providerBalanceHint"),r),_p(e,i)}function Tw(e,t,n,r,o){let i=Pp(e,t,r,o),a=n.length>0?n:r.t("providerBalanceHint");Dp(i,r.t("providerBalanceUnavailable"),a,r),_p(e,i)}function Pp(e,t,n,r){let o=e.querySelector(`[${It}]`);return o===null?(o=document.createElement("span"),o.className="bre-provider-balance",o.setAttribute(It,t)):o.getAttribute(It)!==t&&o.setAttribute(It,t),(o.querySelector(".bre-provider-balance-text")===null||o.querySelector(`[${Li}]`)===null)&&(o.replaceChildren(),Sw(o,e,n,r)),o}function Sw(e,t,n,r){let o=document.createElement("span");o.className="bre-provider-balance-text";let i=document.createElement("button");i.type="button",i.className="bre-provider-balance-refresh",i.setAttribute(Li,"1"),i.setAttribute("aria-label",n.t("providerBalanceRefresh")),i.title=n.t("providerBalanceRefresh"),i.append(fi("balance-refresh",Ew)),i.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation();let s=e.getAttribute(It);if(!(s===null||s.length===0)){if(r.inflight.has(s)){r.pending.add(s);return}r.requested.delete(s),qp(t,s,n,r)}}),e.append(o,i)}function Dp(e,t,n,r){let o=e.querySelector(".bre-provider-balance-text");o!==null&&o.textContent!==t&&(o.textContent=t),e.getAttribute("title")!==n&&e.setAttribute("title",n);let i=e.querySelector(`[${Li}]`);if(i!==null){let a=r.t("providerBalanceRefresh");i.getAttribute("aria-label")!==a&&i.setAttribute("aria-label",a),i.getAttribute("title")!==a&&i.setAttribute("title",a)}}function Ap(e,t,n){let r=e.querySelector(`[${It}]`);if(r===null||r.getAttribute(It)!==t)return;let o=r.querySelector(`[${Li}]`);o!==null&&(o.classList.toggle("is-spinning",n),n?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))}function _p(e,t){let n=e.querySelector(`[${kw}]`);if(n!==null){t.nextElementSibling!==n&&n.before(t);return}if(t.parentElement!==null)return;let r=e.querySelector('[class*="rowActions"]');r!==null?r.insertBefore(t,r.firstChild):e.appendChild(t)}function Fp(e){for(let t of Array.from(e.querySelectorAll(`[${It}]`)))t.remove()}function qp(e,t,n,r){r.requested.has(t)||r.inflight.has(t)||(r.requested.add(t),Kp(e,t,n,r))}function Kp(e,t,n,r){if(r.inflight.size>=Cp){r.queued.some(o=>o.route===t)||r.queued.push({head:e,route:t});return}Bp(e,t,n,r)}function Mw(e,t){for(;t.inflight.size<Cp&&t.queued.length>0;){let n=t.queued.shift();if(n===void 0)return;Bp(n.head,n.route,e,t)}}function Bp(e,t,n,r){r.inflight.add(t),Ap(e,t,!0),(n.client??Lp).read(t).then(i=>{if(i.ok&&i.configured!==!1&&typeof i.amount=="number"&&Number.isFinite(i.amount)){r.errors.delete(t);let a={amount:i.amount,...i.currency===void 0?{}:{currency:i.currency}};r.readings.set(t,a),e.isConnected&&Ip(e,t,a,n,r);return}if(i.ok&&i.configured===!1){r.readings.delete(t),r.errors.delete(t),e.isConnected&&Fp(e);return}i.configured===!0&&r.errors.set(t,i.error??""),e.isConnected&&Op(e,t,n,r)}).catch(()=>{}).finally(()=>{r.inflight.delete(t),Ap(e,t,!1),e.isConnected||n.repaint?.(),r.pending.delete(t)&&(r.requested.delete(t),Kp(e,t,n,r)),Mw(n,r)})}function Wp(){return{requested:new Set,pending:[],running:new Set,visible:!1}}var Lw=2;function Gp(e){for(;e.visible&&e.running.size<Lw;){let t=e.pending.shift();if(t===void 0)return;e.running.add(t.route),Promise.resolve().then(()=>t.client.list(t.route,{preferCache:!0})).catch(()=>{}).finally(()=>{e.running.delete(t.route),Gp(e)})}}function id(e,t,n,r=nt(e)){if(r===void 0){n.visible=!1,n.pending.length=0;return}n.visible||(n.visible=!0,n.requested.clear());let o=t.client;if(o===void 0)return;let i=t.labels();for(let a of Array.from(r.children)){if(!(a instanceof HTMLElement))continue;let s=rt(a,i);s===void 0||n.requested.has(s)||(n.requested.add(s),n.running.has(s)||n.pending.push({route:s,client:o}))}Gp(n)}var Ai="data-bre-provider-delete",Up='[class*="rowActions"]',jp='[class*="dangerButton"]',Aw="bre-provider-delete";function zp(e,t,n=nt(e)){if(!e.isConnected||n===void 0)return;let r=t.labels(),o=Rw(n)??t.t("providerRemoveDisabled");for(let i of Array.from(n.children)){if(!(i instanceof HTMLElement))continue;let a=rt(i,r);if(a===void 0)continue;let s=bn(i);if(s===void 0)continue;let d=s.querySelector(Up);if(d===null)continue;let l=d.querySelector(`[${Ai}]`);if(d.querySelector(jp)!==null){l!==null&&l.remove();continue}let c=l??Cw();d.lastElementChild!==c&&d.appendChild(c),Hw(c,a,o,t.t("providerRemoveLocked",{provider:lr(i)??a}))}}function $p(){for(let e of Array.from(document.querySelectorAll(`[${Ai}]`)))e.remove()}function Rw(e){let n=e.querySelector(`${Up} ${jp}`)?.textContent?.trim()??"";return n.length>0?n:void 0}function Cw(){let e=document.createElement("button");return e.className=Aw,e.setAttribute("type","button"),e.setAttribute("disabled",""),e}function Hw(e,t,n,r){e.getAttribute(Ai)!==t&&e.setAttribute(Ai,t),e.textContent!==n&&(e.textContent=n),e.getAttribute("aria-label")!==r&&e.setAttribute("aria-label",r),e.getAttribute("title")!==r&&e.setAttribute("title",r)}var Ri="data-bre-provider-disabled-group",Nw="bre-provider-disabled-seat",Vp="bre-provider-disabled-group",ad="bre-row-folded",sd="bre-row-hidden";function Yp(){return{expanded:!1}}function Jp(e,t,n,r=nt(e)){if(!e.isConnected||r===void 0)return;let o=Qp(r,t.labels()),i=o.filter(l=>!l.enabled).length,a=Zp(r);if(i===0){a!==void 0&&a.remove(),dd(o,n);return}let s=a??Ow(r,t,n);(s.parentElement!==r||r.lastElementChild!==s)&&r.append(s),dd(o,n);let d=em(s);d!==void 0&&tm(d,i,t,n)}function Xp(){for(let e of Array.from(document.querySelectorAll(`[${Ri}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`.${sd}, .${ad}`)))e.classList.remove(sd,ad)}function Qp(e,t){let n=[];for(let r of Array.from(e.children)){if(!(r instanceof HTMLElement)||r.getAttribute(Ri)!==null)continue;let o=rt(r,t);o!==void 0&&n.push({row:r,id:o,enabled:Nn(o)})}return n}function dd(e,t){for(let n of e){let r=!n.enabled;n.row.classList.toggle(ad,r),n.row.classList.toggle(sd,r&&!t.expanded)}}function Zp(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.getAttribute(Ri)!==null)return t}function em(e){return e.querySelector(`button.${Vp}`)??void 0}function Ow(e,t,n){let r=document.createElement("li");r.className=Nw,r.setAttribute(Ri,"");let o=document.createElement("button");return o.className=Vp,o.setAttribute("type","button"),o.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),n.expanded=!n.expanded,Iw(e,t,n)}),r.appendChild(o),e.append(r),r}function Iw(e,t,n){let r=Qp(e,t.labels());dd(r,n);let o=Zp(e);if(o===void 0)return;let i=r.filter(s=>!s.enabled).length;if(i===0){o.remove();return}let a=em(o);a!==void 0&&tm(a,i,t,n)}function tm(e,t,n,r){let o=n.t(r.expanded?"providerDisabledGroupHide":"providerDisabledGroupShow",{count:t}),i=n.t("providerDisabledGroupHint"),a=r.expanded?"true":"false";e.textContent!==o&&(e.textContent=o),e.getAttribute("aria-expanded")!==a&&e.setAttribute("aria-expanded",a),e.getAttribute("aria-label")!==o&&e.setAttribute("aria-label",o),e.getAttribute("title")!==i&&e.setAttribute("title",i)}var yn="data-bre-row-model",eo="bre-model-grid";function rm(){return Bo()}function cd(e){let t=[];for(let n of Array.from(e.querySelectorAll('[class*="modelList"]')))Ye(n).filter(o=>o.matches('[class*="modelEntry"]')).length!==0&&t.push(n);return t}function om(e){for(let t of e){if(t.type!=="childList")continue;let n=t.target;if(n instanceof HTMLElement&&n.matches('[class*="modelList"]')&&Ye(n).some(r=>r.matches('[class*="modelEntry"]')))return!0;for(let r of[t.addedNodes,t.removedNodes])for(let o of Array.from(r))if(o instanceof HTMLElement&&o.matches('[class*="modelEntry"]'))return!0}return!1}function Ci(e){let t=e.getAttribute(yn);return t===null||t.length===0?void 0:t}function ld(e,t){let n=e.closest("li");if(n!==null)return rt(n,t.labels())}function nm(e,t){let n=Qe(e,t.labels().modelName);return n.length>0?n:Ci(e)}function Pw(e,t){return{rowOf:n=>{let r=n.closest('[class*="modelEntry"]');return r instanceof HTMLElement?r:void 0},idOf:Ci,labelOf:n=>nm(n,t),order:n=>{let r=ld(e,t);return r===void 0?n:tl(r,n)},commit:n=>{let r=ld(n,t);r!==void 0&&Qd(r,Or(n,Ci))},seatOf:n=>n.querySelector('[class*="modelRow"]')??void 0,seatDrags:!1,gripLabel:(n,r)=>t.t("modelReorderAria",{model:nm(n,t)??r}),gripHint:()=>t.t("modelReorderHint"),decorate:(n,r)=>{r.classList.add(eo)}}}function im(e,t,n,r=cd(e)){if(!e.isConnected)return;let o=t.labels();for(let i of r){if(i.querySelector('[class*="modelDragHandle"]')!==null){for(let s of Array.from(i.querySelectorAll(`.${eo}`))){for(let d of Array.from(s.querySelectorAll("[data-bre-drag-handle]")))d.remove();s.classList.remove(eo)}let a=Array.from(i.querySelectorAll(`[${yn}]`));Ir(a);for(let s of a)s.removeAttribute(yn);continue}if(ld(i,t)!==void 0){for(let a of Ye(i)){let s=Qe(a,o.modelId);if(s.length===0){a.removeAttribute(yn);continue}Ci(a)!==s&&a.setAttribute(yn,s)}Uo(e,i,Pw(i,t),n)}}}function am(e){jo(e);for(let n of Array.from(document.querySelectorAll(`.${eo}`)))n.classList.remove(eo);let t=Array.from(document.querySelectorAll(`[${yn}]`));Ir(t);for(let n of t)n.removeAttribute(yn)}var At=require("react");async function Dw(e){try{let t=await e.json();if(typeof t.error=="string"&&t.error.length>0)return t.error}catch{}return`image request failed (${e.status})`}async function _w(e,t){try{let n=await fetch(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));return n.ok&&r.ok===!0?{ok:!0,data:r}:{ok:!1,error:typeof r.error=="string"?r.error:await Dw(n)}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}}var fr,ur=0,Fw=0;var ud=new Set;function sm(e){return ud.add(e),()=>{ud.delete(e)}}function Hi(){return fr}function dm(){vn()}function qw(e){let t=e.defaults,n=e.tool;if(!(typeof e.enabled!="boolean"||!(e.defaultModel===null||typeof e.defaultModel=="string")||typeof e.outputDir!="string"||t===null||typeof t!="object"||typeof t.size!="string"||typeof t.quality!="string"||typeof t.n!="number"||typeof t.timeoutMs!="number"||n===null||typeof n!="object"||typeof n.registered!="boolean"||!(n.name===null||typeof n.name=="string")))return{enabled:e.enabled,models:[],defaultModel:e.defaultModel,defaults:{size:t.size,quality:t.quality,n:t.n,timeoutMs:t.timeoutMs},outputDir:e.outputDir,tool:{registered:n.registered,name:n.name,...typeof n.error=="string"?{error:n.error}:{}}}}async function vn(){let e=++ur;try{let t=await fetch(ia,{method:"GET",cache:"no-store"}),n=await t.json();if(t.ok&&n.ok===!0&&Array.isArray(n.models)){let o={...n,enabled:n.enabled!==!1};return e===ur&&(fr=o),{ok:!0,data:o}}e===ur&&(fr=void 0);let r=qw(n);return{ok:!1,error:typeof n.error=="string"?n.error:`image request failed (${t.status})`,...r===void 0?{}:{data:r}}}catch(t){return e===ur&&(fr=void 0),{ok:!1,error:t instanceof Error?t.message:String(t)}}}async function lm(e){fr=void 0,ur+=1;let t=await _w(ia,{op:"save",...e});if(fr=void 0,ur+=1,!t.ok)return{ok:!1,error:t.error};Fw+=1;for(let n of ud)try{n()}catch{}return{ok:!0,data:void 0}}var Kw=["\u6A21\u578B","Models","models"],um='[class*="rowCard"], [class*="setupCard"], [class*="addCard"]',Bw='h1,h2,h3,h4,h5,h6,[role="heading"]',Ww=/title|heading/i,Gw='nav, button, [role="menu"], [role="menuitem"], [class*="rowName"], [class*="rowCard"]',Uw=4;function jw(e,t){let n="";for(let r of e.childNodes)if(r.nodeType===r.TEXT_NODE)n+=r.textContent??"";else if(r.nodeType===r.ELEMENT_NODE){if(r.classList?.contains(to))continue;return!1}return n.replace(/\s+/g," ").trim()===t}function zw(e,t){for(let n=e;n!==null;n=n.parentElement){if(n.matches(Bw)||Ww.test(String(n.className??"")))return n;if(n===t)break}return null}function $w(e,t){for(let n of Kw)for(let r of e.querySelectorAll("*")){if(!jw(r,n)||r.closest(Gw)!==null||(r.compareDocumentPosition(t)&Uw)===0)continue;let o=zw(r,e);if(o!==null)return o}return null}var fd;function fm(e){let t=fd;if(t!==void 0&&t.root===e&&t.row.isConnected)return t.row;let n=e.querySelector(um);if(n===null)return null;let r=n.ownerDocument?.body??null;for(let o=n.parentElement;o!==null&&o!==r;o=o.parentElement){let i=$w(o,n);if(i!==null){let a=Vw(i,o);return a!==null&&(fd={root:e,row:a}),a}}return null}function Vw(e,t){let n=e,r=n.parentElement;for(;r!==null&&r!==t;){let o=Array.from(r.childNodes).filter(a=>a.nodeType===a.TEXT_NODE).map(a=>a.textContent??"").join("").replace(/\s+/g," ").trim();if(Array.from(r.children).filter(a=>!a.classList?.contains(to)).length>1||o.length>0)return r.querySelector(um)!==null?n:r;n=r,r=r.parentElement}return r===t?n:null}var to="bre-config-host",md="bre-config-title-line",pd={display:"flex",alignItems:"center"},Ni=new WeakMap;function cm(e){e.classList.add(md),Ni.has(e)||Ni.set(e,{display:e.style.display,alignItems:e.style.alignItems}),e.style.display=pd.display,e.style.alignItems=pd.alignItems}function Yw(e){return e.classList.contains(md)&&e.style.display===pd.display}function pm(e){e.classList.remove(md);let t=Ni.get(e);Ni.delete(e),e.style.display=t?.display??"",e.style.alignItems=t?.alignItems??""}function mm(){return{mounts:new Map}}function gm(e,t,n){let r=n.mounts.get(e),o=e.querySelector(`:scope > .${to}`);if(o!==null&&r!==void 0&&r.wrapper===o){Yw(e)||cm(e);return}hm(e,n),o?.remove(),cm(e);let i=e.ownerDocument.createElement("div");i.className=to,e.appendChild(i);let a=Xe(i,(0,At.createElement)(Xw,{t:t.t,onOpen:t.onOpen}),{sync:!0});n.mounts.set(e,a)}function hm(e,t){pm(e);let n=t.mounts.get(e);n!==void 0&&(t.mounts.delete(e),Ne(n))}function bm(e){for(let t of Array.from(e.mounts.keys()))hm(t,e);for(let t of Array.from(document.querySelectorAll(`.${to}`))){let n=t.parentElement;n!==null&&pm(n),t.remove()}fd=void 0}function Jw(){return(0,At.createElement)("svg",{className:"bre-config-btn-icon",width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"},(0,At.createElement)("path",{d:"M4 6h8m4 0h4M4 12h2m4 0h10M4 18h10m4 0h2"}),(0,At.createElement)("circle",{cx:14,cy:6,r:2}),(0,At.createElement)("circle",{cx:8,cy:12,r:2}),(0,At.createElement)("circle",{cx:16,cy:18,r:2}))}function Xw(e){return(0,At.useEffect)(()=>{dm()},[]),(0,At.createElement)("button",{className:"bre-config-btn",type:"button",title:e.t("configButtonHint"),"aria-label":e.t("configButton"),onClick:()=>e.onOpen()},Jw())}var Qw="settings.models",ot={capacity:["modelAdvanced","Model options","Capacities"],modelId:["modelId","Model ID"],modelName:["modelName","Display name"],routeId:["customRoute","Provider ID"],baseUrl:["baseUrl","Base URL"],apiProtocol:["customApi","API protocol"],apply:["apply","Apply"],cancel:["cancel","Cancel"],editProvider:["editProvider","Edit {provider}"],inputImage:["modelInputImage","Image"],contextWindow:["modelContextWindow","contextWindow","Context window","\u4E0A\u4E0B\u6587\u7A97\u53E3"],maxOutput:["modelMaxOutput","maxOutput","maxTokens","Max output","\u6700\u5927\u8F93\u51FA"],addModel:["addModel","Add model","\u6DFB\u52A0\u6A21\u578B"]};function wm(e){let{ctx:t,api:n,t:r,onIdle:o,refreshed:i}=e,a=()=>{let B=t.locale.bind(Qw),J=Z=>{let fe=[];for(let u of Z){let T=B(u);T!==u&&T.trim()!==""&&!fe.includes(T)&&fe.push(T)}return fe.length===0?Z:[...fe,...Z.filter(u=>!fe.includes(u))]};return{capacity:J(ot.capacity),modelId:J(ot.modelId),modelName:J(ot.modelName),routeId:J(ot.routeId),baseUrl:J(ot.baseUrl),apiProtocol:J(ot.apiProtocol),apply:J(ot.apply),cancel:J(ot.cancel),editProvider:J(ot.editProvider),inputImage:J(ot.inputImage),contextWindow:J(ot.contextWindow),maxOutput:J(ot.maxOutput),addModel:J(ot.addModel)}},s=120,d=1e3,l=fu(),c=vp(),f={t:r,labels:a},h=Ep(),p={t:r,labels:a},m=Rp(),b={t:r,labels:a,repaint:()=>te()},g=Wp(),y={labels:a,client:Ge},v={t:r,labels:a},x=Yp(),H={t:r,labels:a},q=rm(),ne={t:r,labels:a},K=xf(),S={t:r},C=mp(),M=mm(),w=jf(),k=Zf(),R={t:r,api:n,routeIdLabels:()=>a().routeId,staged:w,stagedKeys:k,refreshed:i},I,D,W,N,V=B=>{for(let J of B)for(let Z of Array.from(J.addedNodes)){if(!(Z instanceof HTMLElement))continue;let fe=Z.matches('[class*="modelAdvanced"]')?[Z]:Array.from(Z.querySelectorAll('[class*="modelAdvanced"]'));for(let u of fe)Ts(u)}},ie=!1,re={api:n,describeNamespace:B=>pe(n,B),t:r,labels:a,onIdle:o,onBackoff:B=>{ae(B)},onPendingChanged:()=>{te()},mount(B,J){let Z=document.createElement("div");Z.className="bre-effort-slot",Z.dataset.plugin=ke,B.appendChild(Z);let fe=(0,vm.createRoot)(Z),u=T=>{fe.render((0,gd.createElement)(Be,{fallbackText:r("renderFailed"),children:i(()=>(0,gd.createElement)(_o,T))}))};return(0,ym.flushSync)(()=>{u(J)}),{unmount:()=>{try{fe.unmount()}finally{Z.remove()}},render:u}}},oe=0;function ae(B){if(ie)return;let J=Date.now()+B;D!==void 0&&J>=oe||(D!==void 0&&window.clearTimeout(D),oe=J,D=window.setTimeout(()=>{D=void 0,oe=0,te()},B))}let de=()=>{let B=bt(),J=nt(B);if(J===void 0){od(B,b,m,void 0),id(B,y,g,void 0);return}if(wp(B,f,c,J),Tp(B,p,h,J),od(B,b,m,J),id(B,y,g,J),zp(B,v,J),Jp(B,H,x,J),im(B,ne,q,cd(B)),e.configSeat!==void 0){let Z=fm(B);Z!==null&&gm(Z,{t:e.configSeat.t,onOpen:e.configSeat.onOpen},M)}Ws(),Cf(B)},he=(B,J)=>{try{J()}catch(Z){console.error(`[bre] ${B} failed:`,Z)}};function te(){ie||I!==void 0||(I=window.setTimeout(()=>{I=void 0,he("composer mutation",()=>{N?.()}),he("editor reconcile",()=>{As(bt(),re,l)}),he("add-card reconcile",()=>{td(bt(),R,C)}),he("editor tabs reconcile",()=>{Fs(bt(),S,K)}),he("dom decorations",()=>{de()}),Yf(w,n).then(B=>{B>0&&ae(d)}),rp(k,n,Ge).then(B=>{B>0&&ae(d)})},s))}let ue=B=>{let Z=B.detail?.route;typeof Z!="string"||Z.length===0||(Hp(m,Z),te())},Te=B=>{if(ie||W!==void 0)return;N=B,he("models page startup",()=>{B(),de()}),Ou();let J=(Z,fe)=>{B(),fe&&(he("editor reconcile",()=>{As(bt(),re,l)}),td(bt(),R,C),Fs(bt(),S,K),de(),om(Z)&&Fu(bt()))};W=new MutationObserver(Z=>{let fe=Gu(Z);he("models mutation",()=>{J(Z,fe)}),fe&&(he("early reasoning hide",()=>{V(Z)}),te())}),W.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden"]}),document.addEventListener(Sr,ue),te()},Le=()=>{ie=!0,I!==void 0&&(window.clearTimeout(I),I=void 0),D!==void 0&&(window.clearTimeout(D),D=void 0),document.removeEventListener(Sr,ue),W?.disconnect(),W=void 0};return{state:l,labels:a,start:Te,stopObserver:Le,teardown:()=>{if(!l.disposed){Le(),l.disposed=!0,Mu(),cu(l,re);for(let[B,J]of l.mounted)Fr(B),J.editor.unmount();l.mounted.clear(),xp(c),Sp(),Np(),$p(),Xp(),tc(),bm(M),Hf(),qf(),am(q),bp(C),Sf(),eu(),_u()}},flushOnUnload:()=>{uu(l,re)},schedule:te}}var Zw=1500,ex=2,tx=8,nx=6e4;function xm(e,t={}){let n=t.delayMs??Zw,r=Math.max(1,t.concurrency??ex),o=Math.max(1,t.limit??tx),i=t.minAgeMs??nx,s=(t.now??Date.now)(),d=Nc().filter(p=>s-p.savedAt>=i).slice(0,o).map(p=>p.route),l=!1,c=0,f=()=>{for(;!l&&c<r;){let p=d.shift();if(p===void 0)return;c+=1,Promise.resolve().then(()=>e.list(p,{preferCache:!0})).catch(()=>{}).finally(()=>{c-=1,f()})}},h=setTimeout(()=>{l||f()},n);return()=>{l=!0,clearTimeout(h)}}var Em=e=>`?route=${encodeURIComponent(e)}`;async function Tm(e){try{let t=await e.json();if(typeof t.error=="string"&&t.error.length>0)return t.error}catch{}return`fingerprint request failed (${e.status})`}async function hd(e){try{let t=await fetch(`${ta}${Em(e)}`,{method:"GET"}),n=await t.json();if(t.ok&&n.ok===!0){let r=n.data;return{ok:!0,data:{bank:r?.bank??{},records:Array.isArray(r?.records)?r.records:[]}}}return{ok:!1,error:typeof n.error=="string"?n.error:await Tm(t)}}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}}function Sm(e,t,n){let r=new AbortController,o=!1;return{done:(async()=>{let a;try{let s=await fetch(`${ta}${Em(e)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({model:t}),signal:r.signal});if(!s.ok)return{ok:!1,error:await Tm(s)};let d=s.body?.getReader();if(d===void 0)return{ok:!1,error:"the fingerprint route sent no body"};let l=new TextDecoder,c="";for(;;){let{done:h,value:p}=await d.read();if(h)break;c+=l.decode(p,{stream:!0});let m=c.indexOf(`
5307
+ `);for(;m>=0;){let b=c.slice(0,m).trim();if(c=c.slice(m+1),b.length>0){let g=km(b);g!==void 0&&(n(g),g.type==="result"?a={ok:!0,record:g.record}:g.type==="error"&&(a={ok:!1,error:g.error}))}m=c.indexOf(`
5308
+ `)}}let f=c.trim();if(f.length>0){let h=km(f);h!==void 0&&(n(h),h.type==="result"?a={ok:!0,record:h.record}:h.type==="error"&&(a={ok:!1,error:h.error}))}}catch(s){return o?{ok:!1,error:"cancelled"}:{ok:!1,error:s instanceof Error?s.message:String(s)}}return a!==void 0?a:o?{ok:!1,error:"cancelled"}:{ok:!1,error:"the fingerprint route ended without a verdict"}})(),abort:()=>{o=!0,r.abort()}}}function km(e){let t;try{t=JSON.parse(e)}catch{return}if(typeof t!="object"||t===null)return;let n=t,r=n.type;if(r==="progress")return{type:"progress",index:Number(n.index??0),ok:n.ok===!0,...typeof n.error=="string"?{error:n.error}:{}};if(r==="result"){let o=n.record;return typeof o!="object"||o===null?void 0:{type:"result",record:o}}if(r==="error")return{type:"error",error:typeof n.error=="string"?n.error:"fingerprint route failed"}}var rx=3,ox=2,ix=15e3,ax=/\b429\b|rate.?limit|too many requests/i,bd=new Map;function sx(e){return bd.get(e)??{run:(t,n,r)=>Sm(t,n,r)}}var yd=class{constructor(t,n=ox,r=ix){qe(this,"route",t);qe(this,"concurrency",n);qe(this,"backoffMs",r);qe(this,"listeners",new Set);qe(this,"recordListeners",new Set);qe(this,"failureListeners",new Set);qe(this,"state",{running:new Map,queued:[]});qe(this,"handles",new Set);qe(this,"draining",!1);qe(this,"disposed",!1);qe(this,"throttled",!1);qe(this,"backoffUntil",0)}getState(){return this.state}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onRecord(t){return this.recordListeners.add(t),()=>{this.recordListeners.delete(t)}}onFailure(t){return this.failureListeners.add(t),()=>{this.failureListeners.delete(t)}}idle(){return this.state.running.size===0&&this.state.queued.length===0}check(t){this.checkAll([t])}checkAll(t){if(this.disposed)return;let n=[...this.state.queued];for(let r of t)n.includes(r)||this.state.running.has(r)||n.push(r);n.length!==this.state.queued.length&&(this.publish({...this.state,queued:n}),this.drain())}abort(){this.publish({running:new Map,queued:[]});for(let t of[...this.handles])t.abort();this.handles.clear(),this.throttled=!1,this.backoffUntil=0}dispose(){this.disposed||(this.disposed=!0,this.abort(),this.listeners.clear(),this.recordListeners.clear(),this.failureListeners.clear(),Oi.delete(this.route),bd.delete(this.route))}setSender(t){bd.set(this.route,t)}publish(t){this.state=t;for(let n of[...this.listeners])n()}limit(){return this.throttled?1:Math.max(1,this.concurrency)}async drain(){if(this.draining||this.disposed)return;this.draining=!0;let t=new Set;try{for(;!this.disposed;){for(;!this.disposed&&t.size<this.limit()&&this.state.queued.length>0&&Date.now()>=this.backoffUntil;){let r=this.state.queued[0];if(r===void 0)break;this.publish({running:new Map(this.state.running).set(r,0),queued:this.state.queued.slice(1)});let o=this.runOne(r).finally(()=>{t.delete(o)});t.add(o)}if(this.disposed||t.size===0||(await Promise.race(t),this.disposed))break;let n=this.backoffUntil-Date.now();n>0&&await new Promise(r=>setTimeout(r,n))}}finally{t.clear(),this.throttled=!1,this.backoffUntil=0,this.draining=!1}}async runOne(t){let n=sx(this.route),r=0,o=n.run(this.route,t,i=>{i.type==="progress"&&(r+=1,this.publish({running:new Map(this.state.running).set(t,Math.min(r,rx)),queued:this.state.queued}))});this.handles.add(o);try{let i=await o.done;if(this.disposed)return;if(i.ok)for(let a of[...this.recordListeners])a(i.record);else{ax.test(i.error)&&(this.throttled=!0,this.backoffUntil=Date.now()+this.backoffMs);for(let a of[...this.failureListeners])a(t,i.error)}}finally{if(this.handles.delete(o),this.state.running.has(t)){let i=new Map(this.state.running);i.delete(t),this.publish({running:i,queued:this.state.queued})}}}},Oi=new Map;function Mm(e,t){let n=Oi.get(e);return n===void 0&&(n=new yd(e,t?.concurrency,t?.backoffMs),Oi.set(e,n)),n}function Lm(){for(let e of[...Oi.values()])e.dispose()}function pr(e,t){let n=e?.list?.getSnapshot(),r=n?.current;if(typeof r=="string"&&r.length>0)return r;let o=t?.adapter?.current?.getSnapshot?.()?.key;if(typeof o=="string"&&o.length>0)return o;for(let[i,a]of Object.entries(n?.byId??{}))if(!(a===void 0||(a.retainedBy?.mainView??0)<=0))return typeof a.id=="string"&&a.id.length>0?a.id:i}function Am(e){let t,n=new Map,r=(a,s)=>{for(let[d,l]of n){if(d===s)continue;let c;try{c=a.directoryFor(l.sessionId)===d}catch{c=!1}c||(l.restore(),n.delete(d))}};return{ensure:()=>{let a=e.ctx,s=a.get?.("sessions"),d=a.get?.("uiSession"),l=a.get?.("modelDirectories"),c=pr(s,d);if(!(c===void 0||l===void 0))try{let f=l.directoryFor(c);return r(l,f),t!==void 0&&t.sessionId===c&&t.directory===f||(n.has(f)||n.set(f,{sessionId:c,restore:Tl(f,{configuredEffort:e.configuredEffort})}),t={sessionId:c,directory:f}),f}catch{t=void 0;return}},dispose:()=>{for(let[,a]of n)a.restore();n.clear()}}}var no=Object.freeze(["EMPTY_RESPONSE","RATE_LIMIT","SERVER","TIMEOUT","TRANSPORT"]),Ii=Object.freeze(["PI_AI_ERROR","INVALID_REQUEST","AUTH","LEGACY_CLI_OUTCOME_UNKNOWN","UNSUPPORTED_REASONING_EFFORT","MALFORMED_RESPONSE","UNKNOWN_MODEL"]),Pi=Object.freeze([...no,...Ii]);function Rm(){let e={};for(let t of no)e[t]=!0;for(let t of Ii)e[t]=!1;return e}var wn=Object.freeze({maxTokens:!0,httpStatus:!0,codes:Object.freeze(Rm())});function Cm(e){let t=e!==null&&typeof e=="object"?e:{},n=t.codes!==null&&typeof t.codes=="object"?t.codes:{},r=Rm();for(let o of Pi){let i=n[o];typeof i=="boolean"&&(r[o]=i)}return Object.freeze({maxTokens:typeof t.maxTokens=="boolean"?t.maxTokens:wn.maxTokens,httpStatus:typeof t.httpStatus=="boolean"?t.httpStatus:wn.httpStatus,codes:Object.freeze(r)})}function dx(e,t){let n=t.codes[e];return typeof n=="boolean"?n:no.includes(e)?!0:void 0}function lx(e){return e===408||e===425||e===429||e>=500&&e<=599}var cx=new Set(["user/message","developer/message","system/message","request/header","request/context","step/start","assistant/message","assistant/attempt","tool/call","tool/result"]);function ux(e){let t=!1;for(let n of e.turnEvents)if(n.type!=="turn/end"){if(n.type==="turn/start"){t=!0;continue}if(cx.has(n.type))return!0}return t?!1:"unknown"}function fx(e){let t=e.data;if(typeof t!="object"||t===null)return;let n=t.reason;if(typeof n!="object"||n===null)return typeof n=="string"?n:void 0;let r=n.kind;return typeof r=="string"?r:void 0}function px(e){let t=e.data;if(typeof t!="object"||t===null)return;let n=t.reason;if(typeof n!="object"||n===null)return;let r=n.error;if(!(typeof r!="object"||r===null))return r}function mx(e){let t=e?.providerRetryAfterMs;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0}function Di(e,t=wn){let n=fx(e.turnEnd);if(ux(e)===!1)return{kind:"refuse",detail:`${n??"unreadable reason"}: empty turn`};switch(n){case"max-tokens":return t.maxTokens?{kind:"continue",reason:"max-tokens",detail:"max-tokens"}:{kind:"refuse",detail:"max-tokens (not enabled)"};case"error":{let r=px(e.turnEnd),o=typeof r?.code=="string"?r.code:void 0,i=typeof r?.status=="number"?r.status:void 0;if(o!==void 0){let a=dx(o,t);if(a===!0){let s=mx(r);return{kind:"continue",reason:"transient-error",detail:o,...s!==void 0?{waitMs:s}:{}}}if(a===!1)return{kind:"refuse",detail:`${o} (not enabled)`}}return i!==void 0&&t.httpStatus&&lx(i)?{kind:"continue",reason:"transient-error",detail:`status ${i}`}:{kind:"refuse",detail:o??(i!==void 0?`status ${i}`:"unknown error")}}case"completed":return{kind:"settled",detail:"completed"};case"aborted":return{kind:"settled",detail:"aborted"};case"interrupted":return{kind:"settled",detail:"interrupted"};case"blocked":return{kind:"settled",detail:"blocked"};case"forked":case"orphaned":return{kind:"refuse",detail:n};default:return{kind:"refuse",detail:n===void 0?"unreadable reason":`unknown reason ${n}`}}}var qi="dsh-model-think-level.auto-continue.enabled",Ki="dsh-model-think-level.auto-continue.config",Bi=1,Wi=3600,Gi=1,Ui=100,vd=Object.freeze({waitSeconds:2,maxRetries:5,policy:wn}),gx="dsh-model-think-level.auto-continue.claim.",hx=10*6e4;function Nm(e){try{return window.localStorage.getItem(e)}catch{return null}}function Hm(e,t,n,r){return typeof e!="number"||!Number.isFinite(e)?t:Math.min(r,Math.max(n,Math.trunc(e)))}function wd(e){let t=e!==null&&typeof e=="object"?e:{};return Object.freeze({waitSeconds:Hm(t.waitSeconds,vd.waitSeconds,Bi,Wi),maxRetries:Hm(t.maxRetries,vd.maxRetries,Gi,Ui),policy:Cm(t.policy)})}function ji(e){try{return wd(e===null?void 0:JSON.parse(e))}catch{return vd}}var ro=Nm(qi)==="true",mr=ji(Nm(Ki)),_i=new Set,Fi=new Set;function zi(e){for(let t of[...e])t()}function Yt(){return ro}function Ue(){return mr}function Om(e){if(ro!==e){ro=e;try{window.localStorage.setItem(qi,String(e))}catch{}zi(_i)}}function Im(e,t){return JSON.stringify(e)===JSON.stringify(t)}function xn(e){let t=wd({...mr,...e});if(!Im(mr,t)){mr=t;try{window.localStorage.setItem(Ki,JSON.stringify(t))}catch{}zi(Fi)}}function xd(e){ro!==e&&(ro=e,zi(_i))}function kd(e){let t=wd(e);Im(mr,t)||(mr=t,zi(Fi))}function $i(e){return _i.add(e),()=>{_i.delete(e)}}function Vi(e){return Fi.add(e),()=>{Fi.delete(e)}}function Pm(e,t){let n=`${gx}${e}.${t}`;try{let r=window.localStorage.getItem(n);if(r!==null){let o=JSON.parse(r);if(typeof o=="number"&&Number.isFinite(o)&&Date.now()-o<hx)return!1}return window.localStorage.setItem(n,JSON.stringify(Date.now())),!0}catch{return!0}}var bx=1e3,yx=500,vx=600,Dm=6e3,wx=12e4,xx=3e4,kx=1440*60*1e3;function _m(e){let{ctx:t,t:n}=e,r,o=!1,i=new Set,a=new Set,s=new Set,d,l=()=>{let u=r,T=Ue();return u===void 0?{sessionId:void 0,phase:"idle",consecutive:0,maxRetries:T.maxRetries,nextSendAt:0,detail:"",muted:!1}:{sessionId:u.sessionId,phase:u.phase,consecutive:u.consecutive,maxRetries:T.maxRetries,nextSendAt:u.nextSendAt,detail:u.detail,muted:a.has(u.sessionId)}},c=(u,T)=>u.sessionId===T.sessionId&&u.phase===T.phase&&u.consecutive===T.consecutive&&u.maxRetries===T.maxRetries&&u.nextSendAt===T.nextSendAt&&u.detail===T.detail&&u.muted===T.muted,f=()=>{let u=l();if(!(d!==void 0&&c(d,u))){d=u;for(let T of[...s])T()}},h=()=>(d??(d=l()),d),p=u=>{u.sendTimer!==void 0&&(clearTimeout(u.sendTimer),i.delete(u.sendTimer),u.sendTimer=void 0),u.pendingSendTurnEndSeq=void 0,u.pendingSendScheduledAt=0,u.pendingRetryAfterMs=void 0},m=u=>{p(u),u.sendEpoch+=1,u.phase="idle",u.nextSendAt=0,u.detail="",f()},b=(u,T)=>{let _=setTimeout(()=>{i.delete(_),u()},T);i.add(_)},g=u=>{let T=[];try{T=u.getSnapshot().entries??[]}catch{return[]}let _=[];for(let F of T)F.type!=="event"||F.event===void 0||_.push(F.event);return _},y=u=>g(u.eventSource),v=u=>{if(u.type!=="user/message")return!1;let T=u.data;if(typeof T!="object"||T===null)return!0;let _=T.message??T;if(typeof _!="object"||_===null)return!0;let F=_.source;if(typeof F!="object"||F===null)return!0;let Q=F.kind;return Q!=="model-selection"&&Q!=="time-context"},x=u=>{let T=y(u),_=u.lastUserSeq;for(let F of T){if(F.type!=="user/message"||F.seq<=_||(u.lastUserSeq=Math.max(u.lastUserSeq,F.seq),!v(F)))continue;let Q=H(u,F);u.lastAutoSentText=void 0,!Q&&(a.delete(u.sessionId),u.consecutive=0,K(u),m(u))}},H=(u,T)=>{if(u.lastAutoSentText===void 0)return!1;let _=T.data;if(typeof _!="object"||_===null)return!1;let F=_.content??_.message?.content;if(!Array.isArray(F)||F.map(we=>typeof we=="object"&&we!==null&&we.type==="text"?we.text:void 0).filter(we=>typeof we=="string").join("")!==u.lastAutoSentText)return!1;let ve=typeof T.time=="number"?T.time:u.lastAutoSentAt;return Math.abs(ve-u.lastAutoSentAt)<=xx},q=(u,T)=>{let _=-1;for(let F=T-1;F>=0;F-=1)if(u[F].type==="turn/end"){_=F;break}return u.slice(_+1,T+1)},ne=u=>{let T=Ue().waitSeconds*1e3;return u===void 0?T:Math.max(T,Math.min(u,wx))},K=u=>{let T=u.sendTimer!==void 0||u.pendingSendTurnEndSeq!==void 0;p(u),T&&(u.nextSendAt=0,u.phase==="waiting"&&m(u))},S=u=>{u.sendEpoch+=1,u.sendTimer!==void 0&&(clearTimeout(u.sendTimer),i.delete(u.sendTimer));let T=Math.max(0,ne(u.pendingRetryAfterMs)-(Date.now()-u.pendingSendScheduledAt)),_=setTimeout(()=>{i.delete(_),u.sendTimer=void 0,N(u,n("autoContinueMessage"))},T);u.sendTimer=_,u.nextSendAt=Date.now()+T,u.phase="waiting",f(),i.add(_)},C=u=>{try{let T=u.getSnapshot();return{running:T.running===!0,open:T.openState===void 0||T.openState==="open",pending:T.pendingSubmissions?.length??0,subagent:T.subagent!=null}}catch{return}},M=u=>{let T=t.get?.("sessions"),_=t.get?.("uiSession");return pr(T,_)===u.sessionId},w=u=>{if(u.evalTimer!==void 0){u.evalDeadline=Date.now()+Dm;return}u.evalDeadline=Date.now()+Dm,k(u,yx)},k=(u,T)=>{o||r!==u||(u.evalTimer=setTimeout(()=>{u.evalTimer=void 0,W(u)},T),i.add(u.evalTimer))},R=u=>{if(u.historyReady)return;let T=C(u.session);if(T===void 0||!T.open)return;u.historyReady=!0;let _=oe(u.eventSource);u.lastHandledTurnEndSeq=Math.max(u.lastHandledTurnEndSeq,_??ue(u.eventSource,"turn/end"))},I=(u,T)=>{T.kind==="settled"?(u.consecutive=0,m(u)):(K(u),u.phase!=="exhausted"&&m(u))},D=u=>{if(!u.historyReady)return;let T=y(u),_=u.pendingSendTurnEndSeq;_!==void 0&&T.some(F=>F.seq>_&&(F.type==="turn/start"||F.type==="turn/end"))&&K(u);for(let F=T.length-1;F>=0;F-=1){let Q=T[F];if(Q.type!=="turn/end")continue;if(Q.seq<=u.lastHandledTurnEndSeq)return;let ve=Di({turnEnd:Q,turnEvents:q(T,F)},Ue().policy);if(ve.kind!=="continue"){u.lastHandledTurnEndSeq=Q.seq,I(u,ve);return}let we=C(u.session);we!==void 0&&!we.running&&w(u);return}},W=u=>{if(o||r!==u||!Yt()||a.has(u.sessionId))return;let T=C(u.session);if(!u.historyReady||T===void 0||!T.open||T.subagent||T.running||T.pending>0)return;let _=y(u),F=-1;for(let A=_.length-1;A>=0;A-=1){let z=_[A];if(z.type==="turn/end"&&z.seq>u.lastHandledTurnEndSeq){F=A;break}}if(F<0){Date.now()<u.evalDeadline&&k(u,vx);return}let Q=_[F];if(u.lastHandledTurnEndSeq=Q.seq,x(u),_.some(A=>A.seq>Q.seq&&(v(A)||A.type==="turn/start")))return;let ve=Di({turnEnd:Q,turnEvents:q(_,F)},Ue().policy);if(ve.kind!=="continue"){I(u,ve);return}let we=Ue().maxRetries;if(u.consecutive>=we){p(u),u.sendEpoch+=1,console.info(`[dsh-model-think-level] auto-continue: streak cap (${we}) reached, standing down (${ve.detail})`),u.phase="exhausted",u.nextSendAt=0,u.detail=ve.detail,f();return}Pm(u.sessionId,Q.seq)&&(u.pendingSendTurnEndSeq=Q.seq,u.pendingSendScheduledAt=Date.now(),u.pendingRetryAfterMs=ve.waitMs,u.detail=ve.detail,S(u))},N=async(u,T)=>{if(o||r!==u)return;x(u);let _=u.pendingSendTurnEndSeq;u.pendingSendTurnEndSeq=void 0;let F=()=>{u.phase==="waiting"&&m(u)};if(_===void 0||_!==u.lastHandledTurnEndSeq){F();return}if(!Yt()||a.has(u.sessionId)||u.consecutive>=Ue().maxRetries){F();return}let Q=C(u.session);if(Q===void 0||!Q.open||Q.subagent||Q.running||Q.pending>0||!M(u)){F();return}if(y(u).some(z=>z.seq>_&&(v(z)||z.type==="turn/start"||z.type==="turn/end"))){F();return}p(u);let we=++u.sendEpoch;u.lastAutoSentAt=Date.now(),u.lastAutoSentText=T,u.consecutive+=1,u.phase="sent",u.nextSendAt=0,f();let A=()=>!o&&r===u&&u.sendEpoch===we;if(A())try{let z=await u.session.prompt([{type:"text",text:T}],"queue");if(!A())return;z?.ok!==!0&&(u.lastAutoSentText=void 0,u.phase=u.consecutive>=Ue().maxRetries?"exhausted":"idle",f(),console.warn(`[dsh-model-think-level] auto-continue: prompt refused ${V(z)}`))}catch(z){if(!A())return;u.lastAutoSentText=void 0,u.phase=u.consecutive>=Ue().maxRetries?"exhausted":"idle",f(),console.warn("[dsh-model-think-level] auto-continue: prompt failed:",z)}},V=u=>{let T=u?.error;if(T===void 0)return"without an error";let _=typeof T.code=="string"?T.code:"unknown",F=typeof T.message=="string"?T.message:"";return F.length>0?`${_}: ${F}`:_},ie=u=>{let T=C(u.session);T!==void 0&&(R(u),(!T.open||T.subagent||T.running||T.pending>0)&&K(u),T.pending>0&&(u.lastHandledTurnEndSeq=Math.max(u.lastHandledTurnEndSeq,ue(u.eventSource,"turn/end")),u.evalTimer!==void 0&&(clearTimeout(u.evalTimer),i.delete(u.evalTimer),u.evalTimer=void 0),u.evalDeadline=0),u.wasRunning&&!T.running&&w(u),u.wasRunning=T.running)},re=u=>{let T=[];for(let _ of g(u))_.type==="turn/end"&&T.push(_.seq);return T.length<2?0:(T.sort((_,F)=>_-F),T[T.length-2])},oe=u=>{let T=g(u),_=-1;for(let ve=T.length-1;ve>=0;ve-=1)if(T[ve].type==="turn/end"){_=ve;break}if(_<0)return;let F=T[_],Q=typeof F.time=="number"?F.time:Date.now();if(!(Date.now()-Q>kx)&&!T.some(ve=>ve.seq>F.seq&&(v(ve)||ve.type==="turn/start")))return Di({turnEnd:F,turnEvents:q(T,_)},Ue().policy).kind==="continue"?re(u):void 0},ae=u=>{if(o||r!==u||u.evalTimer!==void 0||!Yt()||a.has(u.sessionId)||!u.historyReady)return;let T=C(u.session);if(T===void 0||!T.open||T.subagent||T.running||T.pending>0)return;let _=y(u);for(let F=_.length-1;F>=0;F-=1){let Q=_[F];if(Q.type==="turn/end"&&Q.seq>u.lastHandledTurnEndSeq){w(u);return}}},de=()=>{let u=r;if(u!==void 0){r=void 0;for(let T of u.unsubs)try{T()}catch{}u.evalTimer!==void 0&&(clearTimeout(u.evalTimer),i.delete(u.evalTimer),u.evalTimer=void 0),u.sendTimer!==void 0&&(clearTimeout(u.sendTimer),i.delete(u.sendTimer),u.sendTimer=void 0),f()}},he=u=>{let T=C(u.session);if(T===void 0||T.subagent)return;let _=T.open?oe(u.eventSource):void 0,F={sessionId:u.sessionId,session:u.session,eventSource:u.eventSource,wasRunning:te(u.session),lastUserSeq:ue(u.eventSource,"user/message"),historyReady:T.open,lastHandledTurnEndSeq:T.open?_??ue(u.eventSource,"turn/end"):0,consecutive:0,phase:"idle",sendEpoch:0,nextSendAt:0,detail:"",pendingSendTurnEndSeq:void 0,pendingSendScheduledAt:0,pendingRetryAfterMs:void 0,lastAutoSentAt:0,lastAutoSentText:void 0,unsubs:[],evalDeadline:0,evalTimer:void 0,sendTimer:void 0};r=F,f();try{F.unsubs.push(u.session.subscribe(()=>ie(F)))}catch{de();return}try{F.unsubs.push(u.eventSource.subscribe(()=>{x(F),R(F),D(F)}))}catch(Q){de(),console.warn("[dsh-model-think-level] auto-continue: event source unusable:",Q);return}},te=u=>{try{return u.getSnapshot().running===!0}catch{return!1}},ue=(u,T)=>{let _=0,F=[];try{F=u.getSnapshot().entries??[]}catch{return 0}for(let Q of F)Q.type!=="event"||Q.event===void 0||Q.event.type===T&&Q.event.seq>_&&(_=Q.event.seq);return _},Te=()=>{if(o)return;let u=t.get?.("sessions"),T=t.get?.("uiSession"),_=pr(u,T);if(_===void 0||u===void 0||typeof u.binding!="function"){de();return}let F;try{F=u.binding(_)}catch{F=void 0}if(F===void 0||F.session===void 0){de();return}if(r!==void 0&&r.session===F.session){ae(r);return}de(),he(F),r!==void 0&&ae(r)},Le=setInterval(Te,bx);Te();let He;try{He=t.on?.("connection/reset",()=>{de()})}catch{}let Y=$i(()=>{let u=r;Yt()||u===void 0||(K(u),m(u),u.evalTimer!==void 0&&(clearTimeout(u.evalTimer),i.delete(u.evalTimer),u.evalTimer=void 0))}),B=Vi(()=>{let u=r;f(),u?.pendingSendTurnEndSeq!==void 0&&(!Yt()||u.consecutive>=Ue().maxRetries?K(u):S(u))});return{status:h,subscribe:u=>(s.add(u),()=>{s.delete(u)}),stop:()=>{let u=r;u!==void 0&&(K(u),u.evalTimer!==void 0&&(clearTimeout(u.evalTimer),i.delete(u.evalTimer),u.evalTimer=void 0),u.evalDeadline=0,u.consecutive=0,a.add(u.sessionId),m(u))},reset:()=>{let u=r;u!==void 0&&(u.consecutive=0,a.delete(u.sessionId),m(u))},resumeNow:()=>{let u=r;u!==void 0&&u.pendingSendTurnEndSeq!==void 0&&(u.sendTimer!==void 0&&(clearTimeout(u.sendTimer),i.delete(u.sendTimer),u.sendTimer=void 0),N(u,n("autoContinueMessage")))},dispose:()=>{o=!0,Y(),B(),He?.(),clearInterval(Le),de(),s.clear();for(let u of i)clearTimeout(u);i.clear()}}}var Ex=[[/\b(sk|rk|ak)-[A-Za-z0-9_-]{8,}/g,"$1-***"],[/("?(?:api[_-]?key|apikey|authorization|access[_-]?token|token|x-api-key)"?\s*[:=]\s*"?)[^",}\s]+/gi,"$1***"],[/\bBearer\s+[A-Za-z0-9._-]{10,}/gi,"Bearer ***"]];function Tx(e){let t=String(e??"");for(let[n,r]of Ex)t=t.replace(n,r);return t}function Sx(e,t,n){let r=Tx(typeof e.message=="string"?e.message:JSON.stringify(e)),o,i=r,a=/^\s*(\d{3})\s*:\s*([\s\S]*)$/.exec(r);a!==null&&(o=Number(a[1]),i=a[2]??"");let s;try{let l=JSON.parse(i);l!==null&&typeof l=="object"&&(s=l)}catch{s=void 0}let d=typeof s?.message=="string"&&s.message.length>0?s.message:i.trim().length>0?i.trim():r;return{sessionId:t,seq:n,code:typeof e.code=="string"?e.code:"UNKNOWN",http:o,reason:d,providerCode:typeof s?.code=="string"?s.code:void 0,traceId:typeof s?.traceId=="string"?s.traceId:void 0,raw:r}}var Yi=e=>`${e.sessionId}:${e.seq}`;function Mx(e,t){let n=[];try{n=e.getSnapshot().entries??[]}catch{return[]}let r=[],o=new Set;for(let i of n){if(i?.type!=="event"||i.event===void 0)continue;let a=i.event;if(a.type!=="turn/end")continue;let s=a.data?.reason;if(s?.kind!=="error"||s.error===void 0)continue;let d=a.seq??0;o.has(d)||(o.add(d),r.push(Sx(s.error,t,d)))}return r}var Lx='[class*="turnErrorRow"]',Ax='code[class*="turnErrorCode"]',Ed='[class*="turnErrorMessage"]',io="data-bre-error-detail",qm={AUTH:"API \u5BC6\u94A5\u65E0\u6548",QUOTA:"\u989D\u5EA6\u4E0D\u8DB3",ACCOUNT_QUOTA:"\u989D\u5EA6\u4E0D\u8DB3",ACCOUNT_SIGNED_OUT:"\u8D26\u53F7\u5DF2\u9000\u51FA",ACCOUNT_SIGN_IN_REQUIRED:"\u9700\u8981\u767B\u5F55",INTERRUPTED:"\u5DF2\u4E2D\u65AD"};function Fm(e,t){return(e.querySelector(t)?.textContent??"").trim()}function Rx(e){let t=e.querySelector(Ed);if(t===null)return"";let n="";for(let r of t.childNodes)r instanceof HTMLElement&&r.hasAttribute(io)||(n+=r.textContent??"");return n.trim()}function Cx(e,t,n){if(t.length===0)return;let r=Fm(e,Ax),o=Fm(e,Ed),i=t.filter(l=>!n.has(Yi(l))),a=r.length===0?i:i.filter(l=>l.code===r);if(a.length===0)return;let s=qm[r];return s!==void 0&&o===s?a[0]:a.find(l=>{if(l.http!==void 0&&o.startsWith(`${l.http}:`))return!0;let c=l.raw;return c.length===0||o.length===0?!1:c.startsWith(o.slice(0,40))||o.startsWith(c.slice(0,40))})??a[0]}var oo="bre-error-detail-popover";function Oe(e,t,n){let r=document.createElement(e);return t!==void 0&&(r.className=t),n!==void 0&&(r.textContent=n),r}async function Hx(e){try{return await navigator.clipboard.writeText(e),!0}catch{try{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.append(t),t.select();let n=document.execCommand("copy");return t.remove(),n}catch{return!1}}}function Km(e){let{ctx:t,t:n}=e,r=[],o=!1,i,a=(M,w)=>{let k=Oe("button","bre-ed-copy",w);return k.type="button",k.addEventListener("click",()=>{Hx(M).then(R=>{R&&(k.textContent=n("errorDetailCopied"),window.setTimeout(()=>{k.textContent=w},1400))})}),k},s=(M,w,k={})=>{if(w===void 0||w.length===0)return null;let R=Oe("div","bre-ed-row");R.append(Oe("span","bre-ed-label",M));let I=["bre-ed-value"];return k.mono===!0&&I.push("bre-ed-mono"),k.muted===!0&&I.push("bre-ed-muted"),R.append(Oe("span",I.join(" "),w)),k.copy===!0&&R.append(a(w,n("errorDetailCopy"))),R},d=(M,w)=>{let k=qm[M];return k===void 0?`${w} \u2014 ${n("errorDetailUnwrapped")}`:w===k?`${w} \u2014 ${n("errorDetailFixedLabel")}`:k},l=()=>{let M=document.getElementById(oo);if(M instanceof HTMLDivElement)return M;let w=Oe("div","bre-ed-pop");return w.id=oo,w.setAttribute("role","dialog"),w.setAttribute("aria-label",n("errorDetailTitle")),document.body.append(w),w},c=()=>{let M=document.getElementById(oo);M!==null&&(M.style.display="none"),document.removeEventListener("pointerdown",f,!0),document.removeEventListener("keydown",h,!0),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c,!0)};function f(M){let w=document.getElementById(oo);w!==null&&(M.target instanceof Node&&w.contains(M.target)||M.target instanceof Element&&M.target.closest(`[${io}]`)!==null||c())}function h(M){M.key==="Escape"&&c()}let p=(M,w)=>{let k=w.getBoundingClientRect();M.style.visibility="hidden",M.style.left="0px",M.style.top="0px";let R=M.offsetWidth,I=M.offsetHeight,D=8;if(k.bottom<D||k.top>window.innerHeight-D){let V=Math.max(D,(window.innerWidth-R)/2),ie=Math.max(D,(window.innerHeight-I)/2);M.style.left=`${Math.round(V)}px`,M.style.top=`${Math.round(ie)}px`,M.style.visibility="";return}let W=Math.min(Math.max(D,k.left),Math.max(D,window.innerWidth-R-D)),N=k.bottom+D;N+I>window.innerHeight-D&&(N=Math.max(D,k.top-I-D)),M.style.left=`${Math.round(W)}px`,M.style.top=`${Math.round(N)}px`,M.style.visibility=""},m=(M,w,k)=>{let R=l();R.textContent="";let I=Oe("div","bre-ed-head");I.append(Oe("span","bre-ed-dot")),I.append(Oe("span","bre-ed-title",n("errorDetailTitle")));let D=Oe("span","bre-ed-chips");M.http!==void 0&&D.append(Oe("code","bre-ed-chip",`HTTP ${M.http}`)),M.providerCode!==void 0&&D.append(Oe("code","bre-ed-chip bre-ed-chip-strong",M.providerCode)),I.append(D);let W=Oe("button","bre-ed-x","\xD7");W.type="button",W.setAttribute("aria-label",n("errorDetailClose")),W.addEventListener("click",()=>c()),I.append(W),R.append(I);let N=Oe("div","bre-ed-body"),V=[s(n("errorDetailReason"),M.reason),s(n("errorDetailTrace"),M.traceId,{mono:!0,copy:!0}),s(n("errorDetailCode"),M.code,{mono:!0}),s(n("errorDetailShown"),d(M.code,k),{muted:!0})];for(let de of V)de!==null&&N.append(de);R.append(N);let ie=Oe("div","bre-ed-raw"),re=Oe("button","bre-ed-raw-toggle",`\u25B8 ${n("errorDetailRaw")}`);re.type="button";let oe=Oe("pre","bre-ed-pre",M.raw);oe.hidden=!0,re.addEventListener("click",()=>{oe.hidden=!oe.hidden,re.textContent=`${oe.hidden?"\u25B8":"\u25BE"} ${n("errorDetailRaw")}`}),ie.append(re,oe),R.append(ie);let ae=Oe("div","bre-ed-foot");ae.append(Oe("span","bre-ed-src",n("errorDetailSource"))),ae.append(a(M.raw,n("errorDetailCopyRaw"))),R.append(ae),R.style.display="block",p(R,w),document.addEventListener("pointerdown",f,!0),document.addEventListener("keydown",h,!0),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c,!0)},b=()=>{let M=document.querySelectorAll(Lx);if(M.length===0)return;let w=new Set,k=n("errorDetailButton");for(let R of M){let I=Cx(R,r,w);if(I===void 0)continue;w.add(Yi(I));let D=Rx(R),W=R.querySelector(Ed)??R,N=W.querySelector(`:scope > button[${io}]`);N===null&&(N=document.createElement("button"),N.type="button",N.className="bre-ed-view",N.setAttribute(io,"1"),W.append(N)),N.textContent!==k&&(N.textContent=k),N.onclick=V=>{V.preventDefault(),V.stopPropagation(),m(I,N,D)}}},g=()=>{i===void 0&&(i=window.setTimeout(()=>{i=void 0,b()},120))},y,v,x=(M,w)=>{if(o)return;let k=Mx(w,M);k.length===r.length&&k.every((I,D)=>Yi(I)===Yi(r[D]))||(r=k,g())},H=()=>{v?.(),v=void 0},q=M=>{let w=t.get?.("sessions"),k;try{k=w?.binding?.(M)}catch{k=void 0}let R=k?.eventSource;if(R!==void 0)try{x(M,R),v=R.subscribe(()=>{try{x(M,R)}catch{}})}catch{v=void 0}},ne=()=>{if(o)return;let M=t.get?.("sessions"),w=t.get?.("uiSession"),k=pr(M,w);k===y&&v!==void 0||(k!==y&&(H(),y=k,r=[],c(),g()),k!==void 0&&q(k))},K=window.setInterval(ne,1e3);ne();let S=new MutationObserver(g);S.observe(document.body,{childList:!0,subtree:!0});let C=window.setInterval(b,1500);return b(),{dispose:()=>{o=!0,window.clearInterval(K),window.clearInterval(C),i!==void 0&&window.clearTimeout(i),i=void 0,S.disconnect(),H(),y=void 0,r=[],c();for(let M of document.querySelectorAll(`[${io}]`))M.remove();document.getElementById(oo)?.remove()}}}var Ji="dsh-model-think-level.error-detail.enabled";function Nx(e){try{return window.localStorage.getItem(e)}catch{return null}}var ao=Nx(Ji)!=="false",Td=new Set;function Bm(){for(let e of[...Td])e()}function Xi(){return ao}function Wm(e){if(ao!==e){ao=e;try{window.localStorage.setItem(Ji,String(e))}catch{}Bm()}}function Sd(e){ao!==e&&(ao=e,Bm())}function Qi(e){return Td.add(e),()=>{Td.delete(e)}}var Jt=require("react");var Pt=require("react/jsx-runtime"),Ox="[data-composer-dock]",Ix="[data-composer-stats]",Px="[data-composer-stat]",Dx="data-bre-autocontinue";function _x(){let t=Array.from(document.querySelectorAll(Ox)).filter(a=>a.isConnected&&a.getClientRects().length>0).at(-1);if(t!==void 0)return t;let n=document.querySelector(Ix);if(n!==null&&n.isConnected&&n.getClientRects().length>0)return n;let r=Array.from(document.querySelectorAll(Px)).filter(a=>a.isConnected&&a.getClientRects().length>0),o=r[0];if(o===void 0)return;let i=o.parentElement??void 0;for(let a=0;i!==void 0&&a<8&&!r.every(s=>i!==void 0&&i.contains(s));a+=1)i=i.parentElement??void 0;return i}function Fx(e){let{runner:t,t:n}=e,r=(0,Jt.useSyncExternalStore)(t.subscribe,t.status),[o,i]=(0,Jt.useState)(!1),[a,s]=(0,Jt.useState)(()=>Date.now());if((0,Jt.useEffect)(()=>{if(r.phase!=="waiting")return;s(Date.now());let p=window.setInterval(()=>s(Date.now()),500);return()=>window.clearInterval(p)},[r.phase,r.nextSendAt]),(0,Jt.useEffect)(()=>{r.phase==="idle"&&i(!1)},[r.phase]),r.sessionId===void 0||r.phase==="idle")return null;let d=Math.max(0,Math.ceil((r.nextSendAt-a)/1e3)),l=r.phase==="waiting"?n("autoContinueControllerWaiting",{n:r.consecutive+1,max:r.maxRetries,seconds:d}):r.phase==="sent"?n("autoContinueControllerSent",{n:r.consecutive,max:r.maxRetries}):n("autoContinueControllerExhausted",{max:r.maxRetries}),c=r.detail===""?void 0:n("autoContinueControllerDetail",{detail:r.detail}),f=(p,m)=>(0,Pt.jsx)("button",{type:"button",role:"menuitem",className:"bre-ac-action",onClick:()=>{i(!1),m()},children:p},p),h=[];return r.phase==="waiting"&&h.push(f(n("autoContinueControllerResume"),()=>t.resumeNow())),(r.phase==="waiting"||r.phase==="sent")&&h.push(f(n("autoContinueControllerStop"),()=>t.stop())),r.phase==="exhausted"&&h.push(f(n("autoContinueControllerReset"),()=>t.reset())),h.push(f(n("autoContinueControllerSettings"),e.onSettings)),(0,Pt.jsxs)("span",{className:"bre-ac",children:[(0,Pt.jsxs)("button",{type:"button",className:`bre-ac-chip bre-ac-chip-${r.phase}`,"aria-label":n("autoContinueControllerAria"),"aria-expanded":o,title:c??l,onClick:()=>i(p=>!p),children:[(0,Pt.jsx)("span",{className:"bre-ac-dot","aria-hidden":"true"}),(0,Pt.jsx)("span",{className:"bre-ac-text",children:l})]}),o&&(0,Pt.jsx)("div",{className:"bre-ac-pop",role:"menu",children:h})]})}function Gm(e){let t,n,r=0,o=0,i=()=>{Ne(n),n=void 0,t?.remove(),t=void 0},a=()=>{let c=_x();if(c===void 0){i();return}t!==void 0&&t.parentElement===c&&t.isConnected||(i(),t=document.createElement("span"),t.className="bre-ac-host",t.setAttribute(Dx,""),c.append(t),n=Xe(t,(0,Pt.jsx)(Fx,{runner:e.runner,t:e.t,onSettings:e.onSettings})))},s=()=>{if(r!==0)return;let c=Math.max(0,400-(Date.now()-o));r=window.setTimeout(()=>{r=0,o=Date.now(),a()},c)},d=new MutationObserver(s);d.observe(document.body,{childList:!0,subtree:!0});let l=window.setInterval(a,2e3);return a(),()=>{d.disconnect(),window.clearInterval(l),r!==0&&window.clearTimeout(r),i()}}var vt=require("react");var Ie=require("react");var Dt=require("react/jsx-runtime");function Um(e){let t=e.data;if(typeof t!="object"||t===null)return;let n=t,r={},o=n.providers;if(typeof o=="object"&&o!==null&&!Array.isArray(o))for(let[a,s]of Object.entries(o))s===!0&&(r[a]=!0);let i=n.installed;return typeof i=="boolean"?{providers:r,installed:i}:{providers:r}}function jm({t:e,value:t,installed:n,disabled:r=!1,onChange:o}){let i=(0,Ie.useId)(),a=`${i}-title`,s=`${i}-hint`,d=e("historyCompatHint")+" "+e("historyCompatCost");return(0,Dt.jsxs)("div",{className:"bre-camouflage","data-plugin":ke,"data-open":"1","data-section":"history-compat",title:d,children:[(0,Dt.jsx)("span",{className:"bre-effort-title",id:a,children:e("historyCompatTitle")}),(0,Dt.jsxs)("label",{className:"bre-thinking-switch bre-camouflage-toggle",children:[(0,Dt.jsx)("input",{type:"checkbox",role:"switch",checked:t,disabled:r,"aria-labelledby":a,"aria-describedby":s,onChange:l=>{o(l.target.checked)}}),(0,Dt.jsx)("span",{className:"bre-effort-switch-track","aria-hidden":"true"})]}),(0,Dt.jsx)("span",{className:"bre-sr-only",id:s,children:d}),n?null:(0,Dt.jsx)("p",{className:"bre-camouflage-warn",children:e("historyCompatUnavailable")})]})}function zm(e){let[t,n]=(0,Ie.useState)(!1),[r,o]=(0,Ie.useState)(!1),[i,a]=(0,Ie.useState)(!0),[s,d]=(0,Ie.useState)(!0),l=(0,Ie.useRef)(!1),c=(0,Ie.useRef)(!1),f=(0,Ie.useRef)(!0);(0,Ie.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]),(0,Ie.useEffect)(()=>{if(e===""){d(!1);return}let b=!1;return d(!0),fetch(oa,{method:"GET"}).then(async g=>await g.json()).then(g=>{if(b||!f.current)return;let y=Um(g);if(y===void 0)return;let v=y.providers[e]===!0;l.current=v,c.current=v,n(v),o(v),y.installed!==void 0&&a(y.installed)}).catch(()=>{}).finally(()=>{!b&&f.current&&d(!1)}),()=>{b=!0}},[e]);let h=(0,Ie.useCallback)(b=>{c.current=b,o(b)},[]),p=(0,Ie.useCallback)(()=>{c.current=l.current,o(l.current)},[]),m=(0,Ie.useCallback)(async()=>{if(e===""||c.current===l.current)return;let b=c.current,g=await fetch(oa,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({route:e,enabled:b})}),y=await g.json();if(!g.ok||y.ok!==!0)throw new Error("history-compat write rejected");let v=Um(y);l.current=b,c.current=b,n(b),o(b),v!==void 0&&v.installed!==void 0&&a(v.installed)},[e]);return{value:r,saved:t,installed:i,loading:s,setValue:h,reset:p,commit:m}}var Xt=require("react/jsx-runtime");function $m({route:e,api:t,t:n,onDismiss:r}){let o=Us(e,n),i=zm(e);return(0,Xt.jsx)(wi,{route:e,api:t,t:n,onDismiss:r,extras:(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Gs,{t:n,value:o.value,installed:o.installed,disabled:o.loading,onChange:o.setValue}),(0,Xt.jsx)(jm,{t:n,value:i.value,installed:i.installed,disabled:i.loading,onChange:i.setValue})]}),onCommitExtras:async()=>{let s=(await Promise.allSettled([o.commit(),i.commit()])).find(d=>d.status==="rejected");if(s!==void 0)throw s.reason},onResetExtras:()=>{o.reset(),i.reset()}})}var $=require("react");function Vm(e){let t=[];for(let i of e){let a=i.timing?.durationMs;typeof a=="number"&&Number.isFinite(a)&&a>0&&t.push(a)}if(t.length===0)return;t.sort((i,a)=>i-a);let n=t.length>>1,o=(t.length%2===1?t[n]:(t[n-1]+t[n])/2)/1e3;return o>=75?{unit:"minutes",value:Math.max(1,Math.round(o/60))}:{unit:"seconds",value:Math.max(5,Math.round(o/5)*5)}}var qx=/^(gpt-|chatgpt-|o[134](-|$)|claude-)/;function Kx(e){let t=String(e??"").trim(),n=t.lastIndexOf("/");return n===-1?t:t.slice(n+1)}function Ym(e){let t=Kx(e).toLowerCase();return t.length>0&&qx.test(t)}var Jm={running:new Map,queued:[]};function lo(e){return typeof e!="number"||!Number.isFinite(e)?"\u2014":`${Math.round(e*100)}%`}function Bx(e){return!Number.isFinite(e)||e<=0?"\u2014":new Date(e).toLocaleString()}function Xm(e){return typeof e!="number"||!Number.isFinite(e)||e<0?"\u2014":(Math.round(e/100)/10).toFixed(1)}function Wx(e,t){return t===void 0?e("fpCostUnknown",{count:3}):t.unit==="minutes"?e("fpCostMinutes",{count:3,minutes:t.value}):e("fpCost",{count:3,seconds:t.value})}function Qm({route:e,api:t,t:n,ctx:r,host:o}){let[i]=(0,$.useState)(()=>kf(o.current)),[a,s]=(0,$.useState)([]),[d,l]=(0,$.useState)(new Map),[c,f]=(0,$.useState)(void 0),[h,p]=(0,$.useState)(void 0),[m,b]=(0,$.useState)(new Set),g=(0,$.useCallback)(k=>{b(R=>{let I=new Set(R);return I.has(k)?I.delete(k):I.add(k),I})},[]),y=(0,$.useMemo)(()=>i?void 0:Mm(e),[i,e]),v=(0,$.useSyncExternalStore)((0,$.useCallback)(k=>y?.subscribe(k)??(()=>{}),[y]),(0,$.useCallback)(()=>y?.getState()??Jm,[y]),(0,$.useCallback)(()=>Jm,[]));(0,$.useEffect)(()=>{if(y!==void 0)return y.onRecord(k=>{p(void 0),l(R=>{let I=new Map(R);return I.set(k.model,k),I})})},[y]),(0,$.useEffect)(()=>{if(y!==void 0)return y.onFailure((k,R)=>{p({model:k,error:R})})},[y]);let x=(0,$.useCallback)(async()=>{if(i)return;let R=(await pe(t)).namespace?.value?.providers,I=Dn(R,e).map(W=>W.id).filter(W=>typeof W=="string"&&W.length>0).filter(Ym);s(I.map(W=>({model:W})));let D=await hd(e);D.ok?(f(void 0),l(new Map(D.data.records.map(W=>[W.model,W])))):f(D.error)},[t,i,e]);if((0,$.useEffect)(()=>{i||x()},[i,x]),(0,$.useEffect)(()=>{if(!(i||r===void 0))return r.remote.$on("settings/document-updated",()=>{x()})},[i,r,x]),i)return null;let H=a.length,q=a.filter(k=>d.has(k.model)).length,ne=a.filter(k=>d.get(k.model)?.status==="identified").length,K=a.filter(k=>d.get(k.model)?.status==="doubtful").length,S=a.filter(k=>d.get(k.model)?.status==="failed").length,C=v.running.size>0,M=v.running.size+v.queued.length,w=(0,$.useMemo)(()=>Vm([...d.values()]),[d]);return(0,$.createElement)("div",{className:"bre-fingerprint","data-bre-fingerprint":H>0?"ready":"none"},(0,$.createElement)("div",{className:"bre-fp-head"},(0,$.createElement)("span",{className:"bre-fp-title"},n("fpTitle")),(0,$.createElement)("span",{className:"bre-fp-count"},n("fpCount",{count:H})),(0,$.createElement)("span",{className:"bre-fp-summary",role:"status","aria-live":"polite"},C?n("fpRunning",{done:v.running.size,total:M}):q===0?n("fpSummaryNone"):n("fpSummary",{identified:ne,doubtful:K,failed:S})),(0,$.createElement)("span",{className:"grow"}),(0,$.createElement)("button",{type:"button",className:"bre-fp-all",disabled:C||H===0,onClick:()=>{y?.checkAll(a.map(k=>k.model))}},n("fpDetectAll"))),(0,$.createElement)("p",{className:"bre-fp-intro"},n("fpIntro")),c!==void 0?(0,$.createElement)("p",{className:"bre-fp-error"},n("fpLoadFailed",{error:c})):null,h!==void 0?(0,$.createElement)("p",{className:"bre-fp-error",role:"alert"},n("fpRunFailed",{error:`${h.model}: ${h.error}`})):null,(0,$.createElement)("div",{className:"bre-fp-rows"},...a.map(k=>Ux(k,{t:n,runner:y,runnerState:v,records:d,route:e,expanded:m,estimate:w,onToggle:g}))))}function Gx(e){return(0,$.createElement)("svg",{className:"bre-fp-chev"+(e?" is-open":""),viewBox:"0 0 16 16",width:12,height:12,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:!1},(0,$.createElement)("path",{d:e?"M4.5 6.5 8 10 11.5 6.5":"M6.5 4.5 10 8 6.5 11.5"}))}function Ux(e,t){let{t:n,runner:r,runnerState:o,records:i,expanded:a,estimate:s,onToggle:d}=t,l=i.get(e.model),c=o.running.get(e.model),f=o.queued.indexOf(e.model),h=c!==void 0,p=f>=0,m=a.has(e.model),b=h?{className:"is-running",text:n("fpStateRunning",{done:c,total:3})}:p?{className:"is-queued",text:n("fpQueued",{position:f+1})}:l===void 0?{className:"is-idle",text:n("fpStateUnchecked")}:l.status==="failed"?{className:"is-failed",text:n("fpStateFailed")}:l.status==="doubtful"?{className:"is-doubtful",text:n("fpStateDoubtful",{probability:lo(l.probability)})}:{className:"is-identified",text:n("fpStateIdentified",{model:l.predictionName??l.prediction??e.model,probability:lo(l.probability)})},g=l===void 0?"fpDetect":l.status==="failed"?"fpRetry":"fpRetest";return(0,$.createElement)("div",{className:"bre-fp-row",key:e.model,"data-bre-fp-open":m?"1":void 0},(0,$.createElement)("div",{className:"bre-fp-row-head"},(0,$.createElement)("button",{type:"button",className:"bre-fp-fold","aria-expanded":m,"aria-label":n(m?"fpDetailHide":"fpDetailShow")+" "+e.model,title:n(m?"fpDetailHide":"fpDetailShow"),onClick:()=>{d(e.model)}},Gx(m),(0,$.createElement)("span",{className:"bre-fp-model"},e.model)),(0,$.createElement)("span",{className:`bre-fp-badge ${b.className}`},b.text),(0,$.createElement)("span",{className:"grow"}),(0,$.createElement)("span",{className:"bre-fp-evidence"},l===void 0?Wx(n,s):n("fpEvidence",{used:l.usedOutputs,total:3})),(0,$.createElement)("button",{type:"button",className:"bre-fp-action",disabled:h||p,onClick:()=>{r?.check(e.model)}},n(g))),!m||l===void 0?null:l.status!=="failed"?zx(l,n):jx(l,n))}function Zm(e,t){return e===void 0||e.length===0?null:(0,$.createElement)("div",{className:"bre-fp-chals",title:t("fpChallengeTitle")},...e.map(n=>{let r=n.skipped===!0?" is-skipped":n.accepted?" is-counted":" is-rejected",o=n.skipped===!0?t("fpChallengeSkipped",{index:n.index,numbers:n.expected}):n.accepted?t("fpChallengeCounted",{index:n.index,numbers:n.expected}):t("fpChallengeRejected",{index:n.index,parsed:n.parsed,numbers:n.expected});return(0,$.createElement)("span",{className:`bre-fp-chal${r}`,key:n.index},o)}))}function jx(e,t){let n=e.challenges,r=n!==void 0&&n.length>0;return e.error===void 0&&!r?null:(0,$.createElement)("div",{className:"bre-fp-body"},e.error===void 0?null:(0,$.createElement)("p",{className:"bre-fp-error"},e.error),Zm(n,t))}function zx(e,t){let n=e.top??[],r=e.timing;return(0,$.createElement)("div",{className:"bre-fp-body"},(0,$.createElement)("div",{className:"bre-fp-family"},(0,$.createElement)("span",{className:"bre-fp-k"},t("fpFamily")),(0,$.createElement)("span",{className:"bre-fp-v"},`${e.familyPrediction??"\u2014"} \xB7 ${lo(e.familyProbability)}`),(0,$.createElement)("span",{className:"bre-fp-k"},t("fpSimilarity")),(0,$.createElement)("span",{className:"bre-fp-v"},lo(e.top?.[0]?.similarity)),(0,$.createElement)("span",{className:"grow"}),(0,$.createElement)("span",{className:"bre-fp-k"},t("fpCheckedAt",{time:Bx(e.checkedAt)}))),Zm(e.challenges,t),r!==void 0?(0,$.createElement)("p",{className:"bre-fp-timing"},t("fpTiming",{first:Xm(r.firstTokenMs),total:Xm(r.durationMs),rate:r.charsPerSecond===void 0?"\u2014":String(Math.round(r.charsPerSecond))})):null,(0,$.createElement)("div",{className:"bre-fp-k",style:{marginTop:"8px"}},t("fpCandidates")),(0,$.createElement)("div",{className:"bre-fp-bars"},...n.map((o,i)=>(0,$.createElement)("div",{className:"bre-fp-bar",key:o.model},(0,$.createElement)("span",{className:"bre-fp-bar-name"},o.model),(0,$.createElement)("span",{className:`bre-fp-bar-fill${i===0?" is-top":""}`,style:{width:`${Math.max(2,Math.round(o.probability*100))}%`}}),(0,$.createElement)("span",{className:"bre-fp-bar-value"},lo(o.probability))))),(0,$.createElement)("p",{className:"bre-fp-note"},t("fpClosedSet")))}var eg="settings.models.provider-card";function $x(e){if(e===null)return;let t=e.querySelector('[class*="editorActions"]');if(t===null)return;let n=Array.from(t.querySelectorAll("button")),r=t.querySelector('button[class*="secondaryButton"]')??n.at(-2)??null;r!==null&&(r instanceof HTMLButtonElement&&r.disabled||r.click())}function Vx({provider:e,api:t,t:n,ctx:r}){let o=(0,vt.useRef)(null),i=e?.provider,a=(0,vt.useCallback)(()=>{$x(rr(o.current))},[]);return(0,vt.useLayoutEffect)(()=>{let s=o.current,d=rr(s);if(s===null||d===null)return;let l=d,c=()=>d.querySelector('[class*="_editor"]')!==null,f=()=>{let p=c()?"1":"0";s.dataset.edit!==p&&(s.dataset.edit=p)};f();let h=new MutationObserver(f);return h.observe(l,{childList:!0,subtree:!0}),()=>{h.disconnect()}},[i]),typeof i!="string"||i.length===0?null:(0,vt.createElement)("div",{ref:o,className:"bre-headers-host","data-bre-provider":i},(0,vt.createElement)(xi,{host:o,t:n}),(0,vt.createElement)($m,{route:i,api:t,t:n,onDismiss:a}),(0,vt.createElement)(Qm,{route:i,api:t,t:n,ctx:r,host:o}))}function tg(e,t,n){let r=e,o=r.slots?.inject(eg,()=>{r.slots?.register({name:eg,key:De,inject:()=>({api:t,t:n,ctx:e})},Vx)});return typeof o=="function"?o:()=>{}}var ut=require("react");function ng(e){let{t}=e,n=(0,ut.useSyncExternalStore)(ho,mt),r=()=>{qd(!n)};return(0,ut.createElement)("div",{className:"bre-slider-setting"},(0,ut.createElement)("div",{className:"bre-slider-setting-row"},(0,ut.createElement)("div",{className:"bre-slider-setting-copy"},(0,ut.createElement)("div",{className:"bre-slider-setting-title"},t("sliderToggleTitle")),(0,ut.createElement)("div",{className:"bre-slider-setting-description"},t("sliderToggleDescription"))),(0,ut.createElement)("div",{className:"bre-slider-setting-control"},(0,ut.createElement)("span",{className:"bre-slider-setting-state"},t(n?"settingOn":"settingOff")),(0,ut.createElement)("button",{type:"button",role:"switch","aria-label":t("sliderToggleAria"),"aria-checked":n,className:"bre-slider-setting-switch"+(n?" is-on":""),onClick:r},(0,ut.createElement)("span",{className:"bre-slider-setting-switch-knob","aria-hidden":!0})))))}function rg(e,t){let n=e,r=n.slots?.inject("settings.models.footer",()=>{n.slots?.register({name:"settings.models.footer",id:ke+"-slider-toggle",order:15,inject:()=>({t})},ng)});return typeof r=="function"?r:()=>{}}var E=require("react"),ag=require("react-dom/client");var Zi=[{label:"1K",value:"1024x1024",edge:1024},{label:"2K",value:"2048x2048",edge:2048},{label:"4K",value:"4096x4096",edge:4096}];function Yx(e){let t=/^(\d{2,5})x(\d{2,5})$/.exec(e.trim());if(t!==null)return Math.max(Number(t[1]),Number(t[2]))}function Jx(e){let t=Yx(e),n=Zi[0];if(t===void 0)return n;let r=Number.POSITIVE_INFINITY;for(let o of Zi){let i=Math.abs(o.edge-t);i<r&&(n=o,r=i)}return n}function og(e){return Jx(e).value}var Xx=[5,10,15,30,60];function Qx(e){let t=Xx.map(n=>n*6e4);return t.includes(e)?t:[e,...t]}function Zx(e){let{api:t,t:n}=e,[r,o]=(0,E.useState)(()=>Hi()),[i,a]=(0,E.useState)(void 0),[s,d]=(0,E.useState)([]),[l,c]=(0,E.useState)(!1),[f,h]=(0,E.useState)(void 0),[p,m]=(0,E.useState)(!1),b=(0,E.useRef)(!1),g=(0,E.useRef)(0),y=(0,E.useRef)(Promise.resolve()),v=(0,E.useRef)(0),x=(0,E.useRef)([]),H=(0,E.useCallback)(()=>{let N=++g.current;vn().then(V=>{!b.current||N!==g.current||(o(V.data),a(V.ok?void 0:V.error))})},[]);(0,E.useEffect)(()=>(b.current=!0,H(),()=>{b.current=!1,g.current+=1}),[H]);let[q,ne]=(0,E.useState)({});(0,E.useEffect)(()=>{let N=!0;return pe(t).then(V=>{let ie={};for(let[re,oe]of Object.entries(Ke(V.namespace))){let ae=typeof oe.displayName=="string"?oe.displayName.trim():"";ae.length>0&&(ie[re]=ae)}N&&ne(ie)}).catch(()=>{}),()=>{N=!1}},[t]);let K=(0,E.useCallback)((N,V)=>{g.current+=1,v.current===0&&(x.current=[],h(void 0)),v.current+=1,c(!0),V!==void 0&&d(re=>[...re,V]);let ie=async()=>{let re=await lm(N).catch(oe=>({ok:!1,error:oe instanceof Error?oe.message:String(oe)}));v.current-=1,re.ok||x.current.push(re.error),b.current&&(V!==void 0&&d(oe=>{let ae=oe.indexOf(V);return ae<0?oe:[...oe.slice(0,ae),...oe.slice(ae+1)]}),c(v.current>0),h(x.current.length===0?void 0:x.current.join(`
5309
+ `)),v.current===0&&H())};y.current=y.current.then(ie,ie)},[H]),S=(0,E.useCallback)(N=>{N.length!==0&&K({defaultModel:N},"default")},[K]),C=(0,E.useCallback)(N=>{K({enabled:N},"enabled")},[K]),M=(0,E.useCallback)(N=>{if(r===void 0)return;let V=Number(N);!Number.isFinite(V)||V<6e4||V>36e5||K({defaults:{timeoutMs:V}})},[r,K]);if(r===void 0)return(0,E.createElement)("div",{className:"bre-config-loading","aria-busy":i===void 0},(0,E.createElement)("div",{className:"bre-config-loading-text"},i===void 0?n("imagegenLoading"):`${n("imagegenLoadFailed")}: ${i}`),(0,E.createElement)("div",{className:"bre-config-skeleton"},...[0,1,2].map(N=>(0,E.createElement)("div",{key:N,className:"bre-config-skeleton-row"}))));let w=r.models,k=w.length===0,R="bre-config-imagegen-body",I=r.enabled?r.tool.error:void 0,D=new Map;for(let N of w)D.set(N.label,(D.get(N.label)??0)+1);let W=N=>{if((D.get(N.label)??0)<2)return N.label;let V=q[N.route]??N.providerLabel??N.route;return`${N.label} \xB7 ${V}`};return(0,E.createElement)("div",{className:"bre-config-card","aria-busy":l},(0,E.createElement)("div",{className:"bre-config-card-head"},(0,E.createElement)("button",{type:"button",className:"bre-config-expand","aria-expanded":p,"aria-controls":R,title:n(p?"imagegenCollapse":"imagegenExpand"),onClick:()=>m(N=>!N)},(0,E.createElement)("span",{className:"bre-config-card-title"},n("imagegenSectionTitle")),(0,E.createElement)("span",{className:"bre-config-card-hint"},r.enabled?n("imagegenEnabledHint"):n("imagegenDisabledHint"))),(0,E.createElement)("span",{className:"bre-config-card-state"},r.enabled?n("cardStateOn"):n("cardStateOff")),(0,E.createElement)("label",{className:"bre-config-switch",title:n("imagegenEnable")},(0,E.createElement)("input",{type:"checkbox",className:"bre-config-switch-input",role:"switch","aria-label":n("imagegenEnable"),checked:r.enabled,disabled:s.includes("enabled"),onChange:N=>C(N.target.checked)}),(0,E.createElement)("span",{className:"bre-config-switch-track","aria-hidden":!0})),(0,E.createElement)("span",{className:"bre-config-chevron","aria-hidden":!0,"data-open":String(p),onClick:()=>m(N=>!N)},"\u203A")),i!==void 0&&(0,E.createElement)("div",{className:"bre-config-notice",role:"alert"},`${n("imagegenLoadFailed")}: ${i}`),f!==void 0&&(0,E.createElement)("div",{className:"bre-config-notice"},f),p&&(0,E.createElement)("div",{className:"bre-config-card-body",id:R},I!==void 0&&(0,E.createElement)("div",{className:"bre-config-notice bre-config-notice-warn"},(0,E.createElement)("div",null,n("imagegenToolMissing")),(0,E.createElement)("div",{className:"bre-config-notice-why"},n("imagegenToolMissingWhy",{reason:I}))),(0,E.createElement)("div",{className:"bre-config-defaults"},(0,E.createElement)("label",null,n("imagegenDefaultsLabel")),(0,E.createElement)("select",{className:"bre-config-select",value:og(r.defaults.size),"aria-label":n("imagegenSizeLabel"),onChange:N=>{K({defaults:{size:N.target.value}})}},Zi.map(N=>(0,E.createElement)("option",{key:N.label,value:N.value},N.label))),(0,E.createElement)("select",{className:"bre-config-select",value:r.defaults.quality,"aria-label":n("imagegenQualityLabel"),onChange:N=>{K({defaults:{quality:N.target.value}})}},["low","medium","high","auto"].map(N=>(0,E.createElement)("option",{key:N,value:N},N))),(0,E.createElement)("select",{className:"bre-config-select",value:String(r.defaults.n),"aria-label":n("imagegenCountLabel"),onChange:N=>{K({defaults:{n:Number(N.target.value)}})}},[1,2,3,4].map(N=>(0,E.createElement)("option",{key:N,value:String(N)},`n=${N}`))),(0,E.createElement)("label",{className:"bre-config-timeout",title:n("imagegenTimeoutHint")},(0,E.createElement)("span",{className:"bre-config-timeout-label"},n("imagegenTimeoutLabel")),(0,E.createElement)("select",{className:"bre-config-select",value:String(r.defaults.timeoutMs),"aria-label":n("imagegenTimeoutLabel"),onChange:N=>{M(N.target.value)}},Qx(r.defaults.timeoutMs).map(N=>(0,E.createElement)("option",{key:N,value:String(N)},n("imagegenTimeoutMinutes",{minutes:Math.round(N/6e4)})))))),!k&&(0,E.createElement)("div",{className:"bre-config-default-row"},(0,E.createElement)("label",{className:"bre-config-default-label"},n("imagegenDefaultModelLabel")),(0,E.createElement)("select",{className:"bre-config-select bre-config-default-select",value:r.defaultModel??"","aria-label":n("imagegenDefaultModelLabel"),disabled:s.includes("default"),onChange:N=>S(N.target.value)},r.defaultModel===null&&(0,E.createElement)("option",{value:"",disabled:!0},n("imagegenDefaultModelNone")),w.map(N=>(0,E.createElement)("option",{key:N.id,value:N.id},W(N)))))))}var ig={EMPTY_RESPONSE:"continue",RATE_LIMIT:"continue",SERVER:"continue",TIMEOUT:"continue",TRANSPORT:"continue",INVALID_REQUEST:"useless",AUTH:"useless",UNKNOWN_MODEL:"useless",UNSUPPORTED_REASONING_EFFORT:"useless",PI_AI_ERROR:"depends",MALFORMED_RESPONSE:"depends",LEGACY_CLI_OUTCOME_UNKNOWN:"depends"},ek={continue:"autoContinueTagContinue",useless:"autoContinueTagUseless",depends:"autoContinueTagDepends"};function tk(e){let{t,policy:n}=e,[r,o]=(0,E.useState)(!1),i=(0,E.useRef)(null),a=(0,E.useRef)(null),[s,d]=(0,E.useState)(null);(0,E.useEffect)(()=>{if(!r)return;let g=v=>{let x=i.current;x!==null&&v.target instanceof Node&&!x.contains(v.target)&&o(!1)},y=()=>o(!1);return document.addEventListener("mousedown",g),window.addEventListener("resize",y),window.addEventListener("scroll",y,!0),()=>{document.removeEventListener("mousedown",g),window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0)}},[r]);let l=()=>{if(r){o(!1);return}let g=a.current;if(g===null){o(!0);return}let y=g.getBoundingClientRect(),v=Math.min(Math.max(y.width,400),window.innerWidth-24),x=Math.min(Math.max(8,y.right-v),window.innerWidth-v-8),H=window.innerHeight-y.bottom-12,q=470;d(H>=q?{left:x,width:v,top:y.bottom+6}:y.top>q?{left:x,width:v,bottom:window.innerHeight-y.top+6}:{left:x,width:v,top:Math.max(8,window.innerHeight-8-460)}),o(!0)},c=Pi.filter(g=>n.codes[g]===!0),f=[];n.maxTokens&&f.push((0,E.createElement)("span",{className:"bre-config-chip",key:"max-tokens"},t("autoContinueMaxTokens"))),n.httpStatus&&f.push((0,E.createElement)("span",{className:"bre-config-chip",key:"http"},t("autoContinueChipHttp")));for(let g of c)f.push((0,E.createElement)("span",{className:"bre-config-chip",key:g},g));let h=f.slice(0,3),p=f.length-h.length,m=(g,y,v,x,H,q)=>(0,E.createElement)("label",{className:"bre-config-code-row",key:g},(0,E.createElement)("input",{type:"checkbox",className:"bre-config-code-input",checked:y,onChange:ne=>q(ne.target.checked)}),(0,E.createElement)("span",{className:`bre-config-check${y?" bre-config-check-on":""}`,"aria-hidden":!0}),(0,E.createElement)("span",{className:"bre-config-code-name"},v),(0,E.createElement)("span",{className:"bre-config-code-why",title:x},x),(0,E.createElement)("span",{className:`bre-config-code-tag bre-config-code-tag-${H}`},t(ek[H]))),b=(g,y)=>(0,E.createElement)("div",{className:"bre-config-code-group",key:g},(0,E.createElement)("div",{className:"bre-config-code-group-title"},t(g)),y);return(0,E.createElement)("div",{className:"bre-config-trigger-control",ref:i},(0,E.createElement)("button",{type:"button",className:"bre-config-trigger-button",ref:a,"aria-expanded":r,"aria-label":t("autoContinueTriggers"),onClick:l},h,p>0&&(0,E.createElement)("span",{className:"bre-config-chip bre-config-chip-more"},t("autoContinueCodesMore",{count:p})),f.length===0&&(0,E.createElement)("span",{className:"bre-config-multiselect-empty"},"\u2014"),(0,E.createElement)("span",{className:"bre-config-multiselect-caret","aria-hidden":!0},"\u25BE")),r&&(0,E.createElement)("div",{className:"bre-config-multiselect-pop",role:"group","aria-label":t("autoContinueErrorTypes"),style:s===null?void 0:{left:`${s.left}px`,width:`${s.width}px`,...s.top===void 0?{}:{top:`${s.top}px`},...s.bottom===void 0?{}:{bottom:`${s.bottom}px`}}},b("autoContinueGroupFlags",[m("flag:max-tokens",n.maxTokens,t("autoContinueMaxTokens"),t("autoContinueWhyMaxTokens"),"continue",g=>e.onFlag("maxTokens",g)),m("flag:http",n.httpStatus,t("autoContinueHttpStatus"),t("autoContinueWhyHttpStatus"),"continue",g=>e.onFlag("httpStatus",g))]),b("autoContinueGroupTransient",no.map(g=>m(g,n.codes[g]===!0,(0,E.createElement)("code",{className:"bre-config-code-name-inner"},g),t(`autoContinueWhy${g}`),ig[g]??"depends",y=>e.onToggle(g,y)))),b("autoContinueGroupOther",Ii.map(g=>m(g,n.codes[g]===!0,(0,E.createElement)("code",{className:"bre-config-code-name-inner"},g),t(`autoContinueWhy${g}`),ig[g]??"depends",y=>e.onToggle(g,y)))),(0,E.createElement)("div",{className:"bre-config-multiselect-foot"},(0,E.createElement)("button",{type:"button",className:"bre-config-link",onClick:()=>e.onBulk(!0)},t("autoContinueCodesAll")),(0,E.createElement)("button",{type:"button",className:"bre-config-link",onClick:()=>e.onBulk(!1)},t("autoContinueCodesNone")),(0,E.createElement)("button",{type:"button",className:"bre-config-link bre-config-link-quiet",onClick:e.onRestore},t("autoContinueRestore")))))}function nk(e){let{t}=e,n=(0,E.useSyncExternalStore)($i,Yt),r=(0,E.useSyncExternalStore)(Vi,Ue),[o,i]=(0,E.useState)(String(r.waitSeconds)),[a,s]=(0,E.useState)(String(r.maxRetries));(0,E.useEffect)(()=>{i(String(r.waitSeconds))},[r.waitSeconds]),(0,E.useEffect)(()=>{s(String(r.maxRetries))},[r.maxRetries]);let d=()=>{xn({waitSeconds:o.trim()===""?r.waitSeconds:Number(o)}),i(String(Ue().waitSeconds))},l=()=>{xn({maxRetries:a.trim()===""?r.maxRetries:Number(a)}),s(String(Ue().maxRetries))},[c,f]=(0,E.useState)(!1),h="bre-config-auto-continue-body",p=r.policy,m=v=>{xn({policy:{...p,...v}})},b=(v,x)=>{xn({policy:{...p,codes:{...p.codes,[v]:x}}})},g=v=>{let x={...p.codes};for(let H of Pi)x[H]=v;xn({policy:{...p,codes:x}})},y=()=>{xn({policy:wn})};return(0,E.createElement)("div",{className:"bre-config-card bre-config-auto-card"},(0,E.createElement)("div",{className:"bre-config-card-head"},(0,E.createElement)("button",{type:"button",className:"bre-config-expand","aria-expanded":c,"aria-controls":h,title:t(c?"autoContinueCollapse":"autoContinueExpand"),onClick:()=>f(v=>!v)},(0,E.createElement)("span",{className:"bre-config-card-title"},t("autoContinueSectionTitle")),!c&&(0,E.createElement)("span",{className:"bre-config-card-hint bre-config-auto-summary"},t("autoContinueHint",{seconds:r.waitSeconds,count:r.maxRetries}))),(0,E.createElement)("span",{className:"bre-config-card-state"},t(n?"cardStateOn":"cardStateOff")),(0,E.createElement)("label",{className:"bre-config-switch",title:t("autoContinueAria")},(0,E.createElement)("input",{type:"checkbox",className:"bre-config-switch-input",role:"switch","aria-label":t("autoContinueAria"),checked:n,onChange:v=>{Om(v.target.checked)}}),(0,E.createElement)("span",{className:"bre-config-switch-track","aria-hidden":!0})),(0,E.createElement)("span",{className:"bre-config-chevron","aria-hidden":!0,"data-open":String(c),onClick:()=>f(v=>!v)},"\u203A")),c&&(0,E.createElement)("div",{className:"bre-config-card-body",id:h},(0,E.createElement)("div",{className:"bre-config-auto-fields"},(0,E.createElement)("label",{className:"bre-config-auto-field"},(0,E.createElement)("span",{className:"bre-config-auto-label"},t("autoContinueWaitLabel")),(0,E.createElement)("span",{className:"bre-config-auto-control"},(0,E.createElement)("input",{type:"number",className:"bre-config-auto-input",min:Bi,max:Wi,step:1,value:o,"aria-label":`${t("autoContinueWaitLabel")} (${t("autoContinueSecondsUnit")})`,title:`${Bi}\u2013${Wi} ${t("autoContinueSecondsUnit")}`,onChange:v=>i(v.target.value),onBlur:d,onKeyDown:v=>{v.key==="Enter"&&v.currentTarget.blur()}}),(0,E.createElement)("span",{className:"bre-config-auto-unit","aria-hidden":!0},t("autoContinueSecondsUnit")))),(0,E.createElement)("label",{className:"bre-config-auto-field"},(0,E.createElement)("span",{className:"bre-config-auto-label"},t("autoContinueRetriesLabel")),(0,E.createElement)("span",{className:"bre-config-auto-control"},(0,E.createElement)("input",{type:"number",className:"bre-config-auto-input",min:Gi,max:Ui,step:1,value:a,"aria-label":`${t("autoContinueRetriesLabel")} (${t("autoContinueRetriesUnit")})`,title:`${Gi}\u2013${Ui} ${t("autoContinueRetriesUnit")}`,onChange:v=>s(v.target.value),onBlur:l,onKeyDown:v=>{v.key==="Enter"&&v.currentTarget.blur()}}),(0,E.createElement)("span",{className:"bre-config-auto-unit","aria-hidden":!0},t("autoContinueRetriesUnit"))))),(0,E.createElement)("div",{className:"bre-config-trigger-field"},(0,E.createElement)("span",{className:"bre-config-auto-label"},t("autoContinueTriggers")),(0,E.createElement)(tk,{t,policy:p,onFlag:(v,x)=>m({[v]:x}),onToggle:b,onBulk:g,onRestore:y}))))}function rk(e){let{t}=e,n=(0,E.useSyncExternalStore)(Qi,Xi),[r,o]=(0,E.useState)(!1),i="bre-config-error-detail-body";return(0,E.createElement)("div",{className:"bre-config-card"},(0,E.createElement)("div",{className:"bre-config-card-head"},(0,E.createElement)("button",{type:"button",className:"bre-config-expand","aria-expanded":r,"aria-controls":i,title:t(r?"autoContinueCollapse":"autoContinueExpand"),onClick:()=>o(a=>!a)},(0,E.createElement)("span",{className:"bre-config-card-title"},t("errorDetailSectionTitle")),!r&&(0,E.createElement)("span",{className:"bre-config-card-hint"},t("errorDetailSummary"))),(0,E.createElement)("span",{className:"bre-config-card-state"},t(n?"cardStateOn":"cardStateOff")),(0,E.createElement)("label",{className:"bre-config-switch",title:t("errorDetailAria")},(0,E.createElement)("input",{type:"checkbox",className:"bre-config-switch-input",role:"switch","aria-label":t("errorDetailAria"),checked:n,onChange:a=>{Wm(a.target.checked)}}),(0,E.createElement)("span",{className:"bre-config-switch-track","aria-hidden":!0})),(0,E.createElement)("span",{className:"bre-config-chevron","aria-hidden":!0,"data-open":String(r),onClick:()=>o(a=>!a)},"\u203A")),r&&(0,E.createElement)("div",{className:"bre-config-card-body",id:i},(0,E.createElement)("p",{className:"bre-config-card-hint bre-config-error-detail-copy"},t("errorDetailHint"))))}function ok(e){let{t,onClose:n}=e,r=(0,E.useRef)(null);return(0,E.useEffect)(()=>{let o=i=>{i.key==="Escape"&&n()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n]),(0,E.createElement)("div",{className:"bre-config-backdrop",onMouseDown:o=>{o.target===o.currentTarget&&n()}},(0,E.createElement)("div",{className:"bre-config-pane",ref:r},(0,E.createElement)("div",{className:"bre-config-head"},(0,E.createElement)("span",{className:"bre-config-title"},t("configPaneTitle")),(0,E.createElement)("button",{className:"bre-config-close",type:"button","aria-label":t("configPaneClose"),onClick:n},"\u2715")),(0,E.createElement)("div",{className:"bre-config-body"},(0,E.createElement)(Be,{fallbackText:t("configPaneFailed")},(0,E.createElement)(Zx,{api:e.api,t:e.t})),(0,E.createElement)(Be,{fallbackText:t("configPaneFailed")},(0,E.createElement)(nk,{t:e.t})),(0,E.createElement)(Be,{fallbackText:t("configPaneFailed")},(0,E.createElement)(rk,{t:e.t})))))}function Md(e){let t=document.createElement("div");t.className="bre-config-pane-host",document.body.appendChild(t);let n=(0,ag.createRoot)(t),r=!0,o=()=>{r&&(r=!1,Ne({wrapper:t,root:n}))};return n.render((0,E.createElement)(ok,{api:e.api,t:e.t,onClose:o})),{close:o}}function sg(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return r.length===0||n.includes(r)}function dg(e,t){let n=e.replace(/^\s+/,"");if(n.length===0)return t.map(a=>({label:a.isDefault?`${a.label}\uFF08\u9ED8\u8BA4\uFF09`:a.label,insertText:a.id,kind:"model",hint:a.id}));let r=n.match(/^(\S+)(\s+[\s\S]*)?$/);if(r===null)return[];let o=r[1];return t.filter(a=>sg(a.id,o)||sg(a.label,o)).map(a=>({label:a.isDefault?`${a.label}\uFF08\u9ED8\u8BA4\uFF09`:a.label,insertText:a.id,kind:"model",hint:a.id}))}var gr,Ld=0;function Ad(){gr=void 0,Ld+=1}function ik(){if(gr!==void 0)return gr;let e=Ld,t=vn().then(n=>e===Ld&&n.ok&&n.data.enabled?n.data.models.map(r=>({id:r.id,label:r.label,isDefault:n.data.defaultModel===r.id})):[]).catch(()=>[]).finally(()=>{gr===t&&(gr=void 0)});return gr=t,t}function lg(e){let t;try{t=e.inputTriggers}catch{t=void 0}let n=sm(Ad);if(t===void 0||typeof t.registerSource!="function")return n;let r=!0;try{t.registerSource({trigger:"/",name:"imagegen",order:900,candidates:(o,i={})=>{if(!r||i.signal?.aborted)return[];let a=typeof o?.text=="string"?o.text:"";return/^\/?生图(?:\s|$)/.test(a)?ik().then(s=>r&&!i.signal?.aborted?dg(a.replace(/^\/?生图/,""),s):[]):[]}})}catch{r=!1}return()=>{r=!1,n()}}var kn=require("react");var cg="tool.call.images",ak="generate_image";function sk(e){if(e===void 0||typeof e!="object")return[];let t=e.content??e.resultView?.content;if(!Array.isArray(t))return[];let n=[];for(let r of t)if(r!==null&&typeof r=="object"&&r.type==="image"){let o=r.attachment;o!==void 0&&typeof o.attachmentId=="string"&&n.push({attachment:o})}return n}function dk(e){let t=Array.isArray(e.content)?e.content:[];for(let n of t)if(n!==null&&typeof n=="object"&&n.type==="text"&&typeof n.text=="string")return n.text;return null}function lk(e){let t=e.meta;if(t===void 0||typeof t!="object")return null;let n=[],r=t.paramsUsed;typeof t.model=="string"&&t.model.length>0&&n.push(r===void 0?t.model:`${t.model} \xB7 ${r.size} \xB7 ${r.quality} \xB7 n ${r.n}`);let o=(t.images??[]).map(i=>i.filePath).filter(i=>typeof i=="string");return o.length>0&&n.push(o.join(`
5309
5310
  `)),Array.isArray(t.revisions)&&t.revisions.length>0&&n.push(t.revisions.join("\u3001")),n.length>0?n.join(`
5310
- `):null}function sk(e){let t=e.block;if(!(t!==void 0&&typeof t=="object"&&"kind"in t))return(0,En.createElement)("div",{className:"bre-image-card","aria-busy":!0},(0,En.createElement)("span",{className:"bre-image-card-running"},e.t("imagegenCardRunning")));let r=ok(t);if(r.length===0){let i=ik(t);return(0,En.createElement)("div",{className:"bre-image-card"},i===null?null:(0,En.createElement)("div",{className:"bre-image-card-caption"},i))}let o=ak(t);return(0,En.createElement)("div",{className:"bre-image-card"},typeof e.renderSlot=="function"&&typeof e.loadImage=="function"?e.renderSlot(lg,{images:r,loadImage:e.loadImage,align:"start"}):null,o===null?null:(0,En.createElement)("div",{className:"bre-image-card-caption"},o))}function dk(e,t,n){if(e===void 0)return()=>{};let r;try{let o=e.register.bind(e),i=e.inject("tool.call.toolview",()=>o({name:"tool.call.toolview",key:t,children:{[lg]:{kind:"single",scope:"session"}}},a=>sk({...a,t:n})));typeof i=="function"&&(r=i)}catch{return()=>{}}return()=>{r?.()}}function cg(e,t){let n=e.slots;e.effect(()=>{let r,o,i=!0,a=s=>{i&&(typeof s!="string"||s.length===0||s!==o&&(r?.(),o=s,r=dk(n,s,t)))};return a(rk),a(Hi()?.tool.name),Yt().then(s=>{s.ok&&a(s.data.tool.name)}).catch(()=>{}),()=>{i=!1,r?.()}},"dsh-model-think-level: image tool card")}var fg=200,lk=we,ck=["slots","locale","connection","remote","remote.settings"];function uk(e){e.effect(()=>e.locale.register(ia,{zh:Pd,en:Dd}),"dsh-model-think-level: dictionaries");let t=document.createElement("style");t.dataset.plugin=we,t.dataset.pluginStyles=we,t.textContent=sl,document.head.appendChild(t),e.effect(()=>()=>t.remove(),"dsh-model-think-level: stylesheet"),e.effect(()=>wm(Ge),"dsh-model-think-level: key list revalidation");let n=(()=>{try{let m=e.get?.("configForms");try{let x=m?.get?.(De);if(x!==void 0)return x}catch{}return e.get?.("settingsScope")?.bind?.({namespace:De})}catch{return}})(),r=n===void 0?{settings:e.remote.settings}:{settings:e.remote.settings,scope:n},o=e.locale.bind(ia),i=()=>{let m=e.locale;return typeof m.subscribe=="function"&&typeof m.getSnapshot=="function"?m:void 0},a=m=>{let v=i();return v===void 0?m():(0,ug.createElement)(Id,{locale:v,children:m})},s=Gl({api:r}),d=yl(r),l=Lm({ctx:e,configuredEffort:s.of}),c=Wl({menuOf:Kl,triggerOf:ql,t:o,refreshed:a,sliderEnabled:mt,directory:l.ensure,configuredInputs:d}),f=Ul({api:r}),h=jl({api:r}),p,g=vm({ctx:e,api:r,t:o,onIdle:m=>{h.run(m),f.run(m)},refreshed:a,configSeat:{t:o,onOpen:()=>{p?.close(),p=Md({api:r,t:o})}}}),b=()=>{l.ensure(),c.reconcile()};e.effect(()=>(g.start(b),()=>{g.teardown(),c.dispose(),l.dispose(),p?.close(),p=void 0}),"dsh-model-think-level: DOM injector"),e.effect(()=>{let m=()=>{g.flushOnUnload(),Ta(),Mm()};return window.addEventListener("pagehide",m),()=>{window.removeEventListener("pagehide",m)}},"dsh-model-think-level: ledger flush on unload"),e.effect(()=>al(),"dsh-model-think-level: order file sync"),e.effect(()=>{let m=!1,x=Cd(()=>{m&&(m=!1,document.dispatchEvent(new CustomEvent(Er,{detail:{ns:De}}))),g.state.describePromise=void 0,s.invalidate(),d.invalidate(),f.invalidate(),Ld(),g.schedule()},fg),E=[e.remote.$on("settings/document-updated",N=>{N===De&&(m=!0,x.schedule())}),e.on("connection/reset",x.schedule)];return()=>{x.dispose();for(let N of E)N()}},"dsh-model-think-level: pushed invalidations"),e.effect(()=>{let m=F=>{F.key===go?Kd(F.newValue!=="false"):F.key===bo?Gd(Cn(F.newValue)):F.key===vo?$d(jd(F.newValue)):F.key===wo?Qd(ma(F.newValue)):F.key===Fi?xd(F.newValue==="true"):F.key===Ki?kd(Ui(F.newValue)):F.key===Yi?Sd(F.newValue!=="false"):F.key===null&&(xd(!1),kd(Ui(null)),Sd(!0))};window.addEventListener("storage",m);let v=ho(()=>{g.schedule()}),x=Hn(()=>{g.schedule()}),E=In(()=>{g.schedule()}),N=Dn(()=>{g.schedule()});return()=>{window.removeEventListener("storage",m),v(),x(),E(),N()}},"dsh-model-think-level: client preferences"),e.effect(()=>ng(e,o),"dsh-model-think-level: footer slot activation"),e.effect(()=>eg(e,r,o),"dsh-model-think-level: provider-card slot activation"),e.effect(()=>dg(e),"dsh-model-think-level: imagegen completion source"),cg(e,o),e.effect(()=>{let m=Pm({ctx:e,t:o}),v=Wm({runner:m,t:o,onSettings:()=>{Md({api:r,t:o})}});return()=>{v(),m.dispose()}},"dsh-model-think-level: auto-continue watcher"),e.effect(()=>{let m,v=()=>{if(!Ji()){m?.dispose(),m=void 0;return}m??(m=Km({ctx:e,t:o}))},x=Xi(v);return v(),()=>{x(),m?.dispose(),m=void 0}},"dsh-model-think-level: failure detail seat")}
5311
+ `):null}function ck(e){let t=e.block;if(!(t!==void 0&&typeof t=="object"&&"kind"in t))return(0,kn.createElement)("div",{className:"bre-image-card","aria-busy":!0},(0,kn.createElement)("span",{className:"bre-image-card-running"},e.t("imagegenCardRunning")));let r=sk(t);if(r.length===0){let i=dk(t);return(0,kn.createElement)("div",{className:"bre-image-card"},i===null?null:(0,kn.createElement)("div",{className:"bre-image-card-caption"},i))}let o=lk(t);return(0,kn.createElement)("div",{className:"bre-image-card"},typeof e.renderSlot=="function"&&typeof e.loadImage=="function"?e.renderSlot(cg,{images:r,loadImage:e.loadImage,align:"start"}):null,o===null?null:(0,kn.createElement)("div",{className:"bre-image-card-caption"},o))}function uk(e,t,n){if(e===void 0)return()=>{};let r;try{let o=e.register.bind(e),i=e.inject("tool.call.toolview",()=>o({name:"tool.call.toolview",key:t,children:{[cg]:{kind:"single",scope:"session"}}},a=>ck({...a,t:n})));typeof i=="function"&&(r=i)}catch{return()=>{}}return()=>{r?.()}}function ug(e,t){let n=e.slots;e.effect(()=>{let r,o,i=!0,a=s=>{i&&(typeof s!="string"||s.length===0||s!==o&&(r?.(),o=s,r=uk(n,s,t)))};return a(ak),a(Hi()?.tool.name),vn().then(s=>{s.ok&&a(s.data.tool.name)}).catch(()=>{}),()=>{i=!1,r?.()}},"dsh-model-think-level: image tool card")}var pg=200,fk=ke,pk=["slots","locale","connection","remote","remote.settings"];function mk(e){e.effect(()=>e.locale.register(aa,{zh:_d,en:Dd}),"dsh-model-think-level: dictionaries");let t=document.createElement("style");t.dataset.plugin=ke,t.dataset.pluginStyles=ke,t.textContent=dl,document.head.appendChild(t),e.effect(()=>()=>t.remove(),"dsh-model-think-level: stylesheet"),e.effect(()=>xm(Ge),"dsh-model-think-level: key list revalidation");let n=(()=>{try{let g=e.get?.("configForms");try{let v=g?.get?.(De);if(v!==void 0)return v}catch{}return e.get?.("settingsScope")?.bind?.({namespace:De})}catch{return}})(),r=n===void 0?{settings:e.remote.settings}:{settings:e.remote.settings,scope:n},o=e.locale.bind(aa),i=()=>{let g=e.locale;return typeof g.subscribe=="function"&&typeof g.getSnapshot=="function"?g:void 0},a=g=>{let y=i();return y===void 0?g():(0,fg.createElement)(Pd,{locale:y,children:g})},s=Ul({api:r}),d=vl(r),l=Am({ctx:e,configuredEffort:s.of}),c=Gl({menuOf:Kl,triggerOf:Bl,t:o,refreshed:a,sliderEnabled:mt,directory:l.ensure,configuredInputs:d}),f=jl({api:r}),h=zl({api:r}),p,m=wm({ctx:e,api:r,t:o,onIdle:g=>{h.run(g),f.run(g)},refreshed:a,configSeat:{t:o,onOpen:()=>{p?.close(),p=Md({api:r,t:o})}}}),b=()=>{l.ensure(),c.reconcile()};e.effect(()=>(m.start(b),()=>{m.teardown(),c.dispose(),l.dispose(),p?.close(),p=void 0}),"dsh-model-think-level: DOM injector"),e.effect(()=>{let g=()=>{m.flushOnUnload(),Sa(),Lm()};return window.addEventListener("pagehide",g),()=>{window.removeEventListener("pagehide",g)}},"dsh-model-think-level: ledger flush on unload"),e.effect(()=>sl(),"dsh-model-think-level: order file sync"),e.effect(()=>{let g=!1,v=Cd(()=>{g&&(g=!1,document.dispatchEvent(new CustomEvent(Tr,{detail:{ns:De}}))),m.state.describePromise=void 0,s.invalidate(),d.invalidate(),f.invalidate(),Ad(),m.schedule()},pg),x=[e.remote.$on("settings/document-updated",H=>{H===De&&(g=!0,v.schedule())}),e.on("connection/reset",v.schedule)];return()=>{v.dispose();for(let H of x)H()}},"dsh-model-think-level: pushed invalidations"),e.effect(()=>{let g=q=>{q.key===go?Kd(q.newValue!=="false"):q.key===bo?Ud(An(q.newValue)):q.key===vo?Vd(zd(q.newValue)):q.key===wo?Zd(ga(q.newValue)):q.key===qi?xd(q.newValue==="true"):q.key===Ki?kd(ji(q.newValue)):q.key===Ji?Sd(q.newValue!=="false"):q.key===null&&(xd(!1),kd(ji(null)),Sd(!0))};window.addEventListener("storage",g);let y=ho(()=>{m.schedule()}),v=Cn(()=>{m.schedule()}),x=On(()=>{m.schedule()}),H=In(()=>{m.schedule()});return()=>{window.removeEventListener("storage",g),y(),v(),x(),H()}},"dsh-model-think-level: client preferences"),e.effect(()=>rg(e,o),"dsh-model-think-level: footer slot activation"),e.effect(()=>tg(e,r,o),"dsh-model-think-level: provider-card slot activation"),e.effect(()=>lg(e),"dsh-model-think-level: imagegen completion source"),ug(e,o),e.effect(()=>{let g=_m({ctx:e,t:o}),y=Gm({runner:g,t:o,onSettings:()=>{Md({api:r,t:o})}});return()=>{y(),g.dispose()}},"dsh-model-think-level: auto-continue watcher"),e.effect(()=>{let g,y=()=>{if(!Xi()){g?.dispose(),g=void 0;return}g??(g=Km({ctx:e,t:o}))},v=Qi(y);return y(),()=>{v(),g?.dispose(),g=void 0}},"dsh-model-think-level: failure detail seat")}
5311
5312
 
5312
5313
  return module.exports;
5313
5314
  }