import { CoreMapboxTransform } from "../../../core/mapbox/Transform";
import { InputCloneMode } from "@polygonjs/polygonjs/dist/src/engine/poly/InputCloneMode";
import { MapboxListenerParamConfig, MapboxListenerSopNode } from "./utils/MapboxListener";
const INPUT_NAMES = ["points to transform in mapbox space"];
import { NodeParamsConfig } from "@polygonjs/polygonjs/dist/src/engine/nodes/utils/params/ParamsConfig";
class MapboxTransformSopParamsConfig extends MapboxListenerParamConfig(NodeParamsConfig) {
}
const ParamsConfig = new MapboxTransformSopParamsConfig();
export class MapboxTransformSopNode extends MapboxListenerSopNode {
  constructor() {
    super(...arguments);
    this.paramsConfig = ParamsConfig;
  }
  static type() {
    return "mapboxTransform";
  }
  static displayedInputNames() {
    return INPUT_NAMES;
  }
  initializeNode() {
    this.io.inputs.setCount(1);
    this.io.inputs.initInputsClonedState(InputCloneMode.FROM_NODE);
  }
  cook(input_contents) {
    if (!this._cameraNode) {
      this.updateMapboxCamera();
      if (!this._cameraNode) {
        this.states.error.set("mapbox camera not found");
        return;
      }
    }
    const core_group = input_contents[0];
    this._transformInput(core_group);
  }
  _transformInput(core_group) {
    if (this._cameraNode) {
      const transformer = new CoreMapboxTransform(this._cameraNode);
      for (let object of core_group.objects()) {
        transformer.transform_group_FINAL(object);
      }
    } else {
      this.states.error.set("no camera node found");
    }
    this.setCoreGroup(core_group);
  }
  _postInitController() {
  }
}
