import { getFieldAccessor } from './fieldAccessorCache.js';

class ScopedVarsVariable {
  constructor(name, value) {
    this.state = { name, value, type: "scopedvar" };
  }
  getValue(fieldPath) {
    const { value } = this.state;
    return fieldPath ? getFieldAccessor(fieldPath)(value.value) : value.value;
  }
  getValueText() {
    const { value } = this.state;
    if (value.text != null) {
      return String(value.text);
    }
    return String(value);
  }
}
let scopedVarsVariable;
function getSceneVariableForScopedVar(name, value) {
  if (!scopedVarsVariable) {
    scopedVarsVariable = new ScopedVarsVariable(name, value);
  } else {
    scopedVarsVariable.state.name = name;
    scopedVarsVariable.state.value = value;
  }
  return scopedVarsVariable;
}

export { ScopedVarsVariable, getSceneVariableForScopedVar };
//# sourceMappingURL=ScopedVarsVariable.js.map
