"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _componentState = _interopRequireDefault(require("../lifecycle/component-state"));

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

var LayerState = function (_ComponentState) {
  (0, _inherits2.default)(LayerState, _ComponentState);

  var _super = _createSuper(LayerState);

  function LayerState(_ref) {
    var _this;

    var attributeManager = _ref.attributeManager,
        layer = _ref.layer;
    (0, _classCallCheck2.default)(this, LayerState);
    _this = _super.call(this, layer);
    _this.attributeManager = void 0;
    _this.needsRedraw = void 0;
    _this.needsUpdate = void 0;
    _this.subLayers = void 0;
    _this.usesPickingColorCache = void 0;
    _this.hasPickingBuffer = void 0;
    _this.changeFlags = void 0;
    _this.viewport = void 0;
    _this.uniformTransitions = void 0;
    _this.propsInTransition = void 0;
    _this.attributeManager = attributeManager;
    _this.needsRedraw = true;
    _this.needsUpdate = true;
    _this.subLayers = null;
    _this.usesPickingColorCache = false;
    return _this;
  }

  var _proto = LayerState.prototype;

  _proto._fetch = function _fetch(propName, url) {
    var layer = this.layer;
    var fetch = layer === null || layer === void 0 ? void 0 : layer.props.fetch;

    if (fetch) {
      return fetch(url, {
        propName: propName,
        layer: layer
      });
    }

    return (0, _get2.default)((0, _getPrototypeOf2.default)(LayerState.prototype), "_fetch", this).call(this, propName, url);
  };

  _proto._onResolve = function _onResolve(propName, value) {
    var layer = this.layer;

    if (layer) {
      var onDataLoad = layer.props.onDataLoad;

      if (propName === 'data' && onDataLoad) {
        onDataLoad(value, {
          propName: propName,
          layer: layer
        });
      }
    }
  };

  _proto._onError = function _onError(propName, error) {
    var layer = this.layer;

    if (layer) {
      layer.raiseError(error, "loading ".concat(propName, " of ").concat(this.layer));
    }
  };

  (0, _createClass2.default)(LayerState, [{
    key: "layer",
    get: function get() {
      return this.component;
    }
  }]);
  return LayerState;
}(_componentState.default);

exports.default = LayerState;
//# sourceMappingURL=layer-state.js.map