// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
 * @implements {Common.Runnable}
 */
export class WorkerMainImpl extends Common.Object {
  /**
   * @override
   */
  run() {
    SDK.initMainConnection(() => {
      self.SDK.targetManager.createTarget('main', ls`Main`, SDK.Target.Type.ServiceWorker, null);
    }, Components.TargetDetachedDialog.webSocketConnectionLost);
    new MobileThrottling.NetworkPanelIndicator();
  }
}

SDK.ChildTargetManager.install(async ({target, waitingForDebugger}) => {
  // Only pause the new worker if debugging SW - we are going through the pause on start checkbox.
  if (target.parentTarget() || target.type() !== SDK.Target.Type.ServiceWorker || !waitingForDebugger) {
    return;
  }
  const debuggerModel = target.model(SDK.DebuggerModel);
  if (!debuggerModel) {
    return;
  }
  if (!debuggerModel.isReadyToPause()) {
    await debuggerModel.once(SDK.DebuggerModel.Events.DebuggerIsReadyToPause);
  }
  debuggerModel.pause();
});

@@ -159,16 +159,240 @@
  file.%0A%0A
+import * as Common from '../common/common.js';%0Aimport * as Components from '../components/components.js';%0Aimport * as MobileThrottling from '../mobile_throttling/mobile_throttling.js';%0Aimport * as SDK from '../sdk/sdk.js';%0A%0A
 /**%0A * @
@@ -418,16 +418,25 @@
 Runnable
+.Runnable
 %7D%0A */%0Aex
@@ -482,16 +482,37 @@
 n.Object
+Wrapper.ObjectWrapper
  %7B%0A  /**
@@ -551,16 +551,28 @@
     SDK.
+Connections.
 initMain
@@ -650,30 +650,32 @@
 %60Main%60, SDK.
-Target
+SDKModel
 .Type.Servic
@@ -729,16 +729,37 @@
 dDialog.
+TargetDetachedDialog.
 webSocke
@@ -822,16 +822,38 @@
 ndicator
+.NetworkPanelIndicator
 ();%0A  %7D%0A
@@ -878,16 +878,35 @@
 Manager.
+ChildTargetManager.
 install(
@@ -1099,22 +1099,24 @@
 !== SDK.
-Target
+SDKModel
 .Type.Se
@@ -1223,16 +1223,30 @@
 gerModel
+.DebuggerModel
 );%0A  if 

Migrate worker_main/ to import cross-module