import*as e from"../../core/common/common.js";import*as i from"../../core/i18n/i18n.js";import*as n from"../console/console.js";import*as o from"../../ui/legacy/legacy.js";const t={explainThisError:"Understand this error",explainThisWarning:"Understand this warning",explainThisMessage:"Understand this message",enableConsoleInsights:"Understand console messages with AI",wrongLocale:"To use this feature, set your language preference to English in DevTools settings.",geoRestricted:"This feature is unavailable in your region.",policyRestricted:"This setting is managed by your administrator."},s=i.i18n.registerUIStrings("panels/explain/explain-meta.ts",t),a=i.i18n.getLazilyComputedLocalizedString.bind(void 0,s),l=i.i18n.getLocalizedString.bind(void 0,s),r=[{actionId:"explain.console-message.hover",title:a(t.explainThisMessage),contextTypes:()=>[n.ConsoleViewMessage.ConsoleViewMessage]},{actionId:"explain.console-message.context.error",title:a(t.explainThisError),contextTypes:()=>[]},{actionId:"explain.console-message.context.warning",title:a(t.explainThisWarning),contextTypes:()=>[]},{actionId:"explain.console-message.context.other",title:a(t.explainThisMessage),contextTypes:()=>[]}];function c(e){return!0===e?.aidaAvailability?.blockedByEnterprisePolicy}function g(e){return!0===(e?.aidaAvailability?.enabled&&e?.devToolsConsoleInsights?.enabled)}e.Settings.registerSettingExtension({category:"AI",settingName:"console-insights-enabled",settingType:"boolean",title:a(t.enableConsoleInsights),defaultValue:!1,reloadRequired:!1,condition:e=>g(e),disabledCondition:e=>{const n=[];return function(e){return!0===e?.aidaAvailability?.blockedByGeo}(e)&&n.push(l(t.geoRestricted)),c(e)&&n.push(l(t.policyRestricted)),i.DevToolsLocale.DevToolsLocale.instance().locale.startsWith("en-")||n.push(l(t.wrongLocale)),n.length>0?{disabled:!0,reasons:n}:{disabled:!1}}});for(const e of r)o.ActionRegistration.registerActionExtension({...e,category:"CONSOLE",loadActionDelegate:async()=>new((await import("./explain.js")).ActionDelegate),condition:e=>g(e)&&!c(e)});
