dsh-model-think-level 2.6.3 → 2.6.5

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 yg=Object.getOwnPropertyDescriptor;var vg=Object.getOwnPropertyNames;var wg=Object.prototype.hasOwnProperty;var xg=(e,t,n)=>t in e?fo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var kg=(e,t)=>{for(var n in t)fo(e,n,{get:t[n],enumerable:!0})},Eg=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of vg(t))!wg.call(e,o)&&o!==n&&fo(e,o,{get:()=>t[o],enumerable:!(r=yg(t,o))||r.enumerable});return e};var Tg=e=>Eg(fo({},"__esModule",{value:!0}),e);var Ke=(e,t,n)=>xg(e,typeof t!="symbol"?t+"":t,n);var vk={};kg(vk,{EffortEditor:()=>_o,REFRESH_MIN_INTERVAL_MS:()=>hg,apply:()=>yk,baselineModelsOf:()=>vl,compatOf:()=>Lo,createEditorApi:()=>Ho,defaultEffortOf:()=>Ro,describeNamespace:()=>ge,effortsOf:()=>Mo,findModelMenu:()=>Ya,findModelTrigger:()=>Ja,imageGenOf:()=>Da,inject:()=>bk,inputOf:()=>Ao,invalidateProbeCache:()=>_a,name:()=>hk,nameOf:()=>Co,providerHeadersOf:()=>Fa,providersOf:()=>Be,routeIsDeclared:()=>dt,userProvidersOf:()=>rn,writeModelRows:()=>Mr,writeProviderHeaders:()=>Ar});module.exports=Tg(vk);var gg=require("react");function Hd(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 Ee="dsh-model-think-level",Nd="/dsh-model-think-level/raw-models";var po="/dsh-model-think-level/provider-key",mo="/dsh-model-think-level/key-index",Od="/dsh-model-think-level/balance",Id="/dsh-model-think-level/autofill-config",Pd="/dsh-model-think-level/headers-config",na="/dsh-model-think-level/fingerprint",ra="/dsh-model-think-level/ui-order";var _e="llm-pi-ai",at="reasoningEffortsUnset",xt="inputUnset",st="inputImageGen",Sn="reasoningEffortsAutofilled",Mn="defaultEffort",oa="/dsh-model-think-level/camouflage";var ia="/dsh-model-think-level/history-compat";var aa="/dsh-model-think-level/image-config";var sa=Ee;var hr=require("react");function Dd(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 _d={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:"Auto-continue",autoContinueControllerSeconds:"{seconds}s",autoContinueControllerRatio:"{n}/{max}",autoContinueControllerSent:"Continued",autoContinueControllerExhausted:"Stood down",autoContinueControllerStop:"Stop auto-continue",autoContinueControllerResume:"Continue now",autoContinueControllerReset:"Reset",autoContinueControllerSettings:"Settings\u2026",autoContinueControllerAria:"Auto-continue status",autoContinueControllerDetail:"Last interruption: {detail}",autoContinueControllerPopTitle:"Auto-continue",autoContinueControllerPopBadge:"Try {n}/{max}",autoContinueControllerPopDesc:"This turn was cut off upstream. \u201CContinue\u201D is sent automatically in {seconds}s, at most {max} times; a message from you takes over instead.",autoContinueControllerPopScope:"This session only",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"},Fd={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:"\u81EA\u52A8\u7EE7\u7EED",autoContinueControllerSeconds:"{seconds}s",autoContinueControllerRatio:"{n}/{max}",autoContinueControllerSent:"\u5DF2\u7EE7\u7EED",autoContinueControllerExhausted:"\u5DF2\u505C\u624B",autoContinueControllerStop:"\u505C\u6B62\u81EA\u52A8\u7EE7\u7EED",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}",autoContinueControllerPopTitle:"\u81EA\u52A8\u7EE7\u7EED",autoContinueControllerPopBadge:"\u7B2C {n}/{max} \u6B21",autoContinueControllerPopDesc:"\u672C\u8F6E\u88AB\u4E0A\u6E38\u8D85\u65F6\u4E2D\u65AD\u3002{seconds} \u79D2\u540E\u81EA\u52A8\u53D1\u9001\u300C\u7EE7\u7EED\u300D\uFF0C\u6700\u591A {max} \u6B21\uFF1B\u4F60\u5728\u8FD9\u91CC\u56DE\u4E00\u53E5\u5C31\u63A5\u7BA1\uFF0C\u4E0D\u518D\u81EA\u52A8\u53D1\u3002",autoContinueControllerPopScope:"\u53EA\u5BF9\u5F53\u524D\u4F1A\u8BDD\u751F\u6548",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",Sg=["dsh-reasoning-effort.enabled","@dsh-external/dsh-reasoning-effort.enabled"],br=Mg();function Mg(){try{let e=window.localStorage.getItem(go),t=e===null?Sg.map(n=>window.localStorage.getItem(n)).find(n=>n!==null):null;return(e??t??null)!=="false"}catch{return!0}}var da=new Set;function qd(){for(let e of[...da])e()}function gt(){return br}function Kd(e){if(br!==e){br=e;try{window.localStorage.setItem(go,String(e))}catch{}qd()}}function Bd(e){br!==e&&(br=e,qd())}function ho(e){return da.add(e),()=>{da.delete(e)}}var bo="dsh-model-think-level.provider-order",Wd=["deepseek-account","deepseek-official"];function Ln(e){if(e===null)return[];try{let t=JSON.parse(e);return Array.isArray(t)?ca(t.filter(n=>typeof n=="string")):[]}catch{return[]}}function ca(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 Ln(window.localStorage.getItem(bo))}catch{return[]}})(),la=new Set;function Gd(){for(let e of[...la])e()}function Ud(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function Cn(){return An}function yo(e){let t=ca(e);if(!Ud(An,t)){An=t;try{window.localStorage.setItem(bo,JSON.stringify(An))}catch{}Gd()}}function jd(e){let t=ca(e);Ud(An,t)||(An=t,Gd())}function Rn(e){return la.add(e),()=>{la.delete(e)}}function ua(e){let t=n=>{let r=Wd.indexOf(n);return r<0?Wd.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 zd(e){return Hn(ua(e),Cn())}function fa(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",pa=new Set,_t=Ag();function Ag(){try{return Ln(window.localStorage.getItem(vo))}catch{return[]}}function $d(e){return Ln(e)}function yr(){return _t}function Nn(e){return!_t.includes(e)}function Vd(e,t){let n=!_t.includes(e);t!==n&&ma(t?_t.filter(r=>r!==e):[..._t,e],!0)}function Yd(e){ma(e,!1)}function Jd(e){ma(e,!0)}function On(e){return pa.add(e),()=>{pa.delete(e)}}function Lg(e,t){return e.length!==t.length?!1:e.every(n=>t.includes(n))}function ma(e,t){if(!Lg(_t,e)){if(_t=[...new Set(e)],t)try{window.localStorage.setItem(vo,JSON.stringify(_t))}catch{}for(let n of[...pa])n()}}var wo="dsh-model-think-level.model-order";function ha(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=ba(o.filter(a=>typeof a=="string"));i.length>0&&(n[r]=i)}return n}catch{return{}}}function ba(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 ha(window.localStorage.getItem(wo))}catch{return{}}})(),ga=new Set;function ya(){for(let e of[...ga])e()}function Cg(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function Xd(){try{window.localStorage.setItem(wo,JSON.stringify(Ft))}catch{}}function vr(){return Ft}function Qd(e){return Ft[e]??Rg}var Rg=[];function Zd(e,t){if(e.length===0)return;let n=ba(t),r=Qd(e);if(Cg(r,n)&&(n.length>0||!(e in Ft)))return;let o={...Ft};n.length===0?delete o[e]:o[e]=n,Ft=o,Xd(),ya()}function el(e){Ft=e,ya()}function tl(e){let t={};for(let[n,r]of Object.entries(e)){if(n.length===0)continue;let o=ba(r);o.length>0&&(t[n]=o)}Ft=t,Xd(),ya()}function In(e){return ga.add(e),()=>{ga.delete(e)}}function Hg(e,t){return Hn(e,t)}function nl(e,t){return Hn(t,Qd(e))}function va(e,t){if(e.length===0||t.length===0)return e;let n=new Map(e.map(r=>[r.id,r]));return Hg(e.map(r=>r.id),t).map(r=>n.get(r))}var rl="dsh-model-think-level.order-saved-at",Ng=400,Og=6e4;function ka(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 Ig(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=ka(r);o.length>0&&(t[n]=o)}return t}function ol(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:ka(t.providerOrder),modelOrder:Ig(t.modelOrder),providersDisabled:Array.isArray(t.providersDisabled)?ka(t.providersDisabled):void 0}}function il(e){return e.providerOrder.length>0||Object.keys(e.modelOrder).length>0||e.providersDisabled!==void 0}function wr(){try{let e=window.localStorage.getItem(rl),t=e===null?0:Number(e);return Number.isFinite(t)&&t>0?t:0}catch{return 0}}function Ta(e){try{window.localStorage.setItem(rl,String(e))}catch{}}function xr(){return JSON.stringify({providerOrder:Cn(),modelOrder:vr(),providersDisabled:yr()})}var Kt,ht,Pn=new Set,xo,wa,Fe=!1,Ea=!1,qt,Ye=0;function Pg(){let e=Math.max(Date.now(),wr()+1);return Ta(e),e}function al(){if(ht=void 0,Fe)return;let e=wr(),t=JSON.stringify({savedAt:e>0?e:Date.now(),providerOrder:Cn(),modelOrder:vr(),providersDisabled:yr()});Kt=xr();let n=Ye,r=fetch(ra,{method:"POST",headers:{"content-type":"application/json"},body:t}).then(async o=>{if(Fe||n!==Ye)return!0;let i=await o.json().catch(()=>{});if(Fe||n!==Ye)return!0;let a=ol(i?.data);return o.status===409?wr()!==e?!0:a!==void 0&&il(a)?(sl(a),!0):(Kt=void 0,!1):o.ok?(a!==void 0&&a.savedAt>wr()&&Ta(a.savedAt),!0):(Kt=void 0,!1)}).catch(()=>(!Fe&&n===Ye&&(Kt=void 0),!1));Pn.add(r),r.then(()=>{Pn.delete(r)})}function Sa(e){Fe||ht!==void 0||xr()!==Kt&&(ht=setTimeout(al,e))}function Ma(){ht!==void 0&&(clearTimeout(ht),al())}async function Dg(){if(Fe)return;let e=Ye;if(await Eo(),!(Fe||e!==Ye))for(xr()!==Kt&&ht===void 0&&Pn.size===0&&Sa(0);!Fe&&e===Ye&&(ht!==void 0||Pn.size>0);){Ma();let t=await Promise.all([...Pn]);if(Fe||e!==Ye)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 xa(){Fe||Ea||(Pg(),Sa(Ng))}function sl(e){Ea=!0;try{yo(e.providerOrder),tl(e.modelOrder),e.providersDisabled!==void 0&&Jd(e.providersDisabled)}finally{Ea=!1}Ta(e.savedAt),Kt=xr()}function Eo(){if(Fe)return Promise.resolve();if(qt!==void 0)return qt;let e=_g().finally(()=>{qt===e&&(qt=void 0)});return qt=e,e}async function _g(){let e=Ye,t;try{let o=await fetch(ra,{method:"GET"});if(o.ok){let i=await o.json();i.ok===!0&&(t=ol(i.data))}}catch{return}if(Fe||e!==Ye||ht!==void 0)return;let n=wr(),r=JSON.stringify({providerOrder:t?.providerOrder??[],modelOrder:t?.modelOrder??{},providersDisabled:t?.providersDisabled??[]});if(t!==void 0&&il(t)&&t.savedAt>=n){sl(t);return}xr()!==r&&Sa(0)}function ko(){Fe||typeof document<"u"&&document.visibilityState==="hidden"||Eo()}function dl(){Fe=!1,Ye+=1,qt=void 0,Pn.clear(),Kt=void 0;let e=Rn(xa),t=In(xa),n=On(xa);xo=setInterval(ko,Og);let r=a=>{let s=a.detail;typeof s?.waitUntil=="function"&&s.waitUntil(Dg())},o=()=>{let a=Ye;(async()=>(qt!==void 0&&await qt,!Fe&&a===Ye&&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),wa=()=>{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(),()=>{Fe=!0,Ye+=1,ht!==void 0&&clearTimeout(ht),ht=void 0,xo!==void 0&&clearInterval(xo),xo=void 0,wa?.(),wa=void 0,e(),t(),n()}}var ll=`
7
+ "use strict";var wo=Object.defineProperty;var Gg=Object.getOwnPropertyDescriptor;var jg=Object.getOwnPropertyNames;var zg=Object.prototype.hasOwnProperty;var $g=(e,t,n)=>t in e?wo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Vg=(e,t)=>{for(var n in t)wo(e,n,{get:t[n],enumerable:!0})},Yg=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of jg(t))!zg.call(e,o)&&o!==n&&wo(e,o,{get:()=>t[o],enumerable:!(r=Gg(t,o))||r.enumerable});return e};var Xg=e=>Yg(wo({},"__esModule",{value:!0}),e);var je=(e,t,n)=>$g(e,typeof t!="symbol"?t+"":t,n);var Xk={};Vg(Xk,{EffortEditor:()=>jo,REFRESH_MIN_INTERVAL_MS:()=>Ug,apply:()=>Yk,baselineModelsOf:()=>Hl,compatOf:()=>Po,createEditorApi:()=>qo,defaultEffortOf:()=>Fo,describeNamespace:()=>we,effortsOf:()=>Io,findModelMenu:()=>ns,findModelTrigger:()=>rs,imageGenOf:()=>Wa,inject:()=>Vk,inputOf:()=>Do,invalidateProbeCache:()=>Ga,name:()=>$k,nameOf:()=>_o,providerHeadersOf:()=>ja,providersOf:()=>ze,routeIsDeclared:()=>gt,userProvidersOf:()=>fn,writeModelRows:()=>Nr,writeProviderHeaders:()=>Or});module.exports=Xg(Xk);var Kg=require("react");function Wd(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 Me="dsh-model-think-level",Gd="/dsh-model-think-level/raw-models";var xo="/dsh-model-think-level/provider-key",ko="/dsh-model-think-level/key-index",jd="/dsh-model-think-level/balance",zd="/dsh-model-think-level/autofill-config",$d="/dsh-model-think-level/headers-config",la="/dsh-model-think-level/fingerprint",ca="/dsh-model-think-level/ui-order";var Ue="llm-pi-ai",pt="reasoningEffortsUnset",Lt="inputUnset",mt="inputImageGen",Rn="reasoningEffortsAutofilled",Hn="defaultEffort",ua="/dsh-model-think-level/camouflage";var fa="/dsh-model-think-level/history-compat";var pa="/dsh-model-think-level/image-config";var ma=Me;var kr=require("react");function Vd(e){let{locale:t}=e,n=(0,kr.useCallback)(o=>t.subscribe(o),[t]),r=(0,kr.useCallback)(()=>t.getSnapshot().revision??0,[t]);return(0,kr.useSyncExternalStore)(n,r),e.children()}var Yd={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:"Base wait {seconds}s \xB7 Up to {count} auto-continues",autoContinueWaitLabel:"Wait after failure",autoContinueRetriesLabel:"Auto-continue 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 built-in codes",autoContinueCodesNone:"Clear built-in codes",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",autoContinueWhyMODEL_SWITCH_COMPACTION_FAILED:"Model-switch context compaction failed; retry only if the provider may recover",autoContinueWhyCLI_TIMEOUT:"CLI timeout observed at turn/end; independent CLI tasks are not affected",autoContinueWhyQUOTA:"Insufficient balance or quota; continuing cannot add funds",autoContinueBackoffLabel:"Exponential backoff",autoContinueBackoffHint:"Increase the delay between error-driven continuations; output-limit continuations keep the configured wait.",autoContinueChainMinutesLabel:"Failure-chain time limit",autoContinueChainMinutesUnit:"min",autoContinueRequestsLabel:"Request budget",autoContinueRequestsUnit:"requests",autoContinueRequestsHint:"Observed lower bound of failed-chain requests, including official retries, not a cost or official-request hard cap. The clock starts at the first failure or official retry. Budgets stop only future plugin continuations, not official retries within the turn.",autoContinueCustomCodes:"Custom error codes",autoContinueCustomCodePlaceholder:"ADD_CODE",autoContinueCustomCodeAdd:"Add code",autoContinueCustomCodeRemove:"Remove {code}",autoContinueCustomCodeInvalid:"Use a non-empty code up to 64 letters, numbers, ., _, :, or -.",autoContinueCustomCodeLimit:"At most {count} custom codes",autoContinueControllerProviderRetry:"Provider retry",autoContinueControllerProviderRetryDesc:"The provider is retrying within the current turn; the plugin will not send \u201CContinue\u201D. Stopping auto-continue does not cancel the official request; use the session stop button.",autoContinueControllerRequestCount:"{count} requests observed (including official retries)",autoContinueControllerExhaustedRequests:"Request budget used up",autoContinueControllerExhaustedDuration:"Time limit reached",autoContinueControllerOfficialRetryHint:"Auto-continue is evaluated only after provider retries are exhausted; the two request costs add up.",autoContinueControllerProviderAttempt:"Attempt {n}",autoContinueControllerWaiting:"Auto-continue",autoContinueControllerSeconds:"{seconds}s",autoContinueControllerRatio:"{n}/{max}",autoContinueControllerSent:"Continued",autoContinueControllerSentDesc:"Continue has been sent. The current turn is running; auto-continue does not send another message during official retries.",autoContinueControllerExhausted:"Stood down",autoContinueControllerStop:"Stop auto-continue",autoContinueControllerResume:"Skip local wait",autoContinueControllerReset:"Reset",autoContinueControllerSettings:"Settings\u2026",autoContinueControllerAria:"Auto-continue status",autoContinueControllerDetail:"Last interruption: {detail}",autoContinueControllerPopTitle:"Auto-continue",autoContinueControllerPopBadge:"Try {n}/{max}",autoContinueControllerPopDesc:"This turn was cut off upstream. \u201CContinue\u201D is sent automatically in {seconds}s, at most {max} times; a message from you takes over instead.",autoContinueControllerPopScope:"This session only",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"},Xd={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:"\u57FA\u51C6\u7B49\u5F85 {seconds} \u79D2 \xB7 \u6700\u591A\u7EE7\u7EED {count} \u6B21",autoContinueWaitLabel:"\u5931\u8D25\u540E\u7B49\u5F85",autoContinueRetriesLabel:"\u81EA\u52A8\u7EE7\u7EED\u6B21\u6570\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\u5185\u7F6E\u9519\u8BEF\u7801",autoContinueCodesNone:"\u6E05\u7A7A\u5185\u7F6E\u9519\u8BEF\u7801",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",autoContinueWhyMODEL_SWITCH_COMPACTION_FAILED:"\u6A21\u578B\u5207\u6362\u65F6\u4E0A\u4E0B\u6587\u538B\u7F29\u5931\u8D25\uFF1B\u53EA\u6709\u4F9B\u5E94\u5546\u53EF\u80FD\u6062\u590D\u65F6\u624D\u503C\u5F97\u91CD\u8BD5",autoContinueWhyCLI_TIMEOUT:"\u4EC5\u9002\u7528\u4E8E\u4F1A\u8BDD turn/end \u4E2D\u89C2\u5BDF\u5230\u7684 CLI \u8D85\u65F6\uFF1B\u72EC\u7ACB CLI \u4EFB\u52A1\u4E0D\u53D7\u5F71\u54CD",autoContinueWhyQUOTA:"\u4F59\u989D\u6216\u989D\u5EA6\u4E0D\u8DB3\uFF1B\u7EE7\u7EED\u65E0\u6CD5\u589E\u52A0\u4F59\u989D",autoContinueBackoffLabel:"\u6307\u6570\u9000\u907F",autoContinueBackoffHint:"\u62C9\u957F\u9519\u8BEF\u9A71\u52A8\u7684\u81EA\u52A8\u7EE7\u7EED\u95F4\u9694\uFF1B\u8F93\u51FA\u4E0A\u9650\u89E6\u53D1\u4ECD\u4F7F\u7528\u914D\u7F6E\u7684\u7B49\u5F85\u65F6\u95F4\u3002",autoContinueChainMinutesLabel:"\u5931\u8D25\u94FE\u7D2F\u8BA1\u65F6\u9650",autoContinueChainMinutesUnit:"\u5206\u949F",autoContinueRequestsLabel:"\u8BF7\u6C42\u9884\u7B97",autoContinueRequestsUnit:"\u6B21\u8BF7\u6C42",autoContinueRequestsHint:"\u5931\u8D25\u94FE\u8BF7\u6C42\u7684\u53EF\u89C1\u4E0B\u754C\uFF08\u542B\u5B98\u65B9\u91CD\u8BD5\uFF09\uFF0C\u4E0D\u662F\u8D39\u7528\u6216\u5B98\u65B9\u8BF7\u6C42\u786C\u4E0A\u9650\u3002\u4ECE\u7B2C\u4E00\u6B21\u5931\u8D25\u6216\u5B98\u65B9\u91CD\u8BD5\u8BA1\u65F6\uFF1B\u9884\u7B97\u4EC5\u505C\u6B62\u63D2\u4EF6\u540E\u7EED\u7EE7\u7EED\uFF0C\u4E0D\u4E2D\u6B62\u5B98\u65B9\u540C\u8F6E\u91CD\u8BD5\u3002",autoContinueCustomCodes:"\u81EA\u5B9A\u4E49\u9519\u8BEF\u7801",autoContinueCustomCodePlaceholder:"ADD_CODE",autoContinueCustomCodeAdd:"\u6DFB\u52A0\u9519\u8BEF\u7801",autoContinueCustomCodeRemove:"\u79FB\u9664 {code}",autoContinueCustomCodeInvalid:"\u8BF7\u8F93\u5165\u975E\u7A7A\u9519\u8BEF\u7801\uFF0C\u6700\u591A 64 \u4E2A\u5B57\u6BCD\u3001\u6570\u5B57\u3001.\u3001_\u3001: \u6216 -\u3002",autoContinueCustomCodeLimit:"\u6700\u591A {count} \u4E2A\u81EA\u5B9A\u4E49\u9519\u8BEF\u7801",autoContinueControllerProviderRetry:"\u4F9B\u5E94\u5546\u91CD\u8BD5",autoContinueControllerProviderRetryDesc:"\u5B98\u65B9\u6B63\u5728\u5F53\u524D\u8F6E\u6B21\u5185\u91CD\u8BD5\u8BF7\u6C42\uFF1B\u63D2\u4EF6\u4E0D\u4F1A\u53D1\u9001\u300C\u7EE7\u7EED\u300D\u3002\u505C\u6B62\u81EA\u52A8\u7EE7\u7EED\u4E0D\u4F1A\u53D6\u6D88\u5B98\u65B9\u8BF7\u6C42\uFF0C\u8BF7\u4F7F\u7528\u4F1A\u8BDD\u505C\u6B62\u6309\u94AE\u3002",autoContinueControllerRequestCount:"\u5DF2\u89C2\u5BDF\u5230 {count} \u6B21\u8BF7\u6C42\uFF08\u542B\u5B98\u65B9\u91CD\u8BD5\uFF09",autoContinueControllerExhaustedRequests:"\u8BF7\u6C42\u9884\u7B97\u5DF2\u7528\u5C3D",autoContinueControllerExhaustedDuration:"\u7D2F\u8BA1\u65F6\u9650\u5DF2\u5230",autoContinueControllerOfficialRetryHint:"\u4F9B\u5E94\u5546\u91CD\u8BD5\u8017\u5C3D\u540E\u624D\u8BC4\u4F30\u81EA\u52A8\u7EE7\u7EED\uFF1B\u4E24\u5C42\u8BF7\u6C42\u6210\u672C\u4F1A\u53E0\u52A0\u3002",autoContinueControllerProviderAttempt:"\u7B2C {n} \u6B21",autoContinueControllerWaiting:"\u81EA\u52A8\u7EE7\u7EED",autoContinueControllerSeconds:"{seconds}s",autoContinueControllerRatio:"{n}/{max}",autoContinueControllerSent:"\u5DF2\u7EE7\u7EED",autoContinueControllerSentDesc:"\u5DF2\u53D1\u9001\u300C\u7EE7\u7EED\u300D\uFF0C\u5F53\u524D\u8F6E\u6B21\u6B63\u5728\u8FD0\u884C\uFF1B\u5B98\u65B9\u540C\u8F6E\u91CD\u8BD5\u671F\u95F4\u4E0D\u4F1A\u518D\u53D1\u9001\u6D88\u606F\u3002",autoContinueControllerExhausted:"\u5DF2\u505C\u624B",autoContinueControllerStop:"\u505C\u6B62\u81EA\u52A8\u7EE7\u7EED",autoContinueControllerResume:"\u8DF3\u8FC7\u672C\u5730\u7B49\u5F85",autoContinueControllerReset:"\u91CD\u7F6E",autoContinueControllerSettings:"\u8BBE\u7F6E\u2026",autoContinueControllerAria:"\u81EA\u52A8\u7EE7\u7EED\u72B6\u6001",autoContinueControllerDetail:"\u4E0A\u6B21\u4E2D\u65AD\uFF1A{detail}",autoContinueControllerPopTitle:"\u81EA\u52A8\u7EE7\u7EED",autoContinueControllerPopBadge:"\u7B2C {n}/{max} \u6B21",autoContinueControllerPopDesc:"\u672C\u8F6E\u547D\u4E2D\u4E86\u5DF2\u542F\u7528\u7684\u7EE7\u7EED\u6761\u4EF6\u3002{seconds} \u79D2\u540E\u81EA\u52A8\u53D1\u9001\u300C\u7EE7\u7EED\u300D\uFF0C\u6700\u591A {max} \u6B21\uFF1B\u4F60\u5728\u8FD9\u91CC\u56DE\u4E00\u53E5\u5C31\u63A5\u7BA1\uFF0C\u4E0D\u518D\u81EA\u52A8\u53D1\u3002",autoContinueControllerPopScope:"\u53EA\u5BF9\u5F53\u524D\u4F1A\u8BDD\u751F\u6548",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 Eo="dsh-model-think-level.slider.enabled",Jg=["dsh-reasoning-effort.enabled","@dsh-external/dsh-reasoning-effort.enabled"],Er=Qg();function Qg(){try{let e=window.localStorage.getItem(Eo),t=e===null?Jg.map(n=>window.localStorage.getItem(n)).find(n=>n!==null):null;return(e??t??null)!=="false"}catch{return!0}}var ga=new Set;function Jd(){for(let e of[...ga])e()}function kt(){return Er}function Qd(e){if(Er!==e){Er=e;try{window.localStorage.setItem(Eo,String(e))}catch{}Jd()}}function Zd(e){Er!==e&&(Er=e,Jd())}function To(e){return ga.add(e),()=>{ga.delete(e)}}var So="dsh-model-think-level.provider-order",el=["deepseek-account","deepseek-official"];function On(e){if(e===null)return[];try{let t=JSON.parse(e);return Array.isArray(t)?ba(t.filter(n=>typeof n=="string")):[]}catch{return[]}}function ba(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 Nn=(()=>{try{return On(window.localStorage.getItem(So))}catch{return[]}})(),ha=new Set;function tl(){for(let e of[...ha])e()}function nl(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function In(){return Nn}function Co(e){let t=ba(e);if(!nl(Nn,t)){Nn=t;try{window.localStorage.setItem(So,JSON.stringify(Nn))}catch{}tl()}}function rl(e){let t=ba(e);nl(Nn,t)||(Nn=t,tl())}function Dn(e){return ha.add(e),()=>{ha.delete(e)}}function ya(e){let t=n=>{let r=el.indexOf(n);return r<0?el.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 Pn(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 ol(e){return Pn(ya(e),In())}function va(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 Ao="dsh-model-think-level.providers.disabled",wa=new Set,$t=Zg();function Zg(){try{return On(window.localStorage.getItem(Ao))}catch{return[]}}function il(e){return On(e)}function Tr(){return $t}function _n(e){return!$t.includes(e)}function al(e,t){let n=!$t.includes(e);t!==n&&xa(t?$t.filter(r=>r!==e):[...$t,e],!0)}function sl(e){xa(e,!1)}function dl(e){xa(e,!0)}function Fn(e){return wa.add(e),()=>{wa.delete(e)}}function eh(e,t){return e.length!==t.length?!1:e.every(n=>t.includes(n))}function xa(e,t){if(!eh($t,e)){if($t=[...new Set(e)],t)try{window.localStorage.setItem(Ao,JSON.stringify($t))}catch{}for(let n of[...wa])n()}}var Mo="dsh-model-think-level.model-order";function Ea(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=Ta(o.filter(a=>typeof a=="string"));i.length>0&&(n[r]=i)}return n}catch{return{}}}function Ta(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 Vt=(()=>{try{return Ea(window.localStorage.getItem(Mo))}catch{return{}}})(),ka=new Set;function Sa(){for(let e of[...ka])e()}function th(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function ll(){try{window.localStorage.setItem(Mo,JSON.stringify(Vt))}catch{}}function Sr(){return Vt}function cl(e){return Vt[e]??nh}var nh=[];function ul(e,t){if(e.length===0)return;let n=Ta(t),r=cl(e);if(th(r,n)&&(n.length>0||!(e in Vt)))return;let o={...Vt};n.length===0?delete o[e]:o[e]=n,Vt=o,ll(),Sa()}function fl(e){Vt=e,Sa()}function pl(e){let t={};for(let[n,r]of Object.entries(e)){if(n.length===0)continue;let o=Ta(r);o.length>0&&(t[n]=o)}Vt=t,ll(),Sa()}function qn(e){return ka.add(e),()=>{ka.delete(e)}}function rh(e,t){return Pn(e,t)}function ml(e,t){return Pn(t,cl(e))}function Ca(e,t){if(e.length===0||t.length===0)return e;let n=new Map(e.map(r=>[r.id,r]));return rh(e.map(r=>r.id),t).map(r=>n.get(r))}var gl="dsh-model-think-level.order-saved-at",oh=400,ih=6e4;function La(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 ah(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=La(r);o.length>0&&(t[n]=o)}return t}function hl(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:La(t.providerOrder),modelOrder:ah(t.modelOrder),providersDisabled:Array.isArray(t.providersDisabled)?La(t.providersDisabled):void 0}}function bl(e){return e.providerOrder.length>0||Object.keys(e.modelOrder).length>0||e.providersDisabled!==void 0}function Cr(){try{let e=window.localStorage.getItem(gl),t=e===null?0:Number(e);return Number.isFinite(t)&&t>0?t:0}catch{return 0}}function Ha(e){try{window.localStorage.setItem(gl,String(e))}catch{}}function Ar(){return JSON.stringify({providerOrder:In(),modelOrder:Sr(),providersDisabled:Tr()})}var Xt,Et,Bn=new Set,Lo,Aa,We=!1,Ra=!1,Yt,tt=0;function sh(){let e=Math.max(Date.now(),Cr()+1);return Ha(e),e}function yl(){if(Et=void 0,We)return;let e=Cr(),t=JSON.stringify({savedAt:e>0?e:Date.now(),providerOrder:In(),modelOrder:Sr(),providersDisabled:Tr()});Xt=Ar();let n=tt,r=fetch(ca,{method:"POST",headers:{"content-type":"application/json"},body:t}).then(async o=>{if(We||n!==tt)return!0;let i=await o.json().catch(()=>{});if(We||n!==tt)return!0;let a=hl(i?.data);return o.status===409?Cr()!==e?!0:a!==void 0&&bl(a)?(vl(a),!0):(Xt=void 0,!1):o.ok?(a!==void 0&&a.savedAt>Cr()&&Ha(a.savedAt),!0):(Xt=void 0,!1)}).catch(()=>(!We&&n===tt&&(Xt=void 0),!1));Bn.add(r),r.then(()=>{Bn.delete(r)})}function Na(e){We||Et!==void 0||Ar()!==Xt&&(Et=setTimeout(yl,e))}function Oa(){Et!==void 0&&(clearTimeout(Et),yl())}async function dh(){if(We)return;let e=tt;if(await Ho(),!(We||e!==tt))for(Ar()!==Xt&&Et===void 0&&Bn.size===0&&Na(0);!We&&e===tt&&(Et!==void 0||Bn.size>0);){Oa();let t=await Promise.all([...Bn]);if(We||e!==tt)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 Ma(){We||Ra||(sh(),Na(oh))}function vl(e){Ra=!0;try{Co(e.providerOrder),pl(e.modelOrder),e.providersDisabled!==void 0&&dl(e.providersDisabled)}finally{Ra=!1}Ha(e.savedAt),Xt=Ar()}function Ho(){if(We)return Promise.resolve();if(Yt!==void 0)return Yt;let e=lh().finally(()=>{Yt===e&&(Yt=void 0)});return Yt=e,e}async function lh(){let e=tt,t;try{let o=await fetch(ca,{method:"GET"});if(o.ok){let i=await o.json();i.ok===!0&&(t=hl(i.data))}}catch{return}if(We||e!==tt||Et!==void 0)return;let n=Cr(),r=JSON.stringify({providerOrder:t?.providerOrder??[],modelOrder:t?.modelOrder??{},providersDisabled:t?.providersDisabled??[]});if(t!==void 0&&bl(t)&&t.savedAt>=n){vl(t);return}Ar()!==r&&Na(0)}function Ro(){We||typeof document<"u"&&document.visibilityState==="hidden"||Ho()}function wl(){We=!1,tt+=1,Yt=void 0,Bn.clear(),Xt=void 0;let e=Dn(Ma),t=qn(Ma),n=Fn(Ma);Lo=setInterval(Ro,ih);let r=a=>{let s=a.detail;typeof s?.waitUntil=="function"&&s.waitUntil(dh())},o=()=>{let a=tt;(async()=>(Yt!==void 0&&await Yt,!We&&a===tt&&await Ho()))()};typeof window<"u"&&(window.addEventListener("focus",Ro),window.addEventListener("dsh-webdav-sync:before-snapshot",r),window.addEventListener("dsh-webdav-sync:applied",o));let i=()=>{document.visibilityState==="visible"&&Ro()};return typeof document<"u"&&document.addEventListener("visibilitychange",i),Aa=()=>{typeof document<"u"&&document.removeEventListener("visibilitychange",i),typeof window<"u"&&(window.removeEventListener("focus",Ro),window.removeEventListener("dsh-webdav-sync:before-snapshot",r),window.removeEventListener("dsh-webdav-sync:applied",o))},Ho(),()=>{We=!0,tt+=1,Et!==void 0&&clearTimeout(Et),Et=void 0,Lo!==void 0&&clearInterval(Lo),Lo=void 0,Aa?.(),Aa=void 0,e(),t(),n()}}var xl=`
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
@@ -5253,6 +5253,22 @@ li.bre-row-disabled [class*="rowName"] { opacity: .5; }
5253
5253
  padding: 7px 8px 3px;
5254
5254
  border-top: 1px solid var(--bre-line-1);
5255
5255
  }
5256
+ .bre-config-link {
5257
+ flex: none;
5258
+ margin: 0;
5259
+ padding: 3px 0;
5260
+ border: none;
5261
+ background: transparent;
5262
+ color: var(--bre-accent-ink);
5263
+ font-family: inherit;
5264
+ font-size: 11.5px;
5265
+ line-height: 18px;
5266
+ white-space: nowrap;
5267
+ cursor: pointer;
5268
+ }
5269
+ .bre-config-link:hover { text-decoration: underline; }
5270
+ .bre-config-link:focus-visible { outline: 2px solid var(--bre-accent-line); outline-offset: 2px; border-radius: 3px; }
5271
+ .bre-config-link:disabled { opacity: 0.5; cursor: default; text-decoration: none; }
5256
5272
  .bre-config-link-quiet { margin-right: auto; color: var(--bre-ink-3); }
5257
5273
  .bre-config-link-quiet:hover { color: var(--bre-accent-ink); }
5258
5274
 
@@ -5385,12 +5401,12 @@ li.bre-row-disabled [class*="rowName"] { opacity: .5; }
5385
5401
  .bre-ed-src { flex: 1; min-width: 0; font-size: 10.5px; color: var(--bre-ink-3); }
5386
5402
  .bre-config-error-detail-copy { margin: 0; max-width: none; }
5387
5403
 
5388
- `;var kr="bre:endpoints-changed",Er="bre:settings-changed",Tr="bre:balance-changed";var Lr=require("react"),Gl=require("react-dom");var O=require("react"),Rl=require("react-dom");var X=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function cl(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 hl=["off","minimal","low","medium","high","xhigh","max"],Fg=["text","image"];var qg=[{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"}],Aa={off:null,low:"low",medium:"medium",high:"high"},Kg={"openai-completions":Aa,"openai-responses":Aa,"anthropic-messages":Aa,deepseek:{off:"none",low:"low",high:"high",max:"max"}},Bg={low:"low",medium:"medium",high:"high"};function _n(e){return(e??"").toLowerCase().trim()}function ul(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 Ca(e,t,n){let r=t===0?void 0:e[t-1],o=e[t+n];return!ul(r)&&!ul(o)}function Ra(e,t){let n=nn(e)+" "+nn(t??""),r;for(let o of qg)for(let i of o.patterns){let a=nn(i),s=n.indexOf(a);for(;s>=0;){if(Ca(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 Wg={"deepseek.com":"deepseek","anthropic.com":"anthropic-messages"};function Gg(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=Wg[o.slice(-2).join(".")];if(i!==void 0)return i}}catch{}return"openai-completions"}var Sr="openai-completions",Ug="openai-responses",Ha="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 jg(e,t){let n=_n(t),r={...e};if(delete r.supportsMidConvoEffort,delete r.allowedFallbackModels,n===Ha){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 fl=["supportsReasoningEffort","thinkingFormat","thinkingTokenBudgetField","supportsThinkingTokenBudget","vllmPriority"],pl=["forceAdaptiveThinking"];function Na(e,t){let n=_n(t),r;if(n===Sr)r=pl;else if(n===Ug)r=[...fl,...pl];else if(n===Ha)r=fl;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 zg(e,t){let n=_n(t.api);if(n===Sr){let r=e.compat;r!==void 0&&(r=jg(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===Ha&&e.anthropicAdaptive===!0)return{forceAdaptiveThinking:!0}}var $g=["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 Oa(e){if(_n(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(".")?!$g.some(r=>n===r||n.endsWith("."+r)):!1}catch{return!1}}function ml(e,t,n){return e===void 0||!n||e.supportsDeveloperRole!==void 0||!Oa(t)?e:{...e,supportsDeveloperRole:!1}}var gl={off:null,low:"low",medium:"medium",high:"high"},Vg=["vl","vision","omni","4o","pixtral","internvl"];function Ia(e){let t=nn(e);for(let n of Vg){let r=nn(n),o=t.indexOf(r);for(;o>=0;){if(Ca(t,o,r.length))return["text","image"];o=t.indexOf(r,o+1)}}}var Yg=["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 Jg(e){let t=nn(e);for(let n of Yg){let r=nn(n),o=t.indexOf(r);for(;o>=0;){if(Ca(t,o,r.length))return!0;o=t.indexOf(r,o+1)}}return!1}function Xg(e){if(e===void 0)return;let t=e.map(n=>n.toLowerCase());if(t.some(n=>Fg.includes(n)))return t.includes("image")?["text","image"]:["text"]}function kt(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=Xg(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=Ia(e);x!==void 0&&(o=x,i="heuristic")}a===void 0&&Jg(e)&&(a=!0),a===!0&&(o=void 0,i=void 0);let p={...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,...p};if(r!==void 0){let x=ml(zg(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,...p}}let m=Gg(t),g=Kg[m]??Bg,b=_n(t.api)===Sr?{thinkingFormat:"openai",supportsReasoningEffort:!0}:void 0,f=b!==void 0&&La(t.baseURL)?{...b,thinkingTokenBudgetField:"thinking_token_budget"}:b,v=ml(f,t,!0);return n?.reasoning===!0?{efforts:{...gl},...gl.medium!==void 0?{defaultEffort:"medium"}:{},...v===void 0?{}:{compat:v},matched:!1,source:"endpoint:"+(n.source??"listing"),confidence:"medium",...h,...p}:{efforts:g,...g.medium!==void 0?{defaultEffort:"medium"}:{},...v===void 0?{}:{compat:v},matched:!1,source:"protocol:"+m,confidence:"low",...h,...p}}var Bt=(e,t)=>typeof e[t]=="boolean";function Qg(e,t){if(Array.isArray(e)){for(let n of e)if(X(n)&&n.id===t)return n}}function Zg(e){if(!X(e))return{reasoning:"unknown",source:null};let t=e.supported_features;if(Array.isArray(t)&&t.includes("reasoning"))return{...Xe(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{...Xe(e),reasoning:!0,source:"supported_parameters"};if(Bt(e,"supports_reasoning"))return{...Xe(e),reasoning:e.supports_reasoning,source:"supports_reasoning"};if(Bt(e,"supportsReasoning"))return{...Xe(e),reasoning:e.supportsReasoning,source:"supportsReasoning"};if(Bt(e,"can_reason"))return{...Xe(e),reasoning:e.can_reason,source:"can_reason"};if(Bt(e,"reasoning"))return{...Xe(e),reasoning:e.reasoning,source:"reasoning"};let r=e.reasoning_effort;if(r===!1)return{...Xe(e),reasoning:!1,source:"reasoning_effort"};if(typeof r=="string"&&r.trim().length>0||e.supports_reasoning_effort===!0)return{...Xe(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{...Xe(e),reasoning:!0,source:"capabilities.effort.supported"};if(a===!0)return{...Xe(e),reasoning:!0,source:"capabilities.thinking.supported"};if(a===!1)return{...Xe(e),reasoning:!1,source:"capabilities.thinking.supported"};if(d===!1)return{...Xe(e),reasoning:!1,source:"capabilities.effort.supported"}}return{...Xe(e),reasoning:"unknown",source:null}}function Xe(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 p=X(s[c])?s[c]:void 0;if(p===void 0||typeof p.supported!="boolean")continue;let h=c.replace(/_input$/,"");p.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 p=(X(e.limit)?e.limit:void 0)?.context;typeof p=="number"&&Number.isFinite(p)&&p>0&&(t.contextLength=p)}}}return t}function bl(e,t){let n=Qg(e,t);return n===void 0?{found:!1,signal:{reasoning:"unknown",source:null}}:{found:!0,signal:Zg(n)}}function Be(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 vl(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 Ao(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 Lo(e,t){let r=e.find(o=>o.id===t)?.compat;if(X(r))return{...r}}function Da(e,t){return e.find(r=>r.id===t)?.[st]===!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)?.[Mn];return typeof r=="string"&&r.length>0?r:void 0}var eh=3e4,th=15e3,Pa=new Map,To=new Map;async function nh(e){let t=Pa.get(e);if(t!==void 0&&Date.now()-t.at<eh)return t.data;let n=To.get(e);if(n!==void 0)return n;let r=(async()=>{try{let o=await fetch(`${Nd}?route=${encodeURIComponent(e)}`,{method:"GET",signal:AbortSignal.timeout(th)});if(!o.ok)return;let i=await o.json();return i?.ok?(Pa.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 _a(){Pa.clear(),To.clear()}async function rh(e,t){let n=await nh(e);return n===void 0?{reasoning:"unknown",source:null}:bl(n,t).signal}function Ho(e,t=()=>ge(e),n,r,o,i){return{async suggest(a,s,d,l){let c=Be((await t()).namespace),p=tn(c,a),h={api:p.api??l?.api,baseURL:p.baseURL??l?.baseURL,displayName:d??p.displayName},m=c[a]===void 0?void 0:await rh(a,s),g=kt(s,h,m);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,p,h){n?.(a,s,d,l,c,p,h)},async writeEfforts(a,s,d,l,c,p,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},...p===void 0?{}:{defaultEffort:p}}),{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},...p===void 0?{}:{defaultEffort:p}}],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=()=>ge(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 ge(e,{fresh:!0});if(s.namespace===void 0)return n.map(()=>({ok:!1,error:"no-namespace"}));let d=vl(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(m=>m),p=[];for(let m of n){let g=c.findIndex(b=>b.id===m.modelId);if(g<0){p.push(m.modelId);continue}c[g]=oh(c[g],m,i?void 0:m.compat)}if(p.length>0)return n.map(m=>p.includes(m.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(_e,[{op:"set",path:["providers",t,"models"],value:c}],s.namespace.revision);if(!h.ok){if(a===0&&h.error.code==="settings/conflict")continue;let m=h.error.code==="settings/rejected"&&cl(h.error.message);if(!i&&m&&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 oh(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[at]=!0;else if(delete r[at],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[xt]=!0):(delete r[xt],r.input=[...t.input])),t.imageGen!==void 0&&(t.imageGen===!0?(r[st]=!0,delete r.input,delete r[xt]):delete r[st]),t.defaultEffort!==void 0&&(t.defaultEffort===null?delete r[Mn]:r[Mn]=t.defaultEffort),r}function Fa(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 ge(e):await ge(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(!dt(i.namespace,t)){r=!0;continue}let a=await e.settings.mutate(_e,[{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 dt(e,t){if(Object.prototype.hasOwnProperty.call(Be(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 ge(e,t={}){let n=t.fresh===!0?void 0:ih(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===_e),writable:r.value.writable,source:"wire"}:{namespace:void 0,writable:!1,source:"wire"}}var yl=new WeakMap;function ih(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:_e,schema:{},value:r.value,user:r.user,base:r.base,revision:r.revision,applies:"live",secrets:[]},writable:r.writable===!0,source:"scope"};return yl.set(n,i),i}if(!t||n===void 0)return;let o=yl.get(n);if(o!==void 0)return{...o,source:"scope-stale"}}var qa=new Map;function wl(e){let t=qa,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=ge(e,{fresh:!0}).then(l=>{if(d!==o||l.namespace===void 0)return;let c=new Map;for(let[p,h]of Object.entries(Be(l.namespace))){let m=new Map,g=Array.isArray(h.models)?h.models:[];for(let b of g){if(!X(b)||typeof b.id!="string"||b.id.length===0)continue;let f={};if(Array.isArray(b.input)){let x=b.input.filter(w=>typeof w=="string");x.length>0&&(f.input=x)}b[st]===!0&&(f.imageGen=!0);let v=b.contextWindow;typeof v=="number"&&Number.isFinite(v)&&v>0&&(f.contextWindow=v),(f.input!==void 0||f.imageGen!==void 0||f.contextWindow!==void 0)&&m.set(b.id,f)}m.size>0&&c.set(p,m)}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 ah=new Intl.NumberFormat("en-US"),sh=/^(\d+(?:\.\d+)?)([kmbt])?$/i,dh={k:1e3,m:1e6,b:1e9,t:1e12};function Et(e){let t=e.replace(/[,_\s]/g,"");if(t==="")return;let n=sh.exec(t);if(n===null)return;let r=n[2]===void 0?1:dh[n[2].toLowerCase()],o=Math.round(Number(n[1])*r);return Number.isFinite(o)&&o>0?o:void 0}function bt(e){return e===void 0?"":ah.format(e)}function xl(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=m=>Math.round(m*10)/10,l=e/s.binary,c=e/s.decimal,p=Math.abs(e-d(l)*s.binary),h=Math.abs(e-d(c)*s.decimal);return p<=h?`${i(l)}${s.suffix}`:`${i(c)}${s.suffix}`}return String(e)}var El="dsh-model-think-level.slider.efforts",Ka="breSelectWired",lh=400;function ch(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),lh);e.then(i=>{clearTimeout(o),r(i)},()=>{clearTimeout(o),r(void 0)})})}function Ba(e){return typeof e=="object"&&e!==null&&e.ok===!1}function Wa(e){if(!Ba(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 Tl(){try{let e=window.localStorage.getItem(El);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 uh(e){try{window.localStorage.setItem(El,JSON.stringify(e))}catch{}}function fh(e,t,n){let r=Tl();r[on(e,t)]=n,uh(r)}function ph(e,t){return Tl()[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 mh(e,t,n){return e.groups.find(o=>o.id===t)?.models.find(o=>o.id===n)?.reasoning?.defaultEffort}function gh(e){if(!(e.length<2))return e[Math.floor((e.length-1)/2)]}function hh(e,t){return e===null||e.provider!==t.provider||e.model!==t.model}async function kl(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 ch(o?.configuredEffort===void 0?void 0:o.configuredEffort(t,n));if(d!==void 0&&i.includes(d))return d;let l=ph(t,n);if(l!==void 0&&i.includes(l))return l;let c=kt(n,{}).defaultEffort;if(c!==void 0&&i.includes(c))return c;let p=mh(e,t,n);return p!==void 0&&i.includes(p)?p:gh(i)}function Sl(e,t){let n=e;if(n[Ka]===!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,p=async(b,f)=>{if(f.reasoningEffort!==void 0){let F=await o.call(e,f);return!Ba(F)&&gt()&&(i.set(on(f.provider,f.model),f.reasoningEffort),fh(f.provider,f.model,f.reasoningEffort)),F}let v=e.store.getSnapshot();if(!hh(v.current,f)){if(gt()){let F=on(f.provider,f.model);i.delete(F),a.add(F)}return o.call(e,f)}if(!gt())return o.call(e,f);let x=await kl(v,f.provider,f.model,i,t);if(l!==b)return;let w=e.store.getSnapshot(),R=w.current!==null&&w.current.provider===f.provider&&w.current.model===f.model;return!gt()||x===void 0||!No(w,f.provider,f.model).includes(x)?R?void 0:o.call(e,f):o.call(e,{...f,reasoningEffort:x})},h=async b=>{let f=++l;try{return await p(f,b)}finally{f>c&&(c=f)}},m=()=>{let b=e.store.getSnapshot(),f=b.current;if(f===null||f.reasoningEffort!==void 0||!gt())return;let v=on(f.provider,f.model);if(a.has(v))return;if(No(b,f.provider,f.model).length===0){a.add(v);return}a.add(v);let x=l;kl(b,f.provider,f.model,i,t).then(async w=>{if(w===void 0){a.delete(v);return}if(!gt()){a.delete(v);return}if(l!==x)return;if(l!==c){a.delete(v);return}let R=e.store.getSnapshot(),F=R.current;if(F===null||F.reasoningEffort!==void 0||on(F.provider,F.model)!==v||!No(R,F.provider,F.model).includes(w))return;let re=await o.call(e,{provider:F.provider,model:F.model,reasoningEffort:w});if(Ba(re))throw re}).catch(()=>{let w=(s.get(v)??0)+1;s.set(v,w),w<d&&(a.delete(v),m())})},g=e.store.subscribe(m);return m(),n[Ka]=!0,e.select=h,()=>{delete n[Ka],g(),r?e.select=o:delete n.select}}var bh=1e4;function Ml(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 yh(e){return e.current}function Al(e,t){let n=yh(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 vh(e){return e?.models??[]}function Wt(e){let t=e;return t.name??t.label??t.title??e.id}function Ga(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 wh(){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(()=>{Ga(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(()=>{Ga(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 xh({state:e}){if(typeof document>"u")return null;let t=e.target;if(!Ga(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 kh(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"):(Ia(e.id)??[]).includes("image");return Ll.set(r,a),a}function Cl(e,t){return t?.imageGen===!0?!0:e.inputImageGen===!0}function Eh(e){let t=e.reasoning?.efforts;return Array.isArray(t)&&t.length>0}function Th(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 Sh(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 Mh(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 Ah=["#22c55e","#a3e635","#eab308","#f97316","#ef4444"],lE=Ah.map(e=>[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]);function Lh(e,t,n,r=!1){let o=[];return kh(e,n)&&o.push((0,O.createElement)("span",{key:"vision",className:"bre-tag",title:t("tagVision")},Th(t("tagVision")))),Eh(e)&&o.push((0,O.createElement)("span",{key:"thinking",className:"bre-tag",title:t("tagThinking")},Sh(t("tagThinking")))),r&&o.push((0,O.createElement)("span",{key:"imageGen",className:"bre-tag",title:t("tagImageGen")},Mh(t("tagImageGen")))),o.length===0?null:(0,O.createElement)("span",{className:"bre-option-tags"},...o)}function Ch(e,t){let n=xl(e);return n===""?null:(0,O.createElement)("span",{className:"bre-option-cap",title:t("contextWindowLabel")},n)}function Hl(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()??qa),a=Ml(o),[s,d]=(0,O.useState)(()=>{let L=t.store.getSnapshot(),U=Ml(L);return U[Al(U,L)]?.id??""}),[l,c]=(0,O.useState)(""),[p,h]=(0,O.useState)(null),[m,g]=(0,O.useState)(!1),[b,f]=(0,O.useState)(null),v=(0,O.useRef)(null),x=(0,O.useRef)(""),w=(0,O.useRef)(!1),R=o.current!==null&&a.length>=2,F=m,re=b??o.error,j=t.select,T=(0,O.useCallback)(()=>setTimeout(()=>{w.current&&(w.current=!1,g(!1),f(n("sliderCommitSlow")))},bh),[n]);(0,O.useLayoutEffect)(()=>{if(w.current||me.current)return;let L=Al(a,o),U=a[L]?.id??"";x.current=U,d(ve=>ve===U?ve:U),f(null)},[R,a,o]),(0,O.useEffect)(()=>{t.load().catch(()=>{})},[t]),(0,O.useEffect)(()=>{r?.load().catch(()=>{})},[r]);let N=o.current,z=o.groups.find(L=>L.id===N?.provider),y=z?.models.find(L=>L.id===N?.model)?.name??(N===null?n("triggerFallback"):N.model),A=N===null?"":Wt(z??{id:N.provider}),C=a.find(L=>L.id===s)?.name??n("effortDefault"),I=(0,O.useSyncExternalStore)(Rn,Cn),D=(0,O.useSyncExternalStore)(On,yr),H=(0,O.useSyncExternalStore)(In,vr),$=(0,O.useCallback)((L,U)=>i.get(L)?.get(U),[i]),Q=(0,O.useCallback)((L,U)=>Cl(U,$(L,U.id)),[$]),oe=(0,O.useCallback)((L,U)=>vh(L).filter(ve=>!Q(U,ve)),[Q]),ae=o.groups.filter(L=>oe(L,L.id).length>0&&!D.includes(L.id)).map(L=>L.id),se=Hn(ua(ae),I),ue=p!==null&&se.includes(p)?p:N!==null&&se.includes(N.provider)?N.provider:se[0]??null,fe=l.trim().toLowerCase(),Z=fe!=="",he=Z?se.flatMap(L=>va(oe(o.groups.find(U=>U.id===L),L),H[L]??[]).filter(U=>(U.name??U.id).toLowerCase().includes(fe)||U.id.toLowerCase().includes(fe)).map(U=>({provider:L,choice:U}))):[],Me=Z?he:ue===null?[]:va(oe(o.groups.find(L=>L.id===ue),ue),H[ue]??[]).map(L=>({provider:ue,choice:L})),Ce=N===null?"":N.provider+"/"+N.model,Le=n("sliderNoCurrent"),J=(0,O.useCallback)(()=>{let L=v.current?.closest('[role="menu"], [role="group"]');L!=null&&(L.tabIndex=-1,L.focus({preventScroll:!0}))},[]),B=(0,O.useCallback)(async(L,U)=>{if(w.current)return;let ve=t.store.getSnapshot().current;if(Z&&c(""),ve!==null&&ve.provider===L&&ve.model===U)return;w.current=!0,J(),g(!0),f(null);let $e=T();try{let Ve=await j({provider:L,model:U}),mt=Wa(Ve);if(mt!==void 0)throw new Error(mt)}catch(Ve){f(Ve instanceof Error?Ve.message:String(Ve))}finally{clearTimeout($e),w.current=!1,g(!1)}},[T,t,J,Z,j]),V=(0,O.useCallback)(async L=>{if(w.current||L===o.current?.reasoningEffort&&o.status!=="error")return;w.current=!0;let U=x.current;J(),g(!0),f(null),d(L);let ve=T();try{let $e=o.current;if($e===null)throw new Error(n("sliderNoCurrent"));let Ve=await j({provider:$e.provider,model:$e.model,reasoningEffort:L}),mt=Wa(Ve);if(mt!==void 0)throw new Error(mt);let en=t.store.getSnapshot(),Rd=a.find(bg=>bg.id===en.current?.reasoningEffort)?.id??L;x.current=Rd,d(Rd)}catch($e){x.current=U,d(U),f($e instanceof Error?$e.message:String($e))}finally{clearTimeout(ve),w.current=!1,g(!1)}},[T,t,J,a,j,o.current,o.status,n]),te=(0,O.useRef)(null),pe=(0,O.useRef)(null),ke=(0,O.useRef)(null),me=(0,O.useRef)(!1),Se=(0,O.useRef)(null),u=(0,O.useRef)(null),S=(0,O.useRef)(null),[q,K]=(0,O.useState)(null),[k,_]=(0,O.useState)(null),ee=Math.max(0,a.findIndex(L=>L.id===s)),le=q??ee,be=(k??(a.length>1?le/(a.length-1):0))*100,ye=L=>{let U=te.current;if(U===null)return 0;let ve=U.getBoundingClientRect();return ve.width<=0?0:Math.min(1,Math.max(0,(L-ve.left)/ve.width))},De=L=>a.length>1?Math.round(L*(a.length-1)):0,ze=L=>{u.current=L;let U=L*100;pe.current!==null&&(pe.current.style.clipPath=`inset(0 ${100-U}% 0 0)`),ke.current!==null&&(ke.current.style.left=`${U}%`)},pt=L=>{if(a.length===0)return;let U=ye(L);S.current===null&&(S.current=requestAnimationFrame(()=>{S.current=null,me.current&&u.current!==null&&ze(u.current)})),u.current=U;let ve=De(U);ve!==Se.current&&(Se.current=ve,K(ve),_(U))},Qt=()=>{Se.current=null,u.current=null,S.current!==null&&(cancelAnimationFrame(S.current),S.current=null),K(null),_(null)},En=L=>{if(R){if(L.preventDefault(),me.current=!0,typeof L.currentTarget.setPointerCapture=="function")try{L.currentTarget.setPointerCapture(L.pointerId)}catch{}Se.current=De(ye(L.clientX)),pt(L.clientX),K(Se.current),_(u.current)}},Re=L=>{me.current&&pt(L.clientX)},co=L=>{if(!me.current)return;if(me.current=!1,typeof L.currentTarget.releasePointerCapture=="function"&&L.currentTarget.hasPointerCapture?.(L.pointerId)===!0)try{L.currentTarget.releasePointerCapture(L.pointerId)}catch{}let U=De(ye(L.clientX)),ve=a[U];if(ve===void 0){Qt();return}V(ve.id).finally(Qt)},ta=L=>{if(!R)return;let U;if(L.key==="ArrowRight"||L.key==="ArrowUp"?U=Math.min(a.length-1,le+1):L.key==="ArrowLeft"||L.key==="ArrowDown"?U=Math.max(0,le-1):L.key==="Home"?U=0:L.key==="End"&&(U=a.length-1),U===void 0)return;L.preventDefault();let ve=a[U];ve!==void 0&&V(ve.id)},{tip:Tn,onEnter:Zt,onLeave:gr}=wh(),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":N===null?y:A+" \xB7 "+y,onMouseEnter:L=>{Zt(L,N===null?y:A+" \xB7 "+y)},onMouseLeave:gr},y),A===""?null:(0,O.createElement)("span",{className:"bre-menu-prov"},A))),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")},...se.map(L=>{let U=o.groups.find(ve=>ve.id===L);return(0,O.createElement)("button",{key:L,type:"button",className:"bre-provider"+(L===ue?" is-open":"")+(L===N?.provider?" is-current":""),disabled:F,"aria-expanded":L===ue,onMouseLeave:gr,onClick:()=>{h(L),c("")}},(0,O.createElement)("span",{className:"bre-option-name","aria-label":Wt(U),onMouseEnter:ve=>{Zt(ve,Wt(U))}},Wt(U)),(0,O.createElement)("span",{className:"bre-provider-count"},String(oe(U,L).length)))}),...se.length===0?[(0,O.createElement)("div",{key:"no-providers",className:"bre-empty"},Le)]:[]),He=(0,O.createElement)("div",{className:"bre-provider-models",role:"group","aria-label":n("modelRowLabel")},...Me.length===0?[(0,O.createElement)("div",{key:"no-models",className:"bre-empty"},Z?n("modelSearchNoMatches"):Le)]:Me.map(({provider:L,choice:U})=>{let ve=L+"/"+U.id,$e=ve===Ce,Ve=U.name??U.id,mt=Z?Wt(o.groups.find(en=>en.id===L))+" \xB7 "+Ve:Ve;return(0,O.createElement)("button",{key:ve,type:"button",className:"bre-option"+($e?" is-active":""),disabled:F,"aria-pressed":$e,onMouseLeave:gr,onClick:()=>{B(L,U.id)}},(0,O.createElement)("span",{className:"bre-option-name","aria-label":mt,onMouseEnter:en=>{Zt(en,mt)}},Z?(0,O.createElement)("span",{className:"bre-option-origin"},Wt(o.groups.find(en=>en.id===L))+" \xB7 "):null,Ve),Ch($(L,U.id)?.contextWindow,n),Lh(U,n,$(L,U.id)?.input,Cl(U,$(L,U.id))))})),qe=(0,O.createElement)("div",{className:"bre-menu-foot"},R?(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[le]?.name??C)),(0,O.createElement)("div",{className:"bre-effort-slider",ref:te,role:"slider",tabIndex:0,"aria-label":n("effortRowLabel"),"aria-valuemin":0,"aria-valuemax":a.length-1,"aria-valuenow":le,"aria-valuetext":a[le]?.name,"aria-disabled":F||void 0,"data-bre-dragging":q===null?void 0:"true",onPointerDown:En,onPointerMove:Re,onPointerUp:co,onPointerCancel:co,onKeyDown:ta},(0,O.createElement)("span",{className:"bre-effort-slider-fill",ref:pe,style:{clipPath:`inset(0 ${100-be}% 0 0)`}}),...a.map((L,U)=>U===le?null:(0,O.createElement)("span",{key:"tick-"+L.id,className:"bre-effort-slider-tick",style:{left:a.length>1?`${U/(a.length-1)*100}%`:"0%"}})),(0,O.createElement)("span",{className:"bre-effort-slider-thumb",ref:ke,style:{left:`${be}%`}})),(0,O.createElement)("div",{className:"bre-effort-slider-labels","aria-hidden":!0},...a.map((L,U)=>(0,O.createElement)("span",{key:L.id,className:"bre-effort-slider-label"+(U===0?" is-first":"")+(U===a.length-1?" is-last":"")+(U===le?" is-on":""),style:{left:a.length>1?`${U/(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:v},(0,O.createElement)("div",{className:"bre-card"},uo,P,(0,O.createElement)("div",{className:"bre-panel bre-panel-models"},ce,He),qe),re===null?null:(0,O.createElement)("div",{className:"bre-model-error",role:"status"},re),Tn===null?null:(0,O.createElement)(xh,{key:"tip",state:Tn}))}var Te=require("react"),Ol='section[role="group"]',ja='button[role="menuitemradio"]';function Il(e){return e.querySelector(Ol)!==null}function Ua(e){return Array.from(e.querySelectorAll(ja)).filter(t=>!t.disabled&&t.style.display!=="none")}function Rh(e){let t=e.getAttribute("aria-labelledby");return(t===null?null:e.ownerDocument.getElementById(t))?.textContent?.toLowerCase()??""}function Nl(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(Ol)),s=0;if(i.length===0){for(let d of[...n.keys()])o(d);for(let d of a)s+=d.querySelectorAll(ja).length;return s}for(let d of a){let l=Rh(d),c=Array.from(d.querySelectorAll(ja)),p=0;for(let h of c){let m=(h.getAttribute("title")??"").toLowerCase(),g=(h.textContent??"").toLowerCase(),b=`${l} ${m} ${g}`;i.every(f=>b.includes(f))?(o(h),p+=1):r(h)}p>0?(o(d),s+=p):r(d)}return s}function Pl({menu:e,t}){let[n,r]=(0,Te.useState)(""),[o,i]=(0,Te.useState)(0),a=(0,Te.useRef)(null),s=(0,Te.useRef)(""),d=(0,Te.useRef)(new Map),l=(0,Te.useCallback)(m=>{s.current=m;let g=Nl(e,m,d.current);i(g)},[e]);(0,Te.useEffect)(()=>()=>{Nl(e,"",d.current)},[e]),(0,Te.useEffect)(()=>{let m=new MutationObserver(()=>{s.current.trim().length!==0&&l(s.current)});return m.observe(e,{childList:!0,subtree:!0}),()=>{m.disconnect()}},[e,l]),(0,Te.useEffect)(()=>{let m=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=Ua(e);if(x.length===0)return;let w=x.findIndex(F=>F===document.activeElement),R;b==="Home"||b==="PageUp"?R=0:b==="End"||b==="PageDown"?R=x.length-1:b==="ArrowDown"?R=w===-1?0:(w+1)%x.length:R=w===-1?x.length-1:(w-1+x.length)%x.length,g.preventDefault(),g.stopPropagation(),x[R]?.focus()};return e.addEventListener("keydown",m,!0),()=>{e.removeEventListener("keydown",m,!0)}},[e]);let c=m=>{let g=m.key;if(g==="ArrowDown"){m.preventDefault(),m.stopPropagation(),Ua(e)[0]?.focus();return}if(n.trim().length>0&&(g==="ArrowUp"||g==="Home"||g==="PageUp"||g==="End"||g==="PageDown")){let b=Ua(e);b.length>0&&(m.preventDefault(),m.stopPropagation(),b[g==="ArrowUp"||g==="End"||g==="PageDown"?b.length-1:0]?.focus());return}g==="Escape"&&n.length>0&&(m.preventDefault(),m.stopPropagation(),r(""),l(""))},p=()=>{r(""),l(""),a.current?.focus({preventScroll:!0})},h=o===0&&n.trim().length>0;return(0,Te.createElement)("div",{className:"bre-model-search-box"+(h?" has-empty":""),"data-bre-search":"1"},(0,Te.createElement)("div",{className:"bre-search-input-wrapper"},(0,Te.createElement)("span",{className:"bre-search-icon","aria-hidden":"true"},(0,Te.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,Te.createElement)("circle",{cx:"7",cy:"7",r:"4.5"}),(0,Te.createElement)("path",{d:"M10.5 10.5L14 14",strokeLinecap:"round"}))),(0,Te.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:m=>{let g=m.currentTarget.value;r(g),l(g)},onKeyDown:c}),n.length>0?(0,Te.createElement)("button",{type:"button",className:"bre-search-clear",title:t("modelSearchClear"),"aria-label":t("modelSearchClear"),onClick:p},(0,Te.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,Te.createElement)("path",{d:"M4 4L12 12M12 4L4 12",strokeLinecap:"round"}))):null),h?(0,Te.createElement)("div",{className:"bre-search-empty",role:"status"},t("modelSearchNoMatches")):null)}var Oo=require("react"),Dl=require("react-dom"),_l=require("react-dom/client");function yt(){return document.body}function Qe(e,t,n){let r=(0,_l.createRoot)(e);return n?.sync===!0?(0,Dl.flushSync)(()=>{r.render(t)}):r.render(t),{wrapper:e,root:r}}function Oe(e){e!==void 0&&(e.root.unmount(),e.wrapper.remove())}var We=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 Hh="conversation.input.model";function Fl(e){return e.querySelector("[data-composer-card]")??void 0}function za(e){return e.querySelector(`[data-slot="${Hh}"]`)??void 0}function ql(e){let t=za(e)??e;return Array.from(t.querySelectorAll('button[aria-haspopup="menu"]'))}function $a(e){if(e==null)return!1;let t=e.getAttribute("role");return t==="menu"||t==="group"}function Va(e){return e.getAttribute("role")==="group"}function Kl(e,t){let n=e.getAttribute("aria-controls");if(n===null||n.length===0)return;let r=t.getElementById(n);return $a(r)?r:void 0}function Ya(e=document){let t=Fl(e);if(t===void 0)return;for(let r of ql(t)){let o=Kl(r,e);if(o!==void 0)return o}let n=za(t)??t;for(let r of Array.from(n.querySelectorAll('[role="menu"], [role="group"]')))if(r.previousElementSibling?.matches('button[aria-haspopup="menu"]')&&$a(r)&&!(r.getAttribute("role")==="group"&&r.querySelector('[role="menuitemradio"], section[role="group"]')===null))return r}function Ja(e=document){let t=Fl(e);if(t===void 0)return;let n=za(t),r=ql(t),o=r[0];if(o!==void 0){for(let i of r)if(Kl(i,e)!==void 0)return i;for(let i of r)if($a(i.nextElementSibling))return i;return n===void 0?r.at(-1):o}}function Bl(){return Ya()}function Wl(){return Ja()}var Nh=()=>{(0,Gl.flushSync)(()=>{window.dispatchEvent(new Event("resize"))})};function Ul(e){let{menuOf:t,triggerOf:n,t:r,refreshed:o,sliderEnabled:i,directory:a}=e,s,d,l,c,p,h,m,g,b=()=>{g?.removeAttribute("data-bre-provider"),g=void 0},f=()=>{let M=n();g!==void 0&&g!==M&&b();let y=h?.store.getSnapshot(),A=y?.current;if(M===void 0||A===null||A===void 0){M===g&&b();return}let C=y?.groups.find(D=>D.id===A.provider),I=C===void 0?A.provider:Wt(C);if(I.trim()===""){M===g&&b();return}M.dataset.breProvider=I,g=M},v=()=>{let M=a();M!==h&&(m?.(),m=void 0,h=M,M!==void 0&&(m=M.store.subscribe(f))),f()},x=()=>{Oe(l),l=void 0},w=new Map,R=()=>{for(let[y,A]of w)y.style.display=A;w.clear();let M=t();M!==void 0&&M.getAttribute("tabindex")==="-1"&&M.removeAttribute("tabindex")},F=M=>M.getAttribute("aria-hidden")!=="true"||M.childElementCount>0?!1:(M.textContent??"").trim()==="",re=(M,y)=>{for(let I of Array.from(w.keys()))(!I.isConnected||I.parentElement!==M)&&w.delete(I);let A=[];for(let I of Array.from(M.children))I!==y&&(F(I)||A.push(I));let C=document.activeElement;C!==null&&C!==y&&!y.contains(C)&&A.some(I=>I.contains(C))&&(M.tabIndex=-1,M.focus({preventScroll:!0}));for(let I of A)w.has(I)||w.set(I,I.style.display),I.style.display!=="none"&&(I.style.display="none")},j=M=>{let y=M.querySelector('section[role="group"]'),A=y?.parentElement,C=A!=null&&A.parentElement===M?A:y;if(l===void 0){let I=document.createElement("div");I.dataset.plugin=Ee,I.dataset.breSearch="1",M.insertBefore(I,C),l=Qe(I,(0,Lr.createElement)(We,{fallbackText:r("modelSearchFailed"),children:o(()=>(0,Lr.createElement)(Pl,{menu:M,t:r}))}),{sync:!0});return}if(l.wrapper.parentElement!==M){M.insertBefore(l.wrapper,C);return}C!==null&&l.wrapper.nextSibling!==C&&M.insertBefore(l.wrapper,C)},T=M=>{if(!i()){Oe(s),s=void 0,d=void 0,M.classList.remove("bre-model-menu-host"),R();for(let D of Array.from(M.children))D.getAttribute("role")==="menuitem"&&(D.style.display="");return}let y=a();if(y===void 0)return;if(s!==void 0&&d!==y&&(Oe(s),s=void 0,d=void 0),s===void 0){d=y;let D=document.createElement("div");D.dataset.plugin=Ee,D.dataset.breSlider="1",M.insertBefore(D,M.firstChild),s=Qe(D,(0,Lr.createElement)(We,{fallbackText:r("renderFailed"),children:o(()=>(0,Lr.createElement)(Hl,{directory:y,configuredInputs:e.configuredInputs,t:r}))}),{sync:!0})}else(s.wrapper.parentElement!==M||M.firstChild!==s.wrapper)&&M.insertBefore(s.wrapper,M.firstChild);M.classList.add("bre-model-menu-host");let A=Array.from(M.children).filter(D=>D.getAttribute("role")==="menuitem"),C=s.wrapper;if(Va(M)){C.style.display="",re(M,C);return}if(R(),Array.from(M.querySelectorAll('[role="menuitemradio"]')).some(D=>!C.contains(D)))s.wrapper.contains(document.activeElement)&&(M.tabIndex=-1,M.focus({preventScroll:!0})),s.wrapper.style.display="none";else{s.wrapper.style.display="";for(let D of A)D.style.display="none"}};return{reconcile:()=>{v();let M=t();if(M===void 0){s!==void 0&&(i()?s.wrapper.remove():(Oe(s),s=void 0,d=void 0)),x(),c=void 0,p=void 0,R();return}let y=Va(M),A=y&&i(),C=!y&&Il(M);C?j(M):x(),T(M),(C!==c||A!==p)&&(c=C,p=A,(C||A||i())&&Nh())},dispose:()=>{m?.(),m=void 0,h=void 0,b(),Oe(s),s=void 0,d=void 0,x(),R(),c=void 0,p=void 0}}}var Oh=350;function jl(e){let t,n,r=0,o=()=>{if(t!==void 0)return Promise.resolve();let s=r;return n??(n=ge(e.api).then(d=>{if(d.namespace===void 0){n=void 0;return}let l=new Map;for(let[c,p]of Object.entries(Be(d.namespace))){let h=Array.isArray(p.models)?p.models:[];for(let m of h){if(typeof m!="object"||m===null||Array.isArray(m))continue;let g=m.id,b=m[Mn];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 p=!1,h=()=>{p||(p=!0,c())},m=setTimeout(h,Oh);l.then(()=>{clearTimeout(m),h()},()=>{clearTimeout(m),h()})})}return t?.get(`${s}/${d}`)},invalidate:()=>{r+=1,t=void 0,n=void 0}}}function Ih(e){let t=e.input;return Array.isArray(t)&&t.length>0?!0:e[xt]===!0||e[st]===!0}function Xa(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,p=[],h=!1;for(let m of c){if(!X(m)){p.push(m);continue}let g=m,b=g.reasoningEfforts!==void 0||g[at]===!0,f=Ih(g);if((b||!o)&&(f||!i)){let j=Ph(g,e,s);j!==void 0?(h=!0,p.push(j)):p.push(g);continue}let v=typeof g.id=="string"?g.id:"";if(v.length===0){p.push(g);continue}let x=tn(e,s),w=typeof g.name=="string"?g.name:void 0,R=kt(v,{...x,displayName:w??x.displayName});if(R.efforts===void 0){p.push(g);continue}let F={...g},re=!1;if(!b&&o&&R.confidence!=="low"&&(re=!0,F.reasoningEfforts=R.efforts,F[Sn]=r,R.compat!==void 0)){let j=X(g.compat)?g.compat:{};F.compat={...j,...R.compat}}if(!f&&i&&(R.imageGen===!0?(re=!0,F[st]=!0):R.input!==void 0&&(re=!0,F.input=[...R.input])),!re){p.push(g);continue}h=!0,p.push(F)}h&&(a[s]={models:p})}return Object.keys(a).length===0?void 0:{providers:a}}function Qa(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)?Na(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 p=Na(c.compat,o);if(p===void 0){d.push(c);continue}l=!0,d.push({...c,compat:p})}l&&(i.models=d)}Object.keys(i).length>0&&(t[n]=i)}return Object.keys(t).length===0?void 0:{providers:t}}function Ph(e,t,n){if(!X(e.reasoningEfforts)||e[at]===!0)return;let r=e.compat,o=X(r)?{...r}:{};if(o.supportsDeveloperRole===void 0&&Oa(tn(t,n)))return{...e,compat:{...o,supportsDeveloperRole:!1}}}function zl(e){let t,n=0,r=()=>{if(t!==void 0)return t;let i=(async()=>{try{let a=await fetch(Id,{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 ge(e.api),l=d.namespace;if(a!==n||l===void 0||d.writable!==!0)return;let c=rn(l);if(c===void 0||Xa(c,()=>!0,{modalities:s.modalityAutofill},l.revision)===void 0)return;let h=d.source==="scope"?await ge(e.api,{fresh:!0}):d,m=h.namespace;if(a!==n||m===void 0||h.writable!==!0)return;let g=rn(m);if(g===void 0)return;let b=Xa(g,()=>!0,{modalities:s.modalityAutofill},m.revision);if(b===void 0)return;let f=b.providers,v=Object.entries(f).map(([w,R])=>({op:"set",path:["providers",w,"models"],value:R.models})),x=await e.api.settings.mutate(_e,v,m.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 $l(e){let t=async n=>{let r=n??await ge(e.api),o=r.namespace;if(o===void 0||r.writable!==!0)return;let i=rn(o);if(i===void 0||Qa(i)===void 0)return;let a=r.source==="scope"?await ge(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=Qa(d);if(l===void 0)return;let c=l.providers,p=[];for(let[m,g]of Object.entries(c))for(let b of["compat","models"])g[b]!==void 0&&p.push({op:"set",path:["providers",m,b],value:g[b]});if(p.length===0)return;let h=await e.api.settings.mutate(_e,p,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 hd=require("react"),vm=require("react-dom"),wm=require("react-dom/client");var xe=require("react");var Gt=hl;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 Vl(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 Za="bre:auto-effort",Yl=Promise.resolve();function Jl(e){Yl=Yl.then(e,e).then(()=>{},()=>{})}function Xl(e,t=document){t.dispatchEvent(new CustomEvent(Za,{detail:{route:e}}))}function Ql(e,t=document){let n=r=>{let o=r.detail;typeof o?.route!="string"||o.route.length===0||e(o.route)};return t.addEventListener(Za,n),()=>{t.removeEventListener(Za,n)}}var W=require("react/jsx-runtime"),Dh=["M3.4 4.2h9.2","M8 4.2v8.2","M5.9 12.4h4.2"],_h=["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"],Fh=["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"],qh=["M8 3.2 13.6 12.8H2.4L8 3.2Z","M8 6.9v2.5","M8 11.3h.01"],Kh=["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"],Bh=["M4.5 6.5 8 10 11.5 6.5"],Wh=["M6.5 4.5 10 8 6.5 11.5"];function qn({paths:e}){return(0,W.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,W.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 es(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:p,staged:h=!1,officialInputTypes:m=!1,api:g,readOnly:b,t:f}){let[v,x]=(0,xe.useState)(()=>an(i)),[w,R]=(0,xe.useState)(()=>Rt(s,d)),[F,re]=(0,xe.useState)(()=>i!==!1),[j,T]=(0,xe.useState)(()=>c??""),[N,z]=(0,xe.useState)(!1),[M,y]=(0,xe.useState)(void 0),[A,C]=(0,xe.useState)(()=>Gt.some(P=>v[P].on&&v[P].wire.trim()!==(P==="off"?"":P))),I=(0,xe.useRef)(void 0),D=(0,xe.useRef)(void 0);D.current===void 0&&(D.current=g.readCapacities?.()??{});let[H,$]=(0,xe.useState)(()=>bt(D.current?.contextWindow)),[Q,oe]=(0,xe.useState)(()=>bt(D.current?.maxTokens)),[ae,se]=(0,xe.useState)(void 0),ue=(0,xe.useRef)(!1),fe=(0,xe.useRef)(i),Z=(0,xe.useRef)(s),he=(0,xe.useRef)(d),Me=(0,xe.useRef)(c),Ce=(0,xe.useRef)(void 0),Le=(0,xe.useRef)(i);Le.current=i;let J=(0,xe.useRef)(a);J.current=a,(0,xe.useEffect)(()=>Ql(P=>{if(P!==e||Le.current!==void 0||J.current)return;let ce=Ce.current;ce!==void 0&&Jl(ce)}),[e]),(0,xe.useEffect)(()=>{Cr(fe.current,i)||(fe.current=i,ue.current||(x(an(i)),re(i!==!1))),(Z.current!==s||he.current!==d)&&(Z.current=s,he.current=d,ue.current||R(Rt(s,d))),Me.current!==c&&(Me.current=c,ue.current||T(c??""))},[i,s,d,c]);let B=Gt.filter(P=>v[P].on),V=j===(c??"")?void 0:j===""?null:j,te=F?Fn(v):!1,pe=!Cr(te,i)||!Io(w,s,d)||V!==void 0,ke=(0,xe.useRef)(void 0),me=()=>{ue.current=!0},Se=(P,ce,He,qe=F)=>{let L=es(qe,Fn(P),i),ve=!Io(ce,s,d)?Po(ce):void 0,$e=He===(c??"")?void 0:He===""?null:He,Ve=Do({efforts:L,input:ve?.input,imageGen:ve?.imageGen,defaultEffort:$e,appliedCompat:I.current,routeApi:t,initialCompat:l}),mt=JSON.stringify(Ve);ke.current!==mt&&(ke.current=mt,g.commit(e,r,Ve))},u=(P,ce)=>{me();let He=!ce&&j===P?"":j;He!==j&&T(He);let qe={...v,[P]:{...v[P],on:ce}};ce&&P!=="off"&&qe[P].wire.trim().length===0&&(qe[P]={...qe[P],wire:P}),x(qe),Se(qe,w,He),y(void 0)},S=P=>{me(),re(P);let ce=P?j:"";ce!==j&&T(ce),Se(v,w,ce,P),y(void 0)},q=(P,ce)=>{me();let He={...v,[P]:{...v[P],wire:ce}};x(He),Se(He,w,j),y(void 0)},K=P=>{me();let ce={declared:!0,image:P,imageGen:!1};R(ce),Se(v,ce,j),y(void 0)},k=()=>{me();let P={declared:!1,image:!1,imageGen:!1};R(P),Se(v,P,j),y(void 0)},_=P=>{me();let ce=P?{declared:!1,image:!1,imageGen:!0}:{declared:!1,image:!1,imageGen:!1};R(ce),Se(v,ce,j),y(void 0)},ee=P=>{me(),T(P),Se(v,w,P),y(void 0)},le=(P,ce)=>{let He=ce.slice(0,20),qe=P==="context"?He:H,L=P==="output"?He:Q;se(P),P==="context"?$(He):oe(He),g.setCapacities?.({contextWindow:Et(qe),maxTokens:Et(L)})},be=P=>{P==="context"?$(ce=>bt(Et(ce))):oe(ce=>bt(Et(ce))),se(void 0)},ye=P=>{me();let ce=P.efforts!==!1;re(ce);let He=an(P.efforts);x(He);let qe=P.imageGen===!0?Rt(void 0,!0):P.input===void 0?w:Rt(P.input);qe!==w&&R(qe);let L=j===""&&P.defaultEffort!==void 0?P.defaultEffort:j;if(L!==j&&T(L),I.current=P.compat,P.contextWindow!==void 0||P.maxTokens!==void 0){g.fillCapacities?.(P.contextWindow,P.maxTokens);let U=g.readCapacities?.();$(bt(U?.contextWindow)),oe(bt(U?.maxTokens))}y(void 0),Se(He,qe,L,ce)},De=async()=>{if(!(b||N)){z(!0),y(void 0);try{let P=h?await g.suggest(e,r,o,{...t===void 0?{}:{api:t},...n===void 0?{}:{baseURL:n}}):await g.suggest(e,r,o);if(!P.ok){y({kind:"error",text:P.error==="no-suggestion"?f("noSuggestion"):P.error});return}ye(P.suggestion)}catch(P){y({kind:"error",text:f("writeError",{message:String(P)})})}finally{z(!1)}}};(0,xe.useEffect)(()=>{Ce.current=De});let ze=()=>{ue.current=!1,g.withdraw(e,r),x(an(i)),re(i!==!1),R(Rt(s,d)),T(c??""),I.current=void 0;let P=D.current??{};$(bt(P.contextWindow)),oe(bt(P.maxTokens)),se(void 0),g.setCapacities?.({contextWindow:P.contextWindow,maxTokens:P.maxTokens}),y(void 0),ke.current=void 0},pt=(0,xe.useMemo)(()=>kt(r,{...t===void 0?{}:{api:t},...n===void 0?{}:{baseURL:n}}).compat?.thinkingFormat,[r,t,n]),Qt=I.current?.thinkingFormat??pt,En=Vl(i,Qt),Re=b||N,co=F?B.length===0?f("stateUndeclared"):f("stateDeclared",{count:B.length,default:f(j===""?"defaultEffortUnset":"level_"+j)}):f("thinkingModeOff"),ta=j!==""&&!B.includes(j)?[...B,j]:B,Tn=Et(H),Zt=Et(Q),gr=Tn!==void 0&&Zt!==void 0&&Zt>Tn,uo=(0,W.jsxs)(W.Fragment,{children:[gr?(0,W.jsxs)("p",{className:"bre-effort-note bre-warn",children:[(0,W.jsx)(qn,{paths:qh}),f("capacityRule")]}):null,(0,W.jsxs)("div",{className:"bre-effort-cols",children:[(0,W.jsxs)("div",{className:"bre-effort-sec",children:[(0,W.jsx)("span",{className:"bre-effort-label",children:f("contextWindowLabel")}),(0,W.jsxs)("span",{className:"bre-cap-box",children:[(0,W.jsx)("input",{type:"text",inputMode:"text",className:"bre-cap-input",value:ae==="context"?H:bt(Tn),disabled:Re,placeholder:f("capacityBlank"),"aria-label":f("contextWindowLabel")+" "+String(p+1),onFocus:()=>{se("context")},onBlur:()=>{be("context")},onChange:P=>{le("context",P.target.value)}}),(0,W.jsx)("span",{className:"bre-cap-unit",children:f("tokensUnit")})]}),(0,W.jsx)("p",{className:"bre-effort-note",children:f("capacityInherit")})]}),(0,W.jsxs)("div",{className:"bre-effort-sec",children:[(0,W.jsx)("span",{className:"bre-effort-label",children:f("maxTokensLabel")}),(0,W.jsxs)("span",{className:"bre-cap-box",children:[(0,W.jsx)("input",{type:"text",inputMode:"text",className:"bre-cap-input",value:ae==="output"?Q:bt(Zt),disabled:Re,placeholder:f("capacityBlank"),"aria-label":f("maxTokensLabel")+" "+String(p+1),onFocus:()=>{se("output")},onBlur:()=>{be("output")},onChange:P=>{le("output",P.target.value)}}),(0,W.jsx)("span",{className:"bre-cap-unit",children:f("tokensUnit")})]}),(0,W.jsx)("p",{className:"bre-effort-note",children:f("capacityUnitsHint")})]})]})]});return(0,W.jsxs)("div",{className:"bre-effort-editor","data-plugin":Ee,children:[(0,W.jsxs)("div",{className:"bre-effort-modality",children:[(0,W.jsx)("span",{className:"bre-effort-label",children:f("inputModality")}),(0,W.jsxs)("div",{className:"bre-pillrow",role:"group","aria-label":f("inputModality"),children:[(0,W.jsxs)("button",{type:"button",className:w.declared?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:Re,"aria-pressed":w.declared,"aria-label":f("modalityText")+" "+String(p+1),title:f("modalityText"),onClick:()=>{w.declared?k():K(!1)},children:[(0,W.jsx)(qn,{paths:Dh}),f("modalityText")]}),(0,W.jsxs)("button",{type:"button",className:w.declared&&w.image?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:Re,"aria-pressed":w.declared&&w.image,"aria-label":f("modalityImage")+" "+String(p+1),title:f("modalityImage"),onClick:()=>{K(!(w.declared&&w.image))},children:[(0,W.jsx)(qn,{paths:_h}),f("modalityImage")]}),(0,W.jsxs)("button",{type:"button",className:w.imageGen?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:Re,"aria-pressed":w.imageGen,"aria-label":f("modalityImageGen")+" "+String(p+1),title:f("modalityImageGen"),onClick:()=>{_(!w.imageGen)},children:[(0,W.jsx)(qn,{paths:Fh}),f("modalityImageGen")]})]}),(0,W.jsx)("p",{className:"bre-effort-note",children:w.imageGen?f("modalityImageGenHint"):w.declared?f("modalityDeclared"):f("modalityInherit")})]}),(0,W.jsxs)("div",{className:"bre-effort-top",children:[(0,W.jsxs)("label",{className:"bre-thinking-switch",children:[(0,W.jsx)("input",{type:"checkbox",checked:F,disabled:Re,"aria-label":f("thinkingMode")+" "+String(p+1),onChange:P=>{S(P.target.checked)}}),(0,W.jsx)("span",{className:"bre-effort-switch-track","aria-hidden":"true"}),(0,W.jsx)("span",{className:"bre-effort-title",children:f("thinkingMode")})]}),(0,W.jsx)("span",{className:"bre-effort-state",children:co})]}),F?(0,W.jsxs)(W.Fragment,{children:[i===!1?(0,W.jsx)("p",{className:"bre-effort-note bre-effort-note--top",children:f("reasoningDisabled")}):null,En===void 0?null:(0,W.jsx)("p",{className:"bre-effort-note bre-effort-note--top",children:f(En==="thinking-disabled"?"defaultRiskDisabled":"defaultRiskQwen")})]}):null,F?(0,W.jsxs)("div",{className:"bre-effort-card",children:[(0,W.jsxs)("div",{className:"bre-effort-sec",children:[(0,W.jsxs)("div",{className:"bre-effort-labelrow",children:[(0,W.jsx)("span",{className:"bre-effort-label",children:f("levelsLabel")}),(0,W.jsx)("span",{className:"bre-effort-grow"}),(0,W.jsxs)("button",{type:"button",className:"bre-effort-adapt",disabled:Re,onClick:()=>{De()},children:[(0,W.jsx)(qn,{paths:Kh}),f("autoAdapt")]})]}),(0,W.jsx)("div",{className:"bre-pillrow",role:"group","aria-label":f("levelsLabel"),children:Gt.map(P=>{let ce=v[P];return(0,W.jsx)("button",{type:"button",className:ce.on?"bre-lvl is-on":"bre-lvl",disabled:Re,"aria-pressed":ce.on,"aria-label":f("level_"+P)+" "+String(p+1),title:f("level_"+P),onClick:()=>{u(P,!ce.on)},children:f("level_"+P)},P)})}),(0,W.jsx)("p",{className:"bre-effort-hint",children:f("levelsHint")}),B.length===0?null:(0,W.jsxs)("button",{type:"button",className:"bre-effort-wiretoggle",disabled:Re,"aria-expanded":A,onClick:()=>{C(!A)},children:[(0,W.jsx)(qn,{paths:A?Bh:Wh}),f(A?"wireHide":"wireShow")]}),B.length===0||!A?null:(0,W.jsxs)("div",{className:"bre-wire",children:[(0,W.jsx)("div",{className:"bre-wire-grid",children:B.map(P=>(0,W.jsxs)(xe.Fragment,{children:[(0,W.jsx)("span",{className:"bre-wire-name",children:f("level_"+P)}),(0,W.jsx)("input",{type:"text",className:"bre-effort-wire",value:v[P].wire,disabled:Re,placeholder:f("wirePlaceholder"),"aria-label":f("level_"+P)+" "+f("wireValue"),onChange:ce=>{q(P,ce.target.value)}})]},P))}),(0,W.jsx)("p",{className:"bre-effort-note",children:f("wireHint")})]})]}),B.length===0?null:(0,W.jsx)("div",{className:"bre-effort-cols",children:(0,W.jsxs)("div",{className:"bre-effort-sec",children:[(0,W.jsx)("span",{className:"bre-effort-label",children:f("defaultEffortLabel")}),(0,W.jsxs)("select",{className:"bre-effort-select",value:j,disabled:Re,"aria-label":f("defaultEffortLabel"),onChange:P=>{ee(P.target.value)},children:[(0,W.jsx)("option",{value:"",children:f("followMemory")}),ta.map(P=>(0,W.jsx)("option",{value:P,children:f("level_"+P)},P))]}),(0,W.jsx)("p",{className:"bre-effort-note",children:f("defaultEffortHint")})]})}),h?(0,W.jsx)("p",{className:"bre-effort-note",children:f("stagedHint")}):null,Fn(v)===void 0&&i!==void 0?(0,W.jsx)("p",{className:"bre-effort-note",children:f("bareHint")}):null,(0,W.jsx)("span",{className:"bre-effort-sep"}),uo,M===void 0?null:(0,W.jsx)("p",{className:"bre-effort-message bre-"+M.kind,role:M.kind==="error"?"alert":"status",children:M.text}),(0,W.jsx)("div",{className:"bre-effort-actions",children:(0,W.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:Re||!pe,onClick:ze,children:f("reset")})})]}):(0,W.jsxs)("div",{className:"bre-effort-card bre-effort-card--capacity",children:[uo,M===void 0?null:(0,W.jsx)("p",{className:"bre-effort-message bre-"+M.kind,role:M.kind==="error"?"alert":"status",children:M.text})]})]})}function we(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function vt(e,t){e!==void 0&&e.hidden!==t&&(e.hidden=t)}function Ge(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",ts='[class*="modelCatalog"]',Gh='[class*="modelListHead"]',Uh='button[class*="linkButton"]',jh="bre-auto-effort",zh="bre-auto-effort-note",$h="data-bre-auto-effort-phase",ec="bre-auto-effort-note-text",tc="bre-auto-effort-note-detail",Vh=3e3;function Yh(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 ns(e){return Array.from(e.querySelectorAll(ts)).filter(t=>(t.parentElement?.closest(ts)??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(Gh)??s,c=l.querySelector(`[${Ut}]`)??Xh();rc.set(c,n);let p=Jh(l);p!==null?p.nextElementSibling!==c&&p.after(c):l.lastElementChild!==c&&l.append(c),tb(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(ts),l=s.getAttribute(Ut)??"";if(d===null||!r.has(d)||i.has(d)){s.remove(),l.length>0&&!a.has(l)&&rs(l);continue}i.add(d)}}function rs(e){let t=sn.get(e);t!==void 0&&(t.timer!==null&&clearTimeout(t.timer),t.note.remove(),sn.delete(e))}function nc(){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 Jh(e){let t=Array.from(e.querySelectorAll(Uh));return t.length===0?null:t[t.length-1]}function Xh(){let e=document.createElement("button");return e.className=jh,e.setAttribute("type","button"),e.setAttribute(Ut,""),e.addEventListener("click",()=>{let t=e.getAttribute(Ut)??"";if(t.length===0)return;let n=rc.get(e);n!==void 0&&(Xl(t),Qh(t,n))}),e}async function Qh(e,t){if(t.onRequest===void 0)return;Zl(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){rs(e);return}let r=Yh(n);r!==null&&Zl(e,r,t,Vh)}function Zl(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??Zh();i.setAttribute($h,t.phase);let a=i.querySelector(`.${ec}`),s=i.querySelector(`.${tc}`),d=eb(t,n);a.textContent!==d.text&&(a.textContent=d.text),s.textContent!==d.detail&&(s.textContent=d.detail),vt(s,d.detail.length===0),o===void 0&&document.body.append(i);let l=r>0?setTimeout(()=>{rs(e)},r):null;i.style.setProperty("--bre-note-hold",`${r}ms`),sn.set(e,{note:i,timer:l})}function Zh(){let e=document.createElement("div");return e.className=zh,e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.innerHTML=`<span class="${ec}"></span><span class="${tc}"></span>`,e}var rc=new WeakMap,sn=new Map;function eb(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 tb(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",os="data-bre-row-head",is="data-bre-drop-side",qo="bre-row-dragging",Ko="bre-row-drop-target",lc="bre-drag-ghost",cc="bre-drop-line",oc="http://www.w3.org/2000/svg",ic=8,ac=28,sc=12,nb="transform 180ms cubic-bezier(0.2, 0.7, 0.3, 1)",rb='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 Je(e){return Array.from(e.children).filter(t=>t instanceof HTMLElement)}function ob(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 Je(e).map((t,n)=>({row:t,key:ob(t,n),index:n})).sort((t,n)=>t.key-n.key||t.index-n.index).map(t=>t.row)}function uc(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){uc(dn(e),t)}function as(e,t){let n=Je(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=nb,o.style.transform="")})}function Nr(e,t){return dn(e).map(n=>t(n)).filter(n=>n!==void 0)}function ib(e,t,n){let r=Nr(e,t);if(n===void 0||!ab(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 ab(e,t){return t.rows.some(n=>!e.contains(n))}function sb(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 Je(e))t(o)!==void 0&&r.push(o);return{ids:n,rows:r}}function fc(e,t,n){let r=new Map;for(let[s,d]of t.entries())r.has(d)||r.set(d,s);let o=Je(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});uc(o,a)}function Or(e){for(let t of e)t.style.order="",t.style.transition="",t.style.transform=""}function pc(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 mc(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 db(e,t){let n=e.getBoundingClientRect();return n.height<=0?!0:t>n.top+n.height/2}function gc(e,t){let n=e.getBoundingClientRect();return t?n.bottom+ic/2-1:n.top-ic/2-1}function hc(){let e=document.createElementNS(oc,"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(oc,"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 bc(e,t){let n=document.createElement("div");n.className=lc,n.setAttribute("aria-hidden","true"),n.appendChild(hc());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 lb(e){return!(e instanceof Element)||e.closest(`[${Hr}]`)!==null?!1:e.closest(rb)!==null}function yc(e){return e.parentElement??void 0}function vc(e){for(let t of Je(e))t.classList.remove(Ko),t.removeAttribute(is)}function Go(e){let t=e.parentElement;for(;t!==null;){if(kc(t))return t;t=t.parentElement}let n=document.scrollingElement;return n instanceof HTMLElement&&n.scrollHeight>n.clientHeight?n:void 0}function wc(e){let t=[],n=e.parentElement;for(;n!==null;)kc(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 ss(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&&!t.includes(r)&&t.push(r),t}function xc(e){let t=e.style.overflowY,n=t.length>0?t:window.getComputedStyle(e).overflowY;return n==="auto"||n==="scroll"||n==="overlay"}function kc(e){return e.scrollHeight>e.clientHeight&&xc(e)}function Ec(e,t){let n=e.getBoundingClientRect();return n.height<=0?0:t<n.top+ac?-sc:t>n.bottom-ac?sc:0}function Tc(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 cb(e){let t=e.line;if(t!==void 0&&t.isConnected)return t;let n=document.createElement("div");return n.className=cc,n.setAttribute("aria-hidden","true"),document.body.appendChild(n),e.line=n,n}function ub(e,t,n){let r=cb(e),o=t.getBoundingClientRect();r.style.top=`${gc(t,n)}px`,r.style.left=`${o.left}px`,r.style.width=`${o.width}px`,r.style.display="block",r.setAttribute(is,n?"after":"before")}function fb(e){e.line!==void 0&&(e.line.style.display="none")}function pb(e){let t=e.drag;e.drag=void 0,t!==void 0&&(Tc(e,t,0),fb(e),t.row.classList.remove(qo),vc(t.list),t.dropped||as(t.list,()=>{Wo(t.list,t.before)}))}function mb(e,t,n,r){if(lb(t.target)){t.preventDefault();return}let o=yc(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=bc(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 gb(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:mc(a,t.clientY);if(s===void 0)return;t.preventDefault();let d=t.dataTransfer;d!=null&&(d.dropEffect="move");let l=db(s,t.clientY),c=pc(a,r.row,s,l);c!==a.indexOf(r.row)&&as(e,()=>{Wo(e,fa(a,r.row,c))}),vc(e),s.classList.add(Ko),s.setAttribute(is,l?"after":"before"),ub(n,s,l),Tc(n,r,r.scroller===void 0?0:Ec(r.scroller,t.clientY))}function hb(e,t){t.lists.has(e)||(t.lists.add(e),e.addEventListener("dragover",n=>{gb(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 bb(e,t,n,r){r.sources.has(e)||(r.sources.add(e),n.seatDrags&&(e.setAttribute(os,"1"),e.setAttribute("draggable","true")),e.addEventListener("dragstart",o=>{mb(t,o,n,r)}),e.addEventListener("dragend",()=>{pb(r)}))}function yb(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=yc(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(),as(i,()=>{Wo(i,fa(a,t,d))}),n.commit(i),e.focus())})}function dc(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 vb(e,t,n,r,o){let i=t.querySelector(`[${Hr}]`);if(i!==null){dc(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(hc()),dc(a,e,n,r),yb(a,e,r,o),bb(r.seatDrags?t:a,e,r,o),t.insertBefore(a,t.firstChild)}function Uo(e,t,n,r){if(!e.isConnected)return;hb(t,r);for(let i of Je(t)){let a=n.idOf(i);if(a===void 0)continue;let s=n.seatOf(i);s!==void 0&&vb(i,s,a,n,r)}if(r.drag!==void 0)return;let o=ib(t,n.idOf,r.sighted.get(t));fc(t,n.order(o),n.idOf),r.sighted.set(t,sb(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(`[${os}]`)))t.removeAttribute(os),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(`.${cc}`)))t.remove();for(let t of Array.from(document.querySelectorAll(`.${lc}`)))t.remove();e.line=void 0}var Sc=["openai","anthropic"];function zo(e){return e==="anthropic-messages"?"anthropic":"openai"}function Mc(e){return e==="openai-completions"||e==="anthropic-messages"||e==="openai-responses"}var wb=40;function Ac(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,wb)}function Ht(e){return typeof e=="string"&&/^[\x21-\x7E]+$/.test(e)}var xb=12;function Lc(e){return e.length===0?"":e.length<xb?"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022":`${e.slice(0,4)}...${e.slice(-4)}`}var Cc="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(Cc);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))kb(i)&&(r[o]=i);return r}catch{return{}}}function kb(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 Hc(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(Cc,JSON.stringify(Object.fromEntries(n)))}catch{}}function Nc(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){Eb(e);return}return t.state}function ds(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}},Hc(n)}function Eb(e){let t=$o();t[e]!==void 0&&(delete t[e],Hc(t))}function Oc(){return Object.entries($o()).map(([e,t])=>({route:e,savedAt:t.savedAt})).sort((e,t)=>t.savedAt-e.savedAt)}function Ic(e){for(let t of["error","message"]){let n=e[t];if(typeof n=="string"&&n.length>0)return n}}function Pc(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 Tb(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=Pc(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},...Mc(a)?{protocol:a}:{},...s===!0?{auto:!0}:{},...l!==void 0&&l>=0&&c!==void 0?{rest:{remainingMs:l,failures:c}}:{}}}function Sb(e){let t=e.entries;if(!Array.isArray(t))return;let n=[];for(let l of t){let c=Tb(l);c!==void 0&&n.push(c)}let r=e.addedRef,o=e.route,i=Pc(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 Mb(e){let t;try{t=await e.json()}catch{t=void 0}if(!X(t))return{ok:!1};if(t.ok===!0){let r=Sb(t);if(r!==void 0)return r}let n=Ic(t);return n===void 0?{ok:!1}:{ok:!1,error:n}}async function Dc(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 Mb(r)}catch{return{ok:!1}}}var Ir=new Map,Ab=64,Lb=5e3;function ls(e){let t=Ir.get(e);if(t!==void 0)return t;if(Ir.size>=Ab){let r=Ir.keys().next().value;r!==void 0&&Ir.delete(r)}let n={state:Nc(e),updatedAt:0,revision:0};return Ir.set(e,n),n}function Cb(e){return ls(e).state}function Rb(e,t){let n=ls(e),r=Date.now()-n.updatedAt;if(t?.preferCache===!0&&n.state!==void 0&&r>=0&&r<Lb)return Promise.resolve(n.state);if(n.read!==void 0)return n.read;let o=n.revision,i=Dc(e).then(a=>n.revision!==o?n.state??a:(a.ok&&(n.state=a,n.updatedAt=Date.now(),ds(e,a)),a)).finally(()=>{n.read===i&&(n.read=void 0)});return n.read=i,i}async function Tt(e,t){let n=ls(e),r=++n.revision;n.read=void 0;let o=await Dc(e,t);return o.ok&&n.revision===r&&(n.revision+=1,n.read=void 0,n.state=o,n.updatedAt=Date.now(),ds(e,o)),o}async function Hb(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 Nb(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)?Ic(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 Ue={list:Rb,endpoints:Hb,balanceEndpoint:Nb,cached:Cb,add:(e,t,n)=>Tt(e,{op:"add",value:t,...n===void 0?{}:{alias:n}}),rename:(e,t,n)=>Tt(e,{op:"rename",ref:t,...n===void 0?{}:{alias:n}}),remove:(e,t)=>Tt(e,{op:"remove",ref:t}),replace:(e,t,n)=>Tt(e,{op:"value",ref:t,value:n}),setScope:(e,t,n)=>Tt(e,{op:"scope",ref:t,...n===void 0?{}:{models:n}}),setEnabled:(e,t,n)=>Tt(e,{op:"enable",ref:t,enabled:n}),setProtocol:(e,t,n)=>Tt(e,{op:"protocol",ref:t,...n===void 0?{}:{protocol:n}}),setEndpoints:(e,t,n)=>Tt(e,{op:"endpoints",openai:t??"",anthropic:n??""}),setBalanceEndpoint:(e,t)=>Tt(e,{op:"balance",endpoint:t}),probe:e=>Tt(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",Nt="data-bre-endpoint-row",jn="data-bre-balance-row",Yo="data-bre-endpoint-family",_c="data-bre-endpoint-filled",Jo="data-bre-endpoint-field",Xo="data-bre-endpoint-title",Wn="data-bre-endpoint-toggle",Wc="data-bre-endpoint-count",Qo="data-bre-field-order",Pr="data-bre-endpoint-serving",Fc="data-bre-protocol-watch",qc=new WeakSet,Kc="data-bre-row-provider",us="data-bre-protocol-cards",Gn="data-bre-protocol-value",fs="data-bre-protocol-source";function lt(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=lt(e,t);if(n===void 0)return;let r=n.closest("label");return r!==null&&r.parentElement!==null?r:n.parentElement??void 0}function cs(e,t){let n=e;for(;n!==null&&n.parentElement!==t;)n=n.parentElement;return n===null||n===t?void 0:n}function Ob(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=cs(t,r),i=cs(n,r);if(o===void 0||i===void 0||o===i)continue;let a=e===void 0?void 0:cs(e,r);return{container:r,protocol:o,url:i,name:a}}}function Gc(e,t){let n=lt(e,t);return n instanceof HTMLSelectElement||n instanceof HTMLInputElement?n.value.trim():""}function Ib(e,t){let n=Gc(e,t.apiProtocol);return n==="anthropic-messages"||n==="openai-completions"||n==="openai-responses"?n:void 0}function St(e,t){let n=Ib(e,t);return n===void 0?void 0:zo(n)}function cn(e,t){let n=Gc(e,t.routeId);return n.length>0?n:(e.closest(`[${Kc}]`)?.getAttribute(Kc)??"").trim()}function Uc(e,t){return e==="anthropic"?t("keysEndpointAnthropic"):e==="openai"?t("keysEndpointOpenAI"):""}function Pb(e,t){let n=lt(e,t.modelName),r=lt(e,t.apiProtocol),o=lt(e,t.baseUrl);if(r===void 0||o===void 0)return;let i=Ob(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 jc(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(_c)!==n&&e.setAttribute(_c,n)}function Db(e,t,n){let r=jc(e,t);if(!n){e.removeAttribute(Jo),r?.removeAttribute(Xo);return}e.setAttribute(Jo,"1"),r?.setAttribute(Xo,"1")}function zc(e,t,n){let r=lt(e,t.baseUrl);if(r===void 0)return;let o=Un(e,t.baseUrl);if(o===void 0)return;let i=Uc(St(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),vt(a,i.length===0),ln(a,r instanceof HTMLInputElement&&r.value.trim().length>0)),Db(o,r,a!==null&&i.length>0);let s=St(e,t);s===void 0?o.removeAttribute(Pr):o.setAttribute(Pr,s)}function _b(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 $c(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 Fb(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??"")===Vc(i.value,(i.textContent??i.value).trim(),n.t)})}function Vc(e,t,n){return e==="openai-completions"?n("keysProtocolShortChat"):e==="openai-responses"?n("keysProtocolShortResponses"):e==="anthropic-messages"?n("keysProtocolShortAnthropic"):t}function Bc(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=Vc(o,(r.textContent??o).trim(),n.t),i.title=(r.textContent??o).trim(),i.addEventListener("click",()=>{e.value!==o&&(_b(e,o),$c(e,t))}),t.appendChild(i)}}function qb(e,t,n){let r=lt(e,t.apiProtocol);if(!(r instanceof HTMLSelectElement))return;let o=Un(e,t.apiProtocol);if(o===void 0)return;let i=o.querySelector(`[${us}]`);if(i===null){let a=document.createElement("div");i=a,a.setAttribute(us,"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(fs,"1"),r.after(a),Bc(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 m=d.key==="Home"?c[0]:c[c.length-1];m?.click(),m?.focus();return}if(l===0)return;d.preventDefault();let p=c.findIndex(m=>m.classList.contains("is-selected")),h=c[(Math.max(p,0)+l+c.length)%c.length];h?.click(),h?.focus()})}else Fb(r,i,n)||Bc(r,i,n);vt(r,!0),$c(r,i)}function ps(e,t,n){let r=e===null?0:e.querySelectorAll(`[${Nt}], [${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 Kb(e,t,n){let r=e.querySelector(`[${Wn}]`);if(Un(e,t.apiProtocol)===void 0){r?.remove(),e.querySelector(`[${Wc}]`)?.remove();return}let o=Un(e,t.baseUrl);if(o===void 0)return;let i=lt(e,t.baseUrl);if(i===void 0)return;let a=jc(o,i);if(a===void 0||a===r)return;let s=()=>e.querySelector(`[${Kn}]`),d=c=>{let p=n.t("keysMoreEndpoints");c.textContent!==p&&(c.textContent=p);let h=s();c.setAttribute("aria-expanded",h!==null&&!h.hidden?"true":"false"),ps(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 p=cn(e,t);p.length>0&&Gb(c,p,n,e,t)}}),a.append(l),d(l)}var Bn=new WeakMap,Yc=1e3,Zo=new WeakMap,zn=0,Vo=new Map;function Bb(e,t){zn+=1,typeof CustomEvent=="function"&&document.dispatchEvent(new CustomEvent(kr,{detail:{route:e,openai:t.openai??"",anthropic:t.anthropic??""}}))}function Wb(e,t){zn+=1,typeof CustomEvent=="function"&&document.dispatchEvent(new CustomEvent(Tr,{detail:{route:e,endpoint:t}}))}function Dr(e){let t=e.getAttribute(Nt);return t==="openai"||t==="anthropic"?t:void 0}async function Gb(e,t,n,r,o){for(let i of Array.from(e.querySelectorAll(`[${Nt}], [${jn}]`)))await Jc(i,t,n,r,o)}async function Jc(e,t,n,r,o){let i=e.querySelector(".bre-endpoint-url");if(i===null)return;if(e.hasAttribute(jn)){await Xc(e,i,t,n);return}let a=Dr(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??Ue,l=await ei(t,d);if(l===void 0||Bn.get(e)!==s||Dr(e)!==a||document.activeElement===i)return;await Qc(r,o,n,t,St(r,o),l);let c=l[a];i.value!==c&&(i.value=c);let p=e.querySelector(".bre-endpoint-family");p!==null&&ln(p,c.length>0)}async function Xc(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??Ue;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 Qc(e,t,n,r,o,i,a=!1){if(o===void 0||!a&&i[o].length>0)return;let s=lt(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??Ue;await gs(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 ms(e,t,n){let r=Un(e,t.baseUrl);if(r===void 0||r.parentElement===null)return;let o=St(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=Sc.filter(p=>p!==o),s=Array.from(i.children).filter(p=>p instanceof HTMLElement&&p.hasAttribute(Nt));if(!(a.length===s.length&&a.every((p,h)=>Dr(s[h])===p)))for(let p of a){let h=i.querySelector(`[${Nt}="${p}"]`);h===null&&(h=Ub(e,t,n,p)),i.appendChild(h)}for(let p of Array.from(i.querySelectorAll(`[${Nt}]`))){let h=Dr(p);h!==void 0&&h!==o||p.remove()}let l=e.querySelector(`[${Wn}]`);l!==null&&(l.setAttribute("aria-expanded",i.hidden?"false":"true"),ps(i,l,n));let c=cn(e,t);if(c.length>0)for(let p of Array.from(i.querySelectorAll(`[${Nt}]`))){let h=Zo.get(p);(h===void 0||h.epoch!==zn||Date.now()-h.at>=Yc)&&Jc(p,c,n,e,t)}}function Ub(e,t,n,r){let o=document.createElement("div");o.setAttribute(Nt,r),o.className="bre-endpoint-row";let i=document.createElement("span");i.className="bre-endpoint-family",i.textContent=Uc(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??Ue;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 gs(d,s,c=>{let p=Dr(o);if(p!==void 0)return{openai:p==="openai"?l:c.openai,anthropic:p==="anthropic"?l:c.anthropic}}))()}),o.append(i,a),o}function Zc(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=jb(e,t,n)),r.lastElementChild!==a&&r.appendChild(a);let s=e.querySelector(`[${Wn}]`);s!==null&&ps(r,s,n);let d=Zo.get(a);if(d===void 0||d.epoch!==zn||Date.now()-d.at>=Yc){let l=a.querySelector(".bre-endpoint-url");l!==null&&Xc(a,l,i,n)}}function jb(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??Ue,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&&Wb(d,l))()}),r.append(o,i),r}async function zb(e,t,n,r,o){let i=cn(e,t),a=lt(e,t.baseUrl);if(i.length===0||!(a instanceof HTMLInputElement))return;let s=n.client??Ue,d=await ei(i,s);if(d===void 0||St(e,t)!==o)return;let l=a.value.trim();if(l.length>0&&l!==d[r]){let h=await gs(i,s,m=>{if(St(e,t)===o)return{openai:r==="openai"?l:m.openai,anthropic:r==="anthropic"?l:m.anthropic}});if(h===void 0||(d=h,St(e,t)!==o))return}let c=d[o];if(a.value===c)return;let p=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set;p===void 0?a.value=c:p.call(a,c),a.dispatchEvent(new Event("input",{bubbles:!0})),a.dispatchEvent(new Event("change",{bubbles:!0})),ms(e,t,n)}async function gs(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 Bb(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 $b(e,t,n){let r=Un(e,t.baseUrl),o=St(e,t),i=r?.getAttribute(Pr);zc(e,t,n.t),ms(e,t,n),Zc(e,t,n),!(r===void 0||i===void 0||o===void 0)&&i!==o&&(i!=="openai"&&i!=="anthropic"||zb(e,t,n,i,o))}function eu(e,t,n){Pb(e,t),qb(e,t,n),zc(e,t,n.t),Kb(e,t,n),ms(e,t,n),Zc(e,t,n);let r=lt(e,t.apiProtocol);r instanceof HTMLSelectElement&&!r.hasAttribute(Fc)&&(r.setAttribute(Fc,"1"),r.addEventListener("change",()=>$b(e,t,n)));let o=lt(e,t.baseUrl);o instanceof HTMLInputElement&&!qc.has(o)&&(qc.add(o),o.addEventListener("change",()=>{let i=cn(e,t),a=St(e,t);if(i.length===0||a===void 0)return;let s=n.client??Ue;(async()=>{let d=await ei(i,s);d!==void 0&&St(e,t)===a&&await Qc(e,t,n,i,a,d,!0)})()}))}function Vb(){for(let e of Array.from(document.querySelectorAll(`select[${fs}]`)))e.hidden=!1,e.removeAttribute(fs)}function tu(){Vb();for(let e of Array.from(document.querySelectorAll(`[${Kn}], [${Nt}], [${jn}], [${Wn}], [${Wc}], [${us}], [${Yo}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`[${Qo}], [${Jo}], [${Xo}], [${Pr}]`)))e.removeAttribute(Qo),e.removeAttribute(Jo),e.removeAttribute(Xo),e.removeAttribute(Pr)}function $n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var hs="__breLedgerDocument";function cu(){let e=globalThis;return e[hs]??(e[hs]=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`)}var ri="bre:held-writes:v1";function ks(){try{return typeof sessionStorage>"u"?void 0:sessionStorage}catch{return}}function Mt(e){let t=ks();if(t!==void 0)try{if(e.pending.size===0&&e.queued.size===0){t.removeItem(ri);return}let n={document:cu(),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 nu(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 Yb(e){let t=ks();if(t!==void 0)try{let n=t.getItem(ri);if(n===null)return;let r=JSON.parse(n);if(r.document!==cu())return;let o=nu(r.pending),i=nu(r.queued,oy);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 uu(e,t){(async()=>{try{await Es(t,e),await Ts(t,e)}catch(n){console.error(`[bre] teardown flush failed: ${n instanceof Error?n.message:String(n)}`)}})()}function fu(e,t){(async()=>{try{await Es(t,e,!0),await Ts(t,e,!0)}catch(n){console.error(`[bre] unload flush failed: ${n instanceof Error?n.message:String(n)}`)}finally{try{ks()?.removeItem(ri)}catch{}}})()}function pu(){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 Yb(e),e}async function Jb(e,t,n=!1){if(t.flushing)return;t.flushing=!0;let r;try{r=n&&gu(t)?await ge(e.api,{fresh:!0}):void 0;let o=await Es(e,t,!1,r),i=await Ts(e,t,!1,r);o||i?ru(e,t):(t.flushFailures=0,t.nextFlushAt=0)}catch(o){ru(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 mu=new Set(["no-namespace","invalid-models"]);function ru(e,t){t.flushFailures+=1;let n=Math.min(2**(t.flushFailures-1)*500,3e4);t.nextFlushAt=Date.now()+n,e.onBackoff?.(n)}function gu(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{Mt(e)}}function hu(e,t,n,r){e.queued.set(t,(e.queued.get(t)??new Map).set(n,r)),Mt(e)}function Xb(e,t,n){let r=e.pending.get(t);r!==void 0&&(r.delete(n),r.size===0&&e.pending.delete(t),Mt(e))}function Qb(e,t,n){let r=e.queued.get(t);r!==void 0&&(r.delete(n),r.size===0&&e.queued.delete(t),Mt(e))}function Zb(e,t,n){Xb(e,t,n),Qb(e,t,n)}function ey(e,t){e.queued.delete(t),e.pending.delete(t),e.missedScans.delete(t),e.committing.delete(t),Mt(e)}function ty(e,t,n){if(t===void 0)return null;let i=t[at]!==!0&&t.reasoningEfforts!==void 0&&typeof t[Sn]=="number"||t[at]!==!0&&n?.efforts!==void 0&&ny(t.reasoningEfforts,n.efforts)?!1:t.reasoningEfforts!==void 0||t[at]===!0||e.efforts==="keep",s=t[xt]!==!0&&n?.input!==void 0&&ry(t.input,n.input)?!1:Array.isArray(t.input)&&t.input.length>0||t[xt]===!0,d=i?"keep":e.efforts,l=s?void 0:e.input,c=t[st]===!0,p=e.imageGen!==void 0&&e.imageGen!==c?e.imageGen:void 0,h=e.defaultEffort;return d==="keep"&&l===void 0&&p===void 0&&h===void 0?null:{efforts:d,...e.compat===void 0?{}:{compat:e.compat},...l===void 0?{}:{input:l},...p===void 0?{}:{imageGen:p},...h===void 0?{}:{defaultEffort:h}}}function ny(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 ry(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 oy(e){if(!X(e))return!1;let t=e.efforts;return t===!1||t==="keep"||X(t)}async function iy(e,t,n,r,o=!1,i){let a=i??await e.describeNamespace(),s=Be(a.namespace),d=[];for(let[h,m]of[...r]){let g=Dn(s,n).find(w=>w.id===h);if(g===void 0||t.pending.get(n)?.get(h)!==m)continue;let b=tn(s,n),f=typeof g.name=="string"?g.name:void 0,v=kt(h,f===void 0?b:{...b,displayName:f}),x=ty(m,g,{...v.efforts===void 0?{}:{efforts:v.efforts},...v.input===void 0?{}:{input:v.input}});if(x===null){Vn(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:Bu),p=!1;return d.forEach((h,m)=>{let g=c[m];if(g?.aborted!==!0){if(g?.ok===!0||g?.modelNotFound===!0){Vn(t,n,h.modelId,void 0);return}if(g?.error!==void 0&&mu.has(g.error)){Vn(t,n,h.modelId,void 0),console.error(`[bre] staged flush withdrew "${n}"/"${h.modelId}": ${g.error}`);return}p=!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),p}async function Es(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 Mt(t),!1;let i=r??await e.describeNamespace();if(i.writable!==!0)return Mt(t),!1;let a=!1;for(let[s,d]of[...t.queued]){if(!t.committing.has(s)&&!t.signalsUnavailable)continue;let c=[...d].map(([m,g])=>({modelId:m,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}})),p=await Mr(e.api,s,c,()=>Promise.resolve(i),n?void 0:Bu),h=!1;c.forEach((m,g)=>{let b=p[g];if(b?.aborted===!0){h=!0;return}if(b?.ok===!0||b?.modelNotFound===!0){d.delete(m.modelId);return}if(b?.error!==void 0&&mu.has(b.error)){d.delete(m.modelId),console.error(`[bre] held write withdrawn for "${s}"/"${m.modelId}": ${b.error}`);return}console.error(`[bre] held write failed for "${s}"/"${m.modelId}": ${b?.error??"unknown"}`)}),d.size===0?(t.queued.delete(s),t.committing.delete(s)):h||(a=!0)}return Mt(t),a}async function Ts(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=Be(o.namespace),a=!1;for(let[s,d]of[...t.pending]){if(d.size===0){t.pending.delete(s);continue}$n(i,s)&&await iy(e,t,s,d,n,o)&&(a=!0)}return Mt(t),a}function Ze(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 qr(e){return e.closest('[class*="editor"], [class*="rowCard"], [class*="addCard"]')??void 0}function ay(e){let t=e.closest('[class*="modelEntry"]');if(t===null){let r=qr(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 bu(e,t){return Array.from(e.querySelectorAll("button[aria-label]")).find(n=>t.some(r=>(n.getAttribute("aria-label")??"").startsWith(r)))}function ou(){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 sy="modelReasoning",vs="data-bre-reasoning-hidden";function yu(e){return e.querySelector(`[class*="${sy}"]`)??void 0}function Ss(e){let t=yu(e);t!==void 0&&t.style.display!=="none"&&(t.setAttribute(vs,"1"),t.style.display="none")}function _r(e){let t=yu(e);t!==void 0&&t.getAttribute(vs)==="1"&&(t.removeAttribute(vs),t.style.display==="none"&&(t.style.display=""))}var oi="data-bre-capacity-hidden";function vu(e,t){return Array.from(e.children).filter(n=>n.nodeType!==1?!1:n.matches(`[class*="${t}"]`))}function dy(e){return vu(e,"modelField")}function ly(e){return vu(e,"modelInputTypes")}function wu(e){return[...dy(e),...ly(e)]}function cy(e){for(let t of e)t.style.display!=="none"&&(t.setAttribute(oi,"1"),t.style.display="none")}function uy(e){for(let t of e)t.getAttribute(oi)==="1"&&(t.removeAttribute(oi),t.style.display==="none"&&(t.style.display=""))}function fy(e){cy(wu(e))}function bs(e){uy(wu(e))}function xu(e){let t=e.querySelector('[class*="modelInputTypes"]');return t===null||t.getAttribute(oi)==="1"?!1:!t.hidden&&t.style.display!=="none"}function ku(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 Kr(e,t,n){if(!xu(e))return!1;let r=ku(e,n);return r===void 0||r.disabled?!1:(r.checked!==t&&r.click(),!0)}function ws(e,t,n){return t==null||e===void 0||xu(e)&&Kr(e,t.includes("image"),n),t}function iu(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 Ms(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=>iu(s,t.contextWindow)),i=r.find(s=>iu(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 Eu(e,t,n){let r=Ms(e,t),o=(i,a)=>i===void 0||i.disabled||a===void 0||!Number.isFinite(a)||a<=0||Et(i.value)!==void 0?!1:Tu(i,String(a));return{contextWindow:o(r.contextWindow,n.contextWindow),maxOutput:o(r.maxOutput,n.maxTokens)}}function Tu(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 py(e,t){let n=Ms(e,t),r=a=>{if(a!==void 0)return Et(a.value)},o=r(n.contextWindow),i=r(n.maxOutput);return{...o===void 0?{}:{contextWindow:o},...i===void 0?{}:{maxTokens:i}}}function my(e,t,n){let r=Ms(e,t),o=(i,a)=>i===void 0?!1:Tu(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 Su(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 gy(e,t,n){if(e===void 0)return!1;let r=t.inputImage;if(ni(e))return Kr(e,!0,r);let o=e.closest('[class*="modelEntry"]')??e;if(o.querySelector('[class*="modelAdvanced"]')!==null)return!1;let i=bu(o,t.capacity);return i===void 0||i.disabled?!1:Su(o,async()=>{i.click(),ni(o)||await n();try{return ni(o)&&Kr(o,!0,r)}finally{i.click()}})}async function hy(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=bu(o,t.capacity);return i===void 0||i.disabled?!1:Su(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 by(e,t,n,r,o){n.disposed||!e.isConnected||Ku(e)===void 0||Array.from(e.querySelectorAll("button[aria-label]")).some(a=>o.capacity.some(s=>(a.getAttribute("aria-label")??"").startsWith(s)))||Fo(e,yy(e,Be(r.namespace),o),{t:t.t,onRequest:a=>Mu(n,t,a)})}function yy(e,t,n){let r=[];for(let o of ns(e)){let i=qr(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 vy(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]=ns(i.card);s!==void 0&&r.push({catalogue:s,route:a.route})}return r}function wy(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=qr(d);if(l===void 0)continue;let c=d.closest('[class*="modelEntry"]')??l,p=Ze(c,r.modelId);p.length===0||i.has(p)||un(l,n,r)?.route===t&&(i.add(p),o.push({id:p,name:Ze(c,r.modelName),row:c}))}}return o}async function Mu(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{_a();let a,s=()=>a??(a=t.describeNamespace()),d=await s(),l=Be(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 p=Dn(l,n),h=new Set;for(let T of p){let N=typeof T.id=="string"?T.id:"";N.length>0&&h.add(N)}let m=p.slice();for(let T of r)T.id.length===0||h.has(T.id)||m.push({id:T.id,name:T.name});if(m.length===0)return{held:0,unsuggested:0,blocked:"no-models"};let g=l[n]??{},b=typeof g.api=="string"?g.api:void 0,f=new Set,v=new Map;for(let[T,N]of e.mounted)N.props.route===n&&(v.set(N.props.modelId,T),N.props.efforts!==void 0&&f.add(N.props.modelId));let x=new Map;for(let T of r)T.row!==void 0&&x.set(T.id,T.row);let w=!1,R=(T,N)=>ws(v.get(T),N,t.labels().inputImage),F=async(T,N)=>{if(N.image!==!0)return;let z=v.get(T)??x.get(T);z!==void 0&&await gy(z,t.labels(),ou)},re=async(T,N,z)=>{let M=N.image===!0,y=z.contextWindow!==void 0||z.maxTokens!==void 0;if(!M&&!y)return;let A=v.get(T)??x.get(T);if(A===void 0)return;let C=t.labels();await hy(A,C,ou,I=>{M&&Kr(I,!0,C.inputImage),y&&Eu(I,C,z)})},j=Ho(t.api,s,(T,N,z,M,y,A,C)=>{Vn(e,T,N,z,M,R(N,y),A,C)},(T,N,z)=>{hu(e,T,N,{...z,input:R(N,z.input)})},void 0,()=>w);for(let T of m){let N=typeof T.id=="string"?T.id:"";if(N.length===0)continue;let z=Mo(m,N),M=Ao(m,N),y=T[st]===!0,A=z!==void 0||T[at]===!0,C=Array.isArray(M)&&M.length>0||T[xt]===!0||y;if(f.has(N)&&!A)continue;if(A&&C){let fe=v.get(N)??x.get(N);if(Array.isArray(M)&&M.includes("image")&&fe!==void 0){let Z=t.labels().inputImage,he=ku(fe,Z);he!==void 0&&!he.disabled&&!he.checked&&Kr(fe,!0,Z)}continue}let I=Lo(m,N),D=Ro(m,N)??"",H=await j.suggest(n,N,Co(m,N));if(!H.ok){i+=1;continue}let $=H.suggestion,Q=$.efforts!==!1,oe=$.imageGen===!0?Rt(void 0,!0):$.input===void 0?Rt(M,y):Rt($.input);if(A){if(!oe.image&&!oe.imageGen||e.queued.get(n)?.has(N)===!0)continue;await F(N,oe),w=!h.has(N),j.commit(n,N,Do({efforts:"keep",...Po(oe)})),w&&t.onPendingChanged?.(),w=!1,o+=1;continue}let ae=D!==""?D:$.defaultEffort??D,se=ae===D?void 0:ae===""?null:ae;w=!h.has(N),await re(N,oe,{...$.contextWindow===void 0?{}:{contextWindow:$.contextWindow},...$.maxTokens===void 0?{}:{maxTokens:$.maxTokens}});let ue=Io(oe,M,y)?void 0:Po(oe);j.commit(n,N,Do({efforts:es(Q,Fn(an($.efforts)),z),input:ue?.input,imageGen:ue?.imageGen,defaultEffort:se,appliedCompat:$.compat,routeApi:b,initialCompat:I})),w&&t.onPendingChanged?.(),w=!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 xy(e){return e.querySelector(`[data-plugin="${Ee}"]`)!==null}function ky(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)&&Ty(e.input,t.input)&&e.imageGen===t.imageGen&&Ey(e.compat,t.compat)}function Ey(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 Ty(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 Sy(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(Sy(e,n.routeId)){let a=Ze(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 My(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=(p,h)=>(p.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(p=>t.apply.some(h=>o(p,h))),d=[...r].reverse().find(p=>t.cancel.some(h=>o(p,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 ys=new WeakMap,xs=new Set;function Au(){for(let e of Array.from(xs))e.release()}var Br=420,Lu=320,Ay=160,au=2e3,Ly=150,Cu=new Set(["PageUp","PageDown","Home","End","ArrowUp","ArrowDown"," "]);function As(e,t=Lu){for(let n of ss(e)){let r=ii.get(n);if(r!==void 0){window.clearTimeout(r.timer),r.timer=window.setTimeout(()=>su(n),t);continue}n.style.overflowAnchor!=="none"&&(ii.set(n,{saved:n.style.overflowAnchor,timer:window.setTimeout(()=>su(n),t)}),n.style.overflowAnchor="none")}}var ii=new Map;function su(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=ss(e),o=r[0];if(o===void 0||!e.isConnected)return;let i=performance.now(),a=ys.get(o);if(a!==void 0)if(n)a.release();else{a.deadline=Math.min(Math.max(a.deadline,i+t),a.startedAt+au);return}let s=e.getBoundingClientRect(),d=s.top,l=s.height,c=new Map,p=new Map;for(let w of r){c.set(w,w.scrollTop);let R=w.style.overflowAnchor;R!=="none"&&p.set(w,R),w.style.overflowAnchor="none"}let h=new Set(r),m={deadline:i+t,startedAt:i,frame:void 0,release:()=>{}},g=()=>{if(xs.delete(m)){m.frame!==void 0&&(window.cancelAnimationFrame(m.frame),m.frame=void 0);for(let[w,R]of p)w.style.overflowAnchor=R;ys.delete(o),document.removeEventListener("wheel",b,!0),document.removeEventListener("touchstart",b,!0),document.removeEventListener("pointerdown",b,!0),document.removeEventListener("keydown",f,!0)}};function b(){g()}function f(w){Cu.has(w.key)&&g()}m.release=g,ys.set(o,m),xs.add(m),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",f,{capture:!0});let v=0,x=()=>{if(m.frame=void 0,v+=1,!e.isConnected||v>=Ly){g();return}let w=e.getBoundingClientRect(),R=Math.abs(w.height-l)>.5;if(!R&&[...h].some(T=>T.scrollTop!==c.get(T))){g();return}let F=[];if(R){for(let T of r){let N=c.get(T);N===void 0||T.scrollTop===N||(F.push(T),T.scrollTop=N,c.set(T,T.scrollTop))}w=e.getBoundingClientRect()}let re=w.top-d;re!==0&&Cy(r,h,c,re,F);let j=performance.now();if(R&&(l=w.height,m.deadline=Math.min(Math.max(m.deadline,j+Ay),m.startedAt+au)),j>=m.deadline){g();return}m.frame=window.requestAnimationFrame(x)};m.frame=window.requestAnimationFrame(x)}function Cy(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"]',Ry="bre-list-slack",Ru=3e3,Hy='button[class*="iconButtonDanger"]',Wr,jt=new WeakMap,Yn=new Set;function Hu(e){if(!(e instanceof Element))return;let t=e.closest(Ls);if(t===null)return;let n=wc(t).map(r=>({host:r,top:r.scrollTop}));n.length!==0&&(Wr={targets:n,at:performance.now()})}function Ot(){Wr=void 0}function Nu(e){Hu(e.target),_u(e.target)}function Ou(e){if(Cu.has(e.key)){Ot();return}Hu(e.target),_u(e.target)}var Fr=0;function Iu(){Fr+=1,!(Fr>1)&&(document.addEventListener("click",Nu,!0),document.addEventListener("keydown",Ou,!0),document.addEventListener("focusin",Ot,!0),document.addEventListener("pointerdown",Ot,!0),document.addEventListener("wheel",Ot,{capture:!0,passive:!0}),document.addEventListener("touchstart",Ot,{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 Ny(e){return e===document.scrollingElement?document:e}function Oy(){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 Pu(e,t){return e.scrollTop>e.scrollHeight-e.clientHeight-t}function Du(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=Ry,r.dataset.plugin=Ee,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&&!Pu(e,s.height)&&ai(e)},a={host:e,spacer:r,height:t,onScroll:i,scrollTarget:Ny(e)};return jt.set(e,a),Yn.add(a),a.scrollTarget.addEventListener("scroll",i,{passive:!0}),a}function _u(e){if(!(e instanceof Element))return;let t=e.closest(Hy);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=Wr;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,p=s.scrollHeight-s.clientHeight-c-d;p>=a||Du(s,Math.max(c,a-p))}}function Iy(e=performance.now()){let t=Wr;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&&!Pu(r,o.height)&&ai(r);continue}Du(r,s),r.scrollTop!==n.top&&(r.scrollTop=n.top)}}function Fu(){if(Fr=Math.max(0,Fr-1),!(Fr>0)){document.removeEventListener("click",Nu,!0),document.removeEventListener("keydown",Ou,!0),document.removeEventListener("focusin",Ot,!0),document.removeEventListener("pointerdown",Ot,!0),document.removeEventListener("wheel",Ot,!0),document.removeEventListener("touchstart",Ot,!0),Wr=void 0;for(let e of Array.from(Yn))ai(e.host)}}function qu(e,t=Br){Iy(),Oy();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 Py(e,t){Jn(e,t,()=>{let n=e.closest('[class*="modelEntry"]')??e.closest('[class*="rowCard"]');n!==null&&Xn(e.closest('[class*="rowCard"]')??n,Br)})}var du="{provider}";function Dy(e,t){let n=t.editProvider.map(o=>{let i=o.indexOf(du);return i<0?void 0:{prefix:o.slice(0,i),suffix:o.slice(i+du.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 _y(e,t){Jn(e,t,()=>{let n=e.closest('[class*="rowCard"], [class*="setupCard"], [class*="addCard"]');n!==null&&Xn(n,Br)})}function Fy(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 qy(e,t,n){Jn(e,n,()=>{t.isConnected&&Xn(t,Br)})}function Ky(e,t){Jn(e,t,()=>{let n=e.closest('[class*="addBlock"]');n!==null&&Xn(n,Br,!0)})}function Ku(e){return e.querySelector('[class*="editorActions"]')??e.querySelector('[class*="modelEntry"]')??void 0}function Bu(){return Ku(yt())!==void 0}function By(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)eu(i,r,{t:n})}var ti=new WeakMap;function lu(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 Wy=['[class*="editor"]','[class*="modelEntry"]','[class*="rowCard"]','[class*="setupCard"]','[class*="addCard"]','button[class*="addButton"]',"button[aria-label]"].join(", ");function Cs(e,t,n){if(n.disposed||!e.isConnected)return;let r=t.labels(),o=Array.from(e.querySelectorAll(Wy)),i=!1,a=[],s=[],d=[],l=[],c=[];for(let m of o)!i&&m.matches('[class*="editorActions"], [class*="modelEntry"]')&&(i=!0),m.matches('[class*="rowCard"], [class*="setupCard"]')?(a.push(m),s.push(m)):m.matches('[class*="addCard"]')&&s.push(m),m.matches('[class*="editor"], [class*="addCard"], [class*="rowCard"]')&&l.push(m),m.matches('button[class*="addButton"]')&&m.closest("[data-plugin]")===null&&d.push(m),m.matches("button[aria-label]")&&r.capacity.some(g=>(m.getAttribute("aria-label")??"").startsWith(g))&&c.push(m);for(let m of a)for(let g of Dy(m,r))_y(g,n.editWired);for(let m of s)for(let g of Fy(m,r))qy(g,m,n.addModelWired);for(let m of d)Ky(m,n.addProviderWired);By(l,r,t.t);let p=c.length>0;if(!i){if(Fo(e,[],{t:t.t}),n.mounted.size>0){for(let[g,b]of n.mounted)_r(g),bs(g),b.editor.unmount();n.mounted.clear()}let m=n.editing;n.editing=!1,(m!==!1||gu(n)&&Date.now()>=n.nextFlushAt)&&Jb(t,n,m===!0).catch(g=>{console.error(`[bre] idle pass failed: ${g instanceof Error?g.message:String(g)}`)});return}if(n.editing=!0,!p){for(let[g,b]of n.mounted)_r(g),bs(g),b.editor.unmount();n.mounted.clear(),n.describePromise??(n.describePromise=t.describeNamespace({allowStale:!0}));let m=r;lu(n,g=>{by(e,t,n,g,m)},"empty-catalog seat",!0);return}for(let m of c)Py(m,n.disclosureWired);n.describePromise??(n.describePromise=t.describeNamespace({allowStale:!0})),lu(n,m=>{if(n.disposed||!e.isConnected)return;let g=m.namespace,b=Be(g),f=new Map,v=T=>(f.has(T)||f.set(T,un(T,b,r)),f.get(T)),x=new Map,w=T=>{let N=x.get(T);if(N!==void 0)return N;let z=Dn(b,T),M=new Set,y=new Set,A=new Map;for(let I of z){let D=I.id;M.add(D),A.has(D)||A.set(D,[I]),I[at]===!0&&y.add(D)}let C={models:z,savedModelIds:M,unsetModelIds:y,singletonById:A};return x.set(T,C),C},R=[],F=Array.from(e.querySelectorAll("button[aria-label]")).filter(T=>r.capacity.some(N=>(T.getAttribute("aria-label")??"").startsWith(N)));for(let T of F){let N=qr(T);if(N===void 0)continue;let z=T.closest('[class*="modelEntry"]')??N,M=Ze(z,r.modelId);M.length!==0&&R.push({container:ay(T),row:z,modelId:M,card:N})}Fo(e,vy(R,b,r),{t:t.t,onRequest:T=>Mu(n,t,T,wy(e,T,b,r))});let re=new Set(R.map(T=>T.container));for(let[T,N]of n.mounted)re.has(T)||(_r(T),bs(T),N.editor.unmount(),n.mounted.delete(T));if(n.pending.size>0){let T=new Map;for(let z of R){let M=v(z.card);if(M===void 0)continue;let y=T.get(M.route);y===void 0&&T.set(M.route,y=new Set),y.add(z.modelId)}let N=new Map;for(let[z,M]of n.pending){if(!$n(b,z))continue;let y=T.get(z),A=[...M.keys()].filter(C=>!y?.has(C));A.length>0&&N.set(z,new Set(A))}for(let[z,M]of N){let y=n.missedScans.get(z);if(y!==void 0)for(let A of M)y.has(A)&&(Vn(n,z,A,void 0),y.delete(A),M.delete(A))}n.missedScans=N}else n.missedScans=new Map;let j=new Set(R.map(T=>T.card));for(let T of j){let N=v(T);if(N===void 0)continue;let z=N.route,M=My(T,r);M===void 0?n.signalsUnavailable=!0:(n.signalsUnavailable=!1,Jn(M.submit,n.submitWired,()=>{let y=un(T,b,r)?.route??z;n.committing.add(y),Mt(n)}),Jn(M.cancel,n.cancelWired,()=>{let y=un(T,b,r)?.route??z;ey(n,y)}))}R.forEach((T,N)=>{let z=T.container;if(z===void 0)return;let M=v(T.card);if(M===void 0)return;let{route:y,staged:A}=M,C=b[y]??{},{savedModelIds:I,unsetModelIds:D,singletonById:H}=w(y),$=H.get(T.modelId)??[],Q=A||!I.has(T.modelId),oe=Q?n.pending.get(y)?.get(T.modelId)?.efforts:void 0,ae=Q?oe==="keep"?void 0:oe:Mo($,T.modelId),se=!Q&&D.has(T.modelId),ue=Q?n.pending.get(y)?.get(T.modelId)?.input:Ao($,T.modelId),fe=Q?n.pending.get(y)?.get(T.modelId)?.imageGen:Da($,T.modelId),Z=Q?n.pending.get(y)?.get(T.modelId)?.compat:Lo($,T.modelId),he=Q?n.pending.get(y)?.get(T.modelId)?.defaultEffort??void 0:Ro($,T.modelId),Me=Q?Ze(T.row,r.modelName):"",Ce=Q?Me.length>0?Me:void 0:Co($,T.modelId),Le=A?Ze(T.card,r.apiProtocol):"",J=A?Ze(T.card,r.baseUrl):"",B=A&&Le.length>0?Le:typeof C.api=="string"?C.api:void 0,V=A&&J.length>0?J:typeof C.baseURL=="string"?C.baseURL:void 0,te={route:y,routeDisplayName:A?y:typeof C.displayName=="string"?C.displayName:y,...B===void 0?{}:{routeApi:B},...V===void 0?{}:{routeBaseURL:V},modelId:T.modelId,...Ce===void 0?{}:{modelName:Ce},...ae===void 0?{}:{efforts:ae},...se?{effortsUnset:se}:{},...ue===void 0?{}:{input:ue},...fe?{imageGen:!0}:{},...Z===void 0?{}:{compat:Z},...he===void 0?{}:{defaultEffort:he},index:N,staged:Q,officialInputTypes:ni(z),api:{...Ho(t.api,void 0,(me,Se,u,S,q,K,k)=>{Vn(n,me,Se,u,S,ws(z,q,r.inputImage),K,k)},(me,Se,u)=>{hu(n,me,Se,{...u,input:ws(z,u.input,r.inputImage)})},me=>{Zb(n,me,T.modelId)},()=>(un(T.card,b,r)?.staged??A)||!I.has(T.modelId)),fillCapacities:(me,Se)=>{Eu(z,r,{...me===void 0?{}:{contextWindow:me},...Se===void 0?{}:{maxTokens:Se}})},readCapacities:()=>py(z,r),setCapacities:me=>{my(z,r,me)}},readOnly:m.writable!==!0,t:t.t};Ss(z),fy(z);let pe=n.mounted.get(z);if(pe!==void 0){ky(pe.props,te)||(pe.props=te,pe.editor.render(te));return}if(xy(z))return;Xn(qr(z)??T.card,Lu);let ke=t.mount(z,te);n.mounted.set(z,{editor:ke,props:te})})},"editor reconcile")}var si=['[class*="rowCard"]','[class*="setupCard"]','[class*="addCard"]','[class*="modelEntry"]','[class*="modelAdvanced"]','[class*="modelList"]','[class*="addBlock"]','p[class*="savedNotice"]'].join(","),Gy=[`[data-plugin="${Ee}"]`,".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 Gu(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function Rs(e){let t=Gu(e);return t!==null&&t.closest(Gy)!==null}function Wu(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=e;return Rs(t)?!1:t.matches(si)||t.querySelector(si)!==null}function Uu(e){return e.some(t=>{if(Rs(t.target))return!1;let n=Gu(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(Wu)}return n!==null&&n.closest(si)!==null?!0:t.type==="attributes"&&Wu(t.target)})}var Ns=require("react");var de=require("react"),Zu=require("react-dom");var ct=require("react"),$u=require("react-dom"),At=require("react/jsx-runtime"),ju=6,Uy=292,di=8,jy=52;function zu(e,t){let n=e.getBoundingClientRect(),r=t*jy+46,o=window.innerWidth||0,i=window.innerHeight||0,a=Math.max(di,Math.min(n.left,o-Uy-di)),s=n.bottom+ju,d=n.top-ju-r,l=i>0&&s+r>i-di&&d>di?d:s;return{left:a,top:l}}function Vu(e){let{anchor:t,label:n,options:r,selected:o,onPick:i,onClose:a}=e,[s,d]=(0,ct.useState)(()=>zu(t,r.length)),l=(0,ct.useRef)(null),c=(0,ct.useRef)([]);(0,ct.useLayoutEffect)(()=>{let m=()=>{d(zu(t,r.length))};return m(),window.addEventListener("resize",m),window.addEventListener("scroll",m,!0),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m,!0)}},[t,r.length]),(0,ct.useEffect)(()=>{let m=Math.max(0,r.findIndex(g=>g.value===o));c.current[m]?.focus()},[r,o]),(0,ct.useEffect)(()=>{let m=g=>{let b=g.target;b instanceof Node&&l.current?.contains(b)!==!0&&(t.contains(b)||a())};return document.addEventListener("pointerdown",m,!0),()=>{document.removeEventListener("pointerdown",m,!0)}},[t,a]);let p=(0,ct.useCallback)(m=>{if(r.length===0)return;let g=(m+r.length)%r.length;c.current[g]?.focus()},[r.length]),h=m=>{let g=c.current.findIndex(b=>b===document.activeElement);if(m.key==="Escape"){m.preventDefault(),m.stopPropagation(),a();return}if(m.key==="ArrowDown"){m.preventDefault(),p(g+1);return}if(m.key==="ArrowUp"){m.preventDefault(),p(g<0?r.length-1:g-1);return}if(m.key==="Home"){m.preventDefault(),p(0);return}m.key==="End"&&(m.preventDefault(),p(r.length-1))};return(0,$u.createPortal)((0,At.jsxs)("div",{ref:l,className:"bre-protocol-menu",style:{left:s.left,top:s.top},onKeyDown:h,children:[(0,At.jsx)("p",{className:"bre-protocol-menu-title",children:n}),(0,At.jsx)("ul",{className:"bre-protocol-menu-list",role:"listbox","aria-label":n,children:r.map((m,g)=>{let b=m.value===o;return(0,At.jsx)("li",{children:(0,At.jsx)("button",{ref:f=>{c.current[g]=f},type:"button",role:"option","aria-selected":b,"data-protocol-value":m.value,className:"bre-protocol-option",tabIndex:-1,onClick:()=>{i(m.value)},children:(0,At.jsxs)("span",{className:"bre-protocol-option-text",children:[(0,At.jsx)("span",{className:"bre-protocol-option-title",children:m.title}),(0,At.jsx)("span",{className:"bre-protocol-option-hint",children:m.hint})]})})},m.value)})})]}),document.body)}var G=require("react/jsx-runtime"),zy=200,$y=["M8 3.9v8.2","M3.9 8h8.2"],Yu="M3.9 8.35 6.6 11.05 12.1 5.5",Vy=["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"],Yy=1600;async function Jy(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 Hs({paths:e}){return(0,G.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,G.jsx)("path",{d:t},t))})}function Xy(e,t){return e.masked!==void 0?e.masked:e.configured===!1?t("keysMissing"):"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}function Ju(e){return e.alias??e.masked??e.ref}function Qy(e,t){return e.models===void 0?t("keysScopeAll"):e.models.length===0?t("keysScopeNone"):t("keysScopeCount",{count:e.models.length})}var ef=["openai-completions","openai-responses","anthropic-messages"],Xu={openai:null,anthropic:null},Zy=2e3,ev=150,tv=300,nv=1500,rv=new Intl.Collator("en",{numeric:!0,sensitivity:"base"});function ov(e,t){return ef.filter(n=>n===t?!0:(e[zo(n)]??"").length>0)}function tf(e,t){return t(e==="anthropic-messages"?"keysProtocolAnthropic":e==="openai-responses"?"keysProtocolResponses":e==="openai-completions"?"keysProtocolOpenAI":"keysProtocolDefault")}function iv(e,t){return t(e==="anthropic-messages"?"keysProtocolAnthropicHint":e==="openai-responses"?"keysProtocolResponsesHint":e==="openai-completions"?"keysProtocolOpenAIHint":"keysProtocolDefaultHint")}function Qu(e,t,n,r=!1){return[void 0,...r?ef:ov(e,t)].map(i=>({value:i??"",title:tf(i,n),hint:iv(i,n)}))}function li(e){let{route:t,t:n,draft:r}=e,o=e.client??Ue,[i,a]=(0,de.useState)(()=>o.cached?.(t)?.entries),[s,d]=(0,de.useState)(()=>o.cached?.(t)?.models??[]),[l,c]=(0,de.useState)(void 0),[p,h]=(0,de.useState)(!1),m=i===void 0&&l===void 0;(0,de.useEffect)(()=>{if(h(!1),!m)return;let k=setTimeout(()=>h(!0),zy);return()=>clearTimeout(k)},[m,t]);let[g,b]=(0,de.useState)(!1),[f,v]=(0,de.useState)(void 0),[x,w]=(0,de.useState)(""),[R,F]=(0,de.useState)(""),[re,j]=(0,de.useState)([]),[T,N]=(0,de.useState)(void 0);(0,de.useEffect)(()=>{r===!0&&v({kind:"add"})},[r]);let[z,M]=(0,de.useState)(void 0),[y,A]=(0,de.useState)(void 0),[C,I]=(0,de.useState)(void 0),D=(0,de.useRef)(void 0);(0,de.useEffect)(()=>()=>{D.current!==void 0&&clearTimeout(D.current)},[]);let[H,$]=(0,de.useState)(void 0),[Q,oe]=(0,de.useState)(()=>o.cached?.(t)?.endpoints??Xu),[ae,se]=(0,de.useState)(!1),ue=(0,de.useRef)(!1);(0,de.useEffect)(()=>{ue.current=ae},[ae]);let fe=(0,de.useRef)(0),Z=(0,de.useCallback)((k,_)=>{if(!k.ok){c({kind:"error",text:k.error??n("keysUnreachable")});return}a(k.entries),d(k.models??[]),oe(k.endpoints),se(k.probing===!0),c(_===void 0?void 0:{kind:"status",text:_})},[n]),he=(0,de.useRef)(t);he.current=t,(0,de.useEffect)(()=>(he.current=t,()=>{he.current=void 0}),[t]);let Me=(0,de.useCallback)(async(k,_=!1)=>{let ee=o.cached?.(k)!==void 0,le=await o.list(k,_?{preferCache:!0}:void 0);he.current===k&&(ee&&!le.ok||Z(le,void 0))},[Z,o]);(0,de.useEffect)(()=>{Me(t,!0)},[Me,t]),(0,de.useEffect)(()=>{let k,_,ee=()=>{k===void 0&&(k=setTimeout(()=>{k=void 0,Me(t),_===void 0&&(_=setTimeout(()=>{_=void 0,!ue.current&&Me(t)},nv))},tv))};return document.addEventListener(Er,ee),()=>{document.removeEventListener(Er,ee),k!==void 0&&clearTimeout(k),_!==void 0&&clearTimeout(_)}},[Me,t]),(0,de.useEffect)(()=>{if(!ae){fe.current=0;return}let k=!0,_=setInterval(()=>{if(fe.current+=1,fe.current>ev){se(!1);return}(async()=>{let ee=await o.list(t);!k||he.current!==t||(ee.ok?(Z(ee,void 0),ee.probing!==!0&&c({kind:"status",text:n("keysProbeDone")})):se(!1))})()},Zy);return()=>{k=!1,clearInterval(_)}},[Z,o,ae,t]),(0,de.useEffect)(()=>{let k=!0,_=0,ee=le=>{let be=le.detail,ye=be?.route;if(!k||he.current!==t||ye!==void 0&&ye!==t)return;let De=++_;if(typeof be?.openai=="string"&&typeof be.anthropic=="string"){oe({openai:be.openai||null,anthropic:be.anthropic||null});return}(async()=>{let ze=o.endpoints!==void 0?await o.endpoints(t):await o.list(t);!k||he.current!==t||_!==De||ze.ok&&oe(ze.endpoints??Xu)})().catch(()=>{})};return document.addEventListener(kr,ee),()=>{k=!1,document.removeEventListener(kr,ee)}},[o,t]);let Ce=()=>{v(void 0),w(""),F(""),j([]),N(void 0)},Le=(0,de.useCallback)(async(k,_)=>{let ee=f,le=t;b(!0),M(void 0);try{let be=await k();if(he.current!==le)return;Z(be,_),be.ok&&ee!==void 0&&ee.kind!=="add"&&!be.entries.some(ye=>ye.ref===ee.ref)&&Ce()}finally{b(!1)}},[Z,f,t]),J=(k,_)=>{v({kind:k,ref:_.ref}),w(k==="alias"?_.alias??"":""),F(""),j((_.models??[]).filter(ee=>s.includes(ee))),N(void 0),M(void 0)},B=()=>{if(g||f===void 0)return;let k=f.kind,_=f.ref;if(k!=="alias"&&k!=="scope"&&!Ht(R))return;let ee=Ac(x),le=T,be=t,ye=()=>he.current!==be;b(!0),(async()=>{try{if(k==="add"){let ze=new Set((i??[]).map(Re=>Re.ref)),pt=await o.add(t,R,ee);if(ye())return;if(!pt.ok){Z(pt,n("keysAdded"));return}if(Z(pt,n("keysAdded")),Ce(),le===void 0)return;let Qt=pt.entries.find(Re=>Re.ref===pt.addedRef)??pt.entries.find(Re=>!ze.has(Re.ref)),En=Qt===void 0?{ok:!1}:await o.setProtocol(t,Qt.ref,le);ye()||Z(En,n("keysAdded"));return}if(_===void 0)return;if(k==="scope"){let ze=await o.setScope(t,_,re.length===0?void 0:re);ye()||(Z(ze,n("keysScopeSaved")),ze.ok&&Ce());return}let De=k==="alias"?await o.rename(t,_,ee):await o.replace(t,_,R);ye()||(Z(De,n(k==="alias"?"keysRenamed":"keysReplaced")),De.ok&&Ce())}finally{b(!1)}})()},V=k=>{j(_=>_.includes(k)?_.filter(ee=>ee!==k):[..._,k])},te=(0,de.useMemo)(()=>[...new Set(s)].sort(rv.compare),[s]),pe=(0,de.useMemo)(()=>new Set(re),[re]),ke=()=>{if(f===void 0)return null;let k=f.kind,_=k==="add"||k==="value",ee=k==="scope",le=k==="scope"&&f?.ref!==void 0?i?.find(ye=>ye.ref===f.ref)?.auto===!0:!1,be=_&&R.length>0&&!Ht(R);return(0,G.jsxs)("div",{className:"bre-keys-form",children:[ee?(0,G.jsx)("div",{className:"bre-keys-chips",role:"group","aria-label":n("keysScope"),children:te.length===0?(0,G.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeEmpty")}):te.map(ye=>{let De=pe.has(ye);return(0,G.jsx)("button",{type:"button",className:De?"bre-keys-chip is-selected":"bre-keys-chip","aria-pressed":De,disabled:g,onClick:()=>V(ye),children:ye},ye)})}):(0,G.jsxs)("div",{className:"bre-keys-form-fields",children:[k==="value"?null:(0,G.jsx)("input",{className:"bre-text-input bre-keys-name",type:"text",value:x,placeholder:n("keysAliasPlaceholder"),"aria-label":n("keysAlias"),disabled:g,autoFocus:k==="alias",onChange:ye=>w(ye.target.value)}),_?(0,G.jsx)("input",{className:"bre-text-input bre-keys-secret",type:"password",autoComplete:"new-password",spellCheck:!1,value:R,placeholder:n(k==="add"?"keysValuePlaceholder":"keysNewValuePlaceholder"),"aria-label":n("keysValue"),"aria-invalid":be,disabled:g,autoFocus:!0,onChange:ye=>F(ye.target.value)}):null]}),k==="add"?(0,G.jsx)("div",{className:"bre-keys-chips",role:"group","aria-label":n("keysProtocolCreate"),children:Qu(Q,void 0,n,r===!0).map(ye=>{let De=ye.value===""?void 0:ye.value,ze=T===De;return(0,G.jsx)("button",{type:"button",className:ze?"bre-keys-chip is-selected":"bre-keys-chip","aria-pressed":ze,title:ye.hint,disabled:g,onClick:()=>N(De),children:ye.title},ye.value)})}):null,k==="add"?(0,G.jsx)("p",{className:"bre-keys-hint",children:n("keysProtocolCreateHint")}):null,ee?(0,G.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeHint")}):null,ee&&le?(0,G.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeAutoHint")}):null,be?(0,G.jsx)("p",{className:"bre-effort-message bre-error",role:"alert",children:n("keysAddIllegal")}):null,(0,G.jsxs)("div",{className:"bre-keys-form-actions",children:[ee?(0,G.jsx)("button",{type:"button",className:"bre-link-button bre-keys-allmodels",disabled:g,onClick:()=>j([]),children:n("keysScopeAll")}):null,(0,G.jsx)("button",{type:"button",className:"bre-link-button",disabled:g,onClick:Ce,children:n("keysCancel")}),(0,G.jsx)("button",{type:"button",className:"bre-primary-button",disabled:g||_&&!Ht(R),onClick:B,children:n(k==="add"?"keysAddConfirm":"keysSave")})]})]})},me=()=>f?.kind==="add"?(0,G.jsx)("li",{className:"bre-keys-form-row",children:ke()}):(0,G.jsx)("li",{className:"bre-keys-add-row",children:(0,G.jsxs)("button",{type:"button",className:"bre-keys-add",disabled:g,onClick:()=>{v({kind:"add"}),w(""),F(""),j([]),M(void 0)},children:[(0,G.jsx)("span",{className:"bre-keys-add-mark","aria-hidden":"true",children:(0,G.jsx)(Hs,{paths:$y})}),n("keysAdd")]})}),Se=async k=>{if(C!==void 0)return;let _=t;I(k.ref);try{let ee=await o.reveal(t,k.ref);if(he.current!==_)return;if(ee===void 0){c({kind:"error",text:n("keysCopyFailed")});return}let le=await Jy(ee);if(he.current!==_)return;if(!le){c({kind:"error",text:n("keysCopyFailed")});return}c(void 0),A(k.ref),D.current!==void 0&&clearTimeout(D.current),D.current=setTimeout(()=>{D.current=void 0,A(void 0)},Yy)}finally{I(void 0)}},u=(k,_)=>{let ee=_===""?void 0:_;$(void 0),Le(()=>o.setProtocol(t,k.ref,ee),n("keysProtocolSaved"))},S=H===void 0?void 0:i?.find(k=>k.ref===H.ref);if(i===void 0)return l===void 0?(0,G.jsx)("div",{className:"bre-keys","aria-busy":"true",children:p?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)("ul",{className:"bre-keys-list bre-keys-skeleton","aria-hidden":"true",children:[(0,G.jsxs)("li",{className:"bre-keys-skeleton-row",children:[(0,G.jsx)("span",{className:"bre-keys-skeleton-dot"}),(0,G.jsx)("span",{className:"bre-keys-skeleton-bar is-name"}),(0,G.jsx)("span",{className:"bre-keys-skeleton-bar is-mask"})]}),(0,G.jsx)("li",{className:"bre-keys-skeleton-row is-add",children:(0,G.jsx)("span",{className:"bre-keys-skeleton-bar"})})]}),(0,G.jsx)("p",{className:"bre-keys-sr",role:"status",children:n("keysLoading")})]}):null}):(0,G.jsxs)("div",{className:"bre-keys",children:[(0,G.jsx)("p",{className:"bre-effort-message bre-"+l.kind,role:l.kind==="error"?"alert":"status",children:l.text}),(0,G.jsx)("ul",{className:"bre-keys-list",children:me()})]});let q=i.reduce((k,_)=>_.enabled?k+1:k,0),K=r===!0?null:(0,G.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:()=>{Le(()=>o.probe(t),void 0)},children:n(ae?"keysProbing":"keysProbe")});return(0,G.jsxs)("div",{className:"bre-keys",children:[K===null?null:e.probeHost===void 0?(0,G.jsx)("div",{className:"bre-keys-probe-row",children:K}):(0,Zu.createPortal)(K,e.probeHost),(0,G.jsxs)("ul",{className:"bre-keys-list",children:[i.map(k=>{let _=Ju(k),ee=k.enabled&&q<=1;return(0,G.jsxs)(de.Fragment,{children:[(0,G.jsxs)("li",{className:k.enabled?"bre-keys-row":"bre-keys-row is-off","data-state":k.configured===!1?"missing":"ready",children:[(0,G.jsx)("button",{type:"button",className:k.enabled?"bre-keys-toggle is-on":"bre-keys-toggle","aria-pressed":k.enabled,"aria-label":n(k.enabled?"keysDisable":"keysEnable",{name:_}),title:n(k.enabled?"keysDisable":"keysEnable",{name:_}),disabled:g||ee,onClick:()=>{Le(()=>o.setEnabled(t,k.ref,!k.enabled),void 0)},children:(0,G.jsx)("span",{className:"bre-keys-toggle-mark","aria-hidden":"true",children:(0,G.jsx)(Hs,{paths:[Yu]})})}),(0,G.jsxs)("span",{className:"bre-keys-value",children:[k.alias===void 0?null:(0,G.jsx)("span",{className:"bre-keys-alias",children:k.alias}),(0,G.jsx)("span",{className:k.alias===void 0?"bre-keys-mask bre-keys-mask-plain":"bre-keys-mask",children:Xy(k,n)}),(0,G.jsx)("button",{type:"button",className:y===k.ref?"bre-keys-copy is-copied":"bre-keys-copy","aria-label":n("keysCopy",{name:_}),title:y===k.ref?n("keysCopied"):n("keysCopy",{name:_}),disabled:g||C===k.ref||k.configured===!1,onClick:()=>{Se(k)},children:(0,G.jsx)(Hs,{paths:y===k.ref?[Yu]:Vy})})]}),(0,G.jsx)("span",{className:z===k.ref?"bre-keys-actions is-confirming":"bre-keys-actions",children:z===k.ref?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)("button",{type:"button",className:"bre-link-button bre-keys-danger",disabled:g,onClick:()=>{Le(()=>o.remove(t,k.ref),n("keysRemoved"))},children:n("keysConfirmRemove")}),(0,G.jsx)("button",{type:"button",className:"bre-link-button",disabled:g,onClick:()=>M(void 0),children:n("keysCancel")})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)("span",{className:"bre-keys-protocol-wrap",children:(0,G.jsxs)("button",{type:"button",className:"bre-keys-protocol","aria-haspopup":"listbox","aria-expanded":H?.ref===k.ref,"aria-label":n("keysProtocolLabel",{name:_}),title:n("keysProtocolLabel",{name:_}),disabled:g,onClick:le=>{let be=le.currentTarget;$(ye=>ye?.ref===k.ref?void 0:{ref:k.ref,anchor:be}),M(void 0)},children:[(0,G.jsx)("span",{className:"bre-keys-protocol-label",children:tf(k.protocol,n)}),(0,G.jsx)("span",{className:"bre-keys-protocol-caret","aria-hidden":"true",children:"\u203A"})]})}),r===!0?null:(0,G.jsx)("button",{type:"button",className:"bre-link-button bre-keys-scope",disabled:g,title:n("keysScope",{name:_}),onClick:()=>J("scope",k),children:Qy(k,n)}),(0,G.jsx)("button",{type:"button",className:"bre-link-button",disabled:g,onClick:()=>J("alias",k),children:n("keysAlias")}),(0,G.jsx)("button",{type:"button",className:"bre-link-button",disabled:g,onClick:()=>J("value",k),children:n("keysEdit")}),(0,G.jsx)("button",{type:"button",className:"bre-link-button",disabled:g,onClick:()=>{M(k.ref),v(void 0)},children:n("keysRemove")})]})})]}),f!==void 0&&f.ref===k.ref?(0,G.jsx)("li",{className:"bre-keys-form-row",children:ke()}):null]},k.ref)}),me()]}),r===!0?(0,G.jsx)("p",{className:"bre-keys-note",children:n("keysDraftHint")}):null,l===void 0?null:(0,G.jsx)("p",{className:"bre-effort-message bre-"+l.kind,role:l.kind==="error"?"alert":"status",children:l.text}),H===void 0||S===void 0?null:(0,G.jsx)(Vu,{anchor:H.anchor,label:n("keysProtocolLabel",{name:Ju(S)}),options:Qu(Q,S.protocol,n,r===!0),selected:S.protocol??"",onPick:k=>u(S,k),onClose:()=>$(void 0)})]})}var fn="bre-key-managed",av="bre-keys-host",nf="bre-keys-probe-host",Os="data-bre-key-host",sv="data-bre-key-input",ci="data-bre-region",zt=new WeakMap;function dv(e){let t=e.querySelector(`input[${sv}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function rf(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(Os)?n:void 0}function of(e,t){let n=t.route;if(n===void 0||n.length===0||dv(e)===void 0||e.parentElement===null)return;Ge(e,fn,!0);let r=zt.get(e),o=rf(e);o===void 0&&(r!==void 0&&af(e,r),o=e.ownerDocument.createElement("div"),o.className=av,e.after(o)),we(o,Os,n);let i=e.getAttribute(ci);i===null?o.hasAttribute(ci)&&o.removeAttribute(ci):we(o,ci,i);let a=zt.get(e),s=a?.probeHost??e.ownerDocument.createElement("span");a===void 0&&(s.className=nf),s.parentElement!==e&&e.appendChild(s);let d=()=>(0,Ns.createElement)(We,{fallbackText:t.t("keysPanelFailed")},(0,Ns.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:Qe(o,d(),{sync:!0}),t:t.t,client:t.client})}function af(e,t){zt.delete(e),Oe(t.mount),t.probeHost.remove()}function ui(e){Ge(e,fn,!1);let t=zt.get(e);t!==void 0&&af(e,t),rf(e)?.remove();for(let n of Array.from(e.children))n.classList.contains(nf)&&n.remove()}function sf(){for(let e of Array.from(document.querySelectorAll(`[${Os}]`))){let t=e.previousElementSibling;t instanceof HTMLElement&&zt.has(t)?ui(t):e.remove()}}var df="http://www.w3.org/2000/svg",lv="data-bre-icon";function cv(e){let t=document.createElementNS(df,"path");return t.setAttribute("d",e),t}function fi(e,t){let n=document.createElementNS(df,"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(lv,e),n.append(...t.map(cv)),n}var mn="bre-key-field",uf="bre-key-eye",Gr="data-bre-key-input",ff="data-bre-eye-show",pf="data-bre-eye-hide",lf=["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[${Gr}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function Ps(e){for(let t of Array.from(e.children))if(t instanceof HTMLButtonElement&&t.classList.contains(uf))return t}function mf(e){let t=mi(e);t!==void 0&&(we(t,Gr,""),Ge(e,mn,!0))}function gf(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),we(n,Gr,""),Ge(e,mn,!0);let r=Ps(e)??fv(e);we(r,ff,t.t("keyRevealShow")),we(r,pf,t.t("keyRevealHide")),Is(r,n)}function Qn(e){let t=Ps(e);t!==void 0&&t.remove(),pi.delete(e),Ge(e,mn,!1);let n=e.querySelector(`input[${Gr}]`);n instanceof HTMLInputElement&&(n.removeAttribute(Gr),n.type="password");let r=pn.get(e);pn.delete(e),r!==void 0&&n instanceof HTMLInputElement&&n.value===r&&Ur(n,"")}async function uv(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 Is(e,t){let n=t.type!=="password";we(e,"aria-pressed",n?"true":"false");let r=e.getAttribute(n?pf:ff);r!==null&&(we(e,"aria-label",r),we(e,"title",r)),vt(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 fv(e){let t=document.createElement("button");t.type="button",t.className=uf,t.append(cf("eye"),cf("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&&Ur(r,""),r.type="password",Is(t,r);return}let i=o.route;if(i!==void 0&&pn.get(e)===void 0&&r.value.length===0){we(t,"aria-busy","true");let a;try{a=await(o.loadKey??uv)(i)}catch{a=void 0}if(t.hasAttribute("aria-busy")&&t.removeAttribute("aria-busy"),a===void 0){let s=o.t("keyRevealFailed");we(t,"aria-label",s),we(t,"title",s);return}if(Ps(e)!==t||!t.isConnected||mi(e)!==r||r.value.length>0)return;pn.set(e,a),Ur(r,a)}r.type="text",Is(t,r)};return t.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation(),n()}),e.append(t),t}function cf(e){let t=e==="eye-off"?[...lf,"M2.5 13.5 13.5 2.5"]:lf;return fi(e,t)}var Fs="bre-editor-tabs",pv="bre-editor-tab",gi="data-bre-tab-id",zr="bre-tabbed",It="data-bre-tab",hf="data-bre-provider",ut="data-bre-region",jr="data-bre-editor-body",nr="data-bre-footer",mv="row",gv="path",$r="data-bre-details";var hv=".bre-headers",bv=".bre-fingerprint",yv="data-bre-fingerprint",$t="provider",Zn="models",er="fingerprint",tr="advanced",vv=[$t,Zn,tr,er],wv="none",bf=vv,yf=Fs,vf=pv,wf=gi,hi='[class*="editorActions"], [class*="modelList"], [class*="modelCatalog"], [class*="modelEntry"]',xv='[class*="modelCatalog"], [class*="modelList"], [class*="modelEntry"]',xf='[class*="rowCard"], [class*="addCard"], li',kv='[class*="addPanel"]',Ds=".bre-create-host";function kf(){return{warned:new WeakSet}}function rr(e){return e===null?null:e.closest(xf)}function Ef(e){let t=rr(e);return t!==null&&t.querySelector(Ds)!==null}function Tf(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.matches(kv)&&!t.hidden)return t;return e}function Sf(e,t){if(e.getAttribute(It)===t){_s(e);return}let n=Go(e),r=e.getBoundingClientRect().top,o=n?.scrollTop??0;n!==void 0&&(n.style.overflowAnchor="none"),we(e,It,t),_s(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 qs(e,t,n){if(!e.isConnected)return;let r=new Set;for(let o of Array.from(e.querySelectorAll(hi))){let i=o.closest(xf);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{Lv(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 Mf(){for(let e of Array.from(document.querySelectorAll(`.${zr}`))){e.classList.remove(zr),e.removeAttribute(It),e.removeAttribute(jr);for(let t of Array.from(e.querySelectorAll(`[${ut}]`)))t.removeAttribute(ut)}for(let e of Array.from(document.querySelectorAll(`[${It}]`)))e.removeAttribute(It);for(let e of Array.from(document.querySelectorAll(`[${ut}]`)))e.removeAttribute(ut);for(let e of Array.from(document.querySelectorAll(`[${jr}]`)))e.removeAttribute(jr);for(let e of Array.from(document.querySelectorAll(`[${nr}]`)))e.removeAttribute(nr);for(let e of Array.from(document.querySelectorAll(`details[${$r}]`)))e.removeAttribute("open"),e.removeAttribute($r);for(let e of Array.from(document.querySelectorAll(`.${mn}`)))Qn(e);for(let e of Array.from(document.querySelectorAll(`.${fn}`)))ui(e);sf()}function Ev(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 Tv(e){let t={header:void 0,models:void 0,actions:void 0,fields:[]};Af(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 Sv=4;function Af(e,t,n){if(!(n>Sv)){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(xv)){t.models??(t.models=r);continue}if(r.querySelector(hi)!==null){Af(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 Mv(e,t){if(!t.contains(e))return;we(e,nr,mv);let n=e.parentElement;for(;n!==null&&(we(n,nr,gv),n!==t);)n=n.parentElement}function Av(e){let n=e.querySelector(`[${hf}]`)?.getAttribute(hf);return n==null||n===""?void 0:n}function Lv(e,t){let n=Tf(e),r=Ev(n);if(r===void 0){bi(e);return}let o=Tv(r);if(o===void 0){bi(e);return}let i=Array.from(n.querySelectorAll(hv)),a=i[0]??null,s=Av(n);for(let h of o.fields)we(h,ut,$t),gf(h,{t:t.t,route:s}),of(h,{t:t.t,route:s});o.header!==void 0&&we(o.header,ut,wv),o.models!==void 0&&we(o.models,ut,Zn),we(r,jr,""),n.querySelector(Ds)!==null&&Mv(o.actions,r);for(let h of i)we(h,ut,tr);let d=n.querySelector(bv);d!==null&&we(d,ut,er),Rv(r);let l=new Set([$t]);o.models!==void 0&&l.add(Zn),a!==null&&l.add(tr);let c=n.querySelector(Ds)!==null;d!==null&&!c&&d.getAttribute(yv)==="ready"&&l.add(er);let p=e.getAttribute(It)??$t;we(e,It,l.has(p)?p:$t),Ge(e,zr,!0),Cv(e,n,t,l)}function Cv(e,t,n,r){let o=t.querySelector(`.${Fs}`);o!==null&&(we(o,"aria-label",n.t("editorTabsLabel")),Rr(gn(o,$t),n.t("editorTabProvider")),Rr(gn(o,Zn),n.t("editorTabModels")),Rr(gn(o,tr),n.t("editorTabAdvanced")),Rr(gn(o,er),n.t("editorTabFingerprint")),vt(gn(o,Zn),!r.has(Zn)),vt(gn(o,tr),!r.has(tr)),vt(gn(o,er),!r.has(er)),_s(e,o))}function _s(e,t){let n=t??Tf(e).querySelector(`.${Fs}`);if(n===null)return;let r=e.getAttribute(It)??$t;for(let o of Array.from(n.querySelectorAll(`[${gi}]`)))we(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(zr),e.removeAttribute(It),e.removeAttribute(jr);for(let t of Array.from(e.querySelectorAll(`[${ut}]`)))t.getAttribute(ut)===$t&&(Qn(t),ui(t)),t.removeAttribute(ut);for(let t of Array.from(e.querySelectorAll(`[${nr}]`)))t.removeAttribute(nr);Hv(e)}function Rv(e){for(let t of Array.from(e.querySelectorAll("details")))t.hasAttribute("open")||(we(t,$r,"closed"),we(t,"open",""))}function Hv(e){for(let t of Array.from(e.querySelectorAll(`details[${$r}]`)))t.removeAttribute("open"),t.removeAttribute($r)}var mp=require("react");var tt=require("react");var Ae=require("react");var Nv='p[class*="savedNotice"]',Rf="data-bre-saved-hidden",Ov="bre-auto-effort-note",Iv="data-bre-auto-effort-phase",Lf="bre-auto-effort-note-text",or=new Map,Cf=new WeakMap,ir=null,yi=null;function Hf(e){let t=Array.from(e.querySelectorAll(Nv));for(let n of t){let r=n.textContent?.trim()??"";Cf.get(n)!==r&&(Cf.set(n,r),r.length>0&&Pf(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)||(Of(n,r),or.delete(n))}function Nf(){for(let[e,t]of Array.from(or))Of(e,t);or.clear(),Ks()}function Of(e,t){e.style.display=t,e.removeAttribute(Rf)}function If(e){Pf(e)}function Pf(e){if(ir!==null&&ir.isConnected&&ir.textContent===e)return;Ks();let t=document.createElement("div");t.className=Ov,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute(Iv,"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(()=>{Ks()},3e3)}function Ks(){yi!==null&&(clearTimeout(yi),yi=null),ir?.remove(),ir=null}var hn="data-bre-settle",Df='[class*="rowActions"] > button:not(.bre-provider-switch):not(.bre-provider-delete)';var Lt=null,Bs=0,vi=0,Vr=!1,ar=null;function _f(e){return e.className.includes("dangerButton")?"remove":"edit"}function Ws(e,t){return Array.from(e.querySelectorAll(Df)).find(r=>_f(r)===t)??null}function Pv(e){return typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function Dv(e){typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):clearTimeout(e)}function Ff(e=document){Yr();let t=[];for(let n of Array.from(e.querySelectorAll(Df))){if(n.disabled)continue;let r=n.closest("li")??n.parentElement;if(r===null)continue;let o=_f(n);t.some(i=>i.row===r&&i.role===o)||t.push({row:r,role:o})}t.length!==0&&(Lt=t,vi=Date.now(),Bs=vi+8e3,_v(),qf())}function Gs(){if(Lt===null)return;let e=Date.now();if(e>Bs){Yr();return}let t=0;if(Lt=Lt.filter(n=>{if(!n.row.isConnected)return!1;let r=Ws(n.row,n.role);return r===null||(r.disabled?(Vr=!0,t+=1,r.hasAttribute(hn)||r.setAttribute(hn,"")):Vr&&r.hasAttribute(hn)&&r.removeAttribute(hn)),!0}),Vr&&t===0){Yr();return}if(!Vr&&e-vi>1500){Yr();return}qf()}function qf(){ar!==null||Lt===null||(ar=Pv(()=>{ar=null,Gs()}))}function _v(){if(Lt!==null)for(let e of Lt){let t=Ws(e.row,e.role);t!==null&&!t.hasAttribute(hn)&&t.setAttribute(hn,"")}}function Kf(){Yr()}function Yr(){if(ar!==null&&(Dv(ar),ar=null),Lt!==null)for(let e of Lt){let t=Ws(e.row,e.role);t!==null&&t.removeAttribute(hn)}Lt=null,Vr=!1,Bs=0,vi=0}var ie=require("react/jsx-runtime"),Fv=["claude-cli/2.1.161 (external, cli)","claude-code/1.0.0","Kilo-Code/1.0"];function Bf(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 Wf(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 qv(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,Ae.useId)(),[l,c]=(0,Ae.useState)(void 0),[p,h]=(0,Ae.useState)({rows:[]}),[m,g]=(0,Ae.useState)(!1),[b,f]=(0,Ae.useState)(!1),[v,x]=(0,Ae.useState)(!0),[w,R]=(0,Ae.useState)(!1),[F,re]=(0,Ae.useState)(!1),[j,T]=(0,Ae.useState)(void 0),[N,z]=(0,Ae.useState)(void 0),[M,y]=(0,Ae.useState)(!1),A=(0,Ae.useRef)(0),C=(0,Ae.useRef)(null),I=o!==void 0,D=o?.onDraft,H=(0,Ae.useRef)(void 0);(0,Ae.useEffect)(()=>{if(I&&H.current!==void 0)return;H.current=e;let J=!0;return(async()=>{try{let B=await ge(t);if(!J)return;let V=Fa(B.namespace,e);c(V),h(Bf(V,A)),re(B.writable!==!0)}catch{J&&re(!0)}finally{J&&x(!1)}})(),()=>{J=!1}},[t,e,I]),(0,Ae.useEffect)(()=>{D!==void 0&&D(Wf(p))},[p,D]),(0,Ae.useEffect)(()=>{let J=!0;return(async()=>{try{let V=await(await fetch(Pd,{method:"GET"})).json();J&&V.ok===!0&&V.data!==void 0&&z(V.data)}catch{}})(),()=>{J=!1}},[]),(0,Ae.useEffect)(()=>{let J=C.current;if(J===null)return;let B=()=>{y(J.dataset.breRegion==="advanced")};B();let V=new MutationObserver(B);return V.observe(J,{attributes:!0,attributeFilter:["data-bre-region"]}),()=>{V.disconnect()}},[]);let $=()=>{h(J=>({...J,rows:[...J.rows,{id:A.current+=1,name:"",value:""}]})),T(void 0)},Q=(J,B)=>{h(V=>({...V,rows:V.rows.map(te=>te.id===J?{...te,...B}:te)})),T(void 0)},oe=J=>{h(B=>({...B,rows:B.rows.filter(V=>V.id!==J)})),T(void 0)},ae=()=>{h({rows:[{id:A.current+=1,name:"",value:""}]}),T(void 0)},se=()=>{if(s?.(),h(Bf(l,A)),f(!1),T(void 0),o!==void 0){o.onCancel();return}M&&r?.()},ue=async J=>{if(R(!0),T(void 0),!qv(l,J)){Ff();let pe;try{pe=await Ar(t,e,J)}catch(ke){pe={ok:!1,error:ke instanceof Error?ke.message:String(ke)}}if(!pe.ok){R(!1),T({kind:"error",text:pe.error==="no-route"?n("headersNoRoute"):pe.error==="read-only"?n("headersReadOnly"):n("headersError",{error:pe.error})});return}c(J)}if(f(!1),a!==void 0)try{await a()}catch{R(!1),T({kind:"error",text:n("camouflageError")});return}R(!1);let V=Object.keys(l??{}).length>0,te=Object.keys(J).length===0&&V?n("headersCleared"):n("headersSaved");if(M){If(te),r?.();return}T({kind:"success",text:te})},fe=Object.entries(l??{}),Z=F||w,he=M||I,Me=b||he?p.rows.filter(J=>J.name.trim().length>0).length:fe.length,Ce=p.rows.some(J=>J.name.trim().length>0||J.value.length>0),Le=m||b||he;return(0,ie.jsxs)("div",{className:"bre-headers",ref:C,"data-plugin":Ee,"data-open":m?"1":"0",children:[(0,ie.jsx)("div",{className:"bre-headers-head",children:b||he?(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)("span",{className:"bre-effort-title",children:n("headersTitle")}),Me===0?null:(0,ie.jsx)("span",{className:"bre-headers-count",children:Me}),F||!Ce?null:(0,ie.jsx)("button",{type:"button",className:"bre-headers-clear",disabled:Z,onClick:ae,children:n("headersClear")})]}):(0,ie.jsxs)("button",{type:"button",className:"bre-headers-disclosure","aria-expanded":m,"aria-label":`${n("headersTitle")} ${e}`,onClick:()=>{g(!m),T(void 0)},children:[(0,ie.jsx)("span",{className:"bre-effort-title",children:n("headersTitle")}),v||Me===0?null:(0,ie.jsx)("span",{className:"bre-headers-count",children:Me}),(0,ie.jsx)("span",{className:"bre-headers-chevron","aria-hidden":"true",children:"\u203A"})]})}),Le?(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)("p",{className:"bre-effort-note",children:n("headersHint")}),N===void 0?null:(0,ie.jsxs)(ie.Fragment,{children:[N.environment.preferOfficialLayer?(0,ie.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictPatched")}):null,N.conflicts.length===0&&(N.headerConflicts?.length??0)===0?null:(0,ie.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictOrigin")}),N.environment.siblings.length===0?null:(0,ie.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictSiblings",{names:N.environment.siblings.map(J=>J.name).join(", ")})})]}),v?null:b||he?(0,ie.jsxs)("div",{className:"bre-headers-edit",children:[(0,ie.jsxs)("div",{className:"bre-headers-columns","aria-hidden":"true",children:[(0,ie.jsx)("span",{children:n("headersName")}),(0,ie.jsx)("span",{children:n("headersValue")}),(0,ie.jsx)("span",{})]}),p.rows.map(J=>(0,ie.jsxs)("div",{className:"bre-headers-row",children:[(0,ie.jsx)("input",{type:"text",className:"bre-text-input bre-headers-name",value:J.name,disabled:Z,placeholder:n("headersNamePlaceholder"),"aria-label":n("headersName"),onChange:B=>{Q(J.id,{name:B.target.value})}}),(0,ie.jsx)("input",{type:"text",className:"bre-text-input bre-headers-value",value:J.value,disabled:Z,list:J.name.trim().toLowerCase()==="user-agent"?d:void 0,placeholder:n("headersValue"),"aria-label":n("headersValue"),onChange:B=>{Q(J.id,{value:B.target.value})}}),(0,ie.jsx)("button",{type:"button",className:"bre-headers-remove",disabled:Z,"aria-label":`${n("headersRemove")} ${J.name}`,title:n("headersRemove"),onClick:()=>{oe(J.id)},children:"\xD7"})]},J.id)),(0,ie.jsx)("button",{type:"button",className:"bre-headers-add",disabled:Z,onClick:$,children:n("headersAdd")}),(0,ie.jsx)("datalist",{id:d,children:Fv.map(J=>(0,ie.jsx)("option",{value:J},J))})]}):(0,ie.jsxs)("div",{className:"bre-headers-rows",children:[fe.length===0?(0,ie.jsx)("p",{className:"bre-effort-note",children:n("headersEmpty")}):fe.map(([J,B])=>(0,ie.jsxs)("div",{className:"bre-headers-row",children:[(0,ie.jsx)("span",{className:"bre-headers-name",children:J}),(0,ie.jsx)("span",{className:"bre-headers-value bre-headers-masked",children:"\u2022".repeat(Math.min(B.length,24))})]},J)),F?null:(0,ie.jsx)("div",{className:"bre-effort-actions",children:(0,ie.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:Z,onClick:()=>{f(!0),T(void 0)},children:n("headersEdit")})})]})]}):null,!v&&(he||b)?(0,ie.jsxs)(ie.Fragment,{children:[i,(0,ie.jsxs)("div",{className:"bre-effort-actions bre-headers-actions",children:[(0,ie.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:w,onClick:se,children:n("headersCancel")}),I?null:(0,ie.jsx)("button",{type:"button",className:"bre-primary-button",disabled:Z,onClick:()=>{ue(Wf(p))},children:n("headersSave")})]})]}):null,j===void 0?null:(0,ie.jsx)("p",{className:"bre-effort-message bre-"+j.kind,role:j.kind==="error"?"alert":"status",children:j.text})]})}var Ne=require("react");var et=require("react/jsx-runtime"),Kv=[{value:void 0,labelKey:"camouflageOff"},{value:"codex",labelKey:"camouflageCodex"},{value:"claude",labelKey:"camouflageClaude"}];function Bv(e){return e==="codex"||e==="claude"}function Gf(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))Bv(a)&&(r[i]=a);return{presets:["codex","claude"],providers:r,installed:n.installed===!0}}function Us({t:e,value:t,installed:n,disabled:r=!1,onChange:o}){let i=(0,Ne.useId)(),a=`${i}-title`,s=`${i}-hint`;return(0,et.jsxs)("div",{className:"bre-camouflage","data-plugin":Ee,"data-open":"1",title:e("camouflageHint"),children:[(0,et.jsx)("span",{className:"bre-effort-title",id:a,children:e("camouflageTitle")}),(0,et.jsx)("div",{className:"bre-camouflage-options",role:"radiogroup","aria-labelledby":a,"aria-describedby":s,children:Kv.map(d=>(0,et.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,et.jsx)("span",{className:"bre-sr-only",id:s,children:e("camouflageHint")}),n?null:(0,et.jsx)("p",{className:"bre-camouflage-warn",children:e("camouflageUnavailable")})]})}function js(e,t){let[n,r]=(0,Ne.useState)(void 0),[o,i]=(0,Ne.useState)(void 0),[a,s]=(0,Ne.useState)(!0),[d,l]=(0,Ne.useState)(!0),c=(0,Ne.useRef)(void 0),p=(0,Ne.useRef)(void 0),h=(0,Ne.useRef)(!0);(0,Ne.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]),(0,Ne.useEffect)(()=>{if(e===""){l(!1);return}let f=!1;return l(!0),fetch(oa,{method:"GET"}).then(async v=>await v.json()).then(v=>{if(f||!h.current)return;let x=Gf(v);if(x===void 0)return;let w=x.providers[e];c.current=w,p.current=w,r(w),i(w),s(x.installed)}).catch(()=>{}).finally(()=>{!f&&h.current&&l(!1)}),()=>{f=!0}},[e]);let m=(0,Ne.useCallback)(f=>{p.current=f,i(f)},[]),g=(0,Ne.useCallback)(()=>{p.current=c.current,i(c.current)},[]),b=(0,Ne.useCallback)(async f=>{let v=f===void 0?p.current:f.preset;if(e===""||v===c.current)return;let x=await fetch(oa,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({route:e,preset:v??null})}),w=await x.json();if(!x.ok||w.ok!==!0)throw new Error("camouflage write rejected");let R=Gf(w);c.current=v,p.current=v,r(v),i(v),R!==void 0&&s(R.installed)},[e]);return{value:o,saved:n,installed:a,loading:d,setValue:m,reset:g,commit:b}}function Uf({route:e,t}){let n=js(e,t),[r,o]=(0,Ne.useState)(void 0),i=(0,Ne.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,et.jsxs)(et.Fragment,{children:[(0,et.jsx)(Us,{t,value:n.value,installed:n.installed,disabled:n.loading||e==="",onChange:i}),r===void 0?null:(0,et.jsx)("p",{className:"bre-effort-message bre-"+r.kind,role:r.kind==="error"?"alert":"status",children:r.text})]})}var zs=require("react");var Wv={provider:"editorTabProvider",models:"editorTabModels",fingerprint:"editorTabFingerprint",advanced:"editorTabAdvanced"};function xi({host:e,t}){return(0,zs.createElement)("div",{className:yf,role:"tablist","aria-label":t("editorTabsLabel")},...bf.map(n=>(0,zs.createElement)("button",{key:n,type:"button",role:"tab",className:vf,[wf]:n,onClick:r=>{r.preventDefault(),r.stopPropagation();let o=rr(e.current);o!==null&&Sf(o,n)}},t(Wv[n]))))}var Gv=15e3;function zf(){return{intents:new Map,baseline:new Map,flushing:!1}}function $s(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 Vs(e,t){e.intents.delete(t)}function $f(e,t){let n=e.intents.get(t);n!==void 0&&(n.releasedAt=Date.now())}function Vf(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 Yf(e,t){return t.length>0&&!e.baseline.has(t)}async function Jf(e,t){if(e.flushing)return jf(e);if(e.intents.size===0)return 0;e.flushing=!0;try{let n=await ge(t),r,o=async a=>dt(n.namespace,a)?!0:(r??(r=await ge(t,{fresh:!0})),dt(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>Gv?(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 jf(e)}function jf(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 Qf({host:e,api:t,t:n,routeIdLabels:r,staged:o}){let[i,a]=(0,tt.useState)(()=>Jr(e.current,r)),s=(0,tt.useRef)(i),d=(0,tt.useRef)(void 0),l=(0,tt.useRef)(new Set),c=(0,tt.useRef)(!1),p=(0,tt.useRef)(null);return p.current===null&&(p.current={onDraft:h=>{d.current=h;let m=s.current;if(m.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}$s(o,m,h),Xf(t,o,m,l.current)},onCancel:()=>{d.current=void 0,Vs(o,s.current)}}),(0,tt.useEffect)(()=>{let h=ki(e.current);if(h===null)return;let m=()=>{a(Jr(e.current,r))};return h.addEventListener("input",m,!0),()=>{h.removeEventListener("input",m,!0)}},[e,r]),(0,tt.useEffect)(()=>{i.length>0&&Xf(t,o,i,l.current)},[t,o,i]),(0,tt.useEffect)(()=>{let h=s.current;if(h===i)return;Vs(o,h),s.current=i;let m=d.current;m!==void 0&&i.length>0&&$s(o,i,m)},[i,o]),(0,tt.useEffect)(()=>()=>{$f(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:p.current,extras:(0,Vt.jsx)(Uf,{route:i,t:n})})]})}function Xf(e,t,n,r){!Yf(t,n)||r.has(n)||(r.add(n),(async()=>{try{let o=await ge(e);Vf(t,n,dt(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=Ze(n,r).trim();if(o.length>0)return o;let i=ki(e);return i===null||i===n?"":Ze(i,r).trim()}var Qs=require("react");var nt=require("react");var Xr=15e3,Uv=3;function ep(){return{intents:new Map,baseline:new Map,baselinePending:new Set,baselineFailures:new Set,activeIntents:new Map,draining:!1,drainAgain:!1}}function Ys(e,t,n){if(t.length===0)return;if(n.length===0){Js(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}jv(r.drafts,n)||(r.drafts=[...n],r.revision+=1,r.baselineMissing=!1,e.draining&&(e.drainAgain=!0))}function jv(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 Js(e,t){e.intents.delete(t),e.draining&&(e.drainAgain=!0)}function tp(e,t){let n=e.intents.get(t);n!==void 0&&(n.releasedAt=Date.now())}function Xs(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 np(e,t){return zv(e,t)?(e.baselinePending.add(t),!0):!1}function rp(e,t){e.baselinePending.delete(t),e.baseline.has(t)||e.baselineFailures.add(t),e.draining&&(e.drainAgain=!0)}function zv(e,t){return t.length>0&&!e.baseline.has(t)&&!e.baselinePending.has(t)&&!e.baselineFailures.has(t)}async function op(e,t,n){if(e.draining)return Zf(e);if(e.intents.size===0)return 0;e.draining=!0;try{do{e.drainAgain=!1;let r=await ge(t),o,i=async s=>dt(r.namespace,s)?!0:(o??(o=await ge(t,{fresh:!0})),dt(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))):(Xs(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 p=await $v(e,s,d,n);if(e.intents.get(s)!==d||d.revision!==l)continue;p&&(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 Zf(e)}async function $v(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 p=n.landed.find(h=>h.ref===c.ref);if(p===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(w=>w.ref===h.addedRef)?h.addedRef:void 0)??h.entries.map(w=>w.ref).find(w=>!n.landed.some(R=>R.hostRef===w));if(g===void 0){if(d())return!1;l();break}let b=h.entries.find(w=>w.ref===g),{alias:f,protocol:v,...x}=c;if(p={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(p),s=!0,d())return!1;continue}if(p.draft.value!==c.value){if(!(await r.replace(t,p.hostRef,c.value)).ok){if(d())return!1;l();break}if(p.draft={...p.draft,value:c.value},s=!0,d())return!1}if(p.draft.alias!==c.alias){let{alias:h,...m}=p.draft;if(!(await r.rename(t,p.hostRef,c.alias)).ok){if(d())return!1;l();break}if(p.draft={...m,...c.alias===void 0?{}:{alias:c.alias}},s=!0,d())return!1}}if(!a)for(let c of i){if(d())return!1;let p=n.landed.find(b=>b.ref===c.ref);if(p===void 0||p.draft.protocol===c.protocol)continue;if(!(await r.setProtocol(t,p.hostRef,c.protocol)).ok){if(d())return!1;l();break}let{protocol:m,...g}=p.draft;if(p.draft={...g,...c.protocol===void 0?{}:{protocol:c.protocol}},s=!0,d())return!1}if(!a)for(let c of[!0,!1]){for(let p of i){if(d())return!1;if(p.enabled!==c)continue;let h=n.landed.find(g=>g.ref===p.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>=Uv?(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 Zf(e){let t=0;for(let n of e.intents.values())n.releasedAt!==void 0&&(t+=1);return t}var Vv={openai:null,anthropic:null};function Yv(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 ip(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:Vv}),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(!Ht(s))return{ok:!1,error:t.t("keysAddIllegal")};let l=Yv(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,...p}=l;return i(s,{...p,...d===void 0?{}:{alias:d}})},replace:async(a,s,d)=>{let l=o(s);return l===void 0||!Ht(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,...p}=l;return i(s,{...p,...d===void 0?{}:{protocol:d}})},setEndpoints:async()=>n(),probe:async()=>n(),reveal:async(a,s)=>o(s)?.value}}var sp=require("react/jsx-runtime");function ap({host:e,store:t,api:n,t:r,routeIdLabels:o,staged:i,onChange:a}){let[s,d]=(0,nt.useState)(()=>Jr(e.current,o)),l=(0,nt.useRef)(s),c=(0,nt.useRef)(new Set),p=(0,nt.useRef)(!1),h=(0,nt.useMemo)(()=>ip(t,{t:r,onChange:m=>{a?.(m);let g=l.current;if(g.length===0){!p.current&&m.length>0&&(p.current=!0,console.info("[bre] deferred api keys: holding the list until the provider id is typed"));return}Ys(i,g,m)}}),[a,i,t,r]);return(0,nt.useEffect)(()=>{let m=ki(e.current);if(m===null)return;let g=()=>{d(Jr(e.current,o))};return m.addEventListener("input",g,!0),()=>{m.removeEventListener("input",g,!0)}},[e,o]),(0,nt.useEffect)(()=>{s.length>0&&Jv(n,i,s,c.current)},[n,i,s]),(0,nt.useEffect)(()=>{let m=l.current;m!==s&&(Js(i,m),l.current=s),t.drafts.length>0&&s.length>0&&Ys(i,s,t.drafts)},[s,i,t]),(0,nt.useEffect)(()=>()=>{tp(i,l.current)},[i]),(0,sp.jsx)(li,{route:s,t:r,client:h,draft:!0})}function Jv(e,t,n,r){r.has(n)||!np(t,n)||(r.add(n),(async()=>{try{let o=await ge(e);Xs(t,n,dt(o.namespace,n))}catch(o){rp(t,n),console.warn("[bre] deferred api keys: could not read the settings document for this route:",o)}})())}var Ti="data-bre-create-keys",Xv="bre-keys-host",Qv="data-bre-key-input",Ei="data-bre-region",sr=new WeakMap;function dp(e){let t=e.querySelector(`input[${Qv}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function lp(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 cp(e,t){if(e.closest(`[${Ti}]`)!==null){dr(e);return}let n=dp(e);if(n===void 0){dr(e);return}if(e.parentElement===null)return;Ge(e,fn,!0);let r=sr.get(e),o=lp(e);o===void 0&&(r!==void 0&&Zs(e,r),o=e.ownerDocument.createElement("div"),o.className=Xv,e.after(o)),we(o,Ti,"");let i=e.getAttribute(Ei);if(i===null?o.hasAttribute(Ei)&&o.removeAttribute(Ei):we(o,Ei,i),r!==void 0&&r.host===o)return;r!==void 0&&Zs(e,r);let a={drafts:Ht(n.value)?[{ref:"key-1",value:n.value,enabled:!0}]:[]},s=o,d=Qe(o,t.refreshed(()=>(0,Qs.createElement)(We,{fallbackText:t.t("keysPanelFailed")},(0,Qs.createElement)(ap,{host:{current:s},store:a,api:t.api,t:t.t,routeIdLabels:t.routeIdLabels,staged:t.staged,onChange:l=>{let c=dp(e);if(c===void 0||c.disabled)return;let p=l.find(h=>h.enabled)?.value??"";c.value!==p&&Ur(c,p)}}))),{sync:!0});sr.set(e,{host:o,mount:d})}function Zs(e,t){sr.delete(e),Oe(t.mount)}function dr(e){Ge(e,fn,!1);let t=sr.get(e);t!==void 0&&Zs(e,t),lp(e)?.remove()}function up(){for(let e of Array.from(document.querySelectorAll(`[${Ti}]`))){let t=e.previousElementSibling;t instanceof HTMLElement&&sr.has(t)?dr(t):e.remove()}}var td="bre-create-host",ed="bre-add-mode-picker",Zv='[class*="addCard"]',ew='[class*="addPanel"]',tw='[class*="addModes"]',fp="-custom-panel",nw="-custom";function gp(){return{hosts:new Map}}function nd(e,t,n){if(!e.isConnected)return;let r=new Set;for(let o of Array.from(e.querySelectorAll(Zv)))if(o.isConnected)try{rw(o,t,n),r.add(o)}catch(i){Si(o,n);for(let a of rd(o))try{dr(a)}catch{}hp(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 rw(e,t,n){let r=pp(e,fp);(r===void 0||r.hidden)&&(dw(e,()=>As(e)),r=pp(e,fp),r===void 0||r.hidden)||(e.getAttribute("data-bre-add-card")!=="1"&&e.setAttribute("data-bre-add-card","1"),cw(e,r,t,n),aw(e),sw(r,t),hp(e,!0))}var ow=".field, label",iw=".bre-keys-host, .bre-keys, .bre-create-host";function rd(e){let t=[],n=e.querySelectorAll('input[type="password"], input[data-bre-key-input]');for(let r of Array.from(n)){if(r.closest(iw)!==null)continue;let o=r.closest(ow)??r.parentElement;o!==null&&!t.includes(o)&&t.push(o)}return t}function aw(e){for(let t of rd(e))try{mf(t)}catch(n){console.warn("[bre] add provider card: could not mark a key field:",n)}}function sw(e,t){for(let n of rd(e))try{cp(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 hp(e,t){let n=bp(e);n!==void 0&&Ge(n,ed,t)}function pp(e,t){for(let n of Array.from(e.querySelectorAll(ew)))if(n.id.endsWith(t))return n}function bp(e){let t=e.querySelector(tw);if(t!==null){for(let n of Array.from(t.children))if(n instanceof HTMLElement&&n.getAttribute("role")==="tablist")return n}}function dw(e,t){let n=bp(e);if(n!==void 0){for(let r of Array.from(n.querySelectorAll('[role="tab"]')))if(r.id.endsWith(nw)){if(r.disabled)return;r.getAttribute("aria-selected")!=="true"&&(t(),r.click());return}}}function lw(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.classList.contains(td))return t}function cw(e,t,n,r){let o=r.hosts.get(e),i=lw(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=td,t.insertBefore(a,t.firstChild),As(e);let s=Qe(a,n.refreshed(()=>(0,mp.createElement)(Qf,{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),Oe(n.mount))}function yp(e){for(let t of Array.from(e.hosts.keys()))Si(t,e);for(let t of Array.from(document.querySelectorAll(`.${td}`)))t.remove();for(let t of Array.from(document.querySelectorAll(`.${ed}`)))Ge(t,ed,!1);for(let t of Array.from(document.querySelectorAll(`.${mn}`)))Qn(t);up()}var Qr="data-bre-row-provider",vp="{provider}",uw=["rowCard","setupCard"];function wp(){return Bo()}function rt(e){for(let t of uw)for(let n of Array.from(e.querySelectorAll(`[class*="${t}"]`))){let r=n.parentElement;if(!(r===null||r.tagName!=="UL")&&Je(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 fw(e){let t=e.indexOf(vp);if(!(t<0))return{prefix:e.slice(0,t),suffix:e.slice(t+vp.length)}}function pw(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 mw='[class*="rowCard"], [class*="setupCard"], [class*="addCard"]';function gw(e){let t=e.closest(mw);for(let n=e;n!==null&&n!==t;n=n.parentElement)if(n.matches('[data-plugin], [class*="bre-"]'))return!0;return!1}function ot(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=fw(r);if(o!==void 0)for(let i of Array.from(e.querySelectorAll("button[aria-label]"))){if(gw(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=pw(a.slice(o.prefix.length,a.length-o.suffix.length));if(s!==void 0)return s}}}function od(e){let t=e.getAttribute(Qr);return t===null||t.length===0?void 0:t}function hw(e){return Nr(e,od)}function xp(e,t,n,r=rt(e)){if(!e.isConnected||r===void 0)return;let o=t.labels();for(let i of Je(r)){let a=ot(i,o);if(a===void 0){i.removeAttribute(Qr);continue}od(i)!==a&&i.setAttribute(Qr,a)}Uo(e,r,bw(t),n)}function bw(e){return{rowOf:t=>{let n=t.closest("li");return n instanceof HTMLElement?n:void 0},idOf:od,labelOf:lr,order:t=>zd(t),commit:t=>{yo(hw(t))},seatOf:bn,seatDrags:!0,gripLabel:(t,n)=>e.t("providerReorderAria",{provider:lr(t)??n}),gripHint:()=>e.t("providerReorderHint")}}function kp(e){jo(e);let t=Array.from(document.querySelectorAll(`[${Qr}]`));Or(t);for(let n of t)n.removeAttribute(Qr)}var cr="data-bre-provider-switch",Mi="bre-row-disabled";function Tp(){return{switches:new WeakSet}}function Sp(e,t,n,r=rt(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=ot(i,o);if(a===void 0)continue;let s=bn(i);s!==void 0&&(yw(i,s,a,t,n),i.classList.toggle(Mi,!Nn(a)))}}function Mp(){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 yw(e,t,n,r,o){let i=t.querySelector(`[${cr}]`);if(i!==null){Ep(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),Ep(a,e,n,r),vw(a,e,o);let s=t.querySelector('[class*="rowActions"]');s===null?t.appendChild(a):s.insertBefore(a,s.firstChild)}function Ep(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 vw(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);Vd(o,i),e.setAttribute("aria-checked",i?"true":"false"),t.classList.toggle(Mi,!i)}))}var ww=["balance","totalbalance","availablebalance","remainingbalance","creditbalance","balanceusd","totalavailable","available","remaining","credits","credit","amount","left","remain","remainingquota","quotaremaining","remainquota","availablequota","points"],xw=new Map(ww.map((e,t)=>[e,t])),GT=(xw.get("totalavailable")??0)+.5;var kw=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 Ew(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 Ap(e){let t=Ew(e.amount),n=e.currency?.trim()??"";if(n.length===0)return t;let r=kw.get(n.toUpperCase());return r!==void 0?`${r}${t}`:`${t} ${n}`}async function Tw(e){try{let t=await fetch(`${Od}?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:Tw};var Pt="data-bre-provider-balance",Sw="data-bre-provider-switch",Ai="data-bre-provider-balance-refresh",Mw=["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 Hp=3;function id(e,t,n,r=rt(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=ot(i,o);if(a===void 0)continue;let s=bn(i);s!==void 0&&(Ip(s,a,t,n),Kp(s,a,t,n))}}function Np(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 Op(){for(let e of Array.from(document.querySelectorAll(`[${Pt}]`)))e.remove()}function Ip(e,t,n,r){let o=r.readings.get(t);if(o!==void 0){Pp(e,t,o,n,r);return}let i=r.errors.get(t);if(i!==void 0){Aw(e,t,i,n,r);return}qp(e)}function Pp(e,t,n,r,o){let i=Dp(e,t,r,o);_p(i,`${r.t("providerBalanceLabel")} ${Ap(n)}`,r.t("providerBalanceHint"),r),Fp(e,i)}function Aw(e,t,n,r,o){let i=Dp(e,t,r,o),a=n.length>0?n:r.t("providerBalanceHint");_p(i,r.t("providerBalanceUnavailable"),a,r),Fp(e,i)}function Dp(e,t,n,r){let o=e.querySelector(`[${Pt}]`);return o===null?(o=document.createElement("span"),o.className="bre-provider-balance",o.setAttribute(Pt,t)):o.getAttribute(Pt)!==t&&o.setAttribute(Pt,t),(o.querySelector(".bre-provider-balance-text")===null||o.querySelector(`[${Ai}]`)===null)&&(o.replaceChildren(),Lw(o,e,n,r)),o}function Lw(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(Ai,"1"),i.setAttribute("aria-label",n.t("providerBalanceRefresh")),i.title=n.t("providerBalanceRefresh"),i.append(fi("balance-refresh",Mw)),i.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation();let s=e.getAttribute(Pt);if(!(s===null||s.length===0)){if(r.inflight.has(s)){r.pending.add(s);return}r.requested.delete(s),Kp(t,s,n,r)}}),e.append(o,i)}function _p(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(`[${Ai}]`);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 Cp(e,t,n){let r=e.querySelector(`[${Pt}]`);if(r===null||r.getAttribute(Pt)!==t)return;let o=r.querySelector(`[${Ai}]`);o!==null&&(o.classList.toggle("is-spinning",n),n?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))}function Fp(e,t){let n=e.querySelector(`[${Sw}]`);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 qp(e){for(let t of Array.from(e.querySelectorAll(`[${Pt}]`)))t.remove()}function Kp(e,t,n,r){r.requested.has(t)||r.inflight.has(t)||(r.requested.add(t),Bp(e,t,n,r))}function Bp(e,t,n,r){if(r.inflight.size>=Hp){r.queued.some(o=>o.route===t)||r.queued.push({head:e,route:t});return}Wp(e,t,n,r)}function Cw(e,t){for(;t.inflight.size<Hp&&t.queued.length>0;){let n=t.queued.shift();if(n===void 0)return;Wp(n.head,n.route,e,t)}}function Wp(e,t,n,r){r.inflight.add(t),Cp(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&&Pp(e,t,a,n,r);return}if(i.ok&&i.configured===!1){r.readings.delete(t),r.errors.delete(t),e.isConnected&&qp(e);return}i.configured===!0&&r.errors.set(t,i.error??""),e.isConnected&&Ip(e,t,n,r)}).catch(()=>{}).finally(()=>{r.inflight.delete(t),Cp(e,t,!1),e.isConnected||n.repaint?.(),r.pending.delete(t)&&(r.requested.delete(t),Bp(e,t,n,r)),Cw(n,r)})}function Gp(){return{requested:new Set,pending:[],running:new Set,visible:!1}}var Rw=2;function Up(e){for(;e.visible&&e.running.size<Rw;){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),Up(e)})}}function ad(e,t,n,r=rt(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=ot(a,i);s===void 0||n.requested.has(s)||(n.requested.add(s),n.running.has(s)||n.pending.push({route:s,client:o}))}Up(n)}var Li="data-bre-provider-delete",jp='[class*="rowActions"]',zp='[class*="dangerButton"]',Hw="bre-provider-delete";function $p(e,t,n=rt(e)){if(!e.isConnected||n===void 0)return;let r=t.labels(),o=Nw(n)??t.t("providerRemoveDisabled");for(let i of Array.from(n.children)){if(!(i instanceof HTMLElement))continue;let a=ot(i,r);if(a===void 0)continue;let s=bn(i);if(s===void 0)continue;let d=s.querySelector(jp);if(d===null)continue;let l=d.querySelector(`[${Li}]`);if(d.querySelector(zp)!==null){l!==null&&l.remove();continue}let c=l??Ow();d.lastElementChild!==c&&d.appendChild(c),Iw(c,a,o,t.t("providerRemoveLocked",{provider:lr(i)??a}))}}function Vp(){for(let e of Array.from(document.querySelectorAll(`[${Li}]`)))e.remove()}function Nw(e){let n=e.querySelector(`${jp} ${zp}`)?.textContent?.trim()??"";return n.length>0?n:void 0}function Ow(){let e=document.createElement("button");return e.className=Hw,e.setAttribute("type","button"),e.setAttribute("disabled",""),e}function Iw(e,t,n,r){e.getAttribute(Li)!==t&&e.setAttribute(Li,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",Pw="bre-provider-disabled-seat",Yp="bre-provider-disabled-group",sd="bre-row-folded",dd="bre-row-hidden";function Jp(){return{expanded:!1}}function Xp(e,t,n,r=rt(e)){if(!e.isConnected||r===void 0)return;let o=Zp(r,t.labels()),i=o.filter(l=>!l.enabled).length,a=em(r);if(i===0){a!==void 0&&a.remove(),ld(o,n);return}let s=a??Dw(r,t,n);(s.parentElement!==r||r.lastElementChild!==s)&&r.append(s),ld(o,n);let d=tm(s);d!==void 0&&nm(d,i,t,n)}function Qp(){for(let e of Array.from(document.querySelectorAll(`[${Ci}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`.${dd}, .${sd}`)))e.classList.remove(dd,sd)}function Zp(e,t){let n=[];for(let r of Array.from(e.children)){if(!(r instanceof HTMLElement)||r.getAttribute(Ci)!==null)continue;let o=ot(r,t);o!==void 0&&n.push({row:r,id:o,enabled:Nn(o)})}return n}function ld(e,t){for(let n of e){let r=!n.enabled;n.row.classList.toggle(sd,r),n.row.classList.toggle(dd,r&&!t.expanded)}}function em(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.getAttribute(Ci)!==null)return t}function tm(e){return e.querySelector(`button.${Yp}`)??void 0}function Dw(e,t,n){let r=document.createElement("li");r.className=Pw,r.setAttribute(Ci,"");let o=document.createElement("button");return o.className=Yp,o.setAttribute("type","button"),o.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),n.expanded=!n.expanded,_w(e,t,n)}),r.appendChild(o),e.append(r),r}function _w(e,t,n){let r=Zp(e,t.labels());ld(r,n);let o=em(e);if(o===void 0)return;let i=r.filter(s=>!s.enabled).length;if(i===0){o.remove();return}let a=tm(o);a!==void 0&&nm(a,i,t,n)}function nm(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",Zr="bre-model-grid";function om(){return Bo()}function ud(e){let t=[];for(let n of Array.from(e.querySelectorAll('[class*="modelList"]')))Je(n).filter(o=>o.matches('[class*="modelEntry"]')).length!==0&&t.push(n);return t}function im(e){for(let t of e){if(t.type!=="childList")continue;let n=t.target;if(n instanceof HTMLElement&&n.matches('[class*="modelList"]')&&Je(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(yn);return t===null||t.length===0?void 0:t}function cd(e,t){let n=e.closest("li");if(n!==null)return ot(n,t.labels())}function rm(e,t){let n=Ze(e,t.labels().modelName);return n.length>0?n:Ri(e)}function Fw(e,t){return{rowOf:n=>{let r=n.closest('[class*="modelEntry"]');return r instanceof HTMLElement?r:void 0},idOf:Ri,labelOf:n=>rm(n,t),order:n=>{let r=cd(e,t);return r===void 0?n:nl(r,n)},commit:n=>{let r=cd(n,t);r!==void 0&&Zd(r,Nr(n,Ri))},seatOf:n=>n.querySelector('[class*="modelRow"]')??void 0,seatDrags:!1,gripLabel:(n,r)=>t.t("modelReorderAria",{model:rm(n,t)??r}),gripHint:()=>t.t("modelReorderHint"),decorate:(n,r)=>{r.classList.add(Zr)}}}function am(e,t,n,r=ud(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(`[${yn}]`));Or(a);for(let s of a)s.removeAttribute(yn);continue}if(cd(i,t)!==void 0){for(let a of Je(i)){let s=Ze(a,o.modelId);if(s.length===0){a.removeAttribute(yn);continue}Ri(a)!==s&&a.setAttribute(yn,s)}Uo(e,i,Fw(i,t),n)}}}function sm(e){jo(e);for(let n of Array.from(document.querySelectorAll(`.${Zr}`)))n.classList.remove(Zr);let t=Array.from(document.querySelectorAll(`[${yn}]`));Or(t);for(let n of t)n.removeAttribute(yn)}var Ct=require("react");async function qw(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 Kw(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 qw(n)}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}}var fr,ur=0,Bw=0;var fd=new Set;function dm(e){return fd.add(e),()=>{fd.delete(e)}}function Hi(){return fr}function lm(){vn()}function Ww(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(aa,{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=Ww(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 cm(e){fr=void 0,ur+=1;let t=await Kw(aa,{op:"save",...e});if(fr=void 0,ur+=1,!t.ok)return{ok:!1,error:t.error};Bw+=1;for(let n of fd)try{n()}catch{}return{ok:!0,data:void 0}}var Gw=["\u6A21\u578B","Models","models"],fm='[class*="rowCard"], [class*="setupCard"], [class*="addCard"]',Uw='h1,h2,h3,h4,h5,h6,[role="heading"]',jw=/title|heading/i,zw='nav, button, [role="menu"], [role="menuitem"], [class*="rowName"], [class*="rowCard"]',$w=4;function Vw(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 Yw(e,t){for(let n=e;n!==null;n=n.parentElement){if(n.matches(Uw)||jw.test(String(n.className??"")))return n;if(n===t)break}return null}function Jw(e,t){for(let n of Gw)for(let r of e.querySelectorAll("*")){if(!Vw(r,n)||r.closest(zw)!==null||(r.compareDocumentPosition(t)&$w)===0)continue;let o=Yw(r,e);if(o!==null)return o}return null}var pd;function pm(e){let t=pd;if(t!==void 0&&t.root===e&&t.row.isConnected)return t.row;let n=e.querySelector(fm);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=Jw(o,n);if(i!==null){let a=Xw(i,o);return a!==null&&(pd={root:e,row:a}),a}}return null}function Xw(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(fm)!==null?n:r;n=r,r=r.parentElement}return r===t?n:null}var eo="bre-config-host",gd="bre-config-title-line",md={display:"flex",alignItems:"center"},Ni=new WeakMap;function um(e){e.classList.add(gd),Ni.has(e)||Ni.set(e,{display:e.style.display,alignItems:e.style.alignItems}),e.style.display=md.display,e.style.alignItems=md.alignItems}function Qw(e){return e.classList.contains(gd)&&e.style.display===md.display}function mm(e){e.classList.remove(gd);let t=Ni.get(e);Ni.delete(e),e.style.display=t?.display??"",e.style.alignItems=t?.alignItems??""}function gm(){return{mounts:new Map}}function hm(e,t,n){let r=n.mounts.get(e),o=e.querySelector(`:scope > .${eo}`);if(o!==null&&r!==void 0&&r.wrapper===o){Qw(e)||um(e);return}bm(e,n),o?.remove(),um(e);let i=e.ownerDocument.createElement("div");i.className=eo,e.appendChild(i);let a=Qe(i,(0,Ct.createElement)(ex,{t:t.t,onOpen:t.onOpen}),{sync:!0});n.mounts.set(e,a)}function bm(e,t){mm(e);let n=t.mounts.get(e);n!==void 0&&(t.mounts.delete(e),Oe(n))}function ym(e){for(let t of Array.from(e.mounts.keys()))bm(t,e);for(let t of Array.from(document.querySelectorAll(`.${eo}`))){let n=t.parentElement;n!==null&&mm(n),t.remove()}pd=void 0}function Zw(){return(0,Ct.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,Ct.createElement)("path",{d:"M4 6h8m4 0h4M4 12h2m4 0h10M4 18h10m4 0h2"}),(0,Ct.createElement)("circle",{cx:14,cy:6,r:2}),(0,Ct.createElement)("circle",{cx:8,cy:12,r:2}),(0,Ct.createElement)("circle",{cx:16,cy:18,r:2}))}function ex(e){return(0,Ct.useEffect)(()=>{lm()},[]),(0,Ct.createElement)("button",{className:"bre-config-btn",type:"button",title:e.t("configButtonHint"),"aria-label":e.t("configButton"),onClick:()=>e.onOpen()},Zw())}var tx="settings.models",it={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 xm(e){let{ctx:t,api:n,t:r,onIdle:o,refreshed:i}=e,a=()=>{let B=t.locale.bind(tx),V=te=>{let pe=[];for(let ke of te){let me=B(ke);me!==ke&&me.trim()!==""&&!pe.includes(me)&&pe.push(me)}return pe.length===0?te:[...pe,...te.filter(ke=>!pe.includes(ke))]};return{capacity:V(it.capacity),modelId:V(it.modelId),modelName:V(it.modelName),routeId:V(it.routeId),baseUrl:V(it.baseUrl),apiProtocol:V(it.apiProtocol),apply:V(it.apply),cancel:V(it.cancel),editProvider:V(it.editProvider),inputImage:V(it.inputImage),contextWindow:V(it.contextWindow),maxOutput:V(it.maxOutput),addModel:V(it.addModel)}},s=120,d=1e3,l=pu(),c=wp(),p={t:r,labels:a},h=Tp(),m={t:r,labels:a},g=Rp(),b={t:r,labels:a,repaint:()=>Z()},f=Gp(),v={labels:a,client:Ue},x={t:r,labels:a},w=Jp(),R={t:r,labels:a},F=om(),re={t:r,labels:a},j=kf(),T={t:r},N=gp(),z=gm(),M=zf(),y=ep(),A={t:r,api:n,routeIdLabels:()=>a().routeId,staged:M,stagedKeys:y,refreshed:i},C,I,D,H,$=B=>{for(let V of B)for(let te of Array.from(V.addedNodes)){if(!(te instanceof HTMLElement))continue;let pe=te.matches('[class*="modelAdvanced"]')?[te]:Array.from(te.querySelectorAll('[class*="modelAdvanced"]'));for(let ke of pe)Ss(ke)}},Q=!1,oe={api:n,describeNamespace:B=>ge(n,B),t:r,labels:a,onIdle:o,onBackoff:B=>{se(B)},onPendingChanged:()=>{Z()},mount(B,V){let te=document.createElement("div");te.className="bre-effort-slot",te.dataset.plugin=Ee,B.appendChild(te);let pe=(0,wm.createRoot)(te),ke=me=>{pe.render((0,hd.createElement)(We,{fallbackText:r("renderFailed"),children:i(()=>(0,hd.createElement)(_o,me))}))};return(0,vm.flushSync)(()=>{ke(V)}),{unmount:()=>{try{pe.unmount()}finally{te.remove()}},render:ke}}},ae=0;function se(B){if(Q)return;let V=Date.now()+B;I!==void 0&&V>=ae||(I!==void 0&&window.clearTimeout(I),ae=V,I=window.setTimeout(()=>{I=void 0,ae=0,Z()},B))}let ue=()=>{let B=yt(),V=rt(B);if(V===void 0){id(B,b,g,void 0),ad(B,v,f,void 0);return}if(xp(B,p,c,V),Sp(B,m,h,V),id(B,b,g,V),ad(B,v,f,V),$p(B,x,V),Xp(B,R,w,V),am(B,re,F,ud(B)),e.configSeat!==void 0){let te=pm(B);te!==null&&hm(te,{t:e.configSeat.t,onOpen:e.configSeat.onOpen},z)}Gs(),Hf(B)},fe=(B,V)=>{try{V()}catch(te){console.error(`[bre] ${B} failed:`,te)}};function Z(){Q||C!==void 0||(C=window.setTimeout(()=>{C=void 0,fe("composer mutation",()=>{H?.()}),fe("editor reconcile",()=>{Cs(yt(),oe,l)}),fe("add-card reconcile",()=>{nd(yt(),A,N)}),fe("editor tabs reconcile",()=>{qs(yt(),T,j)}),fe("dom decorations",()=>{ue()}),Jf(M,n).then(B=>{B>0&&se(d)}),op(y,n,Ue).then(B=>{B>0&&se(d)})},s))}let he=B=>{let te=B.detail?.route;typeof te!="string"||te.length===0||(Np(g,te),Z())},Me=B=>{if(Q||D!==void 0)return;H=B,fe("models page startup",()=>{B(),ue()}),Iu();let V=(te,pe)=>{B(),pe&&(fe("editor reconcile",()=>{Cs(yt(),oe,l)}),nd(yt(),A,N),qs(yt(),T,j),ue(),im(te)&&qu(yt()))};D=new MutationObserver(te=>{let pe=Uu(te);fe("models mutation",()=>{V(te,pe)}),pe&&(fe("early reasoning hide",()=>{$(te)}),Z())}),D.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden"]}),document.addEventListener(Tr,he),Z()},Ce=()=>{Q=!0,C!==void 0&&(window.clearTimeout(C),C=void 0),I!==void 0&&(window.clearTimeout(I),I=void 0),document.removeEventListener(Tr,he),D?.disconnect(),D=void 0};return{state:l,labels:a,start:Me,stopObserver:Ce,teardown:()=>{if(!l.disposed){Ce(),l.disposed=!0,Au(),uu(l,oe);for(let[B,V]of l.mounted)_r(B),V.editor.unmount();l.mounted.clear(),kp(c),Mp(),Op(),Vp(),Qp(),nc(),ym(z),Nf(),Kf(),sm(F),yp(N),Mf(),tu(),Fu()}},flushOnUnload:()=>{fu(l,oe)},schedule:Z}}var nx=1500,rx=2,ox=8,ix=6e4;function km(e,t={}){let n=t.delayMs??nx,r=Math.max(1,t.concurrency??rx),o=Math.max(1,t.limit??ox),i=t.minAgeMs??ix,s=(t.now??Date.now)(),d=Oc().filter(m=>s-m.savedAt>=i).slice(0,o).map(m=>m.route),l=!1,c=0,p=()=>{for(;!l&&c<r;){let m=d.shift();if(m===void 0)return;c+=1,Promise.resolve().then(()=>e.list(m,{preferCache:!0})).catch(()=>{}).finally(()=>{c-=1,p()})}},h=setTimeout(()=>{l||p()},n);return()=>{l=!0,clearTimeout(h)}}var Tm=e=>`?route=${encodeURIComponent(e)}`;async function Sm(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 bd(e){try{let t=await fetch(`${na}${Tm(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 Sm(t)}}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}}function Mm(e,t,n){let r=new AbortController,o=!1;return{done:(async()=>{let a;try{let s=await fetch(`${na}${Tm(e)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({model:t}),signal:r.signal});if(!s.ok)return{ok:!1,error:await Sm(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:m}=await d.read();if(h)break;c+=l.decode(m,{stream:!0});let g=c.indexOf(`
5389
- `);for(;g>=0;){let b=c.slice(0,g).trim();if(c=c.slice(g+1),b.length>0){let f=Em(b);f!==void 0&&(n(f),f.type==="result"?a={ok:!0,record:f.record}:f.type==="error"&&(a={ok:!1,error:f.error}))}g=c.indexOf(`
5390
- `)}}let p=c.trim();if(p.length>0){let h=Em(p);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 Em(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 ax=3,sx=2,dx=15e3,lx=/\b429\b|rate.?limit|too many requests/i,yd=new Map;function cx(e){return yd.get(e)??{run:(t,n,r)=>Mm(t,n,r)}}var vd=class{constructor(t,n=sx,r=dx){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),yd.delete(this.route))}setSender(t){yd.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=cx(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,ax)),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{lx.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 Am(e,t){let n=Oi.get(e);return n===void 0&&(n=new vd(e,t?.concurrency,t?.backoffMs),Oi.set(e,n)),n}function Lm(){for(let e of[...Oi.values()])e.dispose()}function to(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 Cm(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=to(s,d);if(!(c===void 0||l===void 0))try{let p=l.directoryFor(c);return r(l,p),t!==void 0&&t.sessionId===c&&t.directory===p||(n.has(p)||n.set(p,{sessionId:c,restore:Sl(p,{configuredEffort:e.configuredEffort})}),t={sessionId:c,directory:p}),p}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 Hm(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 ux(e,t){let n=t.codes[e];return typeof n=="boolean"?n:no.includes(e)?!0:void 0}function fx(e){return e===408||e===425||e===429||e>=500&&e<=599}var px=new Set(["user/message","developer/message","system/message","request/header","request/context","step/start","assistant/message","assistant/attempt","tool/call","tool/result"]);function mx(e){let t=!1;for(let n of e.turnEvents)if(n.type!=="turn/end"){if(n.type==="turn/start"){t=!0;continue}if(px.has(n.type))return!0}return t?!1:"unknown"}function gx(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 hx(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 bx(e){let t=e?.providerRetryAfterMs;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0}function Di(e,t=wn){let n=gx(e.turnEnd);if(mx(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=hx(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=ux(o,t);if(a===!0){let s=bx(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&&fx(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,wd=Object.freeze({waitSeconds:2,maxRetries:5,policy:wn}),yx="dsh-model-think-level.auto-continue.claim.",vx=10*6e4;function Om(e){try{return window.localStorage.getItem(e)}catch{return null}}function Nm(e,t,n,r){return typeof e!="number"||!Number.isFinite(e)?t:Math.min(r,Math.max(n,Math.trunc(e)))}function xd(e){let t=e!==null&&typeof e=="object"?e:{};return Object.freeze({waitSeconds:Nm(t.waitSeconds,wd.waitSeconds,Bi,Wi),maxRetries:Nm(t.maxRetries,wd.maxRetries,Gi,Ui),policy:Hm(t.policy)})}function ji(e){try{return xd(e===null?void 0:JSON.parse(e))}catch{return wd}}var ro=Om(qi)==="true",pr=ji(Om(Ki)),_i=new Set,Fi=new Set;function zi(e){for(let t of[...e])t()}function Yt(){return ro}function je(){return pr}function Im(e){if(ro!==e){ro=e;try{window.localStorage.setItem(qi,String(e))}catch{}zi(_i)}}function Pm(e,t){return JSON.stringify(e)===JSON.stringify(t)}function xn(e){let t=xd({...pr,...e});if(!Pm(pr,t)){pr=t;try{window.localStorage.setItem(Ki,JSON.stringify(t))}catch{}zi(Fi)}}function kd(e){ro!==e&&(ro=e,zi(_i))}function Ed(e){let t=xd(e);Pm(pr,t)||(pr=t,zi(Fi))}function $i(e){return _i.add(e),()=>{_i.delete(e)}}function Vi(e){return Fi.add(e),()=>{Fi.delete(e)}}function Dm(e,t){let n=`${yx}${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<vx)return!1}return window.localStorage.setItem(n,JSON.stringify(Date.now())),!0}catch{return!0}}var wx=1e3,xx=500,kx=600,_m=6e3,Ex=12e4,Tx=3e4,Sx=1440*60*1e3;function Fm(e){let{ctx:t,t:n}=e,r,o=new Map,i=!1,a=new Set,s=new Set,d=new Set,l,c=()=>{let u=r,S=je();return u===void 0?{sessionId:void 0,phase:"idle",consecutive:0,maxRetries:S.maxRetries,nextSendAt:0,waitMs:S.waitSeconds*1e3,detail:"",muted:!1}:{sessionId:u.sessionId,phase:u.phase,consecutive:u.consecutive,maxRetries:S.maxRetries,nextSendAt:u.nextSendAt,waitMs:u.waitMs,detail:u.detail,muted:s.has(u.sessionId)}},p=(u,S)=>u.sessionId===S.sessionId&&u.phase===S.phase&&u.consecutive===S.consecutive&&u.maxRetries===S.maxRetries&&u.nextSendAt===S.nextSendAt&&u.waitMs===S.waitMs&&u.detail===S.detail&&u.muted===S.muted,h=()=>{let u=c();if(!(l!==void 0&&p(l,u))){l=u;for(let S of[...d])S()}},m=()=>(l??(l=c()),l),g=u=>{u.sendTimer!==void 0&&(clearTimeout(u.sendTimer),a.delete(u.sendTimer),u.sendTimer=void 0),u.pendingSendTurnEndSeq=void 0,u.pendingSendScheduledAt=0,u.pendingRetryAfterMs=void 0},b=u=>{g(u),u.sendEpoch+=1,u.phase="idle",u.nextSendAt=0,u.waitMs=0,u.detail="",h()},f=(u,S)=>{let q=setTimeout(()=>{a.delete(q),u()},S);a.add(q)},v=u=>{let S=[];try{S=u.getSnapshot().entries??[]}catch{return[]}let q=[];for(let K of S)K.type!=="event"||K.event===void 0||q.push(K.event);return q},x=u=>v(u.eventSource),w=u=>{if(u.type!=="user/message")return!1;let S=u.data;if(typeof S!="object"||S===null)return!0;let q=S.message??S;if(typeof q!="object"||q===null)return!0;let K=q.source;if(typeof K!="object"||K===null)return!0;let k=K.kind;return k!=="model-selection"&&k!=="time-context"},R=u=>{let S=x(u),q=u.lastUserSeq;for(let K of S){if(K.type!=="user/message"||K.seq<=q||(u.lastUserSeq=Math.max(u.lastUserSeq,K.seq),!w(K)))continue;let k=F(u,K);u.lastAutoSentText=void 0,!k&&(s.delete(u.sessionId),u.consecutive=0,T(u),b(u))}},F=(u,S)=>{if(u.lastAutoSentText===void 0)return!1;let q=S.data;if(typeof q!="object"||q===null)return!1;let K=q.content??q.message?.content;if(!Array.isArray(K)||K.map(ee=>typeof ee=="object"&&ee!==null&&ee.type==="text"?ee.text:void 0).filter(ee=>typeof ee=="string").join("")!==u.lastAutoSentText)return!1;let _=typeof S.time=="number"?S.time:u.lastAutoSentAt;return Math.abs(_-u.lastAutoSentAt)<=Tx},re=(u,S)=>{let q=-1;for(let K=S-1;K>=0;K-=1)if(u[K].type==="turn/end"){q=K;break}return u.slice(q+1,S+1)},j=u=>{let S=je().waitSeconds*1e3;return u===void 0?S:Math.max(S,Math.min(u,Ex))},T=u=>{let S=u.sendTimer!==void 0||u.pendingSendTurnEndSeq!==void 0;g(u),S&&(u.nextSendAt=0,u.phase==="waiting"&&b(u))},N=()=>{try{return document.visibilityState==="hidden"}catch{return!1}},z=(u,S)=>{let q=setTimeout(()=>{a.delete(q),u.sendTimer=void 0,Q(u,n("autoContinueMessage"))},S);u.sendTimer=q,u.nextSendAt=Date.now()+S,u.phase="waiting",h(),a.add(q)},M=u=>{u.sendEpoch+=1,u.sendTimer!==void 0&&(clearTimeout(u.sendTimer),a.delete(u.sendTimer));let S=j(u.pendingRetryAfterMs);u.waitMs=S;let q=Math.max(0,S-(Date.now()-u.pendingSendScheduledAt));z(u,q)},y=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}},A=u=>{if(u.evalTimer!==void 0){u.evalDeadline=Date.now()+_m;return}u.evalDeadline=Date.now()+_m,C(u,xx)},C=(u,S)=>{i||o.get(u.sessionId)!==u||(u.evalTimer=setTimeout(()=>{u.evalTimer=void 0,$(u)},S),a.add(u.evalTimer))},I=u=>{if(u.historyReady)return;let S=y(u.session);if(S===void 0||!S.open)return;u.historyReady=!0;let q=ue(u.eventSource);u.lastHandledTurnEndSeq=Math.max(u.lastHandledTurnEndSeq,q??Le(u.eventSource,"turn/end"))},D=(u,S)=>{S.kind==="settled"?(u.consecutive=0,b(u)):(T(u),u.phase!=="exhausted"&&b(u))},H=u=>{if(!u.historyReady)return;let S=x(u),q=u.pendingSendTurnEndSeq;q!==void 0&&S.some(K=>K.seq>q&&(K.type==="turn/start"||K.type==="turn/end"))&&T(u);for(let K=S.length-1;K>=0;K-=1){let k=S[K];if(k.type!=="turn/end")continue;if(k.seq<=u.lastHandledTurnEndSeq)return;let _=Di({turnEnd:k,turnEvents:re(S,K)},je().policy);if(_.kind!=="continue"){u.lastHandledTurnEndSeq=k.seq,D(u,_);return}let ee=y(u.session);ee!==void 0&&!ee.running&&A(u);return}},$=u=>{if(i||o.get(u.sessionId)!==u||!Yt()||s.has(u.sessionId))return;let S=y(u.session);if(!u.historyReady||S===void 0||!S.open||S.subagent||S.running||S.pending>0)return;let q=x(u),K=-1;for(let le=q.length-1;le>=0;le-=1){let be=q[le];if(be.type==="turn/end"&&be.seq>u.lastHandledTurnEndSeq){K=le;break}}if(K<0){Date.now()<u.evalDeadline&&C(u,kx);return}let k=q[K];if(u.lastHandledTurnEndSeq=k.seq,R(u),q.some(le=>le.seq>k.seq&&(w(le)||le.type==="turn/start")))return;let _=Di({turnEnd:k,turnEvents:re(q,K)},je().policy);if(_.kind!=="continue"){D(u,_);return}let ee=je().maxRetries;if(u.consecutive>=ee){g(u),u.sendEpoch+=1,console.info(`[dsh-model-think-level] auto-continue: streak cap (${ee}) reached, standing down (${_.detail})`),u.phase="exhausted",u.nextSendAt=0,u.detail=_.detail,h();return}Dm(u.sessionId,k.seq)&&(u.pendingSendTurnEndSeq=k.seq,u.pendingSendScheduledAt=Date.now(),u.pendingRetryAfterMs=_.waitMs,u.detail=_.detail,M(u))},Q=async(u,S)=>{if(i||o.get(u.sessionId)!==u)return;R(u);let q=u.pendingSendTurnEndSeq;u.pendingSendTurnEndSeq=void 0;let K=()=>{u.phase==="waiting"&&b(u)};if(q===void 0||q!==u.lastHandledTurnEndSeq){K();return}if(!Yt()||s.has(u.sessionId)||u.consecutive>=je().maxRetries){K();return}let k=y(u.session);if(k===void 0||!k.open||k.subagent||k.running||k.pending>0){K();return}if(x(u).some(be=>be.seq>q&&(w(be)||be.type==="turn/start"||be.type==="turn/end"))){K();return}g(u);let ee=++u.sendEpoch;u.lastAutoSentAt=Date.now(),u.lastAutoSentText=S,u.consecutive+=1,u.phase="sent",u.nextSendAt=0,h();let le=()=>!i&&o.get(u.sessionId)===u&&u.sendEpoch===ee;if(le())try{let be=await u.session.prompt([{type:"text",text:S}],"queue");if(!le())return;be?.ok!==!0&&(u.lastAutoSentText=void 0,u.phase=u.consecutive>=je().maxRetries?"exhausted":"idle",h(),console.warn(`[dsh-model-think-level] auto-continue: prompt refused ${oe(be)}`))}catch(be){if(!le())return;u.lastAutoSentText=void 0,u.phase=u.consecutive>=je().maxRetries?"exhausted":"idle",h(),console.warn("[dsh-model-think-level] auto-continue: prompt failed:",be)}},oe=u=>{let S=u?.error;if(S===void 0)return"without an error";let q=typeof S.code=="string"?S.code:"unknown",K=typeof S.message=="string"?S.message:"";return K.length>0?`${q}: ${K}`:q},ae=u=>{let S=y(u.session);S!==void 0&&(I(u),(!S.open||S.subagent||S.running||S.pending>0)&&T(u),S.pending>0&&(u.lastHandledTurnEndSeq=Math.max(u.lastHandledTurnEndSeq,Le(u.eventSource,"turn/end")),u.evalTimer!==void 0&&(clearTimeout(u.evalTimer),a.delete(u.evalTimer),u.evalTimer=void 0),u.evalDeadline=0),u.wasRunning&&!S.running&&A(u),u.wasRunning=S.running)},se=u=>{let S=[];for(let q of v(u))q.type==="turn/end"&&S.push(q.seq);return S.length<2?0:(S.sort((q,K)=>q-K),S[S.length-2])},ue=u=>{let S=v(u),q=-1;for(let _=S.length-1;_>=0;_-=1)if(S[_].type==="turn/end"){q=_;break}if(q<0)return;let K=S[q],k=typeof K.time=="number"?K.time:Date.now();if(!(Date.now()-k>Sx)&&!S.some(_=>_.seq>K.seq&&(w(_)||_.type==="turn/start")))return Di({turnEnd:K,turnEvents:re(S,q)},je().policy).kind==="continue"?se(u):void 0},fe=u=>{if(i||o.get(u.sessionId)!==u||u.evalTimer!==void 0||!Yt()||s.has(u.sessionId)||!u.historyReady)return;let S=y(u.session);if(S===void 0||!S.open||S.subagent||S.running||S.pending>0)return;let q=x(u);for(let K=q.length-1;K>=0;K-=1){let k=q[K];if(k.type==="turn/end"&&k.seq>u.lastHandledTurnEndSeq){A(u);return}}},Z=u=>{for(let S of u.unsubs)try{S()}catch{}u.evalTimer!==void 0&&(clearTimeout(u.evalTimer),a.delete(u.evalTimer),u.evalTimer=void 0),u.sendTimer!==void 0&&(clearTimeout(u.sendTimer),a.delete(u.sendTimer),u.sendTimer=void 0),o.delete(u.sessionId),r===u&&(r=void 0),h()},he=()=>{for(let u of[...o.values()])Z(u);r=void 0,h()},Me=u=>{let S=o.get(u.sessionId);if(S!==void 0){if(S.session===u.session)return S;Z(S)}let q=y(u.session);if(q===void 0||q.subagent)return;let K=q.open?ue(u.eventSource):void 0,k={sessionId:u.sessionId,session:u.session,eventSource:u.eventSource,wasRunning:Ce(u.session),lastUserSeq:Le(u.eventSource,"user/message"),historyReady:q.open,lastHandledTurnEndSeq:q.open?K??Le(u.eventSource,"turn/end"):0,consecutive:0,phase:"idle",sendEpoch:0,nextSendAt:0,waitMs:0,detail:"",pendingSendTurnEndSeq:void 0,pendingSendScheduledAt:0,pendingRetryAfterMs:void 0,lastAutoSentAt:0,lastAutoSentText:void 0,unsubs:[],evalDeadline:0,evalTimer:void 0,sendTimer:void 0};o.set(k.sessionId,k);try{k.unsubs.push(u.session.subscribe(()=>ae(k)))}catch{Z(k);return}try{k.unsubs.push(u.eventSource.subscribe(()=>{R(k),I(k),H(k)}))}catch(_){Z(k),console.warn("[dsh-model-think-level] auto-continue: event source unusable:",_);return}return k},Ce=u=>{try{return u.getSnapshot().running===!0}catch{return!1}},Le=(u,S)=>{let q=0,K=[];try{K=u.getSnapshot().entries??[]}catch{return 0}for(let k of K)k.type!=="event"||k.event===void 0||k.event.type===S&&k.event.seq>q&&(q=k.event.seq);return q},J=()=>{if(i)return;let u=t.get?.("sessions"),S=t.get?.("uiSession"),q=to(u,S);if(q===void 0||u===void 0||typeof u.binding!="function"){r=void 0,h();return}let K;try{K=u.binding(q)}catch{K=void 0}if(K===void 0||K.session===void 0){r=void 0,h();return}if(r!==void 0&&r.sessionId===q&&r.session===K.session){fe(r),h();return}let k=Me(K);r=k,k!==void 0&&fe(k);for(let _ of[...o.values()])_!==r&&_.phase==="idle"&&(_.evalTimer!==void 0||_.evalDeadline>0||Z(_));h()},B=setInterval(J,wx);J();let V;try{V=t.on?.("connection/reset",()=>{he()})}catch{}let te=$i(()=>{let u=r;Yt()||u===void 0||(T(u),b(u),u.evalTimer!==void 0&&(clearTimeout(u.evalTimer),a.delete(u.evalTimer),u.evalTimer=void 0))}),pe=Vi(()=>{let u=r;h(),u?.pendingSendTurnEndSeq!==void 0&&(!Yt()||u.consecutive>=je().maxRetries?T(u):M(u))});return{status:m,subscribe:u=>(d.add(u),()=>{d.delete(u)}),stop:()=>{let u=r;u!==void 0&&(T(u),u.evalTimer!==void 0&&(clearTimeout(u.evalTimer),a.delete(u.evalTimer),u.evalTimer=void 0),u.evalDeadline=0,u.consecutive=0,s.add(u.sessionId),b(u))},reset:()=>{let u=r;u!==void 0&&(u.consecutive=0,s.delete(u.sessionId),b(u))},resumeNow:()=>{let u=r;u!==void 0&&u.pendingSendTurnEndSeq!==void 0&&(u.sendTimer!==void 0&&(clearTimeout(u.sendTimer),a.delete(u.sendTimer),u.sendTimer=void 0),Q(u,n("autoContinueMessage")))},dispose:()=>{i=!0,te(),pe(),V?.(),clearInterval(B),he(),d.clear();for(let u of a)clearTimeout(u);a.clear()}}}var Mx=[[/\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 Ax(e){let t=String(e??"");for(let[n,r]of Mx)t=t.replace(n,r);return t}function Lx(e,t,n){let r=Ax(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 Cx(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(Lx(s.error,t,d)))}return r}var Rx='[class*="turnErrorRow"]',Hx='code[class*="turnErrorCode"]',Td='[class*="turnErrorMessage"]',io="data-bre-error-detail",Km={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 qm(e,t){return(e.querySelector(t)?.textContent??"").trim()}function Nx(e){let t=e.querySelector(Td);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 Ox(e,t,n){if(t.length===0)return;let r=qm(e,Hx),o=qm(e,Td),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=Km[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 Ie(e,t,n){let r=document.createElement(e);return t!==void 0&&(r.className=t),n!==void 0&&(r.textContent=n),r}async function Ix(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 Bm(e){let{ctx:t,t:n}=e,r=[],o=!1,i,a=(y,A)=>{let C=Ie("button","bre-ed-copy",A);return C.type="button",C.addEventListener("click",()=>{Ix(y).then(I=>{I&&(C.textContent=n("errorDetailCopied"),window.setTimeout(()=>{C.textContent=A},1400))})}),C},s=(y,A,C={})=>{if(A===void 0||A.length===0)return null;let I=Ie("div","bre-ed-row");I.append(Ie("span","bre-ed-label",y));let D=["bre-ed-value"];return C.mono===!0&&D.push("bre-ed-mono"),C.muted===!0&&D.push("bre-ed-muted"),I.append(Ie("span",D.join(" "),A)),C.copy===!0&&I.append(a(A,n("errorDetailCopy"))),I},d=(y,A)=>{let C=Km[y];return C===void 0?`${A} \u2014 ${n("errorDetailUnwrapped")}`:A===C?`${A} \u2014 ${n("errorDetailFixedLabel")}`:C},l=()=>{let y=document.getElementById(oo);if(y instanceof HTMLDivElement)return y;let A=Ie("div","bre-ed-pop");return A.id=oo,A.setAttribute("role","dialog"),A.setAttribute("aria-label",n("errorDetailTitle")),document.body.append(A),A},c=()=>{let y=document.getElementById(oo);y!==null&&(y.style.display="none"),document.removeEventListener("pointerdown",p,!0),document.removeEventListener("keydown",h,!0),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c,!0)};function p(y){let A=document.getElementById(oo);A!==null&&(y.target instanceof Node&&A.contains(y.target)||y.target instanceof Element&&y.target.closest(`[${io}]`)!==null||c())}function h(y){y.key==="Escape"&&c()}let m=(y,A)=>{let C=A.getBoundingClientRect();y.style.visibility="hidden",y.style.left="0px",y.style.top="0px";let I=y.offsetWidth,D=y.offsetHeight,H=8;if(C.bottom<H||C.top>window.innerHeight-H){let oe=Math.max(H,(window.innerWidth-I)/2),ae=Math.max(H,(window.innerHeight-D)/2);y.style.left=`${Math.round(oe)}px`,y.style.top=`${Math.round(ae)}px`,y.style.visibility="";return}let $=Math.min(Math.max(H,C.left),Math.max(H,window.innerWidth-I-H)),Q=C.bottom+H;Q+D>window.innerHeight-H&&(Q=Math.max(H,C.top-D-H)),y.style.left=`${Math.round($)}px`,y.style.top=`${Math.round(Q)}px`,y.style.visibility=""},g=(y,A,C)=>{let I=l();I.textContent="";let D=Ie("div","bre-ed-head");D.append(Ie("span","bre-ed-dot")),D.append(Ie("span","bre-ed-title",n("errorDetailTitle")));let H=Ie("span","bre-ed-chips");y.http!==void 0&&H.append(Ie("code","bre-ed-chip",`HTTP ${y.http}`)),y.providerCode!==void 0&&H.append(Ie("code","bre-ed-chip bre-ed-chip-strong",y.providerCode)),D.append(H);let $=Ie("button","bre-ed-x","\xD7");$.type="button",$.setAttribute("aria-label",n("errorDetailClose")),$.addEventListener("click",()=>c()),D.append($),I.append(D);let Q=Ie("div","bre-ed-body"),oe=[s(n("errorDetailReason"),y.reason),s(n("errorDetailTrace"),y.traceId,{mono:!0,copy:!0}),s(n("errorDetailCode"),y.code,{mono:!0}),s(n("errorDetailShown"),d(y.code,C),{muted:!0})];for(let Z of oe)Z!==null&&Q.append(Z);I.append(Q);let ae=Ie("div","bre-ed-raw"),se=Ie("button","bre-ed-raw-toggle",`\u25B8 ${n("errorDetailRaw")}`);se.type="button";let ue=Ie("pre","bre-ed-pre",y.raw);ue.hidden=!0,se.addEventListener("click",()=>{ue.hidden=!ue.hidden,se.textContent=`${ue.hidden?"\u25B8":"\u25BE"} ${n("errorDetailRaw")}`}),ae.append(se,ue),I.append(ae);let fe=Ie("div","bre-ed-foot");fe.append(Ie("span","bre-ed-src",n("errorDetailSource"))),fe.append(a(y.raw,n("errorDetailCopyRaw"))),I.append(fe),I.style.display="block",m(I,A),document.addEventListener("pointerdown",p,!0),document.addEventListener("keydown",h,!0),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c,!0)},b=new Set,f=()=>{for(let y of b)if(y.isConnected)return!0;return b.clear(),!1},v=()=>{if(r.length===0&&!f())return;let y=document.querySelectorAll(Rx);if(y.length===0)return;let A=new Set,C=n("errorDetailButton");for(let I of y){let D=Ox(I,r,A);if(D===void 0)continue;A.add(Yi(D));let H=Nx(I),$=I.querySelector(Td)??I,Q=$.querySelector(`:scope > button[${io}]`);Q===null&&(Q=document.createElement("button"),Q.type="button",Q.className="bre-ed-view",Q.setAttribute(io,"1"),$.append(Q),b.add(Q)),Q.textContent!==C&&(Q.textContent=C),Q.onclick=oe=>{oe.preventDefault(),oe.stopPropagation(),g(D,Q,H)}}},x=()=>{i===void 0&&(i=window.setTimeout(()=>{i=void 0,v()},120))},w,R,F=(y,A)=>{if(o)return;let C=Cx(A,y);C.length===r.length&&C.every((D,H)=>Yi(D)===Yi(r[H]))||(r=C,x())},re=()=>{R?.(),R=void 0},j=y=>{let A=t.get?.("sessions"),C;try{C=A?.binding?.(y)}catch{C=void 0}let I=C?.eventSource;if(I!==void 0)try{F(y,I),R=I.subscribe(()=>{try{F(y,I)}catch{}})}catch{R=void 0}},T=()=>{if(o)return;let y=t.get?.("sessions"),A=t.get?.("uiSession"),C=to(y,A);C===w&&R!==void 0||(C!==w&&(re(),w=C,r=[],c(),x()),C!==void 0&&j(C))},N=window.setInterval(T,1e3);T();let z=new MutationObserver(x);z.observe(document.body,{childList:!0,subtree:!0});let M=window.setInterval(v,1500);return v(),{dispose:()=>{o=!0,window.clearInterval(N),window.clearInterval(M),i!==void 0&&window.clearTimeout(i),i=void 0,z.disconnect(),re(),w=void 0,r=[],c();for(let y of document.querySelectorAll(`[${io}]`))y.remove();b.clear(),document.getElementById(oo)?.remove()}}}var Ji="dsh-model-think-level.error-detail.enabled";function Px(e){try{return window.localStorage.getItem(e)}catch{return null}}var ao=Px(Ji)!=="false",Sd=new Set;function Wm(){for(let e of[...Sd])e()}function Xi(){return ao}function Gm(e){if(ao!==e){ao=e;try{window.localStorage.setItem(Ji,String(e))}catch{}Wm()}}function Md(e){ao!==e&&(ao=e,Wm())}function Qi(e){return Sd.add(e),()=>{Sd.delete(e)}}var Jt=require("react");var ne=require("react/jsx-runtime"),jm="[data-composer-dock]",Dx="[data-composer-stats]",_x="[data-composer-stat]",Fx="data-bre-autocontinue",Um=2*Math.PI*6;function qx(){let t=Array.from(document.querySelectorAll(jm)).filter(a=>a.isConnected&&a.getClientRects().length>0).at(-1);if(t!==void 0)return t;let n=document.querySelector(Dx);if(n!==null&&n.isConnected&&n.getClientRects().length>0)return n;let r=Array.from(document.querySelectorAll(_x)).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 Kx(e,t){return e!==void 0&&e.isConnected&&t.length===1&&e.parentElement===t[0]}function Zi(e){return(0,ne.jsx)("svg",{className:e.className,viewBox:"0 0 24 24","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:e.children})}function Bx(e){let t=Um*(1-Math.max(0,Math.min(1,e.ratio)));return(0,ne.jsx)("span",{className:"bre-ac-ring","aria-hidden":"true",children:(0,ne.jsxs)("svg",{viewBox:"0 0 16 16",children:[(0,ne.jsx)("circle",{className:"bre-ac-ring-track",cx:"8",cy:"8",r:"6"}),(0,ne.jsx)("circle",{className:"bre-ac-ring-fill",cx:"8",cy:"8",r:"6",strokeDasharray:Um,strokeDashoffset:t})]})})}function Wx(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 w=window.setInterval(()=>s(Date.now()),500);return()=>window.clearInterval(w)},[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=r.maxRetries,l=r.phase==="waiting"?r.consecutive+1:r.consecutive,c=Math.max(0,r.nextSendAt-a),p=Math.ceil(c/1e3),h=Math.max(1e3,r.waitMs),m=r.phase==="waiting"?Math.min(1,c/h):0,g=r.detail===""?void 0:n("autoContinueControllerDetail",{detail:r.detail}),b=(w,R)=>(0,ne.jsx)("button",{type:"button",role:"menuitem",className:"bre-ac-action",onClick:()=>{i(!1),R()},children:w},w),f=[];r.phase==="waiting"?(f.push(b(n("autoContinueControllerResume"),()=>t.resumeNow())),f.push(b(n("autoContinueControllerStop"),()=>t.stop()))):r.phase==="sent"&&f.push(b(n("autoContinueControllerStop"),()=>t.stop()));let v=r.phase==="waiting"?(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsx)(Bx,{ratio:m}),(0,ne.jsx)("span",{className:"bre-ac-text",children:n("autoContinueControllerWaiting")}),(0,ne.jsx)("span",{className:"bre-ac-num",children:n("autoContinueControllerSeconds",{seconds:p})}),(0,ne.jsx)("span",{className:"bre-ac-ratio",children:n("autoContinueControllerRatio",{n:l,max:d})}),(0,ne.jsx)(Zi,{className:"bre-ac-caret",children:(0,ne.jsx)("path",{d:"M6.5 9.5 12 15l5.5-5.5"})})]}):r.phase==="sent"?(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsx)(Zi,{className:"bre-ac-tick",children:(0,ne.jsx)("path",{d:"M4.8 12.5 9.6 17.3 19.2 6.9"})}),(0,ne.jsx)("span",{className:"bre-ac-text",children:n("autoContinueControllerSent")}),(0,ne.jsx)("span",{className:"bre-ac-ratio",children:n("autoContinueControllerRatio",{n:l,max:d})})]}):(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsxs)(Zi,{className:"bre-ac-tick",children:[(0,ne.jsx)("circle",{cx:"12",cy:"12",r:"8.2"}),(0,ne.jsx)("path",{d:"M12 7.6V12l3 1.9"})]}),(0,ne.jsx)("span",{className:"bre-ac-text",children:n("autoContinueControllerExhausted")}),(0,ne.jsx)("span",{className:"bre-ac-ratio",children:n("autoContinueControllerRatio",{n:d,max:d})})]}),x=o?(0,ne.jsxs)("div",{className:"bre-ac-pop",role:"menu",children:[(0,ne.jsxs)("div",{className:"bre-ac-pop-head",children:[(0,ne.jsx)("span",{className:"bre-ac-pop-title",children:n("autoContinueControllerPopTitle")}),(0,ne.jsx)("span",{className:"bre-ac-pop-badge",children:n("autoContinueControllerPopBadge",{n:l,max:d})})]}),(0,ne.jsx)("p",{className:"bre-ac-pop-desc",children:n("autoContinueControllerPopDesc",{seconds:p,max:d})}),f.length>0?(0,ne.jsx)("div",{className:"bre-ac-pop-actions",children:f}):void 0,(0,ne.jsxs)("div",{className:"bre-ac-pop-foot",children:[(0,ne.jsx)("button",{type:"button",className:"bre-ac-link",onClick:()=>{i(!1),e.onSettings()},children:n("autoContinueControllerSettings")}),(0,ne.jsx)("span",{className:"bre-ac-note",children:n("autoContinueControllerPopScope")})]})]}):void 0;return r.phase==="exhausted"?(0,ne.jsxs)("span",{className:"bre-ac",children:[(0,ne.jsxs)("span",{className:"bre-ac-group",children:[(0,ne.jsx)("span",{className:"bre-ac-chip bre-ac-chip-exhausted",title:g??n("autoContinueControllerAria"),children:v}),(0,ne.jsx)("button",{type:"button",className:"bre-ac-reset",onClick:()=>t.reset(),children:n("autoContinueControllerReset")}),(0,ne.jsx)("button",{type:"button",className:"bre-ac-more","aria-label":n("autoContinueControllerSettings"),onClick:()=>i(w=>!w),children:(0,ne.jsxs)(Zi,{className:"bre-ac-more-icon",children:[(0,ne.jsx)("circle",{cx:"5.5",cy:"12",r:"1.4",fill:"currentColor",stroke:"none"}),(0,ne.jsx)("circle",{cx:"12",cy:"12",r:"1.4",fill:"currentColor",stroke:"none"}),(0,ne.jsx)("circle",{cx:"18.5",cy:"12",r:"1.4",fill:"currentColor",stroke:"none"})]})})]}),x]}):(0,ne.jsxs)("span",{className:"bre-ac",children:[(0,ne.jsx)("button",{type:"button",className:`bre-ac-chip bre-ac-chip-${r.phase}`,"aria-label":n("autoContinueControllerAria"),"aria-expanded":o,title:g??n("autoContinueControllerAria"),onClick:()=>i(w=>!w),children:v}),x]})}function zm(e){let t,n,r=0,o=0,i=()=>{Oe(n),n=void 0,t?.remove(),t=void 0},a=()=>{if(Kx(t,document.querySelectorAll(jm)))return;let c=qx();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(Fx,""),c.append(t),n=Qe(t,(0,ne.jsx)(Wx,{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 wt=require("react");var Pe=require("react");var Dt=require("react/jsx-runtime");function $m(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 Vm({t:e,value:t,installed:n,disabled:r=!1,onChange:o}){let i=(0,Pe.useId)(),a=`${i}-title`,s=`${i}-hint`,d=e("historyCompatHint")+" "+e("historyCompatCost");return(0,Dt.jsxs)("div",{className:"bre-camouflage","data-plugin":Ee,"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 Ym(e){let[t,n]=(0,Pe.useState)(!1),[r,o]=(0,Pe.useState)(!1),[i,a]=(0,Pe.useState)(!0),[s,d]=(0,Pe.useState)(!0),l=(0,Pe.useRef)(!1),c=(0,Pe.useRef)(!1),p=(0,Pe.useRef)(!0);(0,Pe.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]),(0,Pe.useEffect)(()=>{if(e===""){d(!1);return}let b=!1;return d(!0),fetch(ia,{method:"GET"}).then(async f=>await f.json()).then(f=>{if(b||!p.current)return;let v=$m(f);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&&p.current&&d(!1)}),()=>{b=!0}},[e]);let h=(0,Pe.useCallback)(b=>{c.current=b,o(b)},[]),m=(0,Pe.useCallback)(()=>{c.current=l.current,o(l.current)},[]),g=(0,Pe.useCallback)(async()=>{if(e===""||c.current===l.current)return;let b=c.current,f=await fetch(ia,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({route:e,enabled:b})}),v=await f.json();if(!f.ok||v.ok!==!0)throw new Error("history-compat write rejected");let x=$m(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:m,commit:g}}var Xt=require("react/jsx-runtime");function Jm({route:e,api:t,t:n,onDismiss:r}){let o=js(e,n),i=Ym(e);return(0,Xt.jsx)(wi,{route:e,api:t,t:n,onDismiss:r,extras:(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Us,{t:n,value:o.value,installed:o.installed,disabled:o.loading,onChange:o.setValue}),(0,Xt.jsx)(Vm,{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 Y=require("react");function Xm(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 Gx=/^(gpt-|chatgpt-|o[134](-|$)|claude-)/;function Ux(e){let t=String(e??"").trim(),n=t.lastIndexOf("/");return n===-1?t:t.slice(n+1)}function Qm(e){let t=Ux(e).toLowerCase();return t.length>0&&Gx.test(t)}var Zm={running:new Map,queued:[]};function lo(e){return typeof e!="number"||!Number.isFinite(e)?"\u2014":`${Math.round(e*100)}%`}function jx(e){return!Number.isFinite(e)||e<=0?"\u2014":new Date(e).toLocaleString()}function eg(e){return typeof e!="number"||!Number.isFinite(e)||e<0?"\u2014":(Math.round(e/100)/10).toFixed(1)}function zx(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 tg({route:e,api:t,t:n,ctx:r,host:o}){let[i]=(0,Y.useState)(()=>Ef(o.current)),[a,s]=(0,Y.useState)([]),[d,l]=(0,Y.useState)(new Map),[c,p]=(0,Y.useState)(void 0),[h,m]=(0,Y.useState)(void 0),[g,b]=(0,Y.useState)(new Set),f=(0,Y.useCallback)(y=>{b(A=>{let C=new Set(A);return C.has(y)?C.delete(y):C.add(y),C})},[]),v=(0,Y.useMemo)(()=>i?void 0:Am(e),[i,e]),x=(0,Y.useSyncExternalStore)((0,Y.useCallback)(y=>v?.subscribe(y)??(()=>{}),[v]),(0,Y.useCallback)(()=>v?.getState()??Zm,[v]),(0,Y.useCallback)(()=>Zm,[]));(0,Y.useEffect)(()=>{if(v!==void 0)return v.onRecord(y=>{m(void 0),l(A=>{let C=new Map(A);return C.set(y.model,y),C})})},[v]),(0,Y.useEffect)(()=>{if(v!==void 0)return v.onFailure((y,A)=>{m({model:y,error:A})})},[v]);let w=(0,Y.useCallback)(async()=>{if(i)return;let A=(await ge(t)).namespace?.value?.providers,C=Dn(A,e).map(D=>D.id).filter(D=>typeof D=="string"&&D.length>0).filter(Qm);s(C.map(D=>({model:D})));let I=await bd(e);I.ok?(p(void 0),l(new Map(I.data.records.map(D=>[D.model,D])))):p(I.error)},[t,i,e]);if((0,Y.useEffect)(()=>{i||w()},[i,w]),(0,Y.useEffect)(()=>{if(!(i||r===void 0))return r.remote.$on("settings/document-updated",()=>{w()})},[i,r,w]),i)return null;let R=a.length,F=a.filter(y=>d.has(y.model)).length,re=a.filter(y=>d.get(y.model)?.status==="identified").length,j=a.filter(y=>d.get(y.model)?.status==="doubtful").length,T=a.filter(y=>d.get(y.model)?.status==="failed").length,N=x.running.size>0,z=x.running.size+x.queued.length,M=(0,Y.useMemo)(()=>Xm([...d.values()]),[d]);return(0,Y.createElement)("div",{className:"bre-fingerprint","data-bre-fingerprint":R>0?"ready":"none"},(0,Y.createElement)("div",{className:"bre-fp-head"},(0,Y.createElement)("span",{className:"bre-fp-title"},n("fpTitle")),(0,Y.createElement)("span",{className:"bre-fp-count"},n("fpCount",{count:R})),(0,Y.createElement)("span",{className:"bre-fp-summary",role:"status","aria-live":"polite"},N?n("fpRunning",{done:x.running.size,total:z}):F===0?n("fpSummaryNone"):n("fpSummary",{identified:re,doubtful:j,failed:T})),(0,Y.createElement)("span",{className:"grow"}),(0,Y.createElement)("button",{type:"button",className:"bre-fp-all",disabled:N||R===0,onClick:()=>{v?.checkAll(a.map(y=>y.model))}},n("fpDetectAll"))),(0,Y.createElement)("p",{className:"bre-fp-intro"},n("fpIntro")),c!==void 0?(0,Y.createElement)("p",{className:"bre-fp-error"},n("fpLoadFailed",{error:c})):null,h!==void 0?(0,Y.createElement)("p",{className:"bre-fp-error",role:"alert"},n("fpRunFailed",{error:`${h.model}: ${h.error}`})):null,(0,Y.createElement)("div",{className:"bre-fp-rows"},...a.map(y=>Vx(y,{t:n,runner:v,runnerState:x,records:d,route:e,expanded:g,estimate:M,onToggle:f}))))}function $x(e){return(0,Y.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,Y.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 Vx(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),p=o.queued.indexOf(e.model),h=c!==void 0,m=p>=0,g=a.has(e.model),b=h?{className:"is-running",text:n("fpStateRunning",{done:c,total:3})}:m?{className:"is-queued",text:n("fpQueued",{position:p+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)})},f=l===void 0?"fpDetect":l.status==="failed"?"fpRetry":"fpRetest";return(0,Y.createElement)("div",{className:"bre-fp-row",key:e.model,"data-bre-fp-open":g?"1":void 0},(0,Y.createElement)("div",{className:"bre-fp-row-head"},(0,Y.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)}},$x(g),(0,Y.createElement)("span",{className:"bre-fp-model"},e.model)),(0,Y.createElement)("span",{className:`bre-fp-badge ${b.className}`},b.text),(0,Y.createElement)("span",{className:"grow"}),(0,Y.createElement)("span",{className:"bre-fp-evidence"},l===void 0?zx(n,s):n("fpEvidence",{used:l.usedOutputs,total:3})),(0,Y.createElement)("button",{type:"button",className:"bre-fp-action",disabled:h||m,onClick:()=>{r?.check(e.model)}},n(f))),!g||l===void 0?null:l.status!=="failed"?Jx(l,n):Yx(l,n))}function ng(e,t){return e===void 0||e.length===0?null:(0,Y.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,Y.createElement)("span",{className:`bre-fp-chal${r}`,key:n.index},o)}))}function Yx(e,t){let n=e.challenges,r=n!==void 0&&n.length>0;return e.error===void 0&&!r?null:(0,Y.createElement)("div",{className:"bre-fp-body"},e.error===void 0?null:(0,Y.createElement)("p",{className:"bre-fp-error"},e.error),ng(n,t))}function Jx(e,t){let n=e.top??[],r=e.timing;return(0,Y.createElement)("div",{className:"bre-fp-body"},(0,Y.createElement)("div",{className:"bre-fp-family"},(0,Y.createElement)("span",{className:"bre-fp-k"},t("fpFamily")),(0,Y.createElement)("span",{className:"bre-fp-v"},`${e.familyPrediction??"\u2014"} \xB7 ${lo(e.familyProbability)}`),(0,Y.createElement)("span",{className:"bre-fp-k"},t("fpSimilarity")),(0,Y.createElement)("span",{className:"bre-fp-v"},lo(e.top?.[0]?.similarity)),(0,Y.createElement)("span",{className:"grow"}),(0,Y.createElement)("span",{className:"bre-fp-k"},t("fpCheckedAt",{time:jx(e.checkedAt)}))),ng(e.challenges,t),r!==void 0?(0,Y.createElement)("p",{className:"bre-fp-timing"},t("fpTiming",{first:eg(r.firstTokenMs),total:eg(r.durationMs),rate:r.charsPerSecond===void 0?"\u2014":String(Math.round(r.charsPerSecond))})):null,(0,Y.createElement)("div",{className:"bre-fp-k",style:{marginTop:"8px"}},t("fpCandidates")),(0,Y.createElement)("div",{className:"bre-fp-bars"},...n.map((o,i)=>(0,Y.createElement)("div",{className:"bre-fp-bar",key:o.model},(0,Y.createElement)("span",{className:"bre-fp-bar-name"},o.model),(0,Y.createElement)("span",{className:`bre-fp-bar-fill${i===0?" is-top":""}`,style:{width:`${Math.max(2,Math.round(o.probability*100))}%`}}),(0,Y.createElement)("span",{className:"bre-fp-bar-value"},lo(o.probability))))),(0,Y.createElement)("p",{className:"bre-fp-note"},t("fpClosedSet")))}var rg="settings.models.provider-card";function Xx(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 Qx({provider:e,api:t,t:n,ctx:r}){let o=(0,wt.useRef)(null),i=e?.provider,a=(0,wt.useCallback)(()=>{Xx(rr(o.current))},[]);return(0,wt.useLayoutEffect)(()=>{let s=o.current,d=rr(s);if(s===null||d===null)return;let l=d,c=()=>d.querySelector('[class*="_editor"]')!==null,p=()=>{let m=c()?"1":"0";s.dataset.edit!==m&&(s.dataset.edit=m)};p();let h=new MutationObserver(p);return h.observe(l,{childList:!0,subtree:!0}),()=>{h.disconnect()}},[i]),typeof i!="string"||i.length===0?null:(0,wt.createElement)("div",{ref:o,className:"bre-headers-host","data-bre-provider":i},(0,wt.createElement)(xi,{host:o,t:n}),(0,wt.createElement)(Jm,{route:i,api:t,t:n,onDismiss:a}),(0,wt.createElement)(tg,{route:i,api:t,t:n,ctx:r,host:o}))}function og(e,t,n){let r=e,o=r.slots?.inject(rg,()=>{r.slots?.register({name:rg,key:_e,inject:()=>({api:t,t:n,ctx:e})},Qx)});return typeof o=="function"?o:()=>{}}var ft=require("react");function ig(e){let{t}=e,n=(0,ft.useSyncExternalStore)(ho,gt),r=()=>{Kd(!n)};return(0,ft.createElement)("div",{className:"bre-slider-setting"},(0,ft.createElement)("div",{className:"bre-slider-setting-row"},(0,ft.createElement)("div",{className:"bre-slider-setting-copy"},(0,ft.createElement)("div",{className:"bre-slider-setting-title"},t("sliderToggleTitle")),(0,ft.createElement)("div",{className:"bre-slider-setting-description"},t("sliderToggleDescription"))),(0,ft.createElement)("div",{className:"bre-slider-setting-control"},(0,ft.createElement)("span",{className:"bre-slider-setting-state"},t(n?"settingOn":"settingOff")),(0,ft.createElement)("button",{type:"button",role:"switch","aria-label":t("sliderToggleAria"),"aria-checked":n,className:"bre-slider-setting-switch"+(n?" is-on":""),onClick:r},(0,ft.createElement)("span",{className:"bre-slider-setting-switch-knob","aria-hidden":!0})))))}function ag(e,t){let n=e,r=n.slots?.inject("settings.models.footer",()=>{n.slots?.register({name:"settings.models.footer",id:Ee+"-slider-toggle",order:15,inject:()=>({t})},ig)});return typeof r=="function"?r:()=>{}}var E=require("react"),lg=require("react-dom/client");var ea=[{label:"1K",value:"1024x1024",edge:1024},{label:"2K",value:"2048x2048",edge:2048},{label:"4K",value:"4096x4096",edge:4096}];function Zx(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 ek(e){let t=Zx(e),n=ea[0];if(t===void 0)return n;let r=Number.POSITIVE_INFINITY;for(let o of ea){let i=Math.abs(o.edge-t);i<r&&(n=o,r=i)}return n}function sg(e){return ek(e).value}var tk=[5,10,15,30,60];function nk(e){let t=tk.map(n=>n*6e4);return t.includes(e)?t:[e,...t]}function rk(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),[p,h]=(0,E.useState)(void 0),[m,g]=(0,E.useState)(!1),b=(0,E.useRef)(!1),f=(0,E.useRef)(0),v=(0,E.useRef)(Promise.resolve()),x=(0,E.useRef)(0),w=(0,E.useRef)([]),R=(0,E.useCallback)(()=>{let H=++f.current;vn().then($=>{!b.current||H!==f.current||(o($.data),a($.ok?void 0:$.error))})},[]);(0,E.useEffect)(()=>(b.current=!0,R(),()=>{b.current=!1,f.current+=1}),[R]);let[F,re]=(0,E.useState)({});(0,E.useEffect)(()=>{let H=!0;return ge(t).then($=>{let Q={};for(let[oe,ae]of Object.entries(Be($.namespace))){let se=typeof ae.displayName=="string"?ae.displayName.trim():"";se.length>0&&(Q[oe]=se)}H&&re(Q)}).catch(()=>{}),()=>{H=!1}},[t]);let j=(0,E.useCallback)((H,$)=>{f.current+=1,x.current===0&&(w.current=[],h(void 0)),x.current+=1,c(!0),$!==void 0&&d(oe=>[...oe,$]);let Q=async()=>{let oe=await cm(H).catch(ae=>({ok:!1,error:ae instanceof Error?ae.message:String(ae)}));x.current-=1,oe.ok||w.current.push(oe.error),b.current&&($!==void 0&&d(ae=>{let se=ae.indexOf($);return se<0?ae:[...ae.slice(0,se),...ae.slice(se+1)]}),c(x.current>0),h(w.current.length===0?void 0:w.current.join(`
5391
- `)),x.current===0&&R())};v.current=v.current.then(Q,Q)},[R]),T=(0,E.useCallback)(H=>{H.length!==0&&j({defaultModel:H},"default")},[j]),N=(0,E.useCallback)(H=>{j({enabled:H},"enabled")},[j]),z=(0,E.useCallback)(H=>{if(r===void 0)return;let $=Number(H);!Number.isFinite($)||$<6e4||$>36e5||j({defaults:{timeoutMs:$}})},[r,j]);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(H=>(0,E.createElement)("div",{key:H,className:"bre-config-skeleton-row"}))));let M=r.models,y=M.length===0,A="bre-config-imagegen-body",C=r.enabled?r.tool.error:void 0,I=new Map;for(let H of M)I.set(H.label,(I.get(H.label)??0)+1);let D=H=>{if((I.get(H.label)??0)<2)return H.label;let $=F[H.route]??H.providerLabel??H.route;return`${H.label} \xB7 ${$}`};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":m,"aria-controls":A,title:n(m?"imagegenCollapse":"imagegenExpand"),onClick:()=>g(H=>!H)},(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:H=>N(H.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(m),onClick:()=>g(H=>!H)},"\u203A")),i!==void 0&&(0,E.createElement)("div",{className:"bre-config-notice",role:"alert"},`${n("imagegenLoadFailed")}: ${i}`),p!==void 0&&(0,E.createElement)("div",{className:"bre-config-notice"},p),m&&(0,E.createElement)("div",{className:"bre-config-card-body",id:A},C!==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:C}))),(0,E.createElement)("div",{className:"bre-config-defaults"},(0,E.createElement)("label",null,n("imagegenDefaultsLabel")),(0,E.createElement)("select",{className:"bre-config-select",value:sg(r.defaults.size),"aria-label":n("imagegenSizeLabel"),onChange:H=>{j({defaults:{size:H.target.value}})}},ea.map(H=>(0,E.createElement)("option",{key:H.label,value:H.value},H.label))),(0,E.createElement)("select",{className:"bre-config-select",value:r.defaults.quality,"aria-label":n("imagegenQualityLabel"),onChange:H=>{j({defaults:{quality:H.target.value}})}},["low","medium","high","auto"].map(H=>(0,E.createElement)("option",{key:H,value:H},H))),(0,E.createElement)("select",{className:"bre-config-select",value:String(r.defaults.n),"aria-label":n("imagegenCountLabel"),onChange:H=>{j({defaults:{n:Number(H.target.value)}})}},[1,2,3,4].map(H=>(0,E.createElement)("option",{key:H,value:String(H)},`n=${H}`))),(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:H=>{z(H.target.value)}},nk(r.defaults.timeoutMs).map(H=>(0,E.createElement)("option",{key:H,value:String(H)},n("imagegenTimeoutMinutes",{minutes:Math.round(H/6e4)})))))),!y&&(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:H=>T(H.target.value)},r.defaultModel===null&&(0,E.createElement)("option",{value:"",disabled:!0},n("imagegenDefaultModelNone")),M.map(H=>(0,E.createElement)("option",{key:H.id,value:H.id},D(H)))))))}var dg={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"},ok={continue:"autoContinueTagContinue",useless:"autoContinueTagUseless",depends:"autoContinueTagDepends"};function ik(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 f=x=>{let w=i.current;w!==null&&x.target instanceof Node&&!w.contains(x.target)&&o(!1)},v=()=>o(!1);return document.addEventListener("mousedown",f),window.addEventListener("resize",v),window.addEventListener("scroll",v,!0),()=>{document.removeEventListener("mousedown",f),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0)}},[r]);let l=()=>{if(r){o(!1);return}let f=a.current;if(f===null){o(!0);return}let v=f.getBoundingClientRect(),x=Math.min(Math.max(v.width,400),window.innerWidth-24),w=Math.min(Math.max(8,v.right-x),window.innerWidth-x-8),R=window.innerHeight-v.bottom-12,F=470;d(R>=F?{left:w,width:x,top:v.bottom+6}:v.top>F?{left:w,width:x,bottom:window.innerHeight-v.top+6}:{left:w,width:x,top:Math.max(8,window.innerHeight-8-460)}),o(!0)},c=Pi.filter(f=>n.codes[f]===!0),p=[];n.maxTokens&&p.push((0,E.createElement)("span",{className:"bre-config-chip",key:"max-tokens"},t("autoContinueMaxTokens"))),n.httpStatus&&p.push((0,E.createElement)("span",{className:"bre-config-chip",key:"http"},t("autoContinueChipHttp")));for(let f of c)p.push((0,E.createElement)("span",{className:"bre-config-chip",key:f},f));let h=p.slice(0,3),m=p.length-h.length,g=(f,v,x,w,R,F)=>(0,E.createElement)("label",{className:"bre-config-code-row",key:f},(0,E.createElement)("input",{type:"checkbox",className:"bre-config-code-input",checked:v,onChange:re=>F(re.target.checked)}),(0,E.createElement)("span",{className:`bre-config-check${v?" bre-config-check-on":""}`,"aria-hidden":!0}),(0,E.createElement)("span",{className:"bre-config-code-name"},x),(0,E.createElement)("span",{className:"bre-config-code-why",title:w},w),(0,E.createElement)("span",{className:`bre-config-code-tag bre-config-code-tag-${R}`},t(ok[R]))),b=(f,v)=>(0,E.createElement)("div",{className:"bre-config-code-group",key:f},(0,E.createElement)("div",{className:"bre-config-code-group-title"},t(f)),v);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,m>0&&(0,E.createElement)("span",{className:"bre-config-chip bre-config-chip-more"},t("autoContinueCodesMore",{count:m})),p.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",[g("flag:max-tokens",n.maxTokens,t("autoContinueMaxTokens"),t("autoContinueWhyMaxTokens"),"continue",f=>e.onFlag("maxTokens",f)),g("flag:http",n.httpStatus,t("autoContinueHttpStatus"),t("autoContinueWhyHttpStatus"),"continue",f=>e.onFlag("httpStatus",f))]),b("autoContinueGroupTransient",no.map(f=>g(f,n.codes[f]===!0,(0,E.createElement)("code",{className:"bre-config-code-name-inner"},f),t(`autoContinueWhy${f}`),dg[f]??"depends",v=>e.onToggle(f,v)))),b("autoContinueGroupOther",Ii.map(f=>g(f,n.codes[f]===!0,(0,E.createElement)("code",{className:"bre-config-code-name-inner"},f),t(`autoContinueWhy${f}`),dg[f]??"depends",v=>e.onToggle(f,v)))),(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 ak(e){let{t}=e,n=(0,E.useSyncExternalStore)($i,Yt),r=(0,E.useSyncExternalStore)(Vi,je),[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(je().waitSeconds))},l=()=>{xn({maxRetries:a.trim()===""?r.maxRetries:Number(a)}),s(String(je().maxRetries))},[c,p]=(0,E.useState)(!1),h="bre-config-auto-continue-body",m=r.policy,g=x=>{xn({policy:{...m,...x}})},b=(x,w)=>{xn({policy:{...m,codes:{...m.codes,[x]:w}}})},f=x=>{let w={...m.codes};for(let R of Pi)w[R]=x;xn({policy:{...m,codes:w}})},v=()=>{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:()=>p(x=>!x)},(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:x=>{Im(x.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:()=>p(x=>!x)},"\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:x=>i(x.target.value),onBlur:d,onKeyDown:x=>{x.key==="Enter"&&x.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:x=>s(x.target.value),onBlur:l,onKeyDown:x=>{x.key==="Enter"&&x.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)(ik,{t,policy:m,onFlag:(x,w)=>g({[x]:w}),onToggle:b,onBulk:f,onRestore:v}))))}function sk(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=>{Gm(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 dk(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)(We,{fallbackText:t("configPaneFailed")},(0,E.createElement)(rk,{api:e.api,t:e.t})),(0,E.createElement)(We,{fallbackText:t("configPaneFailed")},(0,E.createElement)(ak,{t:e.t})),(0,E.createElement)(We,{fallbackText:t("configPaneFailed")},(0,E.createElement)(sk,{t:e.t})))))}function Ad(e){let t=document.createElement("div");t.className="bre-config-pane-host",document.body.appendChild(t);let n=(0,lg.createRoot)(t),r=!0,o=()=>{r&&(r=!1,Oe({wrapper:t,root:n}))};return n.render((0,E.createElement)(dk,{api:e.api,t:e.t,onClose:o})),{close:o}}function cg(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return r.length===0||n.includes(r)}function ug(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=>cg(a.id,o)||cg(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 mr,Ld=0;function Cd(){mr=void 0,Ld+=1}function lk(){if(mr!==void 0)return mr;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(()=>{mr===t&&(mr=void 0)});return mr=t,t}function fg(e){let t;try{t=e.inputTriggers}catch{t=void 0}let n=dm(Cd);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)?lk().then(s=>r&&!i.signal?.aborted?ug(a.replace(/^\/?生图/,""),s):[]):[]}})}catch{r=!1}return()=>{r=!1,n()}}var kn=require("react");var pg="tool.call.images",ck="generate_image";function uk(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 fk(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 pk(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(`
5404
+ `;var Mr="bre:endpoints-changed",Lr="bre:settings-changed",Rr="bre:balance-changed";var Ir=require("react"),tc=require("react-dom");var q=require("react"),Ul=require("react-dom");var Z=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function kl(e){let t=e.toLowerCase();return t.includes("compat")||t.includes("thinkingtokenbudget")||t.includes("vllmpriority")||t.includes("supportsmaxoutput")}function Kn(e,t){if(!Z(e))return[];let n=e[t];return!Z(n)||!Array.isArray(n.models)?[]:n.models.filter(Z)}function cn(e,t){if(!Z(e))return{};let n=e[t];if(!Z(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"],ch=["text","image"];var uh=[{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"}],Ia={off:null,low:"low",medium:"medium",high:"high"},fh={"openai-completions":Ia,"openai-responses":Ia,"anthropic-messages":Ia,deepseek:{off:"none",low:"low",high:"high",max:"max"}},ph={low:"low",medium:"medium",high:"high"};function Un(e){return(e??"").toLowerCase().trim()}function El(e){return e!==void 0&&/[a-z0-9]/.test(e)}function un(e){return e.toLowerCase().trim().replace(/[^a-z0-9]+/g," ").replace(/([a-z])(\d)/g,"$1 $2")}function Pa(e,t,n){let r=t===0?void 0:e[t-1],o=e[t+n];return!El(r)&&!El(o)}function _a(e,t){let n=un(e)+" "+un(t??""),r;for(let o of uh)for(let i of o.patterns){let a=un(i),s=n.indexOf(a);for(;s>=0;){if(Pa(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 mh={"deepseek.com":"deepseek","anthropic.com":"anthropic-messages"};function gh(e){let t=Un(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=mh[o.slice(-2).join(".")];if(i!==void 0)return i}}catch{}return"openai-completions"}var Hr="openai-completions",hh="openai-responses",Fa="anthropic-messages";function Da(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 bh(e,t){let n=Un(t),r={...e};if(delete r.supportsMidConvoEffort,delete r.allowedFallbackModels,n===Fa){for(let o of["thinkingFormat","supportsReasoningEffort","thinkingTokenBudgetField","supportsThinkingTokenBudget","vllmPriority"])delete r[o];return r.forceAdaptiveThinking===void 0?void 0:{forceAdaptiveThinking:r.forceAdaptiveThinking}}if(n===Hr)return delete r.forceAdaptiveThinking,Object.keys(r).length===0?void 0:r}var Tl=["supportsReasoningEffort","thinkingFormat","thinkingTokenBudgetField","supportsThinkingTokenBudget","vllmPriority"],Sl=["forceAdaptiveThinking"];function qa(e,t){let n=Un(t),r;if(n===Hr)r=Sl;else if(n===hh)r=[...Tl,...Sl];else if(n===Fa)r=Tl;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 yh(e,t){let n=Un(t.api);if(n===Hr){let r=e.compat;r!==void 0&&(r=bh(r,n)??void 0);let o=e.efforts!==!1;return r===void 0?o&&Da(t.baseURL)?{thinkingTokenBudgetField:"thinking_token_budget"}:void 0:o&&r.thinkingTokenBudgetField===void 0&&r.supportsThinkingTokenBudget!==!0&&Da(t.baseURL)?{...r,thinkingTokenBudgetField:"thinking_token_budget"}:r}if(n===Fa&&e.anthropicAdaptive===!0)return{forceAdaptiveThinking:!0}}var vh=["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 Ba(e){if(Un(e.api)!==Hr)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(".")?!vh.some(r=>n===r||n.endsWith("."+r)):!1}catch{return!1}}function Cl(e,t,n){return e===void 0||!n||e.supportsDeveloperRole!==void 0||!Ba(t)?e:{...e,supportsDeveloperRole:!1}}var Al={off:null,low:"low",medium:"medium",high:"high"},wh=["vl","vision","omni","4o","pixtral","internvl"];function Ka(e){let t=un(e);for(let n of wh){let r=un(n),o=t.indexOf(r);for(;o>=0;){if(Pa(t,o,r.length))return["text","image"];o=t.indexOf(r,o+1)}}}var xh=["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 kh(e){let t=un(e);for(let n of xh){let r=un(n),o=t.indexOf(r);for(;o>=0;){if(Pa(t,o,r.length))return!0;o=t.indexOf(r,o+1)}}return!1}function Eh(e){if(e===void 0)return;let t=e.map(n=>n.toLowerCase());if(t.some(n=>ch.includes(n)))return t.includes("image")?["text","image"]:["text"]}function Rt(e,t,n){let r=_a(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 c=Eh(n?.input);c!==void 0&&(o=c,i="endpoint");let u=n?.output;if(u!==void 0&&(a=u.includes("image")&&!u.includes("text")),n?.contextLength!==void 0&&Number.isFinite(n.contextLength)&&n.contextLength>0&&(s=n.contextLength),o===void 0){let C=Ka(e);C!==void 0&&(o=C,i="heuristic")}a===void 0&&kh(e)&&(a=!0),a===!0&&(o=void 0,i=void 0);let p={...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}},g=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",...g,...p};if(r!==void 0){let C=Cl(yh(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}:{},...C===void 0?{}:{compat:C},matched:!0,entryId:r.id,source:r.id,confidence:"high",...g,...p}}let m=gh(t),f=fh[m]??ph,v=Un(t.api)===Hr?{thinkingFormat:"openai",supportsReasoningEffort:!0}:void 0,h=v!==void 0&&Da(t.baseURL)?{...v,thinkingTokenBudgetField:"thinking_token_budget"}:v,x=Cl(h,t,!0);return n?.reasoning===!0?{efforts:{...Al},...Al.medium!==void 0?{defaultEffort:"medium"}:{},...x===void 0?{}:{compat:x},matched:!1,source:"endpoint:"+(n.source??"listing"),confidence:"medium",...g,...p}:{efforts:f,...f.medium!==void 0?{defaultEffort:"medium"}:{},...x===void 0?{}:{compat:x},matched:!1,source:"protocol:"+m,confidence:"low",...g,...p}}var Jt=(e,t)=>typeof e[t]=="boolean";function Th(e,t){if(Array.isArray(e)){for(let n of e)if(Z(n)&&n.id===t)return n}}function Sh(e){if(!Z(e))return{reasoning:"unknown",source:null};let t=e.supported_features;if(Array.isArray(t)&&t.includes("reasoning"))return{...ot(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{...ot(e),reasoning:!0,source:"supported_parameters"};if(Jt(e,"supports_reasoning"))return{...ot(e),reasoning:e.supports_reasoning,source:"supports_reasoning"};if(Jt(e,"supportsReasoning"))return{...ot(e),reasoning:e.supportsReasoning,source:"supportsReasoning"};if(Jt(e,"can_reason"))return{...ot(e),reasoning:e.can_reason,source:"can_reason"};if(Jt(e,"reasoning"))return{...ot(e),reasoning:e.reasoning,source:"reasoning"};let r=e.reasoning_effort;if(r===!1)return{...ot(e),reasoning:!1,source:"reasoning_effort"};if(typeof r=="string"&&r.trim().length>0||e.supports_reasoning_effort===!0)return{...ot(e),reasoning:!0,source:"reasoning_effort"};let o=Z(e.capabilities)?e.capabilities:void 0;if(o!==void 0){let i=o.thinking,a=Z(i)&&typeof i.supported=="boolean"?i.supported:void 0,s=o.effort,d=Z(s)&&typeof s.supported=="boolean"?s.supported:void 0;if(d===!0)return{...ot(e),reasoning:!0,source:"capabilities.effort.supported"};if(a===!0)return{...ot(e),reasoning:!0,source:"capabilities.thinking.supported"};if(a===!1)return{...ot(e),reasoning:!1,source:"capabilities.thinking.supported"};if(d===!1)return{...ot(e),reasoning:!1,source:"capabilities.effort.supported"}}return{...ot(e),reasoning:"unknown",source:null}}function ot(e){let t={},n=s=>{if(!Array.isArray(s))return;let d=s.filter(c=>typeof c=="string");return d.length>0?d.map(c=>c.toLowerCase()):[]},r=Z(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=Z(e.modalities)?e.modalities:void 0;o=n(s?.input)}if(o===void 0){let s=e.capabilities,d=c=>Array.isArray(c)&&c.some(u=>typeof u=="string"&&u.toLowerCase()==="vision");if(d(e.supported_features)||d(s))o=["image"];else if(Z(s)){let c=[];for(let u of["image_input","video_input","pdf_input","file_input"]){let p=Z(s[u])?s[u]:void 0;if(p===void 0||typeof p.supported!="boolean")continue;let g=u.replace(/_input$/,"");p.supported===!0?c.push(g):c.length===0&&c.push("text")}c.length>0&&(o=c)}}o===void 0&&(Jt(e,"supports_vision")?o=e.supports_vision===!0?["image"]:[]:Jt(e,"supportsVision")?o=e.supportsVision===!0?["image"]:[]:(Jt(e,"supports_images")||Jt(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=Z(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=(Z(e.top_provider)?e.top_provider:void 0)?.context_length;if(typeof d=="number"&&Number.isFinite(d)&&d>0)t.contextLength=d;else{let c=e.max_input_tokens;if(typeof c=="number"&&Number.isFinite(c)&&c>0)t.contextLength=c;else{let p=(Z(e.limit)?e.limit:void 0)?.context;typeof p=="number"&&Number.isFinite(p)&&p>0&&(t.contextLength=p)}}}return t}function Ll(e,t){let n=Th(e,t);return n===void 0?{found:!1,signal:{reasoning:"unknown",source:null}}:{found:!0,signal:Sh(n)}}function ze(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 Oo(e){if(!Z(e))return;let t=e.providers;return Z(t)?t:void 0}function Hl(e,t){for(let n of[e?.user,e?.base]){let r=Oo(n)?.[t];if(Z(r)&&r.models!==void 0)return r.models}}function fn(e){return Oo(e?.user)}function Io(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 Do(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 Po(e,t){let r=e.find(o=>o.id===t)?.compat;if(Z(r))return{...r}}function Wa(e,t){return e.find(r=>r.id===t)?.[mt]===!0}function _o(e,t){let r=e.find(o=>o.id===t)?.name;return typeof r=="string"&&r.length>0?r:void 0}function Fo(e,t){let r=e.find(o=>o.id===t)?.[Hn];return typeof r=="string"&&r.length>0?r:void 0}var Ch=3e4,Ah=15e3,Ua=new Map,No=new Map;async function Mh(e){let t=Ua.get(e);if(t!==void 0&&Date.now()-t.at<Ch)return t.data;let n=No.get(e);if(n!==void 0)return n;let r=(async()=>{try{let o=await fetch(`${Gd}?route=${encodeURIComponent(e)}`,{method:"GET",signal:AbortSignal.timeout(Ah)});if(!o.ok)return;let i=await o.json();return i?.ok?(Ua.set(e,{at:Date.now(),data:i.data}),i.data):void 0}catch{return}finally{No.delete(e)}})();return No.set(e,r),r}function Ga(){Ua.clear(),No.clear()}async function Lh(e,t){let n=await Mh(e);return n===void 0?{reasoning:"unknown",source:null}:Ll(n,t).signal}function qo(e,t=()=>we(e),n,r,o,i){return{async suggest(a,s,d,c){let u=ze((await t()).namespace),p=cn(u,a),g={api:p.api??c?.api,baseURL:p.baseURL??c?.baseURL,displayName:d??p.displayName},m=u[a]===void 0?void 0:await Lh(a,s),f=Rt(s,g,m);return f.efforts===void 0?{ok:!1,error:"no-suggestion"}:{ok:!0,suggestion:{efforts:f.efforts,...f.compat===void 0?{}:{compat:f.compat},...f.defaultEffort===void 0?{}:{defaultEffort:f.defaultEffort},...f.input===void 0?{}:{input:f.input},...f.inputSource===void 0?{}:{inputSource:f.inputSource},...f.imageGen===void 0?{}:{imageGen:f.imageGen},...f.contextWindow===void 0?{}:{contextWindow:f.contextWindow},...f.maxTokens===void 0?{}:{maxTokens:f.maxTokens},matched:f.matched,source:f.source,confidence:f.confidence,...f.endpoint===void 0?{}:{endpoint:f.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,c,u,p,g){n?.(a,s,d,c,u,p,g)},async writeEfforts(a,s,d,c,u,p,g){if(r!==void 0)return r(a,s,{efforts:d,...c===void 0?{}:{compat:c},...u===void 0?{}:{input:u},...g===void 0?{}:{imageGen:g},...p===void 0?{}:{defaultEffort:p}}),{ok:!0,staged:!0};let f=(await Nr(e,a,[{modelId:s,efforts:d,...c===void 0?{}:{compat:c},...u===void 0?{}:{input:u},...g===void 0?{}:{imageGen:g},...p===void 0?{}:{defaultEffort:p}}],t))[0]??{ok:!1,error:"no-result"};return f.ok?{ok:!0}:f.modelNotFound===!0?{ok:!1,error:"model-not-found"}:{ok:!1,error:f.error??"conflict"}}}}async function Nr(e,t,n,r=()=>we(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 we(e,{fresh:!0});if(s.namespace===void 0)return n.map(()=>({ok:!1,error:"no-namespace"}));let d=Hl(s.namespace,t);if(!Array.isArray(d))return n.map(()=>({ok:!1,modelNotFound:!0}));if(!d.every(Z))return n.map(()=>({ok:!1,error:"invalid-models"}));let u=d.map(m=>m),p=[];for(let m of n){let f=u.findIndex(v=>v.id===m.modelId);if(f<0){p.push(m.modelId);continue}u[f]=Rh(u[f],m,i?void 0:m.compat)}if(p.length>0)return n.map(m=>p.includes(m.modelId)?{ok:!1,modelNotFound:!0}:{ok:!1,error:"model-not-found"});if(o?.()===!0)return n.map(()=>({ok:!1,aborted:!0}));let g=await e.settings.mutate(Ue,[{op:"set",path:["providers",t,"models"],value:u}],s.namespace.revision);if(!g.ok){if(a===0&&g.error.code==="settings/conflict")continue;let m=g.error.code==="settings/rejected"&&kl(g.error.message);if(!i&&m&&n.some(f=>f.compat!==void 0)){i=!0;continue}return n.map(()=>({ok:!1,error:g.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 Rh(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[pt]=!0;else if(delete r[pt],delete r[Rn],i===!1)r.reasoningEfforts=!1;else{r.reasoningEfforts={...i};let s={...Z(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[Lt]=!0):(delete r[Lt],r.input=[...t.input])),t.imageGen!==void 0&&(t.imageGen===!0?(r[mt]=!0,delete r.input,delete r[Lt]):delete r[mt]),t.defaultEffort!==void 0&&(t.defaultEffort===null?delete r[Hn]:r[Hn]=t.defaultEffort),r}function ja(e,t){for(let n of[e?.user,e?.base]){let r=Oo(n)?.[t];if(!Z(r))continue;let o=r.headers;if(o===void 0)continue;if(!Z(o))return;let i={};for(let[a,s]of Object.entries(o))typeof s=="string"&&(i[a]=s);return i}}async function Or(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 we(e):await we(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(!gt(i.namespace,t)){r=!0;continue}let a=await e.settings.mutate(Ue,[{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 gt(e,t){if(Object.prototype.hasOwnProperty.call(ze(e),t))return!0;for(let n of[e?.user,e?.base]){let r=Oo(n);if(r!==void 0&&Object.prototype.hasOwnProperty.call(r,t))return!0}return!1}async function we(e,t={}){let n=t.fresh===!0?void 0:Hh(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===Ue),writable:r.value.writable,source:"wire"}:{namespace:void 0,writable:!1,source:"wire"}}var Rl=new WeakMap;function Hh(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:Ue,schema:{},value:r.value,user:r.user,base:r.base,revision:r.revision,applies:"live",secrets:[]},writable:r.writable===!0,source:"scope"};return Rl.set(n,i),i}if(!t||n===void 0)return;let o=Rl.get(n);if(o!==void 0)return{...o,source:"scope-stale"}}var za=new Map;function Nl(e){let t=za,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=we(e,{fresh:!0}).then(c=>{if(d!==o||c.namespace===void 0)return;let u=new Map;for(let[p,g]of Object.entries(ze(c.namespace))){let m=new Map,f=Array.isArray(g.models)?g.models:[];for(let v of f){if(!Z(v)||typeof v.id!="string"||v.id.length===0)continue;let h={};if(Array.isArray(v.input)){let C=v.input.filter(T=>typeof T=="string");C.length>0&&(h.input=C)}v[mt]===!0&&(h.imageGen=!0);let x=v.contextWindow;typeof x=="number"&&Number.isFinite(x)&&x>0&&(h.contextWindow=x),(h.input!==void 0||h.imageGen!==void 0||h.contextWindow!==void 0)&&m.set(v.id,h)}m.size>0&&u.set(p,m)}t=u,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"),Oh=/^(\d+(?:\.\d+)?)([kmbt])?$/i,Ih={k:1e3,m:1e6,b:1e9,t:1e12};function Ht(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 Tt(e){return e===void 0?"":Nh.format(e)}function Ol(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=m=>Math.round(m*10)/10,c=e/s.binary,u=e/s.decimal,p=Math.abs(e-d(c)*s.binary),g=Math.abs(e-d(u)*s.decimal);return p<=g?`${i(c)}${s.suffix}`:`${i(u)}${s.suffix}`}return String(e)}var Dl="dsh-model-think-level.slider.efforts",$a="breSelectWired",Dh=400;function Ph(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),Dh);e.then(i=>{clearTimeout(o),r(i)},()=>{clearTimeout(o),r(void 0)})})}function Va(e){return typeof e=="object"&&e!==null&&e.ok===!1}function Ya(e){if(!Va(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 pn(e,t){return`${e}/${t}`}function Pl(){try{let e=window.localStorage.getItem(Dl);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 _h(e){try{window.localStorage.setItem(Dl,JSON.stringify(e))}catch{}}function Fh(e,t,n){let r=Pl();r[pn(e,t)]=n,_h(r)}function qh(e,t){return Pl()[pn(e,t)]}function Bo(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 Bh(e,t,n){return e.groups.find(o=>o.id===t)?.models.find(o=>o.id===n)?.reasoning?.defaultEffort}function Kh(e){if(!(e.length<2))return e[Math.floor((e.length-1)/2)]}function Uh(e,t){return e===null||e.provider!==t.provider||e.model!==t.model}async function Il(e,t,n,r,o){let i=Bo(e,t,n);if(i.length===0)return;let a=pn(t,n),s=r.get(a);if(s!==void 0&&i.includes(s))return s;let d=await Ph(o?.configuredEffort===void 0?void 0:o.configuredEffort(t,n));if(d!==void 0&&i.includes(d))return d;let c=qh(t,n);if(c!==void 0&&i.includes(c))return c;let u=Rt(n,{}).defaultEffort;if(u!==void 0&&i.includes(u))return u;let p=Bh(e,t,n);return p!==void 0&&i.includes(p)?p:Kh(i)}function _l(e,t){let n=e;if(n[$a]===!0)return()=>{};let r=Object.prototype.hasOwnProperty.call(n,"select"),o=e.select,i=new Map,a=new Set,s=new Map,d=3,c=0,u=0,p=async(v,h)=>{if(h.reasoningEffort!==void 0){let B=await o.call(e,h);return!Va(B)&&kt()&&(i.set(pn(h.provider,h.model),h.reasoningEffort),Fh(h.provider,h.model,h.reasoningEffort)),B}let x=e.store.getSnapshot();if(!Uh(x.current,h)){if(kt()){let B=pn(h.provider,h.model);i.delete(B),a.add(B)}return o.call(e,h)}if(!kt())return o.call(e,h);let C=await Il(x,h.provider,h.model,i,t);if(c!==v)return;let T=e.store.getSnapshot(),H=T.current!==null&&T.current.provider===h.provider&&T.current.model===h.model;return!kt()||C===void 0||!Bo(T,h.provider,h.model).includes(C)?H?void 0:o.call(e,h):o.call(e,{...h,reasoningEffort:C})},g=async v=>{let h=++c;try{return await p(h,v)}finally{h>u&&(u=h)}},m=()=>{let v=e.store.getSnapshot(),h=v.current;if(h===null||h.reasoningEffort!==void 0||!kt())return;let x=pn(h.provider,h.model);if(a.has(x))return;if(Bo(v,h.provider,h.model).length===0){a.add(x);return}a.add(x);let C=c;Il(v,h.provider,h.model,i,t).then(async T=>{if(T===void 0){a.delete(x);return}if(!kt()){a.delete(x);return}if(c!==C)return;if(c!==u){a.delete(x);return}let H=e.store.getSnapshot(),B=H.current;if(B===null||B.reasoningEffort!==void 0||pn(B.provider,B.model)!==x||!Bo(H,B.provider,B.model).includes(T))return;let I=await o.call(e,{provider:B.provider,model:B.model,reasoningEffort:T});if(Va(I))throw I}).catch(()=>{let T=(s.get(x)??0)+1;s.set(x,T),T<d&&(a.delete(x),m())})},f=e.store.subscribe(m);return m(),n[$a]=!0,e.select=g,()=>{delete n[$a],f(),r?e.select=o:delete n.select}}var Wh=1e4;function Fl(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 ql(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 jh(e){return e?.models??[]}function Qt(e){let t=e;return t.name??t.label??t.title??e.id}function Xa(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 zh(){let[e,t]=(0,q.useState)(null),n=(0,q.useRef)(0),r=(0,q.useCallback)(()=>{window.clearTimeout(n.current),t(null)},[]),o=(0,q.useCallback)((i,a)=>{window.clearTimeout(n.current);let s=i.currentTarget;s.scrollWidth<=s.clientWidth+1||(n.current=window.setTimeout(()=>{Xa(s)&&(s.scrollWidth<=s.clientWidth+1||t({target:s,text:a}))},300))},[]);return(0,q.useEffect)(()=>()=>{window.clearTimeout(n.current),t(null)},[]),(0,q.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(()=>{Xa(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 $h({state:e}){if(typeof document>"u")return null;let t=e.target;if(!Xa(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,Ul.createPortal)((0,q.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 Bl=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=Bl.get(r);if(o!==void 0)return o;let i=_a(e.id,e.name)?.input,a=i!==void 0?i.includes("image"):(Ka(e.id)??[]).includes("image");return Bl.set(r,a),a}function Kl(e,t){return t?.imageGen===!0?!0:e.inputImageGen===!0}function Yh(e){let t=e.reasoning?.efforts;return Array.isArray(t)&&t.length>0}function Xh(e){return(0,q.createElement)("svg",{className:"bre-tag-icon",width:13,height:13,viewBox:"0 0 16 16",fill:"none",role:"img","aria-label":e},(0,q.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,q.createElement)("circle",{cx:8,cy:8,r:1.8,fill:"currentColor"}))}function Jh(e){return(0,q.createElement)("svg",{className:"bre-tag-icon",width:13,height:13,viewBox:"0 0 16 16",fill:"none",role:"img","aria-label":e},(0,q.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 Qh(e){return(0,q.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,q.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,q.createElement)("path",{d:"M2.6 10.6 5.3 8.5l1.8 1.5 1.6-1.3 2.3 2"}),(0,q.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 Zh=["#22c55e","#a3e635","#eab308","#f97316","#ef4444"],BE=Zh.map(e=>[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]);function eb(e,t,n,r=!1){let o=[];return Vh(e,n)&&o.push((0,q.createElement)("span",{key:"vision",className:"bre-tag",title:t("tagVision")},Xh(t("tagVision")))),Yh(e)&&o.push((0,q.createElement)("span",{key:"thinking",className:"bre-tag",title:t("tagThinking")},Jh(t("tagThinking")))),r&&o.push((0,q.createElement)("span",{key:"imageGen",className:"bre-tag",title:t("tagImageGen")},Qh(t("tagImageGen")))),o.length===0?null:(0,q.createElement)("span",{className:"bre-option-tags"},...o)}function tb(e,t){let n=Ol(e);return n===""?null:(0,q.createElement)("span",{className:"bre-option-cap",title:t("contextWindowLabel")},n)}function Wl(e){let{directory:t,t:n,configuredInputs:r}=e,o=(0,q.useSyncExternalStore)(M=>t.store.subscribe(M),()=>t.store.getSnapshot()),i=(0,q.useSyncExternalStore)(M=>r?.subscribe(M)??(()=>{}),()=>r?.getSnapshot()??za),a=Fl(o),[s,d]=(0,q.useState)(()=>{let M=t.store.getSnapshot(),$=Fl(M);return $[ql($,M)]?.id??""}),[c,u]=(0,q.useState)(""),[p,g]=(0,q.useState)(null),[m,f]=(0,q.useState)(!1),[v,h]=(0,q.useState)(null),x=(0,q.useRef)(null),C=(0,q.useRef)(""),T=(0,q.useRef)(!1),H=o.current!==null&&a.length>=2,B=m,I=v??o.error,F=t.select,k=(0,q.useCallback)(()=>setTimeout(()=>{T.current&&(T.current=!1,f(!1),h(n("sliderCommitSlow")))},Wh),[n]);(0,q.useLayoutEffect)(()=>{if(T.current||ce.current)return;let M=ql(a,o),$=a[M]?.id??"";C.current=$,d(xe=>xe===$?xe:$),h(null)},[H,a,o]),(0,q.useEffect)(()=>{t.load().catch(()=>{})},[t]),(0,q.useEffect)(()=>{r?.load().catch(()=>{})},[r]);let E=o.current,_=o.groups.find(M=>M.id===E?.provider),y=_?.models.find(M=>M.id===E?.model)?.name??(E===null?n("triggerFallback"):E.model),A=E===null?"":Qt(_??{id:E.provider}),R=a.find(M=>M.id===s)?.name??n("effortDefault"),D=(0,q.useSyncExternalStore)(Dn,In),K=(0,q.useSyncExternalStore)(Fn,Tr),N=(0,q.useSyncExternalStore)(qn,Sr),V=(0,q.useCallback)((M,$)=>i.get(M)?.get($),[i]),Q=(0,q.useCallback)((M,$)=>Kl($,V(M,$.id)),[V]),ae=(0,q.useCallback)((M,$)=>jh(M).filter(xe=>!Q($,xe)),[Q]),de=o.groups.filter(M=>ae(M,M.id).length>0&&!K.includes(M.id)).map(M=>M.id),le=Pn(ya(de),D),be=p!==null&&le.includes(p)?p:E!==null&&le.includes(E.provider)?E.provider:le[0]??null,Te=c.trim().toLowerCase(),ie=Te!=="",fe=ie?le.flatMap(M=>Ca(ae(o.groups.find($=>$.id===M),M),N[M]??[]).filter($=>($.name??$.id).toLowerCase().includes(Te)||$.id.toLowerCase().includes(Te)).map($=>({provider:M,choice:$}))):[],Re=ie?fe:be===null?[]:Ca(ae(o.groups.find(M=>M.id===be),be),N[be]??[]).map(M=>({provider:be,choice:M})),Oe=E===null?"":E.provider+"/"+E.model,Ie=n("sliderNoCurrent"),X=(0,q.useCallback)(()=>{let M=x.current?.closest('[role="menu"], [role="group"]');M!=null&&(M.tabIndex=-1,M.focus({preventScroll:!0}))},[]),me=(0,q.useCallback)(async(M,$)=>{if(T.current)return;let xe=t.store.getSnapshot().current;if(ie&&u(""),xe!==null&&xe.provider===M&&xe.model===$)return;T.current=!0,X(),f(!0),h(null);let Ze=k();try{let et=await F({provider:M,model:$}),xt=Ya(et);if(xt!==void 0)throw new Error(xt)}catch(et){h(et instanceof Error?et.message:String(et))}finally{clearTimeout(Ze),T.current=!1,f(!1)}},[k,t,X,ie,F]),W=(0,q.useCallback)(async M=>{if(T.current||M===o.current?.reasoningEffort&&o.status!=="error")return;T.current=!0;let $=C.current;X(),f(!0),h(null),d(M);let xe=k();try{let Ze=o.current;if(Ze===null)throw new Error(n("sliderNoCurrent"));let et=await F({provider:Ze.provider,model:Ze.model,reasoningEffort:M}),xt=Ya(et);if(xt!==void 0)throw new Error(xt);let ln=t.store.getSnapshot(),Ud=a.find(Wg=>Wg.id===ln.current?.reasoningEffort)?.id??M;C.current=Ud,d(Ud)}catch(Ze){C.current=$,d($),h(Ze instanceof Error?Ze.message:String(Ze))}finally{clearTimeout(xe),T.current=!1,f(!1)}},[k,t,X,a,F,o.current,o.status,n]),ee=(0,q.useRef)(null),oe=(0,q.useRef)(null),ye=(0,q.useRef)(null),ce=(0,q.useRef)(!1),ve=(0,q.useRef)(null),_e=(0,q.useRef)(null),Fe=(0,q.useRef)(null),[wt,Qe]=(0,q.useState)(null),[O,te]=(0,q.useState)(null),ge=Math.max(0,a.findIndex(M=>M.id===s)),Ce=wt??ge,l=(O??(a.length>1?Ce/(a.length-1):0))*100,b=M=>{let $=ee.current;if($===null)return 0;let xe=$.getBoundingClientRect();return xe.width<=0?0:Math.min(1,Math.max(0,(M-xe.left)/xe.width))},L=M=>a.length>1?Math.round(M*(a.length-1)):0,P=M=>{_e.current=M;let $=M*100;oe.current!==null&&(oe.current.style.clipPath=`inset(0 ${100-$}% 0 0)`),ye.current!==null&&(ye.current.style.left=`${$}%`)},j=M=>{if(a.length===0)return;let $=b(M);Fe.current===null&&(Fe.current=requestAnimationFrame(()=>{Fe.current=null,ce.current&&_e.current!==null&&P(_e.current)})),_e.current=$;let xe=L($);xe!==ve.current&&(ve.current=xe,Qe(xe),te($))},pe=()=>{ve.current=null,_e.current=null,Fe.current!==null&&(cancelAnimationFrame(Fe.current),Fe.current=null),Qe(null),te(null)},ne=M=>{if(H){if(M.preventDefault(),ce.current=!0,typeof M.currentTarget.setPointerCapture=="function")try{M.currentTarget.setPointerCapture(M.pointerId)}catch{}ve.current=L(b(M.clientX)),j(M.clientX),Qe(ve.current),te(_e.current)}},re=M=>{ce.current&&j(M.clientX)},Ae=M=>{if(!ce.current)return;if(ce.current=!1,typeof M.currentTarget.releasePointerCapture=="function"&&M.currentTarget.hasPointerCapture?.(M.pointerId)===!0)try{M.currentTarget.releasePointerCapture(M.pointerId)}catch{}let $=L(b(M.clientX)),xe=a[$];if(xe===void 0){pe();return}W(xe.id).finally(pe)},Se=M=>{if(!H)return;let $;if(M.key==="ArrowRight"||M.key==="ArrowUp"?$=Math.min(a.length-1,Ce+1):M.key==="ArrowLeft"||M.key==="ArrowDown"?$=Math.max(0,Ce-1):M.key==="Home"?$=0:M.key==="End"&&($=a.length-1),$===void 0)return;M.preventDefault();let xe=a[$];xe!==void 0&&W(xe.id)},{tip:zt,onEnter:He,onLeave:dn}=zh(),vo=(0,q.createElement)("div",{className:"bre-menu-head"},(0,q.createElement)("span",{className:"bre-row-label"},n("modelRowLabel")),(0,q.createElement)("span",{className:"bre-menu-cur"},(0,q.createElement)("span",{className:"bre-menu-name","aria-label":E===null?y:A+" \xB7 "+y,onMouseEnter:M=>{He(M,E===null?y:A+" \xB7 "+y)},onMouseLeave:dn},y),A===""?null:(0,q.createElement)("span",{className:"bre-menu-prov"},A))),U=(0,q.createElement)("div",{className:"bre-menu-search"},(0,q.createElement)("div",{className:"bre-menu-search-box"},(0,q.createElement)("span",{className:"bre-menu-search-icon","aria-hidden":!0},(0,q.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,q.createElement)("circle",{cx:"7",cy:"7",r:"4.5"}),(0,q.createElement)("path",{d:"M10.5 10.5L14 14",strokeLinecap:"round"}))),(0,q.createElement)("input",{type:"text",className:"bre-menu-search-input",role:"searchbox",placeholder:n("modelSearchPlaceholder"),"aria-label":n("modelSearchPlaceholder"),value:c,spellCheck:!1,autoComplete:"off",onChange:M=>{u(M.currentTarget.value)},onKeyDown:M=>{M.key!=="Escape"||c===""||(M.preventDefault(),M.stopPropagation(),u(""))}}),c===""?null:(0,q.createElement)("button",{type:"button",className:"bre-menu-search-clear",title:n("modelSearchClear"),"aria-label":n("modelSearchClear"),onClick:()=>{u("")}},(0,q.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,q.createElement)("path",{d:"M4 4L12 12M12 4L4 12",strokeLinecap:"round"}))))),he=(0,q.createElement)("div",{className:"bre-providers",role:"group","aria-label":n("modelRowLabel")},...le.map(M=>{let $=o.groups.find(xe=>xe.id===M);return(0,q.createElement)("button",{key:M,type:"button",className:"bre-provider"+(M===be?" is-open":"")+(M===E?.provider?" is-current":""),disabled:B,"aria-expanded":M===be,onMouseLeave:dn,onClick:()=>{g(M),u("")}},(0,q.createElement)("span",{className:"bre-option-name","aria-label":Qt($),onMouseEnter:xe=>{He(xe,Qt($))}},Qt($)),(0,q.createElement)("span",{className:"bre-provider-count"},String(ae($,M).length)))}),...le.length===0?[(0,q.createElement)("div",{key:"no-providers",className:"bre-empty"},Ie)]:[]),De=(0,q.createElement)("div",{className:"bre-provider-models",role:"group","aria-label":n("modelRowLabel")},...Re.length===0?[(0,q.createElement)("div",{key:"no-models",className:"bre-empty"},ie?n("modelSearchNoMatches"):Ie)]:Re.map(({provider:M,choice:$})=>{let xe=M+"/"+$.id,Ze=xe===Oe,et=$.name??$.id,xt=ie?Qt(o.groups.find(ln=>ln.id===M))+" \xB7 "+et:et;return(0,q.createElement)("button",{key:xe,type:"button",className:"bre-option"+(Ze?" is-active":""),disabled:B,"aria-pressed":Ze,onMouseLeave:dn,onClick:()=>{me(M,$.id)}},(0,q.createElement)("span",{className:"bre-option-name","aria-label":xt,onMouseEnter:ln=>{He(ln,xt)}},ie?(0,q.createElement)("span",{className:"bre-option-origin"},Qt(o.groups.find(ln=>ln.id===M))+" \xB7 "):null,et),tb(V(M,$.id)?.contextWindow,n),eb($,n,V(M,$.id)?.input,Kl($,V(M,$.id))))})),Ge=(0,q.createElement)("div",{className:"bre-menu-foot"},H?(0,q.createElement)("div",{className:"bre-menu-slider"},(0,q.createElement)("div",{className:"bre-effort-slider-head","aria-hidden":!0},(0,q.createElement)("span",{className:"bre-effort-slider-head-label"},n("effortRowLabel")),(0,q.createElement)("span",{className:"bre-effort-slider-head-value"},a[Ce]?.name??R)),(0,q.createElement)("div",{className:"bre-effort-slider",ref:ee,role:"slider",tabIndex:0,"aria-label":n("effortRowLabel"),"aria-valuemin":0,"aria-valuemax":a.length-1,"aria-valuenow":Ce,"aria-valuetext":a[Ce]?.name,"aria-disabled":B||void 0,"data-bre-dragging":wt===null?void 0:"true",onPointerDown:ne,onPointerMove:re,onPointerUp:Ae,onPointerCancel:Ae,onKeyDown:Se},(0,q.createElement)("span",{className:"bre-effort-slider-fill",ref:oe,style:{clipPath:`inset(0 ${100-l}% 0 0)`}}),...a.map((M,$)=>$===Ce?null:(0,q.createElement)("span",{key:"tick-"+M.id,className:"bre-effort-slider-tick",style:{left:a.length>1?`${$/(a.length-1)*100}%`:"0%"}})),(0,q.createElement)("span",{className:"bre-effort-slider-thumb",ref:ye,style:{left:`${l}%`}})),(0,q.createElement)("div",{className:"bre-effort-slider-labels","aria-hidden":!0},...a.map((M,$)=>(0,q.createElement)("span",{key:M.id,className:"bre-effort-slider-label"+($===0?" is-first":"")+($===a.length-1?" is-last":"")+($===Ce?" is-on":""),style:{left:a.length>1?`${$/(a.length-1)*100}%`:"0%"}},M.name)))):(0,q.createElement)("span",{className:"bre-row-value is-muted"},n("sliderNoLevels")));return(0,q.createElement)("div",{className:"bre-slider-body",ref:x},(0,q.createElement)("div",{className:"bre-card"},vo,U,(0,q.createElement)("div",{className:"bre-panel bre-panel-models"},he,De),Ge),I===null?null:(0,q.createElement)("div",{className:"bre-model-error",role:"status"},I),zt===null?null:(0,q.createElement)($h,{key:"tip",state:zt}))}var Le=require("react"),jl='section[role="group"]',Qa='button[role="menuitemradio"]';function zl(e){return e.querySelector(jl)!==null}function Ja(e){return Array.from(e.querySelectorAll(Qa)).filter(t=>!t.disabled&&t.style.display!=="none")}function nb(e){let t=e.getAttribute("aria-labelledby");return(t===null?null:e.ownerDocument.getElementById(t))?.textContent?.toLowerCase()??""}function Gl(e,t,n=new Map){let r=d=>{n.has(d)||n.set(d,d.style.display),d.style.display="none"},o=d=>{let c=n.get(d);c!==void 0&&(d.style.display=c,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(jl)),s=0;if(i.length===0){for(let d of[...n.keys()])o(d);for(let d of a)s+=d.querySelectorAll(Qa).length;return s}for(let d of a){let c=nb(d),u=Array.from(d.querySelectorAll(Qa)),p=0;for(let g of u){let m=(g.getAttribute("title")??"").toLowerCase(),f=(g.textContent??"").toLowerCase(),v=`${c} ${m} ${f}`;i.every(h=>v.includes(h))?(o(g),p+=1):r(g)}p>0?(o(d),s+=p):r(d)}return s}function $l({menu:e,t}){let[n,r]=(0,Le.useState)(""),[o,i]=(0,Le.useState)(0),a=(0,Le.useRef)(null),s=(0,Le.useRef)(""),d=(0,Le.useRef)(new Map),c=(0,Le.useCallback)(m=>{s.current=m;let f=Gl(e,m,d.current);i(f)},[e]);(0,Le.useEffect)(()=>()=>{Gl(e,"",d.current)},[e]),(0,Le.useEffect)(()=>{let m=new MutationObserver(()=>{s.current.trim().length!==0&&c(s.current)});return m.observe(e,{childList:!0,subtree:!0}),()=>{m.disconnect()}},[e,c]),(0,Le.useEffect)(()=>{let m=f=>{if(s.current.trim().length===0)return;let v=f.key;if(!(v==="ArrowDown"||v==="ArrowUp")&&!(v==="Home"||v==="End"||v==="PageUp"||v==="PageDown")||f.target===a.current||f.target instanceof Node&&!e.contains(f.target))return;let C=Ja(e);if(C.length===0)return;let T=C.findIndex(B=>B===document.activeElement),H;v==="Home"||v==="PageUp"?H=0:v==="End"||v==="PageDown"?H=C.length-1:v==="ArrowDown"?H=T===-1?0:(T+1)%C.length:H=T===-1?C.length-1:(T-1+C.length)%C.length,f.preventDefault(),f.stopPropagation(),C[H]?.focus()};return e.addEventListener("keydown",m,!0),()=>{e.removeEventListener("keydown",m,!0)}},[e]);let u=m=>{let f=m.key;if(f==="ArrowDown"){m.preventDefault(),m.stopPropagation(),Ja(e)[0]?.focus();return}if(n.trim().length>0&&(f==="ArrowUp"||f==="Home"||f==="PageUp"||f==="End"||f==="PageDown")){let v=Ja(e);v.length>0&&(m.preventDefault(),m.stopPropagation(),v[f==="ArrowUp"||f==="End"||f==="PageDown"?v.length-1:0]?.focus());return}f==="Escape"&&n.length>0&&(m.preventDefault(),m.stopPropagation(),r(""),c(""))},p=()=>{r(""),c(""),a.current?.focus({preventScroll:!0})},g=o===0&&n.trim().length>0;return(0,Le.createElement)("div",{className:"bre-model-search-box"+(g?" has-empty":""),"data-bre-search":"1"},(0,Le.createElement)("div",{className:"bre-search-input-wrapper"},(0,Le.createElement)("span",{className:"bre-search-icon","aria-hidden":"true"},(0,Le.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,Le.createElement)("circle",{cx:"7",cy:"7",r:"4.5"}),(0,Le.createElement)("path",{d:"M10.5 10.5L14 14",strokeLinecap:"round"}))),(0,Le.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:m=>{let f=m.currentTarget.value;r(f),c(f)},onKeyDown:u}),n.length>0?(0,Le.createElement)("button",{type:"button",className:"bre-search-clear",title:t("modelSearchClear"),"aria-label":t("modelSearchClear"),onClick:p},(0,Le.createElement)("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5"},(0,Le.createElement)("path",{d:"M4 4L12 12M12 4L4 12",strokeLinecap:"round"}))):null),g?(0,Le.createElement)("div",{className:"bre-search-empty",role:"status"},t("modelSearchNoMatches")):null)}var Ko=require("react"),Vl=require("react-dom"),Yl=require("react-dom/client");function St(){return document.body}function it(e,t,n){let r=(0,Yl.createRoot)(e);return n?.sync===!0?(0,Vl.flushSync)(()=>{r.render(t)}):r.render(t),{wrapper:e,root:r}}function qe(e){e!==void 0&&(e.root.unmount(),e.wrapper.remove())}var $e=class extends Ko.Component{constructor(){super(...arguments);je(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,Ko.createElement)("div",{style:{color:"#c00",fontSize:"11px",whiteSpace:"pre-wrap",padding:"6px"}},`${this.props.fallbackText}: ${this.state.error}`):this.props.children}};var rb="conversation.input.model";function Xl(e){return e.querySelector("[data-composer-card]")??void 0}function Za(e){return e.querySelector(`[data-slot="${rb}"]`)??void 0}function Jl(e){let t=Za(e)??e;return Array.from(t.querySelectorAll('button[aria-haspopup="menu"]'))}function es(e){if(e==null)return!1;let t=e.getAttribute("role");return t==="menu"||t==="group"}function ts(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 es(r)?r:void 0}function ns(e=document){let t=Xl(e);if(t===void 0)return;for(let r of Jl(t)){let o=Ql(r,e);if(o!==void 0)return o}let n=Za(t)??t;for(let r of Array.from(n.querySelectorAll('[role="menu"], [role="group"]')))if(r.previousElementSibling?.matches('button[aria-haspopup="menu"]')&&es(r)&&!(r.getAttribute("role")==="group"&&r.querySelector('[role="menuitemradio"], section[role="group"]')===null))return r}function rs(e=document){let t=Xl(e);if(t===void 0)return;let n=Za(t),r=Jl(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(es(i.nextElementSibling))return i;return n===void 0?r.at(-1):o}}function Zl(){return ns()}function ec(){return rs()}var ob=()=>{(0,tc.flushSync)(()=>{window.dispatchEvent(new Event("resize"))})};function nc(e){let{menuOf:t,triggerOf:n,t:r,refreshed:o,sliderEnabled:i,directory:a}=e,s,d,c,u,p,g,m,f,v=()=>{f?.removeAttribute("data-bre-provider"),f=void 0},h=()=>{let S=n();f!==void 0&&f!==S&&v();let y=g?.store.getSnapshot(),A=y?.current;if(S===void 0||A===null||A===void 0){S===f&&v();return}let R=y?.groups.find(K=>K.id===A.provider),D=R===void 0?A.provider:Qt(R);if(D.trim()===""){S===f&&v();return}S.dataset.breProvider=D,f=S},x=()=>{let S=a();S!==g&&(m?.(),m=void 0,g=S,S!==void 0&&(m=S.store.subscribe(h))),h()},C=()=>{qe(c),c=void 0},T=new Map,H=()=>{for(let[y,A]of T)y.style.display=A;T.clear();let S=t();S!==void 0&&S.getAttribute("tabindex")==="-1"&&S.removeAttribute("tabindex")},B=S=>S.getAttribute("aria-hidden")!=="true"||S.childElementCount>0?!1:(S.textContent??"").trim()==="",I=(S,y)=>{for(let D of Array.from(T.keys()))(!D.isConnected||D.parentElement!==S)&&T.delete(D);let A=[];for(let D of Array.from(S.children))D!==y&&(B(D)||A.push(D));let R=document.activeElement;R!==null&&R!==y&&!y.contains(R)&&A.some(D=>D.contains(R))&&(S.tabIndex=-1,S.focus({preventScroll:!0}));for(let D of A)T.has(D)||T.set(D,D.style.display),D.style.display!=="none"&&(D.style.display="none")},F=S=>{let y=S.querySelector('section[role="group"]'),A=y?.parentElement,R=A!=null&&A.parentElement===S?A:y;if(c===void 0){let D=document.createElement("div");D.dataset.plugin=Me,D.dataset.breSearch="1",S.insertBefore(D,R),c=it(D,(0,Ir.createElement)($e,{fallbackText:r("modelSearchFailed"),children:o(()=>(0,Ir.createElement)($l,{menu:S,t:r}))}),{sync:!0});return}if(c.wrapper.parentElement!==S){S.insertBefore(c.wrapper,R);return}R!==null&&c.wrapper.nextSibling!==R&&S.insertBefore(c.wrapper,R)},k=S=>{if(!i()){qe(s),s=void 0,d=void 0,S.classList.remove("bre-model-menu-host"),H();for(let K of Array.from(S.children))K.getAttribute("role")==="menuitem"&&(K.style.display="");return}let y=a();if(y===void 0)return;if(s!==void 0&&d!==y&&(qe(s),s=void 0,d=void 0),s===void 0){d=y;let K=document.createElement("div");K.dataset.plugin=Me,K.dataset.breSlider="1",S.insertBefore(K,S.firstChild),s=it(K,(0,Ir.createElement)($e,{fallbackText:r("renderFailed"),children:o(()=>(0,Ir.createElement)(Wl,{directory:y,configuredInputs:e.configuredInputs,t:r}))}),{sync:!0})}else(s.wrapper.parentElement!==S||S.firstChild!==s.wrapper)&&S.insertBefore(s.wrapper,S.firstChild);S.classList.add("bre-model-menu-host");let A=Array.from(S.children).filter(K=>K.getAttribute("role")==="menuitem"),R=s.wrapper;if(ts(S)){R.style.display="",I(S,R);return}if(H(),Array.from(S.querySelectorAll('[role="menuitemradio"]')).some(K=>!R.contains(K)))s.wrapper.contains(document.activeElement)&&(S.tabIndex=-1,S.focus({preventScroll:!0})),s.wrapper.style.display="none";else{s.wrapper.style.display="";for(let K of A)K.style.display="none"}};return{reconcile:()=>{x();let S=t();if(S===void 0){s!==void 0&&(i()?s.wrapper.remove():(qe(s),s=void 0,d=void 0)),C(),u=void 0,p=void 0,H();return}let y=ts(S),A=y&&i(),R=!y&&zl(S);R?F(S):C(),k(S),(R!==u||A!==p)&&(u=R,p=A,(R||A||i())&&ob())},dispose:()=>{m?.(),m=void 0,g=void 0,v(),qe(s),s=void 0,d=void 0,C(),H(),u=void 0,p=void 0}}}var ib=350;function rc(e){let t,n,r=0,o=()=>{if(t!==void 0)return Promise.resolve();let s=r;return n??(n=we(e.api).then(d=>{if(d.namespace===void 0){n=void 0;return}let c=new Map;for(let[u,p]of Object.entries(ze(d.namespace))){let g=Array.isArray(p.models)?p.models:[];for(let m of g){if(typeof m!="object"||m===null||Array.isArray(m))continue;let f=m.id,v=m[Hn];typeof f=="string"&&typeof v=="string"&&v.length>0&&c.set(`${u}/${f}`,v)}}s===r?t=c:n=void 0}).catch(()=>{s===r&&(n=void 0)})),n};return{of:async(s,d)=>{if(t===void 0){let c=o();await new Promise(u=>{let p=!1,g=()=>{p||(p=!0,u())},m=setTimeout(g,ib);c.then(()=>{clearTimeout(m),g()},()=>{clearTimeout(m),g()})})}return t?.get(`${s}/${d}`)},invalidate:()=>{r+=1,t=void 0,n=void 0}}}function ab(e){let t=e.input;return Array.isArray(t)&&t.length>0?!0:e[Lt]===!0||e[mt]===!0}function os(e,t=()=>!0,n={},r=0){let o=n.efforts!==!1,i=n.modalities!==!1;if(!Z(e))return;let a={};for(let s of Object.keys(e)){if(!t(s))continue;let d=e[s],c=Z(d)&&Array.isArray(d.models)?d.models:void 0;if(c===void 0||c.length===0)continue;let u=c,p=[],g=!1;for(let m of u){if(!Z(m)){p.push(m);continue}let f=m,v=f.reasoningEfforts!==void 0||f[pt]===!0,h=ab(f);if((v||!o)&&(h||!i)){let F=sb(f,e,s);F!==void 0?(g=!0,p.push(F)):p.push(f);continue}let x=typeof f.id=="string"?f.id:"";if(x.length===0){p.push(f);continue}let C=cn(e,s),T=typeof f.name=="string"?f.name:void 0,H=Rt(x,{...C,displayName:T??C.displayName});if(H.efforts===void 0){p.push(f);continue}let B={...f},I=!1;if(!v&&o&&H.confidence!=="low"&&(I=!0,B.reasoningEfforts=H.efforts,B[Rn]=r,H.compat!==void 0)){let F=Z(f.compat)?f.compat:{};B.compat={...F,...H.compat}}if(!h&&i&&(H.imageGen===!0?(I=!0,B[mt]=!0):H.input!==void 0&&(I=!0,B.input=[...H.input])),!I){p.push(f);continue}g=!0,p.push(B)}g&&(a[s]={models:p})}return Object.keys(a).length===0?void 0:{providers:a}}function is(e){if(!Z(e))return;let t={};for(let[n,r]of Object.entries(e)){if(!Z(r))continue;let o=typeof r.api=="string"?r.api:"";if(o.length===0)continue;let i={},a=Z(r.compat)?qa(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=[],c=!1;for(let u of s){if(!Z(u)||!Z(u.compat)){d.push(u);continue}let p=qa(u.compat,o);if(p===void 0){d.push(u);continue}c=!0,d.push({...u,compat:p})}c&&(i.models=d)}Object.keys(i).length>0&&(t[n]=i)}return Object.keys(t).length===0?void 0:{providers:t}}function sb(e,t,n){if(!Z(e.reasoningEfforts)||e[pt]===!0)return;let r=e.compat,o=Z(r)?{...r}:{};if(o.supportsDeveloperRole===void 0&&Ba(cn(t,n)))return{...e,compat:{...o,supportsDeveloperRole:!1}}}function oc(e){let t,n=0,r=()=>{if(t!==void 0)return t;let i=(async()=>{try{let a=await fetch(zd,{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 we(e.api),c=d.namespace;if(a!==n||c===void 0||d.writable!==!0)return;let u=fn(c);if(u===void 0||os(u,()=>!0,{modalities:s.modalityAutofill},c.revision)===void 0)return;let g=d.source==="scope"?await we(e.api,{fresh:!0}):d,m=g.namespace;if(a!==n||m===void 0||g.writable!==!0)return;let f=fn(m);if(f===void 0)return;let v=os(f,()=>!0,{modalities:s.modalityAutofill},m.revision);if(v===void 0)return;let h=v.providers,x=Object.entries(h).map(([T,H])=>({op:"set",path:["providers",T,"models"],value:H.models})),C=await e.api.settings.mutate(Ue,x,m.revision);C.ok||console.error(`[bre] idle autofill refused: ${C.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 ic(e){let t=async n=>{let r=n??await we(e.api),o=r.namespace;if(o===void 0||r.writable!==!0)return;let i=fn(o);if(i===void 0||is(i)===void 0)return;let a=r.source==="scope"?await we(e.api,{fresh:!0}):r,s=a.namespace;if(s===void 0||a.writable!==!0)return;let d=fn(s);if(d===void 0)return;let c=is(d);if(c===void 0)return;let u=c.providers,p=[];for(let[m,f]of Object.entries(u))for(let v of["compat","models"])f[v]!==void 0&&p.push({op:"set",path:["providers",m,v],value:f[v]});if(p.length===0)return;let g=await e.api.settings.mutate(Ue,p,s.revision);g.ok||console.error(`[bre] compat cleanup refused: ${g.error.message}`)};return{run:n=>{t(n).catch(r=>{console.error(`[bre] compat cleanup failed: ${r instanceof Error?r.message:String(r)}`)})}}}var Ed=require("react"),Fm=require("react-dom"),qm=require("react-dom/client");var Ee=require("react");var Zt=Ml;function mn(e){let t={};for(let n of Zt){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 Wn(e){let t=!1,n=!1,r={};for(let o of Zt){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 Dr(e,t){if(e===t)return!0;if(e===!1||e===void 0||t===!1||t===void 0)return!1;let n=Zt.filter(o=>e[o]!==void 0),r=Zt.filter(o=>t[o]!==void 0);return n.length!==r.length?!1:n.every(o=>e[o]===t[o])}function ac(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 as="bre:auto-effort",sc=Promise.resolve();function dc(e){sc=sc.then(e,e).then(()=>{},()=>{})}function lc(e,t=document){t.dispatchEvent(new CustomEvent(as,{detail:{route:e}}))}function cc(e,t=document){let n=r=>{let o=r.detail;typeof o?.route!="string"||o.route.length===0||e(o.route)};return t.addEventListener(as,n),()=>{t.removeEventListener(as,n)}}var G=require("react/jsx-runtime"),db=["M3.4 4.2h9.2","M8 4.2v8.2","M5.9 12.4h4.2"],lb=["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"],cb=["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"],ub=["M8 3.2 13.6 12.8H2.4L8 3.2Z","M8 6.9v2.5","M8 11.3h.01"],fb=["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"],pb=["M4.5 6.5 8 10 11.5 6.5"],mb=["M6.5 4.5 10 8 6.5 11.5"];function Gn({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 qt(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 Wo(e){return e.imageGen?{input:null,imageGen:!0}:e.declared?{input:e.image?["text","image"]:["text"],imageGen:!1}:{input:null,imageGen:!1}}function Uo(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 ss(e,t,n){let r=e?t:!1;return e&&r===void 0&&n===void 0?"keep":r}function Go(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 jo({route:e,routeApi:t,routeBaseURL:n,modelId:r,modelName:o,efforts:i,effortsUnset:a=!1,input:s,imageGen:d,compat:c,defaultEffort:u,index:p,staged:g=!1,officialInputTypes:m=!1,api:f,readOnly:v,t:h}){let[x,C]=(0,Ee.useState)(()=>mn(i)),[T,H]=(0,Ee.useState)(()=>qt(s,d)),[B,I]=(0,Ee.useState)(()=>i!==!1),[F,k]=(0,Ee.useState)(()=>u??""),[E,_]=(0,Ee.useState)(!1),[S,y]=(0,Ee.useState)(void 0),[A,R]=(0,Ee.useState)(()=>Zt.some(U=>x[U].on&&x[U].wire.trim()!==(U==="off"?"":U))),D=(0,Ee.useRef)(void 0),K=(0,Ee.useRef)(void 0);K.current===void 0&&(K.current=f.readCapacities?.()??{});let[N,V]=(0,Ee.useState)(()=>Tt(K.current?.contextWindow)),[Q,ae]=(0,Ee.useState)(()=>Tt(K.current?.maxTokens)),[de,le]=(0,Ee.useState)(void 0),be=(0,Ee.useRef)(!1),Te=(0,Ee.useRef)(i),ie=(0,Ee.useRef)(s),fe=(0,Ee.useRef)(d),Re=(0,Ee.useRef)(u),Oe=(0,Ee.useRef)(void 0),Ie=(0,Ee.useRef)(i);Ie.current=i;let X=(0,Ee.useRef)(a);X.current=a,(0,Ee.useEffect)(()=>cc(U=>{if(U!==e||Ie.current!==void 0||X.current)return;let he=Oe.current;he!==void 0&&dc(he)}),[e]),(0,Ee.useEffect)(()=>{Dr(Te.current,i)||(Te.current=i,be.current||(C(mn(i)),I(i!==!1))),(ie.current!==s||fe.current!==d)&&(ie.current=s,fe.current=d,be.current||H(qt(s,d))),Re.current!==u&&(Re.current=u,be.current||k(u??""))},[i,s,d,u]);let me=Zt.filter(U=>x[U].on),W=F===(u??"")?void 0:F===""?null:F,ee=B?Wn(x):!1,oe=!Dr(ee,i)||!Uo(T,s,d)||W!==void 0,ye=(0,Ee.useRef)(void 0),ce=()=>{be.current=!0},ve=(U,he,De,Ge=B)=>{let M=ss(Ge,Wn(U),i),xe=!Uo(he,s,d)?Wo(he):void 0,Ze=De===(u??"")?void 0:De===""?null:De,et=Go({efforts:M,input:xe?.input,imageGen:xe?.imageGen,defaultEffort:Ze,appliedCompat:D.current,routeApi:t,initialCompat:c}),xt=JSON.stringify(et);ye.current!==xt&&(ye.current=xt,f.commit(e,r,et))},_e=(U,he)=>{ce();let De=!he&&F===U?"":F;De!==F&&k(De);let Ge={...x,[U]:{...x[U],on:he}};he&&U!=="off"&&Ge[U].wire.trim().length===0&&(Ge[U]={...Ge[U],wire:U}),C(Ge),ve(Ge,T,De),y(void 0)},Fe=U=>{ce(),I(U);let he=U?F:"";he!==F&&k(he),ve(x,T,he,U),y(void 0)},wt=(U,he)=>{ce();let De={...x,[U]:{...x[U],wire:he}};C(De),ve(De,T,F),y(void 0)},Qe=U=>{ce();let he={declared:!0,image:U,imageGen:!1};H(he),ve(x,he,F),y(void 0)},O=()=>{ce();let U={declared:!1,image:!1,imageGen:!1};H(U),ve(x,U,F),y(void 0)},te=U=>{ce();let he=U?{declared:!1,image:!1,imageGen:!0}:{declared:!1,image:!1,imageGen:!1};H(he),ve(x,he,F),y(void 0)},ge=U=>{ce(),k(U),ve(x,T,U),y(void 0)},Ce=(U,he)=>{let De=he.slice(0,20),Ge=U==="context"?De:N,M=U==="output"?De:Q;le(U),U==="context"?V(De):ae(De),f.setCapacities?.({contextWindow:Ht(Ge),maxTokens:Ht(M)})},l=U=>{U==="context"?V(he=>Tt(Ht(he))):ae(he=>Tt(Ht(he))),le(void 0)},b=U=>{ce();let he=U.efforts!==!1;I(he);let De=mn(U.efforts);C(De);let Ge=U.imageGen===!0?qt(void 0,!0):U.input===void 0?T:qt(U.input);Ge!==T&&H(Ge);let M=F===""&&U.defaultEffort!==void 0?U.defaultEffort:F;if(M!==F&&k(M),D.current=U.compat,U.contextWindow!==void 0||U.maxTokens!==void 0){f.fillCapacities?.(U.contextWindow,U.maxTokens);let $=f.readCapacities?.();V(Tt($?.contextWindow)),ae(Tt($?.maxTokens))}y(void 0),ve(De,Ge,M,he)},L=async()=>{if(!(v||E)){_(!0),y(void 0);try{let U=g?await f.suggest(e,r,o,{...t===void 0?{}:{api:t},...n===void 0?{}:{baseURL:n}}):await f.suggest(e,r,o);if(!U.ok){y({kind:"error",text:U.error==="no-suggestion"?h("noSuggestion"):U.error});return}b(U.suggestion)}catch(U){y({kind:"error",text:h("writeError",{message:String(U)})})}finally{_(!1)}}};(0,Ee.useEffect)(()=>{Oe.current=L});let P=()=>{be.current=!1,f.withdraw(e,r),C(mn(i)),I(i!==!1),H(qt(s,d)),k(u??""),D.current=void 0;let U=K.current??{};V(Tt(U.contextWindow)),ae(Tt(U.maxTokens)),le(void 0),f.setCapacities?.({contextWindow:U.contextWindow,maxTokens:U.maxTokens}),y(void 0),ye.current=void 0},j=(0,Ee.useMemo)(()=>Rt(r,{...t===void 0?{}:{api:t},...n===void 0?{}:{baseURL:n}}).compat?.thinkingFormat,[r,t,n]),pe=D.current?.thinkingFormat??j,ne=ac(i,pe),re=v||E,Ae=B?me.length===0?h("stateUndeclared"):h("stateDeclared",{count:me.length,default:h(F===""?"defaultEffortUnset":"level_"+F)}):h("thinkingModeOff"),Se=F!==""&&!me.includes(F)?[...me,F]:me,zt=Ht(N),He=Ht(Q),dn=zt!==void 0&&He!==void 0&&He>zt,vo=(0,G.jsxs)(G.Fragment,{children:[dn?(0,G.jsxs)("p",{className:"bre-effort-note bre-warn",children:[(0,G.jsx)(Gn,{paths:ub}),h("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:h("contextWindowLabel")}),(0,G.jsxs)("span",{className:"bre-cap-box",children:[(0,G.jsx)("input",{type:"text",inputMode:"text",className:"bre-cap-input",value:de==="context"?N:Tt(zt),disabled:re,placeholder:h("capacityBlank"),"aria-label":h("contextWindowLabel")+" "+String(p+1),onFocus:()=>{le("context")},onBlur:()=>{l("context")},onChange:U=>{Ce("context",U.target.value)}}),(0,G.jsx)("span",{className:"bre-cap-unit",children:h("tokensUnit")})]}),(0,G.jsx)("p",{className:"bre-effort-note",children:h("capacityInherit")})]}),(0,G.jsxs)("div",{className:"bre-effort-sec",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:h("maxTokensLabel")}),(0,G.jsxs)("span",{className:"bre-cap-box",children:[(0,G.jsx)("input",{type:"text",inputMode:"text",className:"bre-cap-input",value:de==="output"?Q:Tt(He),disabled:re,placeholder:h("capacityBlank"),"aria-label":h("maxTokensLabel")+" "+String(p+1),onFocus:()=>{le("output")},onBlur:()=>{l("output")},onChange:U=>{Ce("output",U.target.value)}}),(0,G.jsx)("span",{className:"bre-cap-unit",children:h("tokensUnit")})]}),(0,G.jsx)("p",{className:"bre-effort-note",children:h("capacityUnitsHint")})]})]})]});return(0,G.jsxs)("div",{className:"bre-effort-editor","data-plugin":Me,children:[(0,G.jsxs)("div",{className:"bre-effort-modality",children:[(0,G.jsx)("span",{className:"bre-effort-label",children:h("inputModality")}),(0,G.jsxs)("div",{className:"bre-pillrow",role:"group","aria-label":h("inputModality"),children:[(0,G.jsxs)("button",{type:"button",className:T.declared?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:re,"aria-pressed":T.declared,"aria-label":h("modalityText")+" "+String(p+1),title:h("modalityText"),onClick:()=>{T.declared?O():Qe(!1)},children:[(0,G.jsx)(Gn,{paths:db}),h("modalityText")]}),(0,G.jsxs)("button",{type:"button",className:T.declared&&T.image?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:re,"aria-pressed":T.declared&&T.image,"aria-label":h("modalityImage")+" "+String(p+1),title:h("modalityImage"),onClick:()=>{Qe(!(T.declared&&T.image))},children:[(0,G.jsx)(Gn,{paths:lb}),h("modalityImage")]}),(0,G.jsxs)("button",{type:"button",className:T.imageGen?"bre-lvl bre-lvl--opt is-on":"bre-lvl bre-lvl--opt",disabled:re,"aria-pressed":T.imageGen,"aria-label":h("modalityImageGen")+" "+String(p+1),title:h("modalityImageGen"),onClick:()=>{te(!T.imageGen)},children:[(0,G.jsx)(Gn,{paths:cb}),h("modalityImageGen")]})]}),(0,G.jsx)("p",{className:"bre-effort-note",children:T.imageGen?h("modalityImageGenHint"):T.declared?h("modalityDeclared"):h("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:B,disabled:re,"aria-label":h("thinkingMode")+" "+String(p+1),onChange:U=>{Fe(U.target.checked)}}),(0,G.jsx)("span",{className:"bre-effort-switch-track","aria-hidden":"true"}),(0,G.jsx)("span",{className:"bre-effort-title",children:h("thinkingMode")})]}),(0,G.jsx)("span",{className:"bre-effort-state",children:Ae})]}),B?(0,G.jsxs)(G.Fragment,{children:[i===!1?(0,G.jsx)("p",{className:"bre-effort-note bre-effort-note--top",children:h("reasoningDisabled")}):null,ne===void 0?null:(0,G.jsx)("p",{className:"bre-effort-note bre-effort-note--top",children:h(ne==="thinking-disabled"?"defaultRiskDisabled":"defaultRiskQwen")})]}):null,B?(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:h("levelsLabel")}),(0,G.jsx)("span",{className:"bre-effort-grow"}),(0,G.jsxs)("button",{type:"button",className:"bre-effort-adapt",disabled:re,onClick:()=>{L()},children:[(0,G.jsx)(Gn,{paths:fb}),h("autoAdapt")]})]}),(0,G.jsx)("div",{className:"bre-pillrow",role:"group","aria-label":h("levelsLabel"),children:Zt.map(U=>{let he=x[U];return(0,G.jsx)("button",{type:"button",className:he.on?"bre-lvl is-on":"bre-lvl",disabled:re,"aria-pressed":he.on,"aria-label":h("level_"+U)+" "+String(p+1),title:h("level_"+U),onClick:()=>{_e(U,!he.on)},children:h("level_"+U)},U)})}),(0,G.jsx)("p",{className:"bre-effort-hint",children:h("levelsHint")}),me.length===0?null:(0,G.jsxs)("button",{type:"button",className:"bre-effort-wiretoggle",disabled:re,"aria-expanded":A,onClick:()=>{R(!A)},children:[(0,G.jsx)(Gn,{paths:A?pb:mb}),h(A?"wireHide":"wireShow")]}),me.length===0||!A?null:(0,G.jsxs)("div",{className:"bre-wire",children:[(0,G.jsx)("div",{className:"bre-wire-grid",children:me.map(U=>(0,G.jsxs)(Ee.Fragment,{children:[(0,G.jsx)("span",{className:"bre-wire-name",children:h("level_"+U)}),(0,G.jsx)("input",{type:"text",className:"bre-effort-wire",value:x[U].wire,disabled:re,placeholder:h("wirePlaceholder"),"aria-label":h("level_"+U)+" "+h("wireValue"),onChange:he=>{wt(U,he.target.value)}})]},U))}),(0,G.jsx)("p",{className:"bre-effort-note",children:h("wireHint")})]})]}),me.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:h("defaultEffortLabel")}),(0,G.jsxs)("select",{className:"bre-effort-select",value:F,disabled:re,"aria-label":h("defaultEffortLabel"),onChange:U=>{ge(U.target.value)},children:[(0,G.jsx)("option",{value:"",children:h("followMemory")}),Se.map(U=>(0,G.jsx)("option",{value:U,children:h("level_"+U)},U))]}),(0,G.jsx)("p",{className:"bre-effort-note",children:h("defaultEffortHint")})]})}),g?(0,G.jsx)("p",{className:"bre-effort-note",children:h("stagedHint")}):null,Wn(x)===void 0&&i!==void 0?(0,G.jsx)("p",{className:"bre-effort-note",children:h("bareHint")}):null,(0,G.jsx)("span",{className:"bre-effort-sep"}),vo,S===void 0?null:(0,G.jsx)("p",{className:"bre-effort-message bre-"+S.kind,role:S.kind==="error"?"alert":"status",children:S.text}),(0,G.jsx)("div",{className:"bre-effort-actions",children:(0,G.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:re||!oe,onClick:P,children:h("reset")})})]}):(0,G.jsxs)("div",{className:"bre-effort-card bre-effort-card--capacity",children:[vo,S===void 0?null:(0,G.jsx)("p",{className:"bre-effort-message bre-"+S.kind,role:S.kind==="error"?"alert":"status",children:S.text})]})]})}function ke(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Ct(e,t){e!==void 0&&e.hidden!==t&&(e.hidden=t)}function Ve(e,t,n){e.classList.contains(t)!==n&&(n?e.classList.add(t):e.classList.remove(t))}function Pr(e,t){e!==void 0&&e.textContent!==t&&(e.textContent=t)}var en="data-bre-auto-effort",ds='[class*="modelCatalog"]',gb='[class*="modelListHead"]',hb='button[class*="linkButton"]',bb="bre-auto-effort",yb="bre-auto-effort-note",vb="data-bre-auto-effort-phase",fc="bre-auto-effort-note-text",pc="bre-auto-effort-note-detail",wb=3e3;function xb(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 ls(e){return Array.from(e.querySelectorAll(ds)).filter(t=>(t.parentElement?.closest(ds)??null)===null)}function zo(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 c=s.querySelector(gb)??s,u=c.querySelector(`[${en}]`)??Eb();gc.set(u,n);let p=kb(c);p!==null?p.nextElementSibling!==u&&p.after(u):c.lastElementChild!==u&&c.append(u),Ab(u,d,o)}let i=new Set,a=new Set(r.values());for(let s of Array.from(e.querySelectorAll(`[${en}]`))){let d=s.closest(ds),c=s.getAttribute(en)??"";if(d===null||!r.has(d)||i.has(d)){s.remove(),c.length>0&&!a.has(c)&&cs(c);continue}i.add(d)}}function cs(e){let t=gn.get(e);t!==void 0&&(t.timer!==null&&clearTimeout(t.timer),t.note.remove(),gn.delete(e))}function mc(){for(let e of Array.from(document.querySelectorAll(`[${en}]`)))e.remove();for(let e of gn.values())e.timer!==null&&clearTimeout(e.timer),e.note.remove();gn.clear()}function kb(e){let t=Array.from(e.querySelectorAll(hb));return t.length===0?null:t[t.length-1]}function Eb(){let e=document.createElement("button");return e.className=bb,e.setAttribute("type","button"),e.setAttribute(en,""),e.addEventListener("click",()=>{let t=e.getAttribute(en)??"";if(t.length===0)return;let n=gc.get(e);n!==void 0&&(lc(t),Tb(t,n))}),e}async function Tb(e,t){if(t.onRequest===void 0)return;uc(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){cs(e);return}let r=xb(n);r!==null&&uc(e,r,t,wb)}function uc(e,t,n,r){let o=gn.get(e);o!==void 0&&!o.note.isConnected&&(o.timer!==null&&clearTimeout(o.timer),gn.delete(e),o=void 0),o!==void 0&&o.timer!==null&&clearTimeout(o.timer);let i=o?.note??Sb();i.setAttribute(vb,t.phase);let a=i.querySelector(`.${fc}`),s=i.querySelector(`.${pc}`),d=Cb(t,n);a.textContent!==d.text&&(a.textContent=d.text),s.textContent!==d.detail&&(s.textContent=d.detail),Ct(s,d.detail.length===0),o===void 0&&document.body.append(i);let c=r>0?setTimeout(()=>{cs(e)},r):null;i.style.setProperty("--bre-note-hold",`${r}ms`),gn.set(e,{note:i,timer:c})}function Sb(){let e=document.createElement("div");return e.className=yb,e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.innerHTML=`<span class="${fc}"></span><span class="${pc}"></span>`,e}var gc=new WeakMap,gn=new Map;function Cb(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 Ab(e,t,n){e.getAttribute(en)!==t&&e.setAttribute(en,t),e.textContent!==n&&(e.textContent=n),e.getAttribute("title")!==null&&e.removeAttribute("title")}var _r="data-bre-drag-handle",us="data-bre-row-head",fs="data-bre-drop-side",$o="bre-row-dragging",Vo="bre-row-drop-target",xc="bre-drag-ghost",kc="bre-drop-line",hc="http://www.w3.org/2000/svg",bc=8,yc=28,vc=12,Mb="transform 180ms cubic-bezier(0.2, 0.7, 0.3, 1)",Lb='button, a, input, textarea, select, [contenteditable], [role="button"], [role="switch"], [role="checkbox"], [role="textbox"], [role="combobox"]';function Yo(){return{sources:new WeakSet,lists:new WeakSet,line:void 0,sighted:new WeakMap,drag:void 0}}function nt(e){return Array.from(e.children).filter(t=>t instanceof HTMLElement)}function Rb(e,t){let n=e.style.order;if(n==="")return t;let r=Number.parseInt(n,10);return Number.isNaN(r)?t:r}function hn(e){return nt(e).map((t,n)=>({row:t,key:Rb(t,n),index:n})).sort((t,n)=>t.key-n.key||t.index-n.index).map(t=>t.row)}function Ec(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 Xo(e,t){Ec(hn(e),t)}function ps(e,t){let n=nt(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=Mb,o.style.transform="")})}function Fr(e,t){return hn(e).map(n=>t(n)).filter(n=>n!==void 0)}function Hb(e,t,n){let r=Fr(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 Ob(e,t){let n=[];for(let o of hn(e)){let i=t(o);i!==void 0&&n.push(i)}let r=[];for(let o of nt(e))t(o)!==void 0&&r.push(o);return{ids:n,rows:r}}function Tc(e,t,n){let r=new Map;for(let[s,d]of t.entries())r.has(d)||r.set(d,s);let o=nt(e),a=[...o.filter(s=>n(s)!==void 0)].sort((s,d)=>{let c=r.get(n(s))??Number.MAX_SAFE_INTEGER,u=r.get(n(d))??Number.MAX_SAFE_INTEGER;return c-u});Ec(o,a)}function qr(e){for(let t of e)t.style.order="",t.style.transition="",t.style.transform=""}function Sc(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 Cc(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 Ac(e,t){let n=e.getBoundingClientRect();return t?n.bottom+bc/2-1:n.top-bc/2-1}function Mc(){let e=document.createElementNS(hc,"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(hc,"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 Lc(e,t){let n=document.createElement("div");n.className=xc,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 Db(e){return!(e instanceof Element)||e.closest(`[${_r}]`)!==null?!1:e.closest(Lb)!==null}function Rc(e){return e.parentElement??void 0}function Hc(e){for(let t of nt(e))t.classList.remove(Vo),t.removeAttribute(fs)}function Jo(e){let t=e.parentElement;for(;t!==null;){if(Ic(t))return t;t=t.parentElement}let n=document.scrollingElement;return n instanceof HTMLElement&&n.scrollHeight>n.clientHeight?n:void 0}function Nc(e){let t=[],n=e.parentElement;for(;n!==null;)Ic(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 ms(e){let t=[],n=e.parentElement;for(;n!==null;)Oc(n)&&t.push(n),n=n.parentElement;let r=document.scrollingElement;return r instanceof HTMLElement&&!t.includes(r)&&t.push(r),t}function Oc(e){let t=e.style.overflowY,n=t.length>0?t:window.getComputedStyle(e).overflowY;return n==="auto"||n==="scroll"||n==="overlay"}function Ic(e){return e.scrollHeight>e.clientHeight&&Oc(e)}function Dc(e,t){let n=e.getBoundingClientRect();return n.height<=0?0:t<n.top+yc?-vc:t>n.bottom-yc?vc:0}function Pc(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 Pb(e){let t=e.line;if(t!==void 0&&t.isConnected)return t;let n=document.createElement("div");return n.className=kc,n.setAttribute("aria-hidden","true"),document.body.appendChild(n),e.line=n,n}function _b(e,t,n){let r=Pb(e),o=t.getBoundingClientRect();r.style.top=`${Ac(t,n)}px`,r.style.left=`${o.left}px`,r.style.width=`${o.width}px`,r.style.display="block",r.setAttribute(fs,n?"after":"before")}function Fb(e){e.line!==void 0&&(e.line.style.display="none")}function qb(e){let t=e.drag;e.drag=void 0,t!==void 0&&(Pc(e,t,0),Fb(e),t.row.classList.remove($o),Hc(t.list),t.dropped||ps(t.list,()=>{Xo(t.list,t.before)}))}function Bb(e,t,n,r){if(Db(t.target)){t.preventDefault();return}let o=Rc(e),i=n.idOf(e);if(o===void 0||i===void 0){t.preventDefault();return}let a={row:e,list:o,before:hn(o),scroller:Jo(o),adapter:n,scrollStep:0,frame:void 0,dropped:!1};r.drag=a,e.classList.add($o);let s=Lc(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 Kb(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=hn(e),s=i!==void 0&&a.includes(i)?i:Cc(a,t.clientY);if(s===void 0)return;t.preventDefault();let d=t.dataTransfer;d!=null&&(d.dropEffect="move");let c=Ib(s,t.clientY),u=Sc(a,r.row,s,c);u!==a.indexOf(r.row)&&ps(e,()=>{Xo(e,va(a,r.row,u))}),Hc(e),s.classList.add(Vo),s.setAttribute(fs,c?"after":"before"),_b(n,s,c),Pc(n,r,r.scroller===void 0?0:Dc(r.scroller,t.clientY))}function Ub(e,t){t.lists.has(e)||(t.lists.add(e),e.addEventListener("dragover",n=>{Kb(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 Wb(e,t,n,r){r.sources.has(e)||(r.sources.add(e),n.seatDrags&&(e.setAttribute(us,"1"),e.setAttribute("draggable","true")),e.addEventListener("dragstart",o=>{Bb(t,o,n,r)}),e.addEventListener("dragend",()=>{qb(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=Rc(t);if(i===void 0)return;let a=hn(i),s=a.indexOf(t);if(s<0)return;let d=s+(o.key==="ArrowUp"?-1:1);d<0||d>=a.length||(o.preventDefault(),ps(i,()=>{Xo(i,va(a,t,d))}),n.commit(i),e.focus())})}function wc(e,t,n,r){let o=r.gripLabel(t,n),i=r.gripHint();e.getAttribute(_r)!==n&&e.setAttribute(_r,n),e.getAttribute("aria-label")!==o&&e.setAttribute("aria-label",o),e.getAttribute("title")!==i&&e.setAttribute("title",i)}function jb(e,t,n,r,o){let i=t.querySelector(`[${_r}]`);if(i!==null){wc(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()),wc(a,e,n,r),Gb(a,e,r,o),Wb(r.seatDrags?t:a,e,r,o),t.insertBefore(a,t.firstChild)}function Qo(e,t,n,r){if(!e.isConnected)return;Ub(t,r);for(let i of nt(t)){let a=n.idOf(i);if(a===void 0)continue;let s=n.seatOf(i);s!==void 0&&jb(i,s,a,n,r)}if(r.drag!==void 0)return;let o=Hb(t,n.idOf,r.sighted.get(t));Tc(t,n.order(o),n.idOf),r.sighted.set(t,Ob(t,n.idOf))}function Zo(e){e.drag=void 0;for(let t of Array.from(document.querySelectorAll(`[${_r}]`)))t.remove();for(let t of Array.from(document.querySelectorAll(`[${us}]`)))t.removeAttribute(us),t.removeAttribute("draggable");for(let t of Array.from(document.querySelectorAll(`.${$o}, .${Vo}`)))t.classList.remove($o,Vo);for(let t of Array.from(document.querySelectorAll(`.${kc}`)))t.remove();for(let t of Array.from(document.querySelectorAll(`.${xc}`)))t.remove();e.line=void 0}var _c=["openai","anthropic"];function ei(e){return e==="anthropic-messages"?"anthropic":"openai"}function Fc(e){return e==="openai-completions"||e==="anthropic-messages"||e==="openai-responses"}var zb=40;function qc(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,zb)}function Bt(e){return typeof e=="string"&&/^[\x21-\x7E]+$/.test(e)}var $b=12;function Bc(e){return e.length===0?"":e.length<$b?"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022":`${e.slice(0,4)}...${e.slice(-4)}`}var Kc="dsh-model-think-level:key-lists:v1";function Uc(){try{return globalThis.localStorage??void 0}catch{return}}function ti(){let e=Uc();if(e===void 0)return{};try{let t=e.getItem(Kc);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 Wc(e){let t=Uc();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(Kc,JSON.stringify(Object.fromEntries(n)))}catch{}}function Gc(e){let t=ti()[e];if(t===void 0||t.state.route!==e)return;let n=Date.now()-t.savedAt;if(!(n>=0)||n>2592e6){Yb(e);return}return t.state}function gs(e,t){if(t.ok!==!0||t.route!==e)return;let n=ti();n[e]={savedAt:Date.now(),state:{...t,probing:void 0,addedRef:void 0}},Wc(n)}function Yb(e){let t=ti();t[e]!==void 0&&(delete t[e],Wc(t))}function jc(){return Object.entries(ti()).map(([e,t])=>({route:e,savedAt:t.savedAt})).sort((e,t)=>t.savedAt-e.savedAt)}function zc(e){for(let t of["error","message"]){let n=e[t];if(typeof n=="string"&&n.length>0)return n}}function $c(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(!Z(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=$c(e.models),a=e.protocol,s=e.auto,d=e.rest,c=Z(d)&&typeof d.remainingMs=="number"?d.remainingMs:void 0,u=Z(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},...Fc(a)?{protocol:a}:{},...s===!0?{auto:!0}:{},...c!==void 0&&c>=0&&u!==void 0?{rest:{remainingMs:c,failures:u}}:{}}}function Jb(e){let t=e.entries;if(!Array.isArray(t))return;let n=[];for(let c of t){let u=Xb(c);u!==void 0&&n.push(u)}let r=e.addedRef,o=e.route,i=$c(e.models),a=e.endpoints,s=Z(a)&&typeof a.openai=="string"?a.openai:null,d=Z(a)&&typeof a.anthropic=="string"?a.anthropic:null;return{ok:!0,route:typeof o=="string"?o:"",entries:n,...typeof r=="string"&&n.some(c=>c.ref===r)?{addedRef:r}:{},...i===void 0?{}:{models:i},...e.probing===!0?{probing:!0}:{},endpoints:{openai:s,anthropic:d}}}async function Qb(e){let t;try{t=await e.json()}catch{t=void 0}if(!Z(t))return{ok:!1};if(t.ok===!0){let r=Jb(t);if(r!==void 0)return r}let n=zc(t);return n===void 0?{ok:!1}:{ok:!1,error:n}}async function Vc(e,t){let n=`${ko}?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 Qb(r)}catch{return{ok:!1}}}var Br=new Map,Zb=64,ey=5e3;function hs(e){let t=Br.get(e);if(t!==void 0)return t;if(Br.size>=Zb){let r=Br.keys().next().value;r!==void 0&&Br.delete(r)}let n={state:Gc(e),updatedAt:0,revision:0};return Br.set(e,n),n}function ty(e){return hs(e).state}function ny(e,t){let n=hs(e),r=Date.now()-n.updatedAt;if(t?.preferCache===!0&&n.state!==void 0&&r>=0&&r<ey)return Promise.resolve(n.state);if(n.read!==void 0)return n.read;let o=n.revision,i=Vc(e).then(a=>n.revision!==o?n.state??a:(a.ok&&(n.state=a,n.updatedAt=Date.now(),gs(e,a)),a)).finally(()=>{n.read===i&&(n.read=void 0)});return n.read=i,i}async function Nt(e,t){let n=hs(e),r=++n.revision;n.read=void 0;let o=await Vc(e,t);return o.ok&&n.revision===r&&(n.revision+=1,n.read=void 0,n.state=o,n.updatedAt=Date.now(),gs(e,o)),o}async function ry(e){try{let t=await fetch(`${ko}?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(!Z(n)||n.ok!==!0)return{ok:!1};let r=n.endpoints;return Z(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 oy(e){try{let n=await(await fetch(`${ko}?route=${encodeURIComponent(e)}&op=balance`,{method:"GET",cache:"no-store",credentials:"same-origin"})).json().catch(()=>{});if(!Z(n)||n.ok!==!0){let o=Z(n)?zc(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 Ye={list:ny,endpoints:ry,balanceEndpoint:oy,cached:ty,add:(e,t,n)=>Nt(e,{op:"add",value:t,...n===void 0?{}:{alias:n}}),rename:(e,t,n)=>Nt(e,{op:"rename",ref:t,...n===void 0?{}:{alias:n}}),remove:(e,t)=>Nt(e,{op:"remove",ref:t}),replace:(e,t,n)=>Nt(e,{op:"value",ref:t,value:n}),setScope:(e,t,n)=>Nt(e,{op:"scope",ref:t,...n===void 0?{}:{models:n}}),setEnabled:(e,t,n)=>Nt(e,{op:"enable",ref:t,enabled:n}),setProtocol:(e,t,n)=>Nt(e,{op:"protocol",ref:t,...n===void 0?{}:{protocol:n}}),setEndpoints:(e,t,n)=>Nt(e,{op:"endpoints",openai:t??"",anthropic:n??""}),setBalanceEndpoint:(e,t)=>Nt(e,{op:"balance",endpoint:t}),probe:e=>Nt(e,{op:"probe"}),async reveal(e,t){try{let n=await fetch(`${xo}?route=${encodeURIComponent(e)}&ref=${encodeURIComponent(t)}`,{method:"GET",cache:"no-store",credentials:"same-origin"});if(!n.ok)return;let r=await n.json();if(!Z(r)||r.ok!==!0)return;let o=r.key;return typeof o=="string"&&o.length>0?o:void 0}catch{return}}};var jn="data-bre-endpoint-rows",Kt="data-bre-endpoint-row",Xn="data-bre-balance-row",ri="data-bre-endpoint-family",Yc="data-bre-endpoint-filled",oi="data-bre-endpoint-field",ii="data-bre-endpoint-title",$n="data-bre-endpoint-toggle",eu="data-bre-endpoint-count",ai="data-bre-field-order",Kr="data-bre-endpoint-serving",Xc="data-bre-protocol-watch",Jc=new WeakSet,Qc="data-bre-row-provider",ys="data-bre-protocol-cards",Vn="data-bre-protocol-value",vs="data-bre-protocol-source";function ht(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 Yn(e,t){let n=ht(e,t);if(n===void 0)return;let r=n.closest("label");return r!==null&&r.parentElement!==null?r:n.parentElement??void 0}function bs(e,t){let n=e;for(;n!==null&&n.parentElement!==t;)n=n.parentElement;return n===null||n===t?void 0:n}function iy(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=bs(t,r),i=bs(n,r);if(o===void 0||i===void 0||o===i)continue;let a=e===void 0?void 0:bs(e,r);return{container:r,protocol:o,url:i,name:a}}}function tu(e,t){let n=ht(e,t);return n instanceof HTMLSelectElement||n instanceof HTMLInputElement?n.value.trim():""}function ay(e,t){let n=tu(e,t.apiProtocol);return n==="anthropic-messages"||n==="openai-completions"||n==="openai-responses"?n:void 0}function Ot(e,t){let n=ay(e,t);return n===void 0?void 0:ei(n)}function yn(e,t){let n=tu(e,t.routeId);return n.length>0?n:(e.closest(`[${Qc}]`)?.getAttribute(Qc)??"").trim()}function nu(e,t){return e==="anthropic"?t("keysEndpointAnthropic"):e==="openai"?t("keysEndpointOpenAI"):""}function sy(e,t){let n=ht(e,t.modelName),r=ht(e,t.apiProtocol),o=ht(e,t.baseUrl);if(r===void 0||o===void 0)return;let i=iy(n,r,o);if(i===void 0)return;let{container:a,protocol:s,url:d,name:c}=i,u=g=>Array.from(a.children).indexOf(g);if((c===void 0||u(c)<u(s))&&u(s)<u(d)){e.setAttribute(ai,"1");return}a.insertBefore(s,d),c!==void 0&&a.insertBefore(c,s),e.setAttribute(ai,"1")}function ru(e,t){for(let n of Array.from(e.children))if(!(n===t||n.contains(t))&&!n.hasAttribute(ri)&&!n.hasAttribute($n)&&n instanceof HTMLElement&&(n.textContent??"").trim().length>0)return n}function bn(e,t){let n=t?"1":"0";e.getAttribute(Yc)!==n&&e.setAttribute(Yc,n)}function dy(e,t,n){let r=ru(e,t);if(!n){e.removeAttribute(oi),r?.removeAttribute(ii);return}e.setAttribute(oi,"1"),r?.setAttribute(ii,"1")}function ou(e,t,n){let r=ht(e,t.baseUrl);if(r===void 0)return;let o=Yn(e,t.baseUrl);if(o===void 0)return;let i=nu(Ot(e,t),n),a=o.querySelector(`[${ri}]`);if(a===null&&i.length>0){a=document.createElement("span"),a.setAttribute(ri,"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),Ct(a,i.length===0),bn(a,r instanceof HTMLInputElement&&r.value.trim().length>0)),dy(o,r,a!==null&&i.length>0);let s=Ot(e,t);s===void 0?o.removeAttribute(Kr):o.setAttribute(Kr,s)}function ly(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 iu(e,t){for(let n of Array.from(t.querySelectorAll(`[${Vn}]`))){let r=n.getAttribute(Vn)===e.value;n.classList.toggle("is-selected",r),n.setAttribute("aria-checked",r?"true":"false"),n.tabIndex=r?0:-1}}function cy(e,t,n){let r=Array.from(t.querySelectorAll(`[${Vn}]`)),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(Vn)===i.value&&(s.textContent??"")===au(i.value,(i.textContent??i.value).trim(),n.t)})}function au(e,t,n){return e==="openai-completions"?n("keysProtocolShortChat"):e==="openai-responses"?n("keysProtocolShortResponses"):e==="anthropic-messages"?n("keysProtocolShortAnthropic"):t}function Zc(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(Vn,o),i.textContent=au(o,(r.textContent??o).trim(),n.t),i.title=(r.textContent??o).trim(),i.addEventListener("click",()=>{e.value!==o&&(ly(e,o),iu(e,t))}),t.appendChild(i)}}function uy(e,t,n){let r=ht(e,t.apiProtocol);if(!(r instanceof HTMLSelectElement))return;let o=Yn(e,t.apiProtocol);if(o===void 0)return;let i=o.querySelector(`[${ys}]`);if(i===null){let a=document.createElement("div");i=a,a.setAttribute(ys,"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(vs,"1"),r.after(a),Zc(r,a,n),a.addEventListener("keydown",d=>{let c=d.key==="ArrowRight"||d.key==="ArrowDown"?1:d.key==="ArrowLeft"||d.key==="ArrowUp"?-1:0,u=Array.from(a.querySelectorAll(`[${Vn}]`));if(u.length===0)return;if(d.key==="Home"||d.key==="End"){d.preventDefault();let m=d.key==="Home"?u[0]:u[u.length-1];m?.click(),m?.focus();return}if(c===0)return;d.preventDefault();let p=u.findIndex(m=>m.classList.contains("is-selected")),g=u[(Math.max(p,0)+c+u.length)%u.length];g?.click(),g?.focus()})}else cy(r,i,n)||Zc(r,i,n);Ct(r,!0),iu(r,i)}function ws(e,t,n){let r=e===null?0:e.querySelectorAll(`[${Kt}], [${Xn}]`).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 fy(e,t,n){let r=e.querySelector(`[${$n}]`);if(Yn(e,t.apiProtocol)===void 0){r?.remove(),e.querySelector(`[${eu}]`)?.remove();return}let o=Yn(e,t.baseUrl);if(o===void 0)return;let i=ht(e,t.baseUrl);if(i===void 0)return;let a=ru(o,i);if(a===void 0||a===r)return;let s=()=>e.querySelector(`[${jn}]`),d=u=>{let p=n.t("keysMoreEndpoints");u.textContent!==p&&(u.textContent=p);let g=s();u.setAttribute("aria-expanded",g!==null&&!g.hidden?"true":"false"),ws(g,u,n)};if(r!==null){r.parentElement!==a&&a.append(r),d(r);return}let c=document.createElement("button");c.type="button",c.setAttribute($n,"1"),c.className="bre-endpoint-toggle",c.textContent=n.t("keysMoreEndpoints"),c.addEventListener("click",()=>{let u=s();if(u!==null&&(u.hidden=!u.hidden,d(c),!u.hidden)){let p=yn(e,t);p.length>0&&gy(u,p,n,e,t)}}),a.append(c),d(c)}var zn=new WeakMap,su=1e3,si=new WeakMap,Jn=0,ni=new Map;function py(e,t){Jn+=1,typeof CustomEvent=="function"&&document.dispatchEvent(new CustomEvent(Mr,{detail:{route:e,openai:t.openai??"",anthropic:t.anthropic??""}}))}function my(e,t){Jn+=1,typeof CustomEvent=="function"&&document.dispatchEvent(new CustomEvent(Rr,{detail:{route:e,endpoint:t}}))}function Ur(e){let t=e.getAttribute(Kt);return t==="openai"||t==="anthropic"?t:void 0}async function gy(e,t,n,r,o){for(let i of Array.from(e.querySelectorAll(`[${Kt}], [${Xn}]`)))await du(i,t,n,r,o)}async function du(e,t,n,r,o){let i=e.querySelector(".bre-endpoint-url");if(i===null)return;if(e.hasAttribute(Xn)){await lu(e,i,t,n);return}let a=Ur(e);if(a===void 0)return;let s=(zn.get(e)??0)+1;zn.set(e,s),si.set(e,{at:Date.now(),epoch:Jn});let d=n.client??Ye,c=await di(t,d);if(c===void 0||zn.get(e)!==s||Ur(e)!==a||document.activeElement===i)return;await cu(r,o,n,t,Ot(r,o),c);let u=c[a];i.value!==u&&(i.value=u);let p=e.querySelector(".bre-endpoint-family");p!==null&&bn(p,u.length>0)}async function lu(e,t,n,r){let o=(zn.get(e)??0)+1;zn.set(e,o),si.set(e,{at:Date.now(),epoch:Jn});let i=r.client??Ye;if(i.balanceEndpoint===void 0)return;let a=await i.balanceEndpoint(n);if(!a.ok||zn.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&&bn(d,s.length>0)}async function cu(e,t,n,r,o,i,a=!1){if(o===void 0||!a&&i[o].length>0)return;let s=ht(e,t.baseUrl);if(!(s instanceof HTMLInputElement)||document.activeElement===s)return;let d=s.value.trim();if(d.length===0&&!a)return;let c=n.client??Ye;await ks(r,c,u=>{if(!(!a&&u[o].length>0)&&u[o]!==d)return{openai:o==="openai"?d:u.openai,anthropic:o==="anthropic"?d:u.anthropic}})}function xs(e,t,n){let r=Yn(e,t.baseUrl);if(r===void 0||r.parentElement===null)return;let o=Ot(e,t);if(o===void 0)return;let i=r.querySelector(`:scope > [${jn}]`);i===null&&(i=e.querySelector(`[${jn}]`),i!==null&&r.appendChild(i)),i===null&&(i=document.createElement("div"),i.setAttribute(jn,"1"),i.hidden=!0,r.appendChild(i));let a=_c.filter(p=>p!==o),s=Array.from(i.children).filter(p=>p instanceof HTMLElement&&p.hasAttribute(Kt));if(!(a.length===s.length&&a.every((p,g)=>Ur(s[g])===p)))for(let p of a){let g=i.querySelector(`[${Kt}="${p}"]`);g===null&&(g=hy(e,t,n,p)),i.appendChild(g)}for(let p of Array.from(i.querySelectorAll(`[${Kt}]`))){let g=Ur(p);g!==void 0&&g!==o||p.remove()}let c=e.querySelector(`[${$n}]`);c!==null&&(c.setAttribute("aria-expanded",i.hidden?"false":"true"),ws(i,c,n));let u=yn(e,t);if(u.length>0)for(let p of Array.from(i.querySelectorAll(`[${Kt}]`))){let g=si.get(p);(g===void 0||g.epoch!==Jn||Date.now()-g.at>=su)&&du(p,u,n,e,t)}}function hy(e,t,n,r){let o=document.createElement("div");o.setAttribute(Kt,r),o.className="bre-endpoint-row";let i=document.createElement("span");i.className="bre-endpoint-family",i.textContent=nu(r,n.t),bn(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??Ye;return a.addEventListener("change",()=>{let d=yn(e,t);if(d.length===0)return;let c=a.value.trim();if(c.length>0&&!/^https?:\/\//i.test(c)){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"),bn(i,c.length>0),(async()=>await ks(d,s,u=>{let p=Ur(o);if(p!==void 0)return{openai:p==="openai"?c:u.openai,anthropic:p==="anthropic"?c:u.anthropic}}))()}),o.append(i,a),o}function uu(e,t,n){let r=e.querySelector(`[${jn}]`),o=e.querySelector(`[${Xn}]`),i=yn(e,t);if(r===null||i.length===0){o?.remove();return}let a=o;a===null&&(a=by(e,t,n)),r.lastElementChild!==a&&r.appendChild(a);let s=e.querySelector(`[${$n}]`);s!==null&&ws(r,s,n);let d=si.get(a);if(d===void 0||d.epoch!==Jn||Date.now()-d.at>=su){let c=a.querySelector(".bre-endpoint-url");c!==null&&lu(a,c,i,n)}}function by(e,t,n){let r=document.createElement("div");r.setAttribute(Xn,"1"),r.className="bre-endpoint-row bre-balance-row";let o=document.createElement("span");o.className="bre-endpoint-family",o.textContent=n.t("keysEndpointBalance"),bn(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??Ye,s=a.setBalanceEndpoint;return i.addEventListener("change",()=>{let d=yn(e,t);if(d.length===0)return;let c=i.value.trim();if(c.length>0&&!/^https?:\/\//i.test(c)){i.setAttribute("aria-invalid","true"),i.title=n.t("keysEndpointInvalid");return}i.hasAttribute("aria-invalid")&&i.removeAttribute("aria-invalid"),i.title=n.t("keysEndpointBalanceHint"),bn(o,c.length>0),s!==void 0&&(async()=>(await s.call(a,d,c)).ok&&my(d,c))()}),r.append(o,i),r}async function yy(e,t,n,r,o){let i=yn(e,t),a=ht(e,t.baseUrl);if(i.length===0||!(a instanceof HTMLInputElement))return;let s=n.client??Ye,d=await di(i,s);if(d===void 0||Ot(e,t)!==o)return;let c=a.value.trim();if(c.length>0&&c!==d[r]){let g=await ks(i,s,m=>{if(Ot(e,t)===o)return{openai:r==="openai"?c:m.openai,anthropic:r==="anthropic"?c:m.anthropic}});if(g===void 0||(d=g,Ot(e,t)!==o))return}let u=d[o];if(a.value===u)return;let p=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set;p===void 0?a.value=u:p.call(a,u),a.dispatchEvent(new Event("input",{bubbles:!0})),a.dispatchEvent(new Event("change",{bubbles:!0})),xs(e,t,n)}async function ks(e,t,n){let o=(ni.get(e)??Promise.resolve()).then(async()=>{let i=await di(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 c={openai:d.endpoints.openai??"",anthropic:d.endpoints.anthropic??""};return py(e,d.endpoints),c});ni.set(e,o);try{return await o}finally{ni.get(e)===o&&ni.delete(e)}}async function di(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 vy(e,t,n){let r=Yn(e,t.baseUrl),o=Ot(e,t),i=r?.getAttribute(Kr);ou(e,t,n.t),xs(e,t,n),uu(e,t,n),!(r===void 0||i===void 0||o===void 0)&&i!==o&&(i!=="openai"&&i!=="anthropic"||yy(e,t,n,i,o))}function fu(e,t,n){sy(e,t),uy(e,t,n),ou(e,t,n.t),fy(e,t,n),xs(e,t,n),uu(e,t,n);let r=ht(e,t.apiProtocol);r instanceof HTMLSelectElement&&!r.hasAttribute(Xc)&&(r.setAttribute(Xc,"1"),r.addEventListener("change",()=>vy(e,t,n)));let o=ht(e,t.baseUrl);o instanceof HTMLInputElement&&!Jc.has(o)&&(Jc.add(o),o.addEventListener("change",()=>{let i=yn(e,t),a=Ot(e,t);if(i.length===0||a===void 0)return;let s=n.client??Ye;(async()=>{let d=await di(i,s);d!==void 0&&Ot(e,t)===a&&await cu(e,t,n,i,a,d,!0)})()}))}function wy(){for(let e of Array.from(document.querySelectorAll(`select[${vs}]`)))e.hidden=!1,e.removeAttribute(vs)}function pu(){wy();for(let e of Array.from(document.querySelectorAll(`[${jn}], [${Kt}], [${Xn}], [${$n}], [${eu}], [${ys}], [${ri}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`[${ai}], [${oi}], [${ii}], [${Kr}]`)))e.removeAttribute(ai),e.removeAttribute(oi),e.removeAttribute(ii),e.removeAttribute(Kr)}function Qn(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Es="__breLedgerDocument";function ku(){let e=globalThis;return e[Es]??(e[Es]=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`)}var ui="bre:held-writes:v1";function Ls(){try{return typeof sessionStorage>"u"?void 0:sessionStorage}catch{return}}function It(e){let t=Ls();if(t!==void 0)try{if(e.pending.size===0&&e.queued.size===0){t.removeItem(ui);return}let n={document:ku(),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(ui,JSON.stringify(n))}catch{}}function mu(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,c]=s;if(typeof d!="string"||!Z(c)||t!==void 0&&!t(c))return;a.push([d,c])}n.push([o,a])}return n}function xy(e){let t=Ls();if(t!==void 0)try{let n=t.getItem(ui);if(n===null)return;let r=JSON.parse(n);if(r.document!==ku())return;let o=mu(r.pending),i=mu(r.queued,Ry);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 Eu(e,t){(async()=>{try{await Rs(t,e),await Hs(t,e)}catch(n){console.error(`[bre] teardown flush failed: ${n instanceof Error?n.message:String(n)}`)}})()}function Tu(e,t){(async()=>{try{await Rs(t,e,!0),await Hs(t,e,!0)}catch(n){console.error(`[bre] unload flush failed: ${n instanceof Error?n.message:String(n)}`)}finally{try{Ls()?.removeItem(ui)}catch{}}})()}function Su(){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 xy(e),e}async function ky(e,t,n=!1){if(t.flushing)return;t.flushing=!0;let r;try{r=n&&Au(t)?await we(e.api,{fresh:!0}):void 0;let o=await Rs(e,t,!1,r),i=await Hs(e,t,!1,r);o||i?gu(e,t):(t.flushFailures=0,t.nextFlushAt=0)}catch(o){gu(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 Cu=new Set(["no-namespace","invalid-models"]);function gu(e,t){t.flushFailures+=1;let n=Math.min(2**(t.flushFailures-1)*500,3e4);t.nextFlushAt=Date.now()+n,e.onBackoff?.(n)}function Au(e){return e.queued.size>0||e.pending.size>0}function Zn(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{It(e)}}function Mu(e,t,n,r){e.queued.set(t,(e.queued.get(t)??new Map).set(n,r)),It(e)}function Ey(e,t,n){let r=e.pending.get(t);r!==void 0&&(r.delete(n),r.size===0&&e.pending.delete(t),It(e))}function Ty(e,t,n){let r=e.queued.get(t);r!==void 0&&(r.delete(n),r.size===0&&e.queued.delete(t),It(e))}function Sy(e,t,n){Ey(e,t,n),Ty(e,t,n)}function Cy(e,t){e.queued.delete(t),e.pending.delete(t),e.missedScans.delete(t),e.committing.delete(t),It(e)}function Ay(e,t,n){if(t===void 0)return null;let i=t[pt]!==!0&&t.reasoningEfforts!==void 0&&typeof t[Rn]=="number"||t[pt]!==!0&&n?.efforts!==void 0&&My(t.reasoningEfforts,n.efforts)?!1:t.reasoningEfforts!==void 0||t[pt]===!0||e.efforts==="keep",s=t[Lt]!==!0&&n?.input!==void 0&&Ly(t.input,n.input)?!1:Array.isArray(t.input)&&t.input.length>0||t[Lt]===!0,d=i?"keep":e.efforts,c=s?void 0:e.input,u=t[mt]===!0,p=e.imageGen!==void 0&&e.imageGen!==u?e.imageGen:void 0,g=e.defaultEffort;return d==="keep"&&c===void 0&&p===void 0&&g===void 0?null:{efforts:d,...e.compat===void 0?{}:{compat:e.compat},...c===void 0?{}:{input:c},...p===void 0?{}:{imageGen:p},...g===void 0?{}:{defaultEffort:g}}}function My(e,t){if(e===t)return!0;if(!Z(e)||!Z(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 Ly(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 Ry(e){if(!Z(e))return!1;let t=e.efforts;return t===!1||t==="keep"||Z(t)}async function Hy(e,t,n,r,o=!1,i){let a=i??await e.describeNamespace(),s=ze(a.namespace),d=[];for(let[g,m]of[...r]){let f=Kn(s,n).find(T=>T.id===g);if(f===void 0||t.pending.get(n)?.get(g)!==m)continue;let v=cn(s,n),h=typeof f.name=="string"?f.name:void 0,x=Rt(g,h===void 0?v:{...v,displayName:h}),C=Ay(m,f,{...x.efforts===void 0?{}:{efforts:x.efforts},...x.input===void 0?{}:{input:x.input}});if(C===null){Zn(t,n,g,void 0);continue}d.push({modelId:g,efforts:C.efforts,...C.compat===void 0?{}:{compat:C.compat},...C.input===void 0?{}:{input:C.input},...C.imageGen===void 0?{}:{imageGen:C.imageGen},...C.defaultEffort===void 0?{}:{defaultEffort:C.defaultEffort}})}if(d.length===0)return!1;let c=!1,u=await Nr(e.api,n,d,()=>c?e.describeNamespace():(c=!0,Promise.resolve(a)),o?void 0:Zu),p=!1;return d.forEach((g,m)=>{let f=u[m];if(f?.aborted!==!0){if(f?.ok===!0||f?.modelNotFound===!0){Zn(t,n,g.modelId,void 0);return}if(f?.error!==void 0&&Cu.has(f.error)){Zn(t,n,g.modelId,void 0),console.error(`[bre] staged flush withdrew "${n}"/"${g.modelId}": ${f.error}`);return}p=!0,console.error(`[bre] staged flush write failed for "${n}"/"${g.modelId}": ${f?.error??"unknown"}`)}}),(t.pending.get(n)?.size??0)===0&&t.pending.delete(n),p}async function Rs(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 It(t),!1;let i=r??await e.describeNamespace();if(i.writable!==!0)return It(t),!1;let a=!1;for(let[s,d]of[...t.queued]){if(!t.committing.has(s)&&!t.signalsUnavailable)continue;let u=[...d].map(([m,f])=>({modelId:m,efforts:f.efforts,...f.compat===void 0?{}:{compat:f.compat},...f.input===void 0?{}:{input:f.input},...f.imageGen===void 0?{}:{imageGen:f.imageGen},...f.defaultEffort===void 0?{}:{defaultEffort:f.defaultEffort}})),p=await Nr(e.api,s,u,()=>Promise.resolve(i),n?void 0:Zu),g=!1;u.forEach((m,f)=>{let v=p[f];if(v?.aborted===!0){g=!0;return}if(v?.ok===!0||v?.modelNotFound===!0){d.delete(m.modelId);return}if(v?.error!==void 0&&Cu.has(v.error)){d.delete(m.modelId),console.error(`[bre] held write withdrawn for "${s}"/"${m.modelId}": ${v.error}`);return}console.error(`[bre] held write failed for "${s}"/"${m.modelId}": ${v?.error??"unknown"}`)}),d.size===0?(t.queued.delete(s),t.committing.delete(s)):g||(a=!0)}return It(t),a}async function Hs(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=ze(o.namespace),a=!1;for(let[s,d]of[...t.pending]){if(d.size===0){t.pending.delete(s);continue}Qn(i,s)&&await Hy(e,t,s,d,n,o)&&(a=!0)}return It(t),a}function at(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 jr(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=jr(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 Lu(e,t){return Array.from(e.querySelectorAll("button[aria-label]")).find(n=>t.some(r=>(n.getAttribute("aria-label")??"").startsWith(r)))}function hu(){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 ci(e){return e.querySelector('[class*="modelInputTypes"]')!==null}var Oy="modelReasoning",Cs="data-bre-reasoning-hidden";function Ru(e){return e.querySelector(`[class*="${Oy}"]`)??void 0}function Ns(e){let t=Ru(e);t!==void 0&&t.style.display!=="none"&&(t.setAttribute(Cs,"1"),t.style.display="none")}function Wr(e){let t=Ru(e);t!==void 0&&t.getAttribute(Cs)==="1"&&(t.removeAttribute(Cs),t.style.display==="none"&&(t.style.display=""))}var fi="data-bre-capacity-hidden";function Hu(e,t){return Array.from(e.children).filter(n=>n.nodeType!==1?!1:n.matches(`[class*="${t}"]`))}function Iy(e){return Hu(e,"modelField")}function Dy(e){return Hu(e,"modelInputTypes")}function Nu(e){return[...Iy(e),...Dy(e)]}function Py(e){for(let t of e)t.style.display!=="none"&&(t.setAttribute(fi,"1"),t.style.display="none")}function _y(e){for(let t of e)t.getAttribute(fi)==="1"&&(t.removeAttribute(fi),t.style.display==="none"&&(t.style.display=""))}function Fy(e){Py(Nu(e))}function Ts(e){_y(Nu(e))}function Ou(e){let t=e.querySelector('[class*="modelInputTypes"]');return t===null||t.getAttribute(fi)==="1"?!1:!t.hidden&&t.style.display!=="none"}function Iu(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 zr(e,t,n){if(!Ou(e))return!1;let r=Iu(e,n);return r===void 0||r.disabled?!1:(r.checked!==t&&r.click(),!0)}function As(e,t,n){return t==null||e===void 0||Ou(e)&&zr(e,t.includes("image"),n),t}function bu(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 Os(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=>bu(s,t.contextWindow)),i=r.find(s=>bu(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 Du(e,t,n){let r=Os(e,t),o=(i,a)=>i===void 0||i.disabled||a===void 0||!Number.isFinite(a)||a<=0||Ht(i.value)!==void 0?!1:Pu(i,String(a));return{contextWindow:o(r.contextWindow,n.contextWindow),maxOutput:o(r.maxOutput,n.maxTokens)}}function Pu(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 qy(e,t){let n=Os(e,t),r=a=>{if(a!==void 0)return Ht(a.value)},o=r(n.contextWindow),i=r(n.maxOutput);return{...o===void 0?{}:{contextWindow:o},...i===void 0?{}:{maxTokens:i}}}function By(e,t,n){let r=Os(e,t),o=(i,a)=>i===void 0?!1:Pu(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 _u(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 Ky(e,t,n){if(e===void 0)return!1;let r=t.inputImage;if(ci(e))return zr(e,!0,r);let o=e.closest('[class*="modelEntry"]')??e;if(o.querySelector('[class*="modelAdvanced"]')!==null)return!1;let i=Lu(o,t.capacity);return i===void 0||i.disabled?!1:_u(o,async()=>{i.click(),ci(o)||await n();try{return ci(o)&&zr(o,!0,r)}finally{i.click()}})}async function Uy(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=Lu(o,t.capacity);return i===void 0||i.disabled?!1:_u(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 Wy(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)))||zo(e,Gy(e,ze(r.namespace),o),{t:t.t,onRequest:a=>Fu(n,t,a)})}function Gy(e,t,n){let r=[];for(let o of ls(e)){let i=jr(o);if(i===void 0)continue;let a=vn(i,t,n);a===void 0||a.staged||r.push({catalogue:o,route:a.route})}return r}function jy(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=vn(i.card,t,n);if(a===void 0)continue;let[s]=ls(i.card);s!==void 0&&r.push({catalogue:s,route:a.route})}return r}function zy(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 c=jr(d);if(c===void 0)continue;let u=d.closest('[class*="modelEntry"]')??c,p=at(u,r.modelId);p.length===0||i.has(p)||vn(c,n,r)?.route===t&&(i.add(p),o.push({id:p,name:at(u,r.modelName),row:u}))}}return o}async function Fu(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{Ga();let a,s=()=>a??(a=t.describeNamespace()),d=await s(),c=ze(d.namespace);if(d.writable!==!0)return{held:0,unsuggested:0,blocked:"unwritable"};if(!Qn(c,n)&&r.length===0)return{held:0,unsuggested:0,blocked:"unknown-route"};let p=Kn(c,n),g=new Set;for(let k of p){let E=typeof k.id=="string"?k.id:"";E.length>0&&g.add(E)}let m=p.slice();for(let k of r)k.id.length===0||g.has(k.id)||m.push({id:k.id,name:k.name});if(m.length===0)return{held:0,unsuggested:0,blocked:"no-models"};let f=c[n]??{},v=typeof f.api=="string"?f.api:void 0,h=new Set,x=new Map;for(let[k,E]of e.mounted)E.props.route===n&&(x.set(E.props.modelId,k),E.props.efforts!==void 0&&h.add(E.props.modelId));let C=new Map;for(let k of r)k.row!==void 0&&C.set(k.id,k.row);let T=!1,H=(k,E)=>As(x.get(k),E,t.labels().inputImage),B=async(k,E)=>{if(E.image!==!0)return;let _=x.get(k)??C.get(k);_!==void 0&&await Ky(_,t.labels(),hu)},I=async(k,E,_)=>{let S=E.image===!0,y=_.contextWindow!==void 0||_.maxTokens!==void 0;if(!S&&!y)return;let A=x.get(k)??C.get(k);if(A===void 0)return;let R=t.labels();await Uy(A,R,hu,D=>{S&&zr(D,!0,R.inputImage),y&&Du(D,R,_)})},F=qo(t.api,s,(k,E,_,S,y,A,R)=>{Zn(e,k,E,_,S,H(E,y),A,R)},(k,E,_)=>{Mu(e,k,E,{..._,input:H(E,_.input)})},void 0,()=>T);for(let k of m){let E=typeof k.id=="string"?k.id:"";if(E.length===0)continue;let _=Io(m,E),S=Do(m,E),y=k[mt]===!0,A=_!==void 0||k[pt]===!0,R=Array.isArray(S)&&S.length>0||k[Lt]===!0||y;if(h.has(E)&&!A)continue;if(A&&R){let Te=x.get(E)??C.get(E);if(Array.isArray(S)&&S.includes("image")&&Te!==void 0){let ie=t.labels().inputImage,fe=Iu(Te,ie);fe!==void 0&&!fe.disabled&&!fe.checked&&zr(Te,!0,ie)}continue}let D=Po(m,E),K=Fo(m,E)??"",N=await F.suggest(n,E,_o(m,E));if(!N.ok){i+=1;continue}let V=N.suggestion,Q=V.efforts!==!1,ae=V.imageGen===!0?qt(void 0,!0):V.input===void 0?qt(S,y):qt(V.input);if(A){if(!ae.image&&!ae.imageGen||e.queued.get(n)?.has(E)===!0)continue;await B(E,ae),T=!g.has(E),F.commit(n,E,Go({efforts:"keep",...Wo(ae)})),T&&t.onPendingChanged?.(),T=!1,o+=1;continue}let de=K!==""?K:V.defaultEffort??K,le=de===K?void 0:de===""?null:de;T=!g.has(E),await I(E,ae,{...V.contextWindow===void 0?{}:{contextWindow:V.contextWindow},...V.maxTokens===void 0?{}:{maxTokens:V.maxTokens}});let be=Uo(ae,S,y)?void 0:Wo(ae);F.commit(n,E,Go({efforts:ss(Q,Wn(mn(V.efforts)),_),input:be?.input,imageGen:be?.imageGen,defaultEffort:le,appliedCompat:V.compat,routeApi:v,initialCompat:D})),T&&t.onPendingChanged?.(),T=!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 $y(e){return e.querySelector(`[data-plugin="${Me}"]`)!==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&&Dr(e.efforts,t.efforts)&&Xy(e.input,t.input)&&e.imageGen===t.imageGen&&Yy(e.compat,t.compat)}function Yy(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 Jy(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 vn(e,t,n){let r=e.querySelector('[class*="editorRoute"]')?.textContent?.trim();if(r!==void 0&&r.length>0&&Qn(t,r))return{route:r,staged:!1};if(Jy(e,n.routeId)){let a=at(e,n.routeId);return a.length>0&&!Qn(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(Qn(t,o))return{route:o,staged:!1}}function Qy(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=(p,g)=>(p.textContent??"").trim()===g,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(p=>t.apply.some(g=>o(p,g))),d=[...r].reverse().find(p=>t.cancel.some(g=>o(p,g)));if(s!==void 0&&d!==void 0)return{submit:s,cancel:d};let c=r[r.length-1],u=r[r.length-2];if(!(c===void 0||u===void 0))return{submit:c,cancel:u}}function tr(e,t,n){t.has(e)||(t.add(e),e.addEventListener("click",n,{capture:!0}))}var Ss=new WeakMap,Ms=new Set;function qu(){for(let e of Array.from(Ms))e.release()}var $r=420,Bu=320,Zy=160,yu=2e3,ev=150,Ku=new Set(["PageUp","PageDown","Home","End","ArrowUp","ArrowDown"," "]);function Is(e,t=Bu){for(let n of ms(e)){let r=pi.get(n);if(r!==void 0){window.clearTimeout(r.timer),r.timer=window.setTimeout(()=>vu(n),t);continue}n.style.overflowAnchor!=="none"&&(pi.set(n,{saved:n.style.overflowAnchor,timer:window.setTimeout(()=>vu(n),t)}),n.style.overflowAnchor="none")}}var pi=new Map;function vu(e){let t=pi.get(e);t!==void 0&&(pi.delete(e),e.style.overflowAnchor=t.saved)}function nr(e,t,n=!1){let r=ms(e),o=r[0];if(o===void 0||!e.isConnected)return;let i=performance.now(),a=Ss.get(o);if(a!==void 0)if(n)a.release();else{a.deadline=Math.min(Math.max(a.deadline,i+t),a.startedAt+yu);return}let s=e.getBoundingClientRect(),d=s.top,c=s.height,u=new Map,p=new Map;for(let T of r){u.set(T,T.scrollTop);let H=T.style.overflowAnchor;H!=="none"&&p.set(T,H),T.style.overflowAnchor="none"}let g=new Set(r),m={deadline:i+t,startedAt:i,frame:void 0,release:()=>{}},f=()=>{if(Ms.delete(m)){m.frame!==void 0&&(window.cancelAnimationFrame(m.frame),m.frame=void 0);for(let[T,H]of p)T.style.overflowAnchor=H;Ss.delete(o),document.removeEventListener("wheel",v,!0),document.removeEventListener("touchstart",v,!0),document.removeEventListener("pointerdown",v,!0),document.removeEventListener("keydown",h,!0)}};function v(){f()}function h(T){Ku.has(T.key)&&f()}m.release=f,Ss.set(o,m),Ms.add(m),document.addEventListener("wheel",v,{capture:!0,passive:!0}),document.addEventListener("touchstart",v,{capture:!0,passive:!0}),document.addEventListener("pointerdown",v,{capture:!0}),document.addEventListener("keydown",h,{capture:!0});let x=0,C=()=>{if(m.frame=void 0,x+=1,!e.isConnected||x>=ev){f();return}let T=e.getBoundingClientRect(),H=Math.abs(T.height-c)>.5;if(!H&&[...g].some(k=>k.scrollTop!==u.get(k))){f();return}let B=[];if(H){for(let k of r){let E=u.get(k);E===void 0||k.scrollTop===E||(B.push(k),k.scrollTop=E,u.set(k,k.scrollTop))}T=e.getBoundingClientRect()}let I=T.top-d;I!==0&&tv(r,g,u,I,B);let F=performance.now();if(H&&(c=T.height,m.deadline=Math.min(Math.max(m.deadline,F+Zy),m.startedAt+yu)),F>=m.deadline){f();return}m.frame=window.requestAnimationFrame(C)};m.frame=window.requestAnimationFrame(C)}function tv(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 Ds='[class*="modelList"]',nv="bre-list-slack",Uu=3e3,rv='button[class*="iconButtonDanger"]',Vr,tn=new WeakMap,er=new Set;function Wu(e){if(!(e instanceof Element))return;let t=e.closest(Ds);if(t===null)return;let n=Nc(t).map(r=>({host:r,top:r.scrollTop}));n.length!==0&&(Vr={targets:n,at:performance.now()})}function Ut(){Vr=void 0}function Gu(e){Wu(e.target),Yu(e.target)}function ju(e){if(Ku.has(e.key)){Ut();return}Wu(e.target),Yu(e.target)}var Gr=0;function zu(){Gr+=1,!(Gr>1)&&(document.addEventListener("click",Gu,!0),document.addEventListener("keydown",ju,!0),document.addEventListener("focusin",Ut,!0),document.addEventListener("pointerdown",Ut,!0),document.addEventListener("wheel",Ut,{capture:!0,passive:!0}),document.addEventListener("touchstart",Ut,{capture:!0,passive:!0}))}function mi(e){let t=tn.get(e);t!==void 0&&(tn.delete(e),er.delete(t),t.scrollTarget.removeEventListener("scroll",t.onScroll),t.spacer.remove())}function ov(e){return e===document.scrollingElement?document:e}function iv(){if(er.size!==0)for(let e of Array.from(er)){let t=e.host;if(!e.spacer.isConnected){tn.delete(t),er.delete(e),e.scrollTarget.removeEventListener("scroll",e.onScroll);continue}t.scrollTop<=t.scrollHeight-t.clientHeight-e.height&&mi(t)}}function $u(e,t){return e.scrollTop>e.scrollHeight-e.clientHeight-t}function Vu(e,t){let n=tn.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=nv,r.dataset.plugin=Me,r.setAttribute("aria-hidden","true"),r.style.height=`${t}px`,(e===document.scrollingElement?document.body??e:e).appendChild(r);let i=()=>{let s=tn.get(e);s!==void 0&&!$u(e,s.height)&&mi(e)},a={host:e,spacer:r,height:t,onScroll:i,scrollTarget:ov(e)};return tn.set(e,a),er.add(a),a.scrollTarget.addEventListener("scroll",i,{passive:!0}),a}function Yu(e){if(!(e instanceof Element))return;let t=e.closest(rv);if(t===null)return;let n=t.closest(Ds);if(n===null)return;let r=t.closest('[class*="modelEntry"]');if(r===null)return;let o=Vr;if(o===void 0||performance.now()-o.at>Uu)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 c=tn.get(s),u=c===void 0?0:c.height,p=s.scrollHeight-s.clientHeight-u-d;p>=a||Vu(s,Math.max(u,a-p))}}function av(e=performance.now()){let t=Vr;if(!(t===void 0||e-t.at>Uu))for(let n of t.targets){let r=n.host;if(!r.isConnected)continue;let o=tn.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&&!$u(r,o.height)&&mi(r);continue}Vu(r,s),r.scrollTop!==n.top&&(r.scrollTop=n.top)}}function Xu(){if(Gr=Math.max(0,Gr-1),!(Gr>0)){document.removeEventListener("click",Gu,!0),document.removeEventListener("keydown",ju,!0),document.removeEventListener("focusin",Ut,!0),document.removeEventListener("pointerdown",Ut,!0),document.removeEventListener("wheel",Ut,!0),document.removeEventListener("touchstart",Ut,!0),Vr=void 0;for(let e of Array.from(er))mi(e.host)}}function Ju(e,t=$r){av(),iv();let n=new Set;for(let r of Array.from(e.querySelectorAll(Ds))){let o=r.closest('[class*="rowCard"], [class*="setupCard"], [class*="addCard"]');o===null||n.has(o)||(n.add(o),nr(o,t))}}function sv(e,t){tr(e,t,()=>{let n=e.closest('[class*="modelEntry"]')??e.closest('[class*="rowCard"]');n!==null&&nr(e.closest('[class*="rowCard"]')??n,$r)})}var wu="{provider}";function dv(e,t){let n=t.editProvider.map(o=>{let i=o.indexOf(wu);return i<0?void 0:{prefix:o.slice(0,i),suffix:o.slice(i+wu.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 lv(e,t){tr(e,t,()=>{let n=e.closest('[class*="rowCard"], [class*="setupCard"], [class*="addCard"]');n!==null&&nr(n,$r)})}function cv(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 uv(e,t,n){tr(e,n,()=>{t.isConnected&&nr(t,$r)})}function fv(e,t){tr(e,t,()=>{let n=e.closest('[class*="addBlock"]');n!==null&&nr(n,$r,!0)})}function Qu(e){return e.querySelector('[class*="editorActions"]')??e.querySelector('[class*="modelEntry"]')??void 0}function Zu(){return Qu(St())!==void 0}function pv(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(c=>d.some(u=>(c.getAttribute("aria-label")??"").startsWith(u)));s(t.apiProtocol)&&s(t.baseUrl)&&o.add(i)}for(let i of o)fu(i,r,{t:n})}var li=new WeakMap;function xu(e,t,n,r=!1){let o=e.describePromise;if(o===void 0)return;let i=li.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};li.set(e,a);let s=()=>{li.get(e)===a&&li.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 mv=['[class*="editor"]','[class*="modelEntry"]','[class*="rowCard"]','[class*="setupCard"]','[class*="addCard"]','button[class*="addButton"]',"button[aria-label]"].join(", ");function Ps(e,t,n){if(n.disposed||!e.isConnected)return;let r=t.labels(),o=Array.from(e.querySelectorAll(mv)),i=!1,a=[],s=[],d=[],c=[],u=[];for(let m of o)!i&&m.matches('[class*="editorActions"], [class*="modelEntry"]')&&(i=!0),m.matches('[class*="rowCard"], [class*="setupCard"]')?(a.push(m),s.push(m)):m.matches('[class*="addCard"]')&&s.push(m),m.matches('[class*="editor"], [class*="addCard"], [class*="rowCard"]')&&c.push(m),m.matches('button[class*="addButton"]')&&m.closest("[data-plugin]")===null&&d.push(m),m.matches("button[aria-label]")&&r.capacity.some(f=>(m.getAttribute("aria-label")??"").startsWith(f))&&u.push(m);for(let m of a)for(let f of dv(m,r))lv(f,n.editWired);for(let m of s)for(let f of cv(m,r))uv(f,m,n.addModelWired);for(let m of d)fv(m,n.addProviderWired);pv(c,r,t.t);let p=u.length>0;if(!i){if(zo(e,[],{t:t.t}),n.mounted.size>0){for(let[f,v]of n.mounted)Wr(f),Ts(f),v.editor.unmount();n.mounted.clear()}let m=n.editing;n.editing=!1,(m!==!1||Au(n)&&Date.now()>=n.nextFlushAt)&&ky(t,n,m===!0).catch(f=>{console.error(`[bre] idle pass failed: ${f instanceof Error?f.message:String(f)}`)});return}if(n.editing=!0,!p){for(let[f,v]of n.mounted)Wr(f),Ts(f),v.editor.unmount();n.mounted.clear(),n.describePromise??(n.describePromise=t.describeNamespace({allowStale:!0}));let m=r;xu(n,f=>{Wy(e,t,n,f,m)},"empty-catalog seat",!0);return}for(let m of u)sv(m,n.disclosureWired);n.describePromise??(n.describePromise=t.describeNamespace({allowStale:!0})),xu(n,m=>{if(n.disposed||!e.isConnected)return;let f=m.namespace,v=ze(f),h=new Map,x=k=>(h.has(k)||h.set(k,vn(k,v,r)),h.get(k)),C=new Map,T=k=>{let E=C.get(k);if(E!==void 0)return E;let _=Kn(v,k),S=new Set,y=new Set,A=new Map;for(let D of _){let K=D.id;S.add(K),A.has(K)||A.set(K,[D]),D[pt]===!0&&y.add(K)}let R={models:_,savedModelIds:S,unsetModelIds:y,singletonById:A};return C.set(k,R),R},H=[],B=Array.from(e.querySelectorAll("button[aria-label]")).filter(k=>r.capacity.some(E=>(k.getAttribute("aria-label")??"").startsWith(E)));for(let k of B){let E=jr(k);if(E===void 0)continue;let _=k.closest('[class*="modelEntry"]')??E,S=at(_,r.modelId);S.length!==0&&H.push({container:Ny(k),row:_,modelId:S,card:E})}zo(e,jy(H,v,r),{t:t.t,onRequest:k=>Fu(n,t,k,zy(e,k,v,r))});let I=new Set(H.map(k=>k.container));for(let[k,E]of n.mounted)I.has(k)||(Wr(k),Ts(k),E.editor.unmount(),n.mounted.delete(k));if(n.pending.size>0){let k=new Map;for(let _ of H){let S=x(_.card);if(S===void 0)continue;let y=k.get(S.route);y===void 0&&k.set(S.route,y=new Set),y.add(_.modelId)}let E=new Map;for(let[_,S]of n.pending){if(!Qn(v,_))continue;let y=k.get(_),A=[...S.keys()].filter(R=>!y?.has(R));A.length>0&&E.set(_,new Set(A))}for(let[_,S]of E){let y=n.missedScans.get(_);if(y!==void 0)for(let A of S)y.has(A)&&(Zn(n,_,A,void 0),y.delete(A),S.delete(A))}n.missedScans=E}else n.missedScans=new Map;let F=new Set(H.map(k=>k.card));for(let k of F){let E=x(k);if(E===void 0)continue;let _=E.route,S=Qy(k,r);S===void 0?n.signalsUnavailable=!0:(n.signalsUnavailable=!1,tr(S.submit,n.submitWired,()=>{let y=vn(k,v,r)?.route??_;n.committing.add(y),It(n)}),tr(S.cancel,n.cancelWired,()=>{let y=vn(k,v,r)?.route??_;Cy(n,y)}))}H.forEach((k,E)=>{let _=k.container;if(_===void 0)return;let S=x(k.card);if(S===void 0)return;let{route:y,staged:A}=S,R=v[y]??{},{savedModelIds:D,unsetModelIds:K,singletonById:N}=T(y),V=N.get(k.modelId)??[],Q=A||!D.has(k.modelId),ae=Q?n.pending.get(y)?.get(k.modelId)?.efforts:void 0,de=Q?ae==="keep"?void 0:ae:Io(V,k.modelId),le=!Q&&K.has(k.modelId),be=Q?n.pending.get(y)?.get(k.modelId)?.input:Do(V,k.modelId),Te=Q?n.pending.get(y)?.get(k.modelId)?.imageGen:Wa(V,k.modelId),ie=Q?n.pending.get(y)?.get(k.modelId)?.compat:Po(V,k.modelId),fe=Q?n.pending.get(y)?.get(k.modelId)?.defaultEffort??void 0:Fo(V,k.modelId),Re=Q?at(k.row,r.modelName):"",Oe=Q?Re.length>0?Re:void 0:_o(V,k.modelId),Ie=A?at(k.card,r.apiProtocol):"",X=A?at(k.card,r.baseUrl):"",me=A&&Ie.length>0?Ie:typeof R.api=="string"?R.api:void 0,W=A&&X.length>0?X:typeof R.baseURL=="string"?R.baseURL:void 0,ee={route:y,routeDisplayName:A?y:typeof R.displayName=="string"?R.displayName:y,...me===void 0?{}:{routeApi:me},...W===void 0?{}:{routeBaseURL:W},modelId:k.modelId,...Oe===void 0?{}:{modelName:Oe},...de===void 0?{}:{efforts:de},...le?{effortsUnset:le}:{},...be===void 0?{}:{input:be},...Te?{imageGen:!0}:{},...ie===void 0?{}:{compat:ie},...fe===void 0?{}:{defaultEffort:fe},index:E,staged:Q,officialInputTypes:ci(_),api:{...qo(t.api,void 0,(ce,ve,_e,Fe,wt,Qe,O)=>{Zn(n,ce,ve,_e,Fe,As(_,wt,r.inputImage),Qe,O)},(ce,ve,_e)=>{Mu(n,ce,ve,{..._e,input:As(_,_e.input,r.inputImage)})},ce=>{Sy(n,ce,k.modelId)},()=>(vn(k.card,v,r)?.staged??A)||!D.has(k.modelId)),fillCapacities:(ce,ve)=>{Du(_,r,{...ce===void 0?{}:{contextWindow:ce},...ve===void 0?{}:{maxTokens:ve}})},readCapacities:()=>qy(_,r),setCapacities:ce=>{By(_,r,ce)}},readOnly:m.writable!==!0,t:t.t};Ns(_),Fy(_);let oe=n.mounted.get(_);if(oe!==void 0){Vy(oe.props,ee)||(oe.props=ee,oe.editor.render(ee));return}if($y(_))return;nr(jr(_)??k.card,Bu);let ye=t.mount(_,ee);n.mounted.set(_,{editor:ye,props:ee})})},"editor reconcile")}var gi=['[class*="rowCard"]','[class*="setupCard"]','[class*="addCard"]','[class*="modelEntry"]','[class*="modelAdvanced"]','[class*="modelList"]','[class*="addBlock"]','p[class*="savedNotice"]'].join(","),gv=[`[data-plugin="${Me}"]`,".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 tf(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function _s(e){let t=tf(e);return t!==null&&t.closest(gv)!==null}function ef(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=e;return _s(t)?!1:t.matches(gi)||t.querySelector(gi)!==null}function nf(e){return e.some(t=>{if(_s(t.target))return!1;let n=tf(t.target);if(t.type==="childList"){let r=[...Array.from(t.addedNodes),...Array.from(t.removedNodes)];return r.length>0&&r.every(_s)?!1:n!==null&&n.closest(gi)!==null?!0:r.some(ef)}return n!==null&&n.closest(gi)!==null?!0:t.type==="attributes"&&ef(t.target)})}var qs=require("react");var ue=require("react"),ff=require("react-dom");var bt=require("react"),af=require("react-dom"),Dt=require("react/jsx-runtime"),rf=6,hv=292,hi=8,bv=52;function of(e,t){let n=e.getBoundingClientRect(),r=t*bv+46,o=window.innerWidth||0,i=window.innerHeight||0,a=Math.max(hi,Math.min(n.left,o-hv-hi)),s=n.bottom+rf,d=n.top-rf-r,c=i>0&&s+r>i-hi&&d>hi?d:s;return{left:a,top:c}}function sf(e){let{anchor:t,label:n,options:r,selected:o,onPick:i,onClose:a}=e,[s,d]=(0,bt.useState)(()=>of(t,r.length)),c=(0,bt.useRef)(null),u=(0,bt.useRef)([]);(0,bt.useLayoutEffect)(()=>{let m=()=>{d(of(t,r.length))};return m(),window.addEventListener("resize",m),window.addEventListener("scroll",m,!0),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m,!0)}},[t,r.length]),(0,bt.useEffect)(()=>{let m=Math.max(0,r.findIndex(f=>f.value===o));u.current[m]?.focus()},[r,o]),(0,bt.useEffect)(()=>{let m=f=>{let v=f.target;v instanceof Node&&c.current?.contains(v)!==!0&&(t.contains(v)||a())};return document.addEventListener("pointerdown",m,!0),()=>{document.removeEventListener("pointerdown",m,!0)}},[t,a]);let p=(0,bt.useCallback)(m=>{if(r.length===0)return;let f=(m+r.length)%r.length;u.current[f]?.focus()},[r.length]),g=m=>{let f=u.current.findIndex(v=>v===document.activeElement);if(m.key==="Escape"){m.preventDefault(),m.stopPropagation(),a();return}if(m.key==="ArrowDown"){m.preventDefault(),p(f+1);return}if(m.key==="ArrowUp"){m.preventDefault(),p(f<0?r.length-1:f-1);return}if(m.key==="Home"){m.preventDefault(),p(0);return}m.key==="End"&&(m.preventDefault(),p(r.length-1))};return(0,af.createPortal)((0,Dt.jsxs)("div",{ref:c,className:"bre-protocol-menu",style:{left:s.left,top:s.top},onKeyDown:g,children:[(0,Dt.jsx)("p",{className:"bre-protocol-menu-title",children:n}),(0,Dt.jsx)("ul",{className:"bre-protocol-menu-list",role:"listbox","aria-label":n,children:r.map((m,f)=>{let v=m.value===o;return(0,Dt.jsx)("li",{children:(0,Dt.jsx)("button",{ref:h=>{u.current[f]=h},type:"button",role:"option","aria-selected":v,"data-protocol-value":m.value,className:"bre-protocol-option",tabIndex:-1,onClick:()=>{i(m.value)},children:(0,Dt.jsxs)("span",{className:"bre-protocol-option-text",children:[(0,Dt.jsx)("span",{className:"bre-protocol-option-title",children:m.title}),(0,Dt.jsx)("span",{className:"bre-protocol-option-hint",children:m.hint})]})})},m.value)})})]}),document.body)}var z=require("react/jsx-runtime"),yv=200,vv=["M8 3.9v8.2","M3.9 8h8.2"],df="M3.9 8.35 6.6 11.05 12.1 5.5",wv=["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"],xv=1600;async function kv(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 Fs({paths:e}){return(0,z.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,z.jsx)("path",{d:t},t))})}function Ev(e,t){return e.masked!==void 0?e.masked:e.configured===!1?t("keysMissing"):"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}function lf(e){return e.alias??e.masked??e.ref}function Tv(e,t){return e.models===void 0?t("keysScopeAll"):e.models.length===0?t("keysScopeNone"):t("keysScopeCount",{count:e.models.length})}var pf=["openai-completions","openai-responses","anthropic-messages"],cf={openai:null,anthropic:null},Sv=2e3,Cv=150,Av=300,Mv=1500,Lv=new Intl.Collator("en",{numeric:!0,sensitivity:"base"});function Rv(e,t){return pf.filter(n=>n===t?!0:(e[ei(n)]??"").length>0)}function mf(e,t){return t(e==="anthropic-messages"?"keysProtocolAnthropic":e==="openai-responses"?"keysProtocolResponses":e==="openai-completions"?"keysProtocolOpenAI":"keysProtocolDefault")}function Hv(e,t){return t(e==="anthropic-messages"?"keysProtocolAnthropicHint":e==="openai-responses"?"keysProtocolResponsesHint":e==="openai-completions"?"keysProtocolOpenAIHint":"keysProtocolDefaultHint")}function uf(e,t,n,r=!1){return[void 0,...r?pf:Rv(e,t)].map(i=>({value:i??"",title:mf(i,n),hint:Hv(i,n)}))}function bi(e){let{route:t,t:n,draft:r}=e,o=e.client??Ye,[i,a]=(0,ue.useState)(()=>o.cached?.(t)?.entries),[s,d]=(0,ue.useState)(()=>o.cached?.(t)?.models??[]),[c,u]=(0,ue.useState)(void 0),[p,g]=(0,ue.useState)(!1),m=i===void 0&&c===void 0;(0,ue.useEffect)(()=>{if(g(!1),!m)return;let O=setTimeout(()=>g(!0),yv);return()=>clearTimeout(O)},[m,t]);let[f,v]=(0,ue.useState)(!1),[h,x]=(0,ue.useState)(void 0),[C,T]=(0,ue.useState)(""),[H,B]=(0,ue.useState)(""),[I,F]=(0,ue.useState)([]),[k,E]=(0,ue.useState)(void 0);(0,ue.useEffect)(()=>{r===!0&&x({kind:"add"})},[r]);let[_,S]=(0,ue.useState)(void 0),[y,A]=(0,ue.useState)(void 0),[R,D]=(0,ue.useState)(void 0),K=(0,ue.useRef)(void 0);(0,ue.useEffect)(()=>()=>{K.current!==void 0&&clearTimeout(K.current)},[]);let[N,V]=(0,ue.useState)(void 0),[Q,ae]=(0,ue.useState)(()=>o.cached?.(t)?.endpoints??cf),[de,le]=(0,ue.useState)(!1),be=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{be.current=de},[de]);let Te=(0,ue.useRef)(0),ie=(0,ue.useCallback)((O,te)=>{if(!O.ok){u({kind:"error",text:O.error??n("keysUnreachable")});return}a(O.entries),d(O.models??[]),ae(O.endpoints),le(O.probing===!0),u(te===void 0?void 0:{kind:"status",text:te})},[n]),fe=(0,ue.useRef)(t);fe.current=t,(0,ue.useEffect)(()=>(fe.current=t,()=>{fe.current=void 0}),[t]);let Re=(0,ue.useCallback)(async(O,te=!1)=>{let ge=o.cached?.(O)!==void 0,Ce=await o.list(O,te?{preferCache:!0}:void 0);fe.current===O&&(ge&&!Ce.ok||ie(Ce,void 0))},[ie,o]);(0,ue.useEffect)(()=>{Re(t,!0)},[Re,t]),(0,ue.useEffect)(()=>{let O,te,ge=()=>{O===void 0&&(O=setTimeout(()=>{O=void 0,Re(t),te===void 0&&(te=setTimeout(()=>{te=void 0,!be.current&&Re(t)},Mv))},Av))};return document.addEventListener(Lr,ge),()=>{document.removeEventListener(Lr,ge),O!==void 0&&clearTimeout(O),te!==void 0&&clearTimeout(te)}},[Re,t]),(0,ue.useEffect)(()=>{if(!de){Te.current=0;return}let O=!0,te=setInterval(()=>{if(Te.current+=1,Te.current>Cv){le(!1);return}(async()=>{let ge=await o.list(t);!O||fe.current!==t||(ge.ok?(ie(ge,void 0),ge.probing!==!0&&u({kind:"status",text:n("keysProbeDone")})):le(!1))})()},Sv);return()=>{O=!1,clearInterval(te)}},[ie,o,de,t]),(0,ue.useEffect)(()=>{let O=!0,te=0,ge=Ce=>{let l=Ce.detail,b=l?.route;if(!O||fe.current!==t||b!==void 0&&b!==t)return;let L=++te;if(typeof l?.openai=="string"&&typeof l.anthropic=="string"){ae({openai:l.openai||null,anthropic:l.anthropic||null});return}(async()=>{let P=o.endpoints!==void 0?await o.endpoints(t):await o.list(t);!O||fe.current!==t||te!==L||P.ok&&ae(P.endpoints??cf)})().catch(()=>{})};return document.addEventListener(Mr,ge),()=>{O=!1,document.removeEventListener(Mr,ge)}},[o,t]);let Oe=()=>{x(void 0),T(""),B(""),F([]),E(void 0)},Ie=(0,ue.useCallback)(async(O,te)=>{let ge=h,Ce=t;v(!0),S(void 0);try{let l=await O();if(fe.current!==Ce)return;ie(l,te),l.ok&&ge!==void 0&&ge.kind!=="add"&&!l.entries.some(b=>b.ref===ge.ref)&&Oe()}finally{v(!1)}},[ie,h,t]),X=(O,te)=>{x({kind:O,ref:te.ref}),T(O==="alias"?te.alias??"":""),B(""),F((te.models??[]).filter(ge=>s.includes(ge))),E(void 0),S(void 0)},me=()=>{if(f||h===void 0)return;let O=h.kind,te=h.ref;if(O!=="alias"&&O!=="scope"&&!Bt(H))return;let ge=qc(C),Ce=k,l=t,b=()=>fe.current!==l;v(!0),(async()=>{try{if(O==="add"){let P=new Set((i??[]).map(re=>re.ref)),j=await o.add(t,H,ge);if(b())return;if(!j.ok){ie(j,n("keysAdded"));return}if(ie(j,n("keysAdded")),Oe(),Ce===void 0)return;let pe=j.entries.find(re=>re.ref===j.addedRef)??j.entries.find(re=>!P.has(re.ref)),ne=pe===void 0?{ok:!1}:await o.setProtocol(t,pe.ref,Ce);b()||ie(ne,n("keysAdded"));return}if(te===void 0)return;if(O==="scope"){let P=await o.setScope(t,te,I.length===0?void 0:I);b()||(ie(P,n("keysScopeSaved")),P.ok&&Oe());return}let L=O==="alias"?await o.rename(t,te,ge):await o.replace(t,te,H);b()||(ie(L,n(O==="alias"?"keysRenamed":"keysReplaced")),L.ok&&Oe())}finally{v(!1)}})()},W=O=>{F(te=>te.includes(O)?te.filter(ge=>ge!==O):[...te,O])},ee=(0,ue.useMemo)(()=>[...new Set(s)].sort(Lv.compare),[s]),oe=(0,ue.useMemo)(()=>new Set(I),[I]),ye=()=>{if(h===void 0)return null;let O=h.kind,te=O==="add"||O==="value",ge=O==="scope",Ce=O==="scope"&&h?.ref!==void 0?i?.find(b=>b.ref===h.ref)?.auto===!0:!1,l=te&&H.length>0&&!Bt(H);return(0,z.jsxs)("div",{className:"bre-keys-form",children:[ge?(0,z.jsx)("div",{className:"bre-keys-chips",role:"group","aria-label":n("keysScope"),children:ee.length===0?(0,z.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeEmpty")}):ee.map(b=>{let L=oe.has(b);return(0,z.jsx)("button",{type:"button",className:L?"bre-keys-chip is-selected":"bre-keys-chip","aria-pressed":L,disabled:f,onClick:()=>W(b),children:b},b)})}):(0,z.jsxs)("div",{className:"bre-keys-form-fields",children:[O==="value"?null:(0,z.jsx)("input",{className:"bre-text-input bre-keys-name",type:"text",value:C,placeholder:n("keysAliasPlaceholder"),"aria-label":n("keysAlias"),disabled:f,autoFocus:O==="alias",onChange:b=>T(b.target.value)}),te?(0,z.jsx)("input",{className:"bre-text-input bre-keys-secret",type:"password",autoComplete:"new-password",spellCheck:!1,value:H,placeholder:n(O==="add"?"keysValuePlaceholder":"keysNewValuePlaceholder"),"aria-label":n("keysValue"),"aria-invalid":l,disabled:f,autoFocus:!0,onChange:b=>B(b.target.value)}):null]}),O==="add"?(0,z.jsx)("div",{className:"bre-keys-chips",role:"group","aria-label":n("keysProtocolCreate"),children:uf(Q,void 0,n,r===!0).map(b=>{let L=b.value===""?void 0:b.value,P=k===L;return(0,z.jsx)("button",{type:"button",className:P?"bre-keys-chip is-selected":"bre-keys-chip","aria-pressed":P,title:b.hint,disabled:f,onClick:()=>E(L),children:b.title},b.value)})}):null,O==="add"?(0,z.jsx)("p",{className:"bre-keys-hint",children:n("keysProtocolCreateHint")}):null,ge?(0,z.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeHint")}):null,ge&&Ce?(0,z.jsx)("p",{className:"bre-keys-hint",children:n("keysScopeAutoHint")}):null,l?(0,z.jsx)("p",{className:"bre-effort-message bre-error",role:"alert",children:n("keysAddIllegal")}):null,(0,z.jsxs)("div",{className:"bre-keys-form-actions",children:[ge?(0,z.jsx)("button",{type:"button",className:"bre-link-button bre-keys-allmodels",disabled:f,onClick:()=>F([]),children:n("keysScopeAll")}):null,(0,z.jsx)("button",{type:"button",className:"bre-link-button",disabled:f,onClick:Oe,children:n("keysCancel")}),(0,z.jsx)("button",{type:"button",className:"bre-primary-button",disabled:f||te&&!Bt(H),onClick:me,children:n(O==="add"?"keysAddConfirm":"keysSave")})]})]})},ce=()=>h?.kind==="add"?(0,z.jsx)("li",{className:"bre-keys-form-row",children:ye()}):(0,z.jsx)("li",{className:"bre-keys-add-row",children:(0,z.jsxs)("button",{type:"button",className:"bre-keys-add",disabled:f,onClick:()=>{x({kind:"add"}),T(""),B(""),F([]),S(void 0)},children:[(0,z.jsx)("span",{className:"bre-keys-add-mark","aria-hidden":"true",children:(0,z.jsx)(Fs,{paths:vv})}),n("keysAdd")]})}),ve=async O=>{if(R!==void 0)return;let te=t;D(O.ref);try{let ge=await o.reveal(t,O.ref);if(fe.current!==te)return;if(ge===void 0){u({kind:"error",text:n("keysCopyFailed")});return}let Ce=await kv(ge);if(fe.current!==te)return;if(!Ce){u({kind:"error",text:n("keysCopyFailed")});return}u(void 0),A(O.ref),K.current!==void 0&&clearTimeout(K.current),K.current=setTimeout(()=>{K.current=void 0,A(void 0)},xv)}finally{D(void 0)}},_e=(O,te)=>{let ge=te===""?void 0:te;V(void 0),Ie(()=>o.setProtocol(t,O.ref,ge),n("keysProtocolSaved"))},Fe=N===void 0?void 0:i?.find(O=>O.ref===N.ref);if(i===void 0)return c===void 0?(0,z.jsx)("div",{className:"bre-keys","aria-busy":"true",children:p?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)("ul",{className:"bre-keys-list bre-keys-skeleton","aria-hidden":"true",children:[(0,z.jsxs)("li",{className:"bre-keys-skeleton-row",children:[(0,z.jsx)("span",{className:"bre-keys-skeleton-dot"}),(0,z.jsx)("span",{className:"bre-keys-skeleton-bar is-name"}),(0,z.jsx)("span",{className:"bre-keys-skeleton-bar is-mask"})]}),(0,z.jsx)("li",{className:"bre-keys-skeleton-row is-add",children:(0,z.jsx)("span",{className:"bre-keys-skeleton-bar"})})]}),(0,z.jsx)("p",{className:"bre-keys-sr",role:"status",children:n("keysLoading")})]}):null}):(0,z.jsxs)("div",{className:"bre-keys",children:[(0,z.jsx)("p",{className:"bre-effort-message bre-"+c.kind,role:c.kind==="error"?"alert":"status",children:c.text}),(0,z.jsx)("ul",{className:"bre-keys-list",children:ce()})]});let wt=i.reduce((O,te)=>te.enabled?O+1:O,0),Qe=r===!0?null:(0,z.jsx)("button",{type:"button",className:"bre-link-button bre-keys-probe",disabled:f||de||i.length<2,title:i.length<2?n("keysProbeSingle"):n("keysProbeHint"),onClick:()=>{Ie(()=>o.probe(t),void 0)},children:n(de?"keysProbing":"keysProbe")});return(0,z.jsxs)("div",{className:"bre-keys",children:[Qe===null?null:e.probeHost===void 0?(0,z.jsx)("div",{className:"bre-keys-probe-row",children:Qe}):(0,ff.createPortal)(Qe,e.probeHost),(0,z.jsxs)("ul",{className:"bre-keys-list",children:[i.map(O=>{let te=lf(O),ge=O.enabled&&wt<=1;return(0,z.jsxs)(ue.Fragment,{children:[(0,z.jsxs)("li",{className:O.enabled?"bre-keys-row":"bre-keys-row is-off","data-state":O.configured===!1?"missing":"ready",children:[(0,z.jsx)("button",{type:"button",className:O.enabled?"bre-keys-toggle is-on":"bre-keys-toggle","aria-pressed":O.enabled,"aria-label":n(O.enabled?"keysDisable":"keysEnable",{name:te}),title:n(O.enabled?"keysDisable":"keysEnable",{name:te}),disabled:f||ge,onClick:()=>{Ie(()=>o.setEnabled(t,O.ref,!O.enabled),void 0)},children:(0,z.jsx)("span",{className:"bre-keys-toggle-mark","aria-hidden":"true",children:(0,z.jsx)(Fs,{paths:[df]})})}),(0,z.jsxs)("span",{className:"bre-keys-value",children:[O.alias===void 0?null:(0,z.jsx)("span",{className:"bre-keys-alias",children:O.alias}),(0,z.jsx)("span",{className:O.alias===void 0?"bre-keys-mask bre-keys-mask-plain":"bre-keys-mask",children:Ev(O,n)}),(0,z.jsx)("button",{type:"button",className:y===O.ref?"bre-keys-copy is-copied":"bre-keys-copy","aria-label":n("keysCopy",{name:te}),title:y===O.ref?n("keysCopied"):n("keysCopy",{name:te}),disabled:f||R===O.ref||O.configured===!1,onClick:()=>{ve(O)},children:(0,z.jsx)(Fs,{paths:y===O.ref?[df]:wv})})]}),(0,z.jsx)("span",{className:_===O.ref?"bre-keys-actions is-confirming":"bre-keys-actions",children:_===O.ref?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("button",{type:"button",className:"bre-link-button bre-keys-danger",disabled:f,onClick:()=>{Ie(()=>o.remove(t,O.ref),n("keysRemoved"))},children:n("keysConfirmRemove")}),(0,z.jsx)("button",{type:"button",className:"bre-link-button",disabled:f,onClick:()=>S(void 0),children:n("keysCancel")})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)("span",{className:"bre-keys-protocol-wrap",children:(0,z.jsxs)("button",{type:"button",className:"bre-keys-protocol","aria-haspopup":"listbox","aria-expanded":N?.ref===O.ref,"aria-label":n("keysProtocolLabel",{name:te}),title:n("keysProtocolLabel",{name:te}),disabled:f,onClick:Ce=>{let l=Ce.currentTarget;V(b=>b?.ref===O.ref?void 0:{ref:O.ref,anchor:l}),S(void 0)},children:[(0,z.jsx)("span",{className:"bre-keys-protocol-label",children:mf(O.protocol,n)}),(0,z.jsx)("span",{className:"bre-keys-protocol-caret","aria-hidden":"true",children:"\u203A"})]})}),r===!0?null:(0,z.jsx)("button",{type:"button",className:"bre-link-button bre-keys-scope",disabled:f,title:n("keysScope",{name:te}),onClick:()=>X("scope",O),children:Tv(O,n)}),(0,z.jsx)("button",{type:"button",className:"bre-link-button",disabled:f,onClick:()=>X("alias",O),children:n("keysAlias")}),(0,z.jsx)("button",{type:"button",className:"bre-link-button",disabled:f,onClick:()=>X("value",O),children:n("keysEdit")}),(0,z.jsx)("button",{type:"button",className:"bre-link-button",disabled:f,onClick:()=>{S(O.ref),x(void 0)},children:n("keysRemove")})]})})]}),h!==void 0&&h.ref===O.ref?(0,z.jsx)("li",{className:"bre-keys-form-row",children:ye()}):null]},O.ref)}),ce()]}),r===!0?(0,z.jsx)("p",{className:"bre-keys-note",children:n("keysDraftHint")}):null,c===void 0?null:(0,z.jsx)("p",{className:"bre-effort-message bre-"+c.kind,role:c.kind==="error"?"alert":"status",children:c.text}),N===void 0||Fe===void 0?null:(0,z.jsx)(sf,{anchor:N.anchor,label:n("keysProtocolLabel",{name:lf(Fe)}),options:uf(Q,Fe.protocol,n,r===!0),selected:Fe.protocol??"",onPick:O=>_e(Fe,O),onClose:()=>V(void 0)})]})}var wn="bre-key-managed",Nv="bre-keys-host",gf="bre-keys-probe-host",Bs="data-bre-key-host",Ov="data-bre-key-input",yi="data-bre-region",nn=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 hf(e){let t=nn.get(e)?.host;if(t!==void 0&&t.isConnected)return t;let n=e.nextElementSibling;return n instanceof HTMLElement&&n.hasAttribute(Bs)?n:void 0}function bf(e,t){let n=t.route;if(n===void 0||n.length===0||Iv(e)===void 0||e.parentElement===null)return;Ve(e,wn,!0);let r=nn.get(e),o=hf(e);o===void 0&&(r!==void 0&&yf(e,r),o=e.ownerDocument.createElement("div"),o.className=Nv,e.after(o)),ke(o,Bs,n);let i=e.getAttribute(yi);i===null?o.hasAttribute(yi)&&o.removeAttribute(yi):ke(o,yi,i);let a=nn.get(e),s=a?.probeHost??e.ownerDocument.createElement("span");a===void 0&&(s.className=gf),s.parentElement!==e&&e.appendChild(s);let d=()=>(0,qs.createElement)($e,{fallbackText:t.t("keysPanelFailed")},(0,qs.createElement)(bi,{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&&(nn.delete(e),a.mount.root.unmount()),nn.set(e,{route:n,host:o,probeHost:s,mount:it(o,d(),{sync:!0}),t:t.t,client:t.client})}function yf(e,t){nn.delete(e),qe(t.mount),t.probeHost.remove()}function vi(e){Ve(e,wn,!1);let t=nn.get(e);t!==void 0&&yf(e,t),hf(e)?.remove();for(let n of Array.from(e.children))n.classList.contains(gf)&&n.remove()}function vf(){for(let e of Array.from(document.querySelectorAll(`[${Bs}]`))){let t=e.previousElementSibling;t instanceof HTMLElement&&nn.has(t)?vi(t):e.remove()}}var wf="http://www.w3.org/2000/svg",Dv="data-bre-icon";function Pv(e){let t=document.createElementNS(wf,"path");return t.setAttribute("d",e),t}function wi(e,t){let n=document.createElementNS(wf,"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(Dv,e),n.append(...t.map(Pv)),n}var kn="bre-key-field",Ef="bre-key-eye",Yr="data-bre-key-input",Tf="data-bre-eye-show",Sf="data-bre-eye-hide",xf=["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"],xi=new WeakMap,xn=new WeakMap;function ki(e){let t=e.querySelector(`input[${Yr}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function Us(e){for(let t of Array.from(e.children))if(t instanceof HTMLButtonElement&&t.classList.contains(Ef))return t}function Cf(e){let t=ki(e);t!==void 0&&(ke(t,Yr,""),Ve(e,kn,!0))}function Af(e,t){let n=ki(e);if(n===void 0){rr(e);return}xi.get(e)?.route!==t.route&&xn.delete(e),xi.set(e,t),ke(n,Yr,""),Ve(e,kn,!0);let r=Us(e)??Fv(e);ke(r,Tf,t.t("keyRevealShow")),ke(r,Sf,t.t("keyRevealHide")),Ks(r,n)}function rr(e){let t=Us(e);t!==void 0&&t.remove(),xi.delete(e),Ve(e,kn,!1);let n=e.querySelector(`input[${Yr}]`);n instanceof HTMLInputElement&&(n.removeAttribute(Yr),n.type="password");let r=xn.get(e);xn.delete(e),r!==void 0&&n instanceof HTMLInputElement&&n.value===r&&Xr(n,"")}async function _v(e){try{let t=await fetch(`${xo}?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 Ks(e,t){let n=t.type!=="password";ke(e,"aria-pressed",n?"true":"false");let r=e.getAttribute(n?Sf:Tf);r!==null&&(ke(e,"aria-label",r),ke(e,"title",r)),Ct(e,t.disabled)}function Xr(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 Fv(e){let t=document.createElement("button");t.type="button",t.className=Ef,t.append(kf("eye"),kf("eye-off"));let n=async()=>{let r=ki(e),o=xi.get(e);if(r===void 0||o===void 0||t.hasAttribute("aria-busy"))return;if(r.type!=="password"){let a=xn.get(e);xn.delete(e),a!==void 0&&r.value===a&&Xr(r,""),r.type="password",Ks(t,r);return}let i=o.route;if(i!==void 0&&xn.get(e)===void 0&&r.value.length===0){ke(t,"aria-busy","true");let a;try{a=await(o.loadKey??_v)(i)}catch{a=void 0}if(t.hasAttribute("aria-busy")&&t.removeAttribute("aria-busy"),a===void 0){let s=o.t("keyRevealFailed");ke(t,"aria-label",s),ke(t,"title",s);return}if(Us(e)!==t||!t.isConnected||ki(e)!==r||r.value.length>0)return;xn.set(e,a),Xr(r,a)}r.type="text",Ks(t,r)};return t.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation(),n()}),e.append(t),t}function kf(e){let t=e==="eye-off"?[...xf,"M2.5 13.5 13.5 2.5"]:xf;return wi(e,t)}var js="bre-editor-tabs",qv="bre-editor-tab",Ei="data-bre-tab-id",Qr="bre-tabbed",Wt="data-bre-tab",Mf="data-bre-provider",yt="data-bre-region",Jr="data-bre-editor-body",sr="data-bre-footer",Bv="row",Kv="path",Zr="data-bre-details";var Uv=".bre-headers",Wv=".bre-fingerprint",Gv="data-bre-fingerprint",rn="provider",or="models",ir="fingerprint",ar="advanced",jv=[rn,or,ar,ir],zv="none",Lf=jv,Rf=js,Hf=qv,Nf=Ei,Ti='[class*="editorActions"], [class*="modelList"], [class*="modelCatalog"], [class*="modelEntry"]',$v='[class*="modelCatalog"], [class*="modelList"], [class*="modelEntry"]',Of='[class*="rowCard"], [class*="addCard"], li',Vv='[class*="addPanel"]',Ws=".bre-create-host";function If(){return{warned:new WeakSet}}function dr(e){return e===null?null:e.closest(Of)}function Df(e){let t=dr(e);return t!==null&&t.querySelector(Ws)!==null}function Pf(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.matches(Vv)&&!t.hidden)return t;return e}function _f(e,t){if(e.getAttribute(Wt)===t){Gs(e);return}let n=Jo(e),r=e.getBoundingClientRect().top,o=n?.scrollTop??0;n!==void 0&&(n.style.overflowAnchor="none"),ke(e,Wt,t),Gs(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 zs(e,t,n){if(!e.isConnected)return;let r=new Set;for(let o of Array.from(e.querySelectorAll(Ti))){let i=o.closest(Of);i!==null&&r.add(i)}for(let o of Array.from(e.querySelectorAll(`.${Qr}`)))r.has(o)||Si(o);for(let o of r)try{ew(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)),Si(o)}}function Ff(){for(let e of Array.from(document.querySelectorAll(`.${Qr}`))){e.classList.remove(Qr),e.removeAttribute(Wt),e.removeAttribute(Jr);for(let t of Array.from(e.querySelectorAll(`[${yt}]`)))t.removeAttribute(yt)}for(let e of Array.from(document.querySelectorAll(`[${Wt}]`)))e.removeAttribute(Wt);for(let e of Array.from(document.querySelectorAll(`[${yt}]`)))e.removeAttribute(yt);for(let e of Array.from(document.querySelectorAll(`[${Jr}]`)))e.removeAttribute(Jr);for(let e of Array.from(document.querySelectorAll(`[${sr}]`)))e.removeAttribute(sr);for(let e of Array.from(document.querySelectorAll(`details[${Zr}]`)))e.removeAttribute("open"),e.removeAttribute(Zr);for(let e of Array.from(document.querySelectorAll(`.${kn}`)))rr(e);for(let e of Array.from(document.querySelectorAll(`.${wn}`)))vi(e);vf()}function Yv(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(Ti)!==null||n.querySelector("input, select")!==null))return n;let t=e.querySelector(Ti);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:[]};qf(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 Jv=4;function qf(e,t,n){if(!(n>Jv)){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($v)){t.models??(t.models=r);continue}if(r.querySelector(Ti)!==null){qf(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 Qv(e,t){if(!t.contains(e))return;ke(e,sr,Bv);let n=e.parentElement;for(;n!==null&&(ke(n,sr,Kv),n!==t);)n=n.parentElement}function Zv(e){let n=e.querySelector(`[${Mf}]`)?.getAttribute(Mf);return n==null||n===""?void 0:n}function ew(e,t){let n=Pf(e),r=Yv(n);if(r===void 0){Si(e);return}let o=Xv(r);if(o===void 0){Si(e);return}let i=Array.from(n.querySelectorAll(Uv)),a=i[0]??null,s=Zv(n);for(let g of o.fields)ke(g,yt,rn),Af(g,{t:t.t,route:s}),bf(g,{t:t.t,route:s});o.header!==void 0&&ke(o.header,yt,zv),o.models!==void 0&&ke(o.models,yt,or),ke(r,Jr,""),n.querySelector(Ws)!==null&&Qv(o.actions,r);for(let g of i)ke(g,yt,ar);let d=n.querySelector(Wv);d!==null&&ke(d,yt,ir),nw(r);let c=new Set([rn]);o.models!==void 0&&c.add(or),a!==null&&c.add(ar);let u=n.querySelector(Ws)!==null;d!==null&&!u&&d.getAttribute(Gv)==="ready"&&c.add(ir);let p=e.getAttribute(Wt)??rn;ke(e,Wt,c.has(p)?p:rn),Ve(e,Qr,!0),tw(e,n,t,c)}function tw(e,t,n,r){let o=t.querySelector(`.${js}`);o!==null&&(ke(o,"aria-label",n.t("editorTabsLabel")),Pr(En(o,rn),n.t("editorTabProvider")),Pr(En(o,or),n.t("editorTabModels")),Pr(En(o,ar),n.t("editorTabAdvanced")),Pr(En(o,ir),n.t("editorTabFingerprint")),Ct(En(o,or),!r.has(or)),Ct(En(o,ar),!r.has(ar)),Ct(En(o,ir),!r.has(ir)),Gs(e,o))}function Gs(e,t){let n=t??Pf(e).querySelector(`.${js}`);if(n===null)return;let r=e.getAttribute(Wt)??rn;for(let o of Array.from(n.querySelectorAll(`[${Ei}]`)))ke(o,"aria-selected",o.getAttribute(Ei)===r?"true":"false")}function En(e,t){for(let n of Array.from(e.children))if(n instanceof HTMLElement&&n.getAttribute(Ei)===t)return n}function Si(e){e.classList.remove(Qr),e.removeAttribute(Wt),e.removeAttribute(Jr);for(let t of Array.from(e.querySelectorAll(`[${yt}]`)))t.getAttribute(yt)===rn&&(rr(t),vi(t)),t.removeAttribute(yt);for(let t of Array.from(e.querySelectorAll(`[${sr}]`)))t.removeAttribute(sr);rw(e)}function nw(e){for(let t of Array.from(e.querySelectorAll("details")))t.hasAttribute("open")||(ke(t,Zr,"closed"),ke(t,"open",""))}function rw(e){for(let t of Array.from(e.querySelectorAll(`details[${Zr}]`)))t.removeAttribute("open"),t.removeAttribute(Zr)}var Cp=require("react");var dt=require("react");var Ne=require("react");var ow='p[class*="savedNotice"]',Uf="data-bre-saved-hidden",iw="bre-auto-effort-note",aw="data-bre-auto-effort-phase",Bf="bre-auto-effort-note-text",lr=new Map,Kf=new WeakMap,cr=null,Ci=null;function Wf(e){let t=Array.from(e.querySelectorAll(ow));for(let n of t){let r=n.textContent?.trim()??"";Kf.get(n)!==r&&(Kf.set(n,r),r.length>0&&$f(r)),!lr.has(n)&&(lr.set(n,n.style.display),n.setAttribute(Uf,""),n.style.display="none")}for(let[n,r]of Array.from(lr))n.isConnected&&t.includes(n)||(jf(n,r),lr.delete(n))}function Gf(){for(let[e,t]of Array.from(lr))jf(e,t);lr.clear(),$s()}function jf(e,t){e.style.display=t,e.removeAttribute(Uf)}function zf(e){$f(e)}function $f(e){if(cr!==null&&cr.isConnected&&cr.textContent===e)return;$s();let t=document.createElement("div");t.className=iw,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute(aw,"done"),t.innerHTML=`<span class="${Bf}"></span>`;let n=t.querySelector(`.${Bf}`);n!==null&&(n.textContent=e),t.style.setProperty("--bre-note-hold","3000ms"),document.body.append(t),cr=t,Ci=setTimeout(()=>{$s()},3e3)}function $s(){Ci!==null&&(clearTimeout(Ci),Ci=null),cr?.remove(),cr=null}var Tn="data-bre-settle",Vf='[class*="rowActions"] > button:not(.bre-provider-switch):not(.bre-provider-delete)';var Pt=null,Vs=0,Ai=0,eo=!1,ur=null;function Yf(e){return e.className.includes("dangerButton")?"remove":"edit"}function Ys(e,t){return Array.from(e.querySelectorAll(Vf)).find(r=>Yf(r)===t)??null}function sw(e){return typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function dw(e){typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):clearTimeout(e)}function Xf(e=document){to();let t=[];for(let n of Array.from(e.querySelectorAll(Vf))){if(n.disabled)continue;let r=n.closest("li")??n.parentElement;if(r===null)continue;let o=Yf(n);t.some(i=>i.row===r&&i.role===o)||t.push({row:r,role:o})}t.length!==0&&(Pt=t,Ai=Date.now(),Vs=Ai+8e3,lw(),Jf())}function Xs(){if(Pt===null)return;let e=Date.now();if(e>Vs){to();return}let t=0;if(Pt=Pt.filter(n=>{if(!n.row.isConnected)return!1;let r=Ys(n.row,n.role);return r===null||(r.disabled?(eo=!0,t+=1,r.hasAttribute(Tn)||r.setAttribute(Tn,"")):eo&&r.hasAttribute(Tn)&&r.removeAttribute(Tn)),!0}),eo&&t===0){to();return}if(!eo&&e-Ai>1500){to();return}Jf()}function Jf(){ur!==null||Pt===null||(ur=sw(()=>{ur=null,Xs()}))}function lw(){if(Pt!==null)for(let e of Pt){let t=Ys(e.row,e.role);t!==null&&!t.hasAttribute(Tn)&&t.setAttribute(Tn,"")}}function Qf(){to()}function to(){if(ur!==null&&(dw(ur),ur=null),Pt!==null)for(let e of Pt){let t=Ys(e.row,e.role);t!==null&&t.removeAttribute(Tn)}Pt=null,eo=!1,Vs=0,Ai=0}var se=require("react/jsx-runtime"),cw=["claude-cli/2.1.161 (external, cli)","claude-code/1.0.0","Kilo-Code/1.0"];function Zf(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 ep(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 uw(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 Mi({route:e,api:t,t:n,onDismiss:r,deferred:o,extras:i,onCommitExtras:a,onResetExtras:s}){let d=(0,Ne.useId)(),[c,u]=(0,Ne.useState)(void 0),[p,g]=(0,Ne.useState)({rows:[]}),[m,f]=(0,Ne.useState)(!1),[v,h]=(0,Ne.useState)(!1),[x,C]=(0,Ne.useState)(!0),[T,H]=(0,Ne.useState)(!1),[B,I]=(0,Ne.useState)(!1),[F,k]=(0,Ne.useState)(void 0),[E,_]=(0,Ne.useState)(void 0),[S,y]=(0,Ne.useState)(!1),A=(0,Ne.useRef)(0),R=(0,Ne.useRef)(null),D=o!==void 0,K=o?.onDraft,N=(0,Ne.useRef)(void 0);(0,Ne.useEffect)(()=>{if(D&&N.current!==void 0)return;N.current=e;let X=!0;return(async()=>{try{let me=await we(t);if(!X)return;let W=ja(me.namespace,e);u(W),g(Zf(W,A)),I(me.writable!==!0)}catch{X&&I(!0)}finally{X&&C(!1)}})(),()=>{X=!1}},[t,e,D]),(0,Ne.useEffect)(()=>{K!==void 0&&K(ep(p))},[p,K]),(0,Ne.useEffect)(()=>{let X=!0;return(async()=>{try{let W=await(await fetch($d,{method:"GET"})).json();X&&W.ok===!0&&W.data!==void 0&&_(W.data)}catch{}})(),()=>{X=!1}},[]),(0,Ne.useEffect)(()=>{let X=R.current;if(X===null)return;let me=()=>{y(X.dataset.breRegion==="advanced")};me();let W=new MutationObserver(me);return W.observe(X,{attributes:!0,attributeFilter:["data-bre-region"]}),()=>{W.disconnect()}},[]);let V=()=>{g(X=>({...X,rows:[...X.rows,{id:A.current+=1,name:"",value:""}]})),k(void 0)},Q=(X,me)=>{g(W=>({...W,rows:W.rows.map(ee=>ee.id===X?{...ee,...me}:ee)})),k(void 0)},ae=X=>{g(me=>({...me,rows:me.rows.filter(W=>W.id!==X)})),k(void 0)},de=()=>{g({rows:[{id:A.current+=1,name:"",value:""}]}),k(void 0)},le=()=>{if(s?.(),g(Zf(c,A)),h(!1),k(void 0),o!==void 0){o.onCancel();return}S&&r?.()},be=async X=>{if(H(!0),k(void 0),!uw(c,X)){Xf();let oe;try{oe=await Or(t,e,X)}catch(ye){oe={ok:!1,error:ye instanceof Error?ye.message:String(ye)}}if(!oe.ok){H(!1),k({kind:"error",text:oe.error==="no-route"?n("headersNoRoute"):oe.error==="read-only"?n("headersReadOnly"):n("headersError",{error:oe.error})});return}u(X)}if(h(!1),a!==void 0)try{await a()}catch{H(!1),k({kind:"error",text:n("camouflageError")});return}H(!1);let W=Object.keys(c??{}).length>0,ee=Object.keys(X).length===0&&W?n("headersCleared"):n("headersSaved");if(S){zf(ee),r?.();return}k({kind:"success",text:ee})},Te=Object.entries(c??{}),ie=B||T,fe=S||D,Re=v||fe?p.rows.filter(X=>X.name.trim().length>0).length:Te.length,Oe=p.rows.some(X=>X.name.trim().length>0||X.value.length>0),Ie=m||v||fe;return(0,se.jsxs)("div",{className:"bre-headers",ref:R,"data-plugin":Me,"data-open":m?"1":"0",children:[(0,se.jsx)("div",{className:"bre-headers-head",children:v||fe?(0,se.jsxs)(se.Fragment,{children:[(0,se.jsx)("span",{className:"bre-effort-title",children:n("headersTitle")}),Re===0?null:(0,se.jsx)("span",{className:"bre-headers-count",children:Re}),B||!Oe?null:(0,se.jsx)("button",{type:"button",className:"bre-headers-clear",disabled:ie,onClick:de,children:n("headersClear")})]}):(0,se.jsxs)("button",{type:"button",className:"bre-headers-disclosure","aria-expanded":m,"aria-label":`${n("headersTitle")} ${e}`,onClick:()=>{f(!m),k(void 0)},children:[(0,se.jsx)("span",{className:"bre-effort-title",children:n("headersTitle")}),x||Re===0?null:(0,se.jsx)("span",{className:"bre-headers-count",children:Re}),(0,se.jsx)("span",{className:"bre-headers-chevron","aria-hidden":"true",children:"\u203A"})]})}),Ie?(0,se.jsxs)(se.Fragment,{children:[(0,se.jsx)("p",{className:"bre-effort-note",children:n("headersHint")}),E===void 0?null:(0,se.jsxs)(se.Fragment,{children:[E.environment.preferOfficialLayer?(0,se.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictPatched")}):null,E.conflicts.length===0&&(E.headerConflicts?.length??0)===0?null:(0,se.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictOrigin")}),E.environment.siblings.length===0?null:(0,se.jsx)("p",{className:"bre-effort-note bre-warn",children:n("headersConflictSiblings",{names:E.environment.siblings.map(X=>X.name).join(", ")})})]}),x?null:v||fe?(0,se.jsxs)("div",{className:"bre-headers-edit",children:[(0,se.jsxs)("div",{className:"bre-headers-columns","aria-hidden":"true",children:[(0,se.jsx)("span",{children:n("headersName")}),(0,se.jsx)("span",{children:n("headersValue")}),(0,se.jsx)("span",{})]}),p.rows.map(X=>(0,se.jsxs)("div",{className:"bre-headers-row",children:[(0,se.jsx)("input",{type:"text",className:"bre-text-input bre-headers-name",value:X.name,disabled:ie,placeholder:n("headersNamePlaceholder"),"aria-label":n("headersName"),onChange:me=>{Q(X.id,{name:me.target.value})}}),(0,se.jsx)("input",{type:"text",className:"bre-text-input bre-headers-value",value:X.value,disabled:ie,list:X.name.trim().toLowerCase()==="user-agent"?d:void 0,placeholder:n("headersValue"),"aria-label":n("headersValue"),onChange:me=>{Q(X.id,{value:me.target.value})}}),(0,se.jsx)("button",{type:"button",className:"bre-headers-remove",disabled:ie,"aria-label":`${n("headersRemove")} ${X.name}`,title:n("headersRemove"),onClick:()=>{ae(X.id)},children:"\xD7"})]},X.id)),(0,se.jsx)("button",{type:"button",className:"bre-headers-add",disabled:ie,onClick:V,children:n("headersAdd")}),(0,se.jsx)("datalist",{id:d,children:cw.map(X=>(0,se.jsx)("option",{value:X},X))})]}):(0,se.jsxs)("div",{className:"bre-headers-rows",children:[Te.length===0?(0,se.jsx)("p",{className:"bre-effort-note",children:n("headersEmpty")}):Te.map(([X,me])=>(0,se.jsxs)("div",{className:"bre-headers-row",children:[(0,se.jsx)("span",{className:"bre-headers-name",children:X}),(0,se.jsx)("span",{className:"bre-headers-value bre-headers-masked",children:"\u2022".repeat(Math.min(me.length,24))})]},X)),B?null:(0,se.jsx)("div",{className:"bre-effort-actions",children:(0,se.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:ie,onClick:()=>{h(!0),k(void 0)},children:n("headersEdit")})})]})]}):null,!x&&(fe||v)?(0,se.jsxs)(se.Fragment,{children:[i,(0,se.jsxs)("div",{className:"bre-effort-actions bre-headers-actions",children:[(0,se.jsx)("button",{type:"button",className:"bre-secondary-button",disabled:T,onClick:le,children:n("headersCancel")}),D?null:(0,se.jsx)("button",{type:"button",className:"bre-primary-button",disabled:ie,onClick:()=>{be(ep(p))},children:n("headersSave")})]})]}):null,F===void 0?null:(0,se.jsx)("p",{className:"bre-effort-message bre-"+F.kind,role:F.kind==="error"?"alert":"status",children:F.text})]})}var Pe=require("react");var st=require("react/jsx-runtime"),fw=[{value:void 0,labelKey:"camouflageOff"},{value:"codex",labelKey:"camouflageCodex"},{value:"claude",labelKey:"camouflageClaude"}];function pw(e){return e==="codex"||e==="claude"}function tp(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))pw(a)&&(r[i]=a);return{presets:["codex","claude"],providers:r,installed:n.installed===!0}}function Js({t:e,value:t,installed:n,disabled:r=!1,onChange:o}){let i=(0,Pe.useId)(),a=`${i}-title`,s=`${i}-hint`;return(0,st.jsxs)("div",{className:"bre-camouflage","data-plugin":Me,"data-open":"1",title:e("camouflageHint"),children:[(0,st.jsx)("span",{className:"bre-effort-title",id:a,children:e("camouflageTitle")}),(0,st.jsx)("div",{className:"bre-camouflage-options",role:"radiogroup","aria-labelledby":a,"aria-describedby":s,children:fw.map(d=>(0,st.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,st.jsx)("span",{className:"bre-sr-only",id:s,children:e("camouflageHint")}),n?null:(0,st.jsx)("p",{className:"bre-camouflage-warn",children:e("camouflageUnavailable")})]})}function Qs(e,t){let[n,r]=(0,Pe.useState)(void 0),[o,i]=(0,Pe.useState)(void 0),[a,s]=(0,Pe.useState)(!0),[d,c]=(0,Pe.useState)(!0),u=(0,Pe.useRef)(void 0),p=(0,Pe.useRef)(void 0),g=(0,Pe.useRef)(!0);(0,Pe.useEffect)(()=>(g.current=!0,()=>{g.current=!1}),[]),(0,Pe.useEffect)(()=>{if(e===""){c(!1);return}let h=!1;return c(!0),fetch(ua,{method:"GET"}).then(async x=>await x.json()).then(x=>{if(h||!g.current)return;let C=tp(x);if(C===void 0)return;let T=C.providers[e];u.current=T,p.current=T,r(T),i(T),s(C.installed)}).catch(()=>{}).finally(()=>{!h&&g.current&&c(!1)}),()=>{h=!0}},[e]);let m=(0,Pe.useCallback)(h=>{p.current=h,i(h)},[]),f=(0,Pe.useCallback)(()=>{p.current=u.current,i(u.current)},[]),v=(0,Pe.useCallback)(async h=>{let x=h===void 0?p.current:h.preset;if(e===""||x===u.current)return;let C=await fetch(ua,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({route:e,preset:x??null})}),T=await C.json();if(!C.ok||T.ok!==!0)throw new Error("camouflage write rejected");let H=tp(T);u.current=x,p.current=x,r(x),i(x),H!==void 0&&s(H.installed)},[e]);return{value:o,saved:n,installed:a,loading:d,setValue:m,reset:f,commit:v}}function np({route:e,t}){let n=Qs(e,t),[r,o]=(0,Pe.useState)(void 0),i=(0,Pe.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,st.jsxs)(st.Fragment,{children:[(0,st.jsx)(Js,{t,value:n.value,installed:n.installed,disabled:n.loading||e==="",onChange:i}),r===void 0?null:(0,st.jsx)("p",{className:"bre-effort-message bre-"+r.kind,role:r.kind==="error"?"alert":"status",children:r.text})]})}var Zs=require("react");var mw={provider:"editorTabProvider",models:"editorTabModels",fingerprint:"editorTabFingerprint",advanced:"editorTabAdvanced"};function Li({host:e,t}){return(0,Zs.createElement)("div",{className:Rf,role:"tablist","aria-label":t("editorTabsLabel")},...Lf.map(n=>(0,Zs.createElement)("button",{key:n,type:"button",role:"tab",className:Hf,[Nf]:n,onClick:r=>{r.preventDefault(),r.stopPropagation();let o=dr(e.current);o!==null&&_f(o,n)}},t(mw[n]))))}var gw=15e3;function op(){return{intents:new Map,baseline:new Map,flushing:!1}}function ed(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 td(e,t){e.intents.delete(t)}function ip(e,t){let n=e.intents.get(t);n!==void 0&&(n.releasedAt=Date.now())}function ap(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 sp(e,t){return t.length>0&&!e.baseline.has(t)}async function dp(e,t){if(e.flushing)return rp(e);if(e.intents.size===0)return 0;e.flushing=!0;try{let n=await we(t),r,o=async a=>gt(n.namespace,a)?!0:(r??(r=await we(t,{fresh:!0})),gt(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>gw?(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 Or(t,a,s.headers)}catch(c){d={ok:!1,error:c instanceof Error?c.message:String(c)}}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 rp(e)}function rp(e){let t=0;for(let n of e.intents.values())n.releasedAt!==void 0&&(t+=1);return t}var on=require("react/jsx-runtime");function cp({host:e,api:t,t:n,routeIdLabels:r,staged:o}){let[i,a]=(0,dt.useState)(()=>no(e.current,r)),s=(0,dt.useRef)(i),d=(0,dt.useRef)(void 0),c=(0,dt.useRef)(new Set),u=(0,dt.useRef)(!1),p=(0,dt.useRef)(null);return p.current===null&&(p.current={onDraft:g=>{d.current=g;let m=s.current;if(m.length===0){!u.current&&Object.keys(g).length>0&&(u.current=!0,console.info("[bre] deferred request headers: holding a draft until the provider id is typed"));return}ed(o,m,g),lp(t,o,m,c.current)},onCancel:()=>{d.current=void 0,td(o,s.current)}}),(0,dt.useEffect)(()=>{let g=Ri(e.current);if(g===null)return;let m=()=>{a(no(e.current,r))};return g.addEventListener("input",m,!0),()=>{g.removeEventListener("input",m,!0)}},[e,r]),(0,dt.useEffect)(()=>{i.length>0&&lp(t,o,i,c.current)},[t,o,i]),(0,dt.useEffect)(()=>{let g=s.current;if(g===i)return;td(o,g),s.current=i;let m=d.current;m!==void 0&&i.length>0&&ed(o,i,m)},[i,o]),(0,dt.useEffect)(()=>()=>{ip(o,s.current)},[o]),(0,on.jsxs)(on.Fragment,{children:[(0,on.jsx)(Li,{host:e,t:n}),(0,on.jsx)(Mi,{route:i,api:t,t:n,deferred:p.current,extras:(0,on.jsx)(np,{route:i,t:n})})]})}function lp(e,t,n,r){!sp(t,n)||r.has(n)||(r.add(n),(async()=>{try{let o=await we(e);ap(t,n,gt(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 Ri(e){let t=e?.parentElement;return t==null?null:t.parentElement?.closest('[class*="addCard"]')??t}function no(e,t){let n=e?.parentElement;if(n==null)return"";let r=t(),o=at(n,r).trim();if(o.length>0)return o;let i=Ri(e);return i===null||i===n?"":at(i,r).trim()}var id=require("react");var lt=require("react");var ro=15e3,hw=3;function fp(){return{intents:new Map,baseline:new Map,baselinePending:new Set,baselineFailures:new Set,activeIntents:new Map,draining:!1,drainAgain:!1}}function nd(e,t,n){if(t.length===0)return;if(n.length===0){rd(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}bw(r.drafts,n)||(r.drafts=[...n],r.revision+=1,r.baselineMissing=!1,e.draining&&(e.drainAgain=!0))}function bw(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 rd(e,t){e.intents.delete(t),e.draining&&(e.drainAgain=!0)}function pp(e,t){let n=e.intents.get(t);n!==void 0&&(n.releasedAt=Date.now())}function od(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 mp(e,t){return yw(e,t)?(e.baselinePending.add(t),!0):!1}function gp(e,t){e.baselinePending.delete(t),e.baseline.has(t)||e.baselineFailures.add(t),e.draining&&(e.drainAgain=!0)}function yw(e,t){return t.length>0&&!e.baseline.has(t)&&!e.baselinePending.has(t)&&!e.baselineFailures.has(t)}async function hp(e,t,n){if(e.draining)return up(e);if(e.intents.size===0)return 0;e.draining=!0;try{do{e.drainAgain=!1;let r=await we(t),o,i=async s=>gt(r.namespace,s)?!0:(o??(o=await we(t,{fresh:!0})),gt(o.namespace,s)),a=Date.now();for(let[s,d]of Array.from(e.intents)){if(e.intents.get(s)!==d)continue;let c=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>ro&&(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 g=await i(s);if(e.intents.get(s)!==d)continue;if(d.revision!==c||d.declaredBefore!==void 0){e.drainAgain=!0;continue}g?(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>ro&&(e.intents.delete(s),console.error("[bre] deferred api keys: the pre-save baseline remained unknown; refusing to write held keys:",s))):(od(e,s,!1),d.releasedAt!==void 0&&a-d.releasedAt>ro&&(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>ro&&e.intents.delete(s);continue}if(d.declaredBefore){e.intents.delete(s);continue}let u=await i(s);if(e.intents.get(s)!==d)continue;if(d.revision!==c){e.drainAgain=!0;continue}if(!u){d.releasedAt!==void 0&&a-d.releasedAt>ro&&(e.intents.delete(s),console.info("[bre] deferred api keys: gave up on drafts whose card closed first:",s));continue}let p=await vw(e,s,d,n);if(e.intents.get(s)!==d||d.revision!==c)continue;p&&(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 up(e)}async function vw(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,c=()=>{a=!0,n.attempts+=1};for(let u of i){if(d())return!1;let p=n.landed.find(g=>g.ref===u.ref);if(p===void 0){let g=await r.add(t,u.value,u.alias);if(!g.ok){if(d())return!1;c();break}let f=(g.addedRef!==void 0&&g.entries.some(T=>T.ref===g.addedRef)?g.addedRef:void 0)??g.entries.map(T=>T.ref).find(T=>!n.landed.some(H=>H.hostRef===T));if(f===void 0){if(d())return!1;c();break}let v=g.entries.find(T=>T.ref===f),{alias:h,protocol:x,...C}=u;if(p={ref:u.ref,hostRef:f,draft:{...C,...v?.alias===void 0?{}:{alias:v.alias},...v?.protocol===void 0?{}:{protocol:v.protocol},enabled:v?.enabled??!0}},n.landed.push(p),s=!0,d())return!1;continue}if(p.draft.value!==u.value){if(!(await r.replace(t,p.hostRef,u.value)).ok){if(d())return!1;c();break}if(p.draft={...p.draft,value:u.value},s=!0,d())return!1}if(p.draft.alias!==u.alias){let{alias:g,...m}=p.draft;if(!(await r.rename(t,p.hostRef,u.alias)).ok){if(d())return!1;c();break}if(p.draft={...m,...u.alias===void 0?{}:{alias:u.alias}},s=!0,d())return!1}}if(!a)for(let u of i){if(d())return!1;let p=n.landed.find(v=>v.ref===u.ref);if(p===void 0||p.draft.protocol===u.protocol)continue;if(!(await r.setProtocol(t,p.hostRef,u.protocol)).ok){if(d())return!1;c();break}let{protocol:m,...f}=p.draft;if(p.draft={...f,...u.protocol===void 0?{}:{protocol:u.protocol}},s=!0,d())return!1}if(!a)for(let u of[!0,!1]){for(let p of i){if(d())return!1;if(p.enabled!==u)continue;let g=n.landed.find(f=>f.ref===p.ref);if(g===void 0||g.draft.enabled===u)continue;if(!(await r.setEnabled(t,g.hostRef,u)).ok){if(d())return!1;c();break}if(g.draft={...g.draft,enabled:u},s=!0,d())return!1}if(a)break}return a?(s&&(n.attempts=0),n.attempts>=hw?(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 up(e){let t=0;for(let n of e.intents.values())n.releasedAt!==void 0&&(t+=1);return t}var ww={openai:null,anthropic:null};function xw(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 bp(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:Bc(a.value),...a.protocol===void 0?{}:{protocol:a.protocol}})),endpoints:ww}),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(!Bt(s))return{ok:!1,error:t.t("keysAddIllegal")};let c=xw(e.drafts);return e.drafts=[...e.drafts,{ref:c,value:s,enabled:!0,...d===void 0?{}:{alias:d}}],r(c)},rename:async(a,s,d)=>{let c=o(s);if(c===void 0)return{ok:!1};let{alias:u,...p}=c;return i(s,{...p,...d===void 0?{}:{alias:d}})},replace:async(a,s,d)=>{let c=o(s);return c===void 0||!Bt(d)?{ok:!1,error:t.t("keysAddIllegal")}:i(s,{...c,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 c=o(s);return c===void 0?{ok:!1}:!d&&!e.drafts.some(u=>u.ref!==s&&u.enabled)?{ok:!1,error:t.t("keysLastEnabledOff")}:i(s,{...c,enabled:d})},setProtocol:async(a,s,d)=>{let c=o(s);if(c===void 0)return{ok:!1};let{protocol:u,...p}=c;return i(s,{...p,...d===void 0?{}:{protocol:d}})},setEndpoints:async()=>n(),probe:async()=>n(),reveal:async(a,s)=>o(s)?.value}}var vp=require("react/jsx-runtime");function yp({host:e,store:t,api:n,t:r,routeIdLabels:o,staged:i,onChange:a}){let[s,d]=(0,lt.useState)(()=>no(e.current,o)),c=(0,lt.useRef)(s),u=(0,lt.useRef)(new Set),p=(0,lt.useRef)(!1),g=(0,lt.useMemo)(()=>bp(t,{t:r,onChange:m=>{a?.(m);let f=c.current;if(f.length===0){!p.current&&m.length>0&&(p.current=!0,console.info("[bre] deferred api keys: holding the list until the provider id is typed"));return}nd(i,f,m)}}),[a,i,t,r]);return(0,lt.useEffect)(()=>{let m=Ri(e.current);if(m===null)return;let f=()=>{d(no(e.current,o))};return m.addEventListener("input",f,!0),()=>{m.removeEventListener("input",f,!0)}},[e,o]),(0,lt.useEffect)(()=>{s.length>0&&kw(n,i,s,u.current)},[n,i,s]),(0,lt.useEffect)(()=>{let m=c.current;m!==s&&(rd(i,m),c.current=s),t.drafts.length>0&&s.length>0&&nd(i,s,t.drafts)},[s,i,t]),(0,lt.useEffect)(()=>()=>{pp(i,c.current)},[i]),(0,vp.jsx)(bi,{route:s,t:r,client:g,draft:!0})}function kw(e,t,n,r){r.has(n)||!mp(t,n)||(r.add(n),(async()=>{try{let o=await we(e);od(t,n,gt(o.namespace,n))}catch(o){gp(t,n),console.warn("[bre] deferred api keys: could not read the settings document for this route:",o)}})())}var Ni="data-bre-create-keys",Ew="bre-keys-host",Tw="data-bre-key-input",Hi="data-bre-region",fr=new WeakMap;function wp(e){let t=e.querySelector(`input[${Tw}]`);if(t instanceof HTMLInputElement)return t;let n=e.querySelector('input[type="password"]');return n instanceof HTMLInputElement?n:void 0}function xp(e){let t=fr.get(e)?.host;if(t!==void 0&&t.isConnected)return t;let n=e.nextElementSibling;return n instanceof HTMLDivElement&&n.hasAttribute(Ni)?n:void 0}function kp(e,t){if(e.closest(`[${Ni}]`)!==null){pr(e);return}let n=wp(e);if(n===void 0){pr(e);return}if(e.parentElement===null)return;Ve(e,wn,!0);let r=fr.get(e),o=xp(e);o===void 0&&(r!==void 0&&ad(e,r),o=e.ownerDocument.createElement("div"),o.className=Ew,e.after(o)),ke(o,Ni,"");let i=e.getAttribute(Hi);if(i===null?o.hasAttribute(Hi)&&o.removeAttribute(Hi):ke(o,Hi,i),r!==void 0&&r.host===o)return;r!==void 0&&ad(e,r);let a={drafts:Bt(n.value)?[{ref:"key-1",value:n.value,enabled:!0}]:[]},s=o,d=it(o,t.refreshed(()=>(0,id.createElement)($e,{fallbackText:t.t("keysPanelFailed")},(0,id.createElement)(yp,{host:{current:s},store:a,api:t.api,t:t.t,routeIdLabels:t.routeIdLabels,staged:t.staged,onChange:c=>{let u=wp(e);if(u===void 0||u.disabled)return;let p=c.find(g=>g.enabled)?.value??"";u.value!==p&&Xr(u,p)}}))),{sync:!0});fr.set(e,{host:o,mount:d})}function ad(e,t){fr.delete(e),qe(t.mount)}function pr(e){Ve(e,wn,!1);let t=fr.get(e);t!==void 0&&ad(e,t),xp(e)?.remove()}function Ep(){for(let e of Array.from(document.querySelectorAll(`[${Ni}]`))){let t=e.previousElementSibling;t instanceof HTMLElement&&fr.has(t)?pr(t):e.remove()}}var dd="bre-create-host",sd="bre-add-mode-picker",Sw='[class*="addCard"]',Cw='[class*="addPanel"]',Aw='[class*="addModes"]',Tp="-custom-panel",Mw="-custom";function Ap(){return{hosts:new Map}}function ld(e,t,n){if(!e.isConnected)return;let r=new Set;for(let o of Array.from(e.querySelectorAll(Sw)))if(o.isConnected)try{Lw(o,t,n),r.add(o)}catch(i){Oi(o,n);for(let a of cd(o))try{pr(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)&&Oi(o,n)}function Lw(e,t,n){let r=Sp(e,Tp);(r===void 0||r.hidden)&&(Iw(e,()=>Is(e)),r=Sp(e,Tp),r===void 0||r.hidden)||(e.getAttribute("data-bre-add-card")!=="1"&&e.setAttribute("data-bre-add-card","1"),Pw(e,r,t,n),Nw(e),Ow(r,t),Mp(e,!0))}var Rw=".field, label",Hw=".bre-keys-host, .bre-keys, .bre-create-host";function cd(e){let t=[],n=e.querySelectorAll('input[type="password"], input[data-bre-key-input]');for(let r of Array.from(n)){if(r.closest(Hw)!==null)continue;let o=r.closest(Rw)??r.parentElement;o!==null&&!t.includes(o)&&t.push(o)}return t}function Nw(e){for(let t of cd(e))try{Cf(t)}catch(n){console.warn("[bre] add provider card: could not mark a key field:",n)}}function Ow(e,t){for(let n of cd(e))try{kp(n,{t:t.t,api:t.api,routeIdLabels:t.routeIdLabels,staged:t.stagedKeys,refreshed:t.refreshed})}catch(r){pr(n),console.warn("[bre] add provider card: could not mount the key list:",r)}}function Mp(e,t){let n=Lp(e);n!==void 0&&Ve(n,sd,t)}function Sp(e,t){for(let n of Array.from(e.querySelectorAll(Cw)))if(n.id.endsWith(t))return n}function Lp(e){let t=e.querySelector(Aw);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=Lp(e);if(n!==void 0){for(let r of Array.from(n.querySelectorAll('[role="tab"]')))if(r.id.endsWith(Mw)){if(r.disabled)return;r.getAttribute("aria-selected")!=="true"&&(t(),r.click());return}}}function Dw(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.classList.contains(dd))return t}function Pw(e,t,n,r){let o=r.hosts.get(e),i=Dw(t);if(i!==void 0&&o!==void 0&&o.host===i)return;Oi(e,r),i!==void 0&&i.remove();let a=e.ownerDocument.createElement("div");a.className=dd,t.insertBefore(a,t.firstChild),Is(e);let s=it(a,n.refreshed(()=>(0,Cp.createElement)(cp,{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 Oi(e,t){let n=t.hosts.get(e);n!==void 0&&(t.hosts.delete(e),qe(n.mount))}function Rp(e){for(let t of Array.from(e.hosts.keys()))Oi(t,e);for(let t of Array.from(document.querySelectorAll(`.${dd}`)))t.remove();for(let t of Array.from(document.querySelectorAll(`.${sd}`)))Ve(t,sd,!1);for(let t of Array.from(document.querySelectorAll(`.${kn}`)))rr(t);Ep()}var oo="data-bre-row-provider",Hp="{provider}",_w=["rowCard","setupCard"];function Np(){return Yo()}function ct(e){for(let t of _w)for(let n of Array.from(e.querySelectorAll(`[class*="${t}"]`))){let r=n.parentElement;if(!(r===null||r.tagName!=="UL")&&nt(r).length!==0)return r}}function Sn(e){return e.querySelector('[class*="rowHead"]')??void 0}function mr(e){let t=e.querySelector('[class*="rowName"]')?.textContent?.trim();return t!==void 0&&t.length>0?t:void 0}function Fw(e){let t=e.indexOf(Hp);if(!(t<0))return{prefix:e.slice(0,t),suffix:e.slice(t+Hp.length)}}function qw(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 Bw='[class*="rowCard"], [class*="setupCard"], [class*="addCard"]';function Kw(e){let t=e.closest(Bw);for(let n=e;n!==null&&n!==t;n=n.parentElement)if(n.matches('[data-plugin], [class*="bre-"]'))return!0;return!1}function ut(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=Fw(r);if(o!==void 0)for(let i of Array.from(e.querySelectorAll("button[aria-label]"))){if(Kw(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=qw(a.slice(o.prefix.length,a.length-o.suffix.length));if(s!==void 0)return s}}}function ud(e){let t=e.getAttribute(oo);return t===null||t.length===0?void 0:t}function Uw(e){return Fr(e,ud)}function Op(e,t,n,r=ct(e)){if(!e.isConnected||r===void 0)return;let o=t.labels();for(let i of nt(r)){let a=ut(i,o);if(a===void 0){i.removeAttribute(oo);continue}ud(i)!==a&&i.setAttribute(oo,a)}Qo(e,r,Ww(t),n)}function Ww(e){return{rowOf:t=>{let n=t.closest("li");return n instanceof HTMLElement?n:void 0},idOf:ud,labelOf:mr,order:t=>ol(t),commit:t=>{Co(Uw(t))},seatOf:Sn,seatDrags:!0,gripLabel:(t,n)=>e.t("providerReorderAria",{provider:mr(t)??n}),gripHint:()=>e.t("providerReorderHint")}}function Ip(e){Zo(e);let t=Array.from(document.querySelectorAll(`[${oo}]`));qr(t);for(let n of t)n.removeAttribute(oo)}var gr="data-bre-provider-switch",Ii="bre-row-disabled";function Pp(){return{switches:new WeakSet}}function _p(e,t,n,r=ct(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=ut(i,o);if(a===void 0)continue;let s=Sn(i);s!==void 0&&(Gw(i,s,a,t,n),i.classList.toggle(Ii,!_n(a)))}}function Fp(){for(let e of Array.from(document.querySelectorAll(`[${gr}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`.${Ii}`)))e.classList.remove(Ii)}function Gw(e,t,n,r,o){let i=t.querySelector(`[${gr}]`);if(i!==null){Dp(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(gr,n),Dp(a,e,n,r),jw(a,e,o);let s=t.querySelector('[class*="rowActions"]');s===null?t.appendChild(a):s.insertBefore(a,s.firstChild)}function Dp(e,t,n,r){let o=r.t("providerToggleAria",{provider:mr(t)??n}),i=r.t("providerToggleHint"),a=_n(n)?"true":"false";e.getAttribute(gr)!==n&&e.setAttribute(gr,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 jw(e,t,n){n.switches.has(e)||(n.switches.add(e),e.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation();let o=e.getAttribute(gr);if(o===null)return;let i=!_n(o);al(o,i),e.setAttribute("aria-checked",i?"true":"false"),t.classList.toggle(Ii,!i)}))}var zw=["balance","totalbalance","availablebalance","remainingbalance","creditbalance","balanceusd","totalavailable","available","remaining","credits","credit","amount","left","remain","remainingquota","quotaremaining","remainquota","availablequota","points"],$w=new Map(zw.map((e,t)=>[e,t])),wS=($w.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 Yw(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 qp(e){let t=Yw(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(`${jd}?route=${encodeURIComponent(e)}`,{method:"GET",cache:"no-store",credentials:"same-origin"}),n;try{n=await t.json()}catch{n=void 0}if(!Z(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 Bp={read:Xw};var Gt="data-bre-provider-balance",Jw="data-bre-provider-switch",Di="data-bre-provider-balance-refresh",Qw=["M13.4 8a5.4 5.4 0 1 1-1.6-3.8","M13.8 2.2v3.5h-3.5"];function Up(){return{readings:new Map,errors:new Map,requested:new Set,inflight:new Set,pending:new Set,queued:[],visible:!1}}var Wp=3;function fd(e,t,n,r=ct(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=ut(i,o);if(a===void 0)continue;let s=Sn(i);s!==void 0&&(zp(s,a,t,n),Qp(s,a,t,n))}}function Gp(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 jp(){for(let e of Array.from(document.querySelectorAll(`[${Gt}]`)))e.remove()}function zp(e,t,n,r){let o=r.readings.get(t);if(o!==void 0){$p(e,t,o,n,r);return}let i=r.errors.get(t);if(i!==void 0){Zw(e,t,i,n,r);return}Jp(e)}function $p(e,t,n,r,o){let i=Vp(e,t,r,o);Yp(i,`${r.t("providerBalanceLabel")} ${qp(n)}`,r.t("providerBalanceHint"),r),Xp(e,i)}function Zw(e,t,n,r,o){let i=Vp(e,t,r,o),a=n.length>0?n:r.t("providerBalanceHint");Yp(i,r.t("providerBalanceUnavailable"),a,r),Xp(e,i)}function Vp(e,t,n,r){let o=e.querySelector(`[${Gt}]`);return o===null?(o=document.createElement("span"),o.className="bre-provider-balance",o.setAttribute(Gt,t)):o.getAttribute(Gt)!==t&&o.setAttribute(Gt,t),(o.querySelector(".bre-provider-balance-text")===null||o.querySelector(`[${Di}]`)===null)&&(o.replaceChildren(),ex(o,e,n,r)),o}function ex(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(Di,"1"),i.setAttribute("aria-label",n.t("providerBalanceRefresh")),i.title=n.t("providerBalanceRefresh"),i.append(wi("balance-refresh",Qw)),i.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation();let s=e.getAttribute(Gt);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 Yp(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(`[${Di}]`);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 Kp(e,t,n){let r=e.querySelector(`[${Gt}]`);if(r===null||r.getAttribute(Gt)!==t)return;let o=r.querySelector(`[${Di}]`);o!==null&&(o.classList.toggle("is-spinning",n),n?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))}function Xp(e,t){let n=e.querySelector(`[${Jw}]`);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 Jp(e){for(let t of Array.from(e.querySelectorAll(`[${Gt}]`)))t.remove()}function Qp(e,t,n,r){r.requested.has(t)||r.inflight.has(t)||(r.requested.add(t),Zp(e,t,n,r))}function Zp(e,t,n,r){if(r.inflight.size>=Wp){r.queued.some(o=>o.route===t)||r.queued.push({head:e,route:t});return}em(e,t,n,r)}function tx(e,t){for(;t.inflight.size<Wp&&t.queued.length>0;){let n=t.queued.shift();if(n===void 0)return;em(n.head,n.route,e,t)}}function em(e,t,n,r){r.inflight.add(t),Kp(e,t,!0),(n.client??Bp).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&&$p(e,t,a,n,r);return}if(i.ok&&i.configured===!1){r.readings.delete(t),r.errors.delete(t),e.isConnected&&Jp(e);return}i.configured===!0&&r.errors.set(t,i.error??""),e.isConnected&&zp(e,t,n,r)}).catch(()=>{}).finally(()=>{r.inflight.delete(t),Kp(e,t,!1),e.isConnected||n.repaint?.(),r.pending.delete(t)&&(r.requested.delete(t),Zp(e,t,n,r)),tx(n,r)})}function tm(){return{requested:new Set,pending:[],running:new Set,visible:!1}}var nx=2;function nm(e){for(;e.visible&&e.running.size<nx;){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),nm(e)})}}function pd(e,t,n,r=ct(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=ut(a,i);s===void 0||n.requested.has(s)||(n.requested.add(s),n.running.has(s)||n.pending.push({route:s,client:o}))}nm(n)}var Pi="data-bre-provider-delete",rm='[class*="rowActions"]',om='[class*="dangerButton"]',rx="bre-provider-delete";function im(e,t,n=ct(e)){if(!e.isConnected||n===void 0)return;let r=t.labels(),o=ox(n)??t.t("providerRemoveDisabled");for(let i of Array.from(n.children)){if(!(i instanceof HTMLElement))continue;let a=ut(i,r);if(a===void 0)continue;let s=Sn(i);if(s===void 0)continue;let d=s.querySelector(rm);if(d===null)continue;let c=d.querySelector(`[${Pi}]`);if(d.querySelector(om)!==null){c!==null&&c.remove();continue}let u=c??ix();d.lastElementChild!==u&&d.appendChild(u),ax(u,a,o,t.t("providerRemoveLocked",{provider:mr(i)??a}))}}function am(){for(let e of Array.from(document.querySelectorAll(`[${Pi}]`)))e.remove()}function ox(e){let n=e.querySelector(`${rm} ${om}`)?.textContent?.trim()??"";return n.length>0?n:void 0}function ix(){let e=document.createElement("button");return e.className=rx,e.setAttribute("type","button"),e.setAttribute("disabled",""),e}function ax(e,t,n,r){e.getAttribute(Pi)!==t&&e.setAttribute(Pi,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 _i="data-bre-provider-disabled-group",sx="bre-provider-disabled-seat",sm="bre-provider-disabled-group",md="bre-row-folded",gd="bre-row-hidden";function dm(){return{expanded:!1}}function lm(e,t,n,r=ct(e)){if(!e.isConnected||r===void 0)return;let o=um(r,t.labels()),i=o.filter(c=>!c.enabled).length,a=fm(r);if(i===0){a!==void 0&&a.remove(),hd(o,n);return}let s=a??dx(r,t,n);(s.parentElement!==r||r.lastElementChild!==s)&&r.append(s),hd(o,n);let d=pm(s);d!==void 0&&mm(d,i,t,n)}function cm(){for(let e of Array.from(document.querySelectorAll(`[${_i}]`)))e.remove();for(let e of Array.from(document.querySelectorAll(`.${gd}, .${md}`)))e.classList.remove(gd,md)}function um(e,t){let n=[];for(let r of Array.from(e.children)){if(!(r instanceof HTMLElement)||r.getAttribute(_i)!==null)continue;let o=ut(r,t);o!==void 0&&n.push({row:r,id:o,enabled:_n(o)})}return n}function hd(e,t){for(let n of e){let r=!n.enabled;n.row.classList.toggle(md,r),n.row.classList.toggle(gd,r&&!t.expanded)}}function fm(e){for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.getAttribute(_i)!==null)return t}function pm(e){return e.querySelector(`button.${sm}`)??void 0}function dx(e,t,n){let r=document.createElement("li");r.className=sx,r.setAttribute(_i,"");let o=document.createElement("button");return o.className=sm,o.setAttribute("type","button"),o.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),n.expanded=!n.expanded,lx(e,t,n)}),r.appendChild(o),e.append(r),r}function lx(e,t,n){let r=um(e,t.labels());hd(r,n);let o=fm(e);if(o===void 0)return;let i=r.filter(s=>!s.enabled).length;if(i===0){o.remove();return}let a=pm(o);a!==void 0&&mm(a,i,t,n)}function mm(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 gm="data-bre-retry-policy-hidden",hm='div[class*="field"][role="group"][aria-labelledby$="-retry-failure-label"]',cx="[data-plugin], .bre-headers-host, .bre-create-host, .bre-config-host, .bre-effort-slot";function bm(){return{hidden:new Map}}function ux(e){if(!e.matches(hm)||e.closest(cx)!==null)return!1;let t=e.parentElement,n=t?.parentElement,r=n?.parentElement;if(t==null||!t.matches('div[class*="customizedBody"]')||n===null||n===void 0||!n.matches('details[class*="customized"]')||r===null||r===void 0||!r.matches('div[class*="editor"]')||r.closest('[class*="rowCard"], [class*="addCard"]')===null)return!1;let o=e.getAttribute("aria-labelledby")??"";if(o.length<=20)return!1;let i=Array.from(e.children).find(d=>d.matches('span[class*="fieldLabel"]')&&d.id===o),a=Array.from(e.children).find(d=>d instanceof HTMLSelectElement&&d.matches('[class*="input"][class*="selectInput"]')&&d.getAttribute("aria-labelledby")===o);if(i===void 0||a===void 0)return!1;let s=Array.from(a.options,d=>d.value);return s.length===3&&new Set(s).size===3&&s.includes("")&&s.includes("normal")&&s.includes("always")}function ym(e){return e.style.getPropertyValue("display")==="none"&&e.style.getPropertyPriority("display")==="important"}function fx(e,t){let n=t.hidden.get(e);n!==void 0&&ym(e)||n===void 0&&e.style.display==="none"||(t.hidden.set(e,{value:e.style.getPropertyValue("display"),priority:e.style.getPropertyPriority("display")}),e.setAttribute(gm,"1"),e.style.setProperty("display","none","important"))}function vm(e,t){let n=t.hidden.get(e);t.hidden.delete(e),e.removeAttribute(gm),n!==void 0&&ym(e)&&(n.value===""?e.style.removeProperty("display"):e.style.setProperty("display",n.value,n.priority))}function wm(e,t){let n=new Set;for(let r of Array.from(e.querySelectorAll(hm)))ux(r)&&(n.add(r),fx(r,t));for(let r of Array.from(t.hidden.keys()))n.has(r)||vm(r,t)}function xm(e){for(let t of Array.from(e.hidden.keys()))vm(t,e)}var Cn="data-bre-row-model",io="bre-model-grid";function Em(){return Yo()}function yd(e){let t=[];for(let n of Array.from(e.querySelectorAll('[class*="modelList"]')))nt(n).filter(o=>o.matches('[class*="modelEntry"]')).length!==0&&t.push(n);return t}function Tm(e){for(let t of e){if(t.type!=="childList")continue;let n=t.target;if(n instanceof HTMLElement&&n.matches('[class*="modelList"]')&&nt(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 Fi(e){let t=e.getAttribute(Cn);return t===null||t.length===0?void 0:t}function bd(e,t){let n=e.closest("li");if(n!==null)return ut(n,t.labels())}function km(e,t){let n=at(e,t.labels().modelName);return n.length>0?n:Fi(e)}function px(e,t){return{rowOf:n=>{let r=n.closest('[class*="modelEntry"]');return r instanceof HTMLElement?r:void 0},idOf:Fi,labelOf:n=>km(n,t),order:n=>{let r=bd(e,t);return r===void 0?n:ml(r,n)},commit:n=>{let r=bd(n,t);r!==void 0&&ul(r,Fr(n,Fi))},seatOf:n=>n.querySelector('[class*="modelRow"]')??void 0,seatDrags:!1,gripLabel:(n,r)=>t.t("modelReorderAria",{model:km(n,t)??r}),gripHint:()=>t.t("modelReorderHint"),decorate:(n,r)=>{r.classList.add(io)}}}function Sm(e,t,n,r=yd(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(`.${io}`))){for(let d of Array.from(s.querySelectorAll("[data-bre-drag-handle]")))d.remove();s.classList.remove(io)}let a=Array.from(i.querySelectorAll(`[${Cn}]`));qr(a);for(let s of a)s.removeAttribute(Cn);continue}if(bd(i,t)!==void 0){for(let a of nt(i)){let s=at(a,o.modelId);if(s.length===0){a.removeAttribute(Cn);continue}Fi(a)!==s&&a.setAttribute(Cn,s)}Qo(e,i,px(i,t),n)}}}function Cm(e){Zo(e);for(let n of Array.from(document.querySelectorAll(`.${io}`)))n.classList.remove(io);let t=Array.from(document.querySelectorAll(`[${Cn}]`));qr(t);for(let n of t)n.removeAttribute(Cn)}var _t=require("react");async function mx(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 gx(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 mx(n)}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}}var br,hr=0,hx=0;var vd=new Set;function Am(e){return vd.add(e),()=>{vd.delete(e)}}function qi(){return br}function Mm(){An()}function bx(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 An(){let e=++hr;try{let t=await fetch(pa,{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===hr&&(br=o),{ok:!0,data:o}}e===hr&&(br=void 0);let r=bx(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===hr&&(br=void 0),{ok:!1,error:t instanceof Error?t.message:String(t)}}}async function Lm(e){br=void 0,hr+=1;let t=await gx(pa,{op:"save",...e});if(br=void 0,hr+=1,!t.ok)return{ok:!1,error:t.error};hx+=1;for(let n of vd)try{n()}catch{}return{ok:!0,data:void 0}}var yx=["\u6A21\u578B","Models","models"],Hm='[class*="rowCard"], [class*="setupCard"], [class*="addCard"]',vx='h1,h2,h3,h4,h5,h6,[role="heading"]',wx=/title|heading/i,xx='nav, button, [role="menu"], [role="menuitem"], [class*="rowName"], [class*="rowCard"]',kx=4;function Ex(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(ao))continue;return!1}return n.replace(/\s+/g," ").trim()===t}function Tx(e,t){for(let n=e;n!==null;n=n.parentElement){if(n.matches(vx)||wx.test(String(n.className??"")))return n;if(n===t)break}return null}function Sx(e,t){for(let n of yx)for(let r of e.querySelectorAll("*")){if(!Ex(r,n)||r.closest(xx)!==null||(r.compareDocumentPosition(t)&kx)===0)continue;let o=Tx(r,e);if(o!==null)return o}return null}var wd;function Nm(e){let t=wd;if(t!==void 0&&t.root===e&&t.row.isConnected)return t.row;let n=e.querySelector(Hm);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=Sx(o,n);if(i!==null){let a=Cx(i,o);return a!==null&&(wd={root:e,row:a}),a}}return null}function Cx(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(ao)).length>1||o.length>0)return r.querySelector(Hm)!==null?n:r;n=r,r=r.parentElement}return r===t?n:null}var ao="bre-config-host",kd="bre-config-title-line",xd={display:"flex",alignItems:"center"},Bi=new WeakMap;function Rm(e){e.classList.add(kd),Bi.has(e)||Bi.set(e,{display:e.style.display,alignItems:e.style.alignItems}),e.style.display=xd.display,e.style.alignItems=xd.alignItems}function Ax(e){return e.classList.contains(kd)&&e.style.display===xd.display}function Om(e){e.classList.remove(kd);let t=Bi.get(e);Bi.delete(e),e.style.display=t?.display??"",e.style.alignItems=t?.alignItems??""}function Im(){return{mounts:new Map}}function Dm(e,t,n){let r=n.mounts.get(e),o=e.querySelector(`:scope > .${ao}`);if(o!==null&&r!==void 0&&r.wrapper===o){Ax(e)||Rm(e);return}Pm(e,n),o?.remove(),Rm(e);let i=e.ownerDocument.createElement("div");i.className=ao,e.appendChild(i);let a=it(i,(0,_t.createElement)(Lx,{t:t.t,onOpen:t.onOpen}),{sync:!0});n.mounts.set(e,a)}function Pm(e,t){Om(e);let n=t.mounts.get(e);n!==void 0&&(t.mounts.delete(e),qe(n))}function _m(e){for(let t of Array.from(e.mounts.keys()))Pm(t,e);for(let t of Array.from(document.querySelectorAll(`.${ao}`))){let n=t.parentElement;n!==null&&Om(n),t.remove()}wd=void 0}function Mx(){return(0,_t.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,_t.createElement)("path",{d:"M4 6h8m4 0h4M4 12h2m4 0h10M4 18h10m4 0h2"}),(0,_t.createElement)("circle",{cx:14,cy:6,r:2}),(0,_t.createElement)("circle",{cx:8,cy:12,r:2}),(0,_t.createElement)("circle",{cx:16,cy:18,r:2}))}function Lx(e){return(0,_t.useEffect)(()=>{Mm()},[]),(0,_t.createElement)("button",{className:"bre-config-btn",type:"button",title:e.t("configButtonHint"),"aria-label":e.t("configButton"),onClick:()=>e.onOpen()},Mx())}var Rx="settings.models",ft={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 Bm(e){let{ctx:t,api:n,t:r,onIdle:o,refreshed:i}=e,a=()=>{let W=t.locale.bind(Rx),ee=oe=>{let ye=[];for(let ce of oe){let ve=W(ce);ve!==ce&&ve.trim()!==""&&!ye.includes(ve)&&ye.push(ve)}return ye.length===0?oe:[...ye,...oe.filter(ce=>!ye.includes(ce))]};return{capacity:ee(ft.capacity),modelId:ee(ft.modelId),modelName:ee(ft.modelName),routeId:ee(ft.routeId),baseUrl:ee(ft.baseUrl),apiProtocol:ee(ft.apiProtocol),apply:ee(ft.apply),cancel:ee(ft.cancel),editProvider:ee(ft.editProvider),inputImage:ee(ft.inputImage),contextWindow:ee(ft.contextWindow),maxOutput:ee(ft.maxOutput),addModel:ee(ft.addModel)}},s=120,d=1e3,c=Su(),u=Np(),p={t:r,labels:a},g=Pp(),m={t:r,labels:a},f=Up(),v={t:r,labels:a,repaint:()=>fe()},h=tm(),x={labels:a,client:Ye},C={t:r,labels:a},T=dm(),H={t:r,labels:a},B=Em(),I=bm(),F={t:r,labels:a},k=If(),E={t:r},_=Ap(),S=Im(),y=op(),A=fp(),R={t:r,api:n,routeIdLabels:()=>a().routeId,staged:y,stagedKeys:A,refreshed:i},D,K,N,V,Q=W=>{for(let ee of W)for(let oe of Array.from(ee.addedNodes)){if(!(oe instanceof HTMLElement))continue;let ye=oe.matches('[class*="modelAdvanced"]')?[oe]:Array.from(oe.querySelectorAll('[class*="modelAdvanced"]'));for(let ce of ye)Ns(ce)}},ae=!1,de={api:n,describeNamespace:W=>we(n,W),t:r,labels:a,onIdle:o,onBackoff:W=>{be(W)},onPendingChanged:()=>{fe()},mount(W,ee){let oe=document.createElement("div");oe.className="bre-effort-slot",oe.dataset.plugin=Me,W.appendChild(oe);let ye=(0,qm.createRoot)(oe),ce=ve=>{ye.render((0,Ed.createElement)($e,{fallbackText:r("renderFailed"),children:i(()=>(0,Ed.createElement)(jo,ve))}))};return(0,Fm.flushSync)(()=>{ce(ee)}),{unmount:()=>{try{ye.unmount()}finally{oe.remove()}},render:ce}}},le=0;function be(W){if(ae)return;let ee=Date.now()+W;K!==void 0&&ee>=le||(K!==void 0&&window.clearTimeout(K),le=ee,K=window.setTimeout(()=>{K=void 0,le=0,fe()},W))}let Te=()=>{let W=St();wm(W,I);let ee=ct(W);if(ee===void 0){fd(W,v,f,void 0),pd(W,x,h,void 0);return}if(Op(W,p,u,ee),_p(W,m,g,ee),fd(W,v,f,ee),pd(W,x,h,ee),im(W,C,ee),lm(W,H,T,ee),Sm(W,F,B,yd(W)),e.configSeat!==void 0){let oe=Nm(W);oe!==null&&Dm(oe,{t:e.configSeat.t,onOpen:e.configSeat.onOpen},S)}Xs(),Wf(W)},ie=(W,ee)=>{try{ee()}catch(oe){console.error(`[bre] ${W} failed:`,oe)}};function fe(){ae||D!==void 0||(D=window.setTimeout(()=>{D=void 0,ie("composer mutation",()=>{V?.()}),ie("editor reconcile",()=>{Ps(St(),de,c)}),ie("add-card reconcile",()=>{ld(St(),R,_)}),ie("editor tabs reconcile",()=>{zs(St(),E,k)}),ie("dom decorations",()=>{Te()}),dp(y,n).then(W=>{W>0&&be(d)}),hp(A,n,Ye).then(W=>{W>0&&be(d)})},s))}let Re=W=>{let oe=W.detail?.route;typeof oe!="string"||oe.length===0||(Gp(f,oe),fe())},Oe=W=>{if(ae||N!==void 0)return;V=W,ie("models page startup",()=>{W(),Te()}),zu();let ee=(oe,ye)=>{W(),ye&&(ie("editor reconcile",()=>{Ps(St(),de,c)}),ld(St(),R,_),zs(St(),E,k),Te(),Tm(oe)&&Ju(St()))};N=new MutationObserver(oe=>{let ye=nf(oe);ie("models mutation",()=>{ee(oe,ye)}),ye&&(ie("early reasoning hide",()=>{Q(oe)}),fe())}),N.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden"]}),document.addEventListener(Rr,Re),fe()},Ie=()=>{ae=!0,D!==void 0&&(window.clearTimeout(D),D=void 0),K!==void 0&&(window.clearTimeout(K),K=void 0),document.removeEventListener(Rr,Re),N?.disconnect(),N=void 0};return{state:c,labels:a,start:Oe,stopObserver:Ie,teardown:()=>{if(!c.disposed){Ie(),c.disposed=!0,xm(I),qu(),Eu(c,de);for(let[W,ee]of c.mounted)Wr(W),ee.editor.unmount();c.mounted.clear(),Ip(u),Fp(),jp(),am(),cm(),mc(),_m(S),Gf(),Qf(),Cm(B),Rp(_),Ff(),pu(),Xu()}},flushOnUnload:()=>{Tu(c,de)},schedule:fe}}var Hx=1500,Nx=2,Ox=8,Ix=6e4;function Km(e,t={}){let n=t.delayMs??Hx,r=Math.max(1,t.concurrency??Nx),o=Math.max(1,t.limit??Ox),i=t.minAgeMs??Ix,s=(t.now??Date.now)(),d=jc().filter(m=>s-m.savedAt>=i).slice(0,o).map(m=>m.route),c=!1,u=0,p=()=>{for(;!c&&u<r;){let m=d.shift();if(m===void 0)return;u+=1,Promise.resolve().then(()=>e.list(m,{preferCache:!0})).catch(()=>{}).finally(()=>{u-=1,p()})}},g=setTimeout(()=>{c||p()},n);return()=>{c=!0,clearTimeout(g)}}var Wm=e=>`?route=${encodeURIComponent(e)}`;async function Gm(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 Td(e){try{let t=await fetch(`${la}${Wm(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 Gm(t)}}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}}function jm(e,t,n){let r=new AbortController,o=!1;return{done:(async()=>{let a;try{let s=await fetch(`${la}${Wm(e)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({model:t}),signal:r.signal});if(!s.ok)return{ok:!1,error:await Gm(s)};let d=s.body?.getReader();if(d===void 0)return{ok:!1,error:"the fingerprint route sent no body"};let c=new TextDecoder,u="";for(;;){let{done:g,value:m}=await d.read();if(g)break;u+=c.decode(m,{stream:!0});let f=u.indexOf(`
5405
+ `);for(;f>=0;){let v=u.slice(0,f).trim();if(u=u.slice(f+1),v.length>0){let h=Um(v);h!==void 0&&(n(h),h.type==="result"?a={ok:!0,record:h.record}:h.type==="error"&&(a={ok:!1,error:h.error}))}f=u.indexOf(`
5406
+ `)}}let p=u.trim();if(p.length>0){let g=Um(p);g!==void 0&&(n(g),g.type==="result"?a={ok:!0,record:g.record}:g.type==="error"&&(a={ok:!1,error:g.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 Um(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 Dx=3,Px=2,_x=15e3,Fx=/\b429\b|rate.?limit|too many requests/i,Sd=new Map;function qx(e){return Sd.get(e)??{run:(t,n,r)=>jm(t,n,r)}}var Cd=class{constructor(t,n=Px,r=_x){je(this,"route",t);je(this,"concurrency",n);je(this,"backoffMs",r);je(this,"listeners",new Set);je(this,"recordListeners",new Set);je(this,"failureListeners",new Set);je(this,"state",{running:new Map,queued:[]});je(this,"handles",new Set);je(this,"draining",!1);je(this,"disposed",!1);je(this,"throttled",!1);je(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(),Ki.delete(this.route),Sd.delete(this.route))}setSender(t){Sd.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=qx(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,Dx)),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{Fx.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})}}}},Ki=new Map;function zm(e,t){let n=Ki.get(e);return n===void 0&&(n=new Cd(e,t?.concurrency,t?.backoffMs),Ki.set(e,n)),n}function $m(){for(let e of[...Ki.values()])e.dispose()}function so(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 Vm(e){let t,n=new Map,r=(a,s)=>{for(let[d,c]of n){if(d===s)continue;let u;try{u=a.directoryFor(c.sessionId)===d}catch{u=!1}u||(c.restore(),n.delete(d))}};return{ensure:()=>{let a=e.ctx,s=a.get?.("sessions"),d=a.get?.("uiSession"),c=a.get?.("modelDirectories"),u=so(s,d);if(!(u===void 0||c===void 0))try{let p=c.directoryFor(u);return r(c,p),t!==void 0&&t.sessionId===u&&t.directory===p||(n.has(p)||n.set(p,{sessionId:u,restore:_l(p,{configuredEffort:e.configuredEffort})}),t={sessionId:u,directory:p}),p}catch{t=void 0;return}},dispose:()=>{for(let[,a]of n)a.restore();n.clear()}}}var Ui=Object.freeze(["EMPTY_RESPONSE","RATE_LIMIT","SERVER","TIMEOUT","TRANSPORT"]),Wi=Object.freeze(["PI_AI_ERROR","INVALID_REQUEST","AUTH","LEGACY_CLI_OUTCOME_UNKNOWN","UNSUPPORTED_REASONING_EFFORT","MALFORMED_RESPONSE","UNKNOWN_MODEL","MODEL_SWITCH_COMPACTION_FAILED","CLI_TIMEOUT","QUOTA"]),yr=Object.freeze([...Ui,...Wi]);function Bx(){let e={};for(let t of Ui)e[t]=!0;for(let t of Wi)e[t]=!1;return e}var lo=24,Ad=64,Kx=/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,63}$/,Ux=new Set([...Object.getOwnPropertyNames(Object.prototype),"__proto__"]);function Md(e){if(typeof e!="string")return;let t=e.trim();if(!(t.length===0||t.length>Ad)&&!(!Kx.test(t)||Ux.has(t))&&!yr.includes(t))return t}var an=Object.freeze({maxTokens:!0,httpStatus:!0,customCodes:Object.freeze([]),codes:Object.freeze(Bx())});function Ym(e){let t=e!==null&&typeof e=="object"?e:{},n=t.codes!==null&&typeof t.codes=="object"?t.codes:{},r=Array.isArray(t.customCodes)?t.customCodes:[],o=[];for(let a of r){let s=Md(a);s!==void 0&&!o.includes(s)&&o.length<lo&&o.push(s)}let i=Object.create(null);for(let a of yr){let s=Object.getOwnPropertyDescriptor(n,a)?.value;i[a]=typeof s=="boolean"?s:an.codes[a]===!0}for(let a of o){let s=Object.getOwnPropertyDescriptor(n,a)?.value;i[a]=typeof s=="boolean"?s:!1}return Object.freeze({maxTokens:typeof t.maxTokens=="boolean"?t.maxTokens:an.maxTokens,httpStatus:typeof t.httpStatus=="boolean"?t.httpStatus:an.httpStatus,customCodes:Object.freeze(o),codes:Object.freeze(i)})}function Wx(e,t){if(!yr.includes(e)&&!(t.customCodes??[]).includes(e))return;let n=Object.getOwnPropertyDescriptor(t.codes,e)?.value;return typeof n=="boolean"?n:void 0}function Gx(e){return e===408||e===425||e===429||e>=500&&e<=599}var jx=new Set(["user/message","developer/message","system/message","request/header","request/context","step/start","assistant/message","assistant/attempt","tool/call","tool/result"]);function zx(e){let t=!1;for(let n of e.turnEvents)if(n.type!=="turn/end"){if(n.type==="turn/start"){t=!0;continue}if(jx.has(n.type))return!0}return t?!1:"unknown"}function $x(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 Vx(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 Yx(e){let t=e?.providerRetryAfterMs;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0}function co(e,t=an){let n=$x(e.turnEnd);if(zx(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=Vx(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=Wx(o,t);if(a===!0){let s=Yx(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&&Gx(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 $i="dsh-model-think-level.auto-continue.enabled",Vi="dsh-model-think-level.auto-continue.config",Yi=1,Xi=3600,Ji=1,Qi=100,Ld=1,Rd=1440,Hd=1,Nd=1e3,vr=Object.freeze({waitSeconds:2,maxRetries:5,backoff:!0,maxChainMinutes:30,maxRequests:36,policy:an}),Xx="dsh-model-think-level.auto-continue.claim.",Jx=10*6e4;function Xm(e){try{return window.localStorage.getItem(e)}catch{return null}}function Gi(e,t,n,r){return typeof e!="number"||!Number.isFinite(e)?t:Math.min(r,Math.max(n,Math.trunc(e)))}function Od(e){let t=e!==null&&typeof e=="object"?e:{};return Object.freeze({waitSeconds:Gi(t.waitSeconds,vr.waitSeconds,Yi,Xi),maxRetries:Gi(t.maxRetries,vr.maxRetries,Ji,Qi),backoff:typeof t.backoff=="boolean"?t.backoff:vr.backoff,maxChainMinutes:Gi(t.maxChainMinutes,vr.maxChainMinutes,Ld,Rd),maxRequests:Gi(t.maxRequests,vr.maxRequests,Hd,Nd),policy:Ym(t.policy)})}function Zi(e){try{return Od(e===null?void 0:JSON.parse(e))}catch{return vr}}var uo=Xm($i)==="true",wr=Zi(Xm(Vi)),ji=new Set,zi=new Set;function ea(e){for(let t of[...e])t()}function Xe(){return uo}function Je(){return wr}function Jm(e){if(uo!==e){uo=e;try{window.localStorage.setItem($i,String(e))}catch{}ea(ji)}}function Qm(e,t){return JSON.stringify(e)===JSON.stringify(t)}function At(e){let t=Od({...wr,...e});if(!Qm(wr,t)){wr=t;try{window.localStorage.setItem(Vi,JSON.stringify(t))}catch{}ea(zi)}}function Id(e){uo!==e&&(uo=e,ea(ji))}function Dd(e){let t=Od(e);Qm(wr,t)||(wr=t,ea(zi))}function ta(e){return ji.add(e),()=>{ji.delete(e)}}function na(e){return zi.add(e),()=>{zi.delete(e)}}function Zm(e,t){let n=`${Xx}${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<Jx)return!1}return window.localStorage.setItem(n,JSON.stringify(Date.now())),!0}catch{return!0}}var eg="dsh-model-think-level.auto-continue.ledger.";function ra(e){return`${eg}${encodeURIComponent(e)}`}function Ft(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function tg(e,t){if(e===null||typeof e!="object")return;let n=e;if(n.version!==1)return;let r=Ft(n.savedAt,0);if(r<=0||t-r<0||t-r>864e5)return;let o=typeof n.lastAutoSentText=="string"?n.lastAutoSentText.slice(0,256):void 0;return{version:1,savedAt:r,seq:Math.max(0,Math.trunc(Ft(n.seq,0))),lastUserSeq:Math.max(0,Math.trunc(Ft(n.lastUserSeq,0))),lastHandledTurnEndSeq:Math.max(0,Math.trunc(Ft(n.lastHandledTurnEndSeq,0))),consecutive:Math.max(0,Math.trunc(Ft(n.consecutive,0))),requests:Math.max(0,Math.trunc(Ft(n.requests,0))),...Ft(n.startedAt,0)>0?{startedAt:Ft(n.startedAt,0)}:{},transientFailures:Math.max(0,Math.trunc(Ft(n.transientFailures,0))),reserved:n.reserved===!0,hasInitial:n.hasInitial===!0,hasStep:n.hasStep===!0,lastAutoSentAt:Math.max(0,Ft(n.lastAutoSentAt,0)),...o===void 0?{}:{lastAutoSentText:o},muted:n.muted===!0}}function ng(e,t=Date.now()){try{let n=window.localStorage.getItem(ra(e));if(n===null)return;let r=tg(JSON.parse(n),t);return r===void 0&&window.localStorage.removeItem(ra(e)),r}catch{return}}function rg(e,t,n=Date.now()){try{let r={...t,version:1,savedAt:n,lastAutoSentText:t.lastAutoSentText?.slice(0,256)};window.localStorage.setItem(ra(e),JSON.stringify(r));let o=[];for(let i=0;i<window.localStorage.length;i+=1){let a=window.localStorage.key(i);if(a===null||!a.startsWith(eg))continue;let s;try{s=tg(JSON.parse(window.localStorage.getItem(a)??"null"),n)}catch{}s===void 0?o.push({key:a,savedAt:0}):o.push({key:a,savedAt:s.savedAt})}o.sort((i,a)=>a.savedAt-i.savedAt);for(let i=0;i<o.length;i+=1){let a=o[i];(a.savedAt===0||i>=128)&&window.localStorage.removeItem(a.key)}return!0}catch{return!1}}function og(e){try{return window.localStorage.removeItem(ra(e)),!0}catch{return!1}}function Mn(e=0){return{seq:e,requests:0,startedAt:void 0,transientFailures:0,hasInitial:!1,hasStep:!1,reserved:!1}}function ig(e,t,n){t.seq<=e.seq||(e.seq=t.seq,t.type==="turn/start"?(e.reserved||(e.requests+=1),e.reserved=!1,e.hasInitial=!0,e.hasStep=!1):t.type==="step/start"?((e.hasStep||!e.hasInitial)&&(e.requests+=1),e.startedAt===void 0&&(e.requests=1),e.hasStep&&(e.transientFailures=0),e.hasInitial=!0,e.hasStep=!0):(t.type==="llm/retry"||t.type==="llm/retry-started"||t.type==="turn/end")&&(e.hasInitial||(e.requests+=1,e.hasInitial=!0),t.type==="llm/retry-started"&&(e.requests+=1),t.type!=="turn/end"?e.startedAt??(e.startedAt=typeof t.time=="number"&&Number.isFinite(t.time)?t.time:n):(e.hasInitial=!1,e.reserved=!1)))}function fo(e,t,n,r){if(n>=t.maxRetries)return"attempts";if(e.requests>=(t.maxRequests??36))return"requests";if(e.startedAt!==void 0&&r-e.startedAt>=(t.maxChainMinutes??30)*6e4)return"duration"}function ag(e,t,n,r,o){let i=Math.max(e,12e4),a=Number.isFinite(r)?Math.max(0,r):0,d=(n?Math.min(i,e*2**Math.min(30,Math.max(0,t-1))):e)*(t>1&&n?.9+Math.max(0,Math.min(1,o))*.2:1);return Math.max(e,a,Math.min(i,d))}function sg(e,t){if(!t)return;let n,r=!1,o,i,a=!1;for(let c of e){let u=c.data;if((c.type==="turn/start"||c.type==="turn/end"||c.type==="step/start")&&(n=void 0,r=!1,o=u?.step),c.type==="turn/start"&&(i=u?.turn,a=!1),c.type==="turn/end"&&(i=u?.turn,a=!0),c.type==="llm/retry"){if(a||i!==void 0&&u?.turn!==i||o!==void 0&&u?.step!==o)continue;n=c,r=!1}if(c.type==="llm/retry-started"&&n!==void 0){let p=n.data;u?.retryId===p.retryId&&u?.retry===p.retry&&(r=!0)}c.type==="assistant/message"&&(n=void 0)}if(n===void 0)return;let s=n.data;if(typeof s?.retry!="number"||!Number.isFinite(s.retry))return;let d=!r&&typeof s.delayMs=="number"&&Number.isFinite(s.delayMs)?Math.max(0,s.delayMs):0;return{retry:s.retry,waitMs:d,nextSendAt:d>0&&typeof n.time=="number"?n.time+d:0}}var Qx=1e3,Zx=500,ek=600,dg=6e3,tk=3e4,nk=1440*60*1e3,rk="dshModelThinkLevelAutoContinue";function lg(e){let{ctx:t,t:n}=e,r,o=new Map,i=!1,a=new Set,s=new Set,d=new Set,c,u=()=>{let l=r,b=Je();return l===void 0?{sessionId:void 0,phase:"idle",consecutive:0,maxRetries:b.maxRetries,nextSendAt:0,waitMs:b.waitSeconds*1e3,detail:"",muted:!1}:{sessionId:l.sessionId,phase:l.phase,consecutive:l.consecutive,maxRetries:b.maxRetries,nextSendAt:l.nextSendAt,waitMs:l.waitMs,detail:l.detail,muted:s.has(l.sessionId),requestCount:l.budget.requests,...l.providerRetry===void 0?{}:{providerRetry:l.providerRetry},...l.exhaustedReason===void 0?{}:{exhaustedReason:l.exhaustedReason}}},p=(l,b)=>l.sessionId===b.sessionId&&l.phase===b.phase&&l.consecutive===b.consecutive&&l.maxRetries===b.maxRetries&&l.nextSendAt===b.nextSendAt&&l.waitMs===b.waitMs&&l.detail===b.detail&&l.muted===b.muted&&l.providerRetry===b.providerRetry&&l.requestCount===b.requestCount&&l.exhaustedReason===b.exhaustedReason,g=()=>{let l=u();if(!(c!==void 0&&p(c,l))){c=l;for(let b of[...d])b()}},m=()=>(c??(c=u()),c),f=l=>{l.sendTimer!==void 0&&(clearTimeout(l.sendTimer),a.delete(l.sendTimer),l.sendTimer=void 0),l.pendingSendTurnEndSeq=void 0,l.pendingSendScheduledAt=0,l.pendingRetryAfterMs=void 0,l.pendingSkipLocal=!1},v=l=>{f(l),l.sendEpoch+=1,l.phase="idle",l.nextSendAt=0,l.waitMs=0,l.detail="",l.providerRetry=void 0,l.exhaustedReason=void 0,g()},h=(l,b)=>{let L=setTimeout(()=>{a.delete(L),l()},b);a.add(L)},x=new Map,C=l=>{x.delete(l.sessionId),og(l.sessionId)},T=l=>{let b=l.budget;if(b.requests<=0&&l.consecutive<=0&&!s.has(l.sessionId)){C(l);return}let L={seq:b.seq,lastUserSeq:l.lastUserSeq,lastHandledTurnEndSeq:l.lastHandledTurnEndSeq,consecutive:l.consecutive,requests:b.requests,...b.startedAt===void 0?{}:{startedAt:b.startedAt},transientFailures:b.transientFailures,reserved:b.reserved,hasInitial:b.hasInitial,hasStep:b.hasStep,lastAutoSentAt:l.lastAutoSentAt,...l.lastAutoSentText===void 0?{}:{lastAutoSentText:l.lastAutoSentText},muted:s.has(l.sessionId)};x.set(l.sessionId,{...L,version:1,savedAt:Date.now(),...l.pendingSendTurnEndSeq===void 0?{}:{pendingWait:{turnEndSeq:l.pendingSendTurnEndSeq,scheduledAt:l.pendingSendScheduledAt,retryAfterMs:l.pendingRetryAfterMs,transient:l.pendingTransient,skipLocal:l.pendingSkipLocal,jitter:l.jitter,detail:l.detail}}}),x.size>128&&x.delete(x.keys().next().value),rg(l.sessionId,L)},H=l=>l===void 0?Mn():{seq:l.seq,requests:l.requests,startedAt:l.startedAt,transientFailures:l.transientFailures,hasInitial:l.hasInitial,hasStep:l.hasStep,reserved:l.reserved},B=l=>{let b=[];try{b=l.getSnapshot().entries??[]}catch{return[]}let L=[];for(let P of b)P.type!=="event"||P.event===void 0||L.push(P.event);return L},I=l=>B(l.eventSource),F=l=>{if(l.type!=="user/message")return!1;let b=l.data;if(typeof b!="object"||b===null)return!0;let L=b.message??b;if(typeof L!="object"||L===null)return!0;let P=L.source;if(typeof P!="object"||P===null)return!0;let j=P.kind;return j!=="model-selection"&&j!=="time-context"},k=l=>{let b=I(l),L=l.lastUserSeq;for(let P of b){if(P.type!=="user/message"||P.seq<=L||(l.lastUserSeq=Math.max(l.lastUserSeq,P.seq),!F(P)))continue;let j=E(l,P);if(l.lastAutoSentText=void 0,j){T(l);continue}s.delete(l.sessionId),l.consecutive=0,l.budget=Mn(P.seq),C(l),D(l),v(l)}},E=(l,b)=>{if(l.lastAutoSentText===void 0)return!1;let L=b.data;if(typeof L!="object"||L===null)return!1;let P=L.content??L.message?.content;if(!Array.isArray(P)||P.map(ne=>typeof ne=="object"&&ne!==null&&ne.type==="text"?ne.text:void 0).filter(ne=>typeof ne=="string").join("")!==l.lastAutoSentText)return!1;let pe=typeof b.time=="number"?b.time:l.lastAutoSentAt;return Math.abs(pe-l.lastAutoSentAt)<=tk},_=(l,b)=>{let L=-1;for(let P=b-1;P>=0;P-=1)if(l[P].type==="turn/end"){L=P;break}return l.slice(L+1,b+1)},S=l=>{if(l.pendingSkipLocal)return Number.isFinite(l.pendingRetryAfterMs)?Math.max(0,l.pendingRetryAfterMs):0;let b=y();return ag(b.waitSeconds*1e3,l.pendingTransient?l.budget.transientFailures:0,l.pendingTransient&&b.backoff!==!1,l.pendingRetryAfterMs,l.jitter)},y=()=>Je(),A=(l,b)=>{f(l),l.sendEpoch+=1,l.exhaustedReason=b,l.providerRetry===void 0&&(l.phase="exhausted",l.nextSendAt=0,l.waitMs=0),g()},R=l=>{var pe;if(!l.historyReady)return;let b=I(l);for(let ne=0;ne<b.length;ne+=1){let re=b[ne];if(!(re.seq<=l.budget.seq)&&(ig(l.budget,re,Date.now()),F(re)&&!l.runtimeReady&&(l.budget=Mn(re.seq),l.consecutive=0),re.type==="turn/end")){let Ae=co({turnEnd:re,turnEvents:_(b,ne)},y().policy);Ae.kind==="settled"?(l.budget=Mn(re.seq),l.consecutive=0):Ae.kind==="continue"&&((pe=l.budget).startedAt??(pe.startedAt=typeof re.time=="number"&&Number.isFinite(re.time)?re.time:Date.now()),l.budget.transientFailures=Ae.reason==="transient-error"?l.budget.transientFailures+1:0)}}l.runtimeReady=!0,T(l);let L=Q(l),P=sg(b,L?.running===!0);l.providerRetry=P?.retry,P!==void 0&&Xe()&&!s.has(l.sessionId)&&!L?.subagent&&L?.open?(f(l),l.phase="provider-retrying",l.nextSendAt=P.nextSendAt,l.waitMs=P.waitMs):l.phase==="provider-retrying"&&(l.phase=l.exhaustedReason===void 0?l.consecutive>0?"sent":"idle":"exhausted",l.nextSendAt=0,l.waitMs=0);let j=fo(l.budget,y(),l.consecutive,Date.now());j!==void 0&&(j!=="attempts"||l.phase==="waiting"||l.phase==="exhausted")&&l.budget.startedAt!==void 0&&Xe()&&!s.has(l.sessionId)?A(l,j):g()},D=l=>{let b=l.sendTimer!==void 0||l.pendingSendTurnEndSeq!==void 0;f(l),b&&(l.nextSendAt=0,l.phase==="waiting"&&v(l))},K=(l,b)=>{let L=setTimeout(()=>{a.delete(L),l.sendTimer=void 0,fe(l,n("autoContinueMessage"))},b);l.sendTimer=L,l.nextSendAt=Date.now()+b,l.phase="waiting",g(),a.add(L)},N=l=>{l.sendEpoch+=1,l.sendTimer!==void 0&&(clearTimeout(l.sendTimer),a.delete(l.sendTimer));let b=S(l);l.waitMs=b;let L=Math.max(0,b-(Date.now()-l.pendingSendScheduledAt));K(l,L)},V=l=>{try{let b=l.getSnapshot();return{running:b.running===!0,open:b.openState===void 0||b.openState==="open",pending:b.pendingSubmissions?.length??0,subagent:b.subagent!=null}}catch{return}},Q=l=>{try{let b=l.reference?.binding;if(b!==void 0&&(b.session!==l.session||b.eventSource!==l.eventSource))return}catch{return}return V(l.session)},ae=l=>{if(!(!Xe()||s.has(l.sessionId))){if(l.evalTimer!==void 0){l.evalDeadline=Date.now()+dg;return}l.evalDeadline=Date.now()+dg,de(l,Zx)}},de=(l,b)=>{i||o.get(l.sessionId)!==l||(l.evalTimer=setTimeout(()=>{l.evalTimer!==void 0&&a.delete(l.evalTimer),l.evalTimer=void 0,ie(l)},b),a.add(l.evalTimer))},le=l=>{if(l.historyReady)return;let b=Q(l);if(b===void 0||!b.open||(l.historyReady=!0,l.runtimeReady))return;l.runtimeReady||(l.lastUserSeq=Math.max(l.lastUserSeq,ve(l.eventSource,"user/message")));let L=X(l.eventSource);l.lastHandledTurnEndSeq=Math.max(l.lastHandledTurnEndSeq,L??ve(l.eventSource,"turn/end"))},be=(l,b)=>{b.kind==="settled"?(l.consecutive=0,l.budget=Mn(l.budget.seq),C(l),v(l)):(D(l),l.phase!=="exhausted"&&v(l))},Te=l=>{if(!l.historyReady)return;let b=I(l),L=l.pendingSendTurnEndSeq;L!==void 0&&b.some(P=>P.seq>L&&(P.type==="turn/start"||P.type==="turn/end"))&&D(l);for(let P=b.length-1;P>=0;P-=1){let j=b[P];if(j.type!=="turn/end")continue;if(j.seq<=l.lastHandledTurnEndSeq)return;let pe=co({turnEnd:j,turnEvents:_(b,P)},Je().policy);if(pe.kind!=="continue"){l.lastHandledTurnEndSeq=j.seq,be(l,pe);return}let ne=Q(l);ne!==void 0&&!ne.running&&ae(l);return}},ie=l=>{if(i||o.get(l.sessionId)!==l||!Xe()||s.has(l.sessionId))return;let b=Q(l);if(!l.historyReady||b===void 0||!b.open||b.subagent||b.running||b.pending>0)return;let L=I(l),P=-1;for(let re=L.length-1;re>=0;re-=1){let Ae=L[re];if(Ae.type==="turn/end"&&Ae.seq>l.lastHandledTurnEndSeq){P=re;break}}if(P<0){Date.now()<l.evalDeadline&&de(l,ek);return}let j=L[P];if(l.lastHandledTurnEndSeq=j.seq,k(l),L.some(re=>re.seq>j.seq&&(F(re)||re.type==="turn/start")))return;let pe=co({turnEnd:j,turnEvents:_(L,P)},Je().policy);if(pe.kind!=="continue"){be(l,pe);return}R(l);let ne=fo(l.budget,y(),l.consecutive,Date.now());if(ne!==void 0){l.detail=pe.detail,A(l,ne);return}Zm(l.sessionId,j.seq)&&(l.pendingSendTurnEndSeq=j.seq,l.pendingSendScheduledAt=Date.now(),l.pendingRetryAfterMs=pe.waitMs,l.pendingTransient=pe.reason==="transient-error",l.jitter=Math.random(),l.detail=pe.detail,N(l))},fe=async(l,b)=>{if(i||o.get(l.sessionId)!==l)return;k(l),R(l);let L=l.pendingSendTurnEndSeq;l.pendingSendTurnEndSeq=void 0;let P=()=>{l.phase==="waiting"&&v(l)};if(L===void 0||L!==l.lastHandledTurnEndSeq){P();return}if(!Xe()||s.has(l.sessionId)||l.consecutive>=Je().maxRetries){P();return}let j=Q(l);if(j===void 0||!j.open||j.subagent||j.running||j.pending>0){P();return}if(I(l).some(Se=>Se.seq>L&&(F(Se)||Se.type==="turn/start"||Se.type==="turn/end"))){P();return}let ne=fo(l.budget,y(),l.consecutive,Date.now());if(ne!==void 0){A(l,ne);return}f(l),l.budget.requests+=1,l.budget.reserved=!0,l.budget.hasInitial=!0,l.budget.hasStep=!1;let re=++l.sendEpoch;l.lastAutoSentAt=Date.now(),l.lastAutoSentText=b,l.consecutive+=1,l.phase="sent",l.nextSendAt=0,T(l),g();let Ae=()=>!i&&o.get(l.sessionId)===l&&l.sendEpoch===re;if(Ae())try{let Se=await l.session.prompt([{type:"text",text:b}],"queue");if(!Ae())return;Se?.ok!==!0&&(l.lastAutoSentText=void 0,l.phase=l.consecutive>=Je().maxRetries?"exhausted":"idle",l.exhaustedReason=l.phase==="exhausted"?"attempts":void 0,g(),console.warn(`[dsh-model-think-level] auto-continue: prompt refused ${Re(Se)}`))}catch(Se){if(!Ae())return;l.lastAutoSentText=void 0,l.phase=l.consecutive>=Je().maxRetries?"exhausted":"idle",l.exhaustedReason=l.phase==="exhausted"?"attempts":void 0,g(),console.warn("[dsh-model-think-level] auto-continue: prompt failed:",Se)}},Re=l=>{let b=l?.error;if(b===void 0)return"without an error";let L=typeof b.code=="string"?b.code:"unknown",P=typeof b.message=="string"?b.message:"";return P.length>0?`${L}: ${P}`:L},Oe=l=>{let b=Q(l);b!==void 0&&(le(l),R(l),(!b.open&&l.historyReady||b.subagent||b.running||b.pending>0)&&D(l),b.pending>0&&(l.lastHandledTurnEndSeq=Math.max(l.lastHandledTurnEndSeq,ve(l.eventSource,"turn/end")),l.evalTimer!==void 0&&(clearTimeout(l.evalTimer),a.delete(l.evalTimer),l.evalTimer=void 0),l.evalDeadline=0),l.wasRunning&&!b.running&&ae(l),l.wasRunning=b.running)},Ie=l=>{let b=[];for(let L of B(l))L.type==="turn/end"&&b.push(L.seq);return b.length<2?0:(b.sort((L,P)=>L-P),b[b.length-2])},X=l=>{let b=B(l),L=-1;for(let ne=b.length-1;ne>=0;ne-=1)if(b[ne].type==="turn/end"){L=ne;break}if(L<0)return;let P=b[L],j=typeof P.time=="number"?P.time:Date.now();if(Date.now()-j>nk)return;let pe=b.slice(0,L).filter(F).at(-1);if(pe!==void 0){let ne=pe.data,re=ne?.content??ne?.message?.content;if(Array.isArray(re)&&re.map(Se=>typeof Se=="object"&&Se!==null&&Se.type==="text"?Se.text:"").join("")===n("autoContinueMessage")&&b.some(Se=>Se.type==="turn/end"&&Se.seq<pe.seq))return}if(!b.some(ne=>ne.seq>P.seq&&(F(ne)||ne.type==="turn/start")))return co({turnEnd:P,turnEvents:_(b,L)},Je().policy).kind==="continue"?Ie(l):void 0},me=l=>{if(i||o.get(l.sessionId)!==l||l.evalTimer!==void 0||!Xe()||s.has(l.sessionId)||!l.historyReady)return;let b=Q(l);if(b===void 0||!b.open||b.subagent||b.running||b.pending>0)return;let L=I(l);if(l.pendingSendTurnEndSeq!==void 0&&l.sendTimer===void 0){let P=l.pendingSendTurnEndSeq;if(L.some(j=>j.seq>P&&(F(j)||j.type==="turn/start"||j.type==="turn/end")))D(l);else if(L.some(j=>j.type==="turn/end"&&j.seq===P)){let j=fo(l.budget,y(),l.consecutive,Date.now());j!==void 0?A(l,j):N(l);return}}for(let P=L.length-1;P>=0;P-=1){let j=L[P];if(j.type==="turn/end"&&j.seq>l.lastHandledTurnEndSeq){ae(l);return}}},W=l=>{T(l);for(let L of l.unsubs)try{L()}catch{}l.evalTimer!==void 0&&(clearTimeout(l.evalTimer),a.delete(l.evalTimer),l.evalTimer=void 0),l.sendTimer!==void 0&&(clearTimeout(l.sendTimer),a.delete(l.sendTimer),l.sendTimer=void 0),o.delete(l.sessionId);let b=l.reference;l.reference=void 0;try{b?.release()}catch{}r===l&&(r=void 0),g()},ee=()=>{for(let l of[...o.values()])W(l);r=void 0,g()},oe=(l,b)=>{b.ready.then(()=>{i||o.get(l.sessionId)!==l||l.reference!==b||(le(l),me(l))},()=>{o.get(l.sessionId)===l&&l.reference===b&&W(l)})},ye=(l,b)=>{let L=o.get(b),P,j;try{if(P=l.binding?.(b),L!==void 0&&P?.session===L.session&&P.eventSource===L.eventSource&&(!Xe()||L.reference!==void 0||typeof l.retain!="function"))return L;if(P!==void 0&&V(P.session)?.subagent){L!==void 0&&W(L);return}Xe()&&typeof l.retain=="function"&&(j=l.retain(b,{source:rk}),j.ready.catch(()=>{}),P=j.binding)}catch{try{j?.release()}catch{}L!==void 0&&W(L);return}if(P===void 0){L!==void 0&&W(L);return}if(L!==void 0){if(L.session===P.session&&L.eventSource===P.eventSource)return L.reference=j,j!==void 0&&oe(L,j),L;W(L)}let pe=V(P.session);if(pe===void 0||pe.subagent){try{j?.release()}catch{}return}let ne=pe.open?X(P.eventSource):void 0,re=x.get(P.sessionId),Ae=re??ng(P.sessionId),Se=Xe()&&!Ae?.muted&&re?.pendingWait?.turnEndSeq===Ae?.lastHandledTurnEndSeq?re?.pendingWait:void 0,zt=Ae!==void 0,He={budget:H(Ae),runtimeReady:zt,providerRetry:void 0,exhaustedReason:void 0,pendingTransient:Se?.transient??!1,pendingSkipLocal:Se?.skipLocal??!1,jitter:Se?.jitter??.5,reference:j,sessionId:P.sessionId,session:P.session,eventSource:P.eventSource,wasRunning:ce(P.session),lastUserSeq:Ae?.lastUserSeq??ve(P.eventSource,"user/message"),historyReady:pe.open,lastHandledTurnEndSeq:Ae?.lastHandledTurnEndSeq??(pe.open?ne??ve(P.eventSource,"turn/end"):0),consecutive:Ae?.consecutive??0,phase:Se===void 0?"idle":"waiting",sendEpoch:0,nextSendAt:0,waitMs:0,detail:Se?.detail??"",pendingSendTurnEndSeq:Se?.turnEndSeq,pendingSendScheduledAt:Se?.scheduledAt??0,pendingRetryAfterMs:Se?.retryAfterMs,lastAutoSentAt:Ae?.lastAutoSentAt??0,lastAutoSentText:Ae?.lastAutoSentText,unsubs:[],evalDeadline:0,evalTimer:void 0,sendTimer:void 0};o.set(He.sessionId,He),Ae?.muted&&s.add(He.sessionId);try{He.unsubs.push(P.session.subscribe(()=>Oe(He)))}catch{W(He);return}try{He.unsubs.push(P.eventSource.subscribe(()=>{le(He),k(He),R(He),Te(He)}))}catch(dn){W(He),console.warn("[dsh-model-think-level] auto-continue: event source unusable:",dn);return}return j!==void 0&&oe(He,j),He},ce=l=>{try{return l.getSnapshot().running===!0}catch{return!1}},ve=(l,b)=>{let L=0,P=[];try{P=l.getSnapshot().entries??[]}catch{return 0}for(let j of P)j.type!=="event"||j.event===void 0||j.event.type===b&&j.event.seq>L&&(L=j.event.seq);return L},_e=()=>{if(i)return;let l=t.get?.("sessions"),b=t.get?.("uiSession"),L=so(l,b);if(l===void 0){ee();return}r=L===void 0?void 0:ye(l,L);let P=l.list?.getSnapshot(),j=new Set;if(Xe())for(let pe of P?.ids??Object.keys(P?.byId??{})){let ne=P?.byId?.[pe];if(ne?.running!==!0||ne.origin==="subagent")continue;let re=ne.id??pe;j.add(re),re!==L&&ye(l,re)}for(let pe of[...o.values()]){let ne=pe===r?pe:ye(l,pe.sessionId);if(ne===void 0||(Oe(ne),k(ne),me(ne),ne===r))continue;let re=Q(ne);re?.running||re?.pending||j.has(ne.sessionId)||ne.phase!=="idle"||ne.evalTimer!==void 0||ne.evalDeadline>Date.now()||W(ne)}g()},Fe=setInterval(_e,Qx);_e();let wt;try{wt=t.on?.("connection/reset",()=>{ee()})}catch{}let Qe=ta(()=>{if(Xe()){_e();return}for(let[l,b]of x)b.pendingWait!==void 0&&x.set(l,{...b,pendingWait:void 0});for(let l of[...o.values()]){if(D(l),v(l),l.evalTimer!==void 0&&(clearTimeout(l.evalTimer),a.delete(l.evalTimer),l.evalTimer=void 0),l.evalDeadline=0,l!==r){W(l);continue}let b=l.reference;l.reference=void 0;try{b?.release()}catch{}}}),O=na(()=>{for(let l of o.values())R(l),l.pendingSendTurnEndSeq!==void 0&&(!Xe()||l.consecutive>=Je().maxRetries?D(l):N(l));g()});return{status:m,subscribe:l=>(d.add(l),()=>{d.delete(l)}),stop:()=>{let l=r;l!==void 0&&(D(l),l.evalTimer!==void 0&&(clearTimeout(l.evalTimer),a.delete(l.evalTimer),l.evalTimer=void 0),l.evalDeadline=0,l.consecutive=0,s.add(l.sessionId),T(l),v(l))},reset:()=>{let l=r;if(l===void 0)return;l.consecutive=0;let b=0;for(let L of I(l))b=Math.max(b,L.seq);l.budget=Mn(b),C(l),s.delete(l.sessionId),v(l)},resumeNow:()=>{let l=r;if(l===void 0||l.pendingSendTurnEndSeq===void 0)return;l.sendTimer!==void 0&&(clearTimeout(l.sendTimer),a.delete(l.sendTimer),l.sendTimer=void 0),l.pendingSkipLocal=!0;let b=Number.isFinite(l.pendingRetryAfterMs)?Math.max(0,l.pendingRetryAfterMs):0,L=Math.max(0,b-(Date.now()-l.pendingSendScheduledAt));L>0?K(l,L):fe(l,n("autoContinueMessage"))},dispose:()=>{i=!0,Qe(),O(),wt?.(),clearInterval(Fe),ee(),d.clear(),s.clear();for(let l of a)clearTimeout(l);a.clear()}}}var ok=[[/\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 ik(e){let t=String(e??"");for(let[n,r]of ok)t=t.replace(n,r);return t}function ak(e,t,n){let r=ik(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 c=JSON.parse(i);c!==null&&typeof c=="object"&&(s=c)}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 oa=e=>`${e.sessionId}:${e.seq}`;function sk(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(ak(s.error,t,d)))}return r}var dk='[class*="turnErrorRow"]',lk='code[class*="turnErrorCode"]',Pd='[class*="turnErrorMessage"]',mo="data-bre-error-detail",ug={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 cg(e,t){return(e.querySelector(t)?.textContent??"").trim()}function ck(e){let t=e.querySelector(Pd);if(t===null)return"";let n="";for(let r of t.childNodes)r instanceof HTMLElement&&r.hasAttribute(mo)||(n+=r.textContent??"");return n.trim()}function uk(e,t,n){if(t.length===0)return;let r=cg(e,lk),o=cg(e,Pd),i=t.filter(c=>!n.has(oa(c))),a=r.length===0?i:i.filter(c=>c.code===r);if(a.length===0)return;let s=ug[r];return s!==void 0&&o===s?a[0]:a.find(c=>{if(c.http!==void 0&&o.startsWith(`${c.http}:`))return!0;let u=c.raw;return u.length===0||o.length===0?!1:u.startsWith(o.slice(0,40))||o.startsWith(u.slice(0,40))})??a[0]}var po="bre-error-detail-popover";function Be(e,t,n){let r=document.createElement(e);return t!==void 0&&(r.className=t),n!==void 0&&(r.textContent=n),r}async function fk(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 fg(e){let{ctx:t,t:n}=e,r=[],o=!1,i,a=(y,A)=>{let R=Be("button","bre-ed-copy",A);return R.type="button",R.addEventListener("click",()=>{fk(y).then(D=>{D&&(R.textContent=n("errorDetailCopied"),window.setTimeout(()=>{R.textContent=A},1400))})}),R},s=(y,A,R={})=>{if(A===void 0||A.length===0)return null;let D=Be("div","bre-ed-row");D.append(Be("span","bre-ed-label",y));let K=["bre-ed-value"];return R.mono===!0&&K.push("bre-ed-mono"),R.muted===!0&&K.push("bre-ed-muted"),D.append(Be("span",K.join(" "),A)),R.copy===!0&&D.append(a(A,n("errorDetailCopy"))),D},d=(y,A)=>{let R=ug[y];return R===void 0?`${A} \u2014 ${n("errorDetailUnwrapped")}`:A===R?`${A} \u2014 ${n("errorDetailFixedLabel")}`:R},c=()=>{let y=document.getElementById(po);if(y instanceof HTMLDivElement)return y;let A=Be("div","bre-ed-pop");return A.id=po,A.setAttribute("role","dialog"),A.setAttribute("aria-label",n("errorDetailTitle")),document.body.append(A),A},u=()=>{let y=document.getElementById(po);y!==null&&(y.style.display="none"),document.removeEventListener("pointerdown",p,!0),document.removeEventListener("keydown",g,!0),window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u,!0)};function p(y){let A=document.getElementById(po);A!==null&&(y.target instanceof Node&&A.contains(y.target)||y.target instanceof Element&&y.target.closest(`[${mo}]`)!==null||u())}function g(y){y.key==="Escape"&&u()}let m=(y,A)=>{let R=A.getBoundingClientRect();y.style.visibility="hidden",y.style.left="0px",y.style.top="0px";let D=y.offsetWidth,K=y.offsetHeight,N=8;if(R.bottom<N||R.top>window.innerHeight-N){let ae=Math.max(N,(window.innerWidth-D)/2),de=Math.max(N,(window.innerHeight-K)/2);y.style.left=`${Math.round(ae)}px`,y.style.top=`${Math.round(de)}px`,y.style.visibility="";return}let V=Math.min(Math.max(N,R.left),Math.max(N,window.innerWidth-D-N)),Q=R.bottom+N;Q+K>window.innerHeight-N&&(Q=Math.max(N,R.top-K-N)),y.style.left=`${Math.round(V)}px`,y.style.top=`${Math.round(Q)}px`,y.style.visibility=""},f=(y,A,R)=>{let D=c();D.textContent="";let K=Be("div","bre-ed-head");K.append(Be("span","bre-ed-dot")),K.append(Be("span","bre-ed-title",n("errorDetailTitle")));let N=Be("span","bre-ed-chips");y.http!==void 0&&N.append(Be("code","bre-ed-chip",`HTTP ${y.http}`)),y.providerCode!==void 0&&N.append(Be("code","bre-ed-chip bre-ed-chip-strong",y.providerCode)),K.append(N);let V=Be("button","bre-ed-x","\xD7");V.type="button",V.setAttribute("aria-label",n("errorDetailClose")),V.addEventListener("click",()=>u()),K.append(V),D.append(K);let Q=Be("div","bre-ed-body"),ae=[s(n("errorDetailReason"),y.reason),s(n("errorDetailTrace"),y.traceId,{mono:!0,copy:!0}),s(n("errorDetailCode"),y.code,{mono:!0}),s(n("errorDetailShown"),d(y.code,R),{muted:!0})];for(let ie of ae)ie!==null&&Q.append(ie);D.append(Q);let de=Be("div","bre-ed-raw"),le=Be("button","bre-ed-raw-toggle",`\u25B8 ${n("errorDetailRaw")}`);le.type="button";let be=Be("pre","bre-ed-pre",y.raw);be.hidden=!0,le.addEventListener("click",()=>{be.hidden=!be.hidden,le.textContent=`${be.hidden?"\u25B8":"\u25BE"} ${n("errorDetailRaw")}`}),de.append(le,be),D.append(de);let Te=Be("div","bre-ed-foot");Te.append(Be("span","bre-ed-src",n("errorDetailSource"))),Te.append(a(y.raw,n("errorDetailCopyRaw"))),D.append(Te),D.style.display="block",m(D,A),document.addEventListener("pointerdown",p,!0),document.addEventListener("keydown",g,!0),window.addEventListener("scroll",u,!0),window.addEventListener("resize",u,!0)},v=new Set,h=()=>{for(let y of v)if(y.isConnected)return!0;return v.clear(),!1},x=()=>{if(r.length===0&&!h())return;let y=document.querySelectorAll(dk);if(y.length===0)return;let A=new Set,R=n("errorDetailButton");for(let D of y){let K=uk(D,r,A);if(K===void 0)continue;A.add(oa(K));let N=ck(D),V=D.querySelector(Pd)??D,Q=V.querySelector(`:scope > button[${mo}]`);Q===null&&(Q=document.createElement("button"),Q.type="button",Q.className="bre-ed-view",Q.setAttribute(mo,"1"),V.append(Q),v.add(Q)),Q.textContent!==R&&(Q.textContent=R),Q.onclick=ae=>{ae.preventDefault(),ae.stopPropagation(),f(K,Q,N)}}},C=()=>{i===void 0&&(i=window.setTimeout(()=>{i=void 0,x()},120))},T,H,B=(y,A)=>{if(o)return;let R=sk(A,y);R.length===r.length&&R.every((K,N)=>oa(K)===oa(r[N]))||(r=R,C())},I=()=>{H?.(),H=void 0},F=y=>{let A=t.get?.("sessions"),R;try{R=A?.binding?.(y)}catch{R=void 0}let D=R?.eventSource;if(D!==void 0)try{B(y,D),H=D.subscribe(()=>{try{B(y,D)}catch{}})}catch{H=void 0}},k=()=>{if(o)return;let y=t.get?.("sessions"),A=t.get?.("uiSession"),R=so(y,A);R===T&&H!==void 0||(R!==T&&(I(),T=R,r=[],u(),C()),R!==void 0&&F(R))},E=window.setInterval(k,1e3);k();let _=new MutationObserver(C);_.observe(document.body,{childList:!0,subtree:!0});let S=window.setInterval(x,1500);return x(),{dispose:()=>{o=!0,window.clearInterval(E),window.clearInterval(S),i!==void 0&&window.clearTimeout(i),i=void 0,_.disconnect(),I(),T=void 0,r=[],u();for(let y of document.querySelectorAll(`[${mo}]`))y.remove();v.clear(),document.getElementById(po)?.remove()}}}var ia="dsh-model-think-level.error-detail.enabled";function pk(e){try{return window.localStorage.getItem(e)}catch{return null}}var go=pk(ia)!=="false",_d=new Set;function pg(){for(let e of[..._d])e()}function aa(){return go}function mg(e){if(go!==e){go=e;try{window.localStorage.setItem(ia,String(e))}catch{}pg()}}function Fd(e){go!==e&&(go=e,pg())}function sa(e){return _d.add(e),()=>{_d.delete(e)}}var rt=require("react");var J=require("react/jsx-runtime"),bg="[data-composer-dock]",mk="[data-composer-stats]",gk="[data-composer-stat]",hk="data-bre-autocontinue",gg=2*Math.PI*6;function bk(){let t=Array.from(document.querySelectorAll(bg)).filter(a=>a.isConnected&&a.getClientRects().length>0).at(-1);if(t!==void 0)return t;let n=document.querySelector(mk);if(n!==null&&n.isConnected&&n.getClientRects().length>0)return n;let r=Array.from(document.querySelectorAll(gk)).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 yk(e,t){return e!==void 0&&e.isConnected&&t.length===1&&e.parentElement===t[0]}function ho(e){return(0,J.jsx)("svg",{className:e.className,viewBox:"0 0 24 24","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:e.children})}function hg(e){let t=gg*(1-Math.max(0,Math.min(1,e.ratio)));return(0,J.jsx)("span",{className:"bre-ac-ring","aria-hidden":"true",children:(0,J.jsxs)("svg",{viewBox:"0 0 16 16",children:[(0,J.jsx)("circle",{className:"bre-ac-ring-track",cx:"8",cy:"8",r:"6"}),(0,J.jsx)("circle",{className:"bre-ac-ring-fill",cx:"8",cy:"8",r:"6",strokeDasharray:gg,strokeDashoffset:t})]})})}function vk(e){let{runner:t,t:n}=e,r=(0,rt.useSyncExternalStore)(t.subscribe,t.status),[o,i]=(0,rt.useState)(!1),[a,s]=(0,rt.useState)(()=>Date.now()),d=(0,rt.useRef)(null),c=(0,rt.useRef)(null),u=(0,rt.useId)();if((0,rt.useEffect)(()=>{if(!o)return;c.current?.querySelector("button")?.focus();let _=y=>{y.key==="Escape"&&(y.preventDefault(),y.stopPropagation(),i(!1),d.current?.focus())},S=y=>{y.target instanceof Node&&!c.current?.contains(y.target)&&!d.current?.contains(y.target)&&i(!1)};return document.addEventListener("keydown",_),document.addEventListener("pointerdown",S),()=>{document.removeEventListener("keydown",_),document.removeEventListener("pointerdown",S)}},[o]),(0,rt.useEffect)(()=>{if(r.phase!=="waiting"&&r.phase!=="provider-retrying")return;s(Date.now());let _=window.setInterval(()=>s(Date.now()),500);return()=>window.clearInterval(_)},[r.phase,r.nextSendAt]),(0,rt.useEffect)(()=>{r.phase==="idle"&&i(!1)},[r.phase]),r.sessionId===void 0||r.phase==="idle")return null;let p=r.maxRetries,g=r.phase==="provider-retrying",m=r.phase==="waiting"?r.consecutive+1:r.consecutive,f=Math.max(0,r.nextSendAt-a),v=Math.ceil(f/1e3),h=Math.max(1e3,r.waitMs),x=r.phase==="waiting"||g?Math.min(1,f/h):0,C=r.exhaustedReason==="requests"?n("autoContinueControllerExhaustedRequests"):r.exhaustedReason==="duration"?n("autoContinueControllerExhaustedDuration"):void 0,T=g?n("autoContinueControllerProviderRetryDesc"):C??(r.detail===""?void 0:n("autoContinueControllerDetail",{detail:r.detail})),H=(_,S)=>(0,J.jsx)("button",{type:"button",className:"bre-ac-action",onClick:()=>{i(!1),S()},children:_},_),B=[];r.phase==="waiting"?(B.push(H(n("autoContinueControllerResume"),()=>t.resumeNow())),B.push(H(n("autoContinueControllerStop"),()=>t.stop()))):r.phase==="sent"&&B.push(H(n("autoContinueControllerStop"),()=>t.stop()));let I=g?(0,J.jsxs)(J.Fragment,{children:[f>0?(0,J.jsx)(hg,{ratio:x}):(0,J.jsx)(ho,{className:"bre-ac-tick",children:(0,J.jsx)("path",{d:"M4 12a8 8 0 1 0 2-5.3M4 4v5h5"})}),(0,J.jsx)("span",{className:"bre-ac-text",children:n("autoContinueControllerProviderRetry")}),f>0&&(0,J.jsx)("span",{className:"bre-ac-num",children:n("autoContinueControllerSeconds",{seconds:v})}),(0,J.jsx)("span",{className:"bre-ac-ratio",children:n("autoContinueControllerProviderAttempt",{n:r.providerRetry??1})})]}):r.phase==="waiting"?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(hg,{ratio:x}),(0,J.jsx)("span",{className:"bre-ac-text",children:n("autoContinueControllerWaiting")}),(0,J.jsx)("span",{className:"bre-ac-num",children:n("autoContinueControllerSeconds",{seconds:v})}),(0,J.jsx)("span",{className:"bre-ac-ratio",children:n("autoContinueControllerRatio",{n:m,max:p})}),(0,J.jsx)(ho,{className:"bre-ac-caret",children:(0,J.jsx)("path",{d:"M6.5 9.5 12 15l5.5-5.5"})})]}):r.phase==="sent"?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ho,{className:"bre-ac-tick",children:(0,J.jsx)("path",{d:"M4.8 12.5 9.6 17.3 19.2 6.9"})}),(0,J.jsx)("span",{className:"bre-ac-text",children:n("autoContinueControllerSent")}),(0,J.jsx)("span",{className:"bre-ac-ratio",children:n("autoContinueControllerRatio",{n:m,max:p})})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(ho,{className:"bre-ac-tick",children:[(0,J.jsx)("circle",{cx:"12",cy:"12",r:"8.2"}),(0,J.jsx)("path",{d:"M12 7.6V12l3 1.9"})]}),(0,J.jsx)("span",{className:"bre-ac-text",children:C??n("autoContinueControllerExhausted")}),(0,J.jsx)("span",{className:"bre-ac-ratio",children:n("autoContinueControllerRatio",{n:m,max:p})})]}),F=g?n("autoContinueControllerProviderRetryDesc"):C??(r.phase==="sent"?n("autoContinueControllerSentDesc"):r.phase==="exhausted"?n("autoContinueControllerExhausted"):n("autoContinueControllerPopDesc",{seconds:v,max:p})),k=[n("autoContinueControllerAria"),g?n("autoContinueControllerProviderRetry"):r.phase==="waiting"?n("autoContinueControllerWaiting"):r.phase==="sent"?n("autoContinueControllerSent"):C??n("autoContinueControllerExhausted"),(g||r.phase==="waiting")&&f>0?n("autoContinueControllerSeconds",{seconds:v}):"",g?n("autoContinueControllerProviderAttempt",{n:r.providerRetry??1}):n("autoContinueControllerRatio",{n:m,max:p})].filter(Boolean).join(" \xB7 "),E=o?(0,J.jsxs)("div",{className:"bre-ac-pop",role:"dialog","aria-modal":"false","aria-label":n(g?"autoContinueControllerProviderRetry":"autoContinueControllerPopTitle"),id:u,ref:c,children:[(0,J.jsxs)("div",{className:"bre-ac-pop-head",children:[(0,J.jsx)("span",{className:"bre-ac-pop-title",children:n(g?"autoContinueControllerProviderRetry":"autoContinueControllerPopTitle")}),(0,J.jsx)("span",{className:"bre-ac-pop-badge",children:g?n("autoContinueControllerProviderAttempt",{n:r.providerRetry??1}):n("autoContinueControllerPopBadge",{n:m,max:p})})]}),(0,J.jsx)("p",{className:"bre-ac-pop-desc",children:F}),(r.requestCount??0)>0&&(0,J.jsx)("p",{className:"bre-ac-pop-desc",children:n("autoContinueControllerRequestCount",{count:r.requestCount})}),g&&C&&(0,J.jsx)("p",{className:"bre-ac-pop-desc",children:C}),!g&&(0,J.jsx)("p",{className:"bre-ac-pop-desc",children:n("autoContinueControllerOfficialRetryHint")}),B.length>0?(0,J.jsx)("div",{className:"bre-ac-pop-actions",children:B}):void 0,(0,J.jsxs)("div",{className:"bre-ac-pop-foot",children:[(0,J.jsx)("button",{type:"button",className:"bre-ac-link",onClick:()=>{i(!1),e.onSettings()},children:n("autoContinueControllerSettings")}),(0,J.jsx)("span",{className:"bre-ac-note",children:n("autoContinueControllerPopScope")})]})]}):void 0;return r.phase==="exhausted"?(0,J.jsxs)("span",{className:"bre-ac",children:[(0,J.jsxs)("span",{className:"bre-ac-group",children:[(0,J.jsx)("span",{className:"bre-ac-chip bre-ac-chip-exhausted",title:T??n("autoContinueControllerAria"),children:I}),(0,J.jsx)("button",{type:"button",className:"bre-ac-reset",onClick:()=>t.reset(),children:n("autoContinueControllerReset")}),(0,J.jsx)("button",{type:"button",className:"bre-ac-more","aria-label":n("autoContinueControllerSettings"),"aria-expanded":o,"aria-controls":o?u:void 0,"aria-haspopup":"dialog",ref:d,onClick:()=>i(_=>!_),children:(0,J.jsxs)(ho,{className:"bre-ac-more-icon",children:[(0,J.jsx)("circle",{cx:"5.5",cy:"12",r:"1.4",fill:"currentColor",stroke:"none"}),(0,J.jsx)("circle",{cx:"12",cy:"12",r:"1.4",fill:"currentColor",stroke:"none"}),(0,J.jsx)("circle",{cx:"18.5",cy:"12",r:"1.4",fill:"currentColor",stroke:"none"})]})})]}),E]}):(0,J.jsxs)("span",{className:"bre-ac",children:[(0,J.jsx)("button",{type:"button",className:`bre-ac-chip bre-ac-chip-${r.phase}`,"aria-label":k,"aria-expanded":o,"aria-controls":o?u:void 0,"aria-haspopup":"dialog",ref:d,title:T??n("autoContinueControllerAria"),onClick:()=>i(_=>!_),children:I}),E]})}function yg(e){let t,n,r=0,o=0,i=()=>{qe(n),n=void 0,t?.remove(),t=void 0},a=()=>{if(yk(t,document.querySelectorAll(bg)))return;let u=bk();if(u===void 0){i();return}t!==void 0&&t.parentElement===u&&t.isConnected||(i(),t=document.createElement("span"),t.className="bre-ac-host",t.setAttribute(hk,""),u.append(t),n=it(t,(0,J.jsx)(vk,{runner:e.runner,t:e.t,onSettings:e.onSettings})))},s=()=>{if(r!==0)return;let u=Math.max(0,400-(Date.now()-o));r=window.setTimeout(()=>{r=0,o=Date.now(),a()},u)},d=new MutationObserver(s);d.observe(document.body,{childList:!0,subtree:!0});let c=window.setInterval(a,2e3);return a(),()=>{d.disconnect(),window.clearInterval(c),r!==0&&window.clearTimeout(r),i()}}var Mt=require("react");var Ke=require("react");var jt=require("react/jsx-runtime");function vg(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 wg({t:e,value:t,installed:n,disabled:r=!1,onChange:o}){let i=(0,Ke.useId)(),a=`${i}-title`,s=`${i}-hint`,d=e("historyCompatHint")+" "+e("historyCompatCost");return(0,jt.jsxs)("div",{className:"bre-camouflage","data-plugin":Me,"data-open":"1","data-section":"history-compat",title:d,children:[(0,jt.jsx)("span",{className:"bre-effort-title",id:a,children:e("historyCompatTitle")}),(0,jt.jsxs)("label",{className:"bre-thinking-switch bre-camouflage-toggle",children:[(0,jt.jsx)("input",{type:"checkbox",role:"switch",checked:t,disabled:r,"aria-labelledby":a,"aria-describedby":s,onChange:c=>{o(c.target.checked)}}),(0,jt.jsx)("span",{className:"bre-effort-switch-track","aria-hidden":"true"})]}),(0,jt.jsx)("span",{className:"bre-sr-only",id:s,children:d}),n?null:(0,jt.jsx)("p",{className:"bre-camouflage-warn",children:e("historyCompatUnavailable")})]})}function xg(e){let[t,n]=(0,Ke.useState)(!1),[r,o]=(0,Ke.useState)(!1),[i,a]=(0,Ke.useState)(!0),[s,d]=(0,Ke.useState)(!0),c=(0,Ke.useRef)(!1),u=(0,Ke.useRef)(!1),p=(0,Ke.useRef)(!0);(0,Ke.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]),(0,Ke.useEffect)(()=>{if(e===""){d(!1);return}let v=!1;return d(!0),fetch(fa,{method:"GET"}).then(async h=>await h.json()).then(h=>{if(v||!p.current)return;let x=vg(h);if(x===void 0)return;let C=x.providers[e]===!0;c.current=C,u.current=C,n(C),o(C),x.installed!==void 0&&a(x.installed)}).catch(()=>{}).finally(()=>{!v&&p.current&&d(!1)}),()=>{v=!0}},[e]);let g=(0,Ke.useCallback)(v=>{u.current=v,o(v)},[]),m=(0,Ke.useCallback)(()=>{u.current=c.current,o(c.current)},[]),f=(0,Ke.useCallback)(async()=>{if(e===""||u.current===c.current)return;let v=u.current,h=await fetch(fa,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({route:e,enabled:v})}),x=await h.json();if(!h.ok||x.ok!==!0)throw new Error("history-compat write rejected");let C=vg(x);c.current=v,u.current=v,n(v),o(v),C!==void 0&&C.installed!==void 0&&a(C.installed)},[e]);return{value:r,saved:t,installed:i,loading:s,setValue:g,reset:m,commit:f}}var sn=require("react/jsx-runtime");function kg({route:e,api:t,t:n,onDismiss:r}){let o=Qs(e,n),i=xg(e);return(0,sn.jsx)(Mi,{route:e,api:t,t:n,onDismiss:r,extras:(0,sn.jsxs)(sn.Fragment,{children:[(0,sn.jsx)(Js,{t:n,value:o.value,installed:o.installed,disabled:o.loading,onChange:o.setValue}),(0,sn.jsx)(wg,{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 Y=require("react");function Eg(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 wk=/^(gpt-|chatgpt-|o[134](-|$)|claude-)/;function xk(e){let t=String(e??"").trim(),n=t.lastIndexOf("/");return n===-1?t:t.slice(n+1)}function Tg(e){let t=xk(e).toLowerCase();return t.length>0&&wk.test(t)}var Sg={running:new Map,queued:[]};function yo(e){return typeof e!="number"||!Number.isFinite(e)?"\u2014":`${Math.round(e*100)}%`}function kk(e){return!Number.isFinite(e)||e<=0?"\u2014":new Date(e).toLocaleString()}function Cg(e){return typeof e!="number"||!Number.isFinite(e)||e<0?"\u2014":(Math.round(e/100)/10).toFixed(1)}function Ek(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 Ag({route:e,api:t,t:n,ctx:r,host:o}){let[i]=(0,Y.useState)(()=>Df(o.current)),[a,s]=(0,Y.useState)([]),[d,c]=(0,Y.useState)(new Map),[u,p]=(0,Y.useState)(void 0),[g,m]=(0,Y.useState)(void 0),[f,v]=(0,Y.useState)(new Set),h=(0,Y.useCallback)(y=>{v(A=>{let R=new Set(A);return R.has(y)?R.delete(y):R.add(y),R})},[]),x=(0,Y.useMemo)(()=>i?void 0:zm(e),[i,e]),C=(0,Y.useSyncExternalStore)((0,Y.useCallback)(y=>x?.subscribe(y)??(()=>{}),[x]),(0,Y.useCallback)(()=>x?.getState()??Sg,[x]),(0,Y.useCallback)(()=>Sg,[]));(0,Y.useEffect)(()=>{if(x!==void 0)return x.onRecord(y=>{m(void 0),c(A=>{let R=new Map(A);return R.set(y.model,y),R})})},[x]),(0,Y.useEffect)(()=>{if(x!==void 0)return x.onFailure((y,A)=>{m({model:y,error:A})})},[x]);let T=(0,Y.useCallback)(async()=>{if(i)return;let A=(await we(t)).namespace?.value?.providers,R=Kn(A,e).map(K=>K.id).filter(K=>typeof K=="string"&&K.length>0).filter(Tg);s(R.map(K=>({model:K})));let D=await Td(e);D.ok?(p(void 0),c(new Map(D.data.records.map(K=>[K.model,K])))):p(D.error)},[t,i,e]);if((0,Y.useEffect)(()=>{i||T()},[i,T]),(0,Y.useEffect)(()=>{if(!(i||r===void 0))return r.remote.$on("settings/document-updated",()=>{T()})},[i,r,T]),i)return null;let H=a.length,B=a.filter(y=>d.has(y.model)).length,I=a.filter(y=>d.get(y.model)?.status==="identified").length,F=a.filter(y=>d.get(y.model)?.status==="doubtful").length,k=a.filter(y=>d.get(y.model)?.status==="failed").length,E=C.running.size>0,_=C.running.size+C.queued.length,S=(0,Y.useMemo)(()=>Eg([...d.values()]),[d]);return(0,Y.createElement)("div",{className:"bre-fingerprint","data-bre-fingerprint":H>0?"ready":"none"},(0,Y.createElement)("div",{className:"bre-fp-head"},(0,Y.createElement)("span",{className:"bre-fp-title"},n("fpTitle")),(0,Y.createElement)("span",{className:"bre-fp-count"},n("fpCount",{count:H})),(0,Y.createElement)("span",{className:"bre-fp-summary",role:"status","aria-live":"polite"},E?n("fpRunning",{done:C.running.size,total:_}):B===0?n("fpSummaryNone"):n("fpSummary",{identified:I,doubtful:F,failed:k})),(0,Y.createElement)("span",{className:"grow"}),(0,Y.createElement)("button",{type:"button",className:"bre-fp-all",disabled:E||H===0,onClick:()=>{x?.checkAll(a.map(y=>y.model))}},n("fpDetectAll"))),(0,Y.createElement)("p",{className:"bre-fp-intro"},n("fpIntro")),u!==void 0?(0,Y.createElement)("p",{className:"bre-fp-error"},n("fpLoadFailed",{error:u})):null,g!==void 0?(0,Y.createElement)("p",{className:"bre-fp-error",role:"alert"},n("fpRunFailed",{error:`${g.model}: ${g.error}`})):null,(0,Y.createElement)("div",{className:"bre-fp-rows"},...a.map(y=>Sk(y,{t:n,runner:x,runnerState:C,records:d,route:e,expanded:f,estimate:S,onToggle:h}))))}function Tk(e){return(0,Y.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,Y.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 Sk(e,t){let{t:n,runner:r,runnerState:o,records:i,expanded:a,estimate:s,onToggle:d}=t,c=i.get(e.model),u=o.running.get(e.model),p=o.queued.indexOf(e.model),g=u!==void 0,m=p>=0,f=a.has(e.model),v=g?{className:"is-running",text:n("fpStateRunning",{done:u,total:3})}:m?{className:"is-queued",text:n("fpQueued",{position:p+1})}:c===void 0?{className:"is-idle",text:n("fpStateUnchecked")}:c.status==="failed"?{className:"is-failed",text:n("fpStateFailed")}:c.status==="doubtful"?{className:"is-doubtful",text:n("fpStateDoubtful",{probability:yo(c.probability)})}:{className:"is-identified",text:n("fpStateIdentified",{model:c.predictionName??c.prediction??e.model,probability:yo(c.probability)})},h=c===void 0?"fpDetect":c.status==="failed"?"fpRetry":"fpRetest";return(0,Y.createElement)("div",{className:"bre-fp-row",key:e.model,"data-bre-fp-open":f?"1":void 0},(0,Y.createElement)("div",{className:"bre-fp-row-head"},(0,Y.createElement)("button",{type:"button",className:"bre-fp-fold","aria-expanded":f,"aria-label":n(f?"fpDetailHide":"fpDetailShow")+" "+e.model,title:n(f?"fpDetailHide":"fpDetailShow"),onClick:()=>{d(e.model)}},Tk(f),(0,Y.createElement)("span",{className:"bre-fp-model"},e.model)),(0,Y.createElement)("span",{className:`bre-fp-badge ${v.className}`},v.text),(0,Y.createElement)("span",{className:"grow"}),(0,Y.createElement)("span",{className:"bre-fp-evidence"},c===void 0?Ek(n,s):n("fpEvidence",{used:c.usedOutputs,total:3})),(0,Y.createElement)("button",{type:"button",className:"bre-fp-action",disabled:g||m,onClick:()=>{r?.check(e.model)}},n(h))),!f||c===void 0?null:c.status!=="failed"?Ak(c,n):Ck(c,n))}function Mg(e,t){return e===void 0||e.length===0?null:(0,Y.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,Y.createElement)("span",{className:`bre-fp-chal${r}`,key:n.index},o)}))}function Ck(e,t){let n=e.challenges,r=n!==void 0&&n.length>0;return e.error===void 0&&!r?null:(0,Y.createElement)("div",{className:"bre-fp-body"},e.error===void 0?null:(0,Y.createElement)("p",{className:"bre-fp-error"},e.error),Mg(n,t))}function Ak(e,t){let n=e.top??[],r=e.timing;return(0,Y.createElement)("div",{className:"bre-fp-body"},(0,Y.createElement)("div",{className:"bre-fp-family"},(0,Y.createElement)("span",{className:"bre-fp-k"},t("fpFamily")),(0,Y.createElement)("span",{className:"bre-fp-v"},`${e.familyPrediction??"\u2014"} \xB7 ${yo(e.familyProbability)}`),(0,Y.createElement)("span",{className:"bre-fp-k"},t("fpSimilarity")),(0,Y.createElement)("span",{className:"bre-fp-v"},yo(e.top?.[0]?.similarity)),(0,Y.createElement)("span",{className:"grow"}),(0,Y.createElement)("span",{className:"bre-fp-k"},t("fpCheckedAt",{time:kk(e.checkedAt)}))),Mg(e.challenges,t),r!==void 0?(0,Y.createElement)("p",{className:"bre-fp-timing"},t("fpTiming",{first:Cg(r.firstTokenMs),total:Cg(r.durationMs),rate:r.charsPerSecond===void 0?"\u2014":String(Math.round(r.charsPerSecond))})):null,(0,Y.createElement)("div",{className:"bre-fp-k",style:{marginTop:"8px"}},t("fpCandidates")),(0,Y.createElement)("div",{className:"bre-fp-bars"},...n.map((o,i)=>(0,Y.createElement)("div",{className:"bre-fp-bar",key:o.model},(0,Y.createElement)("span",{className:"bre-fp-bar-name"},o.model),(0,Y.createElement)("span",{className:`bre-fp-bar-fill${i===0?" is-top":""}`,style:{width:`${Math.max(2,Math.round(o.probability*100))}%`}}),(0,Y.createElement)("span",{className:"bre-fp-bar-value"},yo(o.probability))))),(0,Y.createElement)("p",{className:"bre-fp-note"},t("fpClosedSet")))}var Lg="settings.models.provider-card";function Mk(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 Lk({provider:e,api:t,t:n,ctx:r}){let o=(0,Mt.useRef)(null),i=e?.provider,a=(0,Mt.useCallback)(()=>{Mk(dr(o.current))},[]);return(0,Mt.useLayoutEffect)(()=>{let s=o.current,d=dr(s);if(s===null||d===null)return;let c=d,u=()=>d.querySelector('[class*="_editor"]')!==null,p=()=>{let m=u()?"1":"0";s.dataset.edit!==m&&(s.dataset.edit=m)};p();let g=new MutationObserver(p);return g.observe(c,{childList:!0,subtree:!0}),()=>{g.disconnect()}},[i]),typeof i!="string"||i.length===0?null:(0,Mt.createElement)("div",{ref:o,className:"bre-headers-host","data-bre-provider":i},(0,Mt.createElement)(Li,{host:o,t:n}),(0,Mt.createElement)(kg,{route:i,api:t,t:n,onDismiss:a}),(0,Mt.createElement)(Ag,{route:i,api:t,t:n,ctx:r,host:o}))}function Rg(e,t,n){let r=e,o=r.slots?.inject(Lg,()=>{r.slots?.register({name:Lg,key:Ue,inject:()=>({api:t,t:n,ctx:e})},Lk)});return typeof o=="function"?o:()=>{}}var vt=require("react");function Hg(e){let{t}=e,n=(0,vt.useSyncExternalStore)(To,kt),r=()=>{Qd(!n)};return(0,vt.createElement)("div",{className:"bre-slider-setting"},(0,vt.createElement)("div",{className:"bre-slider-setting-row"},(0,vt.createElement)("div",{className:"bre-slider-setting-copy"},(0,vt.createElement)("div",{className:"bre-slider-setting-title"},t("sliderToggleTitle")),(0,vt.createElement)("div",{className:"bre-slider-setting-description"},t("sliderToggleDescription"))),(0,vt.createElement)("div",{className:"bre-slider-setting-control"},(0,vt.createElement)("span",{className:"bre-slider-setting-state"},t(n?"settingOn":"settingOff")),(0,vt.createElement)("button",{type:"button",role:"switch","aria-label":t("sliderToggleAria"),"aria-checked":n,className:"bre-slider-setting-switch"+(n?" is-on":""),onClick:r},(0,vt.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:Me+"-slider-toggle",order:15,inject:()=>({t})},Hg)});return typeof r=="function"?r:()=>{}}var w=require("react"),Dg=require("react-dom/client");var da=[{label:"1K",value:"1024x1024",edge:1024},{label:"2K",value:"2048x2048",edge:2048},{label:"4K",value:"4096x4096",edge:4096}];function Rk(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 Hk(e){let t=Rk(e),n=da[0];if(t===void 0)return n;let r=Number.POSITIVE_INFINITY;for(let o of da){let i=Math.abs(o.edge-t);i<r&&(n=o,r=i)}return n}function Og(e){return Hk(e).value}var Nk=[5,10,15,30,60];function Ok(e){let t=Nk.map(n=>n*6e4);return t.includes(e)?t:[e,...t]}function Ik(e){let{api:t,t:n}=e,[r,o]=(0,w.useState)(()=>qi()),[i,a]=(0,w.useState)(void 0),[s,d]=(0,w.useState)([]),[c,u]=(0,w.useState)(!1),[p,g]=(0,w.useState)(void 0),[m,f]=(0,w.useState)(!1),v=(0,w.useRef)(!1),h=(0,w.useRef)(0),x=(0,w.useRef)(Promise.resolve()),C=(0,w.useRef)(0),T=(0,w.useRef)([]),H=(0,w.useCallback)(()=>{let N=++h.current;An().then(V=>{!v.current||N!==h.current||(o(V.data),a(V.ok?void 0:V.error))})},[]);(0,w.useEffect)(()=>(v.current=!0,H(),()=>{v.current=!1,h.current+=1}),[H]);let[B,I]=(0,w.useState)({});(0,w.useEffect)(()=>{let N=!0;return we(t).then(V=>{let Q={};for(let[ae,de]of Object.entries(ze(V.namespace))){let le=typeof de.displayName=="string"?de.displayName.trim():"";le.length>0&&(Q[ae]=le)}N&&I(Q)}).catch(()=>{}),()=>{N=!1}},[t]);let F=(0,w.useCallback)((N,V)=>{h.current+=1,C.current===0&&(T.current=[],g(void 0)),C.current+=1,u(!0),V!==void 0&&d(ae=>[...ae,V]);let Q=async()=>{let ae=await Lm(N).catch(de=>({ok:!1,error:de instanceof Error?de.message:String(de)}));C.current-=1,ae.ok||T.current.push(ae.error),v.current&&(V!==void 0&&d(de=>{let le=de.indexOf(V);return le<0?de:[...de.slice(0,le),...de.slice(le+1)]}),u(C.current>0),g(T.current.length===0?void 0:T.current.join(`
5407
+ `)),C.current===0&&H())};x.current=x.current.then(Q,Q)},[H]),k=(0,w.useCallback)(N=>{N.length!==0&&F({defaultModel:N},"default")},[F]),E=(0,w.useCallback)(N=>{F({enabled:N},"enabled")},[F]),_=(0,w.useCallback)(N=>{if(r===void 0)return;let V=Number(N);!Number.isFinite(V)||V<6e4||V>36e5||F({defaults:{timeoutMs:V}})},[r,F]);if(r===void 0)return(0,w.createElement)("div",{className:"bre-config-loading","aria-busy":i===void 0},(0,w.createElement)("div",{className:"bre-config-loading-text"},i===void 0?n("imagegenLoading"):`${n("imagegenLoadFailed")}: ${i}`),(0,w.createElement)("div",{className:"bre-config-skeleton"},...[0,1,2].map(N=>(0,w.createElement)("div",{key:N,className:"bre-config-skeleton-row"}))));let S=r.models,y=S.length===0,A="bre-config-imagegen-body",R=r.enabled?r.tool.error:void 0,D=new Map;for(let N of S)D.set(N.label,(D.get(N.label)??0)+1);let K=N=>{if((D.get(N.label)??0)<2)return N.label;let V=B[N.route]??N.providerLabel??N.route;return`${N.label} \xB7 ${V}`};return(0,w.createElement)("div",{className:"bre-config-card","aria-busy":c},(0,w.createElement)("div",{className:"bre-config-card-head"},(0,w.createElement)("button",{type:"button",className:"bre-config-expand","aria-expanded":m,"aria-controls":A,title:n(m?"imagegenCollapse":"imagegenExpand"),onClick:()=>f(N=>!N)},(0,w.createElement)("span",{className:"bre-config-card-title"},n("imagegenSectionTitle")),(0,w.createElement)("span",{className:"bre-config-card-hint"},r.enabled?n("imagegenEnabledHint"):n("imagegenDisabledHint"))),(0,w.createElement)("span",{className:"bre-config-card-state"},r.enabled?n("cardStateOn"):n("cardStateOff")),(0,w.createElement)("label",{className:"bre-config-switch",title:n("imagegenEnable")},(0,w.createElement)("input",{type:"checkbox",className:"bre-config-switch-input",role:"switch","aria-label":n("imagegenEnable"),checked:r.enabled,disabled:s.includes("enabled"),onChange:N=>E(N.target.checked)}),(0,w.createElement)("span",{className:"bre-config-switch-track","aria-hidden":!0})),(0,w.createElement)("span",{className:"bre-config-chevron","aria-hidden":!0,"data-open":String(m),onClick:()=>f(N=>!N)},"\u203A")),i!==void 0&&(0,w.createElement)("div",{className:"bre-config-notice",role:"alert"},`${n("imagegenLoadFailed")}: ${i}`),p!==void 0&&(0,w.createElement)("div",{className:"bre-config-notice"},p),m&&(0,w.createElement)("div",{className:"bre-config-card-body",id:A},R!==void 0&&(0,w.createElement)("div",{className:"bre-config-notice bre-config-notice-warn"},(0,w.createElement)("div",null,n("imagegenToolMissing")),(0,w.createElement)("div",{className:"bre-config-notice-why"},n("imagegenToolMissingWhy",{reason:R}))),(0,w.createElement)("div",{className:"bre-config-defaults"},(0,w.createElement)("label",null,n("imagegenDefaultsLabel")),(0,w.createElement)("select",{className:"bre-config-select",value:Og(r.defaults.size),"aria-label":n("imagegenSizeLabel"),onChange:N=>{F({defaults:{size:N.target.value}})}},da.map(N=>(0,w.createElement)("option",{key:N.label,value:N.value},N.label))),(0,w.createElement)("select",{className:"bre-config-select",value:r.defaults.quality,"aria-label":n("imagegenQualityLabel"),onChange:N=>{F({defaults:{quality:N.target.value}})}},["low","medium","high","auto"].map(N=>(0,w.createElement)("option",{key:N,value:N},N))),(0,w.createElement)("select",{className:"bre-config-select",value:String(r.defaults.n),"aria-label":n("imagegenCountLabel"),onChange:N=>{F({defaults:{n:Number(N.target.value)}})}},[1,2,3,4].map(N=>(0,w.createElement)("option",{key:N,value:String(N)},`n=${N}`))),(0,w.createElement)("label",{className:"bre-config-timeout",title:n("imagegenTimeoutHint")},(0,w.createElement)("span",{className:"bre-config-timeout-label"},n("imagegenTimeoutLabel")),(0,w.createElement)("select",{className:"bre-config-select",value:String(r.defaults.timeoutMs),"aria-label":n("imagegenTimeoutLabel"),onChange:N=>{_(N.target.value)}},Ok(r.defaults.timeoutMs).map(N=>(0,w.createElement)("option",{key:N,value:String(N)},n("imagegenTimeoutMinutes",{minutes:Math.round(N/6e4)})))))),!y&&(0,w.createElement)("div",{className:"bre-config-default-row"},(0,w.createElement)("label",{className:"bre-config-default-label"},n("imagegenDefaultModelLabel")),(0,w.createElement)("select",{className:"bre-config-select bre-config-default-select",value:r.defaultModel??"","aria-label":n("imagegenDefaultModelLabel"),disabled:s.includes("default"),onChange:N=>k(N.target.value)},r.defaultModel===null&&(0,w.createElement)("option",{value:"",disabled:!0},n("imagegenDefaultModelNone")),S.map(N=>(0,w.createElement)("option",{key:N.id,value:N.id},K(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",MODEL_SWITCH_COMPACTION_FAILED:"depends",CLI_TIMEOUT:"depends",QUOTA:"useless"},Dk={continue:"autoContinueTagContinue",useless:"autoContinueTagUseless",depends:"autoContinueTagDepends"};function Pk(e){let{t,policy:n}=e,[r,o]=(0,w.useState)(""),[i,a]=(0,w.useState)(!1),s=n.customCodes??[],d=()=>{let I=Md(r);if(I===void 0||s.includes(I)||s.length>=lo){a(!0);return}e.onAdd(I),o(""),a(!1)},[c,u]=(0,w.useState)(!1),p=(0,w.useRef)(null),g=(0,w.useRef)(null),[m,f]=(0,w.useState)(null);(0,w.useEffect)(()=>{if(!c)return;let I=k=>{let E=p.current;E!==null&&k.target instanceof Node&&!E.contains(k.target)&&u(!1)},F=()=>u(!1);return document.addEventListener("mousedown",I),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{document.removeEventListener("mousedown",I),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[c]);let v=()=>{if(c){u(!1);return}let I=g.current;if(I===null){u(!0);return}let F=I.getBoundingClientRect(),k=Math.min(Math.max(F.width,400),window.innerWidth-24),E=Math.min(Math.max(8,F.right-k),window.innerWidth-k-8),_=window.innerHeight-F.bottom-12,S=470;f(_>=S?{left:E,width:k,top:F.bottom+6}:F.top>S?{left:E,width:k,bottom:window.innerHeight-F.top+6}:{left:E,width:k,top:Math.max(8,window.innerHeight-8-460)}),u(!0)},h=[...yr,...s].filter(I=>n.codes[I]===!0),x=[];n.maxTokens&&x.push((0,w.createElement)("span",{className:"bre-config-chip",key:"max-tokens"},t("autoContinueMaxTokens"))),n.httpStatus&&x.push((0,w.createElement)("span",{className:"bre-config-chip",key:"http"},t("autoContinueChipHttp")));for(let I of h)x.push((0,w.createElement)("span",{className:"bre-config-chip",key:I},I));let C=x.slice(0,3),T=x.length-C.length,H=(I,F,k,E,_,S)=>(0,w.createElement)("label",{className:"bre-config-code-row",key:I},(0,w.createElement)("input",{type:"checkbox",className:"bre-config-code-input",checked:F,onChange:y=>S(y.target.checked)}),(0,w.createElement)("span",{className:`bre-config-check${F?" bre-config-check-on":""}`,"aria-hidden":!0}),(0,w.createElement)("span",{className:"bre-config-code-name"},k),(0,w.createElement)("span",{className:"bre-config-code-why",title:E},E),(0,w.createElement)("span",{className:`bre-config-code-tag bre-config-code-tag-${_}`},t(Dk[_]))),B=(I,F)=>(0,w.createElement)("div",{className:"bre-config-code-group",key:I},(0,w.createElement)("div",{className:"bre-config-code-group-title"},t(I)),F);return(0,w.createElement)("div",{className:"bre-config-trigger-control",ref:p},(0,w.createElement)("button",{type:"button",className:"bre-config-trigger-button",ref:g,"aria-expanded":c,"aria-label":t("autoContinueTriggers"),onClick:v},C,T>0&&(0,w.createElement)("span",{className:"bre-config-chip bre-config-chip-more"},t("autoContinueCodesMore",{count:T})),x.length===0&&(0,w.createElement)("span",{className:"bre-config-multiselect-empty"},"\u2014"),(0,w.createElement)("span",{className:"bre-config-multiselect-caret","aria-hidden":!0},"\u25BE")),c&&(0,w.createElement)("div",{className:"bre-config-multiselect-pop",role:"group","aria-label":t("autoContinueErrorTypes"),style:m===null?void 0:{left:`${m.left}px`,width:`${m.width}px`,...m.top===void 0?{}:{top:`${m.top}px`},...m.bottom===void 0?{}:{bottom:`${m.bottom}px`}}},B("autoContinueGroupFlags",[H("flag:max-tokens",n.maxTokens,t("autoContinueMaxTokens"),t("autoContinueWhyMaxTokens"),"continue",I=>e.onFlag("maxTokens",I)),H("flag:http",n.httpStatus,t("autoContinueHttpStatus"),t("autoContinueWhyHttpStatus"),"continue",I=>e.onFlag("httpStatus",I))]),B("autoContinueGroupTransient",Ui.map(I=>H(I,n.codes[I]===!0,(0,w.createElement)("code",{className:"bre-config-code-name-inner"},I),t(`autoContinueWhy${I}`),Ig[I]??"depends",F=>e.onToggle(I,F)))),B("autoContinueGroupOther",Wi.map(I=>H(I,n.codes[I]===!0,(0,w.createElement)("code",{className:"bre-config-code-name-inner"},I),t(`autoContinueWhy${I}`),Ig[I]??"depends",F=>e.onToggle(I,F)))),B("autoContinueCustomCodes",s.map(I=>(0,w.createElement)("div",{key:I},H(I,n.codes[I]===!0,(0,w.createElement)("code",null,I),"","depends",F=>e.onToggle(I,F)),(0,w.createElement)("button",{type:"button",className:"bre-config-link",onClick:()=>e.onRemove(I),"aria-label":t("autoContinueCustomCodeRemove",{code:I})},t("autoContinueCustomCodeRemove",{code:I}))))),(0,w.createElement)("div",{className:"bre-config-auto-control"},(0,w.createElement)("input",{type:"text",className:"bre-config-auto-input",value:r,maxLength:Ad,"aria-label":t("autoContinueCustomCodes"),placeholder:t("autoContinueCustomCodePlaceholder"),onChange:I=>{o(I.target.value),a(!1)},onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),d())}}),(0,w.createElement)("button",{type:"button",className:"bre-config-link",disabled:s.length>=lo,onClick:d},t("autoContinueCustomCodeAdd"))),(0,w.createElement)("div",{className:"bre-config-card-hint"},t("autoContinueCustomCodeLimit",{count:lo})),i&&(0,w.createElement)("div",{role:"alert"},t("autoContinueCustomCodeInvalid")),(0,w.createElement)("div",{className:"bre-config-multiselect-foot"},(0,w.createElement)("button",{type:"button",className:"bre-config-link",onClick:()=>e.onBulk(!0)},t("autoContinueCodesAll")),(0,w.createElement)("button",{type:"button",className:"bre-config-link",onClick:()=>e.onBulk(!1)},t("autoContinueCodesNone")),(0,w.createElement)("button",{type:"button",className:"bre-config-link bre-config-link-quiet",onClick:e.onRestore},t("autoContinueRestore")))))}function _k(e){let{t}=e,n=(0,w.useSyncExternalStore)(ta,Xe),r=(0,w.useSyncExternalStore)(na,Je),[o,i]=(0,w.useState)(String(r.waitSeconds)),[a,s]=(0,w.useState)(String(r.maxRetries)),[d,c]=(0,w.useState)(String(r.maxChainMinutes)),[u,p]=(0,w.useState)(String(r.maxRequests));(0,w.useEffect)(()=>{c(String(r.maxChainMinutes))},[r.maxChainMinutes]),(0,w.useEffect)(()=>{p(String(r.maxRequests))},[r.maxRequests]),(0,w.useEffect)(()=>{i(String(r.waitSeconds))},[r.waitSeconds]),(0,w.useEffect)(()=>{s(String(r.maxRetries))},[r.maxRetries]);let g=()=>{At({waitSeconds:o.trim()===""?r.waitSeconds:Number(o)}),i(String(Je().waitSeconds))},m=()=>{At({maxRetries:a.trim()===""?r.maxRetries:Number(a)}),s(String(Je().maxRetries))},[f,v]=(0,w.useState)(!1),h="bre-config-auto-continue-body",x=r.policy,C=E=>{At({policy:{...x,...E}})},T=(E,_)=>{At({policy:{...x,codes:{...x.codes,[E]:_}}})},H=E=>{let _={...x.codes};for(let S of yr)_[S]=E;At({policy:{...x,codes:_}})},B=E=>{At({policy:{...x,customCodes:[...x.customCodes??[],E],codes:{...x.codes,[E]:!1}}})},I=E=>{let _={...x.codes};delete _[E],At({policy:{...x,customCodes:(x.customCodes??[]).filter(S=>S!==E),codes:_}})},F=(E,_,S,y,A,R,D)=>(0,w.createElement)("label",{className:"bre-config-auto-field",key:E},(0,w.createElement)("span",{className:"bre-config-auto-label"},t(_)),(0,w.createElement)("span",{className:"bre-config-auto-control"},(0,w.createElement)("input",{type:"number",className:"bre-config-auto-input",min:R,max:D,step:1,value:y,"aria-label":t(_),title:String(R)+"\u2013"+String(D)+" "+t(S),onChange:K=>A(K.target.value),onBlur:()=>{At({[E]:y.trim()===""?r[E]:Number(y)}),A(String(Je()[E]))},onKeyDown:K=>{K.key==="Enter"&&K.currentTarget.blur()}}),(0,w.createElement)("span",{className:"bre-config-auto-unit","aria-hidden":!0},t(S)))),k=()=>{At({policy:an})};return(0,w.createElement)("div",{className:"bre-config-card bre-config-auto-card"},(0,w.createElement)("div",{className:"bre-config-card-head"},(0,w.createElement)("button",{type:"button",className:"bre-config-expand","aria-expanded":f,"aria-controls":h,title:t(f?"autoContinueCollapse":"autoContinueExpand"),onClick:()=>v(E=>!E)},(0,w.createElement)("span",{className:"bre-config-card-title"},t("autoContinueSectionTitle")),!f&&(0,w.createElement)("span",{className:"bre-config-card-hint bre-config-auto-summary"},t("autoContinueHint",{seconds:r.waitSeconds,count:r.maxRetries}))),(0,w.createElement)("span",{className:"bre-config-card-state"},t(n?"cardStateOn":"cardStateOff")),(0,w.createElement)("label",{className:"bre-config-switch",title:t("autoContinueAria")},(0,w.createElement)("input",{type:"checkbox",className:"bre-config-switch-input",role:"switch","aria-label":t("autoContinueAria"),checked:n,onChange:E=>{Jm(E.target.checked)}}),(0,w.createElement)("span",{className:"bre-config-switch-track","aria-hidden":!0})),(0,w.createElement)("span",{className:"bre-config-chevron","aria-hidden":!0,"data-open":String(f),onClick:()=>v(E=>!E)},"\u203A")),f&&(0,w.createElement)("div",{className:"bre-config-card-body",id:h},(0,w.createElement)("div",{className:"bre-config-auto-fields"},(0,w.createElement)("label",{className:"bre-config-auto-field"},(0,w.createElement)("span",{className:"bre-config-auto-label"},t("autoContinueWaitLabel")),(0,w.createElement)("span",{className:"bre-config-auto-control"},(0,w.createElement)("input",{type:"number",className:"bre-config-auto-input",min:Yi,max:Xi,step:1,value:o,"aria-label":`${t("autoContinueWaitLabel")} (${t("autoContinueSecondsUnit")})`,title:`${Yi}\u2013${Xi} ${t("autoContinueSecondsUnit")}`,onChange:E=>i(E.target.value),onBlur:g,onKeyDown:E=>{E.key==="Enter"&&E.currentTarget.blur()}}),(0,w.createElement)("span",{className:"bre-config-auto-unit","aria-hidden":!0},t("autoContinueSecondsUnit")))),(0,w.createElement)("label",{className:"bre-config-auto-field"},(0,w.createElement)("span",{className:"bre-config-auto-label"},t("autoContinueRetriesLabel")),(0,w.createElement)("span",{className:"bre-config-auto-control"},(0,w.createElement)("input",{type:"number",className:"bre-config-auto-input",min:Ji,max:Qi,step:1,value:a,"aria-label":`${t("autoContinueRetriesLabel")} (${t("autoContinueRetriesUnit")})`,title:`${Ji}\u2013${Qi} ${t("autoContinueRetriesUnit")}`,onChange:E=>s(E.target.value),onBlur:m,onKeyDown:E=>{E.key==="Enter"&&E.currentTarget.blur()}}),(0,w.createElement)("span",{className:"bre-config-auto-unit","aria-hidden":!0},t("autoContinueRetriesUnit"))))),(0,w.createElement)("div",{className:"bre-config-auto-fields"},F("maxChainMinutes","autoContinueChainMinutesLabel","autoContinueChainMinutesUnit",d,c,Ld,Rd),F("maxRequests","autoContinueRequestsLabel","autoContinueRequestsUnit",u,p,Hd,Nd)),(0,w.createElement)("label",{className:"bre-config-auto-field"},(0,w.createElement)("input",{type:"checkbox",checked:r.backoff,"aria-label":t("autoContinueBackoffLabel"),onChange:E=>At({backoff:E.target.checked})}),t("autoContinueBackoffLabel")),(0,w.createElement)("p",{className:"bre-config-card-hint"},t("autoContinueBackoffHint")),(0,w.createElement)("p",{className:"bre-config-card-hint"},t("autoContinueRequestsHint")),(0,w.createElement)("p",{className:"bre-config-card-hint"},t("autoContinueControllerProviderRetryDesc")),(0,w.createElement)("p",{className:"bre-config-card-hint"},t("autoContinueControllerOfficialRetryHint")),(0,w.createElement)("div",{className:"bre-config-trigger-field"},(0,w.createElement)("span",{className:"bre-config-auto-label"},t("autoContinueTriggers")),(0,w.createElement)(Pk,{t,policy:x,onFlag:(E,_)=>C({[E]:_}),onToggle:T,onBulk:H,onRestore:k,onAdd:B,onRemove:I}))))}function Fk(e){let{t}=e,n=(0,w.useSyncExternalStore)(sa,aa),[r,o]=(0,w.useState)(!1),i="bre-config-error-detail-body";return(0,w.createElement)("div",{className:"bre-config-card"},(0,w.createElement)("div",{className:"bre-config-card-head"},(0,w.createElement)("button",{type:"button",className:"bre-config-expand","aria-expanded":r,"aria-controls":i,title:t(r?"autoContinueCollapse":"autoContinueExpand"),onClick:()=>o(a=>!a)},(0,w.createElement)("span",{className:"bre-config-card-title"},t("errorDetailSectionTitle")),!r&&(0,w.createElement)("span",{className:"bre-config-card-hint"},t("errorDetailSummary"))),(0,w.createElement)("span",{className:"bre-config-card-state"},t(n?"cardStateOn":"cardStateOff")),(0,w.createElement)("label",{className:"bre-config-switch",title:t("errorDetailAria")},(0,w.createElement)("input",{type:"checkbox",className:"bre-config-switch-input",role:"switch","aria-label":t("errorDetailAria"),checked:n,onChange:a=>{mg(a.target.checked)}}),(0,w.createElement)("span",{className:"bre-config-switch-track","aria-hidden":!0})),(0,w.createElement)("span",{className:"bre-config-chevron","aria-hidden":!0,"data-open":String(r),onClick:()=>o(a=>!a)},"\u203A")),r&&(0,w.createElement)("div",{className:"bre-config-card-body",id:i},(0,w.createElement)("p",{className:"bre-config-card-hint bre-config-error-detail-copy"},t("errorDetailHint"))))}function qk(e){let{t,onClose:n}=e,r=(0,w.useRef)(null);return(0,w.useEffect)(()=>{let o=i=>{i.key==="Escape"&&n()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n]),(0,w.createElement)("div",{className:"bre-config-backdrop",onMouseDown:o=>{o.target===o.currentTarget&&n()}},(0,w.createElement)("div",{className:"bre-config-pane",ref:r},(0,w.createElement)("div",{className:"bre-config-head"},(0,w.createElement)("span",{className:"bre-config-title"},t("configPaneTitle")),(0,w.createElement)("button",{className:"bre-config-close",type:"button","aria-label":t("configPaneClose"),onClick:n},"\u2715")),(0,w.createElement)("div",{className:"bre-config-body"},(0,w.createElement)($e,{fallbackText:t("configPaneFailed")},(0,w.createElement)(Ik,{api:e.api,t:e.t})),(0,w.createElement)($e,{fallbackText:t("configPaneFailed")},(0,w.createElement)(_k,{t:e.t})),(0,w.createElement)($e,{fallbackText:t("configPaneFailed")},(0,w.createElement)(Fk,{t:e.t})))))}function qd(e){let t=document.createElement("div");t.className="bre-config-pane-host",document.body.appendChild(t);let n=(0,Dg.createRoot)(t),r=!0,o=()=>{r&&(r=!1,qe({wrapper:t,root:n}))};return n.render((0,w.createElement)(qk,{api:e.api,t:e.t,onClose:o})),{close:o}}function Pg(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return r.length===0||n.includes(r)}function _g(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=>Pg(a.id,o)||Pg(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 xr,Bd=0;function Kd(){xr=void 0,Bd+=1}function Bk(){if(xr!==void 0)return xr;let e=Bd,t=An().then(n=>e===Bd&&n.ok&&n.data.enabled?n.data.models.map(r=>({id:r.id,label:r.label,isDefault:n.data.defaultModel===r.id})):[]).catch(()=>[]).finally(()=>{xr===t&&(xr=void 0)});return xr=t,t}function Fg(e){let t;try{t=e.inputTriggers}catch{t=void 0}let n=Am(Kd);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)?Bk().then(s=>r&&!i.signal?.aborted?_g(a.replace(/^\/?生图/,""),s):[]):[]}})}catch{r=!1}return()=>{r=!1,n()}}var Ln=require("react");var qg="tool.call.images",Kk="generate_image";function Uk(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 Wk(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 Gk(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(`
5392
5408
  `)),Array.isArray(t.revisions)&&t.revisions.length>0&&n.push(t.revisions.join("\u3001")),n.length>0?n.join(`
5393
- `):null}function mk(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=uk(t);if(r.length===0){let i=fk(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=pk(t);return(0,kn.createElement)("div",{className:"bre-image-card"},typeof e.renderSlot=="function"&&typeof e.loadImage=="function"?e.renderSlot(pg,{images:r,loadImage:e.loadImage,align:"start"}):null,o===null?null:(0,kn.createElement)("div",{className:"bre-image-card-caption"},o))}function gk(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:{[pg]:{kind:"single",scope:"session"}}},a=>mk({...a,t:n})));typeof i=="function"&&(r=i)}catch{return()=>{}}return()=>{r?.()}}function mg(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=gk(n,s,t)))};return a(ck),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 hg=200,hk=Ee,bk=["slots","locale","connection","remote","remote.settings"];function yk(e){e.effect(()=>e.locale.register(sa,{zh:Fd,en:_d}),"dsh-model-think-level: dictionaries");let t=document.createElement("style");t.dataset.plugin=Ee,t.dataset.pluginStyles=Ee,t.textContent=ll,document.head.appendChild(t),e.effect(()=>()=>t.remove(),"dsh-model-think-level: stylesheet"),e.effect(()=>km(Ue),"dsh-model-think-level: key list revalidation");let n=(()=>{try{let f=e.get?.("configForms");try{let x=f?.get?.(_e);if(x!==void 0)return x}catch{}return e.get?.("settingsScope")?.bind?.({namespace:_e})}catch{return}})(),r=n===void 0?{settings:e.remote.settings}:{settings:e.remote.settings,scope:n},o=e.locale.bind(sa),i=()=>{let f=e.locale;return typeof f.subscribe=="function"&&typeof f.getSnapshot=="function"?f:void 0},a=f=>{let v=i();return v===void 0?f():(0,gg.createElement)(Dd,{locale:v,children:f})},s=jl({api:r}),d=wl(r),l=Cm({ctx:e,configuredEffort:s.of}),c=Ul({menuOf:Bl,triggerOf:Wl,t:o,refreshed:a,sliderEnabled:gt,directory:l.ensure,configuredInputs:d}),p=zl({api:r}),h=$l({api:r}),m,g=xm({ctx:e,api:r,t:o,onIdle:f=>{h.run(f),p.run(f)},refreshed:a,configSeat:{t:o,onOpen:()=>{m?.close(),m=Ad({api:r,t:o})}}}),b=()=>{l.ensure(),c.reconcile()};e.effect(()=>(g.start(b),()=>{g.teardown(),c.dispose(),l.dispose(),m?.close(),m=void 0}),"dsh-model-think-level: DOM injector"),e.effect(()=>{let f=()=>{g.flushOnUnload(),Ma(),Lm()};return window.addEventListener("pagehide",f),()=>{window.removeEventListener("pagehide",f)}},"dsh-model-think-level: ledger flush on unload"),e.effect(()=>dl(),"dsh-model-think-level: order file sync"),e.effect(()=>{let f=!1,x=Hd(()=>{f&&(f=!1,document.dispatchEvent(new CustomEvent(Er,{detail:{ns:_e}}))),g.state.describePromise=void 0,s.invalidate(),d.invalidate(),p.invalidate(),Cd(),g.schedule()},hg),w=[e.remote.$on("settings/document-updated",R=>{R===_e&&(f=!0,x.schedule())}),e.on("connection/reset",x.schedule)];return()=>{x.dispose();for(let R of w)R()}},"dsh-model-think-level: pushed invalidations"),e.effect(()=>{let f=F=>{F.key===go?Bd(F.newValue!=="false"):F.key===bo?jd(Ln(F.newValue)):F.key===vo?Yd($d(F.newValue)):F.key===wo?el(ha(F.newValue)):F.key===qi?kd(F.newValue==="true"):F.key===Ki?Ed(ji(F.newValue)):F.key===Ji?Md(F.newValue!=="false"):F.key===null&&(kd(!1),Ed(ji(null)),Md(!0))};window.addEventListener("storage",f);let v=ho(()=>{g.schedule()}),x=Rn(()=>{g.schedule()}),w=On(()=>{g.schedule()}),R=In(()=>{g.schedule()});return()=>{window.removeEventListener("storage",f),v(),x(),w(),R()}},"dsh-model-think-level: client preferences"),e.effect(()=>ag(e,o),"dsh-model-think-level: footer slot activation"),e.effect(()=>og(e,r,o),"dsh-model-think-level: provider-card slot activation"),e.effect(()=>fg(e),"dsh-model-think-level: imagegen completion source"),mg(e,o),e.effect(()=>{let f=Fm({ctx:e,t:o}),v=zm({runner:f,t:o,onSettings:()=>{Ad({api:r,t:o})}});return()=>{v(),f.dispose()}},"dsh-model-think-level: auto-continue watcher"),e.effect(()=>{let f,v=()=>{if(!Xi()){f?.dispose(),f=void 0;return}f??(f=Bm({ctx:e,t:o}))},x=Qi(v);return v(),()=>{x(),f?.dispose(),f=void 0}},"dsh-model-think-level: failure detail seat")}
5409
+ `):null}function jk(e){let t=e.block;if(!(t!==void 0&&typeof t=="object"&&"kind"in t))return(0,Ln.createElement)("div",{className:"bre-image-card","aria-busy":!0},(0,Ln.createElement)("span",{className:"bre-image-card-running"},e.t("imagegenCardRunning")));let r=Uk(t);if(r.length===0){let i=Wk(t);return(0,Ln.createElement)("div",{className:"bre-image-card"},i===null?null:(0,Ln.createElement)("div",{className:"bre-image-card-caption"},i))}let o=Gk(t);return(0,Ln.createElement)("div",{className:"bre-image-card"},typeof e.renderSlot=="function"&&typeof e.loadImage=="function"?e.renderSlot(qg,{images:r,loadImage:e.loadImage,align:"start"}):null,o===null?null:(0,Ln.createElement)("div",{className:"bre-image-card-caption"},o))}function zk(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:{[qg]:{kind:"single",scope:"session"}}},a=>jk({...a,t:n})));typeof i=="function"&&(r=i)}catch{return()=>{}}return()=>{r?.()}}function Bg(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=zk(n,s,t)))};return a(Kk),a(qi()?.tool.name),An().then(s=>{s.ok&&a(s.data.tool.name)}).catch(()=>{}),()=>{i=!1,r?.()}},"dsh-model-think-level: image tool card")}var Ug=200,$k=Me,Vk=["slots","locale","connection","remote","remote.settings"];function Yk(e){e.effect(()=>e.locale.register(ma,{zh:Xd,en:Yd}),"dsh-model-think-level: dictionaries");let t=document.createElement("style");t.dataset.plugin=Me,t.dataset.pluginStyles=Me,t.textContent=xl,document.head.appendChild(t),e.effect(()=>()=>t.remove(),"dsh-model-think-level: stylesheet"),e.effect(()=>Km(Ye),"dsh-model-think-level: key list revalidation");let n=(()=>{try{let h=e.get?.("configForms");try{let C=h?.get?.(Ue);if(C!==void 0)return C}catch{}return e.get?.("settingsScope")?.bind?.({namespace:Ue})}catch{return}})(),r=n===void 0?{settings:e.remote.settings}:{settings:e.remote.settings,scope:n},o=e.locale.bind(ma),i=()=>{let h=e.locale;return typeof h.subscribe=="function"&&typeof h.getSnapshot=="function"?h:void 0},a=h=>{let x=i();return x===void 0?h():(0,Kg.createElement)(Vd,{locale:x,children:h})},s=rc({api:r}),d=Nl(r),c=Vm({ctx:e,configuredEffort:s.of}),u=nc({menuOf:Zl,triggerOf:ec,t:o,refreshed:a,sliderEnabled:kt,directory:c.ensure,configuredInputs:d}),p=oc({api:r}),g=ic({api:r}),m,f=Bm({ctx:e,api:r,t:o,onIdle:h=>{g.run(h),p.run(h)},refreshed:a,configSeat:{t:o,onOpen:()=>{m?.close(),m=qd({api:r,t:o})}}}),v=()=>{c.ensure(),u.reconcile()};e.effect(()=>(f.start(v),()=>{f.teardown(),u.dispose(),c.dispose(),m?.close(),m=void 0}),"dsh-model-think-level: DOM injector"),e.effect(()=>{let h=()=>{f.flushOnUnload(),Oa(),$m()};return window.addEventListener("pagehide",h),()=>{window.removeEventListener("pagehide",h)}},"dsh-model-think-level: ledger flush on unload"),e.effect(()=>wl(),"dsh-model-think-level: order file sync"),e.effect(()=>{let h=!1,C=Wd(()=>{h&&(h=!1,document.dispatchEvent(new CustomEvent(Lr,{detail:{ns:Ue}}))),f.state.describePromise=void 0,s.invalidate(),d.invalidate(),p.invalidate(),Kd(),f.schedule()},Ug),T=[e.remote.$on("settings/document-updated",H=>{H===Ue&&(h=!0,C.schedule())}),e.on("connection/reset",C.schedule)];return()=>{C.dispose();for(let H of T)H()}},"dsh-model-think-level: pushed invalidations"),e.effect(()=>{let h=B=>{B.key===Eo?Zd(B.newValue!=="false"):B.key===So?rl(On(B.newValue)):B.key===Ao?sl(il(B.newValue)):B.key===Mo?fl(Ea(B.newValue)):B.key===$i?Id(B.newValue==="true"):B.key===Vi?Dd(Zi(B.newValue)):B.key===ia?Fd(B.newValue!=="false"):B.key===null&&(Id(!1),Dd(Zi(null)),Fd(!0))};window.addEventListener("storage",h);let x=To(()=>{f.schedule()}),C=Dn(()=>{f.schedule()}),T=Fn(()=>{f.schedule()}),H=qn(()=>{f.schedule()});return()=>{window.removeEventListener("storage",h),x(),C(),T(),H()}},"dsh-model-think-level: client preferences"),e.effect(()=>Ng(e,o),"dsh-model-think-level: footer slot activation"),e.effect(()=>Rg(e,r,o),"dsh-model-think-level: provider-card slot activation"),e.effect(()=>Fg(e),"dsh-model-think-level: imagegen completion source"),Bg(e,o),e.effect(()=>{let h=lg({ctx:e,t:o}),x=yg({runner:h,t:o,onSettings:()=>{qd({api:r,t:o})}});return()=>{x(),h.dispose()}},"dsh-model-think-level: auto-continue watcher"),e.effect(()=>{let h,x=()=>{if(!aa()){h?.dispose(),h=void 0;return}h??(h=fg({ctx:e,t:o}))},C=sa(x);return x(),()=>{C(),h?.dispose(),h=void 0}},"dsh-model-think-level: failure detail seat")}
5394
5410
 
5395
5411
  return module.exports;
5396
5412
  }