var Se=Object.defineProperty;var U=(g,e)=>{for(var t in e)Se(g,t,{get:e[t],enumerable:!0})};var oe={};U(oe,{ExecutionContextSelector:()=>k});import*as a from"./../../core/sdk/sdk.js";var k=class{#e;#t;#o;#n;constructor(e,t){t.addFlavorChangeListener(a.RuntimeModel.ExecutionContext,this.#r,this),t.addFlavorChangeListener(a.Target.Target,this.#a,this),e.addModelListener(a.RuntimeModel.RuntimeModel,a.RuntimeModel.Events.ExecutionContextCreated,this.#u,this),e.addModelListener(a.RuntimeModel.RuntimeModel,a.RuntimeModel.Events.ExecutionContextDestroyed,this.#g,this),e.addModelListener(a.RuntimeModel.RuntimeModel,a.RuntimeModel.Events.ExecutionContextOrderChanged,this.#m,this),this.#e=e,this.#t=t,e.observeModels(a.RuntimeModel.RuntimeModel,this)}modelAdded(e){queueMicrotask(t.bind(this));function t(){this.#t.flavor(a.Target.Target)||this.#t.setFlavor(a.Target.Target,e.target())}}modelRemoved(e){this.#t.flavor(a.RuntimeModel.ExecutionContext)?.runtimeModel===e&&this.#d();let o=this.#e.models(a.RuntimeModel.RuntimeModel);this.#t.flavor(a.Target.Target)===e.target()&&o.length&&this.#t.setFlavor(a.Target.Target,o[0].target())}#r({data:e}){e&&(this.#t.setFlavor(a.Target.Target,e.target()),this.#n||(this.#o=this.#s(e)))}#s(e){return e.isDefault?e.target().name()+":"+e.frameId:""}#a({data:e}){let t=this.#t.flavor(a.RuntimeModel.ExecutionContext);if(!e||t&&t.target()===e)return;let o=e.model(a.RuntimeModel.RuntimeModel),n=o?o.executionContexts():[];if(!n.length)return;let r=null;for(let l=0;l<n.length&&!r;++l)this.#l(n[l])&&(r=n[l]);for(let l=0;l<n.length&&!r;++l)this.#i(n[l])&&(r=n[l]);this.#n=!0,this.#t.setFlavor(a.RuntimeModel.ExecutionContext,r||n[0]),this.#n=!1}#l(e){return e.target().targetInfo()?.subtype?!1:this.#o&&this.#o===this.#s(e)?!0:!this.#o&&this.#i(e)}#i(e){return!e.isDefault||!e.frameId||e.target().parentTarget()?.type()===a.Target.Type.FRAME?!1:!!e.target().model(a.ResourceTreeModel.ResourceTreeModel)?.frameForId(e.frameId)?.isOutermostFrame()}#u(e){if(this.#o===void 0){this.#c(e.data);return}switch(e.data.target().type()){case a.Target.Type.AUCTION_WORKLET:case a.Target.Type.SHARED_STORAGE_WORKLET:case a.Target.Type.SHARED_WORKER:case a.Target.Type.ServiceWorker:case a.Target.Type.WORKLET:case a.Target.Type.Worker:return;case a.Target.Type.BROWSER:case a.Target.Type.FRAME:case a.Target.Type.NODE:case a.Target.Type.TAB:this.#c(e.data);break}}#g(e){let t=e.data;this.#t.flavor(a.RuntimeModel.ExecutionContext)===t&&this.#d()}#m(e){let o=e.data.executionContexts();for(let n=0;n<o.length&&!this.#c(o[n]);n++);}#c(e){return!this.#t.flavor(a.RuntimeModel.ExecutionContext)||this.#l(e)?(this.#n=!0,this.#t.setFlavor(a.RuntimeModel.ExecutionContext,e),this.#n=!1,!0):!1}#d(){let e=this.#e.models(a.RuntimeModel.RuntimeModel),t=null;for(let o=0;o<e.length&&!t;++o){let n=e[o].executionContexts();for(let r of n)if(this.#i(r)){t=r;break}}if(!t)for(let o=0;o<e.length&&!t;++o){let n=e[o].executionContexts();if(n.length){t=n[0];break}}this.#n=!0,this.#t.setFlavor(a.RuntimeModel.ExecutionContext,t),this.#n=!1}};var ae={};U(ae,{DEFAULT_VIEW:()=>re,GlobalAiButton:()=>A,GlobalAiButtonState:()=>E,GlobalAiButtonToolbarProvider:()=>B});import*as W from"./../../core/common/common.js";import*as G from"./../../core/i18n/i18n.js";import*as $ from"./../../core/root/root.js";import*as z from"./../../models/ai_assistance/ai_assistance.js";import*as T from"./../../ui/legacy/legacy.js";import*as be from"./../../ui/lit/lit.js";import*as se from"./../../ui/visual_logging/visual_logging.js";var ne=`@scope to (devtools-widget > *){.global-ai-button-container{margin-left:var(--sys-size-3);margin-right:var(--sys-size-2)}.global-ai-button{display:flex;justify-content:center;align-items:center;width:var(--sys-size-9);height:var(--sys-size-9);border-radius:var(--sys-shape-corner-full);background-image:var(--app-gradient-google-ai);font:var(--sys-typescale-body4-medium);color:var(--ref-palette-neutral100);transition:width 1s,padding 1s;margin-left:auto;overflow:hidden;position:relative;border:0;&:focus-visible{outline:var(--sys-size-2) solid var(--sys-color-state-focus-ring)}&:hover::after,
    &:active::after{content:"";height:100%;width:100%;border-radius:inherit;position:absolute;top:0;left:0}&:hover::after{background-color:var(--sys-color-state-hover-on-prominent)}&:active::after{background-color:var(--sys-color-state-ripple-primary)}devtools-icon{width:var(--sys-size-7);height:var(--sys-size-7);color:var(--ref-palette-neutral100)}.button-text{opacity:0%;transition:opacity 1s}}.global-ai-button.expanded{width:auto;padding:0 var(--sys-size-6) 0 var(--sys-size-5);.button-text{opacity:100%}}}
/*# sourceURL=${import.meta.resolve("././globalAiButton.css")} */`;var{render:Ie,html:ve,Directives:{classMap:we}}=be,y={aiAssistance:"AI assistance",openAiAssistance:"Open AI assistance panel",gemini:"Gemini",openGemini:"Open Gemini panel"},Te=G.i18n.registerUIStrings("entrypoints/main/GlobalAiButton.ts",y),F=G.i18n.getLocalizedString.bind(void 0,Te),Ce=5e3,Re=new Date("2026-09-30");function ie(g){return g.createSetting("global-ai-button-click-count",0,"Synced")}function Ee(g){let e=ie(g);e.set(e.get()+1)}var E;(function(g){g.PROMOTION="promotion",g.DEFAULT="default"})(E||(E={}));var re=(g,e,t)=>{let o=g.state===E.PROMOTION,n=we({"global-ai-button":!0,expanded:o}),r=z.AiUtils.isGeminiBranding()?{title:F(y.openGemini),label:F(y.gemini)}:{title:F(y.openAiAssistance),label:F(y.aiAssistance)},l=z.AiUtils.getIconName();Ie(ve`
    <style>${ne}</style>
    <div class="global-ai-button-container">
      <button class=${n} @click=${g.onClick} title=${r.title} jslog=${se.action().track({click:!0}).context("global-ai-button")}>
        <devtools-icon name=${l}></devtools-icon>
        <span class="button-text">${` ${r.label}`}</span>
      </button>
    </div>
  `,t)},A=class extends T.Widget.Widget{#e;#t=E.DEFAULT;#o=!1;#n;#r;#s;#a;constructor(e,t,o=W.Settings.Settings.instance(),n=T.InspectorView.InspectorView.instance(),r=T.ViewManager.ViewManager.instance()){super(e),this.#e=t??re,this.#r=o,this.#s=n,this.#a=r,this.requestUpdate(),this.#m()&&this.#c()}willHide(){super.willHide(),this.#g(),this.#n&&window.clearTimeout(this.#n)}#l=()=>{this.#o=!0};#i=()=>{this.#o=!1};#u(){this.#s.tabbedPane.headerElement().addEventListener("mouseenter",this.#l),this.#s.tabbedPane.headerElement().addEventListener("mouseleave",this.#i)}#g(){this.#s.tabbedPane.headerElement().removeEventListener("mouseenter",this.#l),this.#s.tabbedPane.headerElement().removeEventListener("mouseleave",this.#i)}#m(){let e=!!$.Runtime.hostConfig.devToolsGlobalAiButton?.promotionEnabled,t=new Date<Re;return e&&t&&ie(this.#r).get()<2}#c(){this.#t=E.PROMOTION,this.requestUpdate(),this.#u(),this.#d()}#d(){this.#n&&window.clearTimeout(this.#n),this.#n=window.setTimeout(()=>{if(this.#o){this.#d();return}this.#t=E.DEFAULT,this.requestUpdate(),this.#g()},Ce)}#h(){this.#a.showViewInLocation("freestyler","drawer-view"),Ee(this.#r);let e=this.#s.isUserExplicitlyUpdatedDrawerOrientation();$.Runtime.hostConfig.devToolsFlexibleLayout?.verticalDrawerEnabled&&!e&&(this.#s.showDrawer({focus:!0,hasTargetDrawer:!1}),this.#s.toggleDrawerOrientation({force:T.InspectorView.DrawerOrientation.VERTICAL}))}performUpdate(){this.#e({state:this.#t,onClick:this.#h.bind(this)},void 0,this.contentElement)}},B=class{#e;#t;constructor(e=W.Settings.Settings.instance(),t=T.InspectorView.InspectorView.instance(),o=T.ViewManager.ViewManager.instance()){this.#t=document.createElement("devtools-widget"),new A(this.#t,void 0,e,t,o),this.#e=new T.Toolbar.ToolbarItemWithCompactLayout(this.#t),this.#e.setVisible(!1)}item(){return this.#e}};var he={};U(he,{ConsoleProfileFinishedListener:()=>V,MainImpl:()=>L,MainMenuItem:()=>Z,PauseListener:()=>P,ReloadActionDelegate:()=>Q,SearchActionDelegate:()=>J,SettingsButtonProvider:()=>Y,ZoomActionDelegate:()=>X,sendOverProtocol:()=>Le});import*as u from"./../../core/common/common.js";import*as i from"./../../core/host/host.js";import*as C from"./../../core/i18n/i18n.js";import*as ce from"./../../core/platform/platform.js";import*as ee from"./../../core/protocol_client/protocol_client.js";import*as c from"./../../core/root/root.js";import*as p from"./../../core/sdk/sdk.js";import*as de from"./../../foundation/foundation.js";import"./../../models/ai_assistance/ai_assistance.js";import*as ge from"./../../models/crux-manager/crux-manager.js";import*as ue from"./../../models/persistence/persistence.js";import*as x from"./../../models/workspace/workspace.js";import*as M from"./../../panels/common/common.js";import*as me from"./../../panels/snippets/snippets.js";import"./../../ui/components/buttons/buttons.js";import*as j from"./../../ui/components/snackbars/snackbars.js";import*as pe from"./../../ui/helpers/helpers.js";import*as O from"./../../ui/legacy/components/utils/utils.js";import*as s from"./../../ui/legacy/legacy.js";import*as H from"./../../ui/legacy/theme_support/theme_support.js";import{html as Me,render as De}from"./../../ui/lit/lit.js";import*as m from"./../../ui/visual_logging/visual_logging.js";var v,h={customizeAndControlDevtools:"Customize and control DevTools",dockSide:"Dock side",placementOfDevtoolsRelativeToThe:"Placement of DevTools relative to the page. ({PH1} to restore last position)",undockIntoSeparateWindow:"Undock into separate window",dockToBottom:"Dock to bottom",dockToRight:"Dock to right",dockToLeft:"Dock to left",focusDebuggee:"Focus page",hideConsoleDrawer:"Hide Console drawer",showConsoleDrawer:"Show Console drawer",moreTools:"More tools",help:"Help",dockSideNavigation:"Use left and right arrow keys to navigate the options",aiModelDownloaded:"AI model downloaded",getDevToolsMcp:"Get `DevTools MCP`"},xe=C.i18n.registerUIStrings("entrypoints/main/MainImpl.ts",h),S=C.i18n.getLocalizedString.bind(void 0,xe),le,ke={register(g){},async get(g){return window.localStorage.getItem(g)},set(g,e){window.localStorage.setItem(g,e)},remove(g){window.localStorage.removeItem(g)},clear:()=>window.localStorage.clear()},q;function ye(){return typeof q>"u"&&(q=window.location.toString().startsWith("devtools://devtools/custom/")),q}var L=class{#e=Promise.withResolvers();#t;#o;#n=!1;constructor(e){v.instanceForTest=this,this.#n=e?.supportsEmulation??!1,this.#r()}static time(e){i.InspectorFrontendHost.isUnderTest()||console.time(e)}static timeEnd(e){i.InspectorFrontendHost.isUnderTest()||console.timeEnd(e)}static get universeForTest(){if(!v.instanceForTest)throw new Error("MainImpl not initialized yet!");return v.instanceForTest.#o}async#r(){console.timeStamp("Main._loaded"),c.Runtime.Runtime.setPlatform(i.Platform.platform());let[e,t]=await Promise.all([new Promise(l=>{i.InspectorFrontendHost.InspectorFrontendHostInstance.getHostConfig(l)}),new Promise(l=>i.InspectorFrontendHost.InspectorFrontendHostInstance.getPreferences(l))]);console.timeStamp("Main._gotPreferences"),this.#s(),Object.assign(c.Runtime.hostConfig,e);let o={settingsCreationOptions:{...this.createSettingsStorage(t),settingRegistrations:u.SettingRegistration.getRegisteredSettings(),logSettingAccess:m.logSettingAccess,runSettingsMigration:!i.InspectorFrontendHost.isUnderTest()},hostConfig:c.Runtime.hostConfig,inspectorFrontendHost:i.InspectorFrontendHost.InspectorFrontendHostInstance,supportsEmulation:this.#n};this.#o=new de.Universe.Universe(o),c.DevToolsContext.setGlobalInstance(this.#o.context),c.Runtime.Runtime.queryParam("hasOtherClients")&&this.#o.settings.moduleSetting("cache-disabled").setRequiresUserAction(!0),c.Runtime.experiments.cleanUpStaleExperiments(),await this.requestAndRegisterLocaleData(),i.userMetrics.syncSetting(u.Settings.Settings.instance().moduleSetting("sync-preferences").get());let n=e.devToolsVeLogging,r=u.Settings.Settings.instance().createSetting("veLogsTestMode",!1).get();if(n?.enabled)if(n?.testing||r){m.setVeDebugLoggingEnabled(!0,"Test");let l={processingThrottler:new u.Throttler.Throttler(0),keyboardLogThrottler:new u.Throttler.Throttler(10),hoverLogThrottler:new u.Throttler.Throttler(50),dragLogThrottler:new u.Throttler.Throttler(50),clickLogThrottler:new u.Throttler.Throttler(10),resizeLogThrottler:new u.Throttler.Throttler(10)};this.#t=m.startLogging(l)}else this.#t=m.startLogging();this.#i()}#s(){self.Extensions||={},self.Host||={},self.Host.userMetrics||=i.userMetrics,self.Host.UserMetrics||=i.UserMetrics,self.ProtocolClient||={},self.ProtocolClient.test||=ee.InspectorBackend.test}async requestAndRegisterLocaleData(){let e=u.Settings.Settings.instance().moduleSetting("language").get(),t=C.DevToolsLocale.DevToolsLocale.instance({create:!0,data:{navigatorLanguage:navigator.language,settingLanguage:e,lookupClosestDevToolsLocale:C.i18n.lookupClosestSupportedDevToolsLocale}});i.userMetrics.language(t.locale),t.locale!=="en-US"&&await C.i18n.fetchAndRegisterLocaleData("en-US");try{await C.i18n.fetchAndRegisterLocaleData(t.locale)}catch(o){console.warn(`Unable to fetch & register locale data for '${t.locale}', falling back to 'en-US'. Cause: `,o),t.forceFallbackLocale()}}createSettingsStorage(e){this.#l();let t="";ye()?t="__custom__":!c.Runtime.Runtime.queryParam("can_dock")&&c.Runtime.Runtime.queryParam("debugFrontend")&&!i.InspectorFrontendHost.isUnderTest()&&(t="__bundled__");let o;!i.InspectorFrontendHost.isUnderTest()&&window.localStorage?o=new u.Settings.SettingsStorage(window.localStorage,ke,t):o=new u.Settings.SettingsStorage({},void 0,t);let n={register:d=>i.InspectorFrontendHost.InspectorFrontendHostInstance.registerPreference(d,{synced:!1}),set:i.InspectorFrontendHost.InspectorFrontendHostInstance.setPreference,get:d=>new Promise(w=>{i.InspectorFrontendHost.InspectorFrontendHostInstance.getPreference(d,w)}),remove:i.InspectorFrontendHost.InspectorFrontendHostInstance.removePreference,clear:i.InspectorFrontendHost.InspectorFrontendHostInstance.clearPreferences},r={...n,register:d=>i.InspectorFrontendHost.InspectorFrontendHostInstance.registerPreference(d,{synced:!0})},l=new u.Settings.SettingsStorage(e,r,t),R=new u.Settings.SettingsStorage(e,n,t);return{syncedStorage:l,globalStorage:R,localStorage:o}}#a(e,t){let o=c.Runtime.experiments.getValueFromStorage(e);o!==void 0&&t.aboutFlag&&(t.setEnabled(o),i.InspectorFrontendHost.InspectorFrontendHostInstance.setChromeFlag(t.aboutFlag,o))}#l(){let e=(c.Runtime.hostConfig.devToolsProtocolMonitor?.enabled??!1)||!!c.Runtime.Runtime.queryParam("isChromeForTesting"),t=c.Runtime.experiments.registerHostExperiment({name:c.ExperimentNames.ExperimentName.PROTOCOL_MONITOR,title:"Protocol Monitor",aboutFlag:"devtools-protocol-monitor",isEnabled:e,requiresChromeRestart:!1,docLink:"https://developer.chrome.com/blog/new-in-devtools-92/#protocol-monitor"});this.#a(c.ExperimentNames.ExperimentName.PROTOCOL_MONITOR,t);let o=c.Runtime.experiments.registerHostExperiment({name:c.ExperimentNames.ExperimentName.INSTRUMENTATION_BREAKPOINTS,title:"Instrumentation breakpoints",aboutFlag:"devtools-instrumentation-breakpoints",isEnabled:c.Runtime.hostConfig.devToolsInstrumentationBreakpoints?.enabled??!1,requiresChromeRestart:!1});this.#a(c.ExperimentNames.ExperimentName.INSTRUMENTATION_BREAKPOINTS,o),c.Runtime.experiments.registerHostExperiment({name:c.ExperimentNames.ExperimentName.DURABLE_MESSAGES,title:"Durable Messages",aboutFlag:"devtools-enable-durable-messages",isEnabled:c.Runtime.hostConfig.devToolsEnableDurableMessages?.enabled??!1,requiresChromeRestart:!1}),c.Runtime.experiments.registerHostExperiment({name:c.ExperimentNames.ExperimentName.JPEG_XL,title:"JPEG XL support",aboutFlag:"enable-jxl-image-format",isEnabled:c.Runtime.hostConfig.devToolsJpegXlImageFormat?.enabled??!1,requiresChromeRestart:!0}),c.Runtime.experiments.registerHostExperiment({name:c.ExperimentNames.ExperimentName.PLUS_BUTTON,title:'Show "+" button on the tab strip for adding tools',aboutFlag:"devtools-plus-button",isEnabled:c.Runtime.hostConfig.devToolsPlusButton?.enabled??!1,requiresChromeRestart:!1});let n=c.Runtime.Runtime.queryParam("enabledExperiments");n&&c.Runtime.experiments.setServerEnabledExperiments(n.split(";"));for(let r of c.Runtime.experiments.allConfigurableExperiments())r.isEnabled()?i.userMetrics.experimentEnabledAtLaunch(r.name):i.userMetrics.experimentDisabledAtLaunch(r.name)}async#i(){v.time("Main._createAppUI");let e=this.#o.isolatedFileSystemManager;e.addEventListener(ue.IsolatedFileSystemManager.Events.FileSystemError,f=>j.Snackbar.Snackbar.show({message:f.data}));let o=u.Settings.Settings.instance().createSetting("ui-theme","systemPreferred");s.UIUtils.initializeUIUtils(document),H.ThemeSupport.hasInstance()||H.ThemeSupport.instance({forceNew:!0,setting:o}),s.UIUtils.addPlatformClass(document.documentElement),s.UIUtils.installComponentRootStyles(document.body),this.#b(document);let n=!!c.Runtime.Runtime.queryParam("can_dock");s.ZoomManager.ZoomManager.instance({forceNew:!0,win:window,frontendHost:i.InspectorFrontendHost.InspectorFrontendHostInstance}),s.ContextMenu.ContextMenu.initialize(),s.ContextMenu.ContextMenu.installHandler(document),s.ViewManager.ViewManager.instance({forceNew:!0,universe:this.#o}),s.DockController.DockController.instance({forceNew:!0,canDock:n});let r=p.TargetManager.TargetManager.instance();r.addEventListener("SuspendStateChanged",this.#I.bind(this)),r.setScopeTarget(r.primaryPageTarget()),s.Context.Context.instance().addFlavorChangeListener(p.Target.Target,({data:f})=>{let b=f?.outermostTarget();r.setScopeTarget(b)}),self.Extensions.extensionServer=M.ExtensionServer.ExtensionServer.instance({forceNew:!0}),e.addPlatformFileSystem("snippet://",new me.ScriptSnippetFileSystem.SnippetFileSystem);let l=new M.PersistenceUtils.LinkDecorator(this.#o.persistence);O.Linkifier.Linkifier.setLinkDecorator(l),new k(r,s.Context.Context.instance()),this.#o.domDebuggerManager.initialize(),this.#o.cpuThrottlingManager.initialize(),this.#o.presentationConsoleMessageManager.enable(),this.#o.liveMetrics.enable(),ge.CrUXManager.instance(),this.#o.builtInAi.addEventListener("downloadedAndSessionCreated",()=>j.Snackbar.Snackbar.show({message:S(h.aiModelDownloaded)})),new P,new V;let d=s.ActionRegistry.ActionRegistry.instance({forceNew:!0});s.ShortcutRegistry.ShortcutRegistry.instance({forceNew:!0,actionRegistry:d}),this.#d(),i.GdpClient.isGdpProfilesAvailable()&&(i.GdpClient.GdpClient.instance().getProfile().then(f=>{if(!f)return;let{profile:b,isEligible:I}=f;m.logFunctionCall("gdp-client-initialize",!!b?"has-profile":I?"no-profile-and-eligible":"no-profile-and-not-eligible")}),this.#o.userBadges.initialize(),this.#o.userBadges.addEventListener("BadgeTriggered",async f=>{le??=await import("./../../panels/common/common.js");let b=new le.BadgeNotification,{badge:I,reason:D}=f.data;b.present(I,D)})),c.Runtime.hostConfig.devToolsGeminiRebranding?.enabled&&await M.GeminiRebrandPromoDialog.maybeShow(),v.timeEnd("Main._createAppUI");let w=s.AppProvider.getRegisteredAppProviders()[0];if(!w)throw new Error("Unable to boot DevTools, as the appprovider is missing");await this.#u(await w.loadAppProvider())}async#u(e){v.time("Main._showAppUI");let t=e.createApp(this.#o);if(s.DockController.DockController.instance().initialize(),H.ThemeSupport.instance().fetchColorsAndApplyHostTheme(),t.presentUI(document),s.ActionRegistry.ActionRegistry.instance().hasAction("elements.toggle-element-search")){let n=s.ActionRegistry.ActionRegistry.instance().getAction("elements.toggle-element-search");i.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(i.InspectorFrontendHostAPI.Events.EnterInspectElementMode,()=>{n.execute()},this)}i.InspectorFrontendHost.InspectorFrontendHostInstance.events.addEventListener(i.InspectorFrontendHostAPI.Events.RevealSourceLine,this.#h,this);let o=s.InspectorView.InspectorView.instance();this.#o.networkPersistenceManager.addEventListener("LocalOverridesRequested",n=>{o.displaySelectOverrideFolderInfobar(n.data)}),await o.createToolbars(),i.InspectorFrontendHost.InspectorFrontendHostInstance.loadCompleted(),s.ARIAUtils.LiveAnnouncer.initializeAnnouncerElements(),s.DockController.DockController.instance().announceDockLocation(),window.setTimeout(this.#g.bind(this),0),v.timeEnd("Main._showAppUI")}async#g(){v.time("Main._initializeTarget");for(let e of u.Runnable.earlyInitializationRunnables())await e().run();await this.#t,i.InspectorFrontendHost.InspectorFrontendHostInstance.readyForTest(),this.#e.resolve(),window.setTimeout(this.#c.bind(this),100),await this.#m(),v.timeEnd("Main._initializeTarget")}async#m(){let e=p.TargetManager.TargetManager.instance().primaryPageTarget(),t=e?.targetInfo()?.url,o=t?u.ParsedURL.ParsedURL.extractOrigin(t):void 0,n="__devtools_ve_inspection_binding__";if(e&&await m.isUnderInspection(o)){let r=e.model(p.RuntimeModel.RuntimeModel);await r?.addBinding({name:n}),r?.addEventListener(p.RuntimeModel.Events.BindingCalled,l=>{l.data.name===n&&(l.data.payload==="true"||l.data.payload==="false"?m.setVeDebuggingEnabled(l.data.payload==="true",R=>{m.setVeDebuggingEnabled(!1),r?.defaultExecutionContext()?.evaluate({expression:`window.inspect(${JSON.stringify(R)})`,includeCommandLineAPI:!1,silent:!0,returnByValue:!1,generatePreview:!1},!1,!1)}):m.setHighlightedVe(l.data.payload==="null"?null:l.data.payload))})}}async#c(){v.time("Main._lateInitialization"),M.ExtensionServer.ExtensionServer.instance().initializeExtensions(),Promise.all(u.Runnable.lateInitializationRunnables().map(async e=>await(await e()).run())),v.timeEnd("Main._lateInitialization")}readyForTest(){return this.#e.promise}#d(){u.Console.Console.instance().addEventListener("messageAdded",e);function e({data:t}){t.show&&u.Console.Console.instance().show()}}#h(e){let{url:t,lineNumber:o,columnNumber:n}=e.data,r=x.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(t);if(r){u.Revealer.reveal(r.uiLocation(o,n));return}function l(R){let d=R.data;d.url()===t&&(u.Revealer.reveal(d.uiLocation(o,n)),x.Workspace.WorkspaceImpl.instance().removeEventListener(x.Workspace.Events.UISourceCodeAdded,l))}x.Workspace.WorkspaceImpl.instance().addEventListener(x.Workspace.Events.UISourceCodeAdded,l)}#f(e){e.handled||s.ShortcutRegistry.ShortcutRegistry.instance().handleShortcut(e)}#p(e){let t=new CustomEvent("clipboard-"+e.type,{bubbles:!0});t.original=e;let o=e.target&&e.target.ownerDocument,n=o?s.DOMUtilities.deepActiveElement(o):null;n&&n.dispatchEvent(t),t.handled&&e.preventDefault()}#S(e){(e.handled||e.target.classList.contains("popup-glasspane"))&&e.preventDefault()}#b(e){e.addEventListener("keydown",this.#f.bind(this),!1),e.addEventListener("beforecopy",this.#p.bind(this),!0),e.addEventListener("copy",this.#p.bind(this),!1),e.addEventListener("cut",this.#p.bind(this),!1),e.addEventListener("paste",this.#p.bind(this),!1),e.addEventListener("contextmenu",this.#S.bind(this),!0)}#I(){let e=p.TargetManager.TargetManager.instance().allTargetsSuspended();s.InspectorView.InspectorView.instance().onSuspendStateChanged(e)}static instanceForTest=null};v=L;globalThis.Main=globalThis.Main||{};globalThis.Main.Main=L;var X=class{handleAction(e,t){if(i.InspectorFrontendHost.InspectorFrontendHostInstance.isHostedMode())return!1;switch(t){case"main.zoom-in":return i.InspectorFrontendHost.InspectorFrontendHostInstance.zoomIn(),!0;case"main.zoom-out":return i.InspectorFrontendHost.InspectorFrontendHostInstance.zoomOut(),!0;case"main.zoom-reset":return i.InspectorFrontendHost.InspectorFrontendHostInstance.resetZoom(),!0}return!1}},J=class{handleAction(e,t){let o=s.SearchableView.SearchableView.fromElement(s.DOMUtilities.deepActiveElement(document));if(!o){let n=s.InspectorView.InspectorView.instance().currentPanelDeprecated();if(n?.searchableView&&(o=n.searchableView()),!o)return!1}switch(t){case"main.search-in-panel.find":return o.handleFindShortcut();case"main.search-in-panel.cancel":return o.handleCancelSearchShortcut();case"main.search-in-panel.find-next":return o.handleFindNextShortcut();case"main.search-in-panel.find-previous":return o.handleFindPreviousShortcut()}return!1}},Z=class{#e;constructor(){this.#e=new s.Toolbar.ToolbarMenuButton(this.#t.bind(this),!0,!0,"main-menu","dots-vertical"),this.#e.element.classList.add("main-menu"),this.#e.setTitle(S(h.customizeAndControlDevtools))}item(){return this.#e}#t(e){let t=s.DockController.DockController.instance();if(t.canDock()){let d=document.createElement("div");d.classList.add("flex-auto","flex-centered","location-menu"),d.setAttribute("jslog",`${m.item("dock-side").track({keydown:"ArrowDown|ArrowLeft|ArrowRight"})}`),d.tabIndex=-1,s.ARIAUtils.setLabel(d,h.dockSide+h.dockSideNavigation);let[w]=s.ShortcutRegistry.ShortcutRegistry.instance().shortcutsForAction("main.toggle-dock");De(Me`
        <span class="dockside-title"
              title=${S(h.placementOfDevtoolsRelativeToThe,{PH1:w.title()})}>
          ${S(h.dockSide)}
        </span>
        <devtools-toolbar @mousedown=${f=>f.consume()}>
          <devtools-button class="toolbar-button"
                           jslog=${m.toggle().track({click:!0}).context("current-dock-state-undock")}
                           title=${S(h.undockIntoSeparateWindow)}
                           aria-label=${S(h.undockIntoSeparateWindow)}
                           .iconName=${"dock-window"}
                           .toggled=${t.dockSide()==="undocked"}
                           .toggledIconName=${"dock-window"}
                           .toggleType=${"primary-toggle"}
                           .variant=${"icon_toggle"}
                           @click=${n.bind(null,"undocked")}></devtools-button>
          <devtools-button class="toolbar-button"
                           jslog=${m.toggle().track({click:!0}).context("current-dock-state-left")}
                           title=${S(h.dockToLeft)}
                           aria-label=${S(h.dockToLeft)}
                           .iconName=${"dock-left"}
                           .toggled=${t.dockSide()==="left"}
                           .toggledIconName=${"dock-left"}
                           .toggleType=${"primary-toggle"}
                           .variant=${"icon_toggle"}
                           @click=${n.bind(null,"left")}></devtools-button>
          <devtools-button class="toolbar-button"
                           jslog=${m.toggle().track({click:!0}).context("current-dock-state-bottom")}
                           title=${S(h.dockToBottom)}
                           aria-label=${S(h.dockToBottom)}
                           .iconName=${"dock-bottom"}
                           .toggled=${t.dockSide()==="bottom"}
                           .toggledIconName=${"dock-bottom"}
                           .toggleType=${"primary-toggle"}
                           .variant=${"icon_toggle"}
                           @click=${n.bind(null,"bottom")}></devtools-button>
          <devtools-button class="toolbar-button"
                           jslog=${m.toggle().track({click:!0}).context("current-dock-state-right")}
                           title=${S(h.dockToRight)}
                           aria-label=${S(h.dockToRight)}
                           .iconName=${"dock-right"}
                           .toggled=${t.dockSide()==="right"}
                           .toggledIconName=${"dock-right"}
                           .toggleType=${"primary-toggle"}
                           .variant=${"icon_toggle"}
                           @click=${n.bind(null,"right")}></devtools-button>
        </devtools-toolbar>
      `,d,{host:this}),d.addEventListener("keydown",f=>{let b=0;if(f.key==="ArrowLeft")b=-1;else if(f.key==="ArrowRight")b=1;else if(f.key==="ArrowDown"){d.closest(".soft-context-menu")?.dispatchEvent(new KeyboardEvent("keydown",{key:"ArrowDown"}));return}else return;let I=Array.from(d.querySelectorAll("devtools-button")),D=I.findIndex(_=>_.hasFocus());D=ce.NumberUtilities.clamp(D+b,0,I.length-1),I[D].focus(),f.consume(!0)}),e.headerSection().appendCustomItem(d,"dock-side")}let o=this.#e.element;function n(d){t.dockSide()!=="undocked"&&d!=="undocked"&&t.once("AfterDockSideChanged").then(()=>o.focus()),t.setDockSide(d),e.discard()}if(e.defaultSection().appendAction("freestyler.main-menu",void 0,!0),e.defaultSection().appendItem(S(h.getDevToolsMcp),()=>{pe.openInNewTab("https://github.com/ChromeDevTools/chrome-devtools-mcp")},{additionalElement:s.UIUtils.maybeCreateNewBadge("get-devtools-mcp"),jslogContext:"get-devtools-mcp"}),e.defaultSection().appendSeparator(),t.dockSide()==="undocked"){let d=p.TargetManager.TargetManager.instance().primaryPageTarget();d&&d.type()===p.Target.Type.FRAME&&e.defaultSection().appendAction("inspector-main.focus-debuggee",S(h.focusDebuggee))}e.defaultSection().appendAction("main.toggle-drawer",s.InspectorView.InspectorView.instance().drawerVisible()?S(h.hideConsoleDrawer):S(h.showConsoleDrawer)),e.appendItemsAtLocation("mainMenu");let r=e.defaultSection().appendSubMenuItem(S(h.moreTools),!1,"more-tools"),l=s.ViewManager.ViewManager.instance().getRegisteredViewExtensions();l.sort((d,w)=>{let f=d.title(),b=w.title();return f.localeCompare(b)});for(let d of l){let w=d.location(),f=d.persistence(),b=d.title(),I=d.viewId();if(I==="issues-pane"){r.defaultSection().appendItem(b,()=>{i.userMetrics.issuesPanelOpenedFrom(3),s.ViewManager.ViewManager.instance().showView("issues-pane",!0)},{jslogContext:I});continue}f==="closeable"&&(w!=="drawer-view"&&w!=="panel"||r.defaultSection().appendItem(b,()=>{s.ViewManager.ViewManager.instance().showView(I,!0,!1)},{isPreviewFeature:d.isPreviewFeature(),jslogContext:I}))}e.footerSection().appendSubMenuItem(S(h.help),!1,"help").appendItemsAtLocation("mainMenuHelp")}},Y=class{#e;constructor(){this.#e=s.Toolbar.Toolbar.createActionButton("settings.show")}item(){return this.#e}},P=class{constructor(){p.TargetManager.TargetManager.instance().addModelListener(p.DebuggerModel.DebuggerModel,p.DebuggerModel.Events.DebuggerPaused,this.#e,this)}#e(e){p.TargetManager.TargetManager.instance().removeModelListener(p.DebuggerModel.DebuggerModel,p.DebuggerModel.Events.DebuggerPaused,this.#e,this);let t=e.data,o=t.debuggerPausedDetails();s.Context.Context.instance().setFlavor(p.Target.Target,t.target()),u.Revealer.reveal(o)}},V=class{constructor(){p.TargetManager.TargetManager.instance().addModelListener(p.CPUProfilerModel.CPUProfilerModel,"ConsoleProfileFinished",this.#e,this)}#e(e){u.Revealer.reveal(e.data)}};function Le(g,e){return new Promise((t,o)=>{let n=ee.InspectorBackend.test.sendRawMessage;if(!n)return o("Unable to send message to test client");n(g,e,(r,...l)=>r?o(r):t(l))})}var Q=class{handleAction(e,t){return t==="main.debug-reload"?(O.Reload.reload(),!0):!1}};var fe={};U(fe,{SimpleApp:()=>N,SimpleAppProvider:()=>te});import*as K from"./../../ui/legacy/legacy.js";var N=class{#e;constructor(e){this.#e=e}presentUI(e){let t=new K.RootView.RootView(this.#e);K.InspectorView.InspectorView.instance().show(t.element),t.attachToDocument(e),t.focus()}},te=class{createApp(e){return new N(e)}};export{oe as ExecutionContextSelector,ae as GlobalAiButton,he as MainImpl,fe as SimpleApp};
//# sourceMappingURL=main.js.map
