/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { ImplementationError } from "#general";
import { Flow } from "./flow/Flow.js";
class BdxSessionConfiguration {
  #isSender;
  #initMessage;
  #transferConfig;
  #fileDesignator;
  #transferFileDesignator;
  constructor(options) {
    const { isSender, fileDesignator, transferFileDesignator, initMessage } = options;
    this.#fileDesignator = fileDesignator;
    this.#transferFileDesignator = transferFileDesignator ?? fileDesignator;
    this.#isSender = isSender;
    this.#initMessage = initMessage;
    this.#transferConfig = { ...BdxSessionConfiguration.DefaultConfig, ...options };
    const {
      preferredDriverModes = [],
      maxBlockSize,
      maxTransferSize,
      asynchronousTransferAllowed,
      senderStartOffset,
      senderMaxLength
    } = this.#transferConfig;
    if (preferredDriverModes.length === 0) {
      throw new ImplementationError("At least one preferred driver mode must be set.");
    }
    if (maxBlockSize !== void 0 && maxBlockSize <= 0) {
      throw new ImplementationError("Max block size must be greater than 0");
    }
    if (maxTransferSize !== void 0 && maxTransferSize <= 0) {
      throw new ImplementationError("Max transfer size must be greater than 0");
    }
    if (asynchronousTransferAllowed) {
      throw new ImplementationError("Asynchronous transfer is not supported");
    }
    if (!isSender && (senderStartOffset !== void 0 || senderMaxLength !== void 0)) {
      throw new ImplementationError("Sender start offset and sender max length are only supported for senders");
    }
  }
  get isSender() {
    return this.#isSender;
  }
  get initMessage() {
    return this.#initMessage;
  }
  get isInitiator() {
    return this.#initMessage === void 0;
  }
  get fileDesignator() {
    return this.#fileDesignator;
  }
  get transferFileDesignator() {
    return this.#transferFileDesignator;
  }
  get transferConfig() {
    return this.#transferConfig;
  }
}
((BdxSessionConfiguration2) => {
  BdxSessionConfiguration2.DefaultConfig = {
    preferredDriverModes: [
      Flow.DriverMode.SenderDrive,
      // Default if multiple is supported, so lets use this
      Flow.DriverMode.ReceiverDrive
    ],
    asynchronousTransferAllowed: false,
    // Provisional, not supported
    maxTransferSize: 1024 * 1e5
    // 100 MB, lets use that as maximum transfer filesize for now just to protect
  };
})(BdxSessionConfiguration || (BdxSessionConfiguration = {}));
export {
  BdxSessionConfiguration
};
//# sourceMappingURL=BdxSessionConfiguration.js.map
