"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getRooms = void 0;
var _client = require("@xmpp/client");
var _createTimeoutPromise = require("./createTimeoutPromise.xmpp");
const getRooms = async client => {
  let stanzaHdlrPointer;
  const unsubscribe = () => {
    client.off('stanza', stanzaHdlrPointer);
  };
  const responsePromise = new Promise((resolve, reject) => {
    stanzaHdlrPointer = stanza => {};
    client.on('stanza', stanzaHdlrPointer);
    const message = (0, _client.xml)('iq', {
      type: 'get',
      from: client.jid?.toString(),
      id: 'getUserRooms'
    }, (0, _client.xml)('query', {
      xmlns: 'ns:getrooms'
    }));
    client.send(message).catch(err => {
      console.error('Error sending getRooms request:', err);
      unsubscribe();
      reject(err);
    });
    resolve();
  });
  const timeoutPromise = (0, _createTimeoutPromise.createTimeoutPromise)(2000, unsubscribe);
  try {
    return await Promise.race([responsePromise, timeoutPromise]);
  } catch (e) {
    console.error('Error in getRooms:', e);
    return null;
  }
};
exports.getRooms = getRooms;
//# sourceMappingURL=getRooms.xmpp.js.map