import { ref as o } from "vue";
const s = o([]), x = (t) => {
  const i = o(0), d = s.value.find(({ id: l }) => l == t);
  d != null ? i.value = s.value.indexOf(d) : (s.value.push({
    id: t,
    text: "",
    file: void 0,
    forceSend: !1,
    isRecording: !1
  }), i.value = s.value.length - 1);
  const n = () => {
    s.value[i.value] = {
      id: e().id,
      text: "",
      file: void 0,
      reply: void 0,
      forceSend: !1,
      isRecording: e().isRecording
    };
  }, r = (l) => {
    s.value[i.value] = {
      id: e().id,
      text: l,
      file: e().file,
      reply: e().reply,
      forceSend: !1,
      isRecording: e().isRecording
    };
  }, a = (l) => {
    s.value[i.value] = {
      id: e().id,
      text: e().text,
      file: l,
      reply: e().reply,
      forceSend: !1,
      isRecording: e().isRecording
    };
  }, c = () => {
    s.value[i.value] = {
      id: e().id,
      text: e().text,
      file: void 0,
      reply: e().reply,
      forceSend: !1,
      isRecording: e().isRecording
    };
  }, f = (l) => {
    s.value[i.value] = {
      id: e().id,
      text: e().text,
      file: e().file,
      reply: l,
      forceSend: !1,
      isRecording: e().isRecording
    };
  }, g = () => {
    s.value[i.value] = {
      id: e().id,
      text: e().text,
      file: e().file,
      reply: void 0,
      forceSend: !1,
      isRecording: e().isRecording
    };
  };
  function e() {
    return s.value[i.value];
  }
  return {
    getMessage: e,
    resetMessage: n,
    setMessageFile: a,
    resetMessageFile: c,
    setMessageText: r,
    setReply: f,
    resetReply: g,
    setForceSendMessage: (l) => {
      s.value[i.value].forceSend = l;
    },
    setRecordingMessage: (l) => {
      s.value[i.value].isRecording = l;
    }
  };
};
export {
  x as useMessageDraft
};
