import { localize } from "../../../nls.mjs";
import "../../../base/common/map.mjs";
import { URI } from "../../../base/common/uri.mjs";
import { createDecorator } from "../../instantiation/common/instantiation.mjs";
const IWorkspaceContextService = createDecorator("contextService");
function isSingleFolderWorkspaceIdentifier(obj) {
  const singleFolderIdentifier = obj;
  return typeof (singleFolderIdentifier === null || singleFolderIdentifier === void 0 ? void 0 : singleFolderIdentifier.id) === "string" && URI.isUri(singleFolderIdentifier.uri);
}
function toWorkspaceIdentifier(workspace) {
  if (workspace.configuration) {
    return {
      id: workspace.id,
      configPath: workspace.configuration
    };
  }
  if (workspace.folders.length === 1) {
    return {
      id: workspace.id,
      uri: workspace.folders[0].uri
    };
  }
  return void 0;
}
class WorkspaceFolder {
  constructor(data, raw) {
    this.raw = raw;
    this.uri = data.uri;
    this.index = data.index;
    this.name = data.name;
  }
  toJSON() {
    return { uri: this.uri, name: this.name, index: this.index };
  }
}
const WORKSPACE_EXTENSION = "code-workspace";
[{ name: localize("codeWorkspace", "Code Workspace"), extensions: [WORKSPACE_EXTENSION] }];
export {
  IWorkspaceContextService,
  WORKSPACE_EXTENSION,
  WorkspaceFolder,
  isSingleFolderWorkspaceIdentifier,
  toWorkspaceIdentifier
};
