import { _ as _applyDecoratedDescriptor, a as _initializerDefineProperty } from '../_rollupPluginBabelHelpers-9wjJaosZ.js';
import { tracked } from '@glimmer/tracking';
import { helper } from '@ember/component/helper';
import { action } from '@ember/object';
import { scheduleOnce } from '@ember/runloop';

var _class, _descriptor;

/**
 * @param value - initial value to use, undefined if not provided.
 *
 * @returns - Object with a `value` property and `setState` method to set the
 *            `value`
 */
let SingleUseState = (_class = class SingleUseState {
  constructor(value) {
    _initializerDefineProperty(this, "value", _descriptor, this);
    this.value = value;
  }
  setState(value) {
    const updater = () => {
      this.value = value;
    };
    scheduleOnce('afterRender', this, updater);
    return value;
  }
}, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "value", [tracked], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: null
}), _applyDecoratedDescriptor(_class.prototype, "setState", [action], Object.getOwnPropertyDescriptor(_class.prototype, "setState"), _class.prototype)), _class);
function useState([initialValue]) {
  return new SingleUseState(initialValue);
}
var useState$1 = helper(useState);

export { useState$1 as default, useState };
//# sourceMappingURL=use-state.js.map
