"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = require("react");
var _useProps2 = _interopRequireDefault(require("../use-props"));
var _PathPlayBack = _interopRequireDefault(require("./PathPlayBack"));
var _ahooks = require("ahooks");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function PathPlayback(props, ref) {
  var data = props.data,
    play = props.play,
    speed = props.speed,
    show = props.show,
    _props$showStartPoint = props.showStartPoint,
    showStartPoint = _props$showStartPoint === void 0 ? true : _props$showStartPoint,
    _props$showEndPoint = props.showEndPoint,
    showEndPoint = _props$showEndPoint === void 0 ? true : _props$showEndPoint;
  var _useProps = (0, _useProps2["default"])(),
    map = _useProps.map;
  var pathPlayBackRef = (0, _react.useRef)();
  (0, _react.useImperativeHandle)(ref, function () {
    return {
      moveTo: function moveTo(process) {
        pathPlayBackRef.current.moveTo(process);
      },
      cancel: function cancel() {
        pathPlayBackRef.current.cancel();
      }
    };
  }, []);
  (0, _react.useEffect)(function () {
    pathPlayBackRef.current = new _PathPlayBack["default"](_objectSpread(_objectSpread({}, props), {}, {
      map: map
    }));
    return function () {
      pathPlayBackRef.current.destroy();
    };
  }, []);
  (0, _ahooks.useUpdateEffect)(function () {
    pathPlayBackRef.current.loadData(data);
  }, [JSON.stringify(data)]);
  (0, _ahooks.useUpdateEffect)(function () {
    pathPlayBackRef.current.play = play;
  }, [play]);
  (0, _ahooks.useUpdateEffect)(function () {
    pathPlayBackRef.current.speed = speed;
  }, [speed]);
  (0, _ahooks.useUpdateEffect)(function () {
    pathPlayBackRef.current.show = show;
  }, [show]);
  (0, _ahooks.useUpdateEffect)(function () {
    pathPlayBackRef.current.showStartPoint = showStartPoint;
  }, [showStartPoint]);
  (0, _ahooks.useUpdateEffect)(function () {
    pathPlayBackRef.current.showEndPoint = showEndPoint;
  }, [showEndPoint]);
  return null;
}
var _default = exports["default"] = /*#__PURE__*/(0, _react.forwardRef)(PathPlayback);
//# sourceMappingURL=index.js.map
