"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 CommissionerMdnsAdvertisement_exports = {};
__export(CommissionerMdnsAdvertisement_exports, {
  CommissionerMdnsAdvertisement: () => CommissionerMdnsAdvertisement
});
module.exports = __toCommonJS(CommissionerMdnsAdvertisement_exports);
var import_general = require("#general");
var import_MdnsConsts = require("#mdns/MdnsConsts.js");
var import_MdnsAdvertisement = require("./MdnsAdvertisement.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class CommissionerMdnsAdvertisement extends import_MdnsAdvertisement.MdnsAdvertisement {
  instanceId;
  constructor(advertiser, description) {
    const instanceId = advertiser.createInstanceId();
    const qname = (0, import_MdnsConsts.getCommissionerDeviceQname)(instanceId);
    super(advertiser, qname, description);
    this.instanceId = instanceId;
  }
  get ptrRecords() {
    const { deviceType, vendorId } = this.description;
    const vendorQname = `_V${vendorId}._sub.${import_MdnsConsts.MATTER_COMMISSIONER_SERVICE_QNAME}`;
    const records = [
      (0, import_general.PtrRecord)(import_MdnsConsts.SERVICE_DISCOVERY_QNAME, import_MdnsConsts.MATTER_COMMISSIONER_SERVICE_QNAME),
      (0, import_general.PtrRecord)(import_MdnsConsts.MATTER_COMMISSIONER_SERVICE_QNAME, vendorQname),
      (0, import_general.PtrRecord)(vendorQname, this.qname)
    ];
    if (deviceType !== void 0) {
      const deviceTypeQname = `_T${deviceType}._sub.${import_MdnsConsts.MATTER_COMMISSIONER_SERVICE_QNAME}`;
      records.push((0, import_general.PtrRecord)(import_MdnsConsts.SERVICE_DISCOVERY_QNAME, deviceTypeQname));
      records.push((0, import_general.PtrRecord)(deviceTypeQname, this.qname));
    }
    return records;
  }
  get txtValues() {
    const { vendorId, productId, deviceType, name: deviceName } = this.description;
    const values = {
      DN: deviceName,
      DT: deviceType
    };
    if (!this.isPrivacyMasked) {
      values.VP = `${vendorId}+${productId}`;
    }
    return values;
  }
  isDuplicate(other) {
    return other.isCommissioning();
  }
}
//# sourceMappingURL=CommissionerMdnsAdvertisement.js.map
