/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { DecodedDataReport } from "#interaction/DecodedDataReport.js";
import { Status, TlvAny } from "#types";
function* InputChunk(input, leftoverAttributeReports) {
  const report = DecodedDataReport(input, leftoverAttributeReports);
  for (const attr of report.attributeReports) {
    yield {
      kind: "attr-value",
      tlv: TlvAny,
      ...attr
    };
  }
  if (report.attributeStatus) {
    for (const attr of report.attributeStatus) {
      yield {
        kind: "attr-status",
        path: attr.path,
        status: attr.status ?? 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: 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 ?? Status.Failure,
          clusterStatus: event.clusterStatus
        };
      }
    }
  }
}
export {
  InputChunk
};
//# sourceMappingURL=InputChunk.js.map
