var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/plus/pisellTopology/components/TopologyFloorMapEditToggle.tsx
var TopologyFloorMapEditToggle_exports = {};
__export(TopologyFloorMapEditToggle_exports, {
  TopologyFloorMapEditToggle: () => TopologyFloorMapEditToggle
});
module.exports = __toCommonJS(TopologyFloorMapEditToggle_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_icons = require("@ant-design/icons");
var import_utils = require("@pisell/utils");
var import_TopologyFloorMapEditToggle = require("./TopologyFloorMapEditToggle.less");
var I18N_EDIT = "pisell-topology.edit-map";
var I18N_DONE = "pisell-topology.edit-map-done";
var I18N_AUTO_ARRANGE = "pisell-topology.auto-arrange";
function TopologyFloorMapEditToggle(props) {
  const {
    mapEditInternal,
    setMapEditInternal,
    floorMapLayoutRef,
    forceEditMode,
    phoneLayout,
    onAutoArrange,
    autoArrangePending
  } = props;
  const editing = forceEditMode || mapEditInternal;
  const label = import_utils.locales.getText(editing ? I18N_DONE : I18N_EDIT);
  const autoArrangeLabel = import_utils.locales.getText(I18N_AUTO_ARRANGE);
  const showAutoArrange = editing && typeof onAutoArrange === "function";
  const handleClick = () => {
    var _a, _b;
    if (editing) {
      (_b = (_a = floorMapLayoutRef.current) == null ? void 0 : _a.saveLayout) == null ? void 0 : _b.call(_a);
      if (!forceEditMode) {
        setMapEditInternal(false);
      }
      return;
    }
    setMapEditInternal(true);
  };
  if (phoneLayout) {
    return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, showAutoArrange ? /* @__PURE__ */ import_react.default.createElement(
      "button",
      {
        type: "button",
        className: "pisell-floor-map-layout-view-controls-tool-btn",
        title: autoArrangeLabel,
        "aria-label": autoArrangeLabel,
        disabled: autoArrangePending,
        onClick: onAutoArrange
      },
      /* @__PURE__ */ import_react.default.createElement(import_icons.ThunderboltOutlined, null)
    ) : null, /* @__PURE__ */ import_react.default.createElement(
      "button",
      {
        type: "button",
        className: editing ? "pisell-floor-map-layout-view-controls-tool-btn pisell-floor-map-layout-view-controls-tool-btn--active" : "pisell-floor-map-layout-view-controls-tool-btn",
        title: label,
        "aria-label": label,
        "aria-pressed": editing,
        onClick: handleClick
      },
      editing ? /* @__PURE__ */ import_react.default.createElement(import_icons.CheckOutlined, null) : /* @__PURE__ */ import_react.default.createElement(import_icons.EditOutlined, null)
    ));
  }
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-topology-floor-map-dock-actions" }, showAutoArrange ? /* @__PURE__ */ import_react.default.createElement(
    import_antd.Button,
    {
      size: "middle",
      icon: /* @__PURE__ */ import_react.default.createElement(import_icons.ThunderboltOutlined, null),
      className: "pisell-topology-floor-map-edit-btn",
      loading: autoArrangePending,
      onClick: onAutoArrange
    },
    autoArrangeLabel
  ) : null, /* @__PURE__ */ import_react.default.createElement(
    import_antd.Button,
    {
      type: "primary",
      size: "middle",
      className: "pisell-topology-floor-map-edit-btn",
      onClick: handleClick
    },
    label
  ));
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  TopologyFloorMapEditToggle
});
