import ComponentState from '../lifecycle/component-state';
export default class LayerState extends ComponentState {
  constructor({
    attributeManager,
    layer
  }) {
    super(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;
  }

  get layer() {
    return this.component;
  }

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

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

    return super._fetch(propName, url);
  }

  _onResolve(propName, value) {
    const layer = this.layer;

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

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

  _onError(propName, error) {
    const layer = this.layer;

    if (layer) {
      layer.raiseError(error, `loading ${propName} of ${this.layer}`);
    }
  }

}
//# sourceMappingURL=layer-state.js.map