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/components/virtual-keyboard/Time/index.tsx
var Time_exports = {};
__export(Time_exports, {
  default: () => Time_default
});
module.exports = __toCommonJS(Time_exports);
var import_react = __toESM(require("react"));
var import__ = __toESM(require("../index"));
var import_index = require("./index.less");
var import_utils = require("./utils");
var import_locales = require("../../../locales");
var import_dayjs = __toESM(require("dayjs"));
var items = [
  {
    value: 1,
    label: "1",
    disabled: false,
    type: "text"
  },
  {
    value: 2,
    label: "2",
    disabled: false,
    type: "text"
  },
  {
    value: 3,
    label: "3",
    disabled: false,
    type: "text"
  },
  {
    value: 4,
    label: "4",
    disabled: false,
    type: "text"
  },
  {
    value: 5,
    label: "5",
    disabled: false,
    type: "text"
  },
  {
    value: 6,
    label: "6",
    disabled: false,
    type: "text"
  },
  {
    value: 7,
    label: "7",
    disabled: false,
    type: "text"
  },
  {
    value: 8,
    label: "8",
    disabled: false,
    type: "text"
  },
  {
    value: 9,
    label: "9",
    disabled: false,
    type: "text"
  },
  {
    value: "now",
    label: (0, import_locales.getText)("virtual-keyboard-time-now"),
    disabled: false,
    type: "text",
    style: { color: "#7f56d9" }
  },
  {
    value: "0",
    label: "0",
    disabled: false,
    type: "text"
  },
  {
    value: "ok",
    label: (0, import_locales.getText)("virtual-keyboard-time-ok"),
    disabled: false,
    type: "primary"
  }
];
var VirtualKeyboardTime = (props) => {
  const { onChange, onEnter, style, className, value = "", rightPanel } = props;
  (0, import_react.useEffect)(() => {
    document.body.id = "body";
  }, []);
  const res = (0, import_react.useMemo)(() => {
    return (0, import_utils.formatStringToTime)(value);
  }, [value]);
  const _onChange = (current) => {
    if (current === "ok") {
      onEnter == null ? void 0 : onEnter((0, import_utils.formatStringToTime)(value));
      return;
    }
    if (current === "now") {
      onEnter == null ? void 0 : onEnter((0, import_dayjs.default)().format("HH:mm"));
      return;
    }
    let _val = res.valueString + current;
    if (res.valueString.length === 4) {
      _val = current + "";
    }
    if (document.querySelector(".virtual-keyboard-input-select")) {
      _val = current + "";
    }
    onChange == null ? void 0 : onChange((0, import_utils.formatStringToTime)(_val));
  };
  return /* @__PURE__ */ import_react.default.createElement(
    import__.default,
    {
      className,
      style,
      keyboardProps: {
        items,
        onChange: (current) => {
          _onChange(current);
        }
      },
      virtualKeyInputProps: {
        value,
        onChange: (e) => {
          onChange == null ? void 0 : onChange((0, import_utils.formatStringToTime)(e.target.value));
        },
        renderInput: () => {
          return res == null ? void 0 : res.previewValueArrayDom;
        }
      },
      rightPanel
    }
  );
};
var Time_default = VirtualKeyboardTime;
