const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_asyncToGenerator = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
const require_index = require("./components/shiftModal/index.js");
const require_ShiftPreview = require("./components/shiftModal/ShiftPreview.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
//#region src/plus/saasAttendance/settings/ShiftScheduleTab.tsx
const ScheduleSetting = (props) => {
	const { value, onChange } = props;
	const [open, setOpen] = (0, react.useState)(false);
	const label = Array.isArray(value) && value.some((d) => {
		var _d$times;
		return d === null || d === void 0 || (_d$times = d.times) === null || _d$times === void 0 ? void 0 : _d$times.length;
	}) ? _pisell_utils.locales.getText("pisell2.attendance.group-settings.shift-schedule.scheduled-shifts.change-shifts") : _pisell_utils.locales.getText("pisell2.attendance.group-settings.shift-schedule.scheduled-shifts.set-shifts");
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(antd.Button, {
		type: "primary",
		onClick: () => setOpen(true)
	}, label), /* @__PURE__ */ react.default.createElement(require_index.default, {
		open,
		value,
		onCancel: () => setOpen(false),
		onOk: (next) => {
			onChange === null || onChange === void 0 || onChange(next);
		}
	}));
};
const ShiftScheduleTab = (props) => {
	return /* @__PURE__ */ react.default.createElement("div", {
		className: "saas-attendance-group-settings__panel",
		id: props.id
	}, /* @__PURE__ */ react.default.createElement("div", { className: "saas-attendance-group-settings__banner banner-blue" }, /* @__PURE__ */ react.default.createElement("div", { className: "banner-icon" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.Icon, {
		type: "pisell2-calendar",
		size: 20
	})), /* @__PURE__ */ react.default.createElement("div", { className: "banner-body" }, /* @__PURE__ */ react.default.createElement("div", { className: "banner-title" }, _pisell_utils.locales.getText("pisell2.attendance.group-settings.shift-schedule.fixed-shifts.title")), /* @__PURE__ */ react.default.createElement("div", { className: "banner-desc" }, _pisell_utils.locales.getText("pisell2.attendance.group-settings.shift-schedule.fixed-shifts.desc")))), /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
		label: _pisell_utils.locales.getText("pisell2.attendance.group-settings.shift-schedule.attendance-type.label"),
		name: ["shift", "type"],
		initialValue: "fixed"
	}, /* @__PURE__ */ react.default.createElement(antd.Radio.Group, { className: "saas-attendance-group-settings__radio-cards" }, /* @__PURE__ */ react.default.createElement("label", { className: "saas-attendance-group-settings__radio-card saas-attendance-group-settings__radio-card--selected" }, /* @__PURE__ */ react.default.createElement(antd.Radio, { value: "fixed" }), /* @__PURE__ */ react.default.createElement("div", { className: "saas-attendance-group-settings__radio-content" }, /* @__PURE__ */ react.default.createElement("div", { className: "saas-attendance-group-settings__radio-title" }, _pisell_utils.locales.getText("pisell2.attendance.group-settings.shift-schedule.attendance-type.scheduled-shifts.title")), /* @__PURE__ */ react.default.createElement("div", { className: "saas-attendance-group-settings__radio-desc" }, _pisell_utils.locales.getText("pisell2.attendance.group-settings.shift-schedule.fixed-shifts.desc")))))), /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
		name: ["shift", "fixed"],
		rules: [{ validator: function() {
			var _ref = require_asyncToGenerator._asyncToGenerator(function* (_rule, value) {
				if (!(Array.isArray(value) && value.some((item) => Array.isArray(item === null || item === void 0 ? void 0 : item.times) && item.times.length > 0))) throw new Error(_pisell_utils.locales.getText("pisell2.attendance.group-settings.shift-schedule.validation.fixed-required"));
			});
			return function validator(_x, _x2) {
				return _ref.apply(this, arguments);
			};
		}() }]
	}, /* @__PURE__ */ react.default.createElement(ScheduleSetting, null)), /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
		noStyle: true,
		shouldUpdate: true
	}, (form) => /* @__PURE__ */ react.default.createElement(require_ShiftPreview.default, { value: form.getFieldValue(["shift", "fixed"]) })));
};
//#endregion
exports.default = ShiftScheduleTab;
