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/saasAttendance/settings/ClockInMethodTab.tsx
var ClockInMethodTab_exports = {};
__export(ClockInMethodTab_exports, {
  default: () => ClockInMethodTab_default
});
module.exports = __toCommonJS(ClockInMethodTab_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_components = require("./components");
var ClockInMethodTab = (props) => {
  const { form } = props;
  const maxLocations = 200;
  const mapFieldRef = (0, import_react.useRef)(null);
  const defaultValidRangeMeters = import_antd.Form.useWatch(["place", "radius"], form) ?? 100;
  const locations = import_antd.Form.useWatch(["place", "location"], form) ?? [];
  const isMaxLocations = Array.isArray(locations) && locations.length >= maxLocations;
  const openAddLocation = () => {
    var _a;
    if (isMaxLocations) return;
    (_a = mapFieldRef.current) == null ? void 0 : _a.onAddLocation();
  };
  const approvedLocationsLabel = (0, import_react.useMemo)(
    () => import_utils.locales.getText(
      "pisell2.attendance.group-settings.clock-in-method.approved-locations.label"
    )(maxLocations),
    [maxLocations]
  );
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-attendance-group-settings__panel", id: props.id }, /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-attendance-group-settings__banner banner-green" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "banner-icon" }, /* @__PURE__ */ import_react.default.createElement(import_materials.Icon, { type: "pisell2-marker-pin-01", size: 20 })), /* @__PURE__ */ import_react.default.createElement("div", { className: "banner-body" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "banner-title" }, import_utils.locales.getText(
    "pisell2.attendance.group-settings.clock-in-method.gps.title"
  )), /* @__PURE__ */ import_react.default.createElement("div", { className: "banner-desc" }, import_utils.locales.getText(
    "pisell2.attendance.group-settings.clock-in-method.gps.desc"
  )))), /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-attendance-group-settings__section" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-attendance-group-settings__section-head" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-attendance-group-settings__section-title" }, approvedLocationsLabel), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Button,
    {
      type: "primary",
      icon: /* @__PURE__ */ import_react.default.createElement(import_materials.Icon, { type: "pisell2-plus", size: 16 }),
      onClick: openAddLocation,
      disabled: isMaxLocations
    },
    import_utils.locales.getText(
      "pisell2.attendance.group-settings.actions.add-location"
    )
  )), /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { name: ["place", "location"], style: { marginBottom: 0 } }, /* @__PURE__ */ import_react.default.createElement(import_components.MapField, { ref: mapFieldRef, defaultRadius: defaultValidRangeMeters }))), /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-attendance-group-settings__section" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-attendance-group-settings__section-title" }, import_utils.locales.getText(
    "pisell2.attendance.group-settings.clock-in-method.default-valid-range.label"
  )), /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-attendance-group-settings__slider-row" }, /* @__PURE__ */ import_react.default.createElement(
    import_antd.Form.Item,
    {
      name: ["place", "radius"],
      style: { marginBottom: 0, flex: 1 }
    },
    /* @__PURE__ */ import_react.default.createElement(import_antd.Slider, { min: 0, max: 1e3 })
  ), /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-attendance-group-settings__slider-value" }, import_utils.locales.getText(
    "pisell2.attendance.group-settings.clock-in-method.meters"
  )(defaultValidRangeMeters || 0))), /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-attendance-group-settings__help" }, import_utils.locales.getText(
    "pisell2.attendance.group-settings.clock-in-method.default-valid-range.desc"
  ))));
};
var ClockInMethodTab_default = ClockInMethodTab;
