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(
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
__export(stdin_exports, {
  default: () => stdin_default
});
module.exports = __toCommonJS(stdin_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_loading = __toESM(require("../loading"));
var import_use_touch = require("../hooks/use-touch");
var import_ConfigProviderContext = __toESM(require("../config-provider/ConfigProviderContext"));
var import_utils = require("../utils");
const NumberKeyboardKey = (props) => {
  const {
    type,
    text,
    color,
    wider,
    large,
    loading,
    onPress,
    children
  } = props;
  const {
    prefixCls,
    createNamespace
  } = (0, import_react.useContext)(import_ConfigProviderContext.default);
  const [bem] = createNamespace("key", prefixCls);
  const touch = (0, import_use_touch.useTouch)();
  const [active, setActive] = (0, import_react.useState)(false);
  const CollapseIcon = /* @__PURE__ */ import_react.default.createElement("svg", {
    className: (0, import_classnames.default)(bem("collapse-icon")),
    viewBox: "0 0 30 24"
  }, /* @__PURE__ */ import_react.default.createElement("path", {
    d: "M26 13h-2v2h2v-2zm-8-3h2V8h-2v2zm2-4h2V4h-2v2zm2 4h4V4h-2v4h-2v2zm-7 14 3-3h-6l3 3zM6 13H4v2h2v-2zm16 0H8v2h14v-2zm-12-3h2V8h-2v2zM28 0l1 1 1 1v15l-1 2H1l-1-2V2l1-1 1-1zm0 2H2v15h26V2zM6 4v2H4V4zm10 2h2V4h-2v2zM8 9v1H4V8zm8 0v1h-2V8zm-6-5v2H8V4zm4 0v2h-2V4z",
    fill: "currentColor"
  }));
  const DeleteIcon = /* @__PURE__ */ import_react.default.createElement("svg", {
    className: (0, import_classnames.default)(bem("delete-icon")),
    viewBox: "0 0 32 22"
  }, /* @__PURE__ */ import_react.default.createElement("path", {
    d: "M28 0a4 4 0 0 1 4 4v14a4 4 0 0 1-4 4H10.4a2 2 0 0 1-1.4-.6L1 13.1c-.6-.5-.9-1.3-.9-2 0-1 .3-1.7.9-2.2L9 .6a2 2 0 0 1 1.4-.6zm0 2H10.4l-8.2 8.3a1 1 0 0 0-.3.7c0 .3.1.5.3.7l8.2 8.4H28a2 2 0 0 0 2-2V4c0-1.1-.9-2-2-2zm-5 4a1 1 0 0 1 .7.3 1 1 0 0 1 0 1.4L20.4 11l3.3 3.3c.2.2.3.5.3.7 0 .3-.1.5-.3.7a1 1 0 0 1-.7.3 1 1 0 0 1-.7-.3L19 12.4l-3.4 3.3a1 1 0 0 1-.6.3 1 1 0 0 1-.7-.3 1 1 0 0 1-.3-.7c0-.2.1-.5.3-.7l3.3-3.3-3.3-3.3A1 1 0 0 1 14 7c0-.3.1-.5.3-.7A1 1 0 0 1 15 6a1 1 0 0 1 .6.3L19 9.6l3.3-3.3A1 1 0 0 1 23 6z",
    fill: "currentColor"
  }));
  const onTouchStart = (event) => {
    touch.start(event);
    setActive(true);
  };
  const onTouchMove = (event) => {
    touch.move(event);
    if (touch.direction.current) {
      setActive(false);
    }
  };
  const onTouchEnd = (event) => {
    if (active) {
      if (!children) {
        (0, import_utils.preventDefault)(event);
      }
      setActive(false);
      onPress(String(text), type);
    }
  };
  const renderContent = () => {
    if (loading) {
      return /* @__PURE__ */ import_react.default.createElement(import_loading.default, {
        className: (0, import_classnames.default)(bem("loading-icon"))
      });
    }
    const contentText = children || text;
    switch (type) {
      case "delete":
        return contentText || DeleteIcon;
      case "extra":
        return contentText || CollapseIcon;
      default:
        return contentText;
    }
  };
  return /* @__PURE__ */ import_react.default.createElement("div", {
    className: (0, import_classnames.default)(bem("wrapper", {
      wider
    })),
    onTouchStart,
    onTouchMove,
    onTouchEnd,
    onTouchCancel: onTouchEnd
  }, /* @__PURE__ */ import_react.default.createElement("div", {
    role: "button",
    tabIndex: 0,
    className: (0, import_classnames.default)(bem([color, {
      large,
      active,
      delete: type === "delete"
    }]))
  }, renderContent()));
};
NumberKeyboardKey.defaultProps = {
  color: "",
  wider: false,
  large: false,
  loading: false
};
var stdin_default = NumberKeyboardKey;
