import{_ as y,j as p,R as L,O as x,g as f,E as N,I as u}from"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd94578110.js";import{a as R}from"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd9457814.js";import{u as m}from"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd94578119.js";import{c as h}from"./v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd9457817.js";const C=R.lazy(() => __vitePreload(()=>import(chrome.runtime.getURL("content/assets/js/v_7_4_2_19_142f09de-58e9-4005-bc9b-6e38dd94578155.js")),[]));function z({id:t,userID:n,viwerModel:e}){return p.jsx(R.Suspense,{fallback:p.jsx(p.Fragment,{}),children:p.jsx(C,{id:t,userID:n,viwerModel:e})})}const d={useUserLogin:null,useModal:null,useModalOptions:null};function D({useUserLogin:t,useModal:n,useModalOptions:e}){d.useUserLogin=t,d.useModal=n,d.useModalOptions=e}const I=()=>h((t,n)=>({renderView:"list",setRenderView:e=>t({renderView:e}),userID:"",viwerModel:"modal",note:{id:NaN,userID:"",text:"",base64:""},setNote:(e,o)=>t(s=>({note:Object.freeze({...s.note,[e]:o})}))})),_=h()((t,n)=>({container:{},getContainer:e=>{const{container:o}=n();if(o[e])return o[e];{const s=I();return t(a=>({container:{...a.container,[e]:s}})),s}},deleteContainer:e=>t(o=>{const s={...o.container};return delete s[e],{container:s}})})),w=async()=>{const t=await L("notes")||[];S.setState({notes:t})},E=x({createNote:t=>{S.setState(n=>({notes:[t.data,...n.notes]}))},editNote:t=>{S.setState(n=>({notes:n.notes.map(e=>e.id===t.data.id?t.data:e)}))},deleteNote:t=>{S.getState().deleteNote(t.data,!0)},notesBackup:t=>{w()}});chrome.runtime.onMessage.addListener(E);const S=h((t,n)=>({notes:[],createNote:(e,o=!1)=>{const{notes:s}=n(),{language:a}=m.getState(),{user:c}=d.useUserLogin.getState(),{openRendertype:i}=d.useModal.getState(),{getContainer:l}=_.getState(),{note:r,setRenderView:g}=l(e).getState();if(r.text.length<3&&r.base64.length===0){u({type:"Error",message:a.adicioneAnotacaoCom3,position:"top-right"});return}if(!c.estado&&s.length>=3){i("user_free");return}!o&&f("notes",[r,...s]),N({stopPropag:o,action:"createNote",waitForResponse:!1,data:r}),u({type:"Success",message:a.note_add,position:"top-right"}),g("list"),t({notes:[r,...s]})},createNoteSocket:(e,o,s)=>{const{notes:a}=n(),{language:c}=m.getState(),{user:i}=d.useUserLogin.getState(),{openRendertype:l}=d.useModal.getState(),r={id:Date.now(),userID:e,text:o,base64:s};if(!i.estado&&a.length>=3){l("user_free");return}f("notes",[r,...a]),N({stopPropag:!1,action:"createNote",waitForResponse:!1,data:r}),u({type:"Success",message:c.note_add+" via API",position:"top-right"}),t({notes:[r,...a]})},editNote:(e,o=!1)=>{const{notes:s}=n(),{language:a}=m.getState(),{getContainer:c}=_.getState(),{note:i,setRenderView:l}=c(e).getState();if(i.text.length<3&&i.base64.length===0){u({type:"Error",message:a.adicioneAnotacaoCom3,position:"top-right"});return}const r=s.map(g=>g.id===i.id?i:g);!o&&f("notes",r),N({stopPropag:o,action:"editNote",waitForResponse:!1,data:i}),u({type:"Success",message:a.note_add,position:"top-right"}),l("list"),t({notes:r})},deleteNote:(e,o=!1)=>{const{notes:s}=n(),{language:a}=m.getState(),c=s.filter(i=>i.id!==e);!o&&f("notes",c),N({stopPropag:o,action:"deleteNote",waitForResponse:!1,data:e}),u({type:"Success",message:a.note_delete,position:"top-right"}),t({notes:c})},getNotes:e=>{const{notes:o}=n();return o.filter(s=>s.userID===e)}}));w();export{z as N,S as a,d as b,D as s,_ as u};
