import{_ as x,I as d}from"./v_7_4_3_26_c99b3fd5-4d99-426a-8862-d508d2f3e0d67.js";import{j as g}from"./v_7_4_3_26_c99b3fd5-4d99-426a-8862-d508d2f3e0d65.js";import{r as y,b as _}from"./v_7_4_3_26_c99b3fd5-4d99-426a-8862-d508d2f3e0d6.js";import{a as C,O as I,u as p,W as m,E as f,b as h}from"./v_7_4_3_26_c99b3fd5-4d99-426a-8862-d508d2f3e0d64.js";const b=y.lazy(() => __vitePreload(()=>import(chrome.runtime.getURL("content/assets/js/v_7_4_3_26_c99b3fd5-4d99-426a-8862-d508d2f3e0d657.js")),[]));function D({id:t,userID:n,viwerModel:e}){return g.jsx(y.Suspense,{fallback:g.jsx(g.Fragment,{}),children:g.jsx(b,{id:t,userID:n,viwerModel:e})})}const S={useModal:null,useModalOptions:null};function F({useModal:t,useModalOptions:n}){S.useModal=t,S.useModalOptions=n}const E=()=>_((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})}))})),w=_()((t,n)=>({container:{},getContainer:e=>{const{container:o}=n();if(o[e])return o[e];{const s=E();return t(a=>({container:{...a.container,[e]:s}})),s}},deleteContainer:e=>t(o=>{const s={...o.container};return delete s[e],{container:s}})})),R=async()=>{const t=await C("notes")||[];N.setState({notes:t})},L=I({createNote:t=>{N.setState(n=>({notes:[t.data,...n.notes]}))},editNote:t=>{N.setState(n=>({notes:n.notes.map(e=>e.id===t.data.id?t.data:e)}))},deleteNote:t=>{N.getState().deleteNote(t.data,!0)},notesBackup:t=>{R()}});chrome.runtime.onMessage.addListener(L);const N=_((t,n)=>({notes:[],createNote:(e,o=!1)=>{const{notes:s}=n(),{language:a}=p.getState(),{session:c}=h.getState(),{openRendertype:i}=S.useModal.getState(),{getContainer:l}=w.getState(),{note:r,setRenderView:u}=l(e).getState();if(r.text.length<3&&r.base64.length===0){d({type:"Error",message:a.adicioneAnotacaoCom3,position:"top-right"});return}if(!c.is_premium&&s.length>=3){i("user_free");return}!o&&m("notes",[r,...s]),f({stopPropag:o,action:"createNote",waitForResponse:!1,data:r}),d({type:"Success",message:a.note_add,position:"top-right"}),u("list"),t({notes:[r,...s]})},createNoteSocket:(e,o,s)=>{const{notes:a}=n(),{language:c}=p.getState(),{session:i}=h.getState(),{openRendertype:l}=S.useModal.getState(),r={id:Date.now(),userID:e,text:o,base64:s};if(!i.is_premium&&a.length>=3){l("user_free");return}m("notes",[r,...a]),f({stopPropag:!1,action:"createNote",waitForResponse:!1,data:r}),d({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}=p.getState(),{getContainer:c}=w.getState(),{note:i,setRenderView:l}=c(e).getState();if(i.text.length<3&&i.base64.length===0){d({type:"Error",message:a.adicioneAnotacaoCom3,position:"top-right"});return}const r=s.map(u=>u.id===i.id?i:u);!o&&m("notes",r),f({stopPropag:o,action:"editNote",waitForResponse:!1,data:i}),d({type:"Success",message:a.note_add,position:"top-right"}),l("list"),t({notes:r})},deleteNote:(e,o=!1)=>{const{notes:s}=n(),{language:a}=p.getState(),c=s.filter(i=>i.id!==e);!o&&m("notes",c),f({stopPropag:o,action:"deleteNote",waitForResponse:!1,data:e}),d({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)}}));R();export{D as N,N as a,S as b,F as s,w as u};
