import { Registry } from "../../../../platform/registry/common/platform.mjs";
import { Extensions } from "../../../../platform/quickinput/common/quickAccess.mjs";
import { QuickCommandNLS } from "../../../common/standaloneStrings.mjs";
import { ICodeEditorService } from "../../../browser/services/codeEditorService.mjs";
import { AbstractEditorCommandsQuickAccessProvider } from "../../../contrib/quickAccess/browser/commandsQuickAccess.mjs";
import { withNullAsUndefined } from "../../../../base/common/types.mjs";
import { IInstantiationService } from "../../../../platform/instantiation/common/instantiation.mjs";
import { IKeybindingService } from "../../../../platform/keybinding/common/keybinding.mjs";
import { ICommandService } from "../../../../platform/commands/common/commands.mjs";
import { ITelemetryService } from "../../../../platform/telemetry/common/telemetry.mjs";
import { IDialogService } from "../../../../platform/dialogs/common/dialogs.mjs";
import { registerEditorAction, EditorAction } from "../../../browser/editorExtensions.mjs";
import { EditorContextKeys } from "../../../common/editorContextKeys.mjs";
import { IQuickInputService } from "../../../../platform/quickinput/common/quickInput.mjs";
var __decorate = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
    r = Reflect.decorate(decorators, target, key, desc);
  else
    for (var i = decorators.length - 1; i >= 0; i--)
      if (d = decorators[i])
        r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = globalThis && globalThis.__param || function(paramIndex, decorator) {
  return function(target, key) {
    decorator(target, key, paramIndex);
  };
};
var __awaiter = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P, generator) {
  function adopt(value) {
    return value instanceof P ? value : new P(function(resolve) {
      resolve(value);
    });
  }
  return new (P || (P = Promise))(function(resolve, reject) {
    function fulfilled(value) {
      try {
        step(generator.next(value));
      } catch (e) {
        reject(e);
      }
    }
    function rejected(value) {
      try {
        step(generator["throw"](value));
      } catch (e) {
        reject(e);
      }
    }
    function step(result) {
      result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
    }
    step((generator = generator.apply(thisArg, _arguments || [])).next());
  });
};
let StandaloneCommandsQuickAccessProvider = class StandaloneCommandsQuickAccessProvider2 extends AbstractEditorCommandsQuickAccessProvider {
  constructor(instantiationService, codeEditorService, keybindingService, commandService, telemetryService, dialogService) {
    super({ showAlias: false }, instantiationService, keybindingService, commandService, telemetryService, dialogService);
    this.codeEditorService = codeEditorService;
  }
  get activeTextEditorControl() {
    return withNullAsUndefined(this.codeEditorService.getFocusedCodeEditor());
  }
  getCommandPicks() {
    return __awaiter(this, void 0, void 0, function* () {
      return this.getCodeEditorCommandPicks();
    });
  }
};
StandaloneCommandsQuickAccessProvider = __decorate([
  __param(0, IInstantiationService),
  __param(1, ICodeEditorService),
  __param(2, IKeybindingService),
  __param(3, ICommandService),
  __param(4, ITelemetryService),
  __param(5, IDialogService)
], StandaloneCommandsQuickAccessProvider);
Registry.as(Extensions.Quickaccess).registerQuickAccessProvider({
  ctor: StandaloneCommandsQuickAccessProvider,
  prefix: StandaloneCommandsQuickAccessProvider.PREFIX,
  helpEntries: [{ description: QuickCommandNLS.quickCommandHelp, needsEditor: true }]
});
class GotoLineAction extends EditorAction {
  constructor() {
    super({
      id: "editor.action.quickCommand",
      label: QuickCommandNLS.quickCommandActionLabel,
      alias: "Command Palette",
      precondition: void 0,
      kbOpts: {
        kbExpr: EditorContextKeys.focus,
        primary: 59,
        weight: 100
        /* EditorContrib */
      },
      contextMenuOpts: {
        group: "z_commands",
        order: 1
      }
    });
  }
  run(accessor) {
    accessor.get(IQuickInputService).quickAccess.show(StandaloneCommandsQuickAccessProvider.PREFIX);
  }
}
registerEditorAction(GotoLineAction);
export {
  GotoLineAction,
  StandaloneCommandsQuickAccessProvider
};
