function d({ chats: r, emit: l }) {
  const s = (t) => {
    const a = r.value;
    !a || !Array.isArray(a) || a.forEach((i) => {
      i.isSelected = !1, i.dialogs && Array.isArray(i.dialogs) && i.dialogs.forEach((e) => {
        e.isSelected = !1, e.dialogId == t.dialogId && (e.isSelected = !0);
      });
    });
  };
  return {
    selectChat: (t) => {
      const a = r.value;
      if (!a || !Array.isArray(a))
        return;
      a.forEach((e) => {
        e.isSelected = !1, e.dialogs && Array.isArray(e.dialogs) && e.dialogs.forEach((o) => {
          o.isSelected = !1;
        });
      }), t.dialog && s(t.dialog);
      const i = a.find((e) => e.chatId === t.chat.chatId);
      i && (i.isSelected = !0), l("select", t);
    },
    selectDialog: s
  };
}
export {
  d as useChatListSelection
};
