const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
const require_useEngineContext = require("../../../../../hooks/useEngineContext.js");
const require_locales = require("./locales.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
let _pisell_icon_es_ChevronDown = require("@pisell/icon/es/ChevronDown");
_pisell_icon_es_ChevronDown = require_runtime.__toESM(_pisell_icon_es_ChevronDown);
let _pisell_icon_es_UserCircle = require("@pisell/icon/es/UserCircle");
_pisell_icon_es_UserCircle = require_runtime.__toESM(_pisell_icon_es_UserCircle);
require("./index.less");
//#region src/components/eventBooking/components/Voucher/components/Voucher.tsx
const VoucherUI = ({ showDetail, onToggleDetail, isLogin, onLoginClick, availableData, onDiscountChange, mixedSort, code, onCodeChange, onApplyCode, codeDisabled = false }) => {
	var _context$appHelper;
	const utils = ((_context$appHelper = require_useEngineContext.default().appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {};
	(0, react.useEffect)(() => {
		var _utils$storage;
		const locale = (utils === null || utils === void 0 || (_utils$storage = utils.storage) === null || _utils$storage === void 0 ? void 0 : _utils$storage.get("umi_locale")) || "en";
		_pisell_utils.locales.init(require_locales.default, locale);
	}, [utils]);
	const renderLoginCard = () => {
		if (isLogin) return null;
		return /* @__PURE__ */ react.default.createElement("div", { className: "login-card" }, /* @__PURE__ */ react.default.createElement(_pisell_icon_es_UserCircle.default, { style: { fontSize: 28 } }), /* @__PURE__ */ react.default.createElement("div", { className: "text-wrapper" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellText, {
			className: "login-btn",
			onClick: onLoginClick
		}, _pisell_utils.locales.getText("pisell2.voucher.login")), /* @__PURE__ */ react.default.createElement("span", null, " ", _pisell_utils.locales.getText("pisell2.voucher.login-tip"))));
	};
	return /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__event-booking-voucher-container" }, /* @__PURE__ */ react.default.createElement("div", { className: "voucher-title" }, /* @__PURE__ */ react.default.createElement("span", { className: "voucher-title-left" }, _pisell_utils.locales.getText("pisell2.voucher.title")), /* @__PURE__ */ react.default.createElement("span", {
		className: "voucher-title-right",
		onClick: onToggleDetail
	}, _pisell_utils.locales.getText("pisell2.voucher.details"), " ", /* @__PURE__ */ react.default.createElement(_pisell_icon_es_ChevronDown.default, { className: (0, classnames.default)("voucher-right-icon", { show: showDetail }) }))), /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("voucher-detail", { show: showDetail }) }, (availableData === null || availableData === void 0 ? void 0 : availableData.length) > 0 ? /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellGoodPassCard, {
		style: { width: "100%" },
		dataSource: availableData,
		mixedSort,
		onChange: onDiscountChange
	}) : null, renderLoginCard(), /* @__PURE__ */ react.default.createElement("div", { className: "voucher-code-input-wrapper" }, /* @__PURE__ */ react.default.createElement("div", { className: "voucher-code-input" }, /* @__PURE__ */ react.default.createElement("div", { style: { whiteSpace: "nowrap" } }, _pisell_utils.locales.getText("pisell2.voucher.code"), ":"), /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellInput, {
		value: code,
		allowClear: true,
		onChange: (e) => {
			var _e$target;
			onCodeChange((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value);
		},
		size: "small",
		placeholder: _pisell_utils.locales.getText("pisell2.voucher.enter-code")
	})), /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, {
		size: "small",
		disabled: codeDisabled,
		onClick: () => onApplyCode()
	}, _pisell_utils.locales.getText("pisell2.voucher.apply")))));
};
//#endregion
exports.default = VoucherUI;
