slot0 = class("GoodsCard")

function slot0.Ctor(slot0, slot1)
	pg.DelegateInfo.New(slot0)

	slot0.go = slot1
	slot0.tr = tf(slot1)
	slot0.mask = slot0.tr:Find("mask")
	slot0.selloutTag = slot0.tr:Find("mask/tag/sellout_tag")
	slot0.levelTag = slot0.tr:Find("mask/tag/level_tag")
	slot0.levelTagText = slot0.tr:Find("mask/tag/level_tag/Text")
	slot0.stars = slot0.tr:Find("item/icon_bg/stars")
	slot0.itemTF = findTF(slot0.tr, "item")
	slot0.nameTxt = findTF(slot0.tr, "item/name_mask/name")
	slot0.discountTF = findTF(slot0.tr, "item/discount")
	slot0.discountTextTF = findTF(slot0.discountTF, "Text"):GetComponent(typeof(Text))
	slot0.countTF = findTF(slot0.tr, "item/consume/contain/Text"):GetComponent(typeof(Text))
	slot0.resIconTF = findTF(slot0.tr, "item/consume/contain/icon"):GetComponent(typeof(Image))
	slot0.itemIconTF = slot0.itemTF:Find("icon_bg/icon"):GetComponent(typeof(Image))
	slot0.itemCountTF = slot0.itemTF:Find("icon_bg/count"):GetComponent(typeof(Text))
	slot0.maskTip = i18n("buy_countLimit")

	onButton(slot0, slot0.mask, function ()
		pg.TipsMgr.GetInstance():ShowTips(uv0.maskTip)
	end, SFX_PANEL)
end

function slot0.setGroupMask(slot0, slot1)
	slot3 = slot0.goodsVO:getConfig("group_limit") > 0 and slot2 <= slot1

	if isActive(slot0.mask) then
		return
	end

	setActive(slot0.mask, slot3)

	if slot2 > 0 and slot2 <= slot1 then
		setActive(slot0.selloutTag, true)
		setActive(slot0.levelTag, false)
	end
end

function slot0.setLevelMask(slot0, slot1)
	slot2 = slot0.goodsVO:getLevelLimit(slot1)
	slot3 = slot0.goodsVO:isLevelLimit(slot1)

	if isActive(slot0.mask) then
		return
	end

	setActive(slot0.mask, slot3)

	if slot3 then
		setText(slot0.levelTagText, tostring(slot2))
		setActive(slot0.levelTag, true)
		setActive(slot0.selloutTag, false)

		slot0.maskTip = i18n("charge_level_limit")
	end
end

function slot0.update(slot0, slot1)
	slot0.goodsVO = slot1

	setActive(slot0.mask, not slot0.goodsVO:canPurchase())

	slot3 = slot1:getConfig("type")

	setActive(slot0.stars, false)

	slot5 = ""

	if slot1:getConfig("effect_args") == "ship_bag_size" then
		updateDrop(slot0.itemTF, {
			count = 1,
			type = DROP_TYPE_ITEM,
			id = Goods.SHIP_BAG_SIZE_ITEM
		})

		slot5 = pg.item_data_statistics[Goods.SHIP_BAG_SIZE_ITEM].name or "??"
	elseif slot4 == "equip_bag_size" then
		updateDrop(slot0.itemTF, {
			count = 1,
			type = DROP_TYPE_ITEM,
			id = Goods.EQUIP_BAG_SIZE_ITEM
		})

		slot5 = pg.item_data_statistics[Goods.EQUIP_BAG_SIZE_ITEM].name or "??"
	elseif slot4 == "commander_bag_size" then
		updateDrop(slot0.itemTF, {
			count = 1,
			type = DROP_TYPE_ITEM,
			id = Goods.COMMANDER_BAG_SIZE_ITEM
		})

		slot5 = pg.item_data_statistics[Goods.COMMANDER_BAG_SIZE_ITEM].name or "??"
	else
		slot6 = {
			type = slot1:getConfig("type"),
			id = slot4[1],
			count = slot1:getConfig("num")
		}

		updateDrop(slot0.itemTF, slot6)

		slot5 = slot6.cfg.name or "??"
	end

	setText(slot0.nameTxt, shortenString(slot5, 6))

	slot6 = ""

	if slot1:getConfig("genre") == ShopArgs.ShoppingStreetLimit then
		slot6 = 100 - slot1.discount .. "%OFF"
		slot7 = slot1:getConfig("resource_num") * slot1.discount / 100
	end

	setActive(slot0.discountTF, false)

	slot0.discountTF = slot1.activityDiscount and findTF(slot0.tr, "item/discount_activity") or findTF(slot0.tr, "item/discount")
	slot0.discountTextTF = findTF(slot0.discountTF, "Text"):GetComponent(typeof(Text))

	setActive(slot0.discountTF, slot1:hasDiscount())

	slot0.discountTextTF.text = slot6
	slot0.countTF.text = math.ceil(slot7)

	GetImageSpriteFromAtlasAsync(pg.item_data_statistics[id2ItemId(slot1:getConfig("resource_type"))].icon, "", tf(slot0.resIconTF))
end

function slot0.dispose(slot0)
	pg.DelegateInfo.Dispose(slot0)
end

return slot0
