const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_hooks = require("../hooks.js");
const require_locales = require("../locales.js");
const require_const = require("./const.js");
const require_index = require("../components/SearchBar/index.js");
const require_index$1 = require("../components/AddCustomerModal/index.js");
const require_index$2 = require("../components/CustomerAndCupModal/index.js");
const require_index$3 = require("../components/SettingModal/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
require("./index.less");
//#region src/components/ecocup/cupProject/index.tsx
const SCAN_LISTENER_KEY = "eco-cup-project-scan-listener";
function EcoCupProject() {
	const language = require_hooks.useLanguage();
	_pisell_utils.locales.init(require_locales.default, language);
	const getApp = require_hooks.useGetApp();
	const addCustomerModal = require_hooks.useModal("ecocup-add-customer-modal");
	const settingModal = require_hooks.useModal("ecocup-setting-modal");
	const customerAndCupModal = require_hooks.useModal("ecocup-customer-and-cup-modal");
	const { goalShopId } = require_hooks.useGetGoalShopInfo();
	const onSearchResult = (result) => {
		console.log("onSearchResult", result);
		if ((result === null || result === void 0 ? void 0 : result.type) === "customer") customerAndCupModal.open({ data: {
			firstType: result === null || result === void 0 ? void 0 : result.type,
			customerData: result === null || result === void 0 ? void 0 : result.data
		} });
		else if ((result === null || result === void 0 ? void 0 : result.type) === "cup") customerAndCupModal.open({ data: {
			firstType: result === null || result === void 0 ? void 0 : result.type,
			cupData: result === null || result === void 0 ? void 0 : result.data
		} });
	};
	const onClickNewCustomer = () => {
		console.log("onClickNewCustomer");
		addCustomerModal.open();
	};
	const onClickSetting = () => {
		console.log("onClickSetting");
		settingModal.open();
	};
	const onClickCustomerList = () => {
		console.log("onClickCustomerList");
		const app = getApp === null || getApp === void 0 ? void 0 : getApp();
		if (goalShopId) {
			var _app$history;
			app === null || app === void 0 || (_app$history = app.history) === null || _app$history === void 0 || _app$history.push(`/ecocup/customer-list?goal_shop_id=${goalShopId}`);
		} else {
			var _app$history2;
			app === null || app === void 0 || (_app$history2 = app.history) === null || _app$history2 === void 0 || _app$history2.push("/ecocup/customer-list");
		}
	};
	const onClickCupList = () => {
		console.log("onClickCupList");
		const app = getApp === null || getApp === void 0 ? void 0 : getApp();
		if (goalShopId) {
			var _app$history3;
			app === null || app === void 0 || (_app$history3 = app.history) === null || _app$history3 === void 0 || _app$history3.push(`/ecocup/cup-list?goal_shop_id=${goalShopId}`);
		} else {
			var _app$history4;
			app === null || app === void 0 || (_app$history4 = app.history) === null || _app$history4 === void 0 || _app$history4.push("/ecocup/cup-list");
		}
	};
	const onClickButton = (key) => {
		switch (key) {
			case "add-new-customer":
				onClickNewCustomer();
				break;
			case "customer-list":
				onClickCustomerList();
				break;
			case "cup-list":
				onClickCupList();
				break;
			case "setting":
				onClickSetting();
				break;
		}
	};
	return /* @__PURE__ */ react.default.createElement("div", { className: "ecocup-cup-project" }, /* @__PURE__ */ react.default.createElement("div", { className: "ecocup-cup-project-title" }, _pisell_utils.locales.getText("pisell2.text.cup-project.title")), /* @__PURE__ */ react.default.createElement("div", { className: "ecocup-cup-project-search-bar" }, /* @__PURE__ */ react.default.createElement(require_index.default, {
		scanListenerKey: SCAN_LISTENER_KEY,
		onSearchResult
	})), /* @__PURE__ */ react.default.createElement("div", { className: "ecocup-cup-project-actions" }, require_const.CUP_PROJECT_FOOTER_BUTTONS.map((button) => /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, {
		key: button.key,
		type: button.type,
		size: "large",
		icon: /* @__PURE__ */ react.default.createElement(_pisell_materials.Icon, {
			type: button.icon,
			size: 32
		}),
		onClick: () => onClickButton(button.key),
		className: "ecocup-cup-project-actions-button"
	}, _pisell_utils.locales.getText(button.languageKey)))), addCustomerModal.visible && /* @__PURE__ */ react.default.createElement(require_index$1.default, addCustomerModal.modalProps), customerAndCupModal.visible && /* @__PURE__ */ react.default.createElement(require_index$2.default, customerAndCupModal.modalProps), settingModal.visible && /* @__PURE__ */ react.default.createElement(require_index$3.default, settingModal.modalProps));
}
//#endregion
exports.default = EcoCupProject;
