const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
//#region src/plus/saasAttendance/settings/PermissonTab.tsx
const PermissionField = (props) => {
	var _props$value2;
	(0, react.useEffect)(() => {
		var _props$value;
		if (typeof ((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.member_data_view_range) === "undefined") {
			var _props$onChange;
			(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props.value || {}), {}, { member_data_view_range: ["this_week"] }));
		}
	}, []);
	const options = [
		{
			label: _pisell_utils.locales.getText("pisell2.attendance.group-settings.basic-info.permission.this-week.recommended"),
			value: "this_week"
		},
		{
			label: _pisell_utils.locales.getText("pisell2.attendance.group-settings.basic-info.permission.last-week"),
			value: "last_week"
		},
		{
			label: _pisell_utils.locales.getText("pisell2.attendance.group-settings.basic-info.permission.this-month"),
			value: "this_month"
		}
	];
	const value = (_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2.member_data_view_range;
	const isLimited = Array.isArray(value) && value.length > 0;
	return /* @__PURE__ */ react.default.createElement("div", null, /* @__PURE__ */ react.default.createElement(antd.Radio.Group, {
		value: isLimited ? "limited" : "unlimited",
		onChange: (e) => {
			if (e.target.value === "limited") {
				var _props$onChange2;
				const next = Array.isArray(value) && value.length > 0 ? value : ["this_week"];
				(_props$onChange2 = props.onChange) === null || _props$onChange2 === void 0 || _props$onChange2.call(props, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props.value || {}), {}, { member_data_view_range: next }));
			} else {
				var _props$onChange3;
				(_props$onChange3 = props.onChange) === null || _props$onChange3 === void 0 || _props$onChange3.call(props, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props.value || {}), {}, { member_data_view_range: [] }));
			}
		},
		style: { marginBottom: 8 }
	}, /* @__PURE__ */ react.default.createElement(antd.Radio, { value: "limited" }, _pisell_utils.locales.getText("pisell2.attendance.group-settings.basic-info.permission.limited")), /* @__PURE__ */ react.default.createElement(antd.Radio, { value: "unlimited" }, _pisell_utils.locales.getText("pisell2.attendance.group-settings.basic-info.permission.unlimited"))), isLimited && /* @__PURE__ */ react.default.createElement(antd.Select, {
		mode: "multiple",
		allowClear: true,
		value,
		options,
		onChange: (next) => {
			var _props$onChange4;
			(_props$onChange4 = props.onChange) === null || _props$onChange4 === void 0 || _props$onChange4.call(props, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props.value || {}), {}, { member_data_view_range: next.length > 0 ? next : [] }));
		}
	}));
};
const PermissonTab = (props) => {
	return /* @__PURE__ */ react.default.createElement("div", {
		className: "saas-attendance-group-settings__panel",
		id: props.id
	}, /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
		label: _pisell_utils.locales.getText("pisell2.attendance.group-settings.data-permission.employee-data-view-range"),
		name: "permission"
	}, /* @__PURE__ */ react.default.createElement(PermissionField, null)));
};
//#endregion
exports.default = PermissonTab;
