"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.chatAutoEnterer = void 0;
var _roomsSlice = require("../roomStore/roomsSlice");
/** @format */

const chatAutoEnterer = ({
  roomJID,
  wasAutoSelected,
  config,
  dispatch
}) => {
  console.log('🟡 chatAutoEnterer: Called', {
    roomJID,
    wasAutoSelected
  });
  if (roomJID) {
    // If roomJID is already a full JID, use it directly
    // Otherwise, construct it from chatId if needed
    const conferenceDomain = config.xmppSettings?.conference ?? '';
    let finalRoomJID = roomJID;
    if (!roomJID.includes('@') && conferenceDomain) {
      finalRoomJID = `${roomJID}@${conferenceDomain}`;
      console.log('🟡 chatAutoEnterer: Constructed roomJID', finalRoomJID);
    }
    console.log('🟡 chatAutoEnterer: Setting current room', finalRoomJID);
    dispatch((0, _roomsSlice.setCurrentRoom)({
      roomJID: finalRoomJID
    }));
    return;
  }
  console.log('🟡 chatAutoEnterer: No roomJID provided');
  // In React Native, we don't have window.location.search
  // The roomJID should be passed directly via props/config
};
exports.chatAutoEnterer = chatAutoEnterer;
//# sourceMappingURL=chatAutoEnterer.js.map