const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_objectWithoutProperties = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js");
const require_useEngineContext = require("../../../../hooks/useEngineContext.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/walletPassGallery/components/passList/index.tsx
const _excluded = [
	"id",
	"tag",
	"product_title",
	"balance",
	"code",
	"encoded",
	"expire_date",
	"shop",
	"limit_status",
	"product_cover",
	"par_value",
	"unified_available_status",
	"unified_messages",
	"holder"
];
const PassList = (props) => {
	var _context$appHelper;
	const { dataSource = [], value, onChange, valuePropName = "id", hasMore, onLoadMore, loading, onEditHolder } = props;
	const context = require_useEngineContext.default();
	const { isTerminal, isApp } = (context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {};
	const isTerminalEnv = (typeof isTerminal === "function" ? isTerminal() : !!isTerminal) || (isApp === null || isApp === void 0 ? void 0 : isApp());
	const _loadMore = /* @__PURE__ */ react.default.createElement("div", { style: {
		textAlign: "center",
		marginBottom: 12,
		height: 32,
		lineHeight: "32px"
	} }, hasMore ? /* @__PURE__ */ react.default.createElement(antd.Button, {
		onClick: onLoadMore,
		loading
	}, _pisell_utils.locales.getText("wallet-pass-gallery.viewMore")) : /* @__PURE__ */ react.default.createElement("div", { style: { color: "#999" } }, _pisell_utils.locales.getText("wallet-pass-gallery.allLoaded")));
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(antd.List, {
		className: "pisell-wallet-pass-gallery_list",
		itemLayout: "horizontal",
		dataSource,
		split: false,
		loadMore: _loadMore,
		loading,
		renderItem: (item, index) => {
			const { id, tag, product_title = "", balance = 0, code = "", encoded = "", expire_date = "", shop = { name: "" }, limit_status, product_cover = "", par_value = "", unified_available_status, unified_messages = {}, holder } = item, rest = require_objectWithoutProperties._objectWithoutProperties(item, _excluded);
			const itemValue = item === null || item === void 0 ? void 0 : item[valuePropName];
			const { title: disabledReason = "" } = unified_messages;
			const { name: storeName = "" } = shop;
			const isDiscountCard = tag === "product_discount_card";
			return /* @__PURE__ */ react.default.createElement(antd.List.Item, { style: { padding: 0 } }, /* @__PURE__ */ react.default.createElement("div", {
				style: {
					cursor: "pointer",
					width: "100%"
				},
				role: "button",
				onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange(itemValue)
			}, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellWalletPassCard, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, rest), {}, {
				balanceTitle: tag === "good_pass" ? _pisell_utils.locales.getText("wallet-pass-gallery.goodPass") : void 0,
				showDetail: false,
				showRedeem: false,
				showQrCode: true,
				showBalance: !isDiscountCard,
				cover: product_cover,
				disabled: unified_available_status === 0,
				showDisabledReason: unified_available_status === 0,
				disabledReason,
				style: {
					marginBottom: 16,
					width: "100%"
				},
				showBalanceSymbol: !["point_card", "good_pass"].includes(tag),
				active: value === itemValue,
				name: product_title,
				qrCode: code,
				storeName,
				balance: Number(balance),
				discount: isDiscountCard ? Number(par_value) : void 0,
				showDiscount: isDiscountCard,
				code: encoded,
				validDate: expire_date,
				holder,
				onSetHolder: isTerminalEnv ? void 0 : () => {
					var _holder$metadata;
					onEditHolder === null || onEditHolder === void 0 || onEditHolder({
						wallet_pass_detail_id: id,
						customer_id: holder === null || holder === void 0 ? void 0 : holder.customer_id,
						form_id: holder === null || holder === void 0 || (_holder$metadata = holder.metadata) === null || _holder$metadata === void 0 ? void 0 : _holder$metadata.custom_id
					});
				}
			}))));
		}
	}));
};
//#endregion
exports.default = PassList;
