"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var InputChunk_exports = {};
__export(InputChunk_exports, {
  InputChunk: () => InputChunk
});
module.exports = __toCommonJS(InputChunk_exports);
var import_DecodedDataReport = require("#interaction/DecodedDataReport.js");
var import_types = require("#types");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
function* InputChunk(input, leftoverAttributeReports) {
  const report = (0, import_DecodedDataReport.DecodedDataReport)(input, leftoverAttributeReports);
  for (const attr of report.attributeReports) {
    yield {
      kind: "attr-value",
      tlv: import_types.TlvAny,
      ...attr
    };
  }
  if (report.attributeStatus) {
    for (const attr of report.attributeStatus) {
      yield {
        kind: "attr-status",
        path: attr.path,
        status: attr.status ?? import_types.Status.Failure,
        // TODO - attr.status shouldn't be optional?
        clusterStatus: attr.clusterStatus
      };
    }
  }
  for (const event of report.eventReports) {
    for (const occurrence of event.events) {
      yield {
        kind: "event-value",
        path: event.path,
        value: occurrence.data,
        number: occurrence.eventNumber,
        priority: occurrence.priority,
        timestamp: Number(
          // TODO - this may not be useful, need to determine correct form
          occurrence.epochTimestamp ?? occurrence.systemTimestamp ?? occurrence.deltaEpochTimestamp ?? occurrence.deltaSystemTimestamp ?? 0
        ),
        // TODO - temporary, field will be removed
        tlv: import_types.TlvAny
      };
    }
  }
  if (report.eventStatus) {
    for (const event of report.eventStatus) {
      if (event.status !== void 0) {
        yield {
          kind: "event-status",
          path: event.path,
          status: event.status,
          clusterStatus: event.clusterStatus
        };
      }
      if (event.clusterStatus !== void 0) {
        yield {
          kind: "event-status",
          path: event.path,
          status: event.status ?? import_types.Status.Failure,
          clusterStatus: event.clusterStatus
        };
      }
    }
  }
}
//# sourceMappingURL=InputChunk.js.map
