content: import { d as _inherits, _ as _createClass, b as _defineProperty, a as _classCallCheck, f as _possibleConstructorReturn, h as _getPrototypeOf, z as _objectWithoutProperties, k as _objectSpread2 } from './reducer-3b554105.js';
  import 'redux';
  import 'immer';
  import './Debug-dbde6e0c.js';
  import 'flatted';
  import './ai-c4b03e09.js';
  import './initialize-c826f47e.js';
  import { C as Client$1 } from './client-48424900.js';
  import React from 'react';
  import PropTypes from 'prop-types';
  
  /**
   * Client
   *
   * boardgame.io React Native client.
   *
   * @param {...object} game - The return value of `Game`.
   * @param {...object} numPlayers - The number of players.
   * @param {...object} board - The React component for the game.
   * @param {...object} loading - (optional) The React component for the loading state.
   * @param {...object} multiplayer - Set to a falsy value or a transportFactory, e.g., SocketIO()
   * @param {...object} enhancer - Optional enhancer to send to the Redux store
   *
   * Returns:
   *   A React Native component that wraps board and provides an
   *   API through props for it to interact with the framework
   *   and dispatch actions such as MAKE_MOVE.
   */
  
  function Client(opts) {
    var _class, _temp;
  
    var game = opts.game,
        numPlayers = opts.numPlayers,
        board = opts.board,
        multiplayer = opts.multiplayer,
        enhancer = opts.enhancer;
    /*
     * WrappedBoard
     *
     * The main React component that wraps the passed in
     * board component and adds the API to its props.
     */
  
    return _temp = _class =
    /*#__PURE__*/
    function (_React$Component) {
      _inherits(WrappedBoard, _React$Component);
  
      function WrappedBoard(props) {
        var _this;
  
        _classCallCheck(this, WrappedBoard);
  
        _this = _possibleConstructorReturn(this, _getPrototypeOf(WrappedBoard).call(this, props));
        _this.client = Client$1({
          game: game,
          numPlayers: numPlayers,
          multiplayer: multiplayer,
          gameID: props.gameID,
          playerID: props.playerID,
          credentials: props.credentials,
          debug: false,
          enhancer: enhancer
        });
        return _this;
      }
  
      _createClass(WrappedBoard, [{
        key: "componentDidMount",
        value: function componentDidMount() {
          var _this2 = this;
  
          this.unsubscribe = this.client.subscribe(function () {
            return _this2.forceUpdate();
          });
          this.client.start();
        }
      }, {
        key: "componentWillUnmount",
        value: function componentWillUnmount() {
          this.client.stop();
          this.unsubscribe();
        }
      }, {
        key: "componentDidUpdate",
        value: function componentDidUpdate(prevProps) {
          if (prevProps.gameID != this.props.gameID) {
            this.client.updateGameID(this.props.gameID);
          }
  
          if (prevProps.playerID != this.props.playerID) {
            this.client.updatePlayerID(this.props.playerID);
          }
  
          if (prevProps.credentials != this.props.credentials) {
            this.client.updateCredentials(this.props.credentials);
          }
        }
      }, {
        key: "render",
        value: function render() {
          var _board = null;
          var state = this.client.getState();
  
          var _this$props = this.props,
              gameID = _this$props.gameID,
              playerID = _this$props.playerID,
              rest = _objectWithoutProperties(_this$props, ["gameID", "playerID"]);
  
          if (board) {
            _board = React.createElement(board, _objectSpread2({}, state, {}, rest, {
              gameID: gameID,
              playerID: playerID,
              isMultiplayer: !!multiplayer,
              moves: this.client.moves,
              events: this.client.events,
              step: this.client.step,
              reset: this.client.reset,
              undo: this.client.undo,
              redo: this.client.redo,
              gameMetadata: this.client.gameMetadata
            }));
          }
  
          return _board;
        }
      }]);
  
      return WrappedBoard;
    }(React.Component), _defineProperty(_class, "propTypes", {
      // The ID of a game to connect to.
      // Only relevant in multiplayer.
      gameID: PropTypes.string,
      // The ID of the player associated with this client.
      // Only relevant in multiplayer.
      playerID: PropTypes.string,
      // This client's authentication credentials.
      // Only relevant in multiplayer.
      credentials: PropTypes.string
    }), _defineProperty(_class, "defaultProps", {
      gameID: 'default',
      playerID: null,
      credentials: null
    }), _temp;
  }
  
  export { Client };
  