var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __decorateClass = (decorators, target, key, kind) => {
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
    if (decorator = decorators[i])
      result = (kind ? decorator(target, key, result) : decorator(result)) || result;
  if (kind && result) __defProp(target, key, result);
  return result;
};
/**
 * @license
 * Copyright 2025-2026 Open Home Foundation
 * SPDX-License-Identifier: Apache-2.0
 */
import "@material/web/button/filled-button";
import { html } from "lit";
import { customElement, state } from "lit/decorators.js";
import { handleAsync } from "../../../util/async-handler.js";
import { BaseClusterCommands } from "../base-cluster-commands.js";
import { registerClusterCommands } from "../registry.js";
const CLUSTER_ID = 8;
let LevelControlClusterCommands = class extends BaseClusterCommands {
  constructor() {
    super(...arguments);
    this._targetLevel = 128;
    this._transitionTime = 0;
    this._executeIfOff = false;
  }
  render() {
    return html`
            <details class="command-panel">
                <summary>Level Control Commands</summary>
                <div class="command-content">
                    <div class="command-row">
                        <label for="targetLevel">Level:</label>
                        <input
                            id="targetLevel"
                            type="number"
                            min="1"
                            max="254"
                            .value=${String(this._targetLevel)}
                            @input=${this._handleTargetLevelChange}
                        />
                        <label for="transitionTime">Transition (0.1s):</label>
                        <input
                            id="transitionTime"
                            type="number"
                            min="0"
                            max="65535"
                            .value=${String(this._transitionTime)}
                            @input=${this._handleTransitionTimeChange}
                        />
                        <label for="executeIfOff">
                            <input
                                id="executeIfOff"
                                type="checkbox"
                                .checked=${this._executeIfOff}
                                @change=${this._handleExecuteIfOffChange}
                            />
                            Execute if Off
                        </label>
                        <md-outlined-button @click=${handleAsync(() => this._handleMoveToLevel())}
                            >MoveToLevel</md-outlined-button
                        >
                        <md-outlined-button @click=${handleAsync(() => this._handleMoveToLevelWithOnOff())}
                            >MoveToLevelWithOnOff</md-outlined-button
                        >
                    </div>
                </div>
            </details>
        `;
  }
  _handleTargetLevelChange(e) {
    const input = e.target;
    let value = parseInt(input.value, 10);
    if (isNaN(value)) value = 1;
    if (value < 1) value = 1;
    if (value > 254) value = 254;
    this._targetLevel = value;
  }
  _handleTransitionTimeChange(e) {
    const input = e.target;
    let value = parseInt(input.value, 10);
    if (isNaN(value)) value = 0;
    if (value < 0) value = 0;
    if (value > 65535) value = 65535;
    this._transitionTime = value;
  }
  _handleExecuteIfOffChange(e) {
    const input = e.target;
    this._executeIfOff = input.checked;
  }
  async _handleMoveToLevel() {
    const optionsMask = this._executeIfOff ? { executeIfOff: true } : {};
    const optionsOverride = this._executeIfOff ? { executeIfOff: true } : {};
    await this.sendCommand("MoveToLevel", {
      level: this._targetLevel,
      transitionTime: this._transitionTime,
      optionsMask,
      optionsOverride
    });
  }
  async _handleMoveToLevelWithOnOff() {
    const optionsMask = this._executeIfOff ? { executeIfOff: true } : {};
    const optionsOverride = this._executeIfOff ? { executeIfOff: true } : {};
    await this.sendCommand("MoveToLevelWithOnOff", {
      level: this._targetLevel,
      transitionTime: this._transitionTime,
      optionsMask,
      optionsOverride
    });
  }
};
__decorateClass([
  state()
], LevelControlClusterCommands.prototype, "_targetLevel", 2);
__decorateClass([
  state()
], LevelControlClusterCommands.prototype, "_transitionTime", 2);
__decorateClass([
  state()
], LevelControlClusterCommands.prototype, "_executeIfOff", 2);
LevelControlClusterCommands = __decorateClass([
  customElement("level-control-cluster-commands")
], LevelControlClusterCommands);
registerClusterCommands(CLUSTER_ID, "level-control-cluster-commands");
//# sourceMappingURL=level-control-commands.js.map
