import _extends from "@babel/runtime/helpers/extends";
import * as React from 'react';
import { useState } from 'react';
import "./index.scss";
// import { Component, createElement, useState, RefObject } from 'react';
// 锦鲤
import { MySlotMachineChild } from "../koi-SlotMachine/index";
// 黄色系列
import { MySlotMachineChild02 } from "../yellow-SlotMachine/index";
import { MySlotMachineChild03 } from "../SlotMachine/index";
import { MySlotMachineChild04 } from "../Purple-SlotMachine/index";
import { MySlotMachineChild05 } from "../blue-SlotMachine/index";
import LuckDrawSucc from "../../common/LuckDrawSucc";
var triger = function triger(koiSlotMachinProps) {
  var data = _extends({}, koiSlotMachinProps);
  // eslint-disable-next-line react-hooks/rules-of-hooks
  var _useState = useState({
      isOpenPrize: false,
      countPrized: 2,
      prizeTextList: {
        icon: 'prize',
        msg: '恭喜您中奖啦!',
        prizeLv: ['特等奖', '冬奥冰墩墩钥匙扣 × 1']
      }
    }),
    state = _useState[0],
    setState = _useState[1];
  var btnState = function btnState(prize, message) {
    var _prize$imgs, _prize$imgs$, _prize$imgs2, _prize$imgs2$;
    console.log('11111', prize);
    // let winMessage;
    // if (prize.imgs && prize.imgs[1].src) {
    //   winMessage = prize.imgs[1].src
    // } else if (prize.imgs && prize.imgs[0].src) {
    //   winMessage = prize.imgs[0].src
    // }
    // console.log("winMessage", winMessage)
    setState({
      countPrized: state.countPrized,
      isOpenPrize: !state.isOpenPrize,
      prizeTextList: {
        icon: prize.imgs && (((_prize$imgs = prize.imgs) === null || _prize$imgs === void 0 ? void 0 : (_prize$imgs$ = _prize$imgs[1]) === null || _prize$imgs$ === void 0 ? void 0 : _prize$imgs$.src) || ((_prize$imgs2 = prize.imgs) === null || _prize$imgs2 === void 0 ? void 0 : (_prize$imgs2$ = _prize$imgs2[0]) === null || _prize$imgs2$ === void 0 ? void 0 : _prize$imgs2$.src)),
        msg: message,
        prizeLv: [prize.fonts && prize.fonts[0].text, '']
      }
    });
  };
  var subtract = function subtract() {
    if (state.countPrized > 0) {
      setState({
        countPrized: --state.countPrized
      });
    }
  };
  var isOpenPrize = state.isOpenPrize,
    prizeTextList = state.prizeTextList,
    countPrized = state.countPrized;
  var trigerType = data.trigerType;
  var renderApp = function renderApp() {
    if (trigerType === 1) {
      return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(MySlotMachineChild, {
        data: data
      }));
    } else if (trigerType === 2) {
      return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(MySlotMachineChild02, {
        data: data,
        btnState: btnState,
        countPrized: countPrized,
        subtract: subtract
      }, /*#__PURE__*/React.createElement(LuckDrawSucc, {
        btnState: btnState,
        prizeTextList: prizeTextList,
        isOpenPrize: isOpenPrize
      })));
    } else if (trigerType === 3) {
      return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(MySlotMachineChild03, {
        data: data,
        btnState: btnState,
        countPrized: countPrized,
        subtract: subtract
      }, /*#__PURE__*/React.createElement(LuckDrawSucc, {
        btnState: btnState,
        prizeTextList: prizeTextList,
        isOpenPrize: isOpenPrize
      })));
    } else if (trigerType === 4) {
      return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(MySlotMachineChild04, {
        data: data
      }));
    } else if (trigerType === 5) {
      return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(MySlotMachineChild05, {
        data: data,
        btnState: btnState,
        countPrized: countPrized,
        subtract: subtract
      }, /*#__PURE__*/React.createElement(LuckDrawSucc, {
        btnState: btnState,
        prizeTextList: prizeTextList,
        isOpenPrize: isOpenPrize
      })));
    }
  };
  return /*#__PURE__*/React.createElement("div", null, renderApp());
};
export default triger;