"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 SessionParameters_exports = {};
__export(SessionParameters_exports, {
  SessionParameters: () => SessionParameters
});
module.exports = __toCommonJS(SessionParameters_exports);
var import_SupportedTransportsBitmap = require("#common/SupportedTransportsBitmap.js");
var import_model = require("#model");
var import_SessionIntervals = require("./SessionIntervals.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
function SessionParameters(config) {
  let supportedTransports = config?.supportedTransports;
  if (typeof supportedTransports === "number") {
    supportedTransports = import_SupportedTransportsBitmap.SupportedTransportsSchema.decode(supportedTransports);
  }
  supportedTransports ??= SessionParameters.fallbacks.supportedTransports;
  let maxTcpMessageSize;
  if (supportedTransports.tcpClient || supportedTransports.tcpServer) {
    maxTcpMessageSize = config?.maxTcpMessageSize;
    maxTcpMessageSize ??= SessionParameters.fallbacks.maxTcpMessageSize;
  }
  const sanitizedConfig = { ...config };
  for (const key of Object.keys(sanitizedConfig)) {
    if (sanitizedConfig[key] === void 0) {
      delete sanitizedConfig[key];
    }
  }
  return { ...SessionParameters.fallbacks, ...sanitizedConfig, supportedTransports, maxTcpMessageSize };
}
((SessionParameters2) => {
  SessionParameters2.fallbacks = {
    ...import_SessionIntervals.SessionIntervals.defaults,
    /**
     * Fallback value for Data Model Revision when not provided in Session parameters. We use Matter 1.2 as
     * assumption.
     */
    dataModelRevision: 17,
    /**
     * Fallback value for Interaction Model Revision when not provided in Session parameters. We use Matter 1.2 as
     * assumption.
     */
    interactionModelRevision: 11,
    /**
     * Fallback value for Specification Version when not provided in Session parameters. We use 0 as assumption which is
     * "before 1.3".
     */
    specificationVersion: 0,
    /**
     * Fallback value for the maximum number of paths that can be included in a single invoke message when not provided in
     * Session parameters.
     */
    maxPathsPerInvoke: 1,
    /**
     * No TCP support by default.
     */
    supportedTransports: {},
    maxTcpMessageSize: 64e3
  };
  SessionParameters2.defaults = {
    ...SessionParameters2.fallbacks,
    dataModelRevision: import_model.Specification.DATA_MODEL_REVISION,
    interactionModelRevision: import_model.Specification.INTERACTION_MODEL_REVISION,
    specificationVersion: import_model.Specification.SPECIFICATION_VERSION
  };
})(SessionParameters || (SessionParameters = {}));
//# sourceMappingURL=SessionParameters.js.map
