From 0b5d29bd6307c95afef198d4986a3e1803e5e167 Mon Sep 17 00:00:00 2001 From: 0xgingi <0xgingi@0xgingi.com> Date: Fri, 15 Nov 2024 11:16:40 -0500 Subject: [PATCH] fix mobile/android notes not showing until refresh/change mode --- .../{index-DhE_q3AR.js => index-B1frYiu1.js} | 4 ++-- ...nit-BjDn5VWt.js => mobileInit-si7He02f.js} | 4 ++-- .../{web-KEPh1bJr.js => web-DYjHHYsn.js} | 2 +- .../{web-BBNafJl7.js => web-DyTx0sUG.js} | 2 +- android/app/src/main/assets/public/index.html | 2 +- .../build.gradle | 12 +++++----- .../cordova.variables.gradle | 2 +- src/components/RichTextEditor.tsx | 3 ++- src/styles/mobile.css | 22 ++++++++++++++++++- 9 files changed, 38 insertions(+), 15 deletions(-) rename android/app/src/main/assets/public/assets/{index-DhE_q3AR.js => index-B1frYiu1.js} (84%) rename android/app/src/main/assets/public/assets/{mobileInit-BjDn5VWt.js => mobileInit-si7He02f.js} (79%) rename android/app/src/main/assets/public/assets/{web-KEPh1bJr.js => web-DYjHHYsn.js} (82%) rename android/app/src/main/assets/public/assets/{web-BBNafJl7.js => web-DyTx0sUG.js} (90%) diff --git a/android/app/src/main/assets/public/assets/index-DhE_q3AR.js b/android/app/src/main/assets/public/assets/index-B1frYiu1.js similarity index 84% rename from android/app/src/main/assets/public/assets/index-DhE_q3AR.js rename to android/app/src/main/assets/public/assets/index-B1frYiu1.js index f74b732..72058b1 100644 --- a/android/app/src/main/assets/public/assets/index-DhE_q3AR.js +++ b/android/app/src/main/assets/public/assets/index-B1frYiu1.js @@ -365,5 +365,5 @@ img.ProseMirror-separator { `,nre="️",rre="‍";let Ld=null,Pd=null;function ire(e){e===void 0&&(e=[]);const t={};wn.groups=t;const n=new wn;Ld==null&&(Ld=Bw(Qne)),Pd==null&&(Pd=Bw(Xne)),oe(n,"'",Mp),oe(n,"{",_u),oe(n,"}",Cu),oe(n,"[",yp),oe(n,"]",Ep),oe(n,"(",vp),oe(n,")",Tp),oe(n,"<",kp),oe(n,">",xp),oe(n,"(",Sp),oe(n,")",wp),oe(n,"「",_p),oe(n,"」",Cp),oe(n,"『",Np),oe(n,"』",Ap),oe(n,"<",Op),oe(n,">",Ip),oe(n,"&",Rp),oe(n,"*",Dp),oe(n,"@",io),oe(n,"`",Pp),oe(n,"^",Bp),oe(n,":",uo),oe(n,",",Tv),oe(n,"$",zp),oe(n,".",Yr),oe(n,"=",Fp),oe(n,"!",kv),oe(n,"-",Kr),oe(n,"%",Hp),oe(n,"|",Up),oe(n,"+",jp),oe(n,"#",$p),oe(n,"?",Wp),oe(n,'"',xv),oe(n,"/",Gr),oe(n,";",Sv),oe(n,"~",Nu),oe(n,"_",Vp),oe(n,"\\",Lp);const r=Zn(n,o0,Ev,{[ly]:!0});Zn(r,o0,r);const i=Zn(n,fs,bi,{[uy]:!0});Zn(i,fs,i);const o=Zn(n,r0,fy,{[cy]:!0});Zn(o,fs),Zn(o,r0,o);const a=Zn(n,Lw,g3,{[Mw]:!0});oe(n,Pw,vv,{[Mw]:!0}),oe(a,Pw),Zn(a,Lw,a);const s=Zn(n,i0,b3,{[m3]:!0});Zn(s,i0,s),oe(s,nre,s);const l=oe(s,rre);Zn(l,i0,s);const u=[[fs,i]],c=[[fs,null],[r0,o]];for(let d=0;dd[0]>f[0]?1:-1);for(let d=0;d=0?h[dy]=!0:fs.test(f)?o0.test(f)?h[ff]=!0:h[uy]=!0:h[ly]=!0,Dw(n,f,f,h)}return Dw(n,"localhost",dc,{ascii:!0}),n.jd=new wn(qp),{start:n,tokens:pl({groups:t},y3)}}function ore(e,t){const n=are(t.replace(/[A-Z]/g,s=>s.toLowerCase())),r=n.length,i=[];let o=0,a=0;for(;a=0&&(d+=n[a].length,f++),u+=n[a].length,o+=n[a].length,a++;o-=d,a-=f,u-=d,i.push({t:c.t,v:t.slice(o-u,o),s:o-u,e:o})}return i}function are(e){const t=[],n=e.length;let r=0;for(;r56319||r+1===n||(o=e.charCodeAt(r+1))<56320||o>57343?e[r]:e.slice(r,r+2);t.push(a),r+=a.length}return t}function Vi(e,t,n,r,i){let o;const a=t.length;for(let s=0;s=0;)o++;if(o>0){t.push(n.join(""));for(let a=parseInt(e.substring(r,r+o),10);a>0;a--)n.pop();r+=o}else n.push(e[r]),r++}return t}const fc={defaultProtocol:"http",events:null,format:zw,formatHref:zw,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function wv(e,t){t===void 0&&(t=null);let n=pl({},fc);e&&(n=pl(n,e instanceof wv?e.o:e));const r=n.ignoreTags,i=[];for(let o=0;on?r.substring(0,n)+"…":r},toFormattedHref(e){return e.get("formatHref",this.toHref(e.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e){return e===void 0&&(e=fc.defaultProtocol),{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get("validate",this.toString(),this)},render(e){const t=this,n=this.toHref(e.get("defaultProtocol")),r=e.get("formatHref",n,this),i=e.get("tagName",n,t),o=this.toFormattedString(e),a={},s=e.get("className",n,t),l=e.get("target",n,t),u=e.get("rel",n,t),c=e.getObj("attributes",n,t),d=e.getObj("events",n,t);return a.href=r,s&&(a.class=s),l&&(a.target=l),u&&(a.rel=u),c&&pl(a,c),{tagName:i,attributes:a,content:o,eventListeners:d}}};function ym(e,t){class n extends E3{constructor(i,o){super(i,o),this.t=e}}for(const r in t)n.prototype[r]=t[r];return n.t=e,n}const Fw=ym("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Hw=ym("text"),sre=ym("nl"),Bd=ym("url",{isLink:!0,toHref(e){return e===void 0&&(e=fc.defaultProtocol),this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){const e=this.tk;return e.length>=2&&e[0].t!==dc&&e[1].t===uo}}),er=e=>new wn(e);function lre(e){let{groups:t}=e;const n=t.domain.concat([Rp,Dp,io,Lp,Pp,Bp,zp,Fp,Kr,Ev,Hp,Up,jp,$p,Gr,qp,Nu,Vp]),r=[Mp,uo,Tv,Yr,kv,Wp,xv,Sv,kp,xp,_u,Cu,Ep,yp,vp,Tp,Sp,wp,_p,Cp,Np,Ap,Op,Ip],i=[Rp,Mp,Dp,Lp,Pp,Bp,zp,Fp,Kr,_u,Cu,Hp,Up,jp,$p,Wp,Gr,qp,Nu,Vp],o=er(),a=oe(o,Nu);xe(a,i,a),xe(a,t.domain,a);const s=er(),l=er(),u=er();xe(o,t.domain,s),xe(o,t.scheme,l),xe(o,t.slashscheme,u),xe(s,i,a),xe(s,t.domain,s);const c=oe(s,io);oe(a,io,c),oe(l,io,c),oe(u,io,c);const d=oe(a,Yr);xe(d,i,a),xe(d,t.domain,a);const f=er();xe(c,t.domain,f),xe(f,t.domain,f);const p=oe(f,Yr);xe(p,t.domain,f);const h=er(Fw);xe(p,t.tld,h),xe(p,t.utld,h),oe(c,dc,h);const m=oe(f,Kr);xe(m,t.domain,f),xe(h,t.domain,f),oe(h,Yr,p),oe(h,Kr,m);const y=oe(h,uo);xe(y,t.numeric,Fw);const b=oe(s,Kr),E=oe(s,Yr);xe(b,t.domain,s),xe(E,i,a),xe(E,t.domain,s);const v=er(Bd);xe(E,t.tld,v),xe(E,t.utld,v),xe(v,t.domain,s),xe(v,i,a),oe(v,Yr,E),oe(v,Kr,b),oe(v,io,c);const k=oe(v,uo),_=er(Bd);xe(k,t.numeric,_);const x=er(Bd),I=er();xe(x,n,x),xe(x,r,I),xe(I,n,x),xe(I,r,I),oe(v,Gr,x),oe(_,Gr,x);const R=oe(l,uo),z=oe(u,uo),A=oe(z,Gr),j=oe(A,Gr);xe(l,t.domain,s),oe(l,Yr,E),oe(l,Kr,b),xe(u,t.domain,s),oe(u,Yr,E),oe(u,Kr,b),xe(R,t.domain,x),oe(R,Gr,x),xe(j,t.domain,x),xe(j,n,x),oe(j,Gr,x);const L=[[_u,Cu],[yp,Ep],[vp,Tp],[kp,xp],[Sp,wp],[_p,Cp],[Np,Ap],[Op,Ip]];for(let U=0;U=0&&f++,i++,c++;if(f<0)i-=c,i0&&(o.push(a0(Hw,t,a)),a=[]),i-=f,c-=f;const p=d.t,h=n.slice(i-c,i);o.push(a0(p,t,h))}}return a.length>0&&o.push(a0(Hw,t,a)),o}function a0(e,t,n){const r=n[0].s,i=n[n.length-1].e,o=t.slice(r,i);return new e(o,n)}const cre=typeof console<"u"&&console&&console.warn||(()=>{}),dre="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",st={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function fre(){wn.groups={},st.scanner=null,st.parser=null,st.tokenQueue=[],st.pluginQueue=[],st.customSchemes=[],st.initialized=!1}function Uw(e,t){if(t===void 0&&(t=!1),st.initialized&&cre(`linkifyjs: already initialized - will not register custom scheme "${e}" ${dre}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw new Error(`linkifyjs: incorrect scheme format. 1. Must only contain digits, lowercase ASCII letters or "-" 2. Cannot start or end with "-" -3. "-" cannot repeat`);st.customSchemes.push([e,t])}function pre(){st.scanner=ire(st.customSchemes);for(let e=0;e{const i=t.some(u=>u.docChanged)&&!n.doc.eq(r.doc),o=t.some(u=>u.getMeta("preventAutolink"));if(!i||o)return;const{tr:a}=r,s=jee(n.doc,[...t]);if(Xee(s).forEach(({newRange:u})=>{const c=Wee(r.doc,u,p=>p.isTextblock);let d,f;if(c.length>1?(d=c[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ")):c.length&&r.doc.textBetween(u.from,u.to," "," ").endsWith(" ")&&(d=c[0],f=r.doc.textBetween(d.pos,u.to,void 0," ")),d&&f){const p=f.split(" ").filter(b=>b!=="");if(p.length<=0)return!1;const h=p[p.length-1],m=d.pos+f.lastIndexOf(h);if(!h)return!1;const y=v3(h).map(b=>b.toObject(e.defaultProtocol));if(!hre(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:m+b.start+1,to:m+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>e.validate(b.value)).forEach(b=>{mv(b.from,b.to,r.doc).some(E=>E.mark.type===e.type)||a.addMark(b.from,b.to,e.type.create({href:b.href}))})}}),!!a.steps.length)return a}})}function gre(e){return new Qt({key:new Xn("handleClickLink"),props:{handleClick:(t,n,r)=>{var i,o;if(r.button!==0||!t.editable)return!1;let a=r.target;const s=[];for(;a.nodeName!=="DIV";)s.push(a),a=a.parentNode;if(!s.find(f=>f.nodeName==="A"))return!1;const l=a3(t.state,e.type.name),u=r.target,c=(i=u==null?void 0:u.href)!==null&&i!==void 0?i:l.href,d=(o=u==null?void 0:u.target)!==null&&o!==void 0?o:l.target;return u&&c?(window.open(c,d),!0):!1}}})}function bre(e){return new Qt({key:new Xn("handlePasteLink"),props:{handlePaste:(t,n,r)=>{const{state:i}=t,{selection:o}=i,{empty:a}=o;if(a)return!1;let s="";r.content.forEach(u=>{s+=u.textContent});const l=T3(s,{defaultProtocol:e.defaultProtocol}).find(u=>u.isLink&&u.value===s);return!s||!l?!1:(e.editor.commands.setMark(e.type,{href:l.href}),!0)}}})}const yre=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function jw(e,t){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!e||e.replace(yre,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Ere=si.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.protocols.forEach(e=>{if(typeof e=="string"){Uw(e);return}Uw(e.scheme,e.optionalSlashes)})},onDestroy(){fre()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:e=>!!e}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{const t=e.getAttribute("href");return!t||!jw(t,this.options.protocols)?!1:null}}]},renderHTML({HTMLAttributes:e}){return jw(e.href,this.options.protocols)?["a",Nt(this.options.HTMLAttributes,e),0]:["a",Nt(this.options.HTMLAttributes,{...e,href:""}),0]},addCommands(){return{setLink:e=>({chain:t})=>t().setMark(this.name,e).setMeta("preventAutolink",!0).run(),toggleLink:e=>({chain:t})=>t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Bo({find:e=>{const t=[];if(e){const{validate:n}=this.options,r=T3(e).filter(i=>i.isLink&&n(i.value));r.length&&r.forEach(i=>t.push({text:i.value,data:{href:i.href},index:i.start}))}return t},type:this.type,getAttributes:e=>{var t;return{href:(t=e.data)===null||t===void 0?void 0:t.href}}})]},addProseMirrorPlugins(){const e=[];return this.options.autolink&&e.push(mre({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:this.options.validate})),this.options.openOnClick===!0&&e.push(gre({type:this.type})),this.options.linkOnPaste&&e.push(bre({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),e}}),vre=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Tre=kr.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:e}){return["img",Nt(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[s3({find:vre,type:this.type,getAttributes:e=>{const[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),kre=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,xre=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Sre=si.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",Nt(this.options.HTMLAttributes,e),0]},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[ja({find:kre,type:this.type})]},addPasteRules(){return[Bo({find:xre,type:this.type})]}});function wre({content:e,onChange:t}){const n=Yte({extensions:[Gne,Ere.configure({openOnClick:!1}),Tre,c3,Sre],content:e,onUpdate:({editor:r})=>{t(r.getHTML())}});return n?T.jsxs(se,{style:{display:"flex",flexDirection:"column",height:"100%"},children:[T.jsxs(it,{mb:"xs",wrap:"nowrap",children:[T.jsx(Qe,{label:"Bold",children:T.jsx(ze,{variant:n.isActive("bold")?"filled":"subtle",onClick:()=>n.chain().focus().toggleBold().run(),children:T.jsx(eF,{size:16})})}),T.jsx(Qe,{label:"Italic",children:T.jsx(ze,{variant:n.isActive("italic")?"filled":"subtle",onClick:()=>n.chain().focus().toggleItalic().run(),children:T.jsx(cF,{size:16})})}),T.jsx(Qe,{label:"Heading 1",children:T.jsx(ze,{variant:n.isActive("heading",{level:1})?"filled":"subtle",onClick:()=>n.chain().focus().toggleHeading({level:1}).run(),children:T.jsx(sF,{size:16})})}),T.jsx(Qe,{label:"Heading 2",children:T.jsx(ze,{variant:n.isActive("heading",{level:2})?"filled":"subtle",onClick:()=>n.chain().focus().toggleHeading({level:2}).run(),children:T.jsx(lF,{size:16})})}),T.jsx(Qe,{label:"Heading 3",children:T.jsx(ze,{variant:n.isActive("heading",{level:3})?"filled":"subtle",onClick:()=>n.chain().focus().toggleHeading({level:3}).run(),children:T.jsx(uF,{size:16})})}),T.jsx(Qe,{label:"Bullet List",children:T.jsx(ze,{variant:n.isActive("bulletList")?"filled":"subtle",onClick:()=>n.chain().focus().toggleBulletList().run(),children:T.jsx(fF,{size:16})})}),T.jsx(Qe,{label:"Numbered List",children:T.jsx(ze,{variant:n.isActive("orderedList")?"filled":"subtle",onClick:()=>n.chain().focus().toggleOrderedList().run(),children:T.jsx(dF,{size:16})})}),T.jsx(Qe,{label:"Blockquote",children:T.jsx(ze,{variant:n.isActive("blockquote")?"filled":"subtle",onClick:()=>n.chain().focus().toggleBlockquote().run(),children:T.jsx(pF,{size:16})})}),T.jsx(Qe,{label:"Code Block",children:T.jsx(ze,{variant:n.isActive("codeBlock")?"filled":"subtle",onClick:()=>n.chain().focus().toggleCodeBlock().run(),children:T.jsx(oF,{size:16})})}),T.jsx(Qe,{label:"Clear Formatting",children:T.jsx(ze,{variant:"subtle",onClick:()=>n.chain().focus().clearNodes().unsetAllMarks().run(),children:T.jsx(iF,{size:16})})})]}),T.jsx(se,{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",border:"1px solid var(--mantine-color-gray-3)",borderRadius:"var(--mantine-radius-md)",padding:"1rem",overflow:"auto",minHeight:0},children:T.jsx(Bte,{editor:n,style:{flex:"1 1 auto",display:"flex",flexDirection:"column",height:"100%"}})})]}):null}function _re({content:e}){const t=e.trim()?e.trim().split(/\s+/).length:0,n=e.length,r=Math.ceil(t/200);return T.jsxs(it,{gap:"xs",children:[T.jsxs(qt,{size:"xs",c:"dimmed",children:[t," words"]}),T.jsx(qt,{size:"xs",c:"dimmed",children:"·"}),T.jsxs(qt,{size:"xs",c:"dimmed",children:[n," characters"]}),T.jsx(qt,{size:"xs",c:"dimmed",children:"·"}),T.jsxs(qt,{size:"xs",c:"dimmed",children:[r," min read"]})]})}function Cre({content:e,onChange:t,isMobile:n,defaultView:r="edit",editorType:i="markdown"}){const[o,a]=S.useState(n?"edit":r),[s,l]=S.useState(i),u=()=>s==="richtext"?T.jsx(wre,{content:e,onChange:t}):T.jsx(bE,{value:e,onChange:f=>t(f.currentTarget.value),styles:{root:{height:"100%"},wrapper:{height:"100%"},input:{height:"100%",padding:"1rem",fontSize:n?"16px":void 0,borderRadius:"var(--mantine-radius-md)",border:"1px solid var(--mantine-color-gray-3)",backgroundColor:"var(--mantine-color-body)",transition:"border-color 100ms ease","&:focus":{borderColor:"var(--mantine-color-blue-filled)",outline:"none"},"&:hover":{borderColor:"var(--mantine-color-gray-5)"}}}}),c=()=>T.jsx(se,{className:"markdown-preview",p:"md",style:{height:"100%",overflow:"auto"},children:T.jsx(Rj,{remarkPlugins:[$W],rehypePlugins:[tK,CQ],children:e})}),d=()=>{if(n)return o==="edit"?u():c();switch(o){case"preview":return c();case"split":return T.jsxs(it,{grow:!0,style:{height:"100%"},children:[u(),c()]});default:return u()}};return T.jsxs(se,{style:{height:"100%",display:"flex",flexDirection:"column"},children:[T.jsxs(it,{justify:"space-between",mb:"xs",children:[T.jsx(_re,{content:e}),T.jsx(it,{children:n?T.jsx(ze,{variant:o==="edit"?"filled":"subtle",onClick:()=>a(o==="edit"?"preview":"edit"),children:o==="edit"?T.jsx(Fk,{size:16}):T.jsx(zk,{size:16})}):T.jsxs(T.Fragment,{children:[T.jsx(Qe,{label:"Markdown",children:T.jsx(ze,{variant:s==="markdown"&&o==="edit"?"filled":"subtle",onClick:()=>{l("markdown"),a("edit")},children:T.jsx(zk,{size:16})})}),T.jsx(Qe,{label:"Rich Text",children:T.jsx(ze,{variant:s==="richtext"&&o==="edit"?"filled":"subtle",onClick:()=>{l("richtext"),a("edit")},children:T.jsx(hF,{size:16})})}),T.jsx(Qe,{label:"Preview",children:T.jsx(ze,{variant:o==="preview"?"filled":"subtle",onClick:()=>a("preview"),children:T.jsx(Fk,{size:16})})}),T.jsx(Qe,{label:"Split View",children:T.jsx(ze,{variant:o==="split"?"filled":"subtle",onClick:()=>a("split"),children:T.jsx(aF,{size:16})})})]})})]}),d()]})}function Nre(e){let t=e,n=!1;const r=new Set;return{getState(){return t},updateState(i){t=typeof i=="function"?i(t):i},setState(i){this.updateState(i),r.forEach(o=>o(t))},initialize(i){n||(t=i,n=!0)},subscribe(i){return r.add(i),()=>r.delete(i)}}}function Are(e,t,n){const r=[],i=[],o={};for(const a of e){const s=a.position||t;o[s]=o[s]||0,o[s]+=1,o[s]<=n?i.push(a):r.push(a)}return{notifications:i,queue:r}}const Ore=()=>Nre({notifications:[],queue:[],defaultPosition:"bottom-right",limit:5}),Wc=Ore();function Ol(e,t){const n=e.getState(),r=t([...n.notifications,...n.queue]),i=Are(r,n.defaultPosition,n.limit);e.setState({notifications:i.notifications,queue:i.queue,limit:n.limit,defaultPosition:n.defaultPosition})}function Ire(e,t=Wc){const n=e.id||g1();return Ol(t,r=>e.id&&r.some(i=>i.id===e.id)?r:[...r,{...e,id:n}]),n}function Rre(e,t=Wc){return Ol(t,n=>n.filter(r=>{var i;return r.id===e?((i=r.onClose)==null||i.call(r,r),!1):!0})),e}function Mre(e,t=Wc){return Ol(t,n=>n.map(r=>r.id===e.id?{...r,...e}:r)),e.id}function Dre(e=Wc){Ol(e,()=>[])}function Lre(e=Wc){Ol(e,t=>t.slice(0,e.getState().limit))}const Qr={show:Ire,hide:Rre,update:Mre,clean:Dre,cleanQueue:Lre,updateState:Ol};var fi={},Oo={},Ci={},Jn={};Object.defineProperty(Jn,"__esModule",{value:!0});Jn.isBytes=x3;Jn.number=Yp;Jn.bool=k3;Jn.bytes=_v;Jn.hash=S3;Jn.exists=w3;Jn.output=_3;function Yp(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function k3(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function x3(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function _v(e,...t){if(!x3(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function S3(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Yp(e.outputLen),Yp(e.blockLen)}function w3(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function _3(e,t){_v(e);const n=t.outputLen;if(e.lengthnew Uint8Array(L.buffer,L.byteOffset,L.byteLength);e.u8=i;const o=L=>new Uint32Array(L.buffer,L.byteOffset,Math.floor(L.byteLength/4));e.u32=o;const a=L=>new DataView(L.buffer,L.byteOffset,L.byteLength);e.createView=a;const s=(L,U)=>L<<32-U|L>>>U;e.rotr=s;const l=(L,U)=>L<>>32-U>>>0;e.rotl=l,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const u=L=>L<<24&4278190080|L<<8&16711680|L>>>8&65280|L>>>24&255;e.byteSwap=u,e.byteSwapIfBE=e.isLE?L=>L:L=>(0,e.byteSwap)(L);function c(L){for(let U=0;UU.toString(16).padStart(2,"0"));function f(L){(0,n.bytes)(L);let U="";for(let V=0;V=p._0&&L<=p._9)return L-p._0;if(L>=p._A&&L<=p._F)return L-(p._A-10);if(L>=p._a&&L<=p._f)return L-(p._a-10)}function m(L){if(typeof L!="string")throw new Error("hex string expected, got "+typeof L);const U=L.length,V=U/2;if(U%2)throw new Error("padded hex string expected, got unpadded hex of length "+U);const H=new Uint8Array(V);for(let B=0,M=0;B{};e.nextTick=y;async function b(L,U,V){let H=Date.now();for(let B=0;B=0&&ML().update(v(H)).digest(),V=L();return U.outputLen=V.outputLen,U.blockLen=V.blockLen,U.create=()=>L(),U}function z(L){const U=(H,B)=>L(B).update(v(H)).digest(),V=L({});return U.outputLen=V.outputLen,U.blockLen=V.blockLen,U.create=H=>L(H),U}function A(L){const U=(H,B)=>L(B).update(v(H)).digest(),V=L({});return U.outputLen=V.outputLen,U.blockLen=V.blockLen,U.create=H=>L(H),U}function j(L=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(L));if(t.crypto&&typeof t.crypto.randomBytes=="function")return t.crypto.randomBytes(L);throw new Error("crypto.getRandomValues must be defined")}})(Ja);Object.defineProperty(Ci,"__esModule",{value:!0});Ci.HashMD=Ci.Maj=Ci.Chi=void 0;const s0=Jn,Ql=Ja;function Bre(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),a=Number(n>>i&o),s=Number(n&o),l=r?4:0,u=r?0:4;e.setUint32(t+l,a,r),e.setUint32(t+u,s,r)}const zre=(e,t,n)=>e&t^~e&n;Ci.Chi=zre;const Fre=(e,t,n)=>e&t^e&n^t&n;Ci.Maj=Fre;class Hre extends Ql.Hash{constructor(t,n,r,i){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,Ql.createView)(this.buffer)}update(t){(0,s0.exists)(this);const{view:n,buffer:r,blockLen:i}=this;t=(0,Ql.toBytes)(t);const o=t.length;for(let a=0;ai-a&&(this.process(r,0),a=0);for(let d=a;dc.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d>>3,m=(0,tr.rotr)(p,17)^(0,tr.rotr)(p,19)^p>>>10;Yi[d]=m+Yi[d-7]+h+Yi[d-16]|0}let{A:r,B:i,C:o,D:a,E:s,F:l,G:u,H:c}=this;for(let d=0;d<64;d++){const f=(0,tr.rotr)(s,6)^(0,tr.rotr)(s,11)^(0,tr.rotr)(s,25),p=c+f+(0,l0.Chi)(s,l,u)+Ure[d]+Yi[d]|0,m=((0,tr.rotr)(r,2)^(0,tr.rotr)(r,13)^(0,tr.rotr)(r,22))+(0,l0.Maj)(r,i,o)|0;c=u,u=l,l=s,s=a+p|0,a=o,o=i,i=r,r=p+m|0}r=r+this.A|0,i=i+this.B|0,o=o+this.C|0,a=a+this.D|0,s=s+this.E|0,l=l+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,i,o,a,s,l,u,c)}roundClean(){Yi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}Oo.SHA256=Cv;class jre extends Cv{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}Oo.sha256=(0,tr.wrapConstructor)(()=>new Cv);Oo.sha224=(0,tr.wrapConstructor)(()=>new jre);var It={},Ee={};Object.defineProperty(Ee,"__esModule",{value:!0});Ee.add5L=Ee.add5H=Ee.add4H=Ee.add4L=Ee.add3H=Ee.add3L=Ee.rotlBL=Ee.rotlBH=Ee.rotlSL=Ee.rotlSH=Ee.rotr32L=Ee.rotr32H=Ee.rotrBL=Ee.rotrBH=Ee.rotrSL=Ee.rotrSH=Ee.shrSL=Ee.shrSH=Ee.toBig=void 0;Ee.fromBig=Nv;Ee.split=C3;Ee.add=U3;const zd=BigInt(2**32-1),my=BigInt(32);function Nv(e,t=!1){return t?{h:Number(e&zd),l:Number(e>>my&zd)}:{h:Number(e>>my&zd)|0,l:Number(e&zd)|0}}function C3(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;iBigInt(e>>>0)<>>0);Ee.toBig=N3;const A3=(e,t,n)=>e>>>n;Ee.shrSH=A3;const O3=(e,t,n)=>e<<32-n|t>>>n;Ee.shrSL=O3;const I3=(e,t,n)=>e>>>n|t<<32-n;Ee.rotrSH=I3;const R3=(e,t,n)=>e<<32-n|t>>>n;Ee.rotrSL=R3;const M3=(e,t,n)=>e<<64-n|t>>>n-32;Ee.rotrBH=M3;const D3=(e,t,n)=>e>>>n-32|t<<64-n;Ee.rotrBL=D3;const L3=(e,t)=>t;Ee.rotr32H=L3;const P3=(e,t)=>e;Ee.rotr32L=P3;const B3=(e,t,n)=>e<>>32-n;Ee.rotlSH=B3;const z3=(e,t,n)=>t<>>32-n;Ee.rotlSL=z3;const F3=(e,t,n)=>t<>>64-n;Ee.rotlBH=F3;const H3=(e,t,n)=>e<>>64-n;Ee.rotlBL=H3;function U3(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}const j3=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0);Ee.add3L=j3;const $3=(e,t,n,r)=>t+n+r+(e/2**32|0)|0;Ee.add3H=$3;const W3=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);Ee.add4L=W3;const V3=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0;Ee.add4H=V3;const q3=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0);Ee.add5L=q3;const Y3=(e,t,n,r,i,o)=>t+n+r+i+o+(e/2**32|0)|0;Ee.add5H=Y3;const $re={fromBig:Nv,split:C3,toBig:N3,shrSH:A3,shrSL:O3,rotrSH:I3,rotrSL:R3,rotrBH:M3,rotrBL:D3,rotr32H:L3,rotr32L:P3,rotlSH:B3,rotlSL:z3,rotlBH:F3,rotlBL:H3,add:U3,add3L:j3,add3H:$3,add4L:W3,add4H:V3,add5H:Y3,add5L:q3};Ee.default=$re;Object.defineProperty(It,"__esModule",{value:!0});It.sha384=It.sha512_256=It.sha512_224=It.sha512=It.SHA384=It.SHA512_256=It.SHA512_224=It.SHA512=void 0;const Wre=Ci,Se=Ee,vm=Ja,[Vre,qre]=Se.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Ki=new Uint32Array(80),Gi=new Uint32Array(80);class Vc extends Wre.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:n,Bh:r,Bl:i,Ch:o,Cl:a,Dh:s,Dl:l,Eh:u,El:c,Fh:d,Fl:f,Gh:p,Gl:h,Hh:m,Hl:y}=this;return[t,n,r,i,o,a,s,l,u,c,d,f,p,h,m,y]}set(t,n,r,i,o,a,s,l,u,c,d,f,p,h,m,y){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=i|0,this.Ch=o|0,this.Cl=a|0,this.Dh=s|0,this.Dl=l|0,this.Eh=u|0,this.El=c|0,this.Fh=d|0,this.Fl=f|0,this.Gh=p|0,this.Gl=h|0,this.Hh=m|0,this.Hl=y|0}process(t,n){for(let v=0;v<16;v++,n+=4)Ki[v]=t.getUint32(n),Gi[v]=t.getUint32(n+=4);for(let v=16;v<80;v++){const k=Ki[v-15]|0,_=Gi[v-15]|0,x=Se.default.rotrSH(k,_,1)^Se.default.rotrSH(k,_,8)^Se.default.shrSH(k,_,7),I=Se.default.rotrSL(k,_,1)^Se.default.rotrSL(k,_,8)^Se.default.shrSL(k,_,7),R=Ki[v-2]|0,z=Gi[v-2]|0,A=Se.default.rotrSH(R,z,19)^Se.default.rotrBH(R,z,61)^Se.default.shrSH(R,z,6),j=Se.default.rotrSL(R,z,19)^Se.default.rotrBL(R,z,61)^Se.default.shrSL(R,z,6),L=Se.default.add4L(I,j,Gi[v-7],Gi[v-16]),U=Se.default.add4H(L,x,A,Ki[v-7],Ki[v-16]);Ki[v]=U|0,Gi[v]=L|0}let{Ah:r,Al:i,Bh:o,Bl:a,Ch:s,Cl:l,Dh:u,Dl:c,Eh:d,El:f,Fh:p,Fl:h,Gh:m,Gl:y,Hh:b,Hl:E}=this;for(let v=0;v<80;v++){const k=Se.default.rotrSH(d,f,14)^Se.default.rotrSH(d,f,18)^Se.default.rotrBH(d,f,41),_=Se.default.rotrSL(d,f,14)^Se.default.rotrSL(d,f,18)^Se.default.rotrBL(d,f,41),x=d&p^~d&m,I=f&h^~f&y,R=Se.default.add5L(E,_,I,qre[v],Gi[v]),z=Se.default.add5H(R,b,k,x,Vre[v],Ki[v]),A=R|0,j=Se.default.rotrSH(r,i,28)^Se.default.rotrBH(r,i,34)^Se.default.rotrBH(r,i,39),L=Se.default.rotrSL(r,i,28)^Se.default.rotrBL(r,i,34)^Se.default.rotrBL(r,i,39),U=r&o^r&s^o&s,V=i&a^i&l^a&l;b=m|0,E=y|0,m=p|0,y=h|0,p=d|0,h=f|0,{h:d,l:f}=Se.default.add(u|0,c|0,z|0,A|0),u=s|0,c=l|0,s=o|0,l=a|0,o=r|0,a=i|0;const H=Se.default.add3L(A,L,V);r=Se.default.add3H(H,z,j,U),i=H|0}({h:r,l:i}=Se.default.add(this.Ah|0,this.Al|0,r|0,i|0)),{h:o,l:a}=Se.default.add(this.Bh|0,this.Bl|0,o|0,a|0),{h:s,l}=Se.default.add(this.Ch|0,this.Cl|0,s|0,l|0),{h:u,l:c}=Se.default.add(this.Dh|0,this.Dl|0,u|0,c|0),{h:d,l:f}=Se.default.add(this.Eh|0,this.El|0,d|0,f|0),{h:p,l:h}=Se.default.add(this.Fh|0,this.Fl|0,p|0,h|0),{h:m,l:y}=Se.default.add(this.Gh|0,this.Gl|0,m|0,y|0),{h:b,l:E}=Se.default.add(this.Hh|0,this.Hl|0,b|0,E|0),this.set(r,i,o,a,s,l,u,c,d,f,p,h,m,y,b,E)}roundClean(){Ki.fill(0),Gi.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}It.SHA512=Vc;class K3 extends Vc{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}It.SHA512_224=K3;class G3 extends Vc{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}It.SHA512_256=G3;class Q3 extends Vc{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}It.SHA384=Q3;It.sha512=(0,vm.wrapConstructor)(()=>new Vc);It.sha512_224=(0,vm.wrapConstructor)(()=>new K3);It.sha512_256=(0,vm.wrapConstructor)(()=>new G3);It.sha384=(0,vm.wrapConstructor)(()=>new Q3);var Tm={},X3={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=Jn,n=Ja;class r extends n.Hash{constructor(a,s){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(a);const l=(0,n.toBytes)(s);if(this.iHash=a.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const u=this.blockLen,c=new Uint8Array(u);c.set(l.length>u?a.create().update(l).digest():l);for(let d=0;dnew r(o,a).update(s).digest();e.hmac=i,e.hmac.create=(o,a)=>new r(o,a)})(X3);Object.defineProperty(Tm,"__esModule",{value:!0});Tm.pbkdf2=Kre;Tm.pbkdf2Async=Gre;const Fd=Jn,Yre=X3,Ks=Ja;function J3(e,t,n,r){(0,Fd.hash)(e);const i=(0,Ks.checkOpts)({dkLen:32,asyncTick:10},r),{c:o,dkLen:a,asyncTick:s}=i;if((0,Fd.number)(o),(0,Fd.number)(a),(0,Fd.number)(s),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const l=(0,Ks.toBytes)(t),u=(0,Ks.toBytes)(n),c=new Uint8Array(a),d=Yre.hmac.create(e,l),f=d._cloneInto().update(u);return{c:o,dkLen:a,asyncTick:s,DK:c,PRF:d,PRFSalt:f}}function Z3(e,t,n,r,i){return e.destroy(),t.destroy(),r&&r.destroy(),i.fill(0),n}function Kre(e,t,n,r){const{c:i,dkLen:o,DK:a,PRF:s,PRFSalt:l}=J3(e,t,n,r);let u;const c=new Uint8Array(4),d=(0,Ks.createView)(c),f=new Uint8Array(s.outputLen);for(let p=1,h=0;h{l._cloneInto(c).update(p).digestInto(p);for(let b=0;brM(t.toString(2),"0",8)).join("")}function aM(e){const n=e.length*8/32,r=aie.sha256(Uint8Array.from(e));return oM(Array.from(r)).slice(0,n)}function sM(e){return"mnemonic"+(e||"")}function uie(e,t){const n=Uint8Array.from(Buffer.from(hc(e),"utf8")),r=Uint8Array.from(Buffer.from(sM(hc(t)),"utf8")),i=tM.pbkdf2(eM.sha512,n,r,{c:2048,dkLen:64});return Buffer.from(i)}var cie=fi.mnemonicToSeedSync=uie;function die(e,t){const n=Uint8Array.from(Buffer.from(hc(e),"utf8")),r=Uint8Array.from(Buffer.from(sM(hc(t)),"utf8"));return tM.pbkdf2Async(eM.sha512,n,r,{c:2048,dkLen:64}).then(i=>Buffer.from(i))}fi.mnemonicToSeed=die;function lM(e,t){if(t=t||pc,!t)throw new Error(nM);const n=hc(e).split(" ");if(n.length%3!==0)throw new Error($w);const r=n.map(c=>{const d=t.indexOf(c);if(d===-1)throw new Error($w);return rM(d.toString(2),"0",11)}).join(""),i=Math.floor(r.length/33)*32,o=r.slice(0,i),a=r.slice(i),s=o.match(/(.{1,8})/g).map(iM);if(s.length<16)throw new Error(Na);if(s.length>32)throw new Error(Na);if(s.length%4!==0)throw new Error(Na);const l=Buffer.from(s);if(aM(l)!==a)throw new Error(lie);return l.toString("hex")}fi.mnemonicToEntropy=lM;function uM(e,t){if(Buffer.isBuffer(e)||(e=Buffer.from(e,"hex")),t=t||pc,!t)throw new Error(nM);if(e.length<16)throw new TypeError(Na);if(e.length>32)throw new TypeError(Na);if(e.length%4!==0)throw new TypeError(Na);const n=oM(Array.from(e)),r=aM(e),a=(n+r).match(/(.{1,11})/g).map(s=>{const l=iM(s);return t[l]});return t[0]==="あいこくしん"?a.join(" "):a.join(" ")}fi.entropyToMnemonic=uM;function fie(e,t,n){if(e=e||128,e%32!==0)throw new TypeError(Na);return t=t||(r=>Buffer.from(sie.randomBytes(r))),uM(t(e/8),n)}fi.generateMnemonic=fie;function pie(e,t){try{lM(e,t)}catch{return!1}return!0}fi.validateMnemonic=pie;function hie(e){const t=Kp.wordlists[e];if(t)pc=t;else throw new Error('Could not find wordlist for language "'+e+'"')}fi.setDefaultWordlist=hie;function mie(){if(!pc)throw new Error("No Default Wordlist set");return Object.keys(Kp.wordlists).filter(e=>e==="JA"||e==="EN"?!1:Kp.wordlists[e].every((t,n)=>t===pc[n]))[0]}fi.getDefaultWordlist=mie;var gie=vn,bie=fi.wordlists=gie.wordlists;const Ww=bie.english;class qc{constructor(t,n,r){Jo(this,"encryptionKey");Jo(this,"signingKey",null);Jo(this,"verifyingKey",null);this.encryptionKey=t,this.signingKey=n,this.verifyingKey=r}static generateNewSeedPhrase(){try{const t=[];for(let n=0;n<12;n++){const r=new Uint8Array(2);crypto.getRandomValues(r);const i=(r[0]<<8|r[1])%Ww.length;t.push(Ww[i])}return t.join(" ")}catch(t){throw console.error("Failed to generate mnemonic:",t),new Error("Failed to generate seed phrase")}}static async new(t){const n=cie(t),r=new Uint8Array(n.slice(0,32)),i=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign","verify"]),o=await crypto.subtle.digest("SHA-256",n);return localStorage.setItem("user_id",Qi.Buffer.from(o).toString("hex")),new qc(r,i.privateKey,i.publicKey)}async encryptNote(t){if(!t.id)throw new Error("Note must have an ID before encryption");const n=crypto.getRandomValues(new Uint8Array(12)),r=JSON.stringify({title:t.title,content:t.content,created_at:t.created_at,updated_at:t.updated_at,deleted:t.deleted}),i=await crypto.subtle.importKey("raw",this.encryptionKey,{name:"AES-GCM"},!1,["encrypt"]),o=await crypto.subtle.encrypt({name:"AES-GCM",iv:n},i,new TextEncoder().encode(r)),a=await crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},this.signingKey,new Uint8Array(o));return{id:t.id.toString(16).padStart(16,"0"),data:Qi.Buffer.from(o).toString("base64"),nonce:Qi.Buffer.from(n).toString("base64"),timestamp:t.updated_at,signature:Qi.Buffer.from(a).toString("base64")}}async decryptNote(t){const n=Qi.Buffer.from(t.data,"base64"),r=Qi.Buffer.from(t.nonce,"base64"),i=await crypto.subtle.importKey("raw",this.encryptionKey,{name:"AES-GCM"},!1,["decrypt"]),o=await crypto.subtle.decrypt({name:"AES-GCM",iv:r},i,n),a=JSON.parse(new TextDecoder().decode(o));return{id:parseInt(t.id,16),...a}}async getPublicKeyBase64(){const t=await crypto.subtle.exportKey("raw",this.verifyingKey);return Qi.Buffer.from(t).toString("base64")}}class gy{static getEndpoint(t,n){return`${t}/api${n}`}static async healthCheck(t){try{const n=this.getEndpoint(t,"/health"),r=await fetch(n,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error("Health check failed");const i=await r.json();return i.status==="healthy"&&i.database==="connected"}catch(n){return console.error("Health check failed:",n),!1}}static async syncNotes(t,n,r){const i=this.getEndpoint(t,"/sync");console.log("Syncing notes:",{serverUrl:t,endpoint:i,notesCount:r.length,hasPublicKey:!!n});try{const o=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({public_key:n,notes:r,client_version:"0.1.3"})});if(console.log("Server response:",{status:o.status,ok:o.ok,headers:Object.fromEntries(o.headers.entries())}),!o.ok){const s=await o.json().catch(()=>null);throw new Error((s==null?void 0:s.error)||`Sync failed with status ${o.status}`)}const a=await o.json();if(console.log("Sync response data:",a),!a||!Array.isArray(a.notes))throw console.error("Invalid response format:",a),new Error("Invalid server response format");return{notes:a.notes}}catch(o){throw console.error("Sync error:",o),o}}static async validateServer(t){try{const n=this.getEndpoint(t,"/health");console.log("Validate server endpoint:",n);const r=await fetch(n,{headers:{Accept:"application/json"}});if(!r.ok)return!1;const i=await r.json();return i.status==="healthy"&&i.database==="connected"}catch(n){return console.error("Server validation failed:",n),!1}}}class Rt{static async initializeCrypto(t){this.crypto=await qc.new(t)}static async getNotes(){const t=localStorage.getItem(this.NOTES_KEY);return(t?JSON.parse(t):[]).filter(r=>!r.deleted)}static async saveNote(t){const n=await this.getNotes(),r=Date.now(),i={...t,updated_at:r,created_at:t.created_at||r};i.id||(i.id=r);const o=n.findIndex(a=>a.id===i.id);o!==-1?n[o]=i:n.push(i),localStorage.setItem(this.NOTES_KEY,JSON.stringify(n))}static async deleteNote(t){const n=await this.getNotes(),r=n.findIndex(i=>i.id===t);if(r!==-1){const i={...n[r],deleted:!0,updated_at:Date.now()};n[r]=i,localStorage.setItem(this.NOTES_KEY,JSON.stringify(n))}}static async getSyncSettings(){const t=localStorage.getItem(this.SETTINGS_KEY);return t?JSON.parse(t):{auto_sync:!1,sync_interval:300,server_url:"https://notes-sync.toolworks.dev",custom_servers:[],seed_phrase:null}}static async saveSyncSettings(t){const r={...await this.getSyncSettings(),...t};localStorage.setItem(this.SETTINGS_KEY,JSON.stringify(r))}static async syncWithServer(t,n=3){if(!this.crypto)throw new Error("Crypto not initialized");let r=null;for(let i=0;i({...m,id:m.id||Date.now()})),c=await Promise.all(u.map(m=>this.crypto.encryptNote(m)));console.log("Encrypted notes:",c);const d=localStorage.getItem("user_id");if(!d)throw new Error("User ID not found");const f=await gy.syncNotes(t,d,c);console.log("Server response:",f);const p=await Promise.all(f.notes.map(async m=>await this.crypto.decryptNote(m)));console.log("Decrypted server notes:",p);const h=this.mergeNotes(u,p);console.log("Merged notes:",h),localStorage.setItem(this.NOTES_KEY,JSON.stringify(h));return}catch(o){if(console.error(`Sync attempt ${i+1} failed:`,o),r=o,isetTimeout(a,Math.pow(2,i)*1e3));continue}}throw r||new Error("Sync failed after retries")}static async getDeletedNotes(){const t=localStorage.getItem(this.NOTES_KEY);return(t?JSON.parse(t):[]).filter(r=>r.deleted)}static mergeNotes(t,n){const r=new Map;return t.forEach(i=>{i.id&&r.set(i.id,i)}),n.forEach(i=>{if(i.id){const o=r.get(i.id);i.deleted&&(!o||i.updated_at>o.updated_at)?r.delete(i.id):!i.deleted&&(!o||i.updated_at>o.updated_at)&&r.set(i.id,i)}}),Array.from(r.values()).sort((i,o)=>o.updated_at-i.updated_at)}}Jo(Rt,"NOTES_KEY","notes"),Jo(Rt,"SETTINGS_KEY","sync_settings"),Jo(Rt,"crypto",null);const Hd=[{label:"Official Server",value:"https://notes-sync.toolworks.dev"},{label:"Local Server",value:"http://localhost:3222"}];function yie({onSync:e}){const[t,n]=S.useState(""),[r,i]=S.useState(!1),[o,a]=S.useState(!1),[s,l]=S.useState(""),[u,c]=S.useState(!1),[d,f]=S.useState(Hd[0].value),[p,h]=S.useState([]),[m,y]=S.useState(""),[b,E]=S.useState(!1),[v,k]=S.useState(!1),_=H=>{try{return new URL(H),!0}catch{return!1}},x=H=>{y(H),k(_(H))},I=H=>{H.key==="Enter"&&v&&z()};S.useEffect(()=>{(async()=>{try{const B=await Rt.getSyncSettings();i(B.auto_sync),f(B.server_url),h(B.custom_servers||[]),n(B.seed_phrase??"")}catch(B){console.error("Failed to load settings:",B)}})()},[]);const R=async H=>{try{const B=await Rt.getSyncSettings(),M={auto_sync:"auto_sync"in H?H.auto_sync:r,server_url:"server_url"in H?H.server_url:d,custom_servers:"custom_servers"in H?H.custom_servers:p,seed_phrase:"seed_phrase"in H?H.seed_phrase:t,sync_interval:B.sync_interval};await Rt.saveSyncSettings(M)}catch{Qr.show({title:"Error",message:"Failed to save settings",color:"red"})}},z=async()=>{try{if(!v)return;if(p.includes(m)||Hd.some(B=>B.value===m)){Qr.show({title:"Error",message:"Server already exists",color:"red"});return}const H=[...p,m];h(H),f(m),await R({custom_servers:H,server_url:m}),y(""),E(!1),Qr.show({title:"Success",message:"Server added successfully",color:"green"})}catch{Qr.show({title:"Error",message:"Failed to add server",color:"red"})}},A=async H=>{const B=p.filter(M=>M!==H);if(h(B),await R({custom_servers:B}),d===H){const M=Hd[0].value;f(M),await R({server_url:M})}},j=async H=>{H&&(f(H),await R({server_url:H}))},L=async()=>{if(!t){Qr.show({title:"Error",message:"Please enter a seed phrase",color:"red"});return}c(!0);try{if(console.log("Starting sync process..."),await Rt.initializeCrypto(t),console.log("Crypto initialized"),!await gy.healthCheck(d))throw new Error(`Server ${d} is not healthy`);console.log("Server health check passed"),await Rt.syncWithServer(d),console.log("Sync completed"),await Rt.saveSyncSettings({seed_phrase:t}),console.log("Settings saved"),e&&await e(),Qr.show({title:"Success",message:"Notes synced successfully",color:"green"})}catch(H){console.error("Sync error:",H),Qr.show({title:"Error",message:H instanceof Error?H.message:"Failed to sync notes",color:"red",autoClose:!1})}finally{c(!1)}},U=async()=>{try{const H=qc.generateNewSeedPhrase();await Rt.initializeCrypto(H),l(H),n(H),await R({seed_phrase:H}),a(!0)}catch(H){console.error("Failed to generate seed phrase:",H),Qr.show({title:"Error",message:"Failed to generate seed phrase",color:"red"})}},V=[...Hd,...p.map(H=>({label:H,value:H,rightSection:T.jsx(ze,{size:"sm",color:"red",onClick:B=>{B.stopPropagation(),A(H)},children:T.jsx(xE,{size:14})})}))];return T.jsxs(Un,{children:[T.jsx(Pa,{p:"md",withBorder:!0,children:T.jsxs(Un,{children:[T.jsxs(it,{align:"flex-end",children:[T.jsx(TE,{label:"Sync Server",placeholder:"Select a server",data:V,value:d,onChange:j,style:{flex:1}}),T.jsx($t,{variant:"light",onClick:()=>E(!0),leftSection:T.jsx(hu,{size:16}),children:"Add Server"})]}),T.jsx(yE,{label:"Seed Phrase",description:"Enter your seed phrase to sync across devices",value:t,onChange:H=>{n(H.currentTarget.value),R({seed_phrase:H.currentTarget.value})}}),T.jsxs(it,{justify:"space-between",children:[T.jsx($t,{onClick:L,loading:u,children:"Sync Now"}),T.jsx($t,{variant:"light",onClick:U,children:"Generate New Seed Phrase"})]}),T.jsx(qh,{label:"Auto-sync",checked:r,onChange:H=>{i(H.currentTarget.checked),R({auto_sync:H.currentTarget.checked})}})]})}),T.jsx(Yn,{opened:b,onClose:()=>E(!1),title:"Add Custom Server",children:T.jsxs(Un,{children:[T.jsx(Ea,{label:"Server URL",description:"Enter the full URL of your sync server",placeholder:"https://your-server.com",value:m,onChange:H=>x(H.currentTarget.value),onKeyPress:I,error:m&&!v?"Please enter a valid URL":null}),T.jsxs(it,{justify:"flex-end",children:[T.jsx($t,{variant:"light",onClick:()=>E(!1),children:"Cancel"}),T.jsx($t,{onClick:z,disabled:!v,children:"Add Server"})]})]})}),T.jsx(Yn,{opened:o,onClose:()=>a(!1),title:"Your New Seed Phrase",children:T.jsxs(Un,{children:[T.jsx(qt,{fw:500,c:"red",children:"Important: Save this phrase somewhere safe. You'll need it to sync your notes across devices."}),T.jsx(Pa,{p:"md",withBorder:!0,children:T.jsx(qt,{children:s})}),T.jsx(it,{children:T.jsx(j2,{value:s,children:({copied:H,copy:B})=>T.jsx($t,{color:H?"teal":"blue",onClick:B,children:H?"Copied":"Copy"})})})]})})]})}function Eie(e,t){const n=S.useRef(),r=S.useRef(!1);S.useEffect(()=>{async function i(){if(!r.current)try{r.current=!0;const a=await Rt.getSyncSettings();if(!a.seed_phrase)throw new Error("No seed phrase configured");const s=await qc.new(a.seed_phrase),l=await Rt.getNotes(),u=await Promise.all(l.map(d=>s.encryptNote(d))),c=await fetch(`${a.server_url}/api/sync`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({public_key:await s.getPublicKeyBase64(),notes:u,client_version:"0.1.3"})});if(!c.ok)throw new Error(await c.text());Qr.show({title:"Auto-sync Complete",message:"Your notes have been synchronized",color:"green"})}catch(a){console.error("Auto-sync failed:",a),Qr.show({title:"Auto-sync Failed",message:a instanceof Error?a.message:"An unknown error occurred",color:"red"})}finally{r.current=!1}}function o(){e&&(n.current=window.setTimeout(()=>{i().finally(o)},t*60*1e3))}return o(),()=>{n.current&&clearTimeout(n.current)}},[e,t])}function vie({opened:e,onClose:t,onNewNote:n,onSearch:r,searchQuery:i,onToggleTheme:o,colorScheme:a,onShowSyncSettings:s,onExport:l,onImport:u,selectedNote:c,notes:d,onSelectNote:f,onDeleteNote:p}){const h=a==="dark"||a==="auto"&&window.matchMedia("(prefers-color-scheme: dark)").matches;return T.jsx(Fr,{opened:e,onClose:t,size:"100%",padding:"md",title:T.jsxs(it,{children:[T.jsx(Gu,{src:"/trusty.jpg",alt:"Logo",w:30,h:30}),T.jsx(qt,{size:"lg",fw:500,children:"Trusty Notes"})]}),children:T.jsxs(Un,{h:"100%",gap:"md",children:[T.jsx(Ea,{placeholder:"Search notes...",leftSection:T.jsx(rA,{size:16}),value:i,onChange:m=>r(m.currentTarget.value)}),T.jsx($t,{variant:"light",leftSection:T.jsx(hu,{size:16}),onClick:()=>{n(),t()},fullWidth:!0,children:"New Note"}),T.jsx(se,{style:{flex:1,overflowY:"auto"},children:T.jsx(Un,{gap:"xs",children:d.map(m=>T.jsx(Pa,{shadow:"xs",p:"md",onClick:()=>{f(m),t()},style:{cursor:"pointer",backgroundColor:(c==null?void 0:c.id)===m.id?"var(--mantine-color-blue-light)":void 0},children:T.jsxs(it,{justify:"space-between",wrap:"nowrap",children:[T.jsxs(se,{style:{flex:1},children:[T.jsx(qt,{fw:500,truncate:"end",children:m.title||"Untitled"}),T.jsx(qt,{size:"xs",c:"dimmed",children:vb(m.updated_at,"MMM d, yyyy HH:mm")})]}),T.jsx(ze,{variant:"subtle",color:"red",onClick:y=>{y.stopPropagation(),p(m.id)},children:T.jsx(xE,{size:16})})]})},m.id))})}),T.jsxs(Un,{gap:"xs",children:[T.jsx($t,{variant:"light",leftSection:h?T.jsx(xb,{size:16}):T.jsx(kb,{size:16}),onClick:o,fullWidth:!0,children:h?"Light Mode":"Dark Mode"}),T.jsx($t,{variant:"light",leftSection:T.jsx(tA,{size:16}),onClick:()=>{s(),t()},fullWidth:!0,children:"Sync Settings"}),T.jsxs(it,{grow:!0,children:[T.jsx($t,{variant:"light",leftSection:T.jsx(nA,{size:16}),onClick:l,children:"Export"}),T.jsx($t,{variant:"light",leftSection:T.jsx(iA,{size:16}),onClick:u,children:"Import"})]}),T.jsx($t,{variant:"subtle",leftSection:T.jsx(Tb,{size:16}),component:"a",href:"https://github.com/toolworks-dev/trusty-notes",target:"_blank",fullWidth:!0,children:"GitHub"})]})]})})}function Tie(){const[e,t]=S.useState([]),[n,r]=S.useState(null),[i,o]=S.useState(""),[a,s]=S.useState(""),[l,u]=S.useState(null),{colorScheme:c,toggleColorScheme:d}=L6(),[f,p]=S.useState(""),[h,m]=S.useState(!1),[y,b]=S.useState(!1),[E,v]=S.useState(null),k=b1("(max-width: 768px)"),[_,x]=S.useState(!1);S.useEffect(()=>{R()},[]);const I=e.filter(B=>B.title.toLowerCase().includes(f.toLowerCase())||B.content.toLowerCase().includes(f.toLowerCase())),R=async()=>{try{const B=await Rt.getNotes();t(B)}catch(B){console.error("Failed to fetch notes:",B)}},z=Tc(async()=>{if(!(i.trim()===""&&a.trim()==="")){u("saving");try{await L()}catch(B){console.error("Save failed:",B),u(null)}}},1e3);S.useEffect(()=>{(i||a)&&z()},[i,a]);function A(B){r(B),o(B.title),s(B.content)}function j(){r(null),o(""),s("")}S.useEffect(()=>{Rt.getSyncSettings().then(v)},[]),S.useEffect(()=>{(async()=>{if(k){const{initializeMobileApp:M}=await qz(async()=>{const{initializeMobileApp:N}=await import("./mobileInit-BjDn5VWt.js").then(F=>F.m);return{initializeMobileApp:N}},[]);await M()}})()},[k]),Eie((E==null?void 0:E.auto_sync)??!1,(E==null?void 0:E.sync_interval)??5);async function L(){try{const B=Date.now(),M={id:n==null?void 0:n.id,title:i.trim()===""?"Untitled":i,content:a,created_at:(n==null?void 0:n.created_at)||B,updated_at:B};await Rt.saveNote(M),await R(),u("saved"),setTimeout(()=>u(null),2e3)}catch(B){console.error("Failed to save note:",B),u(null),alert(`Failed to save note: ${B}`)}}async function U(B){if(window.confirm("Are you sure you want to delete this note?"))try{await Rt.deleteNote(B),(n==null?void 0:n.id)===B&&j(),await R()}catch(M){console.error("Failed to delete note:",M),alert("Failed to delete note")}}async function V(){const B=await Rt.getNotes(),M=new Blob([JSON.stringify(B)],{type:"application/json"}),N=URL.createObjectURL(M),F=document.createElement("a");F.href=N,F.download=`notes-${vb(new Date,"yyyy-MM-dd")}.json`,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(N)}async function H(){const B=document.createElement("input");B.type="file",B.accept=".json",B.onchange=async M=>{var w;const N=(w=M.target.files)==null?void 0:w[0];if(!N)return;const F=new FileReader;F.onload=async q=>{var be;const X=(be=q.target)==null?void 0:be.result,D=JSON.parse(X);for(const ge of D)await Rt.saveNote(ge);await R()},F.readAsText(N)},B.click()}return T.jsxs(ur,{header:k?{height:60}:void 0,navbar:{width:k?0:h?80:300,breakpoint:"sm",collapsed:{mobile:!0}},padding:"0",children:[k&&T.jsx(ur.Header,{children:T.jsxs(it,{h:"100%",px:"md",justify:"space-between",children:[T.jsxs(it,{children:[T.jsx(mE,{opened:_,onClick:()=>x(B=>!B),hiddenFrom:"sm",size:"sm"}),T.jsx(Gu,{src:"/trusty.jpg",alt:"Logo",w:30,h:30})]}),T.jsx(Ea,{placeholder:"Note title",value:i,onChange:B=>o(B.currentTarget.value),style:{flex:1}}),T.jsxs(it,{children:[T.jsx(Wf,{href:"https://github.com/toolworks-dev/trusty-notes",target:"_blank",children:T.jsx(ze,{variant:"subtle",children:T.jsx(Tb,{size:20})})}),T.jsx(ze,{variant:"subtle",onClick:j,children:T.jsx(hu,{size:20})})]})]})}),k?T.jsx(vie,{opened:_,onClose:()=>x(!1),onNewNote:j,onSearch:p,searchQuery:f,onToggleTheme:d,colorScheme:c,onShowSyncSettings:()=>b(!0),onExport:V,onImport:H,selectedNote:n,notes:I,onSelectNote:A,onDeleteNote:U}):T.jsx(ur.Navbar,{p:"md",children:T.jsxs(Un,{h:"100%",gap:"sm",children:[T.jsxs(it,{justify:"space-between",children:[T.jsxs(it,{children:[T.jsx(Gu,{src:"/trusty.jpg",alt:"Logo",w:30,h:30}),T.jsx(qt,{size:"lg",fw:500,children:"Trusty Notes"})]}),T.jsxs(it,{children:[!h&&T.jsxs(T.Fragment,{children:[T.jsx(Qe,{label:"GitHub",children:T.jsx(Wf,{href:"https://github.com/toolworks-dev/trusty-notes",target:"_blank",children:T.jsx(ze,{variant:"default",size:30,children:T.jsx(Tb,{size:16})})})}),T.jsx(Qe,{label:"Sync Settings",children:T.jsx(ze,{variant:"default",onClick:()=>b(!0),size:30,children:T.jsx(tA,{size:16})})}),T.jsx(Qe,{label:"Toggle Theme",children:T.jsx(ze,{variant:"default",onClick:()=>d(),size:30,children:c==="dark"?T.jsx(xb,{size:16}):T.jsx(kb,{size:16})})}),T.jsx(Qe,{label:"Export Notes",children:T.jsx(ze,{variant:"default",onClick:V,size:30,children:T.jsx(nA,{size:16})})}),T.jsx(Qe,{label:"Import Notes",children:T.jsx(ze,{variant:"default",onClick:H,size:30,children:T.jsx(iA,{size:16})})})]}),T.jsx(Qe,{label:h?"Expand sidebar":"Collapse sidebar",children:T.jsx(ze,{variant:"default",onClick:()=>m(!h),size:30,children:h?T.jsx(rF,{size:16}):T.jsx(nF,{size:16})})})]})]}),!h&&T.jsxs(T.Fragment,{children:[T.jsx($t,{leftSection:T.jsx(hu,{size:14}),variant:"light",onClick:j,fullWidth:!0,children:"New Note"}),T.jsx(Ea,{placeholder:"Search notes...",leftSection:T.jsx(rA,{size:16}),value:f,onChange:B=>p(B.currentTarget.value)}),T.jsx(Un,{gap:"xs",style:{overflow:"auto",flex:1,minHeight:0},children:I.map(B=>T.jsx(Pa,{shadow:"xs",p:"md",onClick:()=>A(B),style:{cursor:"pointer",backgroundColor:(n==null?void 0:n.id)===B.id?"var(--mantine-color-blue-light)":void 0},children:T.jsxs(it,{justify:"space-between",wrap:"nowrap",children:[T.jsxs(se,{style:{flex:1},children:[T.jsx(qt,{fw:500,truncate:"end",children:B.title||"Untitled"}),T.jsx(qt,{size:"xs",c:"dimmed",children:vb(B.updated_at,"MMM d, yyyy HH:mm")})]}),T.jsx(ze,{variant:"subtle",color:"red",onClick:M=>{M.stopPropagation(),U(B.id)},children:T.jsx(xE,{size:16})})]})},B.id))})]}),h&&T.jsxs(Un,{gap:"xs",align:"center",children:[T.jsx(Qe,{label:"New Note",position:"right",children:T.jsx(ze,{variant:"light",onClick:j,size:"lg",children:T.jsx(hu,{size:20})})}),T.jsx(Qe,{label:"Toggle Theme",position:"right",children:T.jsx(ze,{variant:"light",onClick:()=>d(),size:"lg",children:c==="dark"?T.jsx(xb,{size:20}):T.jsx(kb,{size:20})})})]})]})}),T.jsx(ur.Main,{children:T.jsxs(Un,{h:"100vh",gap:0,children:[!k&&T.jsx(se,{p:"md",style:{borderBottom:"1px solid var(--mantine-color-gray-3)"},children:T.jsxs(it,{justify:"space-between",align:"center",children:[T.jsx(Ea,{placeholder:"Note title",value:i,onChange:B=>o(B.currentTarget.value),size:"lg",style:{flex:1}}),T.jsxs(it,{children:[l&&T.jsxs(it,{gap:"xs",children:[T.jsx(tF,{size:16,style:{color:"var(--mantine-color-green-6)"}}),T.jsx(qt,{size:"sm",c:"dimmed",children:l==="saving"?"Saving...":"Saved"})]}),T.jsx($t,{variant:"light",onClick:j,children:"New Note"})]})]})}),T.jsx(se,{style:{flex:1,position:"relative",minHeight:0,padding:k?"0.5rem":"1rem",paddingTop:k?"0.5rem":"1rem"},children:T.jsx(Cre,{content:a,onChange:s,isMobile:k,defaultView:"edit",editorType:"richtext"})})]})}),T.jsx(Yn,{opened:y,onClose:()=>b(!1),title:"Sync Settings",size:"lg",fullScreen:k,children:T.jsx(yie,{onSync:R})})]})}window.Buffer=Qi.Buffer;const kie={primaryColor:"blue"};u0.createRoot(document.getElementById("root")).render(T.jsx(Et.StrictMode,{children:T.jsx(SN,{theme:kie,defaultColorScheme:"auto",children:T.jsx(Tie,{})})}));export{qz as _}; +3. "-" cannot repeat`);st.customSchemes.push([e,t])}function pre(){st.scanner=ire(st.customSchemes);for(let e=0;e{const i=t.some(u=>u.docChanged)&&!n.doc.eq(r.doc),o=t.some(u=>u.getMeta("preventAutolink"));if(!i||o)return;const{tr:a}=r,s=jee(n.doc,[...t]);if(Xee(s).forEach(({newRange:u})=>{const c=Wee(r.doc,u,p=>p.isTextblock);let d,f;if(c.length>1?(d=c[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ")):c.length&&r.doc.textBetween(u.from,u.to," "," ").endsWith(" ")&&(d=c[0],f=r.doc.textBetween(d.pos,u.to,void 0," ")),d&&f){const p=f.split(" ").filter(b=>b!=="");if(p.length<=0)return!1;const h=p[p.length-1],m=d.pos+f.lastIndexOf(h);if(!h)return!1;const y=v3(h).map(b=>b.toObject(e.defaultProtocol));if(!hre(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:m+b.start+1,to:m+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>e.validate(b.value)).forEach(b=>{mv(b.from,b.to,r.doc).some(E=>E.mark.type===e.type)||a.addMark(b.from,b.to,e.type.create({href:b.href}))})}}),!!a.steps.length)return a}})}function gre(e){return new Qt({key:new Xn("handleClickLink"),props:{handleClick:(t,n,r)=>{var i,o;if(r.button!==0||!t.editable)return!1;let a=r.target;const s=[];for(;a.nodeName!=="DIV";)s.push(a),a=a.parentNode;if(!s.find(f=>f.nodeName==="A"))return!1;const l=a3(t.state,e.type.name),u=r.target,c=(i=u==null?void 0:u.href)!==null&&i!==void 0?i:l.href,d=(o=u==null?void 0:u.target)!==null&&o!==void 0?o:l.target;return u&&c?(window.open(c,d),!0):!1}}})}function bre(e){return new Qt({key:new Xn("handlePasteLink"),props:{handlePaste:(t,n,r)=>{const{state:i}=t,{selection:o}=i,{empty:a}=o;if(a)return!1;let s="";r.content.forEach(u=>{s+=u.textContent});const l=T3(s,{defaultProtocol:e.defaultProtocol}).find(u=>u.isLink&&u.value===s);return!s||!l?!1:(e.editor.commands.setMark(e.type,{href:l.href}),!0)}}})}const yre=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function jw(e,t){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!e||e.replace(yre,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Ere=si.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.protocols.forEach(e=>{if(typeof e=="string"){Uw(e);return}Uw(e.scheme,e.optionalSlashes)})},onDestroy(){fre()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:e=>!!e}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{const t=e.getAttribute("href");return!t||!jw(t,this.options.protocols)?!1:null}}]},renderHTML({HTMLAttributes:e}){return jw(e.href,this.options.protocols)?["a",Nt(this.options.HTMLAttributes,e),0]:["a",Nt(this.options.HTMLAttributes,{...e,href:""}),0]},addCommands(){return{setLink:e=>({chain:t})=>t().setMark(this.name,e).setMeta("preventAutolink",!0).run(),toggleLink:e=>({chain:t})=>t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Bo({find:e=>{const t=[];if(e){const{validate:n}=this.options,r=T3(e).filter(i=>i.isLink&&n(i.value));r.length&&r.forEach(i=>t.push({text:i.value,data:{href:i.href},index:i.start}))}return t},type:this.type,getAttributes:e=>{var t;return{href:(t=e.data)===null||t===void 0?void 0:t.href}}})]},addProseMirrorPlugins(){const e=[];return this.options.autolink&&e.push(mre({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:this.options.validate})),this.options.openOnClick===!0&&e.push(gre({type:this.type})),this.options.linkOnPaste&&e.push(bre({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),e}}),vre=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Tre=kr.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:e}){return["img",Nt(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[s3({find:vre,type:this.type,getAttributes:e=>{const[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),kre=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,xre=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Sre=si.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",Nt(this.options.HTMLAttributes,e),0]},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[ja({find:kre,type:this.type})]},addPasteRules(){return[Bo({find:xre,type:this.type})]}});function wre({content:e,onChange:t}){const n=Yte({extensions:[Gne,Ere.configure({openOnClick:!1}),Tre,c3,Sre],content:e,onUpdate:({editor:r})=>{t(r.getHTML())},editorProps:{attributes:{class:"rich-text-editor",style:"height: 100%"}}});return S.useEffect(()=>{n&&e!==n.getHTML()&&n.commands.setContent(e,!1)},[e,n]),n?T.jsxs(se,{style:{display:"flex",flexDirection:"column",height:"100%"},children:[T.jsxs(it,{mb:"xs",wrap:"nowrap",children:[T.jsx(Qe,{label:"Bold",children:T.jsx(ze,{variant:n.isActive("bold")?"filled":"subtle",onClick:()=>n.chain().focus().toggleBold().run(),children:T.jsx(eF,{size:16})})}),T.jsx(Qe,{label:"Italic",children:T.jsx(ze,{variant:n.isActive("italic")?"filled":"subtle",onClick:()=>n.chain().focus().toggleItalic().run(),children:T.jsx(cF,{size:16})})}),T.jsx(Qe,{label:"Heading 1",children:T.jsx(ze,{variant:n.isActive("heading",{level:1})?"filled":"subtle",onClick:()=>n.chain().focus().toggleHeading({level:1}).run(),children:T.jsx(sF,{size:16})})}),T.jsx(Qe,{label:"Heading 2",children:T.jsx(ze,{variant:n.isActive("heading",{level:2})?"filled":"subtle",onClick:()=>n.chain().focus().toggleHeading({level:2}).run(),children:T.jsx(lF,{size:16})})}),T.jsx(Qe,{label:"Heading 3",children:T.jsx(ze,{variant:n.isActive("heading",{level:3})?"filled":"subtle",onClick:()=>n.chain().focus().toggleHeading({level:3}).run(),children:T.jsx(uF,{size:16})})}),T.jsx(Qe,{label:"Bullet List",children:T.jsx(ze,{variant:n.isActive("bulletList")?"filled":"subtle",onClick:()=>n.chain().focus().toggleBulletList().run(),children:T.jsx(fF,{size:16})})}),T.jsx(Qe,{label:"Numbered List",children:T.jsx(ze,{variant:n.isActive("orderedList")?"filled":"subtle",onClick:()=>n.chain().focus().toggleOrderedList().run(),children:T.jsx(dF,{size:16})})}),T.jsx(Qe,{label:"Blockquote",children:T.jsx(ze,{variant:n.isActive("blockquote")?"filled":"subtle",onClick:()=>n.chain().focus().toggleBlockquote().run(),children:T.jsx(pF,{size:16})})}),T.jsx(Qe,{label:"Code Block",children:T.jsx(ze,{variant:n.isActive("codeBlock")?"filled":"subtle",onClick:()=>n.chain().focus().toggleCodeBlock().run(),children:T.jsx(oF,{size:16})})}),T.jsx(Qe,{label:"Clear Formatting",children:T.jsx(ze,{variant:"subtle",onClick:()=>n.chain().focus().clearNodes().unsetAllMarks().run(),children:T.jsx(iF,{size:16})})})]}),T.jsx(se,{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",border:"1px solid var(--mantine-color-gray-3)",borderRadius:"var(--mantine-radius-md)",padding:"1rem",overflow:"auto",minHeight:0},children:T.jsx(Bte,{editor:n,style:{flex:"1 1 auto",display:"flex",flexDirection:"column",height:"100%"}})})]}):null}function _re({content:e}){const t=e.trim()?e.trim().split(/\s+/).length:0,n=e.length,r=Math.ceil(t/200);return T.jsxs(it,{gap:"xs",children:[T.jsxs(qt,{size:"xs",c:"dimmed",children:[t," words"]}),T.jsx(qt,{size:"xs",c:"dimmed",children:"·"}),T.jsxs(qt,{size:"xs",c:"dimmed",children:[n," characters"]}),T.jsx(qt,{size:"xs",c:"dimmed",children:"·"}),T.jsxs(qt,{size:"xs",c:"dimmed",children:[r," min read"]})]})}function Cre({content:e,onChange:t,isMobile:n,defaultView:r="edit",editorType:i="markdown"}){const[o,a]=S.useState(n?"edit":r),[s,l]=S.useState(i),u=()=>s==="richtext"?T.jsx(wre,{content:e,onChange:t}):T.jsx(bE,{value:e,onChange:f=>t(f.currentTarget.value),styles:{root:{height:"100%"},wrapper:{height:"100%"},input:{height:"100%",padding:"1rem",fontSize:n?"16px":void 0,borderRadius:"var(--mantine-radius-md)",border:"1px solid var(--mantine-color-gray-3)",backgroundColor:"var(--mantine-color-body)",transition:"border-color 100ms ease","&:focus":{borderColor:"var(--mantine-color-blue-filled)",outline:"none"},"&:hover":{borderColor:"var(--mantine-color-gray-5)"}}}}),c=()=>T.jsx(se,{className:"markdown-preview",p:"md",style:{height:"100%",overflow:"auto"},children:T.jsx(Rj,{remarkPlugins:[$W],rehypePlugins:[tK,CQ],children:e})}),d=()=>{if(n)return o==="edit"?u():c();switch(o){case"preview":return c();case"split":return T.jsxs(it,{grow:!0,style:{height:"100%"},children:[u(),c()]});default:return u()}};return T.jsxs(se,{style:{height:"100%",display:"flex",flexDirection:"column"},children:[T.jsxs(it,{justify:"space-between",mb:"xs",children:[T.jsx(_re,{content:e}),T.jsx(it,{children:n?T.jsx(ze,{variant:o==="edit"?"filled":"subtle",onClick:()=>a(o==="edit"?"preview":"edit"),children:o==="edit"?T.jsx(Fk,{size:16}):T.jsx(zk,{size:16})}):T.jsxs(T.Fragment,{children:[T.jsx(Qe,{label:"Markdown",children:T.jsx(ze,{variant:s==="markdown"&&o==="edit"?"filled":"subtle",onClick:()=>{l("markdown"),a("edit")},children:T.jsx(zk,{size:16})})}),T.jsx(Qe,{label:"Rich Text",children:T.jsx(ze,{variant:s==="richtext"&&o==="edit"?"filled":"subtle",onClick:()=>{l("richtext"),a("edit")},children:T.jsx(hF,{size:16})})}),T.jsx(Qe,{label:"Preview",children:T.jsx(ze,{variant:o==="preview"?"filled":"subtle",onClick:()=>a("preview"),children:T.jsx(Fk,{size:16})})}),T.jsx(Qe,{label:"Split View",children:T.jsx(ze,{variant:o==="split"?"filled":"subtle",onClick:()=>a("split"),children:T.jsx(aF,{size:16})})})]})})]}),d()]})}function Nre(e){let t=e,n=!1;const r=new Set;return{getState(){return t},updateState(i){t=typeof i=="function"?i(t):i},setState(i){this.updateState(i),r.forEach(o=>o(t))},initialize(i){n||(t=i,n=!0)},subscribe(i){return r.add(i),()=>r.delete(i)}}}function Are(e,t,n){const r=[],i=[],o={};for(const a of e){const s=a.position||t;o[s]=o[s]||0,o[s]+=1,o[s]<=n?i.push(a):r.push(a)}return{notifications:i,queue:r}}const Ore=()=>Nre({notifications:[],queue:[],defaultPosition:"bottom-right",limit:5}),Wc=Ore();function Ol(e,t){const n=e.getState(),r=t([...n.notifications,...n.queue]),i=Are(r,n.defaultPosition,n.limit);e.setState({notifications:i.notifications,queue:i.queue,limit:n.limit,defaultPosition:n.defaultPosition})}function Ire(e,t=Wc){const n=e.id||g1();return Ol(t,r=>e.id&&r.some(i=>i.id===e.id)?r:[...r,{...e,id:n}]),n}function Rre(e,t=Wc){return Ol(t,n=>n.filter(r=>{var i;return r.id===e?((i=r.onClose)==null||i.call(r,r),!1):!0})),e}function Mre(e,t=Wc){return Ol(t,n=>n.map(r=>r.id===e.id?{...r,...e}:r)),e.id}function Dre(e=Wc){Ol(e,()=>[])}function Lre(e=Wc){Ol(e,t=>t.slice(0,e.getState().limit))}const Qr={show:Ire,hide:Rre,update:Mre,clean:Dre,cleanQueue:Lre,updateState:Ol};var fi={},Oo={},Ci={},Jn={};Object.defineProperty(Jn,"__esModule",{value:!0});Jn.isBytes=x3;Jn.number=Yp;Jn.bool=k3;Jn.bytes=_v;Jn.hash=S3;Jn.exists=w3;Jn.output=_3;function Yp(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function k3(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function x3(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function _v(e,...t){if(!x3(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function S3(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Yp(e.outputLen),Yp(e.blockLen)}function w3(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function _3(e,t){_v(e);const n=t.outputLen;if(e.lengthnew Uint8Array(L.buffer,L.byteOffset,L.byteLength);e.u8=i;const o=L=>new Uint32Array(L.buffer,L.byteOffset,Math.floor(L.byteLength/4));e.u32=o;const a=L=>new DataView(L.buffer,L.byteOffset,L.byteLength);e.createView=a;const s=(L,U)=>L<<32-U|L>>>U;e.rotr=s;const l=(L,U)=>L<>>32-U>>>0;e.rotl=l,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const u=L=>L<<24&4278190080|L<<8&16711680|L>>>8&65280|L>>>24&255;e.byteSwap=u,e.byteSwapIfBE=e.isLE?L=>L:L=>(0,e.byteSwap)(L);function c(L){for(let U=0;UU.toString(16).padStart(2,"0"));function f(L){(0,n.bytes)(L);let U="";for(let V=0;V=p._0&&L<=p._9)return L-p._0;if(L>=p._A&&L<=p._F)return L-(p._A-10);if(L>=p._a&&L<=p._f)return L-(p._a-10)}function m(L){if(typeof L!="string")throw new Error("hex string expected, got "+typeof L);const U=L.length,V=U/2;if(U%2)throw new Error("padded hex string expected, got unpadded hex of length "+U);const H=new Uint8Array(V);for(let B=0,M=0;B{};e.nextTick=y;async function b(L,U,V){let H=Date.now();for(let B=0;B=0&&ML().update(v(H)).digest(),V=L();return U.outputLen=V.outputLen,U.blockLen=V.blockLen,U.create=()=>L(),U}function z(L){const U=(H,B)=>L(B).update(v(H)).digest(),V=L({});return U.outputLen=V.outputLen,U.blockLen=V.blockLen,U.create=H=>L(H),U}function A(L){const U=(H,B)=>L(B).update(v(H)).digest(),V=L({});return U.outputLen=V.outputLen,U.blockLen=V.blockLen,U.create=H=>L(H),U}function j(L=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(L));if(t.crypto&&typeof t.crypto.randomBytes=="function")return t.crypto.randomBytes(L);throw new Error("crypto.getRandomValues must be defined")}})(Ja);Object.defineProperty(Ci,"__esModule",{value:!0});Ci.HashMD=Ci.Maj=Ci.Chi=void 0;const s0=Jn,Ql=Ja;function Bre(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),a=Number(n>>i&o),s=Number(n&o),l=r?4:0,u=r?0:4;e.setUint32(t+l,a,r),e.setUint32(t+u,s,r)}const zre=(e,t,n)=>e&t^~e&n;Ci.Chi=zre;const Fre=(e,t,n)=>e&t^e&n^t&n;Ci.Maj=Fre;class Hre extends Ql.Hash{constructor(t,n,r,i){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,Ql.createView)(this.buffer)}update(t){(0,s0.exists)(this);const{view:n,buffer:r,blockLen:i}=this;t=(0,Ql.toBytes)(t);const o=t.length;for(let a=0;ai-a&&(this.process(r,0),a=0);for(let d=a;dc.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d>>3,m=(0,tr.rotr)(p,17)^(0,tr.rotr)(p,19)^p>>>10;Yi[d]=m+Yi[d-7]+h+Yi[d-16]|0}let{A:r,B:i,C:o,D:a,E:s,F:l,G:u,H:c}=this;for(let d=0;d<64;d++){const f=(0,tr.rotr)(s,6)^(0,tr.rotr)(s,11)^(0,tr.rotr)(s,25),p=c+f+(0,l0.Chi)(s,l,u)+Ure[d]+Yi[d]|0,m=((0,tr.rotr)(r,2)^(0,tr.rotr)(r,13)^(0,tr.rotr)(r,22))+(0,l0.Maj)(r,i,o)|0;c=u,u=l,l=s,s=a+p|0,a=o,o=i,i=r,r=p+m|0}r=r+this.A|0,i=i+this.B|0,o=o+this.C|0,a=a+this.D|0,s=s+this.E|0,l=l+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,i,o,a,s,l,u,c)}roundClean(){Yi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}Oo.SHA256=Cv;class jre extends Cv{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}Oo.sha256=(0,tr.wrapConstructor)(()=>new Cv);Oo.sha224=(0,tr.wrapConstructor)(()=>new jre);var It={},Ee={};Object.defineProperty(Ee,"__esModule",{value:!0});Ee.add5L=Ee.add5H=Ee.add4H=Ee.add4L=Ee.add3H=Ee.add3L=Ee.rotlBL=Ee.rotlBH=Ee.rotlSL=Ee.rotlSH=Ee.rotr32L=Ee.rotr32H=Ee.rotrBL=Ee.rotrBH=Ee.rotrSL=Ee.rotrSH=Ee.shrSL=Ee.shrSH=Ee.toBig=void 0;Ee.fromBig=Nv;Ee.split=C3;Ee.add=U3;const zd=BigInt(2**32-1),my=BigInt(32);function Nv(e,t=!1){return t?{h:Number(e&zd),l:Number(e>>my&zd)}:{h:Number(e>>my&zd)|0,l:Number(e&zd)|0}}function C3(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;iBigInt(e>>>0)<>>0);Ee.toBig=N3;const A3=(e,t,n)=>e>>>n;Ee.shrSH=A3;const O3=(e,t,n)=>e<<32-n|t>>>n;Ee.shrSL=O3;const I3=(e,t,n)=>e>>>n|t<<32-n;Ee.rotrSH=I3;const R3=(e,t,n)=>e<<32-n|t>>>n;Ee.rotrSL=R3;const M3=(e,t,n)=>e<<64-n|t>>>n-32;Ee.rotrBH=M3;const D3=(e,t,n)=>e>>>n-32|t<<64-n;Ee.rotrBL=D3;const L3=(e,t)=>t;Ee.rotr32H=L3;const P3=(e,t)=>e;Ee.rotr32L=P3;const B3=(e,t,n)=>e<>>32-n;Ee.rotlSH=B3;const z3=(e,t,n)=>t<>>32-n;Ee.rotlSL=z3;const F3=(e,t,n)=>t<>>64-n;Ee.rotlBH=F3;const H3=(e,t,n)=>e<>>64-n;Ee.rotlBL=H3;function U3(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}const j3=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0);Ee.add3L=j3;const $3=(e,t,n,r)=>t+n+r+(e/2**32|0)|0;Ee.add3H=$3;const W3=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);Ee.add4L=W3;const V3=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0;Ee.add4H=V3;const q3=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0);Ee.add5L=q3;const Y3=(e,t,n,r,i,o)=>t+n+r+i+o+(e/2**32|0)|0;Ee.add5H=Y3;const $re={fromBig:Nv,split:C3,toBig:N3,shrSH:A3,shrSL:O3,rotrSH:I3,rotrSL:R3,rotrBH:M3,rotrBL:D3,rotr32H:L3,rotr32L:P3,rotlSH:B3,rotlSL:z3,rotlBH:F3,rotlBL:H3,add:U3,add3L:j3,add3H:$3,add4L:W3,add4H:V3,add5H:Y3,add5L:q3};Ee.default=$re;Object.defineProperty(It,"__esModule",{value:!0});It.sha384=It.sha512_256=It.sha512_224=It.sha512=It.SHA384=It.SHA512_256=It.SHA512_224=It.SHA512=void 0;const Wre=Ci,Se=Ee,vm=Ja,[Vre,qre]=Se.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Ki=new Uint32Array(80),Gi=new Uint32Array(80);class Vc extends Wre.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:n,Bh:r,Bl:i,Ch:o,Cl:a,Dh:s,Dl:l,Eh:u,El:c,Fh:d,Fl:f,Gh:p,Gl:h,Hh:m,Hl:y}=this;return[t,n,r,i,o,a,s,l,u,c,d,f,p,h,m,y]}set(t,n,r,i,o,a,s,l,u,c,d,f,p,h,m,y){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=i|0,this.Ch=o|0,this.Cl=a|0,this.Dh=s|0,this.Dl=l|0,this.Eh=u|0,this.El=c|0,this.Fh=d|0,this.Fl=f|0,this.Gh=p|0,this.Gl=h|0,this.Hh=m|0,this.Hl=y|0}process(t,n){for(let v=0;v<16;v++,n+=4)Ki[v]=t.getUint32(n),Gi[v]=t.getUint32(n+=4);for(let v=16;v<80;v++){const k=Ki[v-15]|0,_=Gi[v-15]|0,x=Se.default.rotrSH(k,_,1)^Se.default.rotrSH(k,_,8)^Se.default.shrSH(k,_,7),I=Se.default.rotrSL(k,_,1)^Se.default.rotrSL(k,_,8)^Se.default.shrSL(k,_,7),R=Ki[v-2]|0,z=Gi[v-2]|0,A=Se.default.rotrSH(R,z,19)^Se.default.rotrBH(R,z,61)^Se.default.shrSH(R,z,6),j=Se.default.rotrSL(R,z,19)^Se.default.rotrBL(R,z,61)^Se.default.shrSL(R,z,6),L=Se.default.add4L(I,j,Gi[v-7],Gi[v-16]),U=Se.default.add4H(L,x,A,Ki[v-7],Ki[v-16]);Ki[v]=U|0,Gi[v]=L|0}let{Ah:r,Al:i,Bh:o,Bl:a,Ch:s,Cl:l,Dh:u,Dl:c,Eh:d,El:f,Fh:p,Fl:h,Gh:m,Gl:y,Hh:b,Hl:E}=this;for(let v=0;v<80;v++){const k=Se.default.rotrSH(d,f,14)^Se.default.rotrSH(d,f,18)^Se.default.rotrBH(d,f,41),_=Se.default.rotrSL(d,f,14)^Se.default.rotrSL(d,f,18)^Se.default.rotrBL(d,f,41),x=d&p^~d&m,I=f&h^~f&y,R=Se.default.add5L(E,_,I,qre[v],Gi[v]),z=Se.default.add5H(R,b,k,x,Vre[v],Ki[v]),A=R|0,j=Se.default.rotrSH(r,i,28)^Se.default.rotrBH(r,i,34)^Se.default.rotrBH(r,i,39),L=Se.default.rotrSL(r,i,28)^Se.default.rotrBL(r,i,34)^Se.default.rotrBL(r,i,39),U=r&o^r&s^o&s,V=i&a^i&l^a&l;b=m|0,E=y|0,m=p|0,y=h|0,p=d|0,h=f|0,{h:d,l:f}=Se.default.add(u|0,c|0,z|0,A|0),u=s|0,c=l|0,s=o|0,l=a|0,o=r|0,a=i|0;const H=Se.default.add3L(A,L,V);r=Se.default.add3H(H,z,j,U),i=H|0}({h:r,l:i}=Se.default.add(this.Ah|0,this.Al|0,r|0,i|0)),{h:o,l:a}=Se.default.add(this.Bh|0,this.Bl|0,o|0,a|0),{h:s,l}=Se.default.add(this.Ch|0,this.Cl|0,s|0,l|0),{h:u,l:c}=Se.default.add(this.Dh|0,this.Dl|0,u|0,c|0),{h:d,l:f}=Se.default.add(this.Eh|0,this.El|0,d|0,f|0),{h:p,l:h}=Se.default.add(this.Fh|0,this.Fl|0,p|0,h|0),{h:m,l:y}=Se.default.add(this.Gh|0,this.Gl|0,m|0,y|0),{h:b,l:E}=Se.default.add(this.Hh|0,this.Hl|0,b|0,E|0),this.set(r,i,o,a,s,l,u,c,d,f,p,h,m,y,b,E)}roundClean(){Ki.fill(0),Gi.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}It.SHA512=Vc;class K3 extends Vc{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}It.SHA512_224=K3;class G3 extends Vc{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}It.SHA512_256=G3;class Q3 extends Vc{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}It.SHA384=Q3;It.sha512=(0,vm.wrapConstructor)(()=>new Vc);It.sha512_224=(0,vm.wrapConstructor)(()=>new K3);It.sha512_256=(0,vm.wrapConstructor)(()=>new G3);It.sha384=(0,vm.wrapConstructor)(()=>new Q3);var Tm={},X3={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=Jn,n=Ja;class r extends n.Hash{constructor(a,s){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(a);const l=(0,n.toBytes)(s);if(this.iHash=a.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const u=this.blockLen,c=new Uint8Array(u);c.set(l.length>u?a.create().update(l).digest():l);for(let d=0;dnew r(o,a).update(s).digest();e.hmac=i,e.hmac.create=(o,a)=>new r(o,a)})(X3);Object.defineProperty(Tm,"__esModule",{value:!0});Tm.pbkdf2=Kre;Tm.pbkdf2Async=Gre;const Fd=Jn,Yre=X3,Ks=Ja;function J3(e,t,n,r){(0,Fd.hash)(e);const i=(0,Ks.checkOpts)({dkLen:32,asyncTick:10},r),{c:o,dkLen:a,asyncTick:s}=i;if((0,Fd.number)(o),(0,Fd.number)(a),(0,Fd.number)(s),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const l=(0,Ks.toBytes)(t),u=(0,Ks.toBytes)(n),c=new Uint8Array(a),d=Yre.hmac.create(e,l),f=d._cloneInto().update(u);return{c:o,dkLen:a,asyncTick:s,DK:c,PRF:d,PRFSalt:f}}function Z3(e,t,n,r,i){return e.destroy(),t.destroy(),r&&r.destroy(),i.fill(0),n}function Kre(e,t,n,r){const{c:i,dkLen:o,DK:a,PRF:s,PRFSalt:l}=J3(e,t,n,r);let u;const c=new Uint8Array(4),d=(0,Ks.createView)(c),f=new Uint8Array(s.outputLen);for(let p=1,h=0;h{l._cloneInto(c).update(p).digestInto(p);for(let b=0;brM(t.toString(2),"0",8)).join("")}function aM(e){const n=e.length*8/32,r=aie.sha256(Uint8Array.from(e));return oM(Array.from(r)).slice(0,n)}function sM(e){return"mnemonic"+(e||"")}function uie(e,t){const n=Uint8Array.from(Buffer.from(hc(e),"utf8")),r=Uint8Array.from(Buffer.from(sM(hc(t)),"utf8")),i=tM.pbkdf2(eM.sha512,n,r,{c:2048,dkLen:64});return Buffer.from(i)}var cie=fi.mnemonicToSeedSync=uie;function die(e,t){const n=Uint8Array.from(Buffer.from(hc(e),"utf8")),r=Uint8Array.from(Buffer.from(sM(hc(t)),"utf8"));return tM.pbkdf2Async(eM.sha512,n,r,{c:2048,dkLen:64}).then(i=>Buffer.from(i))}fi.mnemonicToSeed=die;function lM(e,t){if(t=t||pc,!t)throw new Error(nM);const n=hc(e).split(" ");if(n.length%3!==0)throw new Error($w);const r=n.map(c=>{const d=t.indexOf(c);if(d===-1)throw new Error($w);return rM(d.toString(2),"0",11)}).join(""),i=Math.floor(r.length/33)*32,o=r.slice(0,i),a=r.slice(i),s=o.match(/(.{1,8})/g).map(iM);if(s.length<16)throw new Error(Na);if(s.length>32)throw new Error(Na);if(s.length%4!==0)throw new Error(Na);const l=Buffer.from(s);if(aM(l)!==a)throw new Error(lie);return l.toString("hex")}fi.mnemonicToEntropy=lM;function uM(e,t){if(Buffer.isBuffer(e)||(e=Buffer.from(e,"hex")),t=t||pc,!t)throw new Error(nM);if(e.length<16)throw new TypeError(Na);if(e.length>32)throw new TypeError(Na);if(e.length%4!==0)throw new TypeError(Na);const n=oM(Array.from(e)),r=aM(e),a=(n+r).match(/(.{1,11})/g).map(s=>{const l=iM(s);return t[l]});return t[0]==="あいこくしん"?a.join(" "):a.join(" ")}fi.entropyToMnemonic=uM;function fie(e,t,n){if(e=e||128,e%32!==0)throw new TypeError(Na);return t=t||(r=>Buffer.from(sie.randomBytes(r))),uM(t(e/8),n)}fi.generateMnemonic=fie;function pie(e,t){try{lM(e,t)}catch{return!1}return!0}fi.validateMnemonic=pie;function hie(e){const t=Kp.wordlists[e];if(t)pc=t;else throw new Error('Could not find wordlist for language "'+e+'"')}fi.setDefaultWordlist=hie;function mie(){if(!pc)throw new Error("No Default Wordlist set");return Object.keys(Kp.wordlists).filter(e=>e==="JA"||e==="EN"?!1:Kp.wordlists[e].every((t,n)=>t===pc[n]))[0]}fi.getDefaultWordlist=mie;var gie=vn,bie=fi.wordlists=gie.wordlists;const Ww=bie.english;class qc{constructor(t,n,r){Jo(this,"encryptionKey");Jo(this,"signingKey",null);Jo(this,"verifyingKey",null);this.encryptionKey=t,this.signingKey=n,this.verifyingKey=r}static generateNewSeedPhrase(){try{const t=[];for(let n=0;n<12;n++){const r=new Uint8Array(2);crypto.getRandomValues(r);const i=(r[0]<<8|r[1])%Ww.length;t.push(Ww[i])}return t.join(" ")}catch(t){throw console.error("Failed to generate mnemonic:",t),new Error("Failed to generate seed phrase")}}static async new(t){const n=cie(t),r=new Uint8Array(n.slice(0,32)),i=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign","verify"]),o=await crypto.subtle.digest("SHA-256",n);return localStorage.setItem("user_id",Qi.Buffer.from(o).toString("hex")),new qc(r,i.privateKey,i.publicKey)}async encryptNote(t){if(!t.id)throw new Error("Note must have an ID before encryption");const n=crypto.getRandomValues(new Uint8Array(12)),r=JSON.stringify({title:t.title,content:t.content,created_at:t.created_at,updated_at:t.updated_at,deleted:t.deleted}),i=await crypto.subtle.importKey("raw",this.encryptionKey,{name:"AES-GCM"},!1,["encrypt"]),o=await crypto.subtle.encrypt({name:"AES-GCM",iv:n},i,new TextEncoder().encode(r)),a=await crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},this.signingKey,new Uint8Array(o));return{id:t.id.toString(16).padStart(16,"0"),data:Qi.Buffer.from(o).toString("base64"),nonce:Qi.Buffer.from(n).toString("base64"),timestamp:t.updated_at,signature:Qi.Buffer.from(a).toString("base64")}}async decryptNote(t){const n=Qi.Buffer.from(t.data,"base64"),r=Qi.Buffer.from(t.nonce,"base64"),i=await crypto.subtle.importKey("raw",this.encryptionKey,{name:"AES-GCM"},!1,["decrypt"]),o=await crypto.subtle.decrypt({name:"AES-GCM",iv:r},i,n),a=JSON.parse(new TextDecoder().decode(o));return{id:parseInt(t.id,16),...a}}async getPublicKeyBase64(){const t=await crypto.subtle.exportKey("raw",this.verifyingKey);return Qi.Buffer.from(t).toString("base64")}}class gy{static getEndpoint(t,n){return`${t}/api${n}`}static async healthCheck(t){try{const n=this.getEndpoint(t,"/health"),r=await fetch(n,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error("Health check failed");const i=await r.json();return i.status==="healthy"&&i.database==="connected"}catch(n){return console.error("Health check failed:",n),!1}}static async syncNotes(t,n,r){const i=this.getEndpoint(t,"/sync");console.log("Syncing notes:",{serverUrl:t,endpoint:i,notesCount:r.length,hasPublicKey:!!n});try{const o=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({public_key:n,notes:r,client_version:"0.1.3"})});if(console.log("Server response:",{status:o.status,ok:o.ok,headers:Object.fromEntries(o.headers.entries())}),!o.ok){const s=await o.json().catch(()=>null);throw new Error((s==null?void 0:s.error)||`Sync failed with status ${o.status}`)}const a=await o.json();if(console.log("Sync response data:",a),!a||!Array.isArray(a.notes))throw console.error("Invalid response format:",a),new Error("Invalid server response format");return{notes:a.notes}}catch(o){throw console.error("Sync error:",o),o}}static async validateServer(t){try{const n=this.getEndpoint(t,"/health");console.log("Validate server endpoint:",n);const r=await fetch(n,{headers:{Accept:"application/json"}});if(!r.ok)return!1;const i=await r.json();return i.status==="healthy"&&i.database==="connected"}catch(n){return console.error("Server validation failed:",n),!1}}}class Rt{static async initializeCrypto(t){this.crypto=await qc.new(t)}static async getNotes(){const t=localStorage.getItem(this.NOTES_KEY);return(t?JSON.parse(t):[]).filter(r=>!r.deleted)}static async saveNote(t){const n=await this.getNotes(),r=Date.now(),i={...t,updated_at:r,created_at:t.created_at||r};i.id||(i.id=r);const o=n.findIndex(a=>a.id===i.id);o!==-1?n[o]=i:n.push(i),localStorage.setItem(this.NOTES_KEY,JSON.stringify(n))}static async deleteNote(t){const n=await this.getNotes(),r=n.findIndex(i=>i.id===t);if(r!==-1){const i={...n[r],deleted:!0,updated_at:Date.now()};n[r]=i,localStorage.setItem(this.NOTES_KEY,JSON.stringify(n))}}static async getSyncSettings(){const t=localStorage.getItem(this.SETTINGS_KEY);return t?JSON.parse(t):{auto_sync:!1,sync_interval:300,server_url:"https://notes-sync.toolworks.dev",custom_servers:[],seed_phrase:null}}static async saveSyncSettings(t){const r={...await this.getSyncSettings(),...t};localStorage.setItem(this.SETTINGS_KEY,JSON.stringify(r))}static async syncWithServer(t,n=3){if(!this.crypto)throw new Error("Crypto not initialized");let r=null;for(let i=0;i({...m,id:m.id||Date.now()})),c=await Promise.all(u.map(m=>this.crypto.encryptNote(m)));console.log("Encrypted notes:",c);const d=localStorage.getItem("user_id");if(!d)throw new Error("User ID not found");const f=await gy.syncNotes(t,d,c);console.log("Server response:",f);const p=await Promise.all(f.notes.map(async m=>await this.crypto.decryptNote(m)));console.log("Decrypted server notes:",p);const h=this.mergeNotes(u,p);console.log("Merged notes:",h),localStorage.setItem(this.NOTES_KEY,JSON.stringify(h));return}catch(o){if(console.error(`Sync attempt ${i+1} failed:`,o),r=o,isetTimeout(a,Math.pow(2,i)*1e3));continue}}throw r||new Error("Sync failed after retries")}static async getDeletedNotes(){const t=localStorage.getItem(this.NOTES_KEY);return(t?JSON.parse(t):[]).filter(r=>r.deleted)}static mergeNotes(t,n){const r=new Map;return t.forEach(i=>{i.id&&r.set(i.id,i)}),n.forEach(i=>{if(i.id){const o=r.get(i.id);i.deleted&&(!o||i.updated_at>o.updated_at)?r.delete(i.id):!i.deleted&&(!o||i.updated_at>o.updated_at)&&r.set(i.id,i)}}),Array.from(r.values()).sort((i,o)=>o.updated_at-i.updated_at)}}Jo(Rt,"NOTES_KEY","notes"),Jo(Rt,"SETTINGS_KEY","sync_settings"),Jo(Rt,"crypto",null);const Hd=[{label:"Official Server",value:"https://notes-sync.toolworks.dev"},{label:"Local Server",value:"http://localhost:3222"}];function yie({onSync:e}){const[t,n]=S.useState(""),[r,i]=S.useState(!1),[o,a]=S.useState(!1),[s,l]=S.useState(""),[u,c]=S.useState(!1),[d,f]=S.useState(Hd[0].value),[p,h]=S.useState([]),[m,y]=S.useState(""),[b,E]=S.useState(!1),[v,k]=S.useState(!1),_=H=>{try{return new URL(H),!0}catch{return!1}},x=H=>{y(H),k(_(H))},I=H=>{H.key==="Enter"&&v&&z()};S.useEffect(()=>{(async()=>{try{const B=await Rt.getSyncSettings();i(B.auto_sync),f(B.server_url),h(B.custom_servers||[]),n(B.seed_phrase??"")}catch(B){console.error("Failed to load settings:",B)}})()},[]);const R=async H=>{try{const B=await Rt.getSyncSettings(),M={auto_sync:"auto_sync"in H?H.auto_sync:r,server_url:"server_url"in H?H.server_url:d,custom_servers:"custom_servers"in H?H.custom_servers:p,seed_phrase:"seed_phrase"in H?H.seed_phrase:t,sync_interval:B.sync_interval};await Rt.saveSyncSettings(M)}catch{Qr.show({title:"Error",message:"Failed to save settings",color:"red"})}},z=async()=>{try{if(!v)return;if(p.includes(m)||Hd.some(B=>B.value===m)){Qr.show({title:"Error",message:"Server already exists",color:"red"});return}const H=[...p,m];h(H),f(m),await R({custom_servers:H,server_url:m}),y(""),E(!1),Qr.show({title:"Success",message:"Server added successfully",color:"green"})}catch{Qr.show({title:"Error",message:"Failed to add server",color:"red"})}},A=async H=>{const B=p.filter(M=>M!==H);if(h(B),await R({custom_servers:B}),d===H){const M=Hd[0].value;f(M),await R({server_url:M})}},j=async H=>{H&&(f(H),await R({server_url:H}))},L=async()=>{if(!t){Qr.show({title:"Error",message:"Please enter a seed phrase",color:"red"});return}c(!0);try{if(console.log("Starting sync process..."),await Rt.initializeCrypto(t),console.log("Crypto initialized"),!await gy.healthCheck(d))throw new Error(`Server ${d} is not healthy`);console.log("Server health check passed"),await Rt.syncWithServer(d),console.log("Sync completed"),await Rt.saveSyncSettings({seed_phrase:t}),console.log("Settings saved"),e&&await e(),Qr.show({title:"Success",message:"Notes synced successfully",color:"green"})}catch(H){console.error("Sync error:",H),Qr.show({title:"Error",message:H instanceof Error?H.message:"Failed to sync notes",color:"red",autoClose:!1})}finally{c(!1)}},U=async()=>{try{const H=qc.generateNewSeedPhrase();await Rt.initializeCrypto(H),l(H),n(H),await R({seed_phrase:H}),a(!0)}catch(H){console.error("Failed to generate seed phrase:",H),Qr.show({title:"Error",message:"Failed to generate seed phrase",color:"red"})}},V=[...Hd,...p.map(H=>({label:H,value:H,rightSection:T.jsx(ze,{size:"sm",color:"red",onClick:B=>{B.stopPropagation(),A(H)},children:T.jsx(xE,{size:14})})}))];return T.jsxs(Un,{children:[T.jsx(Pa,{p:"md",withBorder:!0,children:T.jsxs(Un,{children:[T.jsxs(it,{align:"flex-end",children:[T.jsx(TE,{label:"Sync Server",placeholder:"Select a server",data:V,value:d,onChange:j,style:{flex:1}}),T.jsx($t,{variant:"light",onClick:()=>E(!0),leftSection:T.jsx(hu,{size:16}),children:"Add Server"})]}),T.jsx(yE,{label:"Seed Phrase",description:"Enter your seed phrase to sync across devices",value:t,onChange:H=>{n(H.currentTarget.value),R({seed_phrase:H.currentTarget.value})}}),T.jsxs(it,{justify:"space-between",children:[T.jsx($t,{onClick:L,loading:u,children:"Sync Now"}),T.jsx($t,{variant:"light",onClick:U,children:"Generate New Seed Phrase"})]}),T.jsx(qh,{label:"Auto-sync",checked:r,onChange:H=>{i(H.currentTarget.checked),R({auto_sync:H.currentTarget.checked})}})]})}),T.jsx(Yn,{opened:b,onClose:()=>E(!1),title:"Add Custom Server",children:T.jsxs(Un,{children:[T.jsx(Ea,{label:"Server URL",description:"Enter the full URL of your sync server",placeholder:"https://your-server.com",value:m,onChange:H=>x(H.currentTarget.value),onKeyPress:I,error:m&&!v?"Please enter a valid URL":null}),T.jsxs(it,{justify:"flex-end",children:[T.jsx($t,{variant:"light",onClick:()=>E(!1),children:"Cancel"}),T.jsx($t,{onClick:z,disabled:!v,children:"Add Server"})]})]})}),T.jsx(Yn,{opened:o,onClose:()=>a(!1),title:"Your New Seed Phrase",children:T.jsxs(Un,{children:[T.jsx(qt,{fw:500,c:"red",children:"Important: Save this phrase somewhere safe. You'll need it to sync your notes across devices."}),T.jsx(Pa,{p:"md",withBorder:!0,children:T.jsx(qt,{children:s})}),T.jsx(it,{children:T.jsx(j2,{value:s,children:({copied:H,copy:B})=>T.jsx($t,{color:H?"teal":"blue",onClick:B,children:H?"Copied":"Copy"})})})]})})]})}function Eie(e,t){const n=S.useRef(),r=S.useRef(!1);S.useEffect(()=>{async function i(){if(!r.current)try{r.current=!0;const a=await Rt.getSyncSettings();if(!a.seed_phrase)throw new Error("No seed phrase configured");const s=await qc.new(a.seed_phrase),l=await Rt.getNotes(),u=await Promise.all(l.map(d=>s.encryptNote(d))),c=await fetch(`${a.server_url}/api/sync`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({public_key:await s.getPublicKeyBase64(),notes:u,client_version:"0.1.3"})});if(!c.ok)throw new Error(await c.text());Qr.show({title:"Auto-sync Complete",message:"Your notes have been synchronized",color:"green"})}catch(a){console.error("Auto-sync failed:",a),Qr.show({title:"Auto-sync Failed",message:a instanceof Error?a.message:"An unknown error occurred",color:"red"})}finally{r.current=!1}}function o(){e&&(n.current=window.setTimeout(()=>{i().finally(o)},t*60*1e3))}return o(),()=>{n.current&&clearTimeout(n.current)}},[e,t])}function vie({opened:e,onClose:t,onNewNote:n,onSearch:r,searchQuery:i,onToggleTheme:o,colorScheme:a,onShowSyncSettings:s,onExport:l,onImport:u,selectedNote:c,notes:d,onSelectNote:f,onDeleteNote:p}){const h=a==="dark"||a==="auto"&&window.matchMedia("(prefers-color-scheme: dark)").matches;return T.jsx(Fr,{opened:e,onClose:t,size:"100%",padding:"md",title:T.jsxs(it,{children:[T.jsx(Gu,{src:"/trusty.jpg",alt:"Logo",w:30,h:30}),T.jsx(qt,{size:"lg",fw:500,children:"Trusty Notes"})]}),children:T.jsxs(Un,{h:"100%",gap:"md",children:[T.jsx(Ea,{placeholder:"Search notes...",leftSection:T.jsx(rA,{size:16}),value:i,onChange:m=>r(m.currentTarget.value)}),T.jsx($t,{variant:"light",leftSection:T.jsx(hu,{size:16}),onClick:()=>{n(),t()},fullWidth:!0,children:"New Note"}),T.jsx(se,{style:{flex:1,overflowY:"auto"},children:T.jsx(Un,{gap:"xs",children:d.map(m=>T.jsx(Pa,{shadow:"xs",p:"md",onClick:()=>{f(m),t()},style:{cursor:"pointer",backgroundColor:(c==null?void 0:c.id)===m.id?"var(--mantine-color-blue-light)":void 0},children:T.jsxs(it,{justify:"space-between",wrap:"nowrap",children:[T.jsxs(se,{style:{flex:1},children:[T.jsx(qt,{fw:500,truncate:"end",children:m.title||"Untitled"}),T.jsx(qt,{size:"xs",c:"dimmed",children:vb(m.updated_at,"MMM d, yyyy HH:mm")})]}),T.jsx(ze,{variant:"subtle",color:"red",onClick:y=>{y.stopPropagation(),p(m.id)},children:T.jsx(xE,{size:16})})]})},m.id))})}),T.jsxs(Un,{gap:"xs",children:[T.jsx($t,{variant:"light",leftSection:h?T.jsx(xb,{size:16}):T.jsx(kb,{size:16}),onClick:o,fullWidth:!0,children:h?"Light Mode":"Dark Mode"}),T.jsx($t,{variant:"light",leftSection:T.jsx(tA,{size:16}),onClick:()=>{s(),t()},fullWidth:!0,children:"Sync Settings"}),T.jsxs(it,{grow:!0,children:[T.jsx($t,{variant:"light",leftSection:T.jsx(nA,{size:16}),onClick:l,children:"Export"}),T.jsx($t,{variant:"light",leftSection:T.jsx(iA,{size:16}),onClick:u,children:"Import"})]}),T.jsx($t,{variant:"subtle",leftSection:T.jsx(Tb,{size:16}),component:"a",href:"https://github.com/toolworks-dev/trusty-notes",target:"_blank",fullWidth:!0,children:"GitHub"})]})]})})}function Tie(){const[e,t]=S.useState([]),[n,r]=S.useState(null),[i,o]=S.useState(""),[a,s]=S.useState(""),[l,u]=S.useState(null),{colorScheme:c,toggleColorScheme:d}=L6(),[f,p]=S.useState(""),[h,m]=S.useState(!1),[y,b]=S.useState(!1),[E,v]=S.useState(null),k=b1("(max-width: 768px)"),[_,x]=S.useState(!1);S.useEffect(()=>{R()},[]);const I=e.filter(B=>B.title.toLowerCase().includes(f.toLowerCase())||B.content.toLowerCase().includes(f.toLowerCase())),R=async()=>{try{const B=await Rt.getNotes();t(B)}catch(B){console.error("Failed to fetch notes:",B)}},z=Tc(async()=>{if(!(i.trim()===""&&a.trim()==="")){u("saving");try{await L()}catch(B){console.error("Save failed:",B),u(null)}}},1e3);S.useEffect(()=>{(i||a)&&z()},[i,a]);function A(B){r(B),o(B.title),s(B.content)}function j(){r(null),o(""),s("")}S.useEffect(()=>{Rt.getSyncSettings().then(v)},[]),S.useEffect(()=>{(async()=>{if(k){const{initializeMobileApp:M}=await qz(async()=>{const{initializeMobileApp:N}=await import("./mobileInit-si7He02f.js").then(F=>F.m);return{initializeMobileApp:N}},[]);await M()}})()},[k]),Eie((E==null?void 0:E.auto_sync)??!1,(E==null?void 0:E.sync_interval)??5);async function L(){try{const B=Date.now(),M={id:n==null?void 0:n.id,title:i.trim()===""?"Untitled":i,content:a,created_at:(n==null?void 0:n.created_at)||B,updated_at:B};await Rt.saveNote(M),await R(),u("saved"),setTimeout(()=>u(null),2e3)}catch(B){console.error("Failed to save note:",B),u(null),alert(`Failed to save note: ${B}`)}}async function U(B){if(window.confirm("Are you sure you want to delete this note?"))try{await Rt.deleteNote(B),(n==null?void 0:n.id)===B&&j(),await R()}catch(M){console.error("Failed to delete note:",M),alert("Failed to delete note")}}async function V(){const B=await Rt.getNotes(),M=new Blob([JSON.stringify(B)],{type:"application/json"}),N=URL.createObjectURL(M),F=document.createElement("a");F.href=N,F.download=`notes-${vb(new Date,"yyyy-MM-dd")}.json`,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(N)}async function H(){const B=document.createElement("input");B.type="file",B.accept=".json",B.onchange=async M=>{var w;const N=(w=M.target.files)==null?void 0:w[0];if(!N)return;const F=new FileReader;F.onload=async q=>{var be;const X=(be=q.target)==null?void 0:be.result,D=JSON.parse(X);for(const ge of D)await Rt.saveNote(ge);await R()},F.readAsText(N)},B.click()}return T.jsxs(ur,{header:k?{height:60}:void 0,navbar:{width:k?0:h?80:300,breakpoint:"sm",collapsed:{mobile:!0}},padding:"0",children:[k&&T.jsx(ur.Header,{children:T.jsxs(it,{h:"100%",px:"md",justify:"space-between",children:[T.jsxs(it,{children:[T.jsx(mE,{opened:_,onClick:()=>x(B=>!B),hiddenFrom:"sm",size:"sm"}),T.jsx(Gu,{src:"/trusty.jpg",alt:"Logo",w:30,h:30})]}),T.jsx(Ea,{placeholder:"Note title",value:i,onChange:B=>o(B.currentTarget.value),style:{flex:1}}),T.jsxs(it,{children:[T.jsx(Wf,{href:"https://github.com/toolworks-dev/trusty-notes",target:"_blank",children:T.jsx(ze,{variant:"subtle",children:T.jsx(Tb,{size:20})})}),T.jsx(ze,{variant:"subtle",onClick:j,children:T.jsx(hu,{size:20})})]})]})}),k?T.jsx(vie,{opened:_,onClose:()=>x(!1),onNewNote:j,onSearch:p,searchQuery:f,onToggleTheme:d,colorScheme:c,onShowSyncSettings:()=>b(!0),onExport:V,onImport:H,selectedNote:n,notes:I,onSelectNote:A,onDeleteNote:U}):T.jsx(ur.Navbar,{p:"md",children:T.jsxs(Un,{h:"100%",gap:"sm",children:[T.jsxs(it,{justify:"space-between",children:[T.jsxs(it,{children:[T.jsx(Gu,{src:"/trusty.jpg",alt:"Logo",w:30,h:30}),T.jsx(qt,{size:"lg",fw:500,children:"Trusty Notes"})]}),T.jsxs(it,{children:[!h&&T.jsxs(T.Fragment,{children:[T.jsx(Qe,{label:"GitHub",children:T.jsx(Wf,{href:"https://github.com/toolworks-dev/trusty-notes",target:"_blank",children:T.jsx(ze,{variant:"default",size:30,children:T.jsx(Tb,{size:16})})})}),T.jsx(Qe,{label:"Sync Settings",children:T.jsx(ze,{variant:"default",onClick:()=>b(!0),size:30,children:T.jsx(tA,{size:16})})}),T.jsx(Qe,{label:"Toggle Theme",children:T.jsx(ze,{variant:"default",onClick:()=>d(),size:30,children:c==="dark"?T.jsx(xb,{size:16}):T.jsx(kb,{size:16})})}),T.jsx(Qe,{label:"Export Notes",children:T.jsx(ze,{variant:"default",onClick:V,size:30,children:T.jsx(nA,{size:16})})}),T.jsx(Qe,{label:"Import Notes",children:T.jsx(ze,{variant:"default",onClick:H,size:30,children:T.jsx(iA,{size:16})})})]}),T.jsx(Qe,{label:h?"Expand sidebar":"Collapse sidebar",children:T.jsx(ze,{variant:"default",onClick:()=>m(!h),size:30,children:h?T.jsx(rF,{size:16}):T.jsx(nF,{size:16})})})]})]}),!h&&T.jsxs(T.Fragment,{children:[T.jsx($t,{leftSection:T.jsx(hu,{size:14}),variant:"light",onClick:j,fullWidth:!0,children:"New Note"}),T.jsx(Ea,{placeholder:"Search notes...",leftSection:T.jsx(rA,{size:16}),value:f,onChange:B=>p(B.currentTarget.value)}),T.jsx(Un,{gap:"xs",style:{overflow:"auto",flex:1,minHeight:0},children:I.map(B=>T.jsx(Pa,{shadow:"xs",p:"md",onClick:()=>A(B),style:{cursor:"pointer",backgroundColor:(n==null?void 0:n.id)===B.id?"var(--mantine-color-blue-light)":void 0},children:T.jsxs(it,{justify:"space-between",wrap:"nowrap",children:[T.jsxs(se,{style:{flex:1},children:[T.jsx(qt,{fw:500,truncate:"end",children:B.title||"Untitled"}),T.jsx(qt,{size:"xs",c:"dimmed",children:vb(B.updated_at,"MMM d, yyyy HH:mm")})]}),T.jsx(ze,{variant:"subtle",color:"red",onClick:M=>{M.stopPropagation(),U(B.id)},children:T.jsx(xE,{size:16})})]})},B.id))})]}),h&&T.jsxs(Un,{gap:"xs",align:"center",children:[T.jsx(Qe,{label:"New Note",position:"right",children:T.jsx(ze,{variant:"light",onClick:j,size:"lg",children:T.jsx(hu,{size:20})})}),T.jsx(Qe,{label:"Toggle Theme",position:"right",children:T.jsx(ze,{variant:"light",onClick:()=>d(),size:"lg",children:c==="dark"?T.jsx(xb,{size:20}):T.jsx(kb,{size:20})})})]})]})}),T.jsx(ur.Main,{children:T.jsxs(Un,{h:"100vh",gap:0,children:[!k&&T.jsx(se,{p:"md",style:{borderBottom:"1px solid var(--mantine-color-gray-3)"},children:T.jsxs(it,{justify:"space-between",align:"center",children:[T.jsx(Ea,{placeholder:"Note title",value:i,onChange:B=>o(B.currentTarget.value),size:"lg",style:{flex:1}}),T.jsxs(it,{children:[l&&T.jsxs(it,{gap:"xs",children:[T.jsx(tF,{size:16,style:{color:"var(--mantine-color-green-6)"}}),T.jsx(qt,{size:"sm",c:"dimmed",children:l==="saving"?"Saving...":"Saved"})]}),T.jsx($t,{variant:"light",onClick:j,children:"New Note"})]})]})}),T.jsx(se,{style:{flex:1,position:"relative",minHeight:0,padding:k?"0.5rem":"1rem",paddingTop:k?"0.5rem":"1rem"},children:T.jsx(Cre,{content:a,onChange:s,isMobile:k,defaultView:"edit",editorType:"richtext"})})]})}),T.jsx(Yn,{opened:y,onClose:()=>b(!1),title:"Sync Settings",size:"lg",fullScreen:k,children:T.jsx(yie,{onSync:R})})]})}window.Buffer=Qi.Buffer;const kie={primaryColor:"blue"};u0.createRoot(document.getElementById("root")).render(T.jsx(Et.StrictMode,{children:T.jsx(SN,{theme:kie,defaultColorScheme:"auto",children:T.jsx(Tie,{})})}));export{qz as _}; diff --git a/android/app/src/main/assets/public/assets/mobileInit-BjDn5VWt.js b/android/app/src/main/assets/public/assets/mobileInit-si7He02f.js similarity index 79% rename from android/app/src/main/assets/public/assets/mobileInit-BjDn5VWt.js rename to android/app/src/main/assets/public/assets/mobileInit-si7He02f.js index 1bbcad4..9e7079d 100644 --- a/android/app/src/main/assets/public/assets/mobileInit-BjDn5VWt.js +++ b/android/app/src/main/assets/public/assets/mobileInit-si7He02f.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-KEPh1bJr.js","assets/index-DhE_q3AR.js","assets/buffer-Cq5fL-tY.js","assets/index-BHNR0Rya.css","assets/web-BBNafJl7.js"])))=>i.map(i=>d[i]); -import{_ as K}from"./index-DhE_q3AR.js";var _={};/*! Capacitor: https://capacitorjs.com/ - MIT License */const oe=t=>{const e=new Map;e.set("web",{name:"web"});const r=t.CapacitorPlatforms||{currentPlatform:{name:"web"},platforms:e},o=(n,a)=>{r.platforms.set(n,a)},i=n=>{r.platforms.has(n)&&(r.currentPlatform=r.platforms.get(n))};return r.addPlatform=o,r.setPlatform=i,r},ie=t=>t.CapacitorPlatforms=oe(t),V=ie(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof _<"u"?_:{});V.addPlatform;V.setPlatform;var E;(function(t){t.Unimplemented="UNIMPLEMENTED",t.Unavailable="UNAVAILABLE"})(E||(E={}));class S extends Error{constructor(e,r,o){super(e),this.message=e,this.code=r,this.data=o}}const ae=t=>{var e,r;return t!=null&&t.androidBridge?"android":!((r=(e=t==null?void 0:t.webkit)===null||e===void 0?void 0:e.messageHandlers)===null||r===void 0)&&r.bridge?"ios":"web"},le=t=>{var e,r,o,i,n;const a=t.CapacitorCustomPlatform||null,s=t.Capacitor||{},f=s.Plugins=s.Plugins||{},l=t.CapacitorPlatforms,k=()=>a!==null?a.name:ae(t),P=((e=l==null?void 0:l.currentPlatform)===null||e===void 0?void 0:e.getPlatform)||k,j=()=>P()!=="web",J=((r=l==null?void 0:l.currentPlatform)===null||r===void 0?void 0:r.isNativePlatform)||j,Q=c=>{const d=x.get(c);return!!(d!=null&&d.platforms.has(P())||I(c))},X=((o=l==null?void 0:l.currentPlatform)===null||o===void 0?void 0:o.isPluginAvailable)||Q,Y=c=>{var d;return(d=s.PluginHeaders)===null||d===void 0?void 0:d.find(y=>y.name===c)},I=((i=l==null?void 0:l.currentPlatform)===null||i===void 0?void 0:i.getPluginHeader)||Y,Z=c=>t.console.error(c),N=(c,d,y)=>Promise.reject(`${y} does not have an implementation of "${d}".`),x=new Map,ee=(c,d={})=>{const y=x.get(c);if(y)return console.warn(`Capacitor plugin "${c}" already registered. Cannot register plugins twice.`),y.proxy;const w=P(),L=I(c);let v;const re=async()=>(!v&&w in d?v=typeof d[w]=="function"?v=await d[w]():v=d[w]:a!==null&&!v&&"web"in d&&(v=typeof d.web=="function"?v=await d.web():v=d.web),v),ne=(u,m)=>{var h,p;if(L){const b=L==null?void 0:L.methods.find(g=>m===g.name);if(b)return b.rtype==="promise"?g=>s.nativePromise(c,m.toString(),g):(g,A)=>s.nativeCallback(c,m.toString(),g,A);if(u)return(h=u[m])===null||h===void 0?void 0:h.bind(u)}else{if(u)return(p=u[m])===null||p===void 0?void 0:p.bind(u);throw new S(`"${c}" plugin is not implemented on ${w}`,E.Unimplemented)}},U=u=>{let m;const h=(...p)=>{const b=re().then(g=>{const A=ne(g,u);if(A){const O=A(...p);return m=O==null?void 0:O.remove,O}else throw new S(`"${c}.${u}()" is not implemented on ${w}`,E.Unimplemented)});return u==="addListener"&&(b.remove=async()=>m()),b};return h.toString=()=>`${u.toString()}() { [capacitor code] }`,Object.defineProperty(h,"name",{value:u,writable:!1,configurable:!1}),h},H=U("addListener"),W=U("removeListener"),se=(u,m)=>{const h=H({eventName:u},m),p=async()=>{const g=await h;W({eventName:u,callbackId:g},m)},b=new Promise(g=>h.then(()=>g({remove:p})));return b.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await p()},b},D=new Proxy({},{get(u,m){switch(m){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return L?se:H;case"removeListener":return W;default:return U(m)}}});return f[c]=D,x.set(c,{name:c,proxy:D,platforms:new Set([...Object.keys(d),...L?[w]:[]])}),D},te=((n=l==null?void 0:l.currentPlatform)===null||n===void 0?void 0:n.registerPlugin)||ee;return s.convertFileSrc||(s.convertFileSrc=c=>c),s.getPlatform=P,s.handleError=Z,s.isNativePlatform=J,s.isPluginAvailable=X,s.pluginMethodNoop=N,s.registerPlugin=te,s.Exception=S,s.DEBUG=!!s.DEBUG,s.isLoggingEnabled=!!s.isLoggingEnabled,s.platform=s.getPlatform(),s.isNative=s.isNativePlatform(),s},ce=t=>t.Capacitor=le(t),$=ce(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof _<"u"?_:{}),C=$.registerPlugin;$.Plugins;class z{constructor(e){this.listeners={},this.retainedEventArguments={},this.windowListeners={},e&&(console.warn(`Capacitor WebPlugin "${e.name}" config object was deprecated in v3 and will be removed in v4.`),this.config=e)}addListener(e,r){let o=!1;this.listeners[e]||(this.listeners[e]=[],o=!0),this.listeners[e].push(r);const n=this.windowListeners[e];n&&!n.registered&&this.addWindowListener(n),o&&this.sendRetainedArgumentsForEvent(e);const a=async()=>this.removeListener(e,r);return Promise.resolve({remove:a})}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,r,o){const i=this.listeners[e];if(!i){if(o){let n=this.retainedEventArguments[e];n||(n=[]),n.push(r),this.retainedEventArguments[e]=n}return}i.forEach(n=>n(r))}hasListeners(e){return!!this.listeners[e].length}registerWindowListener(e,r){this.windowListeners[r]={registered:!1,windowEventName:e,pluginEventName:r,handler:o=>{this.notifyListeners(r,o)}}}unimplemented(e="not implemented"){return new $.Exception(e,E.Unimplemented)}unavailable(e="not available"){return new $.Exception(e,E.Unavailable)}async removeListener(e,r){const o=this.listeners[e];if(!o)return;const i=o.indexOf(r);this.listeners[e].splice(i,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}sendRetainedArgumentsForEvent(e){const r=this.retainedEventArguments[e];r&&(delete this.retainedEventArguments[e],r.forEach(o=>{this.notifyListeners(e,o)}))}}const R=t=>encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),F=t=>t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class de extends z{async getCookies(){const e=document.cookie,r={};return e.split(";").forEach(o=>{if(o.length<=0)return;let[i,n]=o.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");i=F(i).trim(),n=F(n).trim(),r[i]=n}),r}async setCookie(e){try{const r=R(e.key),o=R(e.value),i=`; expires=${(e.expires||"").replace("expires=","")}`,n=(e.path||"/").replace("path=",""),a=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${r}=${o||""}${i}; path=${n}; ${a};`}catch(r){return Promise.reject(r)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(r){return Promise.reject(r)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const r of e)document.cookie=r.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}C("CapacitorCookies",{web:()=>new de});const ue=async t=>new Promise((e,r)=>{const o=new FileReader;o.onload=()=>{const i=o.result;e(i.indexOf(",")>=0?i.split(",")[1]:i)},o.onerror=i=>r(i),o.readAsDataURL(t)}),fe=(t={})=>{const e=Object.keys(t);return Object.keys(t).map(i=>i.toLocaleLowerCase()).reduce((i,n,a)=>(i[n]=t[e[a]],i),{})},me=(t,e=!0)=>t?Object.entries(t).reduce((o,i)=>{const[n,a]=i;let s,f;return Array.isArray(a)?(f="",a.forEach(l=>{s=e?encodeURIComponent(l):l,f+=`${n}=${s}&`}),f.slice(0,-1)):(s=e?encodeURIComponent(a):a,f=`${n}=${s}`),`${o}&${f}`},"").substr(1):null,ge=(t,e={})=>{const r=Object.assign({method:t.method||"GET",headers:t.headers},e),i=fe(t.headers)["content-type"]||"";if(typeof t.data=="string")r.body=t.data;else if(i.includes("application/x-www-form-urlencoded")){const n=new URLSearchParams;for(const[a,s]of Object.entries(t.data||{}))n.set(a,s);r.body=n.toString()}else if(i.includes("multipart/form-data")||t.data instanceof FormData){const n=new FormData;if(t.data instanceof FormData)t.data.forEach((s,f)=>{n.append(f,s)});else for(const s of Object.keys(t.data))n.append(s,t.data[s]);r.body=n;const a=new Headers(r.headers);a.delete("content-type"),r.headers=a}else(i.includes("application/json")||typeof t.data=="object")&&(r.body=JSON.stringify(t.data));return r};class he extends z{async request(e){const r=ge(e,e.webFetchExtra),o=me(e.params,e.shouldEncodeUrlParams),i=o?`${e.url}?${o}`:e.url,n=await fetch(i,r),a=n.headers.get("content-type")||"";let{responseType:s="text"}=n.ok?e:{};a.includes("application/json")&&(s="json");let f,l;switch(s){case"arraybuffer":case"blob":l=await n.blob(),f=await ue(l);break;case"json":f=await n.json();break;case"document":case"text":default:f=await n.text()}const k={};return n.headers.forEach((P,j)=>{k[j]=P}),{data:f,headers:k,status:n.status,url:n.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}C("CapacitorHttp",{web:()=>new he});const ve=C("App",{web:()=>K(()=>import("./web-KEPh1bJr.js"),__vite__mapDeps([0,1,2,3])).then(t=>new t.AppWeb)});var T;(function(t){t.Dark="DARK",t.Light="LIGHT",t.Default="DEFAULT"})(T||(T={}));var M;(function(t){t.None="NONE",t.Slide="SLIDE",t.Fade="FADE"})(M||(M={}));const pe=C("StatusBar");var B;(function(t){t.Dark="DARK",t.Light="LIGHT",t.Default="DEFAULT"})(B||(B={}));var G;(function(t){t.Body="body",t.Ionic="ionic",t.Native="native",t.None="none"})(G||(G={}));const q=C("Keyboard"),be=C("Preferences",{web:()=>K(()=>import("./web-BBNafJl7.js"),__vite__mapDeps([4,1,2,3])).then(t=>new t.PreferencesWeb)}),we=async()=>{try{await pe.setStyle({style:T.Dark}),q.addListener("keyboardWillShow",()=>{document.body.classList.add("keyboard-visible")}),q.addListener("keyboardWillHide",()=>{document.body.classList.remove("keyboard-visible")}),ve.addListener("appStateChange",async({isActive:t})=>{t||await be.set({key:"lastActiveTime",value:new Date().toISOString()})})}catch(t){console.error("Error initializing mobile app:",t)}},ye=Object.freeze(Object.defineProperty({__proto__:null,initializeMobileApp:we},Symbol.toStringTag,{value:"Module"}));export{z as W,ye as m}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-DYjHHYsn.js","assets/index-B1frYiu1.js","assets/buffer-Cq5fL-tY.js","assets/index-BHNR0Rya.css","assets/web-DyTx0sUG.js"])))=>i.map(i=>d[i]); +import{_ as K}from"./index-B1frYiu1.js";var _={};/*! Capacitor: https://capacitorjs.com/ - MIT License */const oe=t=>{const e=new Map;e.set("web",{name:"web"});const r=t.CapacitorPlatforms||{currentPlatform:{name:"web"},platforms:e},o=(n,a)=>{r.platforms.set(n,a)},i=n=>{r.platforms.has(n)&&(r.currentPlatform=r.platforms.get(n))};return r.addPlatform=o,r.setPlatform=i,r},ie=t=>t.CapacitorPlatforms=oe(t),V=ie(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof _<"u"?_:{});V.addPlatform;V.setPlatform;var E;(function(t){t.Unimplemented="UNIMPLEMENTED",t.Unavailable="UNAVAILABLE"})(E||(E={}));class D extends Error{constructor(e,r,o){super(e),this.message=e,this.code=r,this.data=o}}const ae=t=>{var e,r;return t!=null&&t.androidBridge?"android":!((r=(e=t==null?void 0:t.webkit)===null||e===void 0?void 0:e.messageHandlers)===null||r===void 0)&&r.bridge?"ios":"web"},le=t=>{var e,r,o,i,n;const a=t.CapacitorCustomPlatform||null,s=t.Capacitor||{},f=s.Plugins=s.Plugins||{},l=t.CapacitorPlatforms,k=()=>a!==null?a.name:ae(t),P=((e=l==null?void 0:l.currentPlatform)===null||e===void 0?void 0:e.getPlatform)||k,x=()=>P()!=="web",J=((r=l==null?void 0:l.currentPlatform)===null||r===void 0?void 0:r.isNativePlatform)||x,Q=c=>{const d=j.get(c);return!!(d!=null&&d.platforms.has(P())||I(c))},X=((o=l==null?void 0:l.currentPlatform)===null||o===void 0?void 0:o.isPluginAvailable)||Q,Y=c=>{var d;return(d=s.PluginHeaders)===null||d===void 0?void 0:d.find(y=>y.name===c)},I=((i=l==null?void 0:l.currentPlatform)===null||i===void 0?void 0:i.getPluginHeader)||Y,Z=c=>t.console.error(c),N=(c,d,y)=>Promise.reject(`${y} does not have an implementation of "${d}".`),j=new Map,ee=(c,d={})=>{const y=j.get(c);if(y)return console.warn(`Capacitor plugin "${c}" already registered. Cannot register plugins twice.`),y.proxy;const w=P(),L=I(c);let v;const re=async()=>(!v&&w in d?v=typeof d[w]=="function"?v=await d[w]():v=d[w]:a!==null&&!v&&"web"in d&&(v=typeof d.web=="function"?v=await d.web():v=d.web),v),ne=(u,m)=>{var h,p;if(L){const b=L==null?void 0:L.methods.find(g=>m===g.name);if(b)return b.rtype==="promise"?g=>s.nativePromise(c,m.toString(),g):(g,A)=>s.nativeCallback(c,m.toString(),g,A);if(u)return(h=u[m])===null||h===void 0?void 0:h.bind(u)}else{if(u)return(p=u[m])===null||p===void 0?void 0:p.bind(u);throw new D(`"${c}" plugin is not implemented on ${w}`,E.Unimplemented)}},S=u=>{let m;const h=(...p)=>{const b=re().then(g=>{const A=ne(g,u);if(A){const O=A(...p);return m=O==null?void 0:O.remove,O}else throw new D(`"${c}.${u}()" is not implemented on ${w}`,E.Unimplemented)});return u==="addListener"&&(b.remove=async()=>m()),b};return h.toString=()=>`${u.toString()}() { [capacitor code] }`,Object.defineProperty(h,"name",{value:u,writable:!1,configurable:!1}),h},H=S("addListener"),W=S("removeListener"),se=(u,m)=>{const h=H({eventName:u},m),p=async()=>{const g=await h;W({eventName:u,callbackId:g},m)},b=new Promise(g=>h.then(()=>g({remove:p})));return b.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await p()},b},U=new Proxy({},{get(u,m){switch(m){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return L?se:H;case"removeListener":return W;default:return S(m)}}});return f[c]=U,j.set(c,{name:c,proxy:U,platforms:new Set([...Object.keys(d),...L?[w]:[]])}),U},te=((n=l==null?void 0:l.currentPlatform)===null||n===void 0?void 0:n.registerPlugin)||ee;return s.convertFileSrc||(s.convertFileSrc=c=>c),s.getPlatform=P,s.handleError=Z,s.isNativePlatform=J,s.isPluginAvailable=X,s.pluginMethodNoop=N,s.registerPlugin=te,s.Exception=D,s.DEBUG=!!s.DEBUG,s.isLoggingEnabled=!!s.isLoggingEnabled,s.platform=s.getPlatform(),s.isNative=s.isNativePlatform(),s},ce=t=>t.Capacitor=le(t),$=ce(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof _<"u"?_:{}),C=$.registerPlugin;$.Plugins;class z{constructor(e){this.listeners={},this.retainedEventArguments={},this.windowListeners={},e&&(console.warn(`Capacitor WebPlugin "${e.name}" config object was deprecated in v3 and will be removed in v4.`),this.config=e)}addListener(e,r){let o=!1;this.listeners[e]||(this.listeners[e]=[],o=!0),this.listeners[e].push(r);const n=this.windowListeners[e];n&&!n.registered&&this.addWindowListener(n),o&&this.sendRetainedArgumentsForEvent(e);const a=async()=>this.removeListener(e,r);return Promise.resolve({remove:a})}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,r,o){const i=this.listeners[e];if(!i){if(o){let n=this.retainedEventArguments[e];n||(n=[]),n.push(r),this.retainedEventArguments[e]=n}return}i.forEach(n=>n(r))}hasListeners(e){return!!this.listeners[e].length}registerWindowListener(e,r){this.windowListeners[r]={registered:!1,windowEventName:e,pluginEventName:r,handler:o=>{this.notifyListeners(r,o)}}}unimplemented(e="not implemented"){return new $.Exception(e,E.Unimplemented)}unavailable(e="not available"){return new $.Exception(e,E.Unavailable)}async removeListener(e,r){const o=this.listeners[e];if(!o)return;const i=o.indexOf(r);this.listeners[e].splice(i,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}sendRetainedArgumentsForEvent(e){const r=this.retainedEventArguments[e];r&&(delete this.retainedEventArguments[e],r.forEach(o=>{this.notifyListeners(e,o)}))}}const R=t=>encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),F=t=>t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class de extends z{async getCookies(){const e=document.cookie,r={};return e.split(";").forEach(o=>{if(o.length<=0)return;let[i,n]=o.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");i=F(i).trim(),n=F(n).trim(),r[i]=n}),r}async setCookie(e){try{const r=R(e.key),o=R(e.value),i=`; expires=${(e.expires||"").replace("expires=","")}`,n=(e.path||"/").replace("path=",""),a=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${r}=${o||""}${i}; path=${n}; ${a};`}catch(r){return Promise.reject(r)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(r){return Promise.reject(r)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const r of e)document.cookie=r.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}C("CapacitorCookies",{web:()=>new de});const ue=async t=>new Promise((e,r)=>{const o=new FileReader;o.onload=()=>{const i=o.result;e(i.indexOf(",")>=0?i.split(",")[1]:i)},o.onerror=i=>r(i),o.readAsDataURL(t)}),fe=(t={})=>{const e=Object.keys(t);return Object.keys(t).map(i=>i.toLocaleLowerCase()).reduce((i,n,a)=>(i[n]=t[e[a]],i),{})},me=(t,e=!0)=>t?Object.entries(t).reduce((o,i)=>{const[n,a]=i;let s,f;return Array.isArray(a)?(f="",a.forEach(l=>{s=e?encodeURIComponent(l):l,f+=`${n}=${s}&`}),f.slice(0,-1)):(s=e?encodeURIComponent(a):a,f=`${n}=${s}`),`${o}&${f}`},"").substr(1):null,ge=(t,e={})=>{const r=Object.assign({method:t.method||"GET",headers:t.headers},e),i=fe(t.headers)["content-type"]||"";if(typeof t.data=="string")r.body=t.data;else if(i.includes("application/x-www-form-urlencoded")){const n=new URLSearchParams;for(const[a,s]of Object.entries(t.data||{}))n.set(a,s);r.body=n.toString()}else if(i.includes("multipart/form-data")||t.data instanceof FormData){const n=new FormData;if(t.data instanceof FormData)t.data.forEach((s,f)=>{n.append(f,s)});else for(const s of Object.keys(t.data))n.append(s,t.data[s]);r.body=n;const a=new Headers(r.headers);a.delete("content-type"),r.headers=a}else(i.includes("application/json")||typeof t.data=="object")&&(r.body=JSON.stringify(t.data));return r};class he extends z{async request(e){const r=ge(e,e.webFetchExtra),o=me(e.params,e.shouldEncodeUrlParams),i=o?`${e.url}?${o}`:e.url,n=await fetch(i,r),a=n.headers.get("content-type")||"";let{responseType:s="text"}=n.ok?e:{};a.includes("application/json")&&(s="json");let f,l;switch(s){case"arraybuffer":case"blob":l=await n.blob(),f=await ue(l);break;case"json":f=await n.json();break;case"document":case"text":default:f=await n.text()}const k={};return n.headers.forEach((P,x)=>{k[x]=P}),{data:f,headers:k,status:n.status,url:n.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}C("CapacitorHttp",{web:()=>new he});const ve=C("App",{web:()=>K(()=>import("./web-DYjHHYsn.js"),__vite__mapDeps([0,1,2,3])).then(t=>new t.AppWeb)});var T;(function(t){t.Dark="DARK",t.Light="LIGHT",t.Default="DEFAULT"})(T||(T={}));var M;(function(t){t.None="NONE",t.Slide="SLIDE",t.Fade="FADE"})(M||(M={}));const pe=C("StatusBar");var B;(function(t){t.Dark="DARK",t.Light="LIGHT",t.Default="DEFAULT"})(B||(B={}));var q;(function(t){t.Body="body",t.Ionic="ionic",t.Native="native",t.None="none"})(q||(q={}));const G=C("Keyboard"),be=C("Preferences",{web:()=>K(()=>import("./web-DyTx0sUG.js"),__vite__mapDeps([4,1,2,3])).then(t=>new t.PreferencesWeb)}),we=async()=>{try{await pe.setStyle({style:T.Dark});const t=document.querySelector("meta[name=viewport]");t&&t.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"),G.addListener("keyboardWillShow",()=>{document.body.classList.add("keyboard-visible")}),G.addListener("keyboardWillHide",()=>{document.body.classList.remove("keyboard-visible")}),ve.addListener("appStateChange",async({isActive:e})=>{e||await be.set({key:"lastActiveTime",value:new Date().toISOString()})})}catch(t){console.error("Error initializing mobile app:",t)}},ye=Object.freeze(Object.defineProperty({__proto__:null,initializeMobileApp:we},Symbol.toStringTag,{value:"Module"}));export{z as W,ye as m}; diff --git a/android/app/src/main/assets/public/assets/web-KEPh1bJr.js b/android/app/src/main/assets/public/assets/web-DYjHHYsn.js similarity index 82% rename from android/app/src/main/assets/public/assets/web-KEPh1bJr.js rename to android/app/src/main/assets/public/assets/web-DYjHHYsn.js index bd2a265..bd6bd9c 100644 --- a/android/app/src/main/assets/public/assets/web-KEPh1bJr.js +++ b/android/app/src/main/assets/public/assets/web-DYjHHYsn.js @@ -1 +1 @@ -import{W as t}from"./mobileInit-BjDn5VWt.js";import"./index-DhE_q3AR.js";import"./buffer-Cq5fL-tY.js";class r extends t{constructor(){super(),this.handleVisibilityChange=()=>{const e={isActive:document.hidden!==!0};this.notifyListeners("appStateChange",e),document.hidden?this.notifyListeners("pause",null):this.notifyListeners("resume",null)},document.addEventListener("visibilitychange",this.handleVisibilityChange,!1)}exitApp(){throw this.unimplemented("Not implemented on web.")}async getInfo(){throw this.unimplemented("Not implemented on web.")}async getLaunchUrl(){return{url:""}}async getState(){return{isActive:document.hidden!==!0}}async minimizeApp(){throw this.unimplemented("Not implemented on web.")}}export{r as AppWeb}; +import{W as t}from"./mobileInit-si7He02f.js";import"./index-B1frYiu1.js";import"./buffer-Cq5fL-tY.js";class r extends t{constructor(){super(),this.handleVisibilityChange=()=>{const e={isActive:document.hidden!==!0};this.notifyListeners("appStateChange",e),document.hidden?this.notifyListeners("pause",null):this.notifyListeners("resume",null)},document.addEventListener("visibilitychange",this.handleVisibilityChange,!1)}exitApp(){throw this.unimplemented("Not implemented on web.")}async getInfo(){throw this.unimplemented("Not implemented on web.")}async getLaunchUrl(){return{url:""}}async getState(){return{isActive:document.hidden!==!0}}async minimizeApp(){throw this.unimplemented("Not implemented on web.")}}export{r as AppWeb}; diff --git a/android/app/src/main/assets/public/assets/web-BBNafJl7.js b/android/app/src/main/assets/public/assets/web-DyTx0sUG.js similarity index 90% rename from android/app/src/main/assets/public/assets/web-BBNafJl7.js rename to android/app/src/main/assets/public/assets/web-DyTx0sUG.js index 63bd83f..b3af619 100644 --- a/android/app/src/main/assets/public/assets/web-BBNafJl7.js +++ b/android/app/src/main/assets/public/assets/web-DyTx0sUG.js @@ -1 +1 @@ -import{W as l}from"./mobileInit-BjDn5VWt.js";import"./index-DhE_q3AR.js";import"./buffer-Cq5fL-tY.js";class h extends l{constructor(){super(...arguments),this.group="CapacitorStorage"}async configure({group:e}){typeof e=="string"&&(this.group=e)}async get(e){return{value:this.impl.getItem(this.applyPrefix(e.key))}}async set(e){this.impl.setItem(this.applyPrefix(e.key),e.value)}async remove(e){this.impl.removeItem(this.applyPrefix(e.key))}async keys(){return{keys:this.rawKeys().map(t=>t.substring(this.prefix.length))}}async clear(){for(const e of this.rawKeys())this.impl.removeItem(e)}async migrate(){var e;const t=[],s=[],n="_cap_",o=Object.keys(this.impl).filter(i=>i.indexOf(n)===0);for(const i of o){const r=i.substring(n.length),a=(e=this.impl.getItem(i))!==null&&e!==void 0?e:"",{value:p}=await this.get({key:r});typeof p=="string"?s.push(r):(await this.set({key:r,value:a}),t.push(r))}return{migrated:t,existing:s}}async removeOld(){const e="_cap_",t=Object.keys(this.impl).filter(s=>s.indexOf(e)===0);for(const s of t)this.impl.removeItem(s)}get impl(){return window.localStorage}get prefix(){return this.group==="NativeStorage"?"":`${this.group}.`}rawKeys(){return Object.keys(this.impl).filter(e=>e.indexOf(this.prefix)===0)}applyPrefix(e){return this.prefix+e}}export{h as PreferencesWeb}; +import{W as l}from"./mobileInit-si7He02f.js";import"./index-B1frYiu1.js";import"./buffer-Cq5fL-tY.js";class h extends l{constructor(){super(...arguments),this.group="CapacitorStorage"}async configure({group:e}){typeof e=="string"&&(this.group=e)}async get(e){return{value:this.impl.getItem(this.applyPrefix(e.key))}}async set(e){this.impl.setItem(this.applyPrefix(e.key),e.value)}async remove(e){this.impl.removeItem(this.applyPrefix(e.key))}async keys(){return{keys:this.rawKeys().map(t=>t.substring(this.prefix.length))}}async clear(){for(const e of this.rawKeys())this.impl.removeItem(e)}async migrate(){var e;const t=[],s=[],n="_cap_",o=Object.keys(this.impl).filter(i=>i.indexOf(n)===0);for(const i of o){const r=i.substring(n.length),a=(e=this.impl.getItem(i))!==null&&e!==void 0?e:"",{value:p}=await this.get({key:r});typeof p=="string"?s.push(r):(await this.set({key:r,value:a}),t.push(r))}return{migrated:t,existing:s}}async removeOld(){const e="_cap_",t=Object.keys(this.impl).filter(s=>s.indexOf(e)===0);for(const s of t)this.impl.removeItem(s)}get impl(){return window.localStorage}get prefix(){return this.group==="NativeStorage"?"":`${this.group}.`}rawKeys(){return Object.keys(this.impl).filter(e=>e.indexOf(this.prefix)===0)}applyPrefix(e){return this.prefix+e}}export{h as PreferencesWeb}; diff --git a/android/app/src/main/assets/public/index.html b/android/app/src/main/assets/public/index.html index 9a1bc6c..c9281ac 100644 --- a/android/app/src/main/assets/public/index.html +++ b/android/app/src/main/assets/public/index.html @@ -8,7 +8,7 @@ Trusty Notes - + diff --git a/android/capacitor-cordova-android-plugins/build.gradle b/android/capacitor-cordova-android-plugins/build.gradle index f30661e..2d9d0f2 100644 --- a/android/capacitor-cordova-android-plugins/build.gradle +++ b/android/capacitor-cordova-android-plugins/build.gradle @@ -9,7 +9,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:8.7.2' + classpath 'com.android.tools.build:gradle:8.2.1' } } @@ -19,16 +19,18 @@ android { namespace "capacitor.cordova.android.plugins" compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34 defaultConfig { - minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23 + minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22 targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34 + versionCode 1 + versionName "1.0" + } + lintOptions { + abortOnError false } compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } - lint { - abortOnError false - } } repositories { diff --git a/android/capacitor-cordova-android-plugins/cordova.variables.gradle b/android/capacitor-cordova-android-plugins/cordova.variables.gradle index c91fae7..5b55884 100644 --- a/android/capacitor-cordova-android-plugins/cordova.variables.gradle +++ b/android/capacitor-cordova-android-plugins/cordova.variables.gradle @@ -1,6 +1,6 @@ // DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN ext { - cdvMinSdkVersion = project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23 + cdvMinSdkVersion = project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22 // Plugin gradle extensions can append to this to have code run at the end. cdvPluginPostBuildExtras = [] cordovaConfig = [:] diff --git a/src/components/RichTextEditor.tsx b/src/components/RichTextEditor.tsx index 9c0dd52..fceadbc 100644 --- a/src/components/RichTextEditor.tsx +++ b/src/components/RichTextEditor.tsx @@ -44,13 +44,14 @@ export function RichTextEditor({ content, onChange }: RichTextEditorProps) { editorProps: { attributes: { class: 'rich-text-editor', + style: 'height: 100%' }, }, }); useEffect(() => { if (editor && content !== editor.getHTML()) { - editor.commands.setContent(content); + editor.commands.setContent(content, false); } }, [content, editor]); diff --git a/src/styles/mobile.css b/src/styles/mobile.css index 21d3d8d..eb293c0 100644 --- a/src/styles/mobile.css +++ b/src/styles/mobile.css @@ -11,8 +11,10 @@ padding-top: var(--ion-safe-area-top); padding-bottom: var(--ion-safe-area-bottom); background-color: var(--mantine-color-body); + height: 100vh; + overflow: hidden; } - + .keyboard-visible .markdown-editor { max-height: calc(100vh - 270px); } @@ -23,6 +25,24 @@ overflow-x: hidden; -webkit-text-size-adjust: 100%; } + + .android .ProseMirror { + min-height: 50vh; + height: calc(100vh - 200px); + overflow-y: auto; + -webkit-overflow-scrolling: touch; + } + + .android .rich-text-editor { + display: flex; + flex-direction: column; + height: calc(100vh - 120px); + } + + .android .mantine-AppShell-main { + height: 100vh; + overflow: hidden; + } .mantine-AppShell-main { padding: 2px !important;